/* Market Dashboard — shared styles (index, health, rates, then-and-now)
   Tokens match dashboard-v2 / hub. Theme key: localStorage 'ar-theme' (dark default). */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0D1B2E;
  --surface:   #152338;
  --card:      #1A2E47;
  --border:    rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.16);
  --gold:      #C5A55A;
  --gold-dim:  rgba(197,165,90,0.15);
  --on-gold:   #0D1B2E;
  --text:      #EDF0F3;
  --muted:     #7A92A8;
  --blue:      #4A8FD4;
  --teal:      #3AADA8;
  --green:     #4BAF7A;
  --amber:     #D4973A;
  --purple:    #8B72BE;
  --rose:      #C46A7A;
  --up:        #4BAF7A;
  --down:      #E0788A;
  --grid:      rgba(255,255,255,0.06);
  --warn-bg:   rgba(212,151,58,0.12);
  --warn-text: #E5B268;
  --err-bg:    rgba(196,106,122,0.12);
  --err-text:  #EE9AA8;

  --radius:    12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:        #F2F0EC;
  --surface:   #E8E5DF;
  --card:      #FFFFFF;
  --border:    rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.18);
  --gold:      #A07830;
  --gold-dim:  rgba(160,120,48,0.12);
  --on-gold:   #FFFFFF;
  --text:      #1A2535;
  --muted:     #5A6E82;
  --blue:      #2F6DB0;
  --teal:      #248F8A;
  --green:     #2E8B57;
  --amber:     #B87A20;
  --purple:    #6F55A8;
  --rose:      #B04A5C;
  --up:        #2E8B57;
  --down:      #B84A5C;
  --grid:      rgba(0,0,0,0.07);
  --warn-bg:   #FBF1DC;
  --warn-text: #7A5314;
  --err-bg:    #FBE9EC;
  --err-text:  #9A2F42;
  color-scheme: light;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
#root { min-height: 100vh; }

a { color: var(--gold); }
code { background: var(--surface); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: 1200px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand {
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: 6px;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a.active { color: var(--text); background: var(--gold-dim); }
.nav .spacer { flex: 1; }

.icon-btn {
  background: none; border: 1px solid var(--border-strong); color: var(--muted);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

/* ── Page layout ───────────────────────────────────────── */
.wrap { max-width: 1200px; margin: 0 auto; padding: 28px 24px 56px; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 12px; margin-bottom: 24px;
}
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.stack > * + * { margin-top: 20px; }

.reveal { animation: reveal .4s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 16px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: var(--gold); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--gold); color: var(--on-gold); border-color: var(--gold); font-weight: 600; text-decoration: none; display: inline-block; }
.btn-primary:hover { filter: brightness(1.08); }

/* Segmented period selector */
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface); border-radius: 8px; flex-wrap: wrap; }
.seg button {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 500;
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--gold); color: var(--on-gold); font-weight: 600; }

/* Pill toggles (indicator chips) */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
  padding: 4px 12px; border-radius: 999px;
  background: transparent; color: var(--chip, var(--muted)); border: 1.5px solid var(--chip, var(--muted));
}
.chip.on { background: var(--chip, var(--muted)); color: var(--bg); }

/* ── Panels ────────────────────────────────────────────── */
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > .panel-head { padding: 22px 24px 16px; margin-bottom: 0; }
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 10px; margin-bottom: 16px;
}
.panel-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.panel-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 380px; }

/* ── Stat strip (market overview) ──────────────────────── */
.stat-strip {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px;
  background: var(--border); border-top: 1px solid var(--border);
}
.stat { background: var(--card); padding: 18px 22px 20px; }
.stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin-top: 6px; }
.stat-trend { font-size: 12.5px; font-weight: 500; margin-top: 6px; color: var(--muted); }
.stat-trend.up { color: var(--up); }
.stat-trend.down { color: var(--down); }

@media (max-width: 900px) { .stat-strip { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .wrap { padding: 20px 16px 48px; }
  .topbar-in { padding: 10px 16px; }
  .panel { padding: 18px 16px; }
  .chart-box { height: 260px; }
}

/* ── Tables ────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.tbl.fixed { table-layout: fixed; }
.tbl th {
  text-align: right; padding: 8px 12px; color: var(--muted); font-weight: 500; font-size: 12.5px;
  border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.tbl td { text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td.dim { color: var(--muted); }
.tbl .name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.arrow { font-size: 11px; margin-left: 5px; color: var(--muted); }
.arrow.up { color: var(--up); }
.arrow.down { color: var(--down); }

/* ── Notices & empty states ────────────────────────────── */
.notice { padding: 10px 16px; border-radius: var(--radius-sm); font-size: 13px; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.err  { background: var(--err-bg);  color: var(--err-text); }
.empty { text-align: center; padding: 40px 24px; }
.empty h3 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 18px; }
.empty p:last-child { margin-bottom: 0; }

.info-strip {
  display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 10px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 12.5px;
}
.info-strip strong { color: var(--text); font-weight: 600; }

/* ── Data management ───────────────────────────────────── */
.dm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.dm-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.dm-item b { display: block; font-size: 14px; margin-bottom: 4px; }
.dm-item span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ── Loading skeleton ──────────────────────────────────── */
.skel { background: var(--surface); border-radius: 6px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

@media (prefers-reduced-motion: reduce) {
  .reveal, .skel { animation: none; }
}
