:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-2: #0d1422;
  --card: #111a2b;
  --card-2: #162033;
  --line: rgba(186, 206, 236, 0.12);
  --text: #e8eef8;
  --muted: #8ea0bb;
  --faint: #66758d;
  --blue: #7aafff;
  --blue-dim: rgba(122, 175, 255, 0.14);
  --green: #3dce8a;
  --green-dim: rgba(61, 206, 138, 0.14);
  --red: #ff6d6d;
  --red-dim: rgba(255, 109, 109, 0.14);
  --gold: #e6c15a;
  --btc: #f0a04b;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  --nav: 68px;
  --radius: 18px;
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-2: #f7f9fc;
  --line: rgba(18, 36, 64, 0.1);
  --text: #142033;
  --muted: #5d6d86;
  --faint: #7d8ba0;
  --blue: #2f6fe0;
  --blue-dim: rgba(47, 111, 224, 0.1);
  --green: #0e8f55;
  --green-dim: rgba(14, 143, 85, 0.1);
  --red: #d23b3b;
  --red-dim: rgba(210, 59, 59, 0.1);
  --gold: #9a7420;
  --btc: #c47a22;
  --shadow: 0 10px 28px rgba(20, 40, 70, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  background:
    radial-gradient(900px 420px at 100% -8%, rgba(88, 140, 255, 0.16), transparent 58%),
    radial-gradient(700px 380px at 0% 12%, rgba(28, 64, 120, 0.18), transparent 52%),
    var(--bg);
}
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.num {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

.app {
  width: min(480px, 100%);
  margin-inline: auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 12px);
}

.top {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}
.brand { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.icon-btn, .text-btn, .primary, .ghost, .danger {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  min-height: 44px;
  padding: 0 14px;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  min-height: 32px;
  padding: 0;
}
.refresh-btn svg { width: 15px; height: 15px; }
.icon-btn { width: 44px; padding: 0; display: grid; place-items: center; background: transparent; border-color: transparent; }
button.primary {
  background: #3d7eff;
  color: #fff;
  border-color: transparent;
  font-weight: 700;
  width: 100%;
  min-height: 48px;
}
html[data-theme="light"] .primary { color: #fff; }
.ghost { background: transparent; }
.danger { background: var(--red-dim); color: var(--red); border-color: transparent; }
.text-btn { background: transparent; color: var(--blue); border: 0; padding-inline: 0; min-height: 36px; }
button:disabled { opacity: 0.55; cursor: default; }
button:active:not(:disabled) { transform: scale(0.98); }

.view { padding: 4px 16px 16px; display: grid; gap: 12px; }
.view.is-enter { animation: page-in 180ms ease; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.banner, .empty, .error-box, .lock {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--card);
}
.banner.warn { border-color: rgba(230, 193, 90, 0.35); background: rgba(230, 193, 90, 0.08); }
.error-box { display: grid; gap: 10px; }
.empty { text-align: center; display: grid; gap: 8px; justify-items: center; padding: 28px 16px; }
.empty p, .muted { color: var(--muted); margin: 0; }
.empty h3, .section h3, .card h2, .sheet h3 { margin: 0; font-weight: 650; }

.card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 46%),
    var(--card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
  padding: 16px;
  display: grid;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.card-hero { padding: 18px 16px 16px; gap: 14px; }
.card-compact { padding: 14px; gap: 8px; }
.card-compact .price b { font-size: 26px; }
.card-hero .price b { font-size: clamp(34px, 10vw, 44px); letter-spacing: -0.04em; }
.card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 4px;
  background: var(--accent, var(--blue));
}
.asset-dollar_tomorrow { --accent: var(--blue); }
.asset-tether { --accent: var(--green); }
.asset-bitcoin { --accent: var(--btc); }
.asset-gold { --accent: var(--gold); }

.card-h, .row, .spread, .nav, .plan, .entry, .alert, .pair {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.id { display: flex; gap: 10px; align-items: center; min-width: 0; }
.mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 700;
  background: color-mix(in srgb, var(--accent, var(--blue)) 16%, var(--card));
  color: var(--accent, var(--blue));
  flex: 0 0 auto;
}
.src, .fresh, .hint { color: var(--faint); font-size: 12px; margin: 0; }
.price-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.spark { width: 112px; height: 36px; flex: 0 0 auto; }
.price { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.price b { font-size: clamp(28px, 8vw, 36px); font-weight: 700; letter-spacing: -0.04em; }
.tick-up [data-field="price"] { color: var(--green); }
.tick-down [data-field="price"] { color: var(--red); }
.market-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 4px; }
.market-head h2, .kicker { margin: 0; }
.kicker { color: var(--muted); font-size: 12px; font-weight: 500; }
.market-head h2 { font-size: 22px; font-weight: 700; }
.status, .fresh { display: flex; align-items: center; gap: 6px; }
.status i, .fresh i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.status.is-stale i, .fresh.stale i { background: var(--gold); }
.market-list { display: grid; gap: 12px; }
.price span, .delta span:last-child { color: var(--muted); font-size: 13px; }
.delta { display: flex; gap: 8px; align-items: center; font-weight: 650; }
.up { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--muted); }
.trend {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.trend.up { background: var(--green-dim); }
.trend.down { background: var(--red-dim); }
.meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}
.meta div, .stat {
  background: var(--card-2);
  border-radius: 12px;
  padding: 8px 10px;
}
.meta dt, .stat span { color: var(--muted); font-size: 11px; }
.meta dd { margin: 2px 0 0; font-weight: 650; }
.meta .wide { grid-column: 1 / -1; }
.fresh.stale { color: var(--gold); }

.section { display: grid; gap: 10px; }
.table {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, minmax(0, 1fr));
  gap: 8px 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
  width: 100%;
}
.table b, .table span { min-width: 0; text-align: center; }
.table b { font-weight: 500; color: var(--muted); }
.table .name, .table b:first-child { text-align: start; font-weight: 650; }
.table .num { width: 100%; text-align: center; }
.pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.ranges {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  overflow: visible;
}
.pills::-webkit-scrollbar, .ranges::-webkit-scrollbar { display: none; }
.pills button, .ranges button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  min-height: 32px;
  padding: 0 4px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}
.pills button.on, .ranges button.on {
  background: var(--blue-dim);
  color: var(--blue);
  border-color: transparent;
  font-weight: 700;
}
.chart-box { min-height: 168px; }
.chart-svg { width: 100%; height: 160px; display: block; touch-action: none; }
.chart-tip {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}
.chart-box { position: relative; }

.movers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.movers .stat { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.movers .stat strong { white-space: normal; display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; }
.book { gap: 6px; padding: 10px 12px; }
.book p { margin: 0; font-size: 13px; }
.book-top { width: 100%; }
.book-date { color: var(--muted); font-size: 12px; }
.pnl { display: grid; gap: 2px; font-size: 13px; font-weight: 650; }
.pnl-title { font-size: 12px; font-weight: 500; }
.pnl-row { display: flex; justify-content: space-between; gap: 8px; }
.date-btn { text-align: right; }
.jalali { border: 1px solid var(--line); border-radius: 14px; padding: 8px; display: grid; gap: 6px; }
.jalali-head { display: flex; align-items: center; justify-content: space-between; }
.jalali-head button { min-height: 36px; width: 36px; border: 0; background: transparent; font-size: 18px; }
.jalali-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.jalali-week { color: var(--muted); font-size: 12px; }
.jday { min-height: 34px; border: 0; background: transparent; border-radius: 8px; padding: 0; }
.jday.on { background: #3d7eff; color: #fff; }
.report-foot { display: grid; gap: 2px; }
.report-foot p { margin: 0; }
.vol-line { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.vol-note { font-size: 11px; color: var(--faint); line-height: 1.35; }
.vdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; flex: 0 0 auto; }

.alert, .entry, .plan {
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
}
.alert, .entry { flex-direction: column; }
.alert header, .entry header { display: flex; justify-content: space-between; gap: 8px; width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .ghost { min-height: 36px; font-size: 12px; padding-inline: 8px; }
.actions button { flex: 1; }
.switch {
  width: 46px; height: 28px; border-radius: 999px; border: 0; padding: 2px;
  background: #2a3548; display: flex; align-items: center;
}
.switch.on { background: var(--green); justify-content: flex-end; }
.switch i { width: 24px; height: 24px; border-radius: 50%; background: white; display: block; }

.admin-screen { padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 16px); }
.admin-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.admin-kicker { margin: 0 0 2px; color: var(--blue); font-size: 12px; font-weight: 700; }
.admin-header h2 { margin: 0; font-size: 22px; }
.admin-badge {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}
.admin-back { width: auto; margin-bottom: 4px; }
.admin-tabs--grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.admin-tile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  text-align: start;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(180deg, rgba(255,255,255,0.035), transparent 50%), var(--card);
  border-radius: 16px;
  padding: 12px;
}
.admin-tabs--grid { grid-template-columns: 1fr; }
.admin-ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--blue-dim); color: var(--blue); }
.admin-ico svg { width: 18px; height: 18px; }
.admin-copy { display: grid; gap: 2px; min-width: 0; }
.admin-copy small { color: var(--muted); font-size: 12px; font-weight: 500; }
.admin-tile em { color: var(--blue); font-style: normal; font-weight: 700; }
.admin-tab {
  min-height: 78px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 10px 6px;
}
.admin-tab span { line-height: 1.3; }
.admin-tab.active {
  border-color: transparent;
  background: var(--blue-dim);
  color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}
.admin-page--section .admin-tabs--grid { display: none; }
.admin-tab-panel { display: grid; gap: 10px; }
.admin-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.admin-stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 8px;
  text-align: center;
}
.admin-stat span { font-size: 22px; font-weight: 700; }
.admin-stat small { color: var(--muted); font-size: 12px; }
.nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  width: min(480px, 100%);
  margin-inline: auto;
  height: calc(var(--nav) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  justify-content: space-around;
}
.nav button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--faint);
  min-height: 48px;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  font-size: 10px;
  padding: 0 2px;
}
.nav button.on {
  color: var(--blue);
  font-weight: 700;
  background: var(--blue-dim);
  border-radius: 14px;
}
.nav svg { width: 22px; height: 22px; }

.sheet, .modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(4, 8, 16, 0.62);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal { align-items: center; padding: 16px; }
.panel {
  width: min(480px, 100%);
  max-height: min(92dvh, 760px);
  overflow: auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
  animation: rise 180ms ease;
}
.modal .panel { border-radius: 18px; width: min(400px, 100%); animation: pop 160ms ease; }
.handle { width: 42px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 4px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
}
button.ghost { color: var(--text); background: transparent; }
button.primary, .tools button.primary {
  background: #3d7eff;
  color: #fff;
  justify-content: center;
  text-align: center;
}
html[data-theme="light"] button.primary,
html[data-theme="light"] .tools button.primary { color: #fff; background: #3d7eff; }
html[data-theme="light"] button.ghost,
html[data-theme="light"] .tools button.ghost { color: var(--text); background: transparent; }
html[data-theme="light"] .switch { background: #d5deea; }
html[data-theme="light"] .switch.on { background: #0e8f55; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.setting-row .switch { width: 48px; min-height: 28px; flex: 0 0 auto; }
textarea { min-height: 80px; resize: vertical; }
select {
  appearance: none;
  text-align: right;
  padding-inline-start: 40px;
  padding-inline-end: 14px;
  background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238ea0bb' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}
.field-error { color: var(--red); font-size: 12px; margin: 0; }
.plans { display: grid; gap: 8px; }
.plan { cursor: pointer; text-align: start; }
.plan.on { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.plan b { font-size: 16px; }
.sub-box { padding: 12px 14px; gap: 8px; }
.sub-box::before { display: none; }
.sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  line-height: 1.4;
}
.sub-row span { color: var(--muted); }
.sub-row strong { color: var(--text); font-weight: 650; white-space: nowrap; }
.sub-box .primary { min-height: 42px; margin-top: 4px; }
.profile {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  padding: 8px 0 4px;
}
.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--blue-dim);
  color: var(--blue);
  display: grid; place-items: center;
  font-size: 26px; font-weight: 700;
  position: relative;
  overflow: hidden;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tools { display: grid; gap: 8px; }
.tools button, .link-row {
  width: 100%;
  text-align: start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 52px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tools button.primary,
button.primary {
  background: #3d7eff;
  color: #fff;
  border-color: transparent;
  justify-content: center;
  text-align: center;
}
.tools button.ghost,
button.ghost {
  background: transparent;
  color: var(--text);
  justify-content: center;
  text-align: center;
}
.tools button.danger,
button.danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: transparent;
  justify-content: center;
  text-align: center;
}
html[data-theme="light"] .tools button.primary,
html[data-theme="light"] button.primary { color: #fff; background: #3d7eff; }
html[data-theme="light"] .tools button.ghost,
html[data-theme="light"] button.ghost,
html[data-theme="light"] .jalali-head button,
html[data-theme="light"] .jday { color: var(--text); }
html[data-theme="light"] .jday.on,
html[data-theme="dark"] .jday.on { color: #fff; background: #3d7eff; }
.toast {
  position: fixed;
  z-index: 40;
  inset-inline: 16px;
  bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 12px);
  width: min(448px, calc(100% - 32px));
  margin-inline: auto;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.skel-hero { height: 220px; }
.skel {
  height: 148px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}
.hidden { display: none; }

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0.6; } }
@keyframes pop { from { transform: scale(0.98); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 720px) {
  body { background: #05080f; }
  html[data-theme="light"] body { background: #e7edf5; }
  .app { border-inline: 1px solid var(--line); min-height: 100dvh; background: var(--bg); }
}
