/* ============================================================
   FinPig Design System — styles.css v2
   Two themes: [data-theme="muji"] | [data-theme="slate"]
   OKLCH with hex fallbacks for Safari < 15.4
   ============================================================ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;800&family=Noto+Serif+TC:wght@700;900&display=swap');

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overscroll-behavior: none; min-height: 100%; }
body { overscroll-behavior: none; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ============================================================
   THEME TOKENS — WARM TERRACOTTA
   ============================================================ */
:root,
body[data-theme="warm"],
body[data-theme="muji"] {
  color-scheme: light;

  /* Hex fallbacks (Safari < 15.4) */
  --bg:           #f5ede1;
  --bg-soft:      #faf5ee;
  --paper:        rgba(253, 250, 245, 0.92);
  --paper-strong: rgba(255, 253, 249, 0.99);
  --panel:        rgba(252, 248, 242, 0.92);
  --panel-muted:  rgba(246, 240, 232, 0.96);
  --panel-strong: rgba(240, 232, 222, 0.98);
  --line:         rgba(90, 72, 58, 0.10);
  --line-strong:  rgba(90, 72, 58, 0.18);
  --ink:          #2a2218;
  --muted:        #6b5c4e;
  --brand:        #9a7562;
  --brand-strong: #7a5a48;
  --brand-soft:   rgba(154, 117, 98, 0.10);
  --accent:       #b89b82;
  --accent-soft:  rgba(184, 155, 130, 0.16);
  --secondary:    #a88870;
  --success:      #526b54;
  --warn:         #8f6a2a;
  --danger:       #8a4038;
  --shadow-color: rgba(74, 56, 42, 0.06);
  --shadow:       0 2px 8px rgba(74,56,42,0.06), 0 8px 24px rgba(74,56,42,0.04);
  --shadow-soft:  0 1px 4px rgba(74,56,42,0.05), 0 4px 12px rgba(74,56,42,0.04);
  --shadow-lg:    0 4px 16px rgba(74,56,42,0.08), 0 16px 48px rgba(74,56,42,0.06);
  --btn-shadow:   0 2px 8px rgba(122,90,72,0.18), 0 6px 20px rgba(122,90,72,0.12);
  --logo-surface: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.88), transparent 48%),
                  linear-gradient(160deg, rgba(253,248,242,0.94), rgba(242,230,218,0.82));
  --logo-border:  rgba(154,117,98,0.20);
  --logo-shadow:  drop-shadow(0 8px 16px rgba(100,76,58,0.12));
  --topbar-bg:    linear-gradient(180deg, rgba(254,251,247,0.98) 0%, rgba(247,239,230,0.96) 100%);
  --nav-hl:       linear-gradient(180deg, color-mix(in srgb, var(--brand) 12%, white 88%), color-mix(in srgb, var(--brand) 6%, white 94%));
  --nav-hl-shadow:0 6px 16px rgba(80,58,42,0.08);
  --switcher-bg:  rgba(74,56,42,0.05);
  --soft-surface: rgba(74,56,42,0.05);

  /* Chart palette (warm theme) */
  --chart-frr:    #a64b3f;
  --chart-ask:    #9a826d;
  --chart-target: #5d7a5f;
  --chart-axis:   var(--muted);
  --chart-grid:   rgba(90, 72, 58, 0.12);
  --chart-range:  rgba(154, 130, 109, 0.55);
  --chart-highlight: rgba(166, 75, 63, 0.08);
  --body-bg:
    radial-gradient(ellipse at 0% 0%, rgba(255,255,255,0.7) 0%, transparent 28%),
    radial-gradient(ellipse at 100% 100%, rgba(154,117,98,0.10) 0%, transparent 24%),
    linear-gradient(180deg, #faf5ee 0%, #f5ede1 52%, #eee0d0 100%);

  /* Sizes */
  --radius-xs:  8px;
  --radius-sm:  12px;
  --radius-md:  18px;
  --radius-lg:  24px;
  --radius-xl:  30px;
  --radius-pill: 999px;

  /* Typography */
  --font-body:     "Noto Sans TC", "Segoe UI", "Microsoft JhengHei", sans-serif;
  --font-display:  "Noto Sans TC", "Segoe UI", "Microsoft JhengHei", sans-serif;
  --font-serif:    "Noto Serif TC", "Georgia", serif;
  --font-mono:     "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
  --heading-track: -0.04em;
  --eyebrow-track:  0.16em;

  /* Motion */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:    160ms;
  --dur-base:    200ms;
  --dur-slow:    360ms;

  /* Layout */
  --shell-max:      min(1720px, calc(100vw - 20px));
  --sidebar-w:      clamp(200px, 14vw, 228px);
  --topbar-h:       60px;
  --page-pad:       clamp(14px, 1.6vw, 20px);
  --col-gap:        clamp(12px, 1.3vw, 18px);
  --stack-gap:      18px;
  --summary-accent: 4px;
}

/* OKLCH overrides for modern browsers */
@supports (color: oklch(50% 0.1 100)) {
  :root,
  body[data-theme="warm"],
  body[data-theme="muji"] {
    --bg:          oklch(94% 0.04 37);
    --bg-soft:     oklch(97.5% 0.018 37);
    --paper:       oklch(99% 0.008 37 / 0.92);
    --panel:       oklch(98% 0.012 37 / 0.92);
    --panel-muted: oklch(95.5% 0.024 37 / 0.96);
    --panel-strong:oklch(91% 0.034 37 / 0.98);
    --line:        oklch(55% 0.03 37 / 0.10);
    --line-strong: oklch(45% 0.04 37 / 0.18);
    --ink:         oklch(18% 0.03 37);
    --muted:       oklch(45% 0.025 37);
    --brand:       oklch(54% 0.14 37);
    --brand-strong:oklch(44% 0.13 37);
    --brand-soft:  oklch(54% 0.14 37 / 0.10);
    --accent:      oklch(68% 0.09 37);
    --accent-soft: oklch(68% 0.09 37 / 0.16);
    --success:     oklch(50% 0.09 145);
    --warn:        oklch(58% 0.11 50);
    --danger:      oklch(50% 0.12 18);
    --shadow-color:oklch(35% 0.06 37 / 0.06);
  }
}

/* ============================================================
   THEME TOKENS — MORANDI SLATE BLUE (default dark)
   ============================================================ */
body[data-theme="slate"],
body[data-theme="morandi"] {
  color-scheme: dark;

  --bg:           #1e2530;
  --bg-soft:      #242d3a;
  --paper:        rgba(50, 62, 78, 0.88);
  --paper-strong: rgba(58, 70, 88, 0.96);
  --panel:        rgba(46, 58, 74, 0.88);
  --panel-muted:  rgba(40, 52, 66, 0.94);
  --panel-strong: rgba(36, 46, 60, 0.98);
  --line:         rgba(140, 165, 192, 0.14);
  --line-strong:  rgba(140, 165, 192, 0.22);
  --ink:          #e8edf4;
  --muted:        #8fa4bb;
  --brand:        #7ca0c0;
  --brand-strong: #9dbedd;
  --brand-soft:   rgba(124, 160, 192, 0.14);
  --accent:       #8ec4c0;
  --accent-soft:  rgba(142, 196, 192, 0.14);
  --secondary:    #7b96b0;
  --success:      #72a880;
  --warn:         #c8914a;
  --danger:       #c06060;
  --shadow-color: rgba(10, 16, 26, 0.28);
  --shadow:       0 2px 8px rgba(10,16,26,0.28), 0 8px 24px rgba(10,16,26,0.18);
  --shadow-soft:  0 1px 4px rgba(10,16,26,0.22), 0 4px 14px rgba(10,16,26,0.14);
  --shadow-lg:    0 4px 20px rgba(10,16,26,0.32), 0 16px 48px rgba(10,16,26,0.22);
  --btn-shadow:   0 4px 14px rgba(10,16,26,0.28), 0 8px 24px rgba(124,160,192,0.16);
  --logo-surface: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.10), transparent 44%),
                  linear-gradient(160deg, rgba(60,74,94,0.90), rgba(40,54,70,0.84));
  --logo-border:  rgba(140,165,192,0.18);
  --logo-shadow:  drop-shadow(0 8px 20px rgba(10,16,26,0.36));
  --topbar-bg:    linear-gradient(180deg, rgba(36,46,60,0.98) 0%, rgba(28,38,52,0.96) 100%);
  --nav-hl:       linear-gradient(180deg, rgba(124,160,192,0.18), rgba(124,160,192,0.08));
  --nav-hl-shadow:0 6px 16px rgba(10,16,26,0.24);
  --switcher-bg:  rgba(255,255,255,0.05);
  --soft-surface: rgba(255,255,255,0.05);

  /* Chart palette (slate theme — lifted for contrast on dark) */
  --chart-frr:    #e08a82;
  --chart-ask:    #c4ad93;
  --chart-target: #8fc096;
  --chart-axis:   var(--muted);
  --chart-grid:   rgba(140, 165, 192, 0.18);
  --chart-range:  rgba(196, 173, 147, 0.45);
  --chart-highlight: rgba(224, 138, 130, 0.10);

  --body-bg:
    radial-gradient(ellipse at 8% 6%, rgba(100,136,172,0.10) 0%, transparent 28%),
    radial-gradient(ellipse at 92% 94%, rgba(80,110,148,0.08) 0%, transparent 22%),
    linear-gradient(180deg, #242d3a 0%, #1e2530 52%, #18202c 100%);
}

@supports (color: oklch(50% 0.1 100)) {
  body[data-theme="slate"],
  body[data-theme="morandi"] {
    --bg:           oklch(28% 0.025 225);
    --bg-soft:      oklch(32% 0.022 225);
    --paper:        oklch(35% 0.020 225 / 0.88);
    --paper-strong: oklch(38% 0.018 225 / 0.96);
    --panel:        oklch(33% 0.022 225 / 0.88);
    --panel-muted:  oklch(30% 0.024 225 / 0.94);
    --panel-strong: oklch(27% 0.026 225 / 0.98);
    --line:         oklch(56% 0.018 225 / 0.14);
    --line-strong:  oklch(56% 0.018 225 / 0.22);
    --ink:          oklch(94% 0.006 225);
    --muted:        oklch(70% 0.016 225);
    --brand:        oklch(65% 0.09 220);
    --brand-strong: oklch(75% 0.08 218);
    --brand-soft:   oklch(65% 0.09 220 / 0.14);
    --accent:       oklch(72% 0.07 200);
    --accent-soft:  oklch(72% 0.07 200 / 0.14);
    --success:      oklch(58% 0.08 155);
    --warn:         oklch(65% 0.10 55);
    --danger:       oklch(55% 0.10 20);
    --shadow-color: oklch(15% 0.02 225 / 0.28);
    --body-bg:
      radial-gradient(ellipse at 8% 6%, oklch(50% 0.06 220 / 0.10) 0%, transparent 28%),
      radial-gradient(ellipse at 92% 94%, oklch(40% 0.04 225 / 0.08) 0%, transparent 22%),
      linear-gradient(180deg, oklch(32% 0.022 225) 0%, oklch(28% 0.025 225) 52%, oklch(23% 0.026 225) 100%);
  }
}

/* ============================================================
   BASE
   ============================================================ */
body {
  font-family:  var(--font-body);
  color:        var(--ink);
  background:   var(--body-bg);
  background-color: var(--bg);
  background-attachment: fixed;
  min-height:   100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size:    15px;
  line-height:  1.55;
}

.hidden { display: none !important; }
.dashboard-page-hidden { display: none !important; }

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.page-shell {
  max-width:  var(--shell-max);
  margin:     0 auto;
  padding:    var(--page-pad) var(--page-pad) 48px;
}

.dashboard-layout {
  display:               grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap:                   var(--col-gap);
  align-items:           start;
}

.main-stack {
  display: grid;
  gap:     var(--stack-gap);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.shell-topbar {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  gap:             16px;
  padding:         14px 20px;
  margin-bottom:   14px;
  border:          1px solid var(--line);
  border-radius:   var(--radius-xl);
  background:      var(--topbar-bg);
  box-shadow:      var(--shadow);
  position:        sticky;
  top:             0;
  z-index:         100;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.brand-block {
  display:     flex;
  align-items: center;
  gap:         14px;
  min-width:   0;
}

.brand-logo {
  width:         clamp(44px, 3.2vw, 52px);
  height:        clamp(44px, 3.2vw, 52px);
  flex:          0 0 auto;
  object-fit:    contain;
  filter:        var(--logo-shadow);
  padding:       clamp(4px, 0.4vw, 6px);
  border-radius: var(--radius-md);
  background:    var(--logo-surface);
  border:        1px solid var(--logo-border);
  box-shadow:    0 8px 24px var(--shadow-color);
}

.brand-copy { min-width: 0; }

.eyebrow,
.panel-eyebrow,
.sidebar-kicker,
.landing-preview-kicker {
  display:        block;
  font-size:      11px;
  font-weight:    800;
  letter-spacing: var(--eyebrow-track);
  text-transform: uppercase;
  color:          var(--brand);
  margin:         0 0 4px;
}

.shell-topbar h1 {
  font-family:    var(--font-display);
  font-size:      clamp(20px, 1.9vw, 28px);
  font-weight:    800;
  letter-spacing: var(--heading-track);
  line-height:    1.1;
  margin:         0;
}

.topbar-actions {
  display:         flex;
  flex-wrap:       wrap;
  align-items:     center;
  gap:             8px;
  justify-content: flex-end;
}

/* ── Theme / Language Switchers ── */
.theme-switcher,
.language-switcher {
  display:       inline-flex;
  align-items:   center;
  gap:           4px;
  padding:       4px;
  border-radius: var(--radius-pill);
  background:    var(--switcher-bg);
  border:        1px solid var(--line);
}

.theme-btn,
.lang-btn {
  padding:       7px clamp(10px, 0.9vw, 14px);
  border-radius: var(--radius-pill);
  border:        none;
  background:    transparent;
  color:         var(--muted);
  font-size:     clamp(11px, 0.78vw, 13px);
  font-weight:   700;
  cursor:        pointer;
  transition:    all var(--dur-fast) var(--ease-out);
  touch-action:  manipulation;
}

.theme-btn:hover,
.lang-btn:hover { color: var(--ink); }

.theme-btn.is-active,
.lang-btn.is-active {
  background:  linear-gradient(160deg, var(--brand), var(--brand-strong));
  color:       #fff;
  box-shadow:  var(--btn-shadow);
}

/* ── FRR Tape ── */
.frr-tape-bar {
  display:       flex;
  align-items:   center;
  gap:           14px;
  padding:       10px 18px;
  margin-bottom: 14px;
  border:        1px solid var(--line);
  border-radius: var(--radius-lg);
  background:    color-mix(in srgb, var(--panel-muted) 80%, transparent 20%);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow:    var(--shadow-soft);
  overflow:      hidden;
}

.frr-tape-label {
  flex:           0 0 auto;
  font-size:      11px;
  font-weight:    800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color:          var(--brand);
  white-space:    nowrap;
}

.frr-tape-marquee {
  position:             relative;
  flex:                 1 1 auto;
  min-width:            0;
  overflow:             hidden;
  mask-image:           linear-gradient(90deg, transparent 0, black 4%, black 96%, transparent 100%);
  -webkit-mask-image:   linear-gradient(90deg, transparent 0, black 4%, black 96%, transparent 100%);
}

.frr-tape-track {
  display:    flex;
  align-items:center;
  gap:        18px;
  width:      max-content;
  animation:  frr-scroll 32s linear infinite;
  will-change:transform;
}

.frr-tape-sequence {
  display:     flex;
  align-items: center;
  gap:         18px;
}

.frr-tape-track:hover { animation-play-state: paused; }

.frr-tape-item {
  display:       inline-flex;
  align-items:   center;
  gap:           9px;
  padding:       6px 13px;
  border-radius: var(--radius-pill);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--paper) 90%, white 10%);
  white-space:   nowrap;
  font-size:     13px;
}

.frr-tape-symbol { font-weight: 800; color: var(--brand); }
.frr-tape-detail { font-weight: 700; }
.frr-tape-time   { font-size: 11px; color: var(--muted); }

@keyframes frr-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .frr-tape-track { animation: none; }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position:    sticky;
  top:         calc(var(--topbar-h) + var(--page-pad));
  align-self:  start;
  max-height:  calc(100vh - var(--topbar-h) - var(--page-pad) * 2);
  overflow-y:  auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-card {
  padding:       10px;
  border-radius: var(--radius-lg);
  border:        1px solid var(--line);
  background:    var(--panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow:    var(--shadow-soft);
}

.sidebar-group + .sidebar-group { margin-top: 14px; }

.sidebar-section-label {
  font-size:      10px;
  font-weight:    800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color:          var(--muted);
  margin-bottom:  6px;
  padding-left:   4px;
}

.sidebar-section-hint {
  font-size:    11px;
  color:        var(--muted);
  line-height:  1.5;
  margin:       -2px 0 8px 4px;
}

/* Page tabs (2×N grid) */
.page-tabs {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   6px;
}

.page-tab {
  min-height:    42px;
  padding:       9px 10px;
  border-radius: var(--radius-md);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel) 88%, transparent);
  color:         var(--muted);
  font-size:     12px;
  font-weight:   800;
  cursor:        pointer;
  transition:    all var(--dur-base) var(--ease-out);
  touch-action:  manipulation;
}

.page-tab:hover {
  transform:    translateY(-1px);
  border-color: color-mix(in srgb, var(--brand) 24%, var(--line));
  color:        var(--ink);
}

.page-tab.is-active {
  color:        var(--brand);
  background:   var(--nav-hl);
  border-color: color-mix(in srgb, var(--brand) 22%, transparent);
  box-shadow:   var(--nav-hl-shadow);
}

.page-tab.is-disabled,
.page-tab:disabled { opacity: 0.44; cursor: not-allowed; transform: none; }

.page-tab-wide { grid-column: 1 / -1; }

/* Section nav */
.sidebar-nav {
  position:      relative;
  display:       grid;
  gap:           3px;
  padding:       4px;
  border-radius: var(--radius-sm);
  background:    color-mix(in srgb, var(--panel-muted) 94%, white 6%);
  border:        1px solid var(--line);
}

.nav-slider {
  position:     absolute;
  left: 4px; right: 4px; top: 4px;
  height:       34px;
  border-radius:var(--radius-xs);
  background:   var(--nav-hl);
  border:       1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  box-shadow:   var(--nav-hl-shadow);
  transition:   transform var(--dur-base) var(--ease-out), height var(--dur-base) var(--ease-out);
  z-index:      0;
  pointer-events: none;
}

.nav-link {
  display:         flex;
  align-items:     center;
  justify-content: flex-start;
  gap:             9px;
  min-height:      34px;
  padding:         7px 10px;
  border-radius:   var(--radius-xs);
  border:          1px solid transparent;
  background:      transparent;
  color:           var(--muted);
  font-size:       12.5px;
  font-weight:     700;
  cursor:          pointer;
  position:        relative;
  z-index:         1;
  transition:      all var(--dur-fast) var(--ease-out);
  touch-action:    manipulation;
  white-space:     nowrap;
}

.nav-link svg {
  width:       16px;
  height:      16px;
  flex:        0 0 auto;
  stroke:      currentColor;
  stroke-width:1.8;
  fill:        none;
  transition:  color var(--dur-fast) var(--ease-out);
}

.nav-link:hover { color: var(--ink); }

.nav-link.is-active {
  color: var(--brand);
}

.sidebar-note {
  margin-top:      10px;
  display:         flex;
  justify-content: center;
}

.user-summary {
  display:     flex;
  align-items: center;
  gap:         10px;
  margin-bottom: 12px;
}

.user-summary img {
  width: 40px; height: 40px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
}

.user-name  { font-weight: 800; font-size: 14px; }
.user-email { font-size: 12px; color: var(--muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.primary-btn,
.secondary-btn,
.ghost-btn,
.theme-btn,
.lang-btn,
.tab-row button,
.nav-link {
  border:        none;
  cursor:        pointer;
  touch-action:  manipulation;
  transition:    transform var(--dur-fast) var(--ease-out),
                 background-color var(--dur-fast) var(--ease-out),
                 box-shadow var(--dur-fast) var(--ease-out),
                 color var(--dur-fast) var(--ease-out),
                 border-color var(--dur-fast) var(--ease-out);
}

.primary-btn {
  padding:       10px 18px;
  border-radius: var(--radius-pill);
  font-weight:   700;
  font-size:     14px;
  color:         #fff;
  background:    linear-gradient(160deg, var(--brand), var(--brand-strong));
  box-shadow:    var(--btn-shadow);
  border:        none;
}

.primary-btn:hover    { transform: translateY(-1px); filter: brightness(1.06); }
.primary-btn:active   { transform: translateY(0); filter: brightness(0.96); }
.primary-btn:disabled { opacity: 0.52; cursor: not-allowed; transform: none; filter: none; }

.secondary-btn {
  padding:       10px 16px;
  border-radius: var(--radius-pill);
  font-weight:   700;
  font-size:     14px;
  color:         var(--ink);
  background:    color-mix(in srgb, var(--panel) 90%, white 10%);
  border:        1px solid var(--line-strong);
}

.secondary-btn:hover    { transform: translateY(-1px); border-color: color-mix(in srgb, var(--brand) 22%, var(--line-strong)); }
.secondary-btn:disabled { opacity: 0.48; cursor: not-allowed; transform: none; }

.ghost-btn {
  padding:       8px 14px;
  border-radius: var(--radius-pill);
  font-weight:   700;
  font-size:     13px;
  color:         var(--muted);
  background:    color-mix(in srgb, var(--panel-muted) 82%, white 18%);
  border:        1px solid var(--line);
}

.ghost-btn:hover { transform: translateY(-1px); color: var(--ink); }

.compact-btn { padding: 7px 12px; font-size: 13px; }

/* ============================================================
   BADGES & CHIPS
   ============================================================ */
.sync-badge,
.soft-badge,
.hero-chip,
.hero-note,
.status-chip,
.legend-pill,
.pill {
  display:       inline-flex;
  align-items:   center;
  gap:           6px;
  border-radius: var(--radius-pill);
  font-weight:   700;
  font-size:     12px;
}

.sync-badge {
  padding:     7px 12px;
  background:  var(--brand-soft);
  border:      1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  color:       var(--brand);
}

.soft-badge {
  padding:    7px 12px;
  background: var(--soft-surface);
  color:      var(--ink);
}

.status-chip {
  padding:    6px 11px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color:      var(--ink);
  border:     1px solid var(--line);
}

.status-chip.ok,
.pill.ok   { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); border-color: color-mix(in srgb, var(--success) 20%, transparent); }
.status-chip.warn,
.pill.warn { background: color-mix(in srgb, var(--warn) 14%, transparent);    color: var(--warn);    border-color: color-mix(in srgb, var(--warn)    20%, transparent); }
.pill.danger,
.status-chip.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }

.hero-chip {
  padding:    7px 11px;
  background: var(--soft-surface);
  color:      var(--muted);
  font-size:  12px;
}

.hero-note {
  padding:    9px 12px;
  background: var(--accent-soft);
  color:      var(--brand);
  border:     1px solid color-mix(in srgb, var(--brand) 18%, transparent);
  font-size:  12px;
}

/* ============================================================
   RUNTIME INDICATOR + LAMP
   ============================================================ */
.runtime-indicator,
.quick-apr-indicator {
  display:       inline-flex;
  align-items:   center;
  gap:           10px;
  min-height:    46px;
  padding:       8px 14px;
  border-radius: var(--radius-md);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 88%, white 12%);
}

.runtime-copy  { display: grid; gap: 2px; }

.runtime-label {
  font-size:      10px;
  font-weight:    800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color:          var(--muted);
}

.runtime-indicator strong,
.quick-apr-indicator strong { font-size: 14px; font-weight: 800; }

.runtime-lamp {
  width:         11px;
  height:        11px;
  flex:          0 0 auto;
  border-radius: var(--radius-pill);
  background:    #9ca3af;
  box-shadow:    0 0 0 3px rgba(156,163,175,0.18);
}

.runtime-lamp.is-on {
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 22%, transparent);
  animation:  lamp-pulse 2.4s ease-in-out infinite;
}

.runtime-lamp.is-off {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent);
}

@keyframes lamp-pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent); }
  50%       { box-shadow: 0 0 0 7px color-mix(in srgb, var(--success) 0%,  transparent); }
}

/* ============================================================
   SECTION BLOCKS
   ============================================================ */
.section-block { display: grid; gap: 12px; }

.section-head {
  display:         flex;
  justify-content: space-between;
  align-items:     flex-end;
  gap:             12px;
}

.section-head h2,
.panel h2 {
  font-family:    var(--font-display);
  font-size:      clamp(19px, 1.4vw, 23px);
  font-weight:    800;
  letter-spacing: var(--heading-track);
  line-height:    1.15;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  gap:             16px;
  padding:         clamp(16px, 1.6vw, 20px) clamp(18px, 2vw, 24px);
  border-radius:   var(--radius-xl);
  border:          1px solid var(--line);
  background:
    radial-gradient(ellipse at 90% 10%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 30%),
    linear-gradient(160deg, var(--paper-strong), var(--panel-muted));
  box-shadow:      var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.hero-copy    { max-width: 760px; }
.hero-kicker-row { display: flex; align-items: center; gap: 10px; }

.hero h2 {
  margin-top:  10px;
  font-size:   clamp(24px, 2.5vw, 36px);
  line-height: 1.1;
}

.hero-summary {
  margin:      4px 0 0;
  font-size:   13px;
  line-height: 1.58;
  color:       var(--muted);
}

.hero-note-list {
  display:         flex;
  flex-wrap:       wrap;
  gap:             8px;
  justify-content: flex-end;
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  padding:       clamp(16px, 1.5vw, 20px);
  border-radius: var(--radius-lg);
  border:        1px solid var(--line);
  background:    var(--panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow:    var(--shadow-soft);
  position:      relative;
  overflow:      hidden;
}

.panel-header {
  display:         flex;
  justify-content: space-between;
  align-items:     flex-start;
  gap:             12px;
  margin-bottom:   14px;
  padding-bottom:  12px;
  border-bottom:   1px solid var(--line);
}

.panel-header.compact { margin-bottom: 12px; }

.panel-eyebrow { color: var(--brand); }

.panel-tools {
  display:     flex;
  flex-wrap:   wrap;
  gap:         8px;
  align-items: center;
}

.panel-subtitle {
  color:       var(--muted);
  font-size:   13px;
  line-height: 1.55;
  margin-top:  3px;
}

.wide { grid-column: 1 / -1; }

.panel-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap:                   12px;
}

.compact-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap:                   10px;
}

/* Collapsible panels */
.panel.is-collapsible.is-collapsed > :not(.panel-header),
.section-block.is-collapsible.is-collapsed > :not(.section-head) { display: none !important; }

.panel.is-collapsible.is-collapsed .panel-header {
  margin-bottom: 0;
  border:        1px dashed color-mix(in srgb, var(--brand) 18%, var(--line));
  border-radius: var(--radius-md);
  background:    linear-gradient(160deg, color-mix(in srgb, var(--panel-muted) 90%, white 10%), var(--panel));
  padding:       10px 14px;
}

.collapse-toggle { min-width: 86px; color: var(--muted); }
.collapse-toggle.is-collapsed { color: var(--brand); background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 22%, transparent); }

/* ============================================================
   SUMMARY / KPI CARDS
   ============================================================ */
.summary-card {
  position:      relative;
  overflow:      hidden;
  padding:       clamp(12px, 1.1vw, 14px) clamp(12px, 1.1vw, 14px) clamp(10px, 0.9vw, 12px) clamp(14px, 1.2vw, 16px);
  border-radius: var(--radius-md);
  border:        1px solid var(--line);
  background:    var(--panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow:    var(--shadow-soft);
  display:       grid;
  gap:           10px;
}

.summary-card::before {
  content:  "";
  position: absolute;
  inset:    0 auto 0 0;
  width:    var(--summary-accent);
  background: linear-gradient(180deg, var(--brand), var(--accent));
}

.summary-card h3 { font-size: 12px; color: var(--muted); margin: 0; font-weight: 700; }

.summary-card-head {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             8px;
}

.summary-card .big {
  font-size:      clamp(24px, 2vw, 2.8rem);
  font-weight:    700;
  letter-spacing: -0.025em;
  line-height:    1.05;
  font-variant-numeric: tabular-nums;
}

.summary-card-list { display: grid; gap: 5px; }

.summary-card-row {
  display:         flex;
  align-items:     baseline;
  justify-content: space-between;
  gap:             8px;
  padding-top:     5px;
  border-top:      1px dashed color-mix(in srgb, var(--line) 80%, transparent 20%);
}

.summary-card-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.summary-card-value { font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

.summary-status-inline {
  display:     inline-flex;
  align-items: center;
  gap:         10px;
  font-size:   clamp(20px, 1.6vw, 24px);
  font-weight: 700;
}

.summary-status-light {
  width:         13px;
  height:        13px;
  border-radius: var(--radius-pill);
  background:    #9ca3af;
  box-shadow:    0 0 0 4px rgba(156,163,175,0.18);
  flex:          0 0 auto;
}

.summary-status-inline--ok .summary-status-light { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 24%, transparent); animation: lamp-pulse 2.4s ease-in-out infinite; }
.summary-status-inline--danger .summary-status-light { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 22%, transparent); }

.summary-card--funds::before    { background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 60%, var(--accent))); }
.summary-card--positions::before{ background: linear-gradient(180deg, var(--success), color-mix(in srgb, var(--success) 50%, var(--accent))); }
.summary-card--yield::before    { background: linear-gradient(180deg, var(--accent), var(--brand)); }
.summary-card--system::before   { background: linear-gradient(180deg, var(--brand-strong), var(--brand)); }
.summary-card--account::before  { background: linear-gradient(180deg, var(--secondary), var(--muted)); }

/* Metric sub line */
.metric-sub  { font-size: 12px; color: var(--muted); }
.metric-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================================
   OVERVIEW LEAD CARD
   ============================================================ */
.overview-lead-card {
  padding:       clamp(16px, 1.5vw, 20px);
  border-radius: var(--radius-md);
  border:        1px solid color-mix(in srgb, var(--brand) 16%, transparent);
  background:
    radial-gradient(ellipse at 98% 2%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 32%),
    linear-gradient(160deg, var(--paper-strong), var(--panel-muted));
  box-shadow:    inset 0 1px 0 rgba(255,255,255,0.44);
  display:       grid;
  gap:           14px;
}

.overview-lead-card.is-empty { display: none; }

.overview-lead-copy h3 {
  font-family:    var(--font-display);
  font-size:      clamp(18px, 1.5vw, 24px);
  font-weight:    800;
  letter-spacing: var(--heading-track);
}

.overview-lead-copy p { color: var(--muted); line-height: 1.64; }

.overview-lead-grid {
  display:               grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:                   10px;
}

.overview-lead-metric {
  display:       grid;
  gap:           7px;
  padding:       13px 16px;
  border-radius: var(--radius-sm);
  border:        1px solid var(--line-strong);
  background:    color-mix(in srgb, var(--paper-strong) 84%, white 16%);
}

.overview-lead-metric-label {
  font-size:      11px;
  font-weight:    800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color:          var(--muted);
}

.overview-lead-metric-value {
  font-size:            clamp(18px, 1.4vw, 22px);
  font-weight:          700;
  letter-spacing:       -0.025em;
  line-height:          1.1;
  word-break:           break-word;
  font-variant-numeric: tabular-nums;
}

.overview-lead-metric-help { color: var(--muted); font-size: 11px; line-height: 1.5; }

.overview-lead-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.overview-lead-action {
  border:        none;
  border-radius: var(--radius-pill);
  padding:       10px 16px;
  font-weight:   800;
  cursor:        pointer;
  transition:    all var(--dur-fast) var(--ease-out);
  touch-action:  manipulation;
}

.overview-lead-action--primary { color: #fff; background: linear-gradient(160deg, var(--brand), var(--brand-strong)); box-shadow: var(--btn-shadow); }
.overview-lead-action--secondary { color: var(--ink); background: color-mix(in srgb, var(--paper-strong) 80%, white 20%); border: 1px solid var(--line-strong); }
.overview-lead-action:hover { transform: translateY(-1px); }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-shell {
  border-radius: var(--radius-sm);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 80%, transparent 20%);
  overflow:      hidden;
}

.chart-panel { min-height: var(--chart-panel-min-height, 220px); }

svg#activeRateChart,
svg#longFrrTrendChart {
  width:      100%;
  height:     clamp(220px, 26vw, 300px);
  display:    block;
  overflow:   visible;
}

/* ── Chart SVG primitives (kept theme-aware so text/lines never default to black) ── */
.chart-line {
  fill:            none;
  stroke-width:    2.4;
  stroke-linejoin: round;
  stroke-linecap:  round;
}
.chart-line.secondary  { stroke-dasharray: 6 5; stroke-width: 1.8; }
.chart-line.tertiary   { stroke-width: 1.8; }
.chart-area-fill       { stroke: none; }
.chart-dot             { stroke: var(--panel-strong); stroke-width: 1.5; }
.chart-guide           { stroke: var(--chart-grid); stroke-width: 1; }
.chart-guide.vertical  { stroke-dasharray: 2 6; }
.chart-axis-label      { fill: var(--chart-axis); font-size: 11px; font-family: var(--font-mono); }
.chart-frame-note      { fill: var(--muted); font-size: 11px; opacity: 0.8; }
.chart-lane-label      { fill: var(--muted); font-size: 11px; font-weight: 700; }
.chart-lane-note,
.chart-lane-current    { fill: var(--muted); font-size: 11px; }
.chart-lane-bg         { fill: var(--chart-highlight); }
.chart-range-bar       { stroke: var(--chart-range); stroke-width: 2; stroke-linecap: round; opacity: 0.55; }
.chart-marker-line     { stroke-width: 1; opacity: 0.45; stroke-dasharray: 2 3; }
.chart-end-text        { font-size: 12px; font-weight: 700; font-family: var(--font-mono); }
.chart-reference-tag,
.chart-average-tag     { fill: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.chart-highlight-band  { fill: var(--chart-highlight); }
.chart-highlight-label { fill: var(--muted); font-size: 10.5px; letter-spacing: 0.04em; }

.chart-focus-toolbar {
  display:     flex;
  align-items: center;
  gap:         12px;
  flex-wrap:   wrap;
  margin-bottom: 10px;
}

.chart-trace-summary { display: flex; flex-wrap: wrap; gap: 8px; }

.chart-range-tabs { margin-left: auto; }

/* Legend stat chips shown above the merged FRR chart */
.chart-stat-pill {
  display:        flex;
  flex-direction: column;
  gap:            2px;
  padding:        6px 12px;
  min-width:      82px;
  border:         1px solid var(--line);
  border-radius:  var(--radius-sm);
  background:     color-mix(in srgb, var(--panel-muted) 70%, transparent);
}
.chart-stat-pill.is-muted  { opacity: 0.7; }
.chart-stat-label {
  font-size:      11px;
  color:          var(--muted);
  letter-spacing: 0.02em;
}
.chart-stat-value {
  font-size:            15px;
  font-weight:          700;
  color:                var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Tab rows */
.tab-row {
  display:   flex;
  flex-wrap: wrap;
  gap:       6px;
}

.tab-row button {
  padding:       7px 13px;
  border-radius: var(--radius-pill);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 80%, white 20%);
  color:         var(--muted);
  font-weight:   700;
  font-size:     12px;
  cursor:        pointer;
  transition:    all var(--dur-fast) var(--ease-out);
}

.tab-row button.active,
.tab-row button[aria-selected="true"] {
  background:  linear-gradient(160deg, var(--brand), var(--brand-strong));
  color:       #fff;
  border-color:transparent;
  box-shadow:  var(--btn-shadow);
}

.tab-row button:hover { transform: translateY(-1px); color: var(--ink); }

/* ============================================================
   MARKET OVERVIEW TABLE
   ============================================================ */
.market-board-wrap,
.table-wrap {
  overflow-x:                  auto;
  -webkit-overflow-scrolling:  touch;
  border-radius:               var(--radius-sm);
  border:                      1px solid var(--line);
}

.market-board-table,
.position-table,
.book-depth-table,
table {
  width:           100%;
  border-collapse: separate;
  border-spacing:  0;
  font-size:       13px;
}

table th {
  padding:        11px 14px;
  font-size:      11px;
  font-weight:    600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color:          var(--muted);
  background:     color-mix(in srgb, var(--panel-muted) 85%, white 15%);
  text-align:     left;
  border-bottom:  1px solid var(--line);
  white-space:    nowrap;
  position:       sticky;
  top:            0;
  z-index:        1;
}

table th:last-child,
table td:last-child { padding-right: 16px; }

table td {
  padding:       11px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  vertical-align: middle;
  min-height:    44px;
  font-variant-numeric: tabular-nums;
}

table td:not(:first-child) { text-align: right; }
table td:first-child        { text-align: left;  }

table tbody tr:last-child td { border-bottom: none; }

table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--panel-muted) 35%, transparent); }

table tbody tr:hover td {
  background: color-mix(in srgb, var(--brand-soft) 50%, color-mix(in srgb, var(--panel-muted) 35%, transparent));
}

/* Ledger tables carry long Bitfinex descriptions; keep numbers tight and text readable. */
#interestPanel .ledger-table,
#eventPanel .event-log-table {
  table-layout: fixed;
}

#interestPanel .ledger-table { min-width: 760px; }
#interestPanel .ledger-table th:nth-child(1) { width: 140px; }
#interestPanel .ledger-table th:nth-child(2) { width: 112px; }
#interestPanel .ledger-table th:nth-child(3) { width: 128px; }
#interestPanel .ledger-table th:nth-child(4) { width: 92px; }
#interestPanel .ledger-table th:nth-child(5) { width: auto; }

#eventPanel .event-log-table { min-width: 860px; }
#eventPanel .event-log-table th:nth-child(1) { width: 142px; }
#eventPanel .event-log-table th:nth-child(2) { width: 132px; }
#eventPanel .event-log-table th:nth-child(3) { width: 210px; }
#eventPanel .event-log-table th:nth-child(4) { width: auto; }

table td.is-description,
table td.is-event-type,
table td.is-event-status,
table td.is-event-message,
table td.is-ledger-type,
table td.is-ledger-description {
  text-align: left;
}

table td.is-numeric,
table td.is-ledger-amount,
table td.is-ledger-balance {
  text-align: right;
}

#interestPanel .ledger-table .table-cell-body,
#eventPanel .event-log-table .table-cell-body {
  min-width: 0;
}

#interestPanel .ledger-table .is-ledger-type .table-cell-body,
#eventPanel .event-log-table .is-event-type .table-cell-body {
  display: flex;
  justify-content: flex-start;
}

#interestPanel .ledger-table .is-description .table-cell-content,
#eventPanel .event-log-table .is-description .table-cell-content {
  display: block;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.48;
  text-align: left;
}

#interestPanel .ledger-table .is-numeric .table-cell-content {
  display: block;
  text-align: right;
}

#eventPanel .event-log-table .pill,
#interestPanel .ledger-table .pill {
  max-width: 100%;
  white-space: normal;
  line-height: 1.25;
  text-align: center;
}

/* Table footer */
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.pager-info   { font-size: 12px; color: var(--muted); }
.pager-actions{ display: flex; gap: 6px; }
.pager-btn    { padding: 6px 11px; }

/* ============================================================
   GRIDS
   ============================================================ */
.content-grid,
.detail-grid,
.info-grid,
.insight-grid { display: grid; gap: var(--col-gap); align-items: stretch; }

.content-grid,
.detail-grid,
.info-grid,
.insight-grid { grid-template-columns: 1fr 1fr; }

.account-grid {
  display:               grid;
  gap:                   var(--col-gap);
  grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 1.1fr);
}

.account-grid.is-setup-first { grid-template-columns: minmax(380px, 1.1fr) minmax(280px, 0.9fr); }
.account-grid.is-setup-first .credential-form { order: -1; }

.account-side-stack { display: grid; gap: 12px; align-content: start; }

/* ============================================================
   CONTROL CARDS
   ============================================================ */
.control-card {
  padding:       14px 16px;
  border-radius: var(--radius-md);
  background:    color-mix(in srgb, var(--panel) 90%, white 10%);
  border:        1px solid var(--line);
  display:       grid;
  gap:           12px;
}

.control-card-head {
  display:         flex;
  flex-wrap:       wrap;
  align-items:     center;
  justify-content: space-between;
  gap:             10px;
}

.control-card h4 { font-size: 16px; font-weight: 800; }

.revenue-record-card {
  gap: 14px;
}

.revenue-record-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.revenue-record-metric {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--panel-muted) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
}

.revenue-record-metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.revenue-record-metric strong {
  color: var(--ink);
  font-size: clamp(16px, 1.7vw, 20px);
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.revenue-record-metric.is-secondary {
  opacity: 0.86;
}

.live-backtest-card {
  gap: 12px;
}

.live-backtest-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.live-backtest-result {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--panel-muted) 84%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}

.live-backtest-result > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.live-backtest-result > strong {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.live-backtest-condition,
.live-backtest-empty {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  color: var(--ink);
  white-space: nowrap;
}

.live-backtest-empty {
  color: var(--muted);
}

/* Lending control */
.lending-control-state-line {
  display:       inline-flex;
  align-items:   center;
  gap:           8px;
  padding:       10px 13px;
  border-radius: var(--radius-sm);
  background:    color-mix(in srgb, var(--panel) 88%, white 12%);
  border:        1px solid var(--line);
  font-size:     14px;
  font-weight:   700;
}

.lending-control-state-line::before {
  content:       "";
  width:         10px; height: 10px;
  border-radius: var(--radius-pill);
  background:    var(--muted);
  box-shadow:    0 0 0 3px color-mix(in srgb, var(--muted) 16%, transparent);
  flex:          0 0 auto;
}

.lending-control-state-line.is-live::before { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent); animation: lamp-pulse 2.4s ease-in-out infinite; }
.lending-control-state-line.is-stopped::before { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.lending-control-state-line.is-queued::before  { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }

.lending-control-actions {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   10px;
}

.lending-control-action-card {
  display:       grid;
  gap:           10px;
  padding:       13px;
  border-radius: var(--radius-md);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 85%, white 15%);
}

.lending-control-action-copy { display: grid; gap: 3px; }
.lending-control-action-copy strong { font-size: 14px; font-weight: 800; }
.lending-control-action-copy span { font-size: 12px; color: var(--muted); line-height: 1.5; }

.lending-action-btn { min-height: 48px; justify-content: center; font-size: 14px; }
.lending-action-btn.is-danger-action { background: linear-gradient(160deg, color-mix(in srgb, var(--danger) 80%, white 20%), var(--danger)); color: #fff; border: none; box-shadow: 0 6px 18px color-mix(in srgb, var(--danger) 22%, transparent); }
.lending-action-btn.is-inactive-action { opacity: 0.68; }
.lending-control-utility { justify-content: flex-start; }

/* Strategy presets */
.strategy-mode-presets { gap: 8px; }

.strategy-mode-presets button {
  display:         grid;
  gap:             5px;
  justify-items:   start;
  align-content:   start;
  min-width:       120px;
  min-height:      68px;
  padding:         11px 13px;
  border-radius:   var(--radius-md);
  font-size:       13px;
  text-align:      left;
}

.strategy-mode-presets button::after {
  content:       attr(data-mode-tag);
  display:       inline-flex;
  align-items:   center;
  padding:       3px 8px;
  border-radius: var(--radius-pill);
  background:    color-mix(in srgb, var(--brand) 10%, white 90%);
  color:         var(--brand);
  font-size:     10px;
  font-weight:   800;
  letter-spacing:0.03em;
  line-height:   1.2;
}

.strategy-mode-presets button.active {
  background:   linear-gradient(160deg, var(--brand), var(--brand-strong));
  color:        #fff;
  border-color: transparent;
  box-shadow:   var(--btn-shadow);
}

.strategy-mode-presets button.active::after { background: rgba(255,255,255,0.22); color: #fff; }

/* Order size presets */
.order-size-presets button.active {
  background:   linear-gradient(160deg, var(--brand), var(--brand-strong));
  color:        #fff;
  border-color: transparent;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-row { display: grid; gap: 6px; }

.form-row label {
  font-size:   13px;
  font-weight: 700;
  color:       var(--ink);
}

.form-row input,
.form-row select,
.form-row textarea {
  padding:       10px 14px;
  border-radius: var(--radius-sm);
  border:        1px solid var(--line-strong);
  background:    color-mix(in srgb, var(--paper) 96%, white 4%);
  color:         var(--ink);
  font-size:     16px; /* ≥16px prevents iOS Safari zoom */
  outline:       none;
  width:         100%;
  transition:    border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  -webkit-appearance: none;
}

.form-row input:focus,
.form-row select:focus {
  border-color: color-mix(in srgb, var(--brand) 50%, transparent);
  box-shadow:   0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
}

.form-row input::placeholder { color: color-mix(in srgb, var(--muted) 55%, transparent); }

.inline-field-grid { display: grid; gap: 10px; }

.inline-input-group { display: flex; }
.inline-input-group input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.inline-input-suffix { padding: 10px 12px; border: 1px solid var(--line-strong); border-left: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: color-mix(in srgb, var(--panel-muted) 90%, white 10%); font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }

.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.compact-actions { gap: 8px; }
.form-hint { font-size: 12px; color: var(--muted); line-height: 1.5; }

.wallet-panel-stack {
  display: grid;
  gap: 14px;
}

.wallet-transfer-form {
  display: grid;
  gap: 14px;
}

.wallet-transfer-route {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
}

.wallet-route-side {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.wallet-route-caption {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.wallet-route-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  min-height: 104px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-muted) 82%, white 18%);
  overflow: hidden;
}

.wallet-route-card-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.wallet-route-name-group {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.wallet-route-name {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.wallet-route-name-note {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.wallet-route-balance {
  flex: 0 0 auto;
  font-size: clamp(16px, 1.8vw, 21px);
  line-height: 1.12;
  text-align: right;
  color: var(--ink);
  white-space: nowrap;
}

.wallet-route-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.wallet-route-stat {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--paper) 72%, transparent);
}

.wallet-route-stat span {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

.wallet-route-stat strong {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-route-swap {
  align-self: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--panel) 86%, white 14%);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
}

.wallet-transfer-detail-grid {
  grid-template-columns: minmax(130px, 0.4fr) minmax(220px, 1fr);
}

/* ============================================================
   ACCOUNT / SETUP
   ============================================================ */
.account-setup-guide {
  padding:       18px 20px;
  margin-bottom: 16px;
  border:        1px solid var(--line);
  border-radius: var(--radius-md);
  background:    linear-gradient(160deg, color-mix(in srgb, var(--panel-muted) 92%, white 8%), var(--panel));
  box-shadow:    var(--shadow-soft);
  display:       grid;
  gap:           14px;
}

.account-setup-guide-copy { display: grid; gap: 6px; }
.account-setup-guide h3   { font-family: var(--font-display); font-size: clamp(17px, 1.3vw, 21px); font-weight: 800; letter-spacing: var(--heading-track); }

.setup-steps {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   10px;
}

.setup-step {
  display:               grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap:                   10px;
  align-items:           start;
  padding:               13px 14px;
  border-radius:         var(--radius-md);
  border:                1px solid var(--line);
  background:            color-mix(in srgb, var(--panel) 90%, white 10%);
}

.setup-step.is-active { border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); }
.setup-step.is-done   { background: color-mix(in srgb, var(--success) 8%, var(--panel) 92%); border-color: color-mix(in srgb, var(--success) 18%, var(--line)); }

.setup-step-index { width: 28px; height: 28px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--brand), var(--brand-strong)); color: #fff; font-weight: 800; font-size: 13px; flex: 0 0 auto; }
.setup-step-copy  { display: grid; gap: 3px; min-width: 0; }
.setup-step-copy h4 { font-size: 14px; }
.setup-step-copy p  { color: var(--muted); font-size: 12px; line-height: 1.55; }

.setup-step-badge { display: inline-flex; align-items: center; justify-content: center; padding: 5px 10px; min-width: 68px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 800; white-space: nowrap; background: var(--soft-surface); color: var(--muted); }
.setup-step-badge.is-done   { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.setup-step-badge.is-active { background: color-mix(in srgb, var(--warn)    14%, transparent); color: var(--warn); }

/* ============================================================
   ACCOUNT STATUS
   ============================================================ */
.account-status-card {
  padding:       16px;
  border-radius: var(--radius-md);
  background:    var(--panel-muted);
  border:        1px solid var(--line);
}

.account-status-card h3 { font-size: 17px; font-weight: 800; margin-bottom: 8px; }

.status-copy,
.form-hint,
.meta-line,
.empty-state p,
.hero-summary,
.login-copy { color: var(--muted); }

.meta-line { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ============================================================
   LANDING PAGE
   ============================================================ */
.landing-panel { padding: clamp(16px, 2vw, 24px); border-radius: var(--radius-xl); }

.landing-shell {
  display:               grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  gap:                   clamp(18px, 2vw, 30px);
  align-items:           start;
}

.landing-copy, .landing-preview { display: grid; gap: 14px; }

.landing-copy h2 {
  font-family:    var(--font-display);
  font-size:      clamp(30px, 3.2vw, 46px);
  font-weight:    800;
  letter-spacing: var(--heading-track);
  line-height:    1.04;
  max-width:      12ch;
  margin:         0;
  text-wrap:      balance;
}

.landing-trust-row { display: flex; flex-wrap: wrap; gap: 7px; }
.landing-trust-row .status-chip {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 16%, transparent);
  white-space: nowrap;
}

.landing-preview-card {
  padding:       clamp(14px, 1.4vw, 18px);
  border-radius: var(--radius-md);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 70%, white 30%);
  box-shadow:    inset 0 1px 0 rgba(255,255,255,0.44);
  display:       grid;
  gap:           12px;
}

.landing-step-grid {
  display:               grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:                   10px;
}

.landing-step-card {
  padding:       14px 14px 16px;
  border-radius: var(--radius-sm);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 68%, white 32%);
  display:       grid;
  gap:           8px;
}

.landing-step-index { width: 28px; height: 28px; border-radius: var(--radius-pill); display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--brand), var(--brand-strong)); color: #fff; font-weight: 800; font-size: 13px; }
.landing-step-card h4 { font-weight: 800; font-size: 15px; }
.landing-step-card p  { color: var(--muted); font-size: 13px; line-height: 1.55; }

/* Login gate */
.paywall-shell { display: grid; gap: 16px; max-width: 600px; margin: 0 auto; }

/* ============================================================
   NOTIFICATION PANEL
   ============================================================ */
.notification-panel {
  border:        1px solid var(--line);
  border-radius: var(--radius-md);
  background:    color-mix(in srgb, var(--panel-muted) 88%, white 12%);
  overflow:      hidden;
}

.notification-summary {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         12px 16px;
  cursor:          pointer;
  user-select:     none;
}

.notification-panel-body   { padding: 14px 16px; display: grid; gap: 12px; }
.notification-grid         { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.notification-frequency-card { grid-column: 1 / -1; }
.glossary-summary-hint     { font-size: 12px; color: var(--muted); }

/* ============================================================
   GLOSSARY
   ============================================================ */
.glossary-card {
  padding:       16px;
  border-radius: var(--radius-md);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 80%, white 20%);
}

.glossary-card h3 { font-family: var(--font-display); font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.glossary-card p  { color: var(--muted); font-size: 13px; line-height: 1.58; }
.glossary-full    { color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ============================================================
   BOOK / WALLET SECTION
   ============================================================ */
.book-grid     { display: grid; grid-template-columns: 1fr 1fr; gap: var(--col-gap); }
.subsection-title { font-size: 12px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }

.mini-metrics  { display: flex; flex-wrap: wrap; gap: 8px; }

/* ============================================================
   OPPORTUNITY FILTER
   ============================================================ */
.opportunity-filter-card    { grid-column: 1 / -1; }
.opportunity-filter-grid    { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.opportunity-quick-hint     { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
.market-review-headline     { font-family: var(--font-display); font-size: clamp(16px, 1.2vw, 20px); font-weight: 800; line-height: 1.25; margin-bottom: 12px; }
.market-review-grid         { display: grid; gap: 10px; }

.position-card {
  padding:       13px 16px;
  border-radius: var(--radius-sm);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 75%, white 25%);
}

/* ============================================================
   API TRUST CARD
   ============================================================ */
.api-trust-card {
  margin-bottom: 14px;
  border:        1px solid color-mix(in srgb, var(--brand) 18%, transparent);
  background:
    radial-gradient(ellipse at 100% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 30%),
    linear-gradient(160deg, var(--panel-muted), var(--panel));
}

.api-trust-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.api-trust-item {
  padding:       12px;
  border-radius: var(--radius-xs);
  border:        1px solid var(--line);
  background:    color-mix(in srgb, var(--panel-muted) 70%, white 30%);
  display:       grid;
  gap:           6px;
}

.api-trust-item strong { font-size: 13px; }
.api-trust-item p      { color: var(--muted); font-size: 12px; line-height: 1.55; }

/* Payment */
.payment-plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.payment-order-list { display: grid; gap: 8px; }

/* Coupon */
.coupon-list { display: grid; gap: 8px; }

/* Bitfinex status */
.bitfinex-status, .status-list { display: grid; gap: 8px; }
.status-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.status-fact  { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 88%, white 12%); }
.status-fact span   { display: block; color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
.status-fact strong { display: block; font-size: 14px; line-height: 1.45; }

.status-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* credential */
.credential-form { display: grid; gap: 12px; }
.google-login-mount { margin-top: 14px; }

/* ============================================================
   COLLAPSE TOOL ROW / PANEL TOOLS
   ============================================================ */
.collapse-tool-row { margin-left: auto; }

/* ============================================================
   ROUTE BRAND HERO
   ============================================================ */
.route-brand-hero { display: none; margin-bottom: 16px; }
.route-brand-image { width: clamp(90px, 8vw, 120px); height: auto; object-fit: contain; filter: var(--logo-shadow); padding: clamp(9px, 0.9vw, 13px); border-radius: var(--radius-lg); background: var(--logo-surface); border: 1px solid var(--logo-border); }
body[data-app-route="login"] .route-brand-hero { display: block; }

/* ============================================================
   MOBILE PAGE INTRO
   ============================================================ */
.mobile-page-intro { display: none; gap: 12px; }
.mobile-page-intro.is-visible { display: grid; }
.mobile-page-intro-copy { display: grid; gap: 5px; }
.mobile-page-intro h2 { font-size: 20px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { display: grid; gap: 12px; text-align: center; padding: 32px 20px; }
.empty-state h2 { font-family: var(--font-display); font-size: clamp(18px, 1.4vw, 22px); font-weight: 800; }

/* Landing action row */
.landing-action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.landing-action-row .google-login-mount { margin-top: 0; }

/* ============================================================
   MOBILE BOTTOM TAB BAR
   ============================================================ */
.mobile-tab-bar {
  display:          none;
  position:         fixed;
  bottom:           0;
  left:             0;
  right:            0;
  z-index:          200;
  height:           calc(60px + env(safe-area-inset-bottom));
  padding-bottom:   env(safe-area-inset-bottom);
  background:       color-mix(in srgb, var(--panel) 94%, white 6%);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter:  blur(20px);
  border-top:       1px solid var(--line);
  box-shadow:       0 -4px 20px var(--shadow-color);
  will-change:      transform;
}

.mobile-tab-bar-inner {
  display:               grid;
  grid-template-columns: repeat(5, 1fr);
  height:                60px;
}

.mobile-tab-item {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  justify-content:center;
  gap:            3px;
  border:         none;
  background:     transparent;
  cursor:         pointer;
  color:          var(--muted);
  font-size:      10px;
  font-weight:    700;
  touch-action:   manipulation;
  min-height:     44px;
  transition:     color var(--dur-fast) var(--ease-out);
  -webkit-user-select: none;
  user-select:    none;
}

.mobile-tab-item svg {
  width:         22px;
  height:        22px;
  stroke:        currentColor;
  stroke-width:  1.8;
  fill:          none;
}

.mobile-tab-item.is-active {
  color: var(--brand);
  position: relative;
}

.mobile-tab-item.is-active::before {
  content:       "";
  position:      absolute;
  top:           0;
  left:          50%;
  transform:     translateX(-50%);
  width:         32px;
  height:        2.5px;
  border-radius: 0 0 var(--radius-pill) var(--radius-pill);
  background:    var(--brand);
}

/* ============================================================
   RESPONSIVE — TABLET (1024px)
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: clamp(170px, 16vw, 200px); }
  .overview-lead-grid { grid-template-columns: repeat(2, 1fr); }
  .setup-steps { grid-template-columns: 1fr; }
}

/* ============================================================
   RESPONSIVE — MOBILE (768px)
   ============================================================ */
@media (max-width: 768px) {
  /* Show mobile tab bar, hide sidebar */
  .mobile-tab-bar { display: block; }

  .sidebar { display: none; }

  .dashboard-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Shell padding + body padding for tab bar */
  .page-shell { padding: 12px 16px calc(72px + env(safe-area-inset-bottom)); }

  /* Topbar: compact */
  .shell-topbar {
    padding:       10px 14px;
    border-radius: var(--radius-lg);
    position:      sticky;
    top:           env(safe-area-inset-top);
    z-index:       100;
    gap:           10px;
  }

  .shell-topbar h1 { font-size: 18px; }
  .eyebrow { font-size: 10px; }
  .brand-logo { width: 38px; height: 38px; }
  .topbar-actions {
    width:           100%;
    justify-content: flex-end;
    gap:             6px;
  }

  /* Hide non-essential topbar items */
  .language-switcher,
  #syncBadge,
  #exportButton { display: none !important; }

  /* KPI: 2×2 */
  .panel-grid,
  .compact-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  .summary-card .big { font-size: clamp(20px, 5vw, 26px); }

  /* Charts: single col, shorter */
  .content-grid,
  .detail-grid,
  .info-grid,
  .insight-grid,
  .account-grid,
  .overview-lead-grid { grid-template-columns: 1fr; }

  svg#activeRateChart,
  svg#longFrrTrendChart { height: 200px; }

  .chart-range-tabs { margin-left: 0; }

  /* Tables: horizontal scroll, first col sticky */
  .market-board-wrap,
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table th:first-child,
  table td:first-child {
    position:   sticky;
    left:       0;
    z-index:    1;
    background: var(--panel-strong);
  }

  /* Cards: full width */
  .landing-shell,
  .notification-grid,
  .lending-control-actions,
  .api-trust-grid { grid-template-columns: 1fr; }

  .landing-panel {
    padding: clamp(16px, 4.8vw, 22px);
    border-radius: clamp(22px, 7vw, 30px);
  }

  .landing-shell { gap: 14px; }
  .landing-copy { gap: 12px; }
  .landing-copy h2 {
    font-size: clamp(30px, 8.4vw, 36px);
    line-height: 1.03;
    max-width: 100%;
  }
  .landing-copy .panel-subtitle {
    font-size: 15px;
    line-height: 1.55;
    max-width: 32ch;
  }
  .landing-action-row { margin-top: 2px; }
  .landing-trust-row { gap: 6px; }
  .landing-trust-row .status-chip {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 12px;
  }
  .landing-preview { display: none; }
  .setup-steps    { grid-template-columns: 1fr; }
  .book-grid      { grid-template-columns: 1fr; }

  /* Panel radii */
  .panel          { border-radius: var(--radius-md); padding: 14px; }
  .summary-card   { border-radius: var(--radius-sm); }

  /* Hero: stack */
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-note-list { justify-content: flex-start; }
  .hero h2 { font-size: clamp(20px, 5.5vw, 28px); }

  /* FRR tape */
  .frr-tape-bar { padding: 8px 12px; border-radius: var(--radius-md); }

  /* Strategy presets */
  .strategy-mode-presets { gap: 6px; }
  .strategy-mode-presets button { min-width: unset; min-height: 56px; }

  .wallet-transfer-route {
    grid-template-columns: 1fr;
  }

  .wallet-route-swap {
    justify-self: center;
    transform: rotate(90deg);
  }

  .wallet-route-card-main {
    flex-direction: column;
  }

  .wallet-route-balance {
    text-align: left;
  }

  .wallet-transfer-detail-grid {
    grid-template-columns: 1fr;
  }

  .wallet-route-stats {
    grid-template-columns: 1fr;
  }

  .revenue-record-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .live-backtest-result-grid {
    grid-template-columns: 1fr;
  }

  @media (max-width: 480px) {
    .revenue-record-metrics {
      grid-template-columns: 1fr;
    }
  }

  /* Form inputs — ensure ≥16px for Safari zoom prevention */
  .form-row input,
  .form-row select { font-size: 16px; }

  /* 小屏(<=420px)頂列再瘦身:風格切換器縮成圓點、隱藏 FRR 跑馬、topbar 單列 */
  .theme-switcher { padding: 2px; gap: 2px; border-radius: var(--radius-pill); }
  .theme-btn { min-width: 40px; padding: 6px 10px; font-size: 11px; }

  /* 頂列 logo + 標題 壓縮,避免小 iPhone 溢位 */
  .shell-topbar { flex-wrap: wrap; row-gap: 8px; }
  .brand-block { flex: 0 1 auto; min-width: 0; }
  .brand-copy h1 { font-size: 15px; line-height: 1.2; }
  .brand-copy .eyebrow { font-size: 9px; letter-spacing: 0.12em; }

  /* 區段導覽改成可橫向捲動(sidebar 隱藏後,這些仍可從 section anchor 存取) */
  .sidebar-nav { flex-direction: row; overflow-x: auto; white-space: nowrap; }
  .sidebar-nav .nav-link { flex: 0 0 auto; }

  /* 主要內容區底部留給 mobile-tab-bar 的空間(已有),再多補 8px 給捲動餘裕 */
  .main-stack { padding-bottom: 12px; }
}

@media (max-width: 430px) {
  .page-shell { padding-inline: 10px; }
  .landing-panel { padding: 16px; }
  .theme-switcher {
    flex: 0 0 auto;
    padding: 3px;
  }
  .theme-btn {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    overflow: hidden;
    color: transparent !important;
    font-size: 0;
  }
  .theme-btn::after {
    content: "";
    width: 16px;
    height: 16px;
    border-radius: var(--radius-pill);
    display: block;
    margin: auto;
    background: var(--brand);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
  }
  .theme-btn[data-theme="muji"]::after {
    background: #b58a70;
  }
  .landing-copy h2 {
    font-size: clamp(28px, 8.6vw, 36px);
    max-width: 100%;
  }
  .landing-copy .panel-subtitle { font-size: 14px; }
}

@media (max-width: 375px) {
  .landing-copy h2 {
    font-size: 30px;
    max-width: 100%;
  }
  .landing-trust-row .status-chip { padding-inline: 8px; }
}

/* ============================================================
   PWA / IPHONE SPECIFIC
   ============================================================ */

/* Safe area for topbar */
@supports (padding-top: env(safe-area-inset-top)) {
  .shell-topbar {
    padding-top:    calc(14px + env(safe-area-inset-top, 0px));
    padding-left:   max(20px, env(safe-area-inset-left, 0px));
    padding-right:  max(20px, env(safe-area-inset-right, 0px));
  }
}

/* Standalone (Add to Home Screen) */
@media (display-mode: standalone) {
  .shell-topbar {
    padding-top: calc(14px + env(safe-area-inset-top));
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    margin-bottom: 0;
    top: 0;
  }

  .page-shell {
    padding-top: 0;
  }
}

body[data-standalone="true"] {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

@media (max-width: 768px) {
  body[data-standalone="true"] .page-shell {
    padding-top: 0;
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  body[data-standalone="true"] .shell-topbar {
    top: 0;
    margin-inline: -4px;
    padding-top: calc(10px + env(safe-area-inset-top));
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }

  body[data-standalone="true"] .brand-copy h1 {
    font-size: 17px;
    line-height: 1.1;
  }

  body[data-standalone="true"] .topbar-actions {
    gap: 5px;
  }

  body[data-standalone="true"] #refreshButton {
    min-width: 60px;
    padding-inline: 12px;
  }

  body[data-standalone="true"] .mobile-tab-bar {
    height: calc(58px + env(safe-area-inset-bottom));
  }
}

/* ============================================================
   FIX: iOS Safari PWA(加入主畫面)模式下,sticky topbar 因為
   backdrop-filter:blur 與半透明背景的渲染 bug,內容捲動時
   會「滲透」過 banner,讓使用者感覺 banner 跟著整塊一起動。
   解法:在 mobile + standalone 下強制改為完全不透明背景並
   關閉 backdrop-filter。
   ============================================================ */
@media (max-width: 768px) {
  .shell-topbar {
    -webkit-backdrop-filter: none;
    backdrop-filter:         none;
  }

  body[data-theme="slate"] .shell-topbar,
  body[data-theme="morandi"] .shell-topbar {
    background: linear-gradient(160deg,
      rgb(34, 44, 58) 0%,
      rgb(28, 36, 50) 100%);
  }

  body[data-theme="warm"] .shell-topbar,
  body[data-theme="muji"] .shell-topbar {
    background: linear-gradient(180deg,
      rgb(254, 251, 247) 0%,
      rgb(247, 239, 230) 100%);
  }
}

@supports (color: oklch(50% 0.1 100)) {
  @media (max-width: 768px) {
    body[data-theme="slate"] .shell-topbar,
    body[data-theme="morandi"] .shell-topbar {
      background: linear-gradient(160deg,
        oklch(28% 0.03 225) 0%,
        oklch(30% 0.025 225) 100%);
    }
  }
}

@media (display-mode: standalone) {
  .shell-topbar {
    -webkit-backdrop-filter: none;
    backdrop-filter:         none;
  }

  body[data-theme="slate"] .shell-topbar,
  body[data-theme="morandi"] .shell-topbar {
    background: linear-gradient(160deg,
      rgb(34, 44, 58) 0%,
      rgb(28, 36, 50) 100%);
  }

  body[data-theme="warm"] .shell-topbar,
  body[data-theme="muji"] .shell-topbar {
    background: linear-gradient(180deg,
      rgb(254, 251, 247) 0%,
      rgb(247, 239, 230) 100%);
  }
}

/* Touch targets */
button,
a,
[role="button"],
.page-tab,
.nav-link,
.theme-btn,
.lang-btn {
  min-height:   44px;
  touch-action: manipulation;
}

/* Prevent tap highlight */
* { -webkit-tap-highlight-color: transparent; }

/* 只在真正不該長按選取的元件上停用 text selection(表格數字仍可複製) */
.brand-logo {
  -webkit-user-select: none;
  user-select: none;
}

/* Smooth scroll on iOS */
.sidebar,
.table-wrap,
.market-board-wrap {
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   LOGIN PAGE OVERRIDES
   ============================================================ */
body[data-app-route="login"] .sidebar,
body[data-app-route="login"] .main-stack > :not(#landingPanel),
body[data-app-route="login"] #frrTapeBar,
body[data-app-route="login"] #refreshButton,
body[data-app-route="login"] #exportButton,
body[data-app-route="login"] #syncBadge,
body[data-app-route="login"] .mobile-tab-bar { display: none !important; }

/* Native iOS shell: SwiftUI owns the navigation chrome, web keeps only content. */
body[data-native-shell="ios"] .sidebar,
body[data-native-shell="ios"] .shell-topbar,
body[data-native-shell="ios"] .page-tabs,
body[data-native-shell="ios"] .mobile-tab-bar,
body[data-native-shell="ios"] .mobile-page-intro {
  display: none !important;
}

body[data-native-shell="ios"] .page-shell {
  min-height: 100dvh;
  padding:
    max(10px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

body[data-native-shell="ios"] .dashboard-layout {
  display: block;
}

body[data-native-shell="ios"] .main-stack {
  gap: 12px;
  padding-bottom: 0;
}

body[data-native-shell="ios"][data-app-route="login"] .page-shell {
  display: grid;
  align-items: center;
  padding-top: max(16px, env(safe-area-inset-top));
}

body[data-app-route="login"] .dashboard-layout { grid-template-columns: 1fr; }
body[data-app-route="login"] #landingPanel { max-width: 980px; margin: 0 auto; }
body[data-app-route="login"] .page-shell { min-height: 100dvh; }

@media (min-width: 769px) {
  body[data-app-route="login"] .dashboard-layout {
    min-height: calc(100vh - var(--topbar-h) - var(--page-pad) * 4);
    align-items: center;
  }

  body[data-app-route="login"] .landing-shell {
    gap: clamp(16px, 1.8vw, 24px);
  }
}

@media (max-width: 768px) {
  body[data-app-route="login"] .page-shell {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  body[data-app-route="login"] .dashboard-layout {
    gap: 10px;
  }

  body[data-app-route="login"] #landingPanel {
    width: 100%;
  }
}

body[data-auth-stage="recovering"] .landing-shell,
body[data-auth-stage="authenticated"] .landing-shell { grid-template-columns: 1fr; }
body[data-auth-stage="recovering"] .landing-preview,
body[data-auth-stage="authenticated"] .landing-preview { display: none; }

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.decision-copy  { color: var(--muted); font-size: 13px; line-height: 1.55; }
.market-stage   { } /* placeholder for chart section spacing */
.account-billing-card { } /* payment card */
.paywall-card   { max-width: 480px; }
.paywall-copy   { }
.paywall-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Profile image avatar */
.user-summary img { object-fit: cover; }

/* Loading state */
.boot-skeleton       { max-width: 1100px; margin: 0 auto; padding: 24px 20px 12px; }
.boot-skeleton.hidden { display: none; }
.boot-skeleton-card  { border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--paper); box-shadow: var(--shadow); padding: 18px 20px; }
.boot-skeleton-title { font-size: 14px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.72; }
.boot-skeleton-text  { margin-top: 8px; font-size: 15px; line-height: 1.6; color: var(--muted); }

/* Asset failure banner */
.asset-failure-banner { position: sticky; top: 0; z-index: 9999; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--danger); color: #fff8f2; }
.asset-failure-banner.hidden { display: none; }
.asset-failure-title { font-size: 14px; font-weight: 800; }
.asset-failure-text  { font-size: 12px; opacity: 0.9; }

/* Scroll area protection */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 30%, transparent); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 50%, transparent); }


/* slate 深色主題 — 針對 .control-card / .sidebar-card 額外補色,
   防止淺色 color-mix 在深色底圖上對比不足 */
body[data-theme="slate"] .control-card,
body[data-theme="morandi"] .control-card {
  background:    linear-gradient(180deg, rgba(54,68,86,0.92), rgba(44,58,76,0.88));
  border:        1px solid rgba(140,165,192,0.20);
  box-shadow:    0 1px 3px rgba(10,16,26,0.24), 0 8px 22px rgba(10,16,26,0.18);
}
body[data-theme="slate"] .control-card .panel-subtitle,
body[data-theme="morandi"] .control-card .panel-subtitle {
  color: rgba(220, 230, 242, 0.72);
}
body[data-theme="slate"] .mobile-tab-bar,
body[data-theme="morandi"] .mobile-tab-bar {
  background: linear-gradient(180deg, rgba(32,42,58,0.92), rgba(24,32,44,0.96));
  border-top: 1px solid rgba(140,165,192,0.18);
}

/* ============================================================
   QUALITY UPGRADE — Visual refinements (both themes)
   ============================================================ */

/* ── Background grid texture ── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line, rgba(128,100,80,0.03)) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line, rgba(128,100,80,0.03)) 1px, transparent 1px);
  background-size: 32px 32px;
}

body[data-theme="slate"]::before,
body[data-theme="morandi"]::before {
  --grid-line: rgba(120,150,180,0.04);
}

.page-shell { position: relative; z-index: 1; }

/* ── Topbar: frosted glass quality ── */
.shell-topbar {
  border-bottom: 1px solid rgba(200,210,220,0.08);
}

body[data-theme="warm"] .shell-topbar,
body[data-theme="muji"] .shell-topbar {
  border-bottom-color: rgba(154,117,98,0.10);
}

/* APR quick indicator: monospace numbers */
.quick-apr-indicator strong,
.frr-tape-detail,
.frr-tape-symbol { font-family: var(--font-mono); }

.frr-tape-detail { color: var(--ink); letter-spacing: 0.02em; }

/* ── Lamp: double-layer pulse glow ── */
@keyframes lamp-pulse-double {
  0%   { box-shadow: 0 0 0 2px color-mix(in srgb,var(--success) 40%,transparent), 0 0 0 5px color-mix(in srgb,var(--success) 16%,transparent); }
  50%  { box-shadow: 0 0 0 5px color-mix(in srgb,var(--success) 22%,transparent), 0 0 0 10px color-mix(in srgb,var(--success) 6%,transparent); }
  100% { box-shadow: 0 0 0 2px color-mix(in srgb,var(--success) 40%,transparent), 0 0 0 5px color-mix(in srgb,var(--success) 16%,transparent); }
}

.runtime-lamp.is-on,
.summary-status-light.is-on { animation: lamp-pulse-double 2.2s ease-in-out infinite; }

.lending-control-state-line.is-live::before { animation: lamp-pulse-double 2.2s ease-in-out infinite; }

/* ── Theme switcher: pill quality ── */
.theme-btn.is-active,
.lang-btn.is-active {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-strong) 100%);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 30%, transparent),
              inset 0 1px 0 rgba(255,255,255,0.18);
}

/* ── Sidebar: deeper + right gradient border ── */
body[data-theme="slate"] .sidebar-card,
body[data-theme="morandi"] .sidebar-card {
  background: rgba(36,44,58,0.95);
  border-right: 1px solid;
  border-image: linear-gradient(180deg, rgba(120,150,180,0.18) 0%, rgba(120,150,180,0.04) 60%, transparent 100%) 1;
  border-radius: var(--radius-lg);
}

body[data-theme="warm"] .sidebar-card,
body[data-theme="muji"] .sidebar-card {
  background: rgba(245,235,222,0.96);
}

/* ── Nav link: 48px row, 10px gap, active stripe ── */
.nav-link {
  min-height: 40px;
  gap: 10px;
  padding: 9px 12px;
  position: relative;
}

.nav-link.is-active {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border-color: color-mix(in srgb, var(--brand) 18%, transparent);
}

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  min-height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

/* ── KPI cards: gradient bg + borders + highlight ── */
.summary-card {
  background: linear-gradient(160deg, var(--panel), var(--panel-muted));
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 rgba(255,255,255,0.07);
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}

body[data-theme="warm"] .summary-card,
body[data-theme="muji"] .summary-card {
  border-color: rgba(154,117,98,0.12);
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 rgba(255,255,255,0.55);
}

body[data-theme="slate"] .summary-card,
body[data-theme="morandi"] .summary-card {
  background: linear-gradient(160deg, rgba(52,64,82,0.88), rgba(42,52,70,0.92));
  border-color: rgba(100,130,160,0.12);
  box-shadow:
    var(--shadow-soft),
    inset 0 0.5px 0 rgba(120,160,200,0.10);
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255,255,255,0.07);
}

/* KPI big number: 3rem 800 */
.summary-card .big {
  font-size: clamp(26px, 2.4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.04;
  font-variant-numeric: tabular-nums lining-nums;
}

/* Positive value glow */
.pos {
  text-shadow: 0 0 20px color-mix(in srgb, var(--success) 40%, transparent);
}

/* KPI corner accent */
.summary-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 48px; height: 48px;
  background: radial-gradient(circle at 0% 0%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 70%);
  pointer-events: none;
}

/* ── Overview lead card: upgraded ── */
.overview-lead-card {
  border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: box-shadow 200ms var(--ease-out);
}

body[data-theme="slate"] .overview-lead-card,
body[data-theme="morandi"] .overview-lead-card {
  background:
    radial-gradient(ellipse at 96% 4%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 30%),
    linear-gradient(160deg, rgba(46,60,80,0.92), rgba(36,48,66,0.96));
}

/* Overview lead title: larger */
.overview-lead-copy h3 {
  font-size: clamp(20px, 1.6vw, 1.5rem);
  line-height: 1.25;
}

/* Metric dividers: border-right style, no card box */
.overview-lead-metric {
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 20px 10px 0;
}

.overview-lead-metric:last-child { border-right: none; }

.overview-lead-grid {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

/* ── Charts: upgraded ── */
/* Dotted grid lines */
.chart-grid-line {
  stroke: currentColor;
  stroke-opacity: 0.06;
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

/* Chart panel hover */
.chart-panel {
  transition: box-shadow 200ms var(--ease-out);
}
.chart-panel:hover {
  box-shadow: var(--shadow);
}

/* ── Panels: hover lift ── */
.panel,
.control-card,
.landing-preview-card,
.landing-step-card,
.glossary-card {
  transition:
    transform 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out);
}

.panel:hover,
.landing-preview-card:hover,
.glossary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Exception: nested panels don't need lift */
.panel .panel,
.control-card:hover { transform: none; }

/* ── Buttons: pressed state ── */
.primary-btn:active   { transform: scale(0.97) !important; box-shadow: inset 0 2px 6px rgba(0,0,0,0.18) !important; }
.secondary-btn:active { transform: scale(0.97) !important; }
.ghost-btn:active     { transform: scale(0.97) !important; }

/* ── All numeric columns ── */
table td,
.summary-card-value,
.overview-lead-metric-value,
.big,
.kpi-value,
.frr-tape-detail { font-variant-numeric: tabular-nums lining-nums; }

/* ── Card gap: 16px ── */
.main-stack          { gap: 16px; }
.panel-grid          { gap: 16px; }
.compact-kpi-grid    { gap: 16px; }
.section-block       { gap: 14px; }
.detail-grid,
.info-grid,
.content-grid,
.insight-grid { gap: 16px; }

/* ── Warm theme: quality sync ── */
body[data-theme="warm"] .overview-lead-metric,
body[data-theme="muji"] .overview-lead-metric {
  border-right-color: rgba(154,117,98,0.14);
}

body[data-theme="warm"] .panel:hover,
body[data-theme="muji"] .panel:hover {
  box-shadow:
    0 8px 32px rgba(74,56,42,0.10),
    0 2px 8px rgba(74,56,42,0.06);
}

body[data-theme="warm"] .summary-card:hover,
body[data-theme="muji"] .summary-card:hover {
  box-shadow:
    0 8px 28px rgba(74,56,42,0.12),
    inset 0 1px 0 rgba(255,255,255,0.55);
}

/* ── Slate theme: topbar frosted ── */
body[data-theme="slate"] .shell-topbar,
body[data-theme="morandi"] .shell-topbar {
  background:
    linear-gradient(160deg,
      rgba(34,44,58,0.85) 0%,
      rgba(28,36,50,0.75) 100%);
  border-bottom: 1px solid rgba(120,150,190,0.08);
}

@supports (color: oklch(50% 0.1 100)) {
  body[data-theme="slate"] .shell-topbar,
  body[data-theme="morandi"] .shell-topbar {
    background:
      linear-gradient(160deg,
        oklch(28% 0.03 225 / 0.85) 0%,
        oklch(30% 0.025 225 / 0.75) 100%);
    border-bottom-color: oklch(80% 0.01 225 / 0.08);
  }
}

/* ── Summary status light on-state: double pulse ── */
.summary-status-light {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent), 0 0 0 6px color-mix(in srgb, var(--success) 8%, transparent);
}

/* ── Tooltip placeholder (hover) ── */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms, transform 160ms;
}

@media (max-width: 768px) {
  .topbar-actions {
    justify-content: flex-start !important;
  }

  .theme-switcher {
    flex: 0 0 auto;
    padding: 3px;
    gap: 3px;
  }

  .theme-btn {
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 !important;
    overflow: hidden;
    color: transparent !important;
    font-size: 0 !important;
  }

  .theme-btn::after {
    content: "";
    width: 16px;
    height: 16px;
    border-radius: var(--radius-pill);
    display: block;
    margin: auto;
    background: var(--brand);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
  }

  .theme-btn[data-theme="muji"]::after {
    background: #b58a70;
  }
}

/* ============================================================
   UX TUNE — authenticated dashboard and mobile readability
   ============================================================ */
body:not([data-app-route="login"])[data-auth-stage="authenticated"] #landingPanel {
  display: none !important;
}

@media (max-width: 768px) {
  .frr-tape-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    overflow: visible;
  }

  .frr-tape-label {
    white-space: normal;
  }

  .frr-tape-marquee {
    overflow-x: auto;
    mask-image: none;
    -webkit-mask-image: none;
    scrollbar-width: none;
  }

  .frr-tape-marquee::-webkit-scrollbar {
    display: none;
  }

  .frr-tape-track,
  .frr-tape-sequence {
    gap: 8px;
  }

  .frr-tape-track {
    animation: none;
    width: max-content;
    min-width: 100%;
  }

  .frr-tape-item {
    gap: 7px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .frr-tape-time {
    display: none;
  }

  .theme-btn::after {
    content: "藍";
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(160deg, #6aa8c4, #486477);
  }

  .theme-btn[data-theme="muji"]::after {
    content: "陶";
    background: linear-gradient(160deg, #c29a7c, #8d604c);
  }

  .overview-lead-card {
    gap: 12px;
  }

  .overview-lead-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .overview-lead-action {
    width: 100%;
  }

  .account-header-tools {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .runtime-indicator,
  .quick-apr-indicator {
    min-width: 0;
  }

  .mobile-card-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tbody {
    display: grid;
    gap: 10px;
  }

  .mobile-card-table tr {
    display: grid;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--panel-muted) 88%, transparent);
    box-shadow: var(--shadow-soft);
  }

  .mobile-card-table td,
  .mobile-card-table td:first-child,
  .mobile-card-table td:not(:first-child) {
    position: static;
    display: grid;
    grid-template-columns: minmax(88px, 0.42fr) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 0;
    padding: 8px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
    background: transparent !important;
    text-align: right;
  }

  .mobile-card-table td:last-child {
    border-bottom: 0;
    padding-right: 0;
  }

  .mobile-card-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: none;
    text-align: left;
  }

  .mobile-card-table td.is-spanning {
    display: block;
    text-align: left;
  }

  .mobile-card-table td.is-spanning::before {
    display: none;
  }

  .mobile-card-table .table-cell-body {
    min-width: 0;
    display: flex;
    justify-content: flex-end;
  }

  .mobile-card-table .table-cell-content,
  .mobile-card-table .asset-cell,
  .mobile-card-table .cell-actions {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .mobile-card-table .cell-actions {
    justify-content: flex-end;
  }

  #interestPanel .ledger-table,
  #eventPanel .event-log-table {
    min-width: 0;
  }

  #interestPanel .ledger-table .is-ledger-type .table-cell-body,
  #eventPanel .event-log-table .is-event-type .table-cell-body,
  #interestPanel .ledger-table .is-description .table-cell-body,
  #eventPanel .event-log-table .is-description .table-cell-body {
    justify-content: flex-end;
  }

  #interestPanel .ledger-table .is-description .table-cell-content,
  #eventPanel .event-log-table .is-description .table-cell-content {
    text-align: right;
  }

  #interestPanel .ledger-table td.is-description,
  #eventPanel .event-log-table td.is-description {
    grid-template-columns: 1fr;
    text-align: left;
  }

  #interestPanel .ledger-table td.is-description::before,
  #eventPanel .event-log-table td.is-description::before {
    margin-bottom: 2px;
  }

  #interestPanel .ledger-table .is-description .table-cell-body,
  #eventPanel .event-log-table .is-description .table-cell-body {
    justify-content: flex-start;
  }

  #interestPanel .ledger-table .is-description .table-cell-content,
  #eventPanel .event-log-table .is-description .table-cell-content {
    text-align: left;
  }

  .market-board-wrap,
  .table-wrap {
    border: 0;
    overflow: visible;
  }

  .table-footer {
    flex-wrap: wrap;
    padding-inline: 4px;
  }

  .pager-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pager-btn {
    width: 100%;
    justify-content: center;
  }

  .wallet-transfer-form {
    gap: 12px;
  }

  .wallet-route-card {
    min-height: 0;
    padding: 12px;
  }

  .wallet-route-card-main {
    flex-direction: row;
    align-items: center;
  }

  .wallet-route-balance {
    max-width: 46%;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .wallet-route-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wallet-route-swap {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 390px) {
  .wallet-route-card-main {
    align-items: flex-start;
  }

  .wallet-route-balance {
    max-width: 50%;
    font-size: 16px;
  }

  .wallet-route-stats {
    grid-template-columns: 1fr;
  }
}
