:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --bg: #090b0f;
  --surface: #111419;
  --surface-2: #171b21;
  --line: #2b3038;
  --text: #f6f7f8;
  --muted: #9298a1;
  --green: #48c79b;
  --red: #ee7684;
  --amber: #e1b96e;
  --bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); letter-spacing: 0; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .46; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
[hidden] { display: none !important; }
.up { color: var(--green) !important; }
.down { color: var(--red) !important; }
.warn { color: var(--amber) !important; }
.muted { color: var(--muted) !important; }

.access-gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 11px; background: var(--bg); text-align: center; padding: 24px; }
.access-gate .gate-mark, .brand-mark, .account-mark { display: grid; place-items: center; background: var(--text); color: var(--bg); font-weight: 900; border-radius: 5px; }
.gate-mark { width: 54px; height: 54px; font-size: 30px; margin-bottom: 12px; }
.access-gate strong { font-size: 20px; }
.access-gate span { color: var(--muted); font-size: 13px; }
.access-gate button { margin-top: 15px; padding: 9px 22px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); }

.app { width: min(1440px, 100%); height: 100vh; height: 100dvh; margin: auto; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.sidebar { border-right: 1px solid var(--line); padding: 24px 12px; display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 11px 27px; }
.brand-mark { width: 34px; height: 34px; font-size: 20px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; line-height: 1.2; }
.brand small { font-size: 11px; margin-top: 3px; color: var(--muted); }
.desktop-nav { display: grid; gap: 3px; }
.nav-item { appearance: none; border: 1px solid transparent; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 11px; border-radius: 5px; min-height: 45px; width: 100%; padding: 0 12px; font-size: 13px; font-weight: 600; text-align: left; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--text); background: #1d2229; border-color: #333a43; }
.nav-icon { display: grid; place-items: center; width: 22px; height: 22px; font-size: 21px; font-weight: 500; line-height: 1; }
.nav-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-meta { margin-top: auto; border-top: 1px solid var(--line); padding: 15px 12px 0; display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.sidebar-meta strong { color: var(--green); font-size: 13px; }
.sidebar-meta small { font-size: 11px; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 22px 27px 24px; }
.topbar { min-height: 58px; flex: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.crumb { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; margin-bottom: 5px; }
.crumb span:first-child { margin: 0 5px; color: #535b65; }
.preview-badge { color: var(--amber); margin-left: 8px; }
h1, h2, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.15; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #59616b; }
.status-dot.live { background: var(--green); box-shadow: 0 0 0 3px #1c3f34; }
.status-dot.stale { background: var(--amber); }
.update-label { color: var(--muted); font-size: 11px; white-space: nowrap; }
.icon-button { appearance: none; width: 37px; height: 37px; flex: none; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); display: grid; place-items: center; font-size: 23px; line-height: 1; }
.icon-button:hover { background: var(--surface-2); }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stage { flex: 1; min-height: 0; }
.page { display: none; height: 100%; min-height: 0; flex-direction: column; gap: 13px; }
.page.active { display: flex; }
.section-title { flex: none; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
.section-title h2 { font-size: 14px; font-weight: 680; }
.section-title span { font-size: 11px; color: var(--muted); text-align: right; }
.text-link { border: 0; background: none; font-size: 11px; color: var(--muted); padding: 0; }
.text-link:hover { color: var(--text); }
.text-link span { font-size: 18px; vertical-align: -1px; }

.price-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; flex: none; }
.price-tile { min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 18px 20px; display: flex; flex-direction: column; gap: 9px; }
.tile-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; font-weight: 700; }
.tile-top small { font-size: 11px; color: var(--muted); font-weight: 500; }
.market-live { color: var(--muted); font-size: 10px; font-weight: 500; }
.price-tile strong { font-variant-numeric: tabular-nums; font-size: clamp(22px, 2.8vw, 38px); line-height: 1.12; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price-change { font-size: 12px; font-weight: 700; min-height: 16px; }
.home-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex: none; }
.stat-cell { border: 0; border-right: 1px solid var(--line); background: var(--surface); text-align: left; padding: 16px 18px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.stat-cell:last-child { border-right: 0; }
.stat-cell:hover { background: var(--surface-2); }
.stat-cell span, .stat-cell small { color: var(--muted); font-size: 11px; }
.stat-cell strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-feed { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 9px; }
.feed-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; border-top: 1px solid var(--line); }
.feed-item { display: flex; flex-direction: column; gap: 5px; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.feed-item .feed-meta { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; gap: 10px; }
.feed-item strong { font-size: 13px; line-height: 1.4; font-weight: 600; }
.feed-item p { color: var(--muted); font-size: 11px; line-height: 1.35; }
.feed-item a { color: inherit; text-decoration: none; }
.feed-item a:hover { text-decoration: underline; }

.subnav { display: flex; gap: 5px; overflow-x: auto; min-width: 0; flex: none; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subtab { flex: none; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); padding: 8px 11px; font-size: 12px; white-space: nowrap; }
.subtab.active { background: #f0f2f4; border-color: #f0f2f4; color: #111419; font-weight: 700; }
.data-surface { flex: 1; min-height: 0; border-top: 1px solid var(--line); }
.surface-scroll { width: 100%; height: 100%; overflow-y: auto; scrollbar-width: thin; }
.empty-state { color: var(--muted); font-size: 12px; padding: 25px 4px; }
.data-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 14px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.data-row strong { font-size: 13px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.data-row small { color: var(--muted); font-size: 11px; }
.data-row .value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.row-detail { grid-column: 1 / -1; font-size: 11px; color: var(--muted); }
.tag { border: 1px solid var(--line); border-radius: 3px; padding: 3px 6px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.pair { display: flex; align-items: center; gap: 10px; }
.pair .tag { flex: none; }
.bar-track { height: 5px; border-radius: 5px; background: #2b3036; overflow: hidden; }
.bar-track span { display: block; height: 100%; width: var(--fill, 0%); background: var(--green); border-radius: inherit; }
.bar-track.negative span { background: var(--red); }
.data-row .bar-track { grid-column: 1 / -1; }

.ai-selectors { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; }
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.segmented button { border: 0; border-radius: 3px; background: none; color: var(--muted); padding: 6px 11px; font-size: 11px; white-space: nowrap; }
.segmented button.selected { background: #f0f2f4; color: #111419; font-weight: 800; }
.ai-body { flex: none; height: clamp(270px, 43dvh, 390px); min-height: 0; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(260px, .8fr); gap: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 7px; min-height: 0; }
.metric { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); padding: 11px 13px; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; }
.metric span, .metric small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.metric strong { font-size: clamp(15px, 1.6vw, 23px); line-height: 1.1; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.trend-section { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.trend-list { flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 7px; }
.trend-row { border: 1px solid var(--line); border-radius: 5px; background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; justify-content: space-between; gap: 5px; }
.trend-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.trend-top strong { font-size: 12px; }
.trend-top span { font-size: 12px; font-weight: 700; }
.trend-foot { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 10px; }
.ai-context { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; flex: none; }
.ai-context strong { color: var(--text); margin-left: 5px; font-variant-numeric: tabular-nums; }
.analysis-area { flex: none; }
.analysis-button { border: 1px solid #333d3a; background: #1b3129; color: #dcfff0; width: 100%; min-height: 43px; border-radius: 5px; font-size: 12px; font-weight: 750; }
.analysis-button:hover:not(:disabled) { background: #234334; }
.analysis-button span { font-size: 17px; vertical-align: -1px; margin-right: 4px; }
.analysis-output { position: fixed; z-index: 50; width: min(530px, calc(100vw - 24px)); left: 50%; bottom: 20px; transform: translateX(-50%); max-height: 55vh; overflow-y: auto; background: #181d23; border: 1px solid #505963; box-shadow: 0 15px 50px #000a; border-radius: 7px; padding: 14px 17px 18px; }
.analysis-head { display: flex; align-items: center; justify-content: space-between; }
.analysis-head strong { font-size: 14px; }
.analysis-head .icon-button { width: 26px; height: 26px; border: 0; background: transparent; }
.analysis-output p { margin-top: 8px; font-size: 12px; line-height: 1.7; color: #dbe0e3; white-space: pre-wrap; }

.account-block { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 19px; display: flex; gap: 14px; align-items: center; }
.account-mark { width: 43px; height: 43px; font-size: 25px; }
.account-block span, .account-block strong { display: block; }
.account-block span { font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.account-block strong { font-size: 17px; }
.account-list { border-top: 1px solid var(--line); }
.account-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 15px 2px; border-bottom: 1px solid var(--line); font-size: 12px; }
.account-list span { color: var(--muted); }
.account-list strong { font-variant-numeric: tabular-nums; }
.account-note { color: var(--muted); font-size: 11px; line-height: 1.5; }
.bottom-nav { display: none; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; transition: .18s; background: #252b33; border: 1px solid #4a535e; border-radius: 5px; padding: 8px 12px; color: white; font-size: 11px; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 13px 16px calc(80px + var(--bottom)); }
  .topbar { min-height: 43px; margin-bottom: 11px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(66px + var(--bottom)); padding: 6px 8px var(--bottom); border-top: 1px solid var(--line); background: #0d1014; }
  .bottom-nav .nav-item { min-height: 52px; height: 52px; padding: 3px 0; flex-direction: column; justify-content: center; gap: 3px; font-size: 10px; text-align: center; }
  .bottom-nav .nav-icon { font-size: 20px; height: 21px; }
  .bottom-nav .ai-nav { position: relative; top: -7px; height: 59px; border: 1px solid #484e56; background: #20252b; color: white; }
  .bottom-nav .ai-nav.active { background: #f0f2f4; color: #111419; border-color: #f0f2f4; }
  .analysis-output { bottom: calc(78px + var(--bottom)); }
  .toast { bottom: calc(78px + var(--bottom)); }
}
@media (max-width: 700px) {
  h1 { font-size: 19px; }
  .crumb { font-size: 9px; }
  .main { padding: 10px 12px calc(77px + var(--bottom)); }
  .topbar { margin-bottom: 9px; }
  .page { gap: 9px; }
  .price-grid { gap: 7px; }
  .price-tile { padding: 12px 11px; gap: 6px; }
  .price-tile strong { font-size: 20px; }
  .tile-top { font-size: 12px; }
  .tile-top small, .market-live { font-size: 9px; }
  .home-stats .stat-cell { padding: 10px 8px; }
  .stat-cell span, .stat-cell small { font-size: 9px; }
  .stat-cell strong { font-size: 12px; }
  .ai-body { display: flex; flex: 1; height: auto; flex-direction: column; gap: 9px; }
  .metric-grid { flex: none; height: 146px; gap: 5px; }
  .metric { padding: 8px 7px; }
  .metric span, .metric small { font-size: 9px; }
  .metric strong { font-size: 14px; }
  .trend-section { flex: 1; }
  .trend-row { padding: 7px 9px; }
  .trend-list { gap: 5px; }
  .trend-foot { font-size: 9px; }
  .analysis-button { min-height: 39px; }
  .update-label { display: none; }
}
@media (max-width: 700px) and (max-height: 700px) {
  .main { padding-top: 6px; }
  .page { gap: 6px; }
  .metric-grid { height: 126px; }
  .metric { gap: 2px; }
  .trend-row { padding: 4px 8px; gap: 2px; }
  .trend-foot { display: none; }
  .price-tile { padding: 8px 10px; }
  .stat-cell small { display: none; }
}
