:root {
  color-scheme: dark;
  --bg: #071014;
  --surface: #0c181d;
  --surface-2: #11232a;
  --line: #28424a;
  --text: #e9f5f3;
  --muted: #91aaa9;
  --cyan: #22c9c3;
  --gold: #d5ad55;
  --green: #4fd18b;
  --red: #f06f78;
  --amber: #f3bf62;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: Inter, "Segoe UI", Arial, sans-serif; }
button, select { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; }
.topbar { min-height: 70px; padding: 10px 28px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #081318; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 44px; height: 44px; object-fit: contain; }
.brand div { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: 18px; font-weight: 750; }
.brand span { color: var(--gold); font-size: 11px; text-transform: uppercase; }
.system-state { display: grid; grid-template-columns: 9px auto; align-items: center; gap: 2px 8px; text-align: right; }
.system-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(79,209,139,.65); grid-row: span 2; }
.system-state span { font-size: 12px; font-weight: 700; }
.system-state small { color: var(--muted); font-size: 10px; }
.workspace-tabs { min-height: 46px; padding: 0 28px; display: flex; align-items: stretch; gap: 28px; border-bottom: 1px solid var(--line); overflow-x: auto; background: #09151a; }
.tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 0 2px; white-space: nowrap; cursor: pointer; }
.tab:hover, .tab:focus-visible { color: var(--text); }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }
main { max-width: 1540px; margin: 0 auto; padding: 22px 28px 26px; }
.controls { min-height: 50px; display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.symbol-control { display: flex; align-items: center; gap: 10px; }
.symbol-control span { color: var(--muted); font-size: 12px; text-transform: uppercase; }
select { min-width: 176px; height: 38px; padding: 0 32px 0 10px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.timeframes { height: 36px; display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.timeframes button { min-width: 46px; padding: 0 10px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.timeframes button:last-child { border-right: 0; }
.timeframes button.active { background: var(--cyan); color: #031214; font-weight: 800; }
.refresh-button { height: 36px; margin-left: auto; padding: 0 16px; border: 1px solid var(--cyan); border-radius: 5px; background: transparent; color: var(--cyan); cursor: pointer; }
.refresh-button:hover { background: rgba(34,201,195,.1); }
.view { display: none; }
.view.active { display: block; }
.market-header { min-height: 104px; display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 4px 0 22px; border-bottom: 1px solid var(--line); }
.eyebrow, .panel-heading span, .view-heading span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.price-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.price-row h1 { margin: 4px 0 0; font-size: clamp(34px, 5vw, 56px); line-height: 1; font-weight: 720; }
.price-row span { font-size: 16px; font-weight: 750; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.bias-block { text-align: right; display: flex; flex-direction: column; gap: 4px; }
.bias-block span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.bias-block strong { font-size: 22px; color: var(--amber); }
.bias-block small { color: var(--muted); }
.desk-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 560px; }
.chart-panel { min-width: 0; padding: 22px 24px 8px 0; border-right: 1px solid var(--line); }
.signal-panel { padding: 22px 0 8px 24px; }
.panel-heading { min-height: 42px; display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.panel-heading div:first-child { display: flex; flex-direction: column; gap: 4px; }
.panel-heading strong { font-size: 15px; }
.legend { display: flex; gap: 14px; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; }
.legend .up::before { background: var(--green); }
.legend .down::before { background: var(--red); }
#chart { width: 100%; height: 460px; display: block; background: #081317; border: 1px solid #19323a; border-radius: 5px; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font: 10px Consolas, monospace; padding-top: 7px; }
.metrics { margin: 12px 0 22px; }
.metrics div { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #1c333a; }
.metrics dt { color: var(--muted); font-size: 12px; }
.metrics dd { margin: 0; font: 700 13px Consolas, monospace; }
.read-only { border-left: 3px solid var(--gold); background: rgba(213,173,85,.08); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.read-only strong { color: var(--gold); font-size: 12px; }
.read-only span { color: var(--muted); font-size: 11px; line-height: 1.45; }
.view-heading { min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); }
.view-heading h2 { margin: 3px 0 0; font-size: 24px; }
.market-table { margin-top: 12px; }
.market-row { min-height: 50px; display: grid; grid-template-columns: 1.4fr 1fr .8fr 1fr; align-items: center; gap: 12px; padding: 0 12px; border-bottom: 1px solid #193039; cursor: pointer; }
.market-row:hover { background: #0c1b20; }
.market-row span:not(:first-child) { text-align: right; font-family: Consolas, monospace; }
.table-head { min-height: 36px; color: var(--muted); font-size: 10px; text-transform: uppercase; cursor: default; }
.table-head:hover { background: transparent; }
.heat-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 8px; padding-top: 18px; }
.heat-tile { min-height: 104px; border: 1px solid var(--line); border-radius: 5px; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; }
.heat-tile strong { font-size: 14px; }
.heat-tile span { font-size: 20px; font-weight: 800; }
.heat-tile small { color: var(--muted); }
.heat-tile.gain { background: rgba(79,209,139,var(--intensity)); border-color: rgba(79,209,139,.55); }
.heat-tile.loss { background: rgba(240,111,120,var(--intensity)); border-color: rgba(240,111,120,.55); }
.activity-log { padding-top: 18px; }
.activity-item { min-height: 50px; display: grid; grid-template-columns: 90px 1fr; align-items: center; border-bottom: 1px solid #193039; color: var(--muted); }
.activity-item time { font-family: Consolas, monospace; color: var(--cyan); }
footer { min-height: 48px; border-top: 1px solid var(--line); padding: 0 28px; display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--muted); font-size: 10px; }
.error-banner { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 11px 14px; background: #291419; border: 1px solid var(--red); border-radius: 5px; color: #ffdadd; z-index: 10; }

@media (max-width: 900px) {
  .topbar, .workspace-tabs, main, footer { padding-left: 16px; padding-right: 16px; }
  .desk-grid { grid-template-columns: 1fr; }
  .chart-panel { padding-right: 0; border-right: 0; }
  .signal-panel { padding-left: 0; border-top: 1px solid var(--line); }
  .heat-grid { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; }
  .brand img { width: 38px; height: 38px; }
  .brand span { white-space: normal; }
  .system-state span { display: none; }
  .workspace-tabs { gap: 20px; }
  .controls { align-items: stretch; flex-wrap: wrap; }
  .symbol-control { width: 100%; justify-content: space-between; }
  select { flex: 1; min-width: 0; }
  .timeframes { width: 100%; }
  .timeframes button { min-width: 0; flex: 1; padding: 0 4px; }
  .refresh-button { width: 100%; margin-left: 0; }
  .market-header { align-items: flex-start; flex-direction: column; }
  .bias-block { text-align: left; }
  #chart { height: 340px; }
  .market-row { grid-template-columns: 1.2fr 1fr .7fr; }
  .market-row span:nth-child(4) { display: none; }
  .heat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { padding-top: 10px; padding-bottom: 10px; align-items: flex-start; flex-direction: column; }
}
