/* Gold Journal — desktop sidebar layout, mobile tab bar, light/dark follows the device. No build step. */

:root {
  --bg: #f5f3ed;
  --surface: #ffffff;
  --surface-2: #f3f0e7;
  --surface-3: #ebe6d8;
  --border: #e6e0d1;
  --border-strong: #d8cfb9;
  --text: #1b1912;
  --muted: #6d6656;
  --faint: #9a9280;
  --accent: #a07400;
  --accent-strong: #7b5900;
  --accent-soft: #f6ecce;
  --accent-ink: #ffffff;
  --pos: #11783a;
  --pos-soft: #e1f3e6;
  --neg: #c0262f;
  --neg-soft: #fbe5e4;
  --warn: #9a5b00;
  --warn-soft: #fcefd6;
  --info: #2a63b8;
  --info-soft: #e5eefb;
  --focus: #2f6fde;

  --side-bg: #fbf9f3;
  --side-text: #2b271d;
  --side-muted: #857d6a;
  --side-hover: rgb(60 45 0 / 6%);
  --side-active: #f6ecce;
  --side-border: #e6e0d1;
  --side-brand: #3a2c00;
  --side-active-text: #7b5900;
  --side-active-icon: #a07400;
  --side-chip: rgb(60 45 0 / 5%);
  --side-chip-border: rgb(60 45 0 / 9%);
  --side-chip-on: #ffffff;
  --side-ok: #11783a;
  --side-warn: #9a5b00;
  --side-err: #c0262f;
  --art-bg: radial-gradient(120% 120% at 0% 0%, #fff1c7 0%, #f8ecd0 55%, #efe2c0 100%);
  --art-text: #3a2f14;
  --art-brand: #3a2c00;
  --art-tag: #6d5f3d;
  --logo-ink: #2a1f00;
  --logo-spark: #b8860b;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(40 30 0 / 5%), 0 4px 14px rgb(40 30 0 / 5%);
  --shadow-lg: 0 10px 40px rgb(40 30 0 / 12%);
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Leelawadee UI", Thonburi, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --side-w: 248px;
  color-scheme: light;
}

/* Dark tokens: used when the device prefers dark (unless the user picked light), or when the user
   picked dark with the theme switch (static/theme.js sets <html data-theme>). Keep both copies equal. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0e0b;
    --surface: #18170f;
    --surface-2: #201e17;
    --surface-3: #29261d;
    --border: #2e2b22;
    --border-strong: #3d392d;
    --text: #efe9da;
    --muted: #a69e8a;
    --faint: #7b7462;
    --accent: #e2b443;
    --accent-strong: #f1c862;
    --accent-soft: #352c15;
    --accent-ink: #1a1405;
    --pos: #4fd680;
    --pos-soft: #13301e;
    --neg: #ff7a7a;
    --neg-soft: #3b1a1a;
    --warn: #f3b941;
    --warn-soft: #382a10;
    --info: #7fb0ff;
    --info-soft: #172640;
    --focus: #7aa7ff;
    --side-bg: #0b0a08;
    --side-text: #e8e2d0;
    --side-muted: #958c76;
    --side-hover: rgb(255 255 255 / 6%);
    --side-active: rgb(226 180 67 / 15%);
    --side-border: rgb(255 255 255 / 6%);
    --side-brand: #fff3cf;
    --side-active-text: #ffe39a;
    --side-active-icon: #f0c45a;
    --side-chip: rgb(255 255 255 / 6%);
    --side-chip-border: rgb(255 255 255 / 8%);
    --side-chip-on: rgb(255 255 255 / 12%);
    --side-ok: #6be39a;
    --side-warn: #f3c15a;
    --side-err: #ff8a8a;
    --art-bg: radial-gradient(120% 120% at 0% 0%, #3a2c08 0%, #15120a 55%, #0c0b07 100%);
    --art-text: #f3ead2;
    --art-brand: #fff3cf;
    --art-tag: #cbbf9e;
    --logo-ink: #1a1405;
    --logo-spark: #f1c862;
    --shadow: 0 1px 0 rgb(255 255 255 / 3%) inset;
    --shadow-lg: 0 10px 40px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0e0b;
  --surface: #18170f;
  --surface-2: #201e17;
  --surface-3: #29261d;
  --border: #2e2b22;
  --border-strong: #3d392d;
  --text: #efe9da;
  --muted: #a69e8a;
  --faint: #7b7462;
  --accent: #e2b443;
  --accent-strong: #f1c862;
  --accent-soft: #352c15;
  --accent-ink: #1a1405;
  --pos: #4fd680;
  --pos-soft: #13301e;
  --neg: #ff7a7a;
  --neg-soft: #3b1a1a;
  --warn: #f3b941;
  --warn-soft: #382a10;
  --info: #7fb0ff;
  --info-soft: #172640;
  --focus: #7aa7ff;
  --side-bg: #0b0a08;
  --side-text: #e8e2d0;
  --side-muted: #958c76;
  --side-hover: rgb(255 255 255 / 6%);
  --side-active: rgb(226 180 67 / 15%);
  --side-border: rgb(255 255 255 / 6%);
  --side-brand: #fff3cf;
  --side-active-text: #ffe39a;
  --side-active-icon: #f0c45a;
  --side-chip: rgb(255 255 255 / 6%);
  --side-chip-border: rgb(255 255 255 / 8%);
  --side-chip-on: rgb(255 255 255 / 12%);
  --side-ok: #6be39a;
  --side-warn: #f3c15a;
  --side-err: #ff8a8a;
  --art-bg: radial-gradient(120% 120% at 0% 0%, #3a2c08 0%, #15120a 55%, #0c0b07 100%);
  --art-text: #f3ead2;
  --art-brand: #fff3cf;
  --art-tag: #cbbf9e;
  --logo-ink: #1a1405;
  --logo-spark: #f1c862;
  --shadow: 0 1px 0 rgb(255 255 255 / 3%) inset;
  --shadow-lg: 0 10px 40px rgb(0 0 0 / 50%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent-strong); text-decoration-thickness: from-font; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
p { margin: 0 0 .6em; }
code, pre { font-family: var(--mono); font-size: 13px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.num, .kpi__value, .tile__value, .trade__net, .trade__lots, .trade__prices, .trade__r, .day__sum,
.acct__value, .acct__stats dd, .table td, .day-cell__net, .news-row__nums, .upcoming__time { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ico { width: 20px; height: 20px; flex: none; }

/* ------------------------------------------------------------- app shell */

.app { min-height: 100vh; }
.main { min-width: 0; }
.content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 16px calc(88px + env(safe-area-inset-bottom));
}

.sidebar { display: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 17px;
  letter-spacing: .01em;
  color: inherit;
  text-decoration: none;
}
.brand__gold { color: var(--accent); }

/* The mark (app/web/logo.py): a faceted gold gem whose last candle breaks out and sparkles. Ink and
   sparkle follow the theme; the shine sweep, twinkle and rising candles are CSS (no inline styles: CSP). */
.logo { display: block; flex: none; overflow: visible; }
.logo .logo__ink { fill: var(--logo-ink); }
.logo .logo__spark { fill: var(--logo-spark); }
.logo__shine { opacity: 0; transform: translateX(-12px); }
.logo__star, .logo__candle { transform-box: fill-box; }
.logo__star { transform-origin: center; }
.logo__candle { transform-origin: 50% 100%; }
@media (prefers-reduced-motion: no-preference) {
  .logo__star, .logo__candle { transition: transform .35s cubic-bezier(.2, .8, .2, 1.3); }
  .brand:hover .logo__shine, .brand:focus-visible .logo__shine { animation: logo-shine .9s ease-out; }
  .brand:hover .logo__star, .brand:focus-visible .logo__star { transform: scale(1.35) rotate(45deg); }
  .brand:hover .logo__candle--3, .brand:focus-visible .logo__candle--3 { transform: translateY(-2px); }
  .logo--hero .logo__candle { animation: logo-rise .55s cubic-bezier(.2, .8, .2, 1.25) both; }
  .logo--hero .logo__candle--2 { animation-delay: .15s; }
  .logo--hero .logo__candle--3 { animation-delay: .3s; }
  .logo--hero .logo__breakout { animation: logo-pop .3s ease-out .65s both; }
  .logo--hero .logo__star { animation: logo-pop .45s cubic-bezier(.2, .8, .2, 1.6) .75s both,
                                       logo-twinkle 3.2s ease-in-out 1.4s infinite; }
  .logo--hero .logo__shine { animation: logo-shine-loop 7s ease-out 1s infinite; }
}
@keyframes logo-shine { 0% { opacity: 0; transform: translateX(-12px); } 15% { opacity: 1; }
  100% { opacity: 0; transform: translateX(72px); } }
@keyframes logo-shine-loop { 0% { opacity: 0; transform: translateX(-12px); } 2% { opacity: 1; }
  14%, 100% { opacity: 0; transform: translateX(72px); } }
@keyframes logo-twinkle { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(.6) rotate(45deg); } }
@keyframes logo-rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes logo-pop { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }

.mobilebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.mobilebar .status { margin-left: auto; }

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar .nav__item {
  flex-direction: column;
  gap: 2px;
  padding: 6px 2px;
  font-size: 11.5px;
  color: var(--muted);
  justify-content: center;
}
.tabbar .nav__item.is-active { color: var(--accent-strong); background: none; }
.tabbar .nav__item.is-active .ico { stroke-width: 2.2; }

.nav { display: grid; gap: 2px; }
.nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--side-text);
  text-decoration: none;
  font: inherit;
  font-size: 14.5px;
  background: none;
  border: 0;
  width: 100%;
  cursor: pointer;
  text-align: left;
}

.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  padding: 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 2px;
}
.usermenu__panel a, .usermenu__panel button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  background: none;
  border: 0;
  width: 100%;
  cursor: pointer;
}
.usermenu__panel a:hover, .usermenu__panel button:hover { background: var(--surface-2); }
.usermenu__panel form { margin: 0; }
.usermenu__name { margin: 2px 10px 6px; font-weight: 650; }

.me__avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f6d77a, #b8860b);
  color: #2a1e00;
  font-weight: 750;
  font-size: 14px;
  flex: none;
}

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 14px 16px;
    background: var(--side-bg);
    color: var(--side-text);
    border-right: 1px solid var(--side-border);
    overflow-y: auto;
  }
  .sidebar .brand { padding: 2px 10px 10px; color: var(--side-brand); }
  .sidebar .nav__item:hover { background: var(--side-hover); }
  .sidebar .nav__item.is-active { background: var(--side-active); color: var(--side-active-text); }
  .sidebar .nav__item .ico { color: var(--side-muted); }
  .sidebar .nav__item.is-active .ico { color: var(--side-active-icon); }
  .sidebar__foot { margin-top: auto; display: grid; gap: 8px; }
  .sidebar__foot form { margin: 0; }
  .sidebar .status { justify-content: flex-start; background: var(--side-chip); }
  .me {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--side-text);
    text-decoration: none;
  }
  .me:hover, .me.is-active { background: var(--side-hover); }
  .me__text { display: grid; line-height: 1.25; min-width: 0; }
  .me__text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .me__text small { color: var(--side-muted); font-size: 12px; }
  .mobilebar, .tabbar { display: none; }
  .content { padding: 30px 36px 48px; }
}

.demo-banner {
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-align: center;
  font-size: 13px;
  padding: 6px 16px;
}

/* ------------------------------------------------------------- status dots & pills */

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface-2);
  color: var(--muted);
}
.status .dot { background: currentColor; }
.status--ok { color: var(--pos); }
.status--running { color: var(--accent-strong); }
.status--stale, .status--none { color: var(--warn); }
.status--error { color: var(--neg); }
.sidebar .status--ok { color: var(--side-ok); }
.sidebar .status--stale, .sidebar .status--none { color: var(--side-warn); }
.sidebar .status--error { color: var(--side-err); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot--online, .status--ok .dot { background: var(--pos); box-shadow: 0 0 0 0 rgb(34 197 94 / 50%); animation: pulse 2s infinite; }
.dot--connecting, .dot--starting { background: var(--accent); }
.dot--error { background: var(--neg); }
.dot--stale, .dot--stopped { background: var(--warn); }
.dot--off { background: var(--faint); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(34 197 94 / 45%); }
  70% { box-shadow: 0 0 0 7px rgb(34 197 94 / 0%); }
  100% { box-shadow: 0 0 0 0 rgb(34 197 94 / 0%); }
}
@media (prefers-reduced-motion: reduce) { .dot--online, .status--ok .dot { animation: none; } }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}
.pill--open, .pill--connecting, .pill--starting, .pill--running { background: var(--accent-soft); color: var(--accent-strong); }
.pill--ok, .pill--online { background: var(--pos-soft); color: var(--pos); }
.pill--error { background: var(--neg-soft); color: var(--neg); }
.pill--stale, .pill--stopped, .pill--soon { background: var(--warn-soft); color: var(--warn); }
.pill--off { background: var(--surface-3); color: var(--faint); }

.side {
  display: inline-block;
  min-width: 44px;
  padding: 1px 0;
  text-align: center;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: .05em;
  border: 1.5px solid currentColor;
}
.side--buy { color: var(--pos); }
.side--sell { color: var(--neg); }

/* ------------------------------------------------------------- page building blocks */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  margin: 0 0 18px;
}
.page-head h1 { font-size: 22px; font-weight: 750; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; }
@media (min-width: 960px) { .page-head h1 { font-size: 28px; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin: 0 0 16px;
  min-width: 0;
}
.card h2 { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card__head h2 { margin: 0; }
.card__head a { font-size: 14px; }
.narrow { max-width: 680px; }

.grid-2 { display: grid; gap: 16px; }
.grid-2 > .card { margin: 0; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn .ico { width: 18px; height: 18px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-strong); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, var(--border)); }
.btn--danger:hover { background: var(--neg-soft); }
.btn--block { width: 100%; }
.btn--lg { min-height: 46px; font-size: 16px; }
.btn--sm { min-height: 32px; padding: 4px 11px; font-size: 13.5px; }
.btn--icon { min-width: 40px; padding: 0; }

.field { display: grid; gap: 5px; font-size: 13.5px; color: var(--muted); min-width: 0; border: 0; padding: 0; margin: 0; }
.field legend { padding: 0; margin-bottom: 6px; }
.field input:not([type=checkbox]), .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px stops iOS from zooming into inputs */
}
.field input:focus, .field select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
.field select:disabled { opacity: .6; }
.field--inline { grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.field--compact select { min-height: 36px; font-size: 14px; padding: 4px 10px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14.5px; color: var(--text); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.stack { display: grid; gap: 14px; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.form-error { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--neg-soft); color: var(--neg); font-size: 14px; }
.sub-form { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); }
.danger-zone { margin-top: 26px; padding-top: 18px; border-top: 1px dashed var(--border-strong); display: grid; gap: 8px; justify-items: start; }
.field--custom-tz { display: none; }
form:has(select[name=sync_timezone] option[value=custom]:checked) .field--custom-tz { display: grid; }

.hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}
.notice { padding: 10px 13px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-strong); font-size: 14px; margin: 0 0 14px; }
.notice p { margin: 0 0 6px; }
.notice--ok { background: var(--pos-soft); color: var(--pos); }
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.cmd {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}
.cmd code { background: none; padding: 0; }
.steps { margin: 0 0 6px; padding-left: 20px; display: grid; gap: 4px; }

.empty { text-align: center; padding: 44px 12px; }
.empty__title { font-size: 17px; font-weight: 650; margin: 0 0 6px; }
.empty__code { font-size: 46px; font-weight: 750; color: var(--accent); margin: 0; }
.empty .cmd { text-align: left; display: inline-block; max-width: 100%; }
.footnote { font-size: 12.5px; color: var(--muted); text-align: center; margin: 10px 0 0; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-weight: 600; color: var(--muted); font-size: 12.5px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; }
.table a { font-weight: 600; text-decoration: none; }

/* ------------------------------------------------------------- guest / login */

.guest { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login {
  width: 100%;
  max-width: 940px;
  display: grid;
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.login__art {
  position: relative;
  padding: 28px 28px 24px;
  background: var(--art-bg);
  color: var(--art-text);
  overflow: hidden;
}
.login__glow {
  position: absolute;
  width: 360px;
  height: 360px;
  right: -120px;
  top: -140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(240 196 90 / 35%), transparent 65%);
}
.login__brand { position: relative; display: flex; align-items: center; gap: 14px; font-size: 26px; font-weight: 800; color: var(--art-brand); }
.login__tag { position: relative; margin: 14px 0 0; color: var(--art-tag); font-size: 15px; line-height: 1.7; }
.login__panel { padding: 26px 24px 28px; }
.login__title { font-size: 22px; margin: 0 0 16px; }
.login__lead { margin: -6px 0 16px; font-size: 14px; line-height: 1.6; }
.login__alt { margin: 18px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.field__row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field__link { font-size: 13px; font-weight: 500; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent-strong); }
.otp-input { font-size: 22px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.otp-demo { font-size: 16px; letter-spacing: .2em; }
.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 14px; }
@media (min-width: 820px) {
  .login { grid-template-columns: 1.05fr 1fr; min-height: 520px; }
  .login__art { padding: 48px 44px; display: flex; flex-direction: column; justify-content: flex-end; }
  .login__brand { font-size: 32px; }
  .login__panel { padding: 56px 48px; align-self: center; }
}

/* ------------------------------------------------------------- KPIs */

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 0;
}
.kpi__label { font-size: 12.5px; color: var(--muted); }
.kpi__value { font-size: 24px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__value--sm { font-size: 15.5px; white-space: normal; line-height: 1.35; }
.kpi__sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.kpi--news { background: linear-gradient(135deg, var(--surface) 55%, var(--accent-soft)); }
.kpis--compact .kpi__value { font-size: 20px; }

/* ------------------------------------------------------------- live accounts */

.accounts-live { display: grid; gap: 12px; margin: 0 0 16px; }
@media (min-width: 700px) { .accounts-live { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }
.acct {
  position: relative;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.acct::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--faint); }
.acct--online::before { background: var(--pos); }
.acct--error::before { background: var(--neg); }
.acct--stale::before, .acct--stopped::before { background: var(--warn); }
.acct--connecting::before, .acct--starting::before { background: var(--accent); }
.acct--empty { display: grid; gap: 10px; justify-items: start; color: var(--muted); }
.acct--empty::before { display: none; }
.acct__head { display: flex; align-items: center; gap: 10px; }
.acct__name { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.acct__name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct__name small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct__equity { margin: 12px 0 8px; display: grid; }
.acct__label { font-size: 12px; color: var(--muted); }
.acct__value { font-size: 26px; font-weight: 750; letter-spacing: -.01em; }
.acct__stats { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.acct__stats div { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.acct__stats dt { color: var(--muted); }
.acct__stats dd { margin: 0; font-weight: 600; }
.acct__foot { margin: 10px 0 0; font-size: 12px; color: var(--faint); }
.acct__empty { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.acct__error { margin: 8px 0 0; font-size: 13px; color: var(--neg); }
.live-tag { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--pos-soft); color: var(--pos); font-size: 11px; font-weight: 750; letter-spacing: .06em; vertical-align: middle; }
.live-tag .dot { width: 7px; height: 7px; }

/* ------------------------------------------------------------- dashboard lists */

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li + li { border-top: 1px solid var(--border); }
.mini-list a { display: flex; align-items: center; gap: 12px; padding: 10px 2px; color: inherit; text-decoration: none; }
.mini-list a:hover { background: var(--surface-2); border-radius: 8px; }
.mini-list__main { display: grid; flex: 1; min-width: 0; line-height: 1.35; font-weight: 600; }
.mini-list small { color: var(--muted); font-weight: 400; font-size: 12px; }
.mini-list__end { display: grid; text-align: right; line-height: 1.35; }

.news-brief { padding: 10px 0; border-bottom: 1px solid var(--border); }
.news-brief p { margin: 0 0 3px; font-size: 14px; }
.news-brief__title { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.news-brief__bias { color: var(--muted); }
.upcoming { list-style: none; margin: 8px 0 0; padding: 0; }
.upcoming li { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.upcoming li + li { border-top: 1px solid var(--border); }
.upcoming__time { font-weight: 700; width: 46px; }
.upcoming__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming__in { color: var(--accent-strong); font-size: 13px; white-space: nowrap; }

.imp { display: inline-flex; gap: 2px; align-items: flex-end; flex: none; }
.imp i { width: 4px; border-radius: 2px; background: var(--border-strong); }
.imp i:nth-child(1) { height: 7px; }
.imp i:nth-child(2) { height: 10px; }
.imp i:nth-child(3) { height: 13px; }
.imp--1 i.on { background: var(--faint); }
.imp--2 i.on { background: var(--warn); }
.imp--3 i.on { background: var(--neg); }
.cur { display: inline-block; min-width: 38px; padding: 0 5px; border-radius: 5px; background: var(--surface-3); font-size: 12px; font-weight: 750; text-align: center; letter-spacing: .03em; }

/* ------------------------------------------------------------- filters (trades, news) */

.filters { margin: 0 0 14px; }
.filters--row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.chip span:hover { background: var(--surface-2); }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.custom-range { display: none; gap: 8px; margin-top: 10px; grid-template-columns: 1fr 1fr; max-width: 520px; }
.filters.is-custom .custom-range,
.filters:has(input[value="custom"]:checked) .custom-range { display: grid; }
.filters:has(input[name="period"]:checked:not([value="custom"])) .custom-range { display: none; }

.more-filters { margin-top: 10px; }
.more-filters summary { display: inline-block; cursor: pointer; font-size: 14px; color: var(--accent-strong); padding: 4px 0; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; max-width: 860px; }
@media (min-width: 760px) { .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.filter-actions { display: flex; gap: 8px; margin-top: 10px; }
.results { transition: opacity .15s; }
.results.htmx-request { opacity: .5; }

.acct-switch select { min-height: 38px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; max-width: 100%; }
.acct-chip { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13.5px; color: var(--muted); }

/* ------------------------------------------------------------- trade list */

.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; }
@media (min-width: 760px) { .summary { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { display: grid; gap: 1px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); min-width: 0; }
.tile__label { font-size: 12px; color: var(--muted); }
.tile__value { font-size: 21px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paged-note { margin: 0 0 10px; font-size: 14px; }

.trades { list-style: none; margin: 0; padding: 0; max-width: 900px; }
.day { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 16px 4px 7px; font-size: 13px; color: var(--muted); }
.day:first-child { padding-top: 2px; }
.day__date { font-weight: 650; color: var(--text); }
.trade { display: block; margin: 0 0 8px; padding: 12px 15px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: inherit; text-decoration: none; }
.trade:active { background: var(--surface-2); }
@media (hover: hover) { .trade:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); } }
.trade__row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.trade__row--sub { margin-top: 4px; font-size: 14px; }
.trade__lots { font-weight: 650; }
.trade__sym { color: var(--muted); font-size: 14px; }
.trade__net { margin-left: auto; font-weight: 750; font-size: 16px; white-space: nowrap; }
.trade__prices { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade__r { margin-left: auto; font-weight: 650; white-space: nowrap; }
.trade__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.icon { display: inline-flex; color: var(--accent-strong); }
.icon svg { width: 15px; height: 15px; }
.more { list-style: none; text-align: center; padding: 8px 0 4px; }

/* ------------------------------------------------------------- trade detail */

.back { display: inline-block; margin: 0 0 12px; font-size: 14px; text-decoration: none; }
.trade-head__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.trade-head__net { font-size: 34px; font-weight: 800; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.trade-head__sub { font-size: 14px; font-variant-numeric: tabular-nums; }
.kv { margin: 0; display: grid; grid-template-columns: 1fr; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); flex: none; }
.kv dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv__total dt, .kv__total dd { font-weight: 750; color: inherit; }
.kv--compact > div { padding: 6px 0; font-size: 14px; }
.kv .path { font-family: var(--mono); font-size: 12px; }
@media (min-width: 700px) {
  .kv { grid-template-columns: 1fr 1fr; column-gap: 30px; }
  .kv > div:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}
.legs { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.legs th, .legs td { padding: 8px 5px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.legs th { font-weight: 600; color: var(--muted); font-size: 12px; }
.legs tr:last-child td { border-bottom: 0; }
.legs .num { text-align: right; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.tag { padding: 2px 10px; border-radius: 999px; font-size: 13px; background: var(--surface-2); }
.tag--news { background: var(--accent-soft); color: var(--accent-strong); }
.tag--mistake { background: var(--neg-soft); color: var(--neg); }
.tag--setup { background: var(--pos-soft); color: var(--pos); }
.notes { white-space: pre-wrap; margin: 10px 0 0; overflow-wrap: anywhere; }
@media (min-width: 1100px) {
  .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .detail-grid > .card { margin: 0; }
}

/* ------------------------------------------------------------- P&L calendar */

.cal-toolbar { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.cal-toolbar__title { font-size: 20px; font-weight: 750; min-width: 170px; text-align: center; }
.calendar { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.calendar__head, .calendar__row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar__head > div { padding: 8px 6px; font-size: 12px; font-weight: 650; color: var(--muted); text-align: center; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.calendar__weekcol { display: none; }
.day-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 66px;
  padding: 6px 6px 7px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.calendar__row > .day-cell:nth-child(7) { border-right: 0; }
.calendar__row:last-child .day-cell { border-bottom: 0; }
.day-cell.is-out { background: color-mix(in srgb, var(--surface-2) 60%, transparent); color: var(--faint); pointer-events: none; }
.day-cell__date { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 650; }
.day-cell.is-today .day-cell__date { color: var(--accent-strong); }
.day-cell.is-today::after { content: ""; position: absolute; inset: 0; border: 2px solid var(--accent); pointer-events: none; }
.day-cell__news { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--neg-soft); color: var(--neg); font-size: 10.5px; font-weight: 750; }
.day-cell__net { font-size: 12.5px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-cell__meta { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-cell--pos { background: var(--pos-soft); }
.day-cell--pos .day-cell__net { color: var(--pos); }
.day-cell--neg { background: var(--neg-soft); }
.day-cell--neg .day-cell__net { color: var(--neg); }
.day-cell--flat { background: var(--surface-2); }
a.day-cell:not(.is-out):hover { filter: brightness(.97); }
@media (max-width: 559px) { .day-cell__meta { display: none; } .day-cell { min-height: 58px; } }
@media (min-width: 960px) {
  .calendar__head, .calendar__row { grid-template-columns: repeat(7, minmax(0, 1fr)) 130px; }
  .calendar__weekcol { display: grid; align-content: center; gap: 1px; padding: 8px 10px; background: var(--surface-2); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 700; text-align: right; }
  .calendar__head .calendar__weekcol { display: block; font-size: 12px; text-align: center; font-weight: 650; color: var(--muted); }
  .calendar__row:last-child .calendar__weekcol { border-bottom: 0; }
  .calendar__row > .day-cell:nth-child(7) { border-right: 1px solid var(--border); }
  .week-total__label { font-size: 11px; font-weight: 500; color: var(--muted); }
  .week-total small { font-weight: 500; color: var(--muted); font-size: 11.5px; }
  .day-cell { min-height: 98px; padding: 9px 10px; gap: 4px; }
  .day-cell__net { font-size: 15px; }
  .day-cell__meta { font-size: 12px; }
}

/* ------------------------------------------------------------- news */

.next-news {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin: 0 0 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 70%);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}
.next-news__label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--accent-strong); }
.next-news__label .ico { width: 17px; height: 17px; }
.next-news__name { font-weight: 700; flex: 1; min-width: 200px; }
.next-news__when { font-size: 14px; }
.news-day { margin: 0 0 18px; }
.news-day__title { font-size: 14px; font-weight: 700; color: var(--muted); margin: 0 0 8px; padding-left: 4px; }
.news-rows { list-style: none; margin: 0; padding: 0; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.news-row { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.news-row:last-child { border-bottom: 0; }
.news-row.is-soon { background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.news-row__line { display: grid; grid-template-columns: 46px auto auto minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; }
.news-row__time { font-weight: 750; font-size: 14px; }
.news-row__name { font-weight: 600; min-width: 0; }
.news-row__nums { grid-column: 1 / -1; display: flex; gap: 18px; font-size: 13.5px; }
.news-row__state { grid-row: 1; grid-column: 5; }
.num-cell { display: inline-flex; align-items: baseline; gap: 5px; }
.num-cell small { color: var(--muted); font-size: 11.5px; }
@media (min-width: 900px) {
  .news-row__line { grid-template-columns: 52px 48px 22px minmax(0, 1fr) 330px 110px; }
  .news-row__nums { grid-column: auto; justify-content: flex-end; }
  .news-row__state { grid-row: auto; grid-column: auto; text-align: right; }
}
.news-summary { margin: 8px 0 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.news-summary p { margin: 0 0 4px; }
.news-summary p:last-child { margin-bottom: 0; }
.news-summary__move { color: var(--muted); font-variant-numeric: tabular-nums; }
.bias--1 { color: var(--pos); font-weight: 650; }
.bias---1 { color: var(--neg); font-weight: 650; }
.ai-box { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--info-soft); }
.ai-box p { margin: 4px 0 0; color: var(--text); }
.ai-box__tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 750; color: var(--info); }
.ai-box__tag .ico { width: 15px; height: 15px; }
.setup-card ol { padding-left: 20px; display: grid; gap: 6px; }
.poller { display: none; }

/* ------------------------------------------------------------- broker accounts */

.broker-grid { display: grid; gap: 14px; margin: 0 0 16px; }
@media (min-width: 1000px) { .broker-grid { grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); } }
.broker { margin: 0; }
.broker__head { display: flex; align-items: center; gap: 11px; margin-bottom: 8px; }
.broker__title { flex: 1; min-width: 0; }
.broker__title h2 { margin: 0; font-size: 17px; }
.broker__title p { margin: 2px 0 0; font-size: 13px; }
.broker__msg { font-size: 13.5px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.broker__msg.is-error { background: var(--neg-soft); color: var(--neg); }
.broker__foot { margin-top: 10px; display: flex; gap: 8px; }

.runs { list-style: none; margin: 0; padding: 0; }
.run { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.run:last-child { border-bottom: 0; }
.run__time { font-variant-numeric: tabular-nums; }
.run__msg { flex-basis: 100%; color: var(--muted); overflow-wrap: anywhere; }

/* ------------------------------------------------------------- markets & charts */

.ico--xs { width: 15px; height: 15px; vertical-align: -2px; }
.market-filters { display: grid; gap: 12px; margin: 0 0 14px; }
.market-filters .chip small { color: inherit; opacity: .65; font-size: 12px; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 460px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
}
.search input { flex: 1; min-width: 0; min-height: 42px; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; outline: none; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

.quotes { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.quotes__head, .quote { display: grid; grid-template-columns: minmax(0, 1fr) 110px 86px 40px; align-items: center; gap: 10px; padding: 10px 14px; }
.quotes__head { font-size: 12px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.quote { border-bottom: 1px solid var(--border); }
.quote:last-child { border-bottom: 0; }
.quote:hover { background: var(--surface-2); }
.quote.is-stale .quote__price { color: var(--faint); }
.quote__name { display: grid; min-width: 0; color: inherit; text-decoration: none; line-height: 1.3; }
.quote__name strong { font-size: 15px; }
.quote__name small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote__price { font-weight: 700; font-size: 15px; text-align: right; }
.quote__chg { font-weight: 650; text-align: right; }
.quote__range { font-size: 13px; color: var(--muted); text-align: right; }
.quotes .num { text-align: right; }
.hide-sm { display: none; }
@media (min-width: 760px) {
  .quotes__head, .quote { grid-template-columns: minmax(0, 1fr) 140px 110px 210px 44px; }
  .hide-sm { display: block; }
}

.star-form { margin: 0; display: flex; justify-content: center; }
.star { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; background: none; color: var(--faint); cursor: pointer; }
.star:hover { background: var(--surface-3); color: var(--accent); }
.star.is-on { color: var(--accent); }
.star.is-on .ico { fill: currentColor; }

.chart-layout { display: grid; gap: 16px; }
@media (min-width: 1180px) { .chart-layout { grid-template-columns: minmax(0, 1fr) 240px; } }
.chart-main { min-width: 0; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin: 0 0 12px; }
.chart-head__title h1 { font-size: 24px; font-weight: 800; }
.chart-head__title p { margin: 2px 0 0; }
.chart-head__price { display: grid; gap: 1px; margin-left: auto; text-align: right; }
.chart-head__bid { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.chart-head__bid.is-stale { color: var(--faint); }
.chart-head__chg { font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-head__price small { font-variant-numeric: tabular-nums; }
.tf-bar { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.tf { padding: 5px 11px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.tf:hover { background: var(--surface-2); color: var(--text); }
.tf.is-active { background: var(--accent); color: var(--accent-ink); }
.chart-box { position: relative; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.chart { height: 62vh; min-height: 340px; }
@media (min-width: 960px) { .chart { height: calc(100vh - 290px); min-height: 460px; } }
.chart-status { position: absolute; inset: auto 12px 12px auto; padding: 6px 12px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 13px; box-shadow: var(--shadow); }
.chart-status[hidden] { display: none; }
.chart-side .card { padding: 14px; }
.chart-side h2 { font-size: 14px; margin-bottom: 8px; }
.side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 360px; overflow-y: auto; }
.side-list a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.side-list a:hover { background: var(--surface-2); }
.side-list a.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }

/* ------------------------------------------------------------- onboarding: help links, welcome, checklist, guide, tour */

.page-head__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.page-head__tools form { margin: 0; }
.help-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.help-link:hover { color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.help-link .ico { width: 17px; height: 17px; }

.welcome { max-width: 860px; margin: 0 auto; }
.welcome__hero { text-align: center; padding: 18px 8px 8px; }
.welcome__hero .logo { margin: 0 auto 14px; }
.welcome__hero h1 { font-size: 26px; font-weight: 800; margin: 0 0 10px; }
.welcome__hero p { color: var(--muted); max-width: 620px; margin: 0 auto; font-size: 15.5px; }
@media (min-width: 960px) { .welcome__hero h1 { font-size: 32px; } }
.welcome__steps { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 820px) { .welcome__steps { grid-template-columns: 1fr 1fr; } }
.welcome-step {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 0;
}
.welcome-step > div { min-width: 0; }
.welcome-step__num {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}
.welcome-step h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 4px 0 6px; }
.welcome-step h2 .ico { color: var(--accent-strong); }
.welcome-step p { color: var(--muted); font-size: 14px; margin: 0; }
.welcome-step .cmd { font-size: 12px; }
.welcome__safety { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 22px 0 0; color: var(--pos); font-weight: 600; font-size: 14px; }
.welcome__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0 0; }
.welcome__later { text-align: center; font-size: 13px; margin-top: 12px; }

.checklist { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 45%); }
.checklist__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.checklist__head h2 { margin: 0; }
.checklist__head p { margin: 2px 0 0; font-size: 13px; }
.checklist__head form { margin: 0; }
.checklist__bar { width: 100%; height: 8px; margin: 12px 0 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.checklist__bar::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
.checklist__bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.checklist__bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.checklist__steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
@media (min-width: 900px) { .checklist__steps { grid-template-columns: 1fr 1fr; column-gap: 18px; } }
.check-step { display: flex; align-items: flex-start; gap: 10px; padding: 7px 6px; border-radius: 10px; }
.check-step:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.check-step__mark { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-strong); font-size: 12px; font-weight: 700; color: var(--muted); }
.check-step__mark .ico { width: 15px; height: 15px; stroke-width: 2.6; }
.check-step.is-done .check-step__mark { background: var(--pos); border-color: var(--pos); color: #fff; }
.check-step__body { display: grid; min-width: 0; color: inherit; text-decoration: none; line-height: 1.35; }
.check-step__body strong { font-size: 14.5px; }
.check-step__body small { color: var(--muted); font-size: 12.5px; }
.check-step.is-done .check-step__body strong { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.checklist--done { background: var(--pos-soft); border-color: color-mix(in srgb, var(--pos) 35%, var(--border)); }
.checklist--done .checklist__bar::-webkit-progress-value { background: var(--pos); }
.checklist--done .checklist__bar::-moz-progress-bar { background: var(--pos); }

.guide { display: grid; gap: 16px; }
@media (min-width: 1100px) { .guide { grid-template-columns: 220px minmax(0, 1fr); align-items: start; } }
.guide__toc { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
@media (min-width: 1100px) { .guide__toc { position: sticky; top: 24px; } }
.guide__toc-title { font-weight: 700; margin: 0 0 6px; }
.guide__toc ol { margin: 0; padding-left: 18px; display: grid; gap: 3px; font-size: 14px; }
.guide__toc a { text-decoration: none; }
.guide__body { min-width: 0; max-width: 860px; }
.guide-sec { scroll-margin-top: 80px; }
.guide-sec h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.guide-sec h2 .ico { color: var(--accent-strong); }
.guide-sec p, .guide-sec li { font-size: 14.5px; }
.guide-list { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.guide-dl { margin: 6px 0 10px; display: grid; gap: 0; }
.guide-dl > div { display: grid; gap: 2px 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.guide-dl > div:last-child { border-bottom: 0; }
@media (min-width: 700px) { .guide-dl > div { grid-template-columns: 190px 1fr; } }
.guide-dl dt { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.guide-dl dd { margin: 0; color: var(--muted); font-size: 14.5px; }
.faq { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 650; font-size: 14.5px; }
.faq p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.tour { position: fixed; inset: 0; z-index: 1000; }
.tour__spot {
  position: fixed;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgb(8 6 2 / 64%);
  outline: 2px solid #f0c45a;
  outline-offset: 2px;
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
  pointer-events: none;
}
.tour__card {
  position: fixed;
  width: min(340px, calc(100vw - 24px));
  padding: 16px 18px 14px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.tour__count { margin: 0 0 4px; font-size: 12px; font-weight: 700; color: var(--accent-strong); letter-spacing: .02em; }
.tour__title { margin: 0 0 6px; font-size: 17px; }
.tour__text { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; }
.tour__actions { display: flex; justify-content: flex-end; gap: 8px; }
.tour__actions .btn--ghost { margin-right: auto; }
@media (prefers-reduced-motion: reduce) { .tour__spot { transition: none; } }

/* ------------------------------------------------------------- theme switch */

.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.theme-switch button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.theme-switch button .ico { width: 17px; height: 17px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow); }
.sidebar .theme-switch { background: var(--side-chip); border-color: var(--side-chip-border); justify-self: start; }
.sidebar .theme-switch button { color: var(--side-muted); }
.sidebar .theme-switch button:hover { color: var(--side-brand); }
.sidebar .theme-switch button[aria-pressed="true"] { background: var(--side-chip-on); color: var(--side-active-icon); box-shadow: none; }
.sidebar__theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; font-size: 12.5px; color: var(--side-muted); }
.usermenu__theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; font-size: 13.5px; color: var(--muted); }
.guest-theme { position: fixed; top: 14px; right: 14px; z-index: 5; }

/* ------------------------------------------------------------- calendars: views, month picker, lists */

.view-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 14px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.seg__item { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.seg__item .ico { width: 17px; height: 17px; }
.seg__item:hover { color: var(--text); }
.seg__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chip-link { display: inline-block; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 14px; text-decoration: none; }
.chip-link:hover { background: var(--surface-2); }
.chip-link.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.month-nav, .filter-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.month-nav select, .filter-inline select {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.filter-inline { margin-left: auto; }
.list-range { margin: 0 0 10px; font-size: 13.5px; }

.year-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 0 0 14px; }
@media (min-width: 900px) { .year-strip { grid-template-columns: repeat(12, minmax(0, 1fr)); } }
.year-strip__m {
  display: grid;
  gap: 1px;
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.year-strip__m span { font-size: 12px; color: var(--muted); }
.year-strip__m strong { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; color: var(--faint); }
.year-strip__m.is-pos { background: var(--pos-soft); }
.year-strip__m.is-pos strong { color: var(--pos); }
.year-strip__m.is-neg { background: var(--neg-soft); }
.year-strip__m.is-neg strong { color: var(--neg); }
.year-strip__m.is-active { outline: 2px solid var(--accent); outline-offset: -1px; }

.day-list { list-style: none; margin: 0; padding: 0; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.day-list li + li { border-top: 1px solid var(--border); }
.day-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; grid-template-areas: "date net go" "stats net go"; align-items: center; gap: 2px 12px; padding: 12px 16px; color: inherit; text-decoration: none; }
.day-row:hover { background: var(--surface-2); }
.day-row__date { grid-area: date; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.day-row__news { color: var(--neg); font-size: 12px; font-weight: 650; }
.day-row__stats { grid-area: stats; color: var(--muted); font-size: 13px; }
.day-row__net { grid-area: net; font-weight: 750; font-size: 16px; font-variant-numeric: tabular-nums; }
.day-row__go { grid-area: go; color: var(--faint); }
.day-row__go .ico { width: 18px; height: 18px; }

.section-title { font-size: 16px; font-weight: 700; margin: 0 0 10px; }
@media (min-width: 1100px) { .detail-grid--wide { grid-template-columns: 1.3fr 1fr; } }
.detail-grid--wide .trades { max-width: none; }
.news-mini { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.news-mini__name { display: grid; min-width: 0; font-weight: 600; font-size: 14px; }
.news-mini__name small { font-weight: 400; color: var(--muted); font-size: 12.5px; }

/* news month calendar */
.ncal { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.ncal__head, .ncal__row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.ncal__head > div { padding: 8px 6px; text-align: center; font-size: 12px; font-weight: 650; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.ncal__cell { display: flex; flex-direction: column; gap: 3px; min-height: 74px; min-width: 0; padding: 5px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.ncal__row > .ncal__cell:nth-child(7) { border-right: 0; }
.ncal__row:last-child .ncal__cell { border-bottom: 0; }
.ncal__cell.is-out { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.ncal__cell.is-out .ncal__date { color: var(--faint); }
.ncal__cell.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.ncal__date { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--text); text-decoration: none; }
.ncal__date small { font-weight: 500; font-size: 10.5px; color: var(--muted); }
.ncal__ev {
  display: block;
  padding: 2px 5px 2px 6px;
  border-radius: 5px;
  border-left: 3px solid var(--faint);
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ncal__ev:hover { background: var(--surface-3); }
.ncal__ev time { color: var(--muted); font-variant-numeric: tabular-nums; }
.ncal__ev.imp-ev--3 { border-left-color: var(--neg); }
.ncal__ev.imp-ev--2 { border-left-color: var(--warn); }
.ncal__ev.is-released { opacity: .78; }
.ncal__more { font-size: 11px; color: var(--accent-strong); text-decoration: none; }
@media (max-width: 699px) {
  .ncal__ev { font-size: 0; padding: 0; height: 6px; border-left-width: 0; background: var(--faint); }
  .ncal__ev.imp-ev--3 { background: var(--neg); }
  .ncal__ev.imp-ev--2 { background: var(--warn); }
  .ncal__more { font-size: 10px; }
  .ncal__cell { min-height: 58px; }
  .ncal__date small { display: none; }
}
@media (min-width: 960px) { .ncal__cell { min-height: 118px; padding: 7px; } .ncal__ev { font-size: 12px; } }

/* news list extras and detail page */
a.next-news { color: inherit; text-decoration: none; }
a.next-news:hover { border-color: var(--accent); }
.news-row__name { color: inherit; text-decoration: none; }
.news-row__name:hover { color: var(--accent-strong); text-decoration: underline; }
.news-more { display: inline-block; margin-top: 4px; font-size: 13px; text-decoration: none; }
.news-hero h1 { font-size: 24px; font-weight: 800; margin: 8px 0 2px; }
.news-hero__top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.news-hero__top .help-link { margin-left: auto; }
.cur--lg { font-size: 14px; padding: 2px 8px; }
.news-hero__nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.big-num { display: grid; gap: 1px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.big-num small { color: var(--muted); font-size: 12px; }
.big-num strong { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.moves { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 8px; }
.move { display: grid; gap: 1px; padding: 10px; border-radius: 10px; background: var(--surface-2); text-align: center; }
.move small { color: var(--muted); font-size: 12px; }
.move strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.chart--small { height: 340px; min-height: 0; }
@media (min-width: 960px) { .chart--small { height: 380px; } }

/* ------------------------------------------------------------- trade journal */

.journal-form textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  resize: vertical;
}
.journal-form textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); border-color: var(--accent); }
.stars { display: inline-flex; flex-direction: row-reverse; align-items: center; gap: 2px; }
.stars input { position: absolute; opacity: 0; pointer-events: none; }
.stars label { font-size: 28px; line-height: 1; color: var(--border-strong); cursor: pointer; padding: 0 2px; }
.stars label.stars__clear { font-size: 13px; color: var(--muted); margin-left: 12px; order: -1; }
.stars input:checked ~ label:not(.stars__clear), .stars label:not(.stars__clear):hover, .stars label:not(.stars__clear):hover ~ label:not(.stars__clear) { color: var(--accent); }
.stars input:focus-visible + label { outline: 2px solid var(--focus); border-radius: 4px; }

/* ------------------------------------------------------------- goals (challenge) */

.goals { display: grid; gap: 16px; }
@media (min-width: 1150px) { .goals { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; } }
.goals > .card { margin: 0; }
.goal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.goal__head h2 { margin: 0; }
.goal__head p { margin: 2px 0 0; font-size: 13px; }
.goal__numbers { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 12px 0 6px; }
.goal__net { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.goal__bar { width: 100%; height: 10px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.goal__bar::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
.goal__bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.goal__bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.goal--achieved .goal__bar::-webkit-progress-value { background: var(--pos); }
.goal--achieved .goal__bar::-moz-progress-bar { background: var(--pos); }
.goal__bar--loss::-webkit-progress-value { background: var(--neg); }
.goal__bar--loss::-moz-progress-bar { background: var(--neg); }
.goal__note { margin: 8px 0 0; font-size: 14px; }
.goal--stop .goal__note { color: var(--neg); font-weight: 650; }
.goal--achieved .goal__note { color: var(--pos); font-weight: 650; }
.goal__limit { display: grid; gap: 4px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.goal-pill--achieved { background: var(--pos-soft); color: var(--pos); }
.goal-pill--stop { background: var(--neg-soft); color: var(--neg); }
.goal-pill--limit { background: var(--warn-soft); color: var(--warn); }
.goal-pill--going { background: var(--accent-soft); color: var(--accent-strong); }
.goal__history { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.goal__streak { margin: 0 0 8px; font-size: 14px; }
.goal__dots { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.dot-p { width: 18px; height: 18px; border-radius: 5px; background: var(--surface-3); }
.dot-p.is-win { background: var(--pos); }
.dot-p.is-miss { background: color-mix(in srgb, var(--neg) 55%, var(--surface)); }
.dot-p.is-stop { background: color-mix(in srgb, var(--neg) 55%, var(--surface)); box-shadow: inset 0 0 0 2px var(--neg); }
.goal__form { margin-top: 12px; }
.goal__form summary { cursor: pointer; font-weight: 650; font-size: 14px; color: var(--accent-strong); padding: 4px 0; }
.goal__form form { margin-top: 10px; }
.goal-strip__items { display: grid; gap: 10px; }
@media (min-width: 760px) { .goal-strip__items { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.goal-mini { display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: inherit; text-decoration: none; }
.goal-mini__label { font-size: 12.5px; color: var(--muted); }
.goal-mini strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.goal-mini small { color: var(--muted); font-size: 12px; }
.goal-mini.goal--stop small { color: var(--neg); font-weight: 650; }
.goal-mini.goal--achieved small { color: var(--pos); font-weight: 650; }

/* ------------------------------------------------------------- indicators */

.chart-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; }
.ind-menu { position: relative; }
.ind-menu summary { list-style: none; }
.ind-menu summary::-webkit-details-marker { display: none; }
.ind-menu__panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 6px;
}
.ind-menu__title { display: flex; justify-content: space-between; margin: 4px 0 0; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.ind-opt { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ind-opt input[type=checkbox], .ind-opt input[type=radio] { width: 17px; height: 17px; accent-color: var(--accent); }
.ind-opt input[type=number] { width: 64px; min-height: 30px; padding: 2px 6px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.ind-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--muted); }
.ind-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ind-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.ind-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.ind-card__head h2 { margin: 0 0 6px; font-size: 19px; }
.ind-card__shows { font-size: 15px; }
.ind-card__grid { display: grid; gap: 14px; margin: 10px 0; }
@media (min-width: 900px) { .ind-card__grid { grid-template-columns: 1.4fr 1fr; } }
.ind-card h3 { font-size: 14px; margin: 0 0 6px; }
.ind-pairs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.ind-pairs .cur { font-size: 12.5px; padding: 2px 8px; }
.table--wrap th, .table--wrap td { white-space: normal; }

/* ------------------------------------------------------------- news tabs, feed tag, headlines */
.page-tabs { margin: 0 0 14px; }
.src-tag { display: inline-block; padding: 0 6px; border-radius: 6px; border: 1px solid var(--border-strong); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; vertical-align: 1px; }
.notice--soft { background: var(--surface-2); color: var(--muted); }
.headline-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.headline { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.headline:last-child { border-bottom: 0; }
.headline__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12.5px; color: var(--muted); }
.headline__meta time { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--text); }
.headline__source { font-weight: 600; }
.tag-chip { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; }
.headline__title { display: block; margin: 5px 0 0; color: var(--text); font-weight: 650; font-size: 15.5px; line-height: 1.45; text-decoration: none; }
.headline__title:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.headline__title .ico { width: 14px; height: 14px; vertical-align: -1px; color: var(--muted); }
.headline__desc { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0 4px; }


/* ------------------------------------------------------------- theme switch: everything follows */
body, .sidebar, .card, .tabbar, .mobilebar { transition: background-color .2s ease, border-color .2s ease, color .2s ease; }
@media (prefers-reduced-motion: reduce) { body, .sidebar, .card, .tabbar, .mobilebar { transition: none; } }

/* ------------------------------------------------------------- collapsible sidebar (desktop) */
.side-toggle { display: none; }
@media (min-width: 960px) {
  .app { transition: grid-template-columns .2s ease; }
  .sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
  .sidebar__head .brand { min-width: 0; }
  .side-toggle {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--side-muted);
    cursor: pointer;
  }
  .side-toggle:hover { background: var(--side-hover); color: var(--side-brand); }
  .side-toggle .ico { transition: transform .2s ease; }

  :root[data-side="collapsed"] { --side-w: 72px; }
  /* above the page so the label tooltips are not hidden behind the content */
  :root[data-side="collapsed"] .sidebar { padding-inline: 10px; overflow: visible; z-index: 40; }
  :root[data-side="collapsed"] .sidebar__head { flex-direction: column; gap: 10px; }
  :root[data-side="collapsed"] .sidebar .brand { padding: 2px 0 0; }
  :root[data-side="collapsed"] .side-toggle .ico { transform: scaleX(-1); }
  :root[data-side="collapsed"] .sidebar .brand__name,
  :root[data-side="collapsed"] .sidebar .nav__item > span,
  :root[data-side="collapsed"] .sidebar .me__text,
  :root[data-side="collapsed"] .sidebar__theme > span,
  :root[data-side="collapsed"] .sidebar .status__text {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  :root[data-side="collapsed"] .sidebar .nav__item,
  :root[data-side="collapsed"] .sidebar .me { justify-content: center; padding: 10px 0; }
  :root[data-side="collapsed"] .sidebar .status { justify-content: center; padding: 9px 0; }
  :root[data-side="collapsed"] .sidebar__theme { justify-content: center; padding: 0; }
  :root[data-side="collapsed"] .sidebar .theme-switch { flex-direction: column; justify-self: center; }
  /* labels as tooltips while collapsed */
  :root[data-side="collapsed"] .sidebar [data-tip] { position: relative; }
  :root[data-side="collapsed"] .sidebar [data-tip]:hover::after,
  :root[data-side="collapsed"] .sidebar [data-tip]:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 60;
    padding: 5px 10px;
    border-radius: 8px;
    background: var(--text);
    color: var(--bg);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
  }
  :root:not([data-side="collapsed"]) .side-toggle[data-tip]::after { content: none; }
}
@media (min-width: 960px) and (prefers-reduced-motion: reduce) { .app, .side-toggle .ico { transition: none; } }

/* ------------------------------------------------------------- loss-limit warning bar */
.loss-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.5;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.loss-alert .ico { width: 19px; height: 19px; margin-top: 1px; }
.loss-alert--stop { background: var(--neg-soft); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 30%, transparent); }
.loss-alert--near { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.loss-alert:hover span { text-decoration: underline; text-underline-offset: 2px; }
@media (min-width: 960px) { .loss-alert { padding-inline: 36px; } }

/* ------------------------------------------------------------- goals: near state, calendar marks */
.goal-pill--near { background: var(--warn-soft); color: var(--warn); }
.goal--near .goal__note { color: var(--warn); font-weight: 650; }
.goal__limit.is-near { color: var(--warn); font-weight: 600; }
.goal__limit.is-hit { color: var(--neg); font-weight: 650; }
.goal-mini.goal--near small { color: var(--warn); font-weight: 650; }
.goal-cal { display: grid; gap: 8px; padding: 12px 14px; margin: 0 0 14px; }
.goal-cal__items { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.goal-cal__item strong { margin-right: 4px; }
.goal-cal__month { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
.goal-cal__legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0; }
.goal-badge { display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; flex: none; }
.goal-badge .ico { width: 13px; height: 13px; vertical-align: 0; stroke-width: 2.2; }
.goal-badge--achieved { background: var(--pos); color: var(--surface); }
.goal-badge--near { background: var(--warn); color: var(--surface); }
.goal-badge--stop { background: var(--neg); color: var(--surface); }
.day-cell__date .goal-badge { margin: 0 auto 0 6px; }
.day-cell--goal-stop { box-shadow: inset 0 0 0 2px var(--neg); }
.day-cell--goal-near { box-shadow: inset 0 0 0 2px var(--warn); }
.day-cell--goal-achieved { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--pos) 70%, transparent); }
.week-goal { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; }
.week-goal .goal-badge { width: 16px; height: 16px; }
.week-goal--achieved { color: var(--pos); }
.week-goal--near { color: var(--warn); }
.week-goal--stop { color: var(--neg); }

/* ------------------------------------------------------------- indicator chips and readings */
.ind-c0 { --ind: #e0a526; }
.ind-c1 { --ind: #4f8cff; }
.ind-c2 { --ind: #b06cff; }
.ind-c3 { --ind: #22b8cf; }
.ind-c4 { --ind: #e05db0; }
.ind-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 10px; }
.ind-tools__label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 650; color: var(--muted); }
.ind-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ind-chips + .ind-chips { padding-left: 10px; border-left: 1px solid var(--border); }
@media (max-width: 640px) {
  .ind-chips + .ind-chips { padding-left: 0; border-left: 0; }
  .ind-chip { min-height: 30px; padding: 3px 9px; font-size: 13px; }
}
.ind-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.ind-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.ind-chip i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ind); flex: none; }
.ind-chip b { font-weight: 600; color: var(--muted); }
.ind-chip:hover { border-color: var(--ind); }
.ind-chip:has(input:checked) { background: color-mix(in srgb, var(--ind) 16%, var(--surface)); border-color: var(--ind); }
.ind-chip:has(input:checked) i { background: var(--ind); }
.ind-chip:has(input:checked) b { color: var(--text); }
.ind-chip:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.ind-settings { position: relative; }
.ind-settings summary { list-style: none; cursor: pointer; }
.ind-settings summary::-webkit-details-marker { display: none; }
.ind-settings .ind-menu__panel { left: auto; right: 0; }
@media (max-width: 640px) { .ind-settings[open] .ind-menu__panel { position: fixed; top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); left: 16px; right: 16px; width: auto; max-height: 70vh; overflow-y: auto; } }
.ind-opt span { min-width: 92px; }
.ind-read { display: grid; gap: 6px; margin: 10px 0 0; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.ind-read[hidden] { display: none; }
.ind-read__title { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.ind-read__row { display: grid; grid-template-columns: minmax(110px, auto) auto 1fr; align-items: baseline; gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 14px; }
.ind-read__title + .ind-read__row { border-top: 0; }
.ind-read__name { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; }
.ind-read__name i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ind-read__value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ind-read__text { color: var(--muted); }
.ind-read__row.is-up .ind-read__text { color: var(--pos); }
.ind-read__row.is-down .ind-read__text { color: var(--neg); }
.ind-read__row.is-warn .ind-read__text { color: var(--warn); font-weight: 600; }
.ind-read__note { margin: 4px 0 0; font-size: 12px; color: var(--faint); }
@media (max-width: 640px) {
  .ind-read__row { grid-template-columns: 1fr auto; }
  .ind-read__text { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------- dashboard chart */
.dash-chart { margin: 0 0 16px; }
.dash-chart__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 10px; }
.dash-chart__pick { margin: 0; }
.dash-chart__select { display: inline-flex; align-items: center; gap: 6px; }
.dash-chart__select select { min-height: 38px; font-size: 16px; font-weight: 750; padding: 4px 30px 4px 10px; }
.dash-chart__desc { margin: 0; font-size: 13px; }
.chart-head__price--sm .chart-head__bid { font-size: 22px; }
.dash-chart__full { margin-left: 4px; }
.tf-bar--sm .tf { padding: 3px 9px; font-size: 13px; }
.chart--dash { height: 400px; min-height: 0; }
@media (min-width: 960px) { .chart--dash { height: 460px; } }

/* ------------------------------------------------------------- trade history tools */
.filters__top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 10px; }
.search-field { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 0; padding: 0 12px; min-height: 42px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--muted); }
.search-field:focus-within { border-color: var(--accent); }
.search-field input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; outline: none; }
.results-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin: 0 0 10px; }
.results-bar p { margin: 0; }
.results-bar__export { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------- analytics */
.ana-filters { margin-bottom: 14px; }
.ana-kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 0 12px; }
@media (min-width: 760px) { .ana-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ana-card { margin: 0 0 14px; }
.ana-card .card__head { flex-wrap: wrap; align-items: center; }
.ana-svg { display: block; width: 100%; height: auto; overflow: visible; }
.ana-grid { stroke: var(--border); stroke-width: 1; }
.ana-zero { stroke: var(--border-strong); stroke-width: 1.2; }
.ana-tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.ana-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ana-line.is-pos { stroke: var(--pos); }
.ana-line.is-neg { stroke: var(--neg); }
.is-rate .ana-line, .is-rate .ana-line.is-neg { stroke: var(--info); }
.ana-area { stroke: none; opacity: .12; }
.ana-area.is-pos { fill: var(--pos); }
.ana-area.is-neg { fill: var(--neg); }
.is-rate .ana-area { fill: var(--info); }
.ana-bar.is-pos { fill: var(--pos); }
.ana-bar.is-neg { fill: var(--neg); }
.ana-bar:hover { opacity: .8; }
.ana-sub { margin: 14px 0 4px; font-size: 14px; color: var(--muted); }
.ana-more { margin-top: 10px; }
.ana-more summary, .ana-method summary { cursor: pointer; font-size: 14px; }
.ana-method ul { margin-top: 10px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ana-table th[scope="row"] { font-weight: 600; white-space: nowrap; }

/* ------------------------------------------------------------- journal reasons, screenshots */
@media (min-width: 760px) { .form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.shots { display: grid; gap: 14px; }
@media (min-width: 760px) { .shots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.shots__title { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.shot { margin: 0 0 12px; }
.shot img { display: block; width: 100%; max-height: 360px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); }
.shot figcaption { display: grid; gap: 2px; margin-top: 6px; font-size: 13.5px; }
.shot__del { margin: 0; }
.shot-upload { display: grid; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
@media (min-width: 760px) { .shot-upload { grid-template-columns: 2fr 1fr 2fr; align-items: end; } .shot-upload .form-actions { grid-column: 1 / -1; } }
.shot-upload input[type=file] { max-width: 100%; }

/* ------------------------------------------------------------- loading / error feedback, phone tap sizes */
.results { position: relative; }
.results.htmx-request::before {
  content: "";
  position: absolute;
  inset: -6px 0 auto 0;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: loading-bar 1s linear infinite;
}
@keyframes loading-bar { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@media (prefers-reduced-motion: reduce) { .results.htmx-request::before { animation: none; background-position: 50% 0; } }
.net-toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
}
.net-toast[hidden] { display: none; }
@media (min-width: 960px) { .net-toast { bottom: 24px; } }
@media (max-width: 959px) {
  .theme-switch button { width: 40px; height: 36px; }
  .back { display: inline-flex; align-items: center; min-height: 36px; }
  .usermenu summary { padding: 4px; }
  .usermenu__panel a, .usermenu__panel button { min-height: 42px; }
}


/* ------------------------------------------------------------- chart drawings (static/drawings.js) */
.draw-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 8px; }
.draw-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.draw-btn .ico { width: 19px; height: 19px; }
.draw-btn:hover { background: var(--surface-2); color: var(--text); }
.draw-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.draw-tools__sep { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }
.draw-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.draw-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.draw-c0 { background: #e0a526; } .draw-c1 { background: #4f8cff; } .draw-c2 { background: #22b8cf; }
.draw-c3 { background: #2fbf71; } .draw-c4 { background: #f0544f; } .draw-c5 { background: #b06cff; }
.draw-hint { position: absolute; top: 8px; left: 8px; z-index: 4; max-width: calc(100% - 90px); padding: 5px 10px; border-radius: 8px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 13px; pointer-events: none; }
.draw-hint[hidden] { display: none; }
@media (max-width: 640px) { .draw-btn { width: 38px; height: 38px; } .draw-swatch { width: 26px; height: 26px; } }

.draw-layer { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.draw-layer.is-drawing { pointer-events: all; cursor: crosshair; touch-action: none; }
.draw-layer .dr-line { stroke-width: 1.8; fill: none; }
.draw-layer .dr-line--level { stroke-width: 1; stroke-dasharray: 4 3; opacity: .85; }
.draw-layer .dr-line--guide { stroke-width: 1; stroke-dasharray: 2 4; opacity: .6; }
.draw-layer .dr-hit { stroke: transparent; stroke-width: 12; fill: none; pointer-events: stroke; cursor: move; touch-action: none; }
.draw-layer .dr-zone { fill-opacity: .14; stroke-width: 1.2; pointer-events: all; cursor: move; touch-action: none; }
.draw-layer .dr-text { font: 600 12px var(--font); pointer-events: all; cursor: move; touch-action: none; }
.draw-layer .dr-textbox { fill: var(--surface); fill-opacity: .9; stroke-width: 1; pointer-events: all; cursor: move; }
.draw-layer .dr-tag rect { pointer-events: none; }
.draw-layer .dr-tag__text { font: 600 11px var(--font); fill: #fff; pointer-events: none; }
.draw-layer .dr-handle { fill: var(--surface); stroke-width: 2; pointer-events: all; cursor: grab; touch-action: none; }
.draw-layer .is-sel .dr-line { stroke-width: 2.6; }
.draw-layer .is-draft { opacity: .75; }
.draw-layer.is-drawing .dr-hit, .draw-layer.is-drawing .dr-zone, .draw-layer.is-drawing .dr-text,
.draw-layer.is-drawing .dr-handle { pointer-events: none; }
.dr-input { position: absolute; z-index: 4; width: 220px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--accent); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; box-shadow: var(--shadow-lg); }

.guide-sub { margin: 14px 0 6px; font-size: 15px; }

/* ------------------------------------------------------------- full-screen chart workspace (templates/chart.html) */
.ws-body { margin: 0; overflow: hidden; background: var(--bg); }
.ws {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 236px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "left main right";
  height: 100vh;
  height: 100dvh;
}
:root[data-ws-panel="closed"] .ws { grid-template-columns: 52px minmax(0, 1fr) 0; }
:root[data-ws-panel="closed"] .ws-right { display: none; }

.ws-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
  padding: 6px 10px;
  padding-top: calc(6px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.ws-top__spacer { flex: 1; }
.ws-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
.ws-icon:hover { background: var(--surface-2); color: var(--text); }
.ws-icon[aria-expanded="true"] { color: var(--accent-strong); }
.ws-symbol { margin: 0; }
.ws-symbol select { min-height: 36px; max-width: 190px; padding: 3px 28px 3px 10px; font-size: 16px; font-weight: 800; }
.ws-quote { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ws-quote__bid { font-size: 19px; font-weight: 800; }
.ws-quote__bid.is-stale { color: var(--faint); }
.ws-tf { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.ws-tf::-webkit-scrollbar { display: none; }
.ws-tf .tf { padding: 6px 9px; white-space: nowrap; }
.ws-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-strong); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; white-space: nowrap; }
.ws-btn::-webkit-details-marker { display: none; }
.ws-pop { position: relative; }
.ws-pop[open] > .ws-btn { border-color: var(--accent); color: var(--accent-strong); }
.ws-pop__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: min(440px, calc(100vw - 24px));
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.ws-pop__panel .ind-tools { margin: 0; }
.ws-pop__panel .ind-settings .ind-menu__panel { position: static; width: auto; margin-top: 8px; box-shadow: none; }
.ws-alert { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 700; text-decoration: none; }
.ws-alert--stop { background: var(--neg-soft); color: var(--neg); }
.ws-alert--near { background: var(--warn-soft); color: var(--warn); }
.ws-demo { padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; font-weight: 700; }

.ws-left { grid-area: left; overflow-y: auto; overflow-x: hidden; border-right: 1px solid var(--border); background: var(--surface); scrollbar-width: thin; }
.draw-tools--vertical { flex-direction: column; flex-wrap: nowrap; align-items: center; gap: 2px; margin: 0; padding: 8px 0; }
.draw-tools--vertical .draw-tools__sep { width: 24px; height: 1px; margin: 6px 0; }
.draw-tools--vertical .draw-btn { width: 38px; height: 38px; }
.draw-colors { position: relative; }
.draw-colors > summary { list-style: none; }
.draw-colors > summary::-webkit-details-marker { display: none; }
.draw-colors__dot { width: 18px; height: 18px; border-radius: 50%; background: #e0a526; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-strong); }
.draw-colors__panel {
  position: fixed;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 26px);
  gap: 8px;
  margin: -34px 0 0 46px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.ws-main { grid-area: main; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ws-chart-box { flex: 1; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
.ws-chart { height: 100% !important; min-height: 0 !important; }
.ws-legend {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  max-width: calc(100% - 90px);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.ws-legend__title { font-weight: 700; color: var(--text); }
.ws-legend b { margin-right: 3px; color: var(--muted); font-weight: 600; }
.ws-chart-box .draw-hint { top: auto; bottom: 36px; }
.ws-read { margin: 0; max-height: 26vh; overflow-y: auto; border-radius: 0; border-width: 1px 0 0; }

.ws-right { grid-area: right; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding: 10px; border-left: 1px solid var(--border); background: var(--surface); }
.ws-right__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ws-right .acct-switch select { width: 100%; }
.ws-list h2 { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.ws-list .side-list { max-height: none; }
.ws-note { margin: auto 0 0; }
.ws-show-sm { display: none; }

@media (max-width: 899px) {
  .ws { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "top" "main" "left"; }
  :root[data-ws-panel="closed"] .ws { grid-template-columns: minmax(0, 1fr); }
  .ws-top { flex-wrap: wrap; }
  .ws-tf { order: 10; flex-basis: 100%; }
  .ws-hide-sm { display: none !important; }
  .ws-show-sm { display: inline-grid; }
  .ws-quote__bid { font-size: 17px; }
  .ws-symbol select { max-width: 150px; }
  .ws-left { border-right: 0; border-top: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; padding-bottom: env(safe-area-inset-bottom); }
  .draw-tools--vertical { flex-direction: row; padding: 4px 6px; width: max-content; }
  .draw-tools--vertical .draw-tools__sep { width: 1px; height: 24px; margin: 0 4px; }
  .draw-colors__panel { position: fixed; left: 12px; right: auto; bottom: calc(60px + env(safe-area-inset-bottom)); margin: 0; }
  .ws-right { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(300px, 86vw); box-shadow: var(--shadow-lg); }
  :root[data-ws-panel="closed"] .ws-right { display: none; }
  .ws-pop__panel { position: fixed; left: 12px; right: 12px; top: calc(100px + env(safe-area-inset-top)); width: auto; max-height: 65vh; overflow-y: auto; }
}
.ws-tf { flex: none; }
@media (max-width: 1499px) { .ws-quote small { display: none; } }
@media (min-width: 900px) and (max-width: 1180px) { .ws-top { flex-wrap: wrap; } .ws-ind .ws-btn span { display: none; } }
@media (max-width: 899px) { .ws-tf { flex: 1 1 100%; min-width: 0; } }
/* closed pop-outs must not take part in layout (a fixed panel inside a closed <details> could widen the page on phones) */
.ws-pop:not([open]) > .ws-pop__panel, .draw-colors:not([open]) > .draw-colors__panel,
.ind-settings:not([open]) > .ind-menu__panel { display: none; }
.ws-body, .ws { max-width: 100vw; overflow-x: hidden; }
/* keep the hidden labels (.sr-only, absolute) inside their scrolling toolbars instead of widening the page */
.draw-btn, .ws-icon, .ws-left, .ws-tf, .ws-top { position: relative; }
