/* ULTRON Trading Command Center: design system
   VOICE  work: an industrial AI command center; precise, quiet, expensive
   IDEA   machined graphite and sacred geometry lit from within by a crimson core
   COLOUR graphite #17191c ground, charcoal/gunmetal surfaces, metallic silver lines,
          deep crimson #b3122e for selection and the core; P&L: muted green / coral red / amber
   TYPE   Rajdhani 600 (display, engraved labels) + Inter (text) + JetBrains Mono (figures)
   LAYOUT the Metatron geometry is the whole navigation; screens grow out of the chosen circle */

:root {
  color-scheme: dark;
  --bg: #141618;
  --bg-2: #1b1e21;
  --glass: rgba(30, 33, 37, 0.78);
  --glass-2: rgba(38, 42, 47, 0.92);
  --line: rgba(196, 202, 210, 0.14);
  --line-2: rgba(196, 202, 210, 0.30);
  --silver: #b9c0c8;
  --ink: #f2f3f5;
  --ink-2: #a3a9b0;
  --ink-3: #737a82;
  --accent: #c41a36;
  --accent-2: #8e0f24;
  --accent-glow: rgba(196, 26, 54, 0.35);
  --win: #5fbf8f;
  --loss: #e0566a;
  --be: #d4a64a;
  --none: #2b2f34;
  --r: 14px;
  --hud-h: 60px;
  --font-d: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  --font-t: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --font-m: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-t);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}
/* Holographic scene (js/hologram.js) sits behind everything */
.hologram { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.num { font-family: var(--font-m); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--win); }
.neg { color: var(--loss); }
.zero { color: var(--be); }
.muted { color: var(--ink-2); }
.dim { color: var(--ink-3); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }











.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin-right: 8px; vertical-align: 1px; }
.status-dot.ok { background: var(--win); box-shadow: 0 0 8px var(--win); }
.status-dot.warn { background: var(--be); }
.status-dot.err { background: var(--loss); }

.main { padding: 26px max(28px, var(--safe-r)) 48px 28px; max-width: 1480px; width: 100%; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { font: 700 clamp(28px, 3.2vw, 40px)/1.05 var(--font-d); letter-spacing: 0.04em; margin: 0; text-shadow: 0 1px 0 rgba(0,0,0,.6); }
.page-sub { color: var(--ink-2); margin: 6px 0 0; font-size: 14px; }
.topbar-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.clock { font: 500 13px var(--font-m); color: var(--ink-2); }



/* ---------- Panels ---------- */
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.g-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }

.panel {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  backdrop-filter: blur(5px) saturate(1.3); -webkit-backdrop-filter: blur(5px) saturate(1.3);
  box-shadow: 0 0 30px rgba(196, 202, 210, 0.04) inset, 0 0 0 1px rgba(196, 202, 210, 0.04);
  animation: rise 0.45s ease both;
}
/* HUD corner brackets */
.panel::before, .panel::after {
  content: ''; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-color: var(--silver); opacity: 0.4;
}
.panel::before { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; border-top-left-radius: var(--r); }
.panel::after { bottom: -1px; right: -1px; border-bottom: 2px solid; border-right: 2px solid; border-bottom-right-radius: var(--r); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-title { font: 600 15px/1.2 var(--font-d); letter-spacing: 0.1em; color: var(--ink); margin: 0; text-transform: uppercase; }
.panel-title small { font: 500 12px var(--font-t); letter-spacing: 0; text-transform: none; color: var(--ink-3); margin-left: 8px; }

.kpi { padding: 14px 16px; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); }
.kpi-value { font: 600 clamp(22px, 2.2vw, 28px)/1.15 var(--font-m); margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-foot { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.kpi.hero .kpi-value { font-size: clamp(28px, 3vw, 38px); }

.empty {
  display: grid; place-items: center; text-align: center; gap: 10px;
  min-height: 180px; padding: 20px;
  color: var(--ink-2); font-size: 14px;
  border: 1px dashed var(--line); border-radius: 10px;
  background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(196, 202, 210, 0.015) 10px 20px);
}
.empty strong { color: var(--ink); font: 600 16px var(--font-d); letter-spacing: 0.06em; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line-2); background: rgba(196, 202, 210, 0.06);
  color: var(--ink); font: 600 15px/1 var(--font-d); letter-spacing: 0.08em;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}
.btn:hover { background: rgba(196, 26, 54, 0.12); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }

.btn.primary { background: linear-gradient(180deg, #d42340, #8e0f24); color: #fff; border-color: transparent; box-shadow: 0 0 22px rgba(196, 26, 54, 0.28); }
.btn.primary:hover { box-shadow: 0 0 30px rgba(196, 26, 54, 0.45); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { border-color: rgba(224, 86, 106, 0.5); color: var(--loss); background: rgba(224, 86, 106, 0.06); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px;
  font-size: 16px; /* >=16px stops iOS zoom-on-focus */
  background: rgba(16, 18, 20, 0.85); border: 1px solid var(--line-2); border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(196, 26, 54, 0.15); }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select.input option { background: #1e2125; }

.seg { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 11px; background: rgba(16, 18, 20, 0.7); flex-wrap: wrap; }
.seg button { min-height: 36px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font: 600 14px var(--font-d); letter-spacing: 0.06em; cursor: pointer; }
.seg button[aria-pressed='true'] { background: rgba(196, 26, 54, 0.14); color: var(--accent); box-shadow: 0 0 0 1px var(--line-2) inset; }
.seg.big button { min-height: 48px; flex: 1; font-size: 16px; }
.seg.dir button[data-v='Long'][aria-pressed='true'] { background: rgba(95, 191, 143, 0.14); color: var(--win); box-shadow: 0 0 0 1px rgba(95, 191, 143, 0.5) inset; }
.seg.dir button[data-v='Short'][aria-pressed='true'] { background: rgba(224, 86, 106, 0.14); color: var(--loss); box-shadow: 0 0 0 1px rgba(224, 86, 106, 0.5) inset; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip.win { color: var(--win); border-color: rgba(95, 191, 143, 0.45); }
.chip.loss { color: var(--loss); border-color: rgba(224, 86, 106, 0.45); }
.chip.be { color: var(--be); border-color: rgba(212, 166, 74, 0.45); }

/* ---------- Tables ---------- */
.scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font: 600 12.5px var(--font-d); letter-spacing: 0.08em; color: var(--ink-3); text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid rgba(196, 202, 210, 0.06); }
table.data td.r, table.data th.r { text-align: right; }
table.data tbody tr:hover { background: rgba(196, 202, 210, 0.04); }

/* ---------- Calendar ---------- */
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
.cal-head div { font: 600 12px var(--font-d); letter-spacing: 0.1em; color: var(--ink-3); text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-day {
  position: relative; min-height: 92px; padding: 8px; border-radius: 10px; text-align: left;
  border: 1px solid rgba(60, 65, 72, 0.9); background: rgba(60, 65, 72, 0.22);
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; color: var(--ink);
}
.cal-day.out { opacity: 0.28; cursor: default; }
.cal-day.today { border-color: var(--accent); box-shadow: 0 0 14px rgba(196, 26, 54, 0.25); }
.cal-day.win { background: rgba(95, 191, 143, 0.12); border-color: rgba(95, 191, 143, 0.45); }
.cal-day.loss { background: rgba(224, 86, 106, 0.12); border-color: rgba(224, 86, 106, 0.45); }
.cal-day.be { background: rgba(212, 166, 74, 0.11); border-color: rgba(212, 166, 74, 0.45); }
.cal-day .d { font: 600 14px var(--font-d); color: var(--ink-2); }
.cal-day .p { font: 600 14px var(--font-m); margin-top: auto; }
.cal-day .n { font-size: 11.5px; color: var(--ink-3); }
.cal.mini .cal-day { min-height: 40px; padding: 5px; align-items: center; justify-content: center; }
.cal.mini .cal-day .d { font-size: 13px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.form-section + .form-section { margin-top: 16px; }

/* ---------- Attachments ---------- */
.att { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(16, 18, 20, 0.6); }
.att.audio { grid-template-columns: minmax(0, 1fr); }
.att img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.att-body { display: grid; gap: 8px; align-content: start; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; background: var(--bg-2); }
.gallery figcaption { font-size: 12px; color: var(--ink-2); margin-top: 4px; text-transform: capitalize; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.92); display: grid; place-items: center; padding: 12px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 16px; margin: 0; }
.dl div { border-bottom: 1px solid rgba(196, 202, 210, 0.07); padding-bottom: 6px; }
.dl dt { font-size: 12px; color: var(--ink-3); }
.dl dd { margin: 2px 0 0; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---------- Toast / sheet ---------- */
.toasts { position: fixed; z-index: 60; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--glass-2); border: 1px solid var(--line-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); max-width: 360px; animation: rise 0.25s ease both; }
.toast.err { border-color: rgba(224, 86, 106, 0.6); }
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 20px; animation: fade 0.2s ease both; }
.sheet { width: min(720px, 100%); max-height: 86vh; max-height: 86dvh; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* ---------- Boot sequence ---------- */
.boot { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); transition: opacity 0.5s ease, visibility 0.5s; }
.boot.done { opacity: 0; visibility: hidden; }
.boot-ring { width: 132px; height: 132px; }
.boot-ring circle { fill: none; stroke: var(--accent); }
.boot-ring .r1 { stroke-width: 2; stroke-dasharray: 60 20; animation: spin 2.4s linear infinite; transform-origin: 50% 50%; opacity: 0.8; }
.boot-ring .r2 { stroke-width: 1; stroke-dasharray: 4 8; animation: spin 6s linear infinite reverse; transform-origin: 50% 50%; opacity: 0.5; }
.boot-ring .core { fill: rgba(196, 26, 54, 0.18); stroke-width: 1.5; }
.boot-text { margin-top: 18px; text-align: center; font: 600 14px var(--font-d); letter-spacing: 0.32em; color: var(--accent); }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Tablet ---------- */
@media (max-width: 1180px) {
  .g-main { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Phone: iPhone Pro Max is 430–440px wide ---------- */
@media (max-width: 820px) {

  .topbar { margin-bottom: 14px; }
  .page-title { font-size: 28px; }
  .g-2 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 10px 12px; }
  .kpi-value, .kpi.hero .kpi-value { font-size: 21px; margin-top: 2px; }
  .kpi-label, .kpi-foot { font-size: 12px; }
  .kpi-foot { margin-top: 2px; }
  .topbar-tools, .topbar-tools .scope-picker { width: 100%; }
  .panel { padding: 14px; }
  .cal-day { min-height: 58px; padding: 5px; }
  .cal-day .p { font-size: 11px; }
  .cal-day .n { display: none; }
  .toasts { left: 16px; right: 16px; }
  .toast { max-width: none; }
  .sheet-backdrop { place-items: end center; padding: 0; }
  .sheet { width: 100%; max-height: 88vh; border-radius: 18px 18px 0 0; padding-bottom: calc(18px + var(--safe-b)); }
  .hide-phone { display: none !important; }
  #calc-panel { position: static !important; }
  .calc-mini {
    position: fixed; z-index: 35; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 12px);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line-2);
    background: var(--glass-2); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  }

  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 8px 6px; }
}
@media (min-width: 821px) { .hide-desktop { display: none !important; } }

/* ================= Geometric navigation ================= */
.hud {
  position: fixed; z-index: 40; top: 0; left: 0; right: 0;
  height: calc(var(--hud-h) + var(--safe-t)); padding: var(--safe-t) max(14px, var(--safe-r)) 0 max(14px, var(--safe-l));
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(18, 20, 22, 0.92), rgba(18, 20, 22, 0.55));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.hud-home { flex: none; width: 46px; height: 46px; padding: 3px; border-radius: 50%; border: 1px solid var(--line-2); background: #101214; cursor: pointer; }
.hud-home:hover, .hud-home:focus-visible { border-color: var(--accent); box-shadow: 0 0 14px var(--accent-glow); outline: none; }
.hud-core { width: 40px; height: 40px; display: block; }
.hud-back { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: rgba(30, 33, 37, 0.6); color: var(--ink); cursor: pointer; }
.hud-back svg { width: 20px; height: 20px; }
.hud-back:disabled { opacity: 0.3; cursor: default; }
.hud-back:not(:disabled):hover { border-color: var(--accent); }
.crumbs { flex: 1; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; font: 600 14px var(--font-d); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); mask-image: linear-gradient(90deg, transparent, #000 24px); -webkit-mask-image: linear-gradient(90deg, transparent, #000 24px); justify-content: flex-end; }
.crumbs a { color: var(--ink-2); text-decoration: none; padding: 6px 2px; }
.crumbs a:hover { color: var(--ink); }
.crumbs [aria-current] { color: var(--ink); }
.crumbs .sep { color: var(--accent); opacity: 0.7; }
.hud-status { flex: none; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); }

.geo-host { position: fixed; inset: calc(var(--hud-h) + var(--safe-t)) 0 var(--safe-b) 0; overflow: hidden; touch-action: none; }
.geo-world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; will-change: transform; }
.geo-lines { position: absolute; overflow: visible; pointer-events: none; }
.geo-lines .ml { stroke: rgba(190, 197, 206, 0.10); stroke-width: 1; }
.geo-lines .ml.major { stroke: rgba(200, 207, 215, 0.22); }
.geo-lines .hex { fill: none; stroke: rgba(196, 26, 54, 0.32); stroke-width: 1.2; }
.geo-lines .seed { fill: none; stroke: rgba(190, 197, 206, 0.09); stroke-width: 1; }
.geo-lines .seed.outer { stroke: rgba(190, 197, 206, 0.16); stroke-dasharray: 2 6; }
.geo-lines g { transform-origin: 0 0; }
.geo-nodes { position: absolute; left: 0; top: 0; }
.geo-slot { position: absolute; border-radius: 50%; border: 1px dashed rgba(190, 197, 206, 0.12); pointer-events: none; }
.geo-node {
  position: absolute; border-radius: 50%; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--r) * 0.05);
  color: var(--ink); text-align: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.07), transparent 60%),
    radial-gradient(circle at 50% 50%, #26292d 0%, #1a1c1f 70%, #121416 100%);
  border: 1px solid rgba(200, 207, 215, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 calc(var(--r) * 0.12) calc(var(--r) * 0.4) rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.geo-node::before { content: ''; position: absolute; inset: 5%; border-radius: 50%; border: 1px solid rgba(200, 207, 215, 0.12); pointer-events: none; }
.geo-node:hover, .geo-node:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 calc(var(--r) * 0.5) var(--accent-glow), inset 0 0 calc(var(--r) * 0.4) rgba(196, 26, 54, 0.18);
}
.geo-node.branch::after { content: ''; position: absolute; inset: -6%; border-radius: 50%; border: 1px dotted rgba(196, 26, 54, 0.55); pointer-events: none; }
.geo-node.picked { border-color: var(--accent); box-shadow: 0 0 calc(var(--r) * 0.8) var(--accent-glow); }
.geo-node.center {
  border: 1.5px solid rgba(214, 220, 228, 0.6);
  background: radial-gradient(circle at 50% 50%, #2a1215 0%, #1b1d20 62%, #111315 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 0 calc(var(--r) * 0.9) rgba(196, 26, 54, 0.28), inset 0 0 calc(var(--r) * 0.6) rgba(196, 26, 54, 0.22);
}
.geo-icon { width: calc(var(--r) * 0.46); height: calc(var(--r) * 0.46); color: var(--silver); }
.geo-node:hover .geo-icon, .geo-node.center .geo-icon { color: #ff5a6c; }
.geo-icon svg { width: 100%; height: 100%; }
.geo-title { font: 600 clamp(11px, calc(var(--r) * 0.2), 19px)/1.05 var(--font-d); letter-spacing: 0.08em; text-transform: uppercase; max-width: 84%; }
.geo-node.center .geo-title { font-size: clamp(13px, calc(var(--r) * 0.19), 22px); }
.geo-hint, .geo-badge { font-size: clamp(9.5px, calc(var(--r) * 0.13), 12px); color: var(--ink-3); max-width: 80%; line-height: 1.1; }
.geo-badge { color: #ff8a96; }
.geo-core { position: absolute; inset: 6%; width: 88%; height: 88%; border-radius: 50%; pointer-events: none; }
.geo-node.center.is-root .geo-title { position: relative; margin-top: 58%; text-shadow: 0 1px 3px #000; }
.geo-node.center.is-root .geo-hint { position: relative; }

.screen {
  position: fixed; z-index: 30; inset: calc(var(--hud-h) + var(--safe-t)) 0 0 0;
  background: linear-gradient(180deg, rgba(20, 22, 24, 0.97), rgba(16, 18, 20, 0.985));
}
.screen-scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.screen .main { margin: 0 auto; padding: 22px max(20px, var(--safe-r)) calc(40px + var(--safe-b)) max(20px, var(--safe-l)); max-width: 1320px; }
.flash { animation: flash 1.6s ease 1; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 1px var(--accent), 0 0 28px var(--accent-glow); } 100% { box-shadow: none; } }
@media (max-width: 820px) {
  :root { --hud-h: 56px; }
  .screen .main { padding: 14px max(14px, var(--safe-r)) calc(96px + var(--safe-b)) max(14px, var(--safe-l)); }
  .calc-mini { bottom: calc(var(--safe-b) + 12px); }
  .toasts { bottom: calc(var(--safe-b) + 16px); }
}

/* Breadcrumbs: flex items must not shrink into each other; phones show only the current level + parent */
.crumbs > * { flex-shrink: 0; }
@media (max-width: 640px) {
  .crumbs > :not(:nth-last-child(-n+3)) { display: none; }
  .crumbs { font-size: 12px; }
}
.geo-node.center.is-root .geo-title, .geo-node.center.is-root .geo-hint { text-shadow: 0 1px 6px rgba(0,0,0,.9), 0 0 2px rgba(0,0,0,.9); }

/* ---------- Accounts (Stage 5) ---------- */
.acc-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.acc-card { display: grid; gap: 14px; align-content: start; }
.acc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.acc-name { margin: 0 0 2px; font: 600 18px var(--font-d); letter-spacing: .04em; color: var(--ink); }
.acc-figs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.acc-figs > div { display: grid; gap: 2px; }
.acc-figs strong { font-size: 15px; color: var(--ink); }
.acc-figs strong.pos { color: var(--win); } .acc-figs strong.neg { color: var(--loss); }
@media (max-width: 520px) { .acc-figs { grid-template-columns: repeat(2, 1fr); } }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.meter { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.meter-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.meter-bar { height: 6px; border-radius: 3px; background: rgba(200, 207, 215, .09); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(200, 207, 215, .08); }
.meter-bar i { display: block; height: 100%; background: linear-gradient(90deg, #8d949c, #d9dde2); border-radius: inherit; }
.meter.warn .meter-bar i { background: linear-gradient(90deg, #8a6a2a, var(--be)); }
.meter.crit .meter-bar i { background: linear-gradient(90deg, var(--accent-2), var(--loss)); box-shadow: 0 0 10px var(--accent-glow); }
.meter.crit .meter-top .num { color: var(--loss); }
.field small { font-size: 12px; }
.btn.danger-text { color: var(--loss); }

/* ---------- Charts & dashboard (Stage 6) ---------- */
.chart { position: relative; width: 100%; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; overflow: visible; }
.chart-tip { position: absolute; z-index: 3; pointer-events: none; display: grid; gap: 2px; padding: 8px 10px; min-width: 96px; border-radius: 8px;
  background: rgba(22, 24, 27, .96); border: 1px solid var(--line-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); font-size: 12px; white-space: nowrap; }
.chart-tip strong { font-size: 14px; color: var(--ink); }
.chart-tip strong.pos { color: var(--win); } .chart-tip strong.neg { color: var(--loss); }
.hbars { display: grid; gap: 14px; }
.hbar { display: grid; gap: 6px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--ink); }
.hbar-track { height: 8px; border-radius: 4px; background: rgba(200, 207, 215, .07); overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: inherit; }
.hbar-track i.pos { background: linear-gradient(90deg, rgba(95, 191, 143, .35), var(--win)); }
.hbar-track i.neg { background: linear-gradient(90deg, rgba(224, 86, 106, .35), var(--loss)); }
.panel-head .seg { flex-wrap: nowrap; }

/* calendar: weekly totals column, month stats, year strip, day sheet */
.cal-head.weeks, .cal.weeks { grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(0, 1.05fr); }
.cal-week { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 8px; min-height: 88px; border-radius: 10px;
  border: 1px dashed var(--line-2); background: rgba(200, 207, 215, .025); text-align: right; }
.cal-week .p, .cal-week .p-short { font: 600 13.5px var(--font-m); }
.cal-week .n { font-size: 11px; color: var(--ink-3); }
.cal-day .p-short, .cal-week .p-short { display: none; }
.month-stats, .day-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0 0 16px; }
.month-stats > div, .day-stats > div { display: grid; gap: 3px; padding: 10px 12px; border-radius: 10px; background: rgba(200, 207, 215, .035); border: 1px solid var(--line); }
.month-stats strong, .day-stats strong { font-size: 15px; color: var(--ink); }
.month-stats small { font-size: 11.5px; font-weight: 400; }
.month-stats .pos, .day-stats .pos { color: var(--win); } .month-stats .neg, .day-stats .neg { color: var(--loss); }
.year-strip { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.ym { display: grid; gap: 4px; justify-items: center; padding: 10px 4px; border-radius: 10px; border: 1px solid var(--line); background: rgba(200, 207, 215, .03);
  color: var(--ink-2); font: 600 12px var(--font-d); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.ym strong { font: 600 12.5px var(--font-m); letter-spacing: 0; text-transform: none; }
.ym.win { border-color: rgba(95, 191, 143, .4); background: rgba(95, 191, 143, .08); }
.ym.loss { border-color: rgba(224, 86, 106, .4); background: rgba(224, 86, 106, .08); }
.ym.be { border-color: rgba(212, 166, 74, .4); }
.ym.cur { box-shadow: inset 0 0 0 1px var(--accent), 0 0 12px var(--accent-glow); }
.ym:hover { border-color: var(--silver); }
@media (max-width: 760px) {
  .year-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cal-week { min-height: 58px; padding: 4px; }
  .cal-day .p, .cal-week .p, .cal-week .n { display: none; }
  .cal-day .p-short, .cal-week .p-short { display: block; font: 600 10.5px var(--font-m); margin-top: auto; }
  .cal-head.weeks div:last-child { font-size: 10px; }
}
.chart-tip[hidden] { display: none; }
/* KPI numbers scale with their own tile so long amounts never overflow */
.kpi { container-type: inline-size; min-width: 0; }
.kpi-value { font-size: clamp(16px, 12.5cqi, 28px); }
.kpi.hero .kpi-value { font-size: clamp(18px, 13cqi, 38px); }
@media (max-width: 760px) { .kpi-value, .kpi.hero .kpi-value { font-size: clamp(15px, 12.5cqi, 22px); } }
@media (max-width: 760px) { .cal-day .p-short, .cal-week .p-short { white-space: nowrap; font-size: 9.5px; letter-spacing: -0.03em; } }

/* ---------- Trade review (Stage 7) ---------- */
.review { border-top: 1px solid var(--line); margin-top: 20px; display: grid; gap: 14px; }
.review .panel-head { margin-top: 16px !important; }
.seg.grade button { min-width: 44px; font: 700 15px var(--font-d); }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip { padding: 7px 12px; min-height: 36px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(200, 207, 215, .04); color: var(--ink-2); font-size: 13.5px; cursor: pointer; }
.tag-chip:hover { border-color: var(--silver); color: var(--ink); }
.tag-chip[aria-pressed="true"] { border-color: var(--accent); background: rgba(196, 26, 54, .16); color: var(--ink); box-shadow: 0 0 10px var(--accent-glow); }
.rv-cat[data-cat="Mistake"] .tag-chip[aria-pressed="true"] { border-color: var(--loss); background: rgba(224, 86, 106, .14); }
.tag-chip.add { border-style: dashed; color: var(--ink-3); }
.tag-new { display: inline-flex; gap: 6px; align-items: center; }
.tag-new .input { width: 170px; min-height: 36px; padding: 6px 10px; }
.rules { display: grid; gap: 6px; margin-bottom: 8px; }
.rule { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: 10px; }
.rule .seg button { min-width: 38px; }
.rule .seg button[data-v="followed"][aria-pressed="true"] { color: var(--win); border-color: rgba(95, 191, 143, .5); background: rgba(95, 191, 143, .12); }
.rule .seg button[data-v="broken"][aria-pressed="true"] { color: var(--loss); border-color: rgba(224, 86, 106, .5); background: rgba(224, 86, 106, .12); }
.verdict { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; border: 1px solid var(--line-2); }
.verdict.win { border-color: rgba(95, 191, 143, .45); color: var(--win); background: rgba(95, 191, 143, .07); }
.verdict.loss { border-color: rgba(224, 86, 106, .45); color: var(--loss); background: rgba(224, 86, 106, .07); }
.verdict.be { border-color: rgba(212, 166, 74, .45); color: var(--be); background: rgba(212, 166, 74, .07); }
.tag-manager { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.tm-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.tm-row.off > span:first-child { color: var(--ink-3); text-decoration: line-through; }
.tm-add { display: flex; gap: 6px; margin-top: 8px; }
.tm-add .input { min-height: 36px; padding: 6px 10px; }
/* sheets are solid: nothing behind them may bleed through text */
.sheet.panel { background: linear-gradient(180deg, #202327, #191b1e); backdrop-filter: none; -webkit-backdrop-filter: none; }
.sheet-backdrop { background: rgba(8, 9, 10, .72); }
