:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050608;
  --bg-elevated: #0c0e14;
  --surface: rgba(18, 20, 28, 0.72);
  --surface-hover: rgba(28, 32, 44, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --text: #f4f6fb;
  --text-muted: #8b93a8;
  --accent: #3ee0b8;
  --accent-hover: #5ef0cc;
  --accent-violet: #8b7cf8;
  --accent-muted: rgba(62, 224, 184, 0.14);
  --accent-glow: rgba(62, 224, 184, 0.35);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --warn: #f5b942;
  --warn-bg: rgba(245, 185, 66, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --card-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  --chart-line: #3ee0b8;
  --chart-fill: rgba(62, 224, 184, 0.12);
  --chart-grid: rgba(255, 255, 255, 0.05);
  --top-bg: rgba(5, 6, 8, 0.72);
  --nav-bg: rgba(255, 255, 255, 0.04);
  --mesh-1: rgba(62, 224, 184, 0.09);
  --mesh-2: rgba(139, 124, 248, 0.1);
  --mesh-3: rgba(59, 130, 246, 0.06);
  --radius-lg: 20px;
  --radius-md: 14px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f8;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-hover: #f3f6fc;
  --border: rgba(20, 24, 40, 0.08);
  --border-subtle: rgba(20, 24, 40, 0.05);
  --text: #0f1219;
  --text-muted: #5e6678;
  --accent: #0d9f7a;
  --accent-hover: #0b8668;
  --accent-violet: #6d5ce8;
  --accent-muted: rgba(13, 159, 122, 0.12);
  --accent-glow: rgba(13, 159, 122, 0.2);
  --success: #15803d;
  --success-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fff8eb;
  --shadow: 0 20px 50px rgba(15, 18, 25, 0.08);
  --card-shadow: 0 12px 40px rgba(15, 18, 25, 0.06);
  --chart-line: #0d9f7a;
  --chart-fill: rgba(13, 159, 122, 0.1);
  --chart-grid: rgba(15, 18, 25, 0.06);
  --top-bg: rgba(238, 241, 248, 0.88);
  --nav-bg: rgba(255, 255, 255, 0.7);
  --mesh-1: rgba(13, 159, 122, 0.07);
  --mesh-2: rgba(109, 92, 232, 0.06);
  --mesh-3: rgba(37, 99, 235, 0.04);
  --radius-lg: 20px;
  --radius-md: 14px;
}

@font-face {
  font-family: Vazirmatn;
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/vazirmatn-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: Vazirmatn;
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/vazirmatn-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Vazirmatn;
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/vazirmatn-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
  min-height: 100vh;
}

.num,
.total-num,
.stat-value,
.market-bar-time {
  font-family: Vazirmatn, Tahoma, sans-serif;
  font-variant-numeric: normal;
}

body.app-body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 60% at 85% -10%, var(--mesh-2), transparent 55%),
    radial-gradient(ellipse 70% 50% at 10% 20%, var(--mesh-1), transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 100%, var(--mesh-3), transparent 45%);
  background-attachment: fixed;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); }

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -48px;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus { top: calc(12px + env(safe-area-inset-top)); }

.top {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--top-bg);
  backdrop-filter: blur(16px) saturate(1.2);
  padding-top: env(safe-area-inset-top);
}

.top-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 10px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-tabs {
  display: flex;
  gap: 8px;
  margin: 0;
  flex: 1;
}

.menu-toggle {
  flex-shrink: 0;
}

.side-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.side-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.side-panel {
  position: fixed;
  z-index: 70;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: min(320px, 88vw);
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-inline-start: 1px solid var(--border-subtle);
  box-shadow: var(--card-shadow);
  overflow: auto;
  transform: translate3d(100%, 0, 0);
  visibility: hidden;
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.32s;
}

.side-panel.is-open {
  transform: translate3d(0, 0, 0);
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .side-backdrop,
  .side-panel {
    transition-duration: 0.01ms;
  }
}

.side-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.side-nav .nav-link,
.side-logout .btn,
.side-nav .install-btn,
.side-nav .theme-toggle {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  text-align: start;
}

.side-logout .btn,
.side-nav .theme-toggle {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.side-logout .btn:hover,
.side-nav .theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.side-nav .theme-toggle {
  height: auto;
}

.side-logout { margin: 0; }

body.menu-open { overflow: hidden; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 11px;
  box-shadow: 0 10px 28px var(--accent-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand:hover .brand-logo {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 14px 32px var(--accent-glow);
}

.brand-name {
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 5px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
}

.nav-link {
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.install-btn { cursor: pointer; background: transparent; border: 0; font: inherit; color: var(--accent); }
.pwa-offline-bar {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 56px);
  z-index: 45;
  margin: 0 auto;
  width: min(1180px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--warn);
  background: var(--warn-bg);
  color: var(--text);
  font-size: 14px;
}
.pwa-offline-toast {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(420px, calc(100% - 32px));
}
.pwa-ios-hint {
  margin: 12px auto 0;
  width: min(1180px, calc(100% - 32px));
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-muted);
}
.landing-android {
  margin-top: 16px;
}
.landing-steps-compact {
  margin-bottom: 16px;
}
.apk-hash {
  font-size: 12px;
  word-break: break-all;
  margin-top: 10px;
}

.nav-link.is-active,
.nav-link:hover {
  color: var(--text);
  background: var(--accent-muted);
}
.nav-link:hover {
  background: var(--surface-hover);
}

.btn:focus-visible,
.tab:focus-visible,
.nav-link:focus-visible,
.chart-tool-btn:focus-visible,
.menu-toggle:focus-visible,
.privacy-btn:focus-visible,
.theme-toggle:focus-visible,
.th-sort:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chart-card.is-empty .chart-stage,
.chart-card.is-empty .chart-head-actions,
.chart-card.is-empty .chart-hint {
  display: none;
}
.chart-card.is-empty #chart-empty {
  display: block;
  margin: 0 16px 18px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto calc(48px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.shell-wide {
  width: min(1120px, calc(100% - 32px));
}

.page-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 400px);
  gap: 28px 36px;
  align-items: start;
}

.page-split-form {
  margin-inline: 0;
  width: 100%;
  position: sticky;
  top: 88px;
}

.intro-panel {
  padding: 4px 0 8px;
}

.intro-eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.intro-title {
  margin: 0 0 12px;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.intro-lead {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-muted);
}

.intro-lead a {
  font-weight: 500;
}

.intro-features {
  margin: 0 0 20px;
  padding: 0 1.2em 0 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.intro-features li {
  margin-bottom: 8px;
}

.intro-previews {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.intro-previews-lg {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.preview-card {
  margin: 0;
  padding: 0;
}

.preview-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow);
  background: var(--bg-elevated);
}

.preview-card figcaption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.landing {
  gap: 24px;
}

.landing-hero {
  padding: 8px 0 12px;
}

.landing-cta h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.landing-steps {
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  font-size: 14px;
  line-height: 1.5;
}

.landing-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.landing-onboarding {
  margin-top: 4px;
}

.nav-link-accent {
  color: var(--accent) !important;
  font-weight: 600;
}

.nav-link-accent:hover {
  background: var(--accent-muted);
  color: var(--accent-hover) !important;
}

@media (max-width: 900px) {
  .page-split {
    grid-template-columns: 1fr;
  }
  .page-split-form {
    position: static;
  }
  .intro-previews {
    grid-template-columns: 1fr;
  }
}

.foot {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto calc(32px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.foot a { color: var(--text-muted); }
.foot a:hover { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
}

.card-head { margin-bottom: 16px; }
.card-head h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.card-desc { margin: 0; color: var(--text-muted); font-size: 14px; }

h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; }

.summary {
  padding: 28px 26px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background:
    linear-gradient(135deg, rgba(62, 224, 184, 0.06), transparent 42%),
    linear-gradient(225deg, rgba(139, 124, 248, 0.08), transparent 48%),
    var(--surface);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
}

.summary::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(62, 224, 184, 0.25), transparent 40%, rgba(139, 124, 248, 0.2));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.summary-grid {
  display: grid;
  gap: 22px;
  align-items: stretch;
  direction: rtl;
  text-align: right;
}

.summary-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.summary-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}

.summary-pie {
  min-width: 0;
  padding: 16px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 840px) {
  .summary-grid {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
    gap: 28px;
  }

  /* RTL: ستون ۱ راست (متن)، ستون ۲ چپ (نمودار) */
  .summary-main {
    grid-column: 1;
    grid-row: 1;
  }

  .summary-pie {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 839px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-pie {
    order: 1;
  }

  .summary-main {
    order: 0;
  }
}

.summary-pie-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.summary-pie-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.pie-wrap-summary {
  max-width: none;
  height: min(220px, 34vw);
  min-height: 180px;
}

.chart-empty-compact {
  padding: 24px 12px;
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.portfolio-usd {
  margin: 0 0 8px;
  font-size: clamp(18px, 3.5vw, 22px);
  font-weight: 600;
  line-height: 1.4;
}

.summary-text p.total,
p.total {
  margin: 0 0 10px;
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: isolate;
  line-height: 1.2;
}

.total-num {
  display: inline;
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 700;
  letter-spacing: -0.03em;
  unicode-bidi: embed;
  direction: rtl;
  background: linear-gradient(120deg, var(--text) 20%, var(--accent) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="light"] .total-num {
  background: linear-gradient(120deg, var(--text) 10%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.total-suffix,
.total-unit {
  display: inline;
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
  unicode-bidi: embed;
  direction: rtl;
}

.meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.market-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.18);
  direction: rtl;
}

[data-theme="light"] .market-bar {
  background: rgba(255, 255, 255, 0.65);
}

.market-bar-status {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.market-bar-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.market-bar-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.market-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.market-bar-time-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  font-size: 14px;
  color: var(--text);
}

.market-bar-time {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.market-bar-tz {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.market-bar-form {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.market-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.market-refresh-btn:not(:disabled):hover {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

.market-refresh-btn:not(:disabled):hover .market-refresh-icon {
  transform: rotate(-30deg);
}

.market-refresh-btn.is-waiting {
  opacity: 0.85;
  cursor: not-allowed;
  color: var(--text-muted);
  border-style: dashed;
}

.market-refresh-btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.market-refresh-icon {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.market-bar-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: start;
  max-width: 220px;
  line-height: 1.4;
}

@media (max-width: 520px) {
  .top-inner { flex-wrap: wrap; }
  .top-tabs {
    flex: 1 1 100%;
    min-width: 0;
  }
  .top-tabs .tab {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
  }
  .menu-toggle,
  .side-panel-head .btn,
  .top-tabs .tab {
    min-height: 44px;
  }
  .pwa-offline-bar {
    top: calc(env(safe-area-inset-top) + 7.5rem);
  }
  .debt-total {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
  }
  .market-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .market-bar-form {
    align-items: stretch;
  }
  .market-refresh-btn {
    justify-content: center;
    width: 100%;
  }
  .market-bar-hint {
    text-align: center;
    max-width: none;
  }
}

.pie-wrap {
  position: relative;
  width: 100%;
  max-width: 340px;
  height: min(320px, 42vh);
  min-height: 220px;
  margin: 0 auto;
}

.chart-card {
  padding: 0;
  overflow: hidden;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 0;
}

.chart-head-title h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.chart-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.chart-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.chart-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--nav-bg);
  border: 1px solid var(--border-subtle);
}

.chart-tab {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chart-tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.chart-tab.is-active {
  color: #04120e;
  background: linear-gradient(135deg, var(--accent), #6eecc9);
  box-shadow: 0 8px 20px var(--accent-glow);
}

[data-theme="light"] .chart-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-violet));
}

.chart-view-controls {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}

.chart-asset-picker {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: min(220px, 52vw);
  cursor: pointer;
}

.chart-asset-picker-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

.chart-asset-picker.is-active .chart-asset-picker-title {
  color: var(--accent);
}

.chart-asset-select {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px 10px 40px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  color: var(--text);
  cursor: pointer;
  width: 100%;
  direction: rtl;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.chart-asset-picker.is-active .chart-asset-select {
  border-color: var(--accent);
  background-color: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.chart-asset-select:hover:not(:disabled) {
  border-color: var(--accent);
}

.chart-asset-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.chart-asset-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chart-tools {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}

.chart-tool-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chart-tool-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.chart-stage {
  margin: 14px 16px 18px;
  padding: 12px 8px 8px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-subtle);
}

[data-theme="light"] .chart-stage {
  background: rgba(255, 255, 255, 0.55);
}

.chart-wrap {
  position: relative;
  height: min(400px, 56vh);
  min-height: 280px;
  touch-action: manipulation;
}

.chart-wrap.is-range-mode {
  touch-action: none;
  cursor: crosshair;
}

.chart-tool-btn.is-active {
  color: var(--accent);
  background: var(--accent-muted);
}

.chart-card.is-fullscreen {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-bottom: 16px;
}

.chart-card.is-fullscreen .chart-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 12px 20px 0;
  min-height: 0;
}

.chart-card.is-fullscreen .chart-wrap {
  flex: 1;
  height: auto;
  min-height: 280px;
}

@media (max-width: 720px) {
  #chart-fullscreen { display: none; }
  .chart-head-actions {
    width: 100%;
    justify-content: space-between;
  }
  .chart-tools .chart-tool-btn {
    width: 44px;
    height: 44px;
  }
}

.chart-empty {
  margin: 0;
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.hidden { display: none !important; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }

.table-wrap-wide .data-table {
  min-width: 1100px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
}

.stat-label {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-value-sm {
  font-size: 15px;
  font-weight: 600;
}

.stat-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.admin-summary {
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.db-table-card {
  text-decoration: none;
  color: inherit;
}
.db-table-card:hover {
  border-color: var(--accent);
}

.db-search {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}
.db-search-label { flex: 1; margin: 0; }
.db-delete { margin-top: 18px; }

textarea,
select {
  display: block;
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
}
textarea:focus,
select:focus {
  outline: 2px solid var(--accent-muted);
  border-color: var(--accent);
}
textarea { min-height: 180px; resize: vertical; }
input[readonly] { opacity: 0.75; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: none;
  white-space: nowrap;
  padding: 0;
}

.data-table thead th:not(:has(.th-sort)) {
  padding: 12px 10px;
}

.th-sort {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 12px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: right;
  cursor: pointer;
  border-radius: 8px;
}
.th-sort:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.th-sort::after {
  content: "↕";
  font-size: 11px;
  opacity: 0.35;
}
.th-sort.is-sorted::after {
  opacity: 1;
  color: var(--accent);
}
.th-sort.is-sorted:not(.is-desc)::after {
  content: "↑";
}
.th-sort.is-sorted.is-desc::after {
  content: "↓";
}

.data-table tbody tr:hover { background: var(--accent-muted); }

.data-table tfoot th,
.data-table tfoot td {
  border-bottom: none;
  font-weight: 600;
  padding-top: 14px;
}

.num { font-variant-numeric: normal; }
.num-strong { font-weight: 600; }

.badge {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 6px;
  background: var(--accent-muted);
  color: var(--accent);
  vertical-align: middle;
}
.badge-sanjeh {
  background: rgba(39, 174, 96, 0.15);
  color: #27ae60;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.help-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-muted);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}
.field-hint, .field-status {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.sanjeh-block { margin-top: 4px; }
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-muted);
}
.checkbox-row input { width: auto; margin: 0; }

.asset-logo {
  width: 22px;
  height: 22px;
  margin-inline-end: 8px;
  vertical-align: middle;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
  box-sizing: border-box;
}
.privacy-btn {
  width: 44px;
  height: 44px;
  margin-inline-start: 8px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  vertical-align: middle;
  font-size: 14px;
  line-height: 1;
}
.privacy-btn:hover { color: var(--text); }
.privacy-btn[aria-pressed="false"] .privacy-icon-hide { display: none; }
.privacy-btn[aria-pressed="true"] .privacy-icon-show { display: none; }
.privacy-icon { width: 18px; height: 18px; display: block; margin: auto; }
[data-mask] {
  font-size: 0 !important;
  user-select: none;
}
[data-mask]::after {
  content: "******";
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.08em;
}
html[data-show-portfolio="1"] [data-mask="portfolio"],
html[data-show-salary="1"] [data-mask="salary"] {
  font-size: inherit !important;
  color: inherit !important;
  user-select: auto;
}
html[data-show-portfolio="1"] [data-mask="portfolio"].total-num {
  font-size: clamp(32px, 6vw, 48px) !important;
}
html[data-show-portfolio="1"] [data-mask="portfolio"]::after,
html[data-show-salary="1"] [data-mask="salary"]::after {
  content: none;
}
.section-logo {
  width: 18px;
  height: 18px;
  margin-inline-end: 6px;
  vertical-align: -3px;
}
.asset-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-inline-end: 8px;
  vertical-align: middle;
}
.asset-dot-gold { background: #f59e0b; }
.asset-dot-silver { background: #cbd5e1; }
.asset-dot-btc { background: #f97316; }
.asset-dot-ada { background: #3b82f6; }
.asset-dot-eth { background: #8b5cf6; }
.asset-dot-sol { background: #14b8a6; }
.asset-dot-doge { background: #eab308; }
.asset-dot-matic { background: #a855f7; }
.asset-dot-usd { background: #22c55e; }
.asset-dot-cash { background: #38bdf8; }
.asset-dot-car { background: #94a3b8; }

.sparkline-col {
  width: 80px;
  text-align: center !important;
  font-size: 11px;
  white-space: nowrap;
}

.sparkline-cell {
  width: 80px;
  padding-inline: 6px !important;
  vertical-align: middle;
}

.row-sparkline {
  display: block;
  margin: 0 auto;
  opacity: 0.95;
}

.gain-cell {
  font-size: 13px;
  white-space: nowrap;
}

.gain-positive {
  color: var(--success);
  font-weight: 600;
}

.btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5ad4f0 55%, var(--accent-violet));
  color: #04120e;
  box-shadow: 0 12px 28px var(--accent-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #7ee8ff 55%, var(--accent-violet));
  color: #04120e;
}

[data-theme="light"] .btn-primary {
  color: #fff;
}
[data-theme="light"] .btn-primary:hover {
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.btn-danger {
  background: #b42318;
  color: #fff;
  border: 1px solid transparent;
}

.btn-danger:hover {
  background: #912018;
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.text-muted {
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-block { width: 100%; }

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.btn-icon:hover { background: var(--surface-hover); }

[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }

.inline { display: inline; margin: 0; }

.toast {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}
.toast-ok { background: var(--success-bg); color: var(--success); }
.toast-warn { background: var(--warn-bg); color: var(--warn); }

.auth-card {
  width: min(440px, 100%);
  margin-inline: auto;
}

.page-split .auth-card {
  width: 100%;
}
.auth-card.wide { width: min(720px, 100%); }

.stack-form label,
.grid-form label { display: block; margin-bottom: 14px; }

.label-text {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

input {
  display: block;
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
}
input:focus {
  outline: 2px solid var(--accent-muted);
  border-color: var(--accent);
}

.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.grid-form .span-2 { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
}
.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
}
.tab.is-active {
  color: var(--text);
  background: var(--accent-muted);
  border-color: transparent;
}
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.monthly-block {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}
.monthly-block h2 {
  margin: 0 0 8px;
  font-size: 18px;
}
.daily-chart {
  max-width: 440px;
  height: 280px;
  margin: 8px auto 16px;
}
.daily-section + .daily-section {
  margin-top: 16px;
}
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}
.category-tree {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.category-tree li {
  margin: 6px 0;
}
.category-tree ul {
  margin: 4px 18px 0 0;
  padding: 0;
  list-style: disc;
}
.amount-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.amount-suggest-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  direction: ltr;
}
.amount-suggest-btn:hover {
  background: var(--accent-muted);
  border-color: transparent;
}
.jalali-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
}
.net-line {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
}
.net-line div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.net-line dt, .net-line dd {
  margin: 0;
  font-size: 14px;
}
.net-line dt { color: var(--text-muted); font-weight: 500; }
.net-line dd { font-weight: 700; }

.muted { color: var(--text-muted); font-size: 14px; }
.center { text-align: center; margin-top: 20px; }

@media (max-width: 720px) {
  .top-inner { gap: 8px; }
  .brand-name { font-size: 15px; }
  .data-table .row-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .data-table .row-actions .btn { width: 100%; min-height: 44px; }
  .summary { padding: 20px 18px; }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span-2 { grid-column: auto; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}
