/* Agryos Terminal — base: reset, shell layout, components, motion (SHARED)
   The design system behind it is docs/DESIGN.md. View-specific styles live in static/css/views/<id>.css scoped
   under .view-<id>. Every class below is used by at least one view: restyle freely, never rename or drop. */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-ui); font-size: var(--fs); line-height: var(--lh); color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
}
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img, svg, canvas { display: block; max-width: 100%; }
canvas { max-width: none; }
table { border-collapse: collapse; border-spacing: 0; }
kbd { font-family: var(--font-mono); font-size: 10px; }
/* Figures in Plex Mono, words in Plex Sans: a column header, a meta line or a label is words even when it sits
   over numbers (mono for small labels is one of the generated-UI tells). */
code, .mono, .num, .tbl td.num, .kpi .val, .price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tabular, .tbl th.num { font-variant-numeric: tabular-nums; }
/* the generic .num above also matched <th class="num">, so every numeric column header was still mono */
.tbl th.num { font-family: var(--font-ui); }
::selection { background: rgba(var(--accent-rgb), .28); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: rgba(236, 233, 229, .14) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(236, 233, 229, .12); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(236, 233, 229, .24); background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-corner { background: transparent; }
[data-theme="light"] * { scrollbar-color: rgba(29, 26, 23, .2) transparent; }
[data-theme="light"] *::-webkit-scrollbar-thumb { background: rgba(29, 26, 23, .18); background-clip: padding-box; border: 2px solid transparent; }

/* ---------- background: flat canvas + film grain ----------
   Static on purpose. The drifting conic "aurora" that used to rotate here was decoration with no meaning, and
   the accent glow that replaced it went too: a data terminal separates areas by surface steps and hairlines,
   not by atmosphere (Binance/Coinbase rule; a cyan accent turned it into a cyan haze). */
.bg-fx { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; background: var(--bg); }
.bg-fx::before { content: none; }
.bg-fx::after { content: ""; position: absolute; inset: 0; background-image: var(--grain); background-size: 180px 180px; opacity: var(--grain-opacity); mix-blend-mode: overlay; }

/* ---------- app shell ---------- */
body.app { overflow: hidden; height: 100vh; height: 100dvh; }
.shell {
  position: relative; z-index: 1; height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: auto var(--header-h) var(--ticker-h) 1fr var(--footer-h);
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas: "banner banner" "header header" "ticker ticker" "sidebar main" "footer footer";
}
body.sidebar-collapsed .shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.demo-banner {
  grid-area: banner; display: flex; align-items: center; justify-content: center; gap: var(--sp-3);
  padding: 6px var(--sp-4); font-size: var(--fs-sm); font-weight: 500;
  background: rgba(var(--accent-rgb), .1); color: var(--accent-text); border-bottom: 1px solid rgba(var(--accent-rgb), .22);
}
.demo-banner a { text-decoration: underline; text-underline-offset: 2px; color: var(--text); }

/* header */
.hdr {
  grid-area: header; display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-3) 0 var(--sp-4);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: calc(var(--sidebar-w) - var(--sp-4)); }
/* Marca Agryos (17/10/2026, marca_publicacao/logo_agryos/final/GUIA.md): o nome em contornos com o A de fios, fio de 1 px e o
   descritor AGRIBUSINESS FINANCIAL TERMINAL ao lado, no tamanho fixo do cabeçalho (28 px de altura). Com a barra lateral recolhida
   (e abaixo de 1024 px) fica só o símbolo, no quadrado do ícone do app. Cores da marca, com a versão de fundo claro no tema claro. */
.brand .brand-sym { display: none; width: 26px; height: 26px; flex: none; }
.brand .brand-wm { display: block; width: 89px; height: 28px; flex: none; }
.brand .brand-desc { display: block; width: 240px; height: 28px; flex: none; margin: 0 var(--sp-3) 0 1px; }   /* respiro antes do estado da conexão */
.brand-wm .a { fill: #e3b662; } .brand-wm .n { fill: #ece9e5; } .brand-desc .f { fill: #3a3530; } .brand-desc .d { fill: #a9a39b; }
[data-theme="light"] .brand-wm .a { fill: #7d5700; } [data-theme="light"] .brand-wm .n { fill: #1d1a17; }
[data-theme="light"] .brand-desc .f { fill: #d4cfc8; } [data-theme="light"] .brand-desc .d { fill: #6f6a63; }
.hdr-mid { flex: 1; display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.hdr-right { display: flex; align-items: center; gap: var(--sp-2); }

/* Connection state. The dot is static; the thin ring only plays when a real quote arrives (shell.js, at most
   once every 2 s), so it stops by itself when the feed or the exchange stops. */
.live { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); white-space: nowrap; }
.live .dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.live .dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid rgba(var(--up-rgb), .9); opacity: 0; transform: scale(.5); pointer-events: none; }
.live .dot.tick::after { animation: tick-ring 900ms var(--ease-out); }
@keyframes tick-ring { 0% { opacity: .75; transform: scale(.5); } 100% { opacity: 0; transform: scale(1.35); } }
.live.on .dot { background: var(--up); box-shadow: 0 0 0 3px rgba(var(--up-rgb), .14); }
.live.on { color: var(--text); }
.live.idle .dot { background: var(--text-2); }
.live.idle { color: var(--text-2); }
.live.off .dot { background: var(--down); }
.live.off { color: var(--down); }

.mkt-state {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); white-space: nowrap;
  background: var(--tint); border: 1px solid var(--border);
}
.mkt-state:empty { display: none; }
.mkt-state.open { color: var(--up); border-color: rgba(var(--up-rgb), .24); background: rgba(var(--up-rgb), .07); }
.mkt-state.pre { color: var(--warn); border-color: rgba(var(--warn-rgb), .24); background: rgba(var(--warn-rgb), .07); }
.mkt-state.closed { color: var(--text-3); }
.mkt-state small { font-size: var(--fs-xs); font-weight: 400; color: var(--text-3); }

.clocks { display: flex; gap: var(--sp-3); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; }
.clocks b { color: var(--text-3); font-weight: 500; margin-right: 5px; }

.btn-cmd {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px 0 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--tint); color: var(--text-2); font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn-cmd:hover { border-color: var(--border-hover); color: var(--text); background: var(--hover); }
.btn-cmd kbd { padding: 1px 5px; border: 1px solid var(--border); border-radius: var(--r-xs); color: var(--text-3); background: var(--tint); }
.btn-cmd svg { width: 14px; height: 14px; }

.user-menu { position: relative; }
.user-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 4px; border-radius: var(--r-sm);
  border: 1px solid transparent; transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.user-btn:hover, .user-menu.open .user-btn { border-color: var(--border-strong); background: var(--hover); }
.avatar { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: 10.5px; font-weight: 600; color: var(--accent-ink); background: var(--accent); }
.user-btn .uname { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); }
.user-dd {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 5px; border-radius: var(--r);
  background: var(--panel-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top right; pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); z-index: var(--z-dropdown);
}
.user-menu.open .user-dd { opacity: 1; transform: none; pointer-events: auto; }
.user-dd .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-dd .who b { display: block; font-size: var(--fs-sm); font-weight: 600; }
.user-dd .who span { font-size: var(--fs-xs); color: var(--text-3); }
.user-dd a, .user-dd button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-2); text-align: left; transition: background-color var(--dur-instant), color var(--dur-instant); }
.user-dd a:hover, .user-dd button:hover { background: var(--hover-strong); color: var(--text); }
.user-dd svg { width: 14px; height: 14px; }
.plan-pill { display: inline-block; font-size: 10.5px; font-weight: 600; line-height: 16px; padding: 0 6px; border-radius: var(--r-xs); background: rgba(var(--accent-rgb), .13); color: var(--accent-text); }

/* ticker tape */
.ticker { grid-area: ticker; position: relative; overflow: hidden; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.ticker::before, .ticker::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40px; z-index: 2; pointer-events: none; }
.ticker::before { left: 0; background: linear-gradient(90deg, var(--bg-2), transparent); }
.ticker::after { right: 0; background: linear-gradient(270deg, var(--bg-2), transparent); }
.tape { display: flex; width: max-content; height: var(--ticker-h); align-items: center; animation: marquee 60s linear infinite; will-change: transform; }
.ticker:hover .tape { animation-play-state: paused; }
.tape-item { display: inline-flex; align-items: center; gap: 7px; padding: 0 16px; height: 100%; border-right: 1px solid var(--border); font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; transition: background-color var(--dur-fast) var(--ease); }
.tape-item:hover { background: var(--hover); }
.tape-item .sym { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; color: var(--text); }
.tape-item .nm { color: var(--text-3); font-size: var(--fs-xs); }
.tape-item .px { font-family: var(--font-mono); font-variant-numeric: tabular-nums; padding: 1px 4px; border-radius: var(--r-xs); }
.tape-item .pc { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--fs-xs); }
.tape-item.empty .px { color: var(--text-3); }
@keyframes marquee { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-50%, 0, 0); } }

/* sidebar */
.sidebar { grid-area: sidebar; position: relative; overflow: hidden auto; padding: 10px 8px; border-right: 1px solid var(--border); background: var(--bg); }
.nav { position: relative; display: flex; flex-direction: column; gap: 1px; }
.nav-indicator {
  position: absolute; left: -8px; width: 2px; height: 16px; border-radius: 0 2px 2px 0; background: var(--accent); top: 0;
  transform: translateY(0); opacity: 0; z-index: 1;
  transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur-fast);
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: .8; transition: opacity var(--dur-fast), color var(--dur-fast); }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active { background: var(--hover-strong); color: var(--text); }
.nav-item.active svg { color: var(--accent); opacity: 1; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item kbd { color: var(--text-3); padding: 0 4px; border-radius: var(--r-xs); opacity: .7; }
.nav-item:hover kbd, .nav-item.active kbd { opacity: 1; }
.nav-sep { height: 1px; margin: 6px 8px; background: var(--border); }
.sidebar-foot { position: sticky; bottom: 0; padding-top: 8px; margin-top: 8px; }
.sidebar-toggle { display: flex; align-items: center; gap: 10px; width: 100%; height: 30px; padding: 0 10px; border-radius: var(--r-sm); color: var(--text-3); font-size: var(--fs-xs); transition: background-color var(--dur-fast), color var(--dur-fast); }
.sidebar-toggle:hover { background: var(--hover); color: var(--text); }
.sidebar-toggle svg { width: 15px; height: 15px; transition: transform var(--dur) var(--ease); }
body.sidebar-collapsed .sidebar { padding: 10px 6px; }
body.sidebar-collapsed .nav-indicator { left: -6px; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
body.sidebar-collapsed .nav-item .label, body.sidebar-collapsed .nav-item kbd, body.sidebar-collapsed .sidebar-toggle span { display: none; }
body.sidebar-collapsed .sidebar-toggle { justify-content: center; padding: 0; }
body.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
body.sidebar-collapsed .brand .name, body.sidebar-collapsed .brand .tag { display: none; }
body.sidebar-collapsed .brand .brand-sym { display: block; }
body.sidebar-collapsed .brand { min-width: calc(var(--sidebar-w-collapsed) - var(--sp-4)); }

/* main + views */
.main { grid-area: main; position: relative; overflow: auto; padding: var(--sp-3) var(--sp-3) var(--sp-4); min-width: 0; }
.view { display: none; min-height: 100%; }
/* a view module may set its own display (flex/grid) on .view-<id>; this keeps inactive views hidden regardless */
.view:not(.active) { display: none !important; }
.view.active { display: block; }
@keyframes view-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.view-head h1 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.view-head .sub { color: var(--text-3); font-size: var(--fs-sm); }
.view-head .spacer, .spacer { flex: 1; }
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* footer / status bar */
.statusbar { grid-area: footer; display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-3); font-size: var(--fs-xs); color: var(--text-3); border-top: 1px solid var(--border); background: var(--bg); white-space: nowrap; overflow: hidden; }
.statusbar .src-chips { display: flex; gap: 4px; }
.src-chip { display: inline-flex; align-items: center; gap: 5px; height: 18px; padding: 0 6px; border-radius: var(--r-xs); font-family: var(--font-mono); font-size: 10px; border: 1px solid var(--border); color: var(--text-3); background: var(--tint); }
.src-chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); }
.src-chip.ok { color: var(--text-2); }
.src-chip.ok::before { background: var(--up); }
.src-chip.err { color: var(--down); border-color: rgba(var(--down-rgb), .3); }
.src-chip.err::before { background: var(--down); }
.statusbar .ticks { color: var(--text-2); font-variant-numeric: tabular-nums; }
.statusbar .ticks b { font-family: var(--font-mono); color: var(--text); font-weight: 600; }
.statusbar .sources { color: var(--text-3); }
.statusbar .sources a:hover { color: var(--text-2); }
.statusbar .ver { margin-left: auto; font-family: var(--font-mono); }

/* ---------- panels ---------- */
.panel {
  position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); min-width: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.panel.lift:hover, .card.lift:hover { transform: translateY(-1px); border-color: var(--border-hover); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: var(--sp-2); padding: 8px 12px; border-bottom: 1px solid var(--border); min-height: 38px; }
.panel-head h3, .panel-head .title { font-size: var(--fs-sm); font-weight: 600; letter-spacing: -.005em; color: var(--text); }
.panel-head .code { font-size: 10.5px; font-weight: 600; letter-spacing: .01em; line-height: 16px; padding: 0 6px; border-radius: var(--r-xs); background: var(--tint-strong); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.panel-head .spacer { flex: 1; }
.panel-head .meta { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.panel-body { padding: 12px; }
.panel-body.tight { padding: 0; }
.panel-foot { padding: 8px 12px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); padding: var(--sp-3); transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }

/* ---------- grids ---------- */
.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--sp-3); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1280px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1024px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.mt { margin-top: var(--sp-3); } .mb { margin-bottom: var(--sp-3); }
.muted { color: var(--text-3); } .dim { color: var(--text-2); }
.small { font-size: var(--fs-xs); }
.up { color: var(--up) !important; } .down { color: var(--down) !important; } .flat { color: var(--flat) !important; }
.accent { color: var(--accent-text); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* ---------- tables ---------- */
.tbl-wrap { overflow: auto; max-height: 100%; }
.tbl { width: 100%; font-size: var(--fs-sm); }
.tbl th, .tbl td { height: var(--row-h); padding: 0 var(--cell-px); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); vertical-align: middle; }
/* sentence-case header; the bottom rule is a shadow so it survives position:sticky */
.tbl thead th {
  position: sticky; top: 0; z-index: 2; background: var(--panel-solid); color: var(--text-3);
  font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0; text-transform: none; cursor: default; user-select: none;
  border-bottom: 0; box-shadow: inset 0 -1px 0 var(--border-strong);
}
.tbl thead th.sortable { cursor: pointer; transition: color var(--dur-fast); }
.tbl thead th.sortable:hover { color: var(--text); }
.tbl thead th .sort::after { content: "↕"; margin-left: 4px; opacity: .35; }
.tbl thead th.asc .sort::after { content: "↑"; opacity: 1; color: var(--accent-text); }
.tbl thead th.desc .sort::after { content: "↓"; opacity: 1; color: var(--accent-text); }
.tbl tbody tr { transition: background-color var(--dur-fast) var(--ease); }
.tbl.zebra tbody tr:nth-child(even) { background: var(--tint); }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tbody tr.selected { background: rgba(var(--accent-rgb), .08); box-shadow: inset 2px 0 0 var(--accent); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl td.sym { font-weight: 600; font-family: var(--font-mono); }
.tbl td.dim { color: var(--text-3); }
.tbl tr.group-row td { background: var(--bg-2); color: var(--text); font-weight: 600; font-size: var(--fs-xs); letter-spacing: .01em; }

/* Number-change highlight (AF.flash): a short tint behind the cell in the direction of the move, then nothing.
   Only real ticks trigger it — the server sends dir=0 outside trading hours. */
@keyframes flash-up { 0% { background-color: rgba(var(--up-rgb), .24); color: var(--up); } 100% { background-color: rgba(var(--up-rgb), 0); } }
@keyframes flash-down { 0% { background-color: rgba(var(--down-rgb), .24); color: var(--down); } 100% { background-color: rgba(var(--down-rgb), 0); } }
.flash-up { animation: flash-up var(--flash-ms) var(--ease-out); }
.flash-down { animation: flash-down var(--flash-ms) var(--ease-out); }
tr.flash-up > td { animation: flash-up var(--flash-ms) var(--ease-out); }
tr.flash-down > td { animation: flash-down var(--flash-ms) var(--ease-out); }
@keyframes roll { 0% { opacity: .2; transform: translateY(-35%); } 100% { opacity: 1; transform: none; } }
.roll { display: inline-block; animation: roll 220ms var(--ease-out); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; padding: 0 13px;
  border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--tint); color: var(--text);
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; box-shadow: var(--inset-hi);
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--hover-strong); border-color: var(--border-hover); }
.btn:active { transform: scale(.97); background: var(--press); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 1px 2px rgba(var(--shadow-rgb), .3); }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn.primary:active { filter: brightness(.96); background: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--down); border-color: rgba(var(--down-rgb), .35); background: transparent; }
.btn.danger:hover { background: rgba(var(--down-rgb), .1); }
.btn.sm { height: 26px; padding: 0 9px; font-size: var(--fs-xs); }
.btn.lg { height: 40px; padding: 0 20px; font-size: var(--fs-md); border-radius: var(--r); }
.btn.icon { width: 32px; padding: 0; }
.btn.icon.sm { width: 26px; }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.btn-group .btn + .btn { margin-left: -1px; }

/* chips (toggle filters): squared tags, not a cloud of pills */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: var(--r-sm);
  border: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); background: var(--tint);
  cursor: pointer; user-select: none;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); background: var(--hover); }
.chip.active, .chip[aria-pressed="true"] { background: rgba(var(--accent-rgb), .12); color: var(--accent-text); border-color: rgba(var(--accent-rgb), .42); }
.chip .cnt { font-family: var(--font-mono); font-size: 10.5px; opacity: .6; }
.chip.active .cnt, .chip[aria-pressed="true"] .cnt { opacity: .85; }
.chip.up.active { background: rgba(var(--up-rgb), .12); color: var(--up); border-color: rgba(var(--up-rgb), .4); }
.chip.down.active { background: rgba(var(--down-rgb), .12); color: var(--down); border-color: rgba(var(--down-rgb), .4); }

/* tabs — underline variant. motion.js adds a .tab-ind that slides between tabs; without it (or without JS) the
   active tab draws its own underline, so nothing depends on the script. */
.tabs { position: relative; display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tabs .tab { position: relative; z-index: 1; height: 34px; padding: 0 12px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .tab:hover { color: var(--text-2); }
.tabs .tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs > .tab-ind {
  position: absolute; left: 0; top: 0; width: 0; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
  pointer-events: none; z-index: 2;
  transition: transform 260ms var(--ease-in-out), width 260ms var(--ease-in-out), height 260ms var(--ease-in-out);
}
.tabs:has(> .tab-ind) .tab.active { border-bottom-color: transparent !important; }
/* segmented control variant */
.tabs.pill { border: 1px solid var(--border); gap: 2px; padding: 2px; background: var(--sunken); border-radius: calc(var(--r-sm) + 2px); width: max-content; }
.tabs.pill .tab { height: 26px; padding: 0 10px; border: 0; margin: 0; border-radius: var(--r-sm); color: var(--text-2); }
.tabs.pill .tab:hover { color: var(--text); }
.tabs.pill .tab.active { background: var(--panel-2); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.tabs.pill > .tab-ind { border-radius: var(--r-sm); background: var(--panel-2); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); z-index: 0; }
.tabs.pill:has(> .tab-ind) .tab.active { background: transparent; box-shadow: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in var(--dur-fast) var(--ease-out); }

/* forms */
.input, .select, .textarea {
  height: 32px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--sunken);
  color: var(--text); font-size: var(--fs-sm); outline: none; min-width: 0;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-hover); }
.input:focus, .select:focus, .textarea:focus { border-color: rgba(var(--accent-rgb), .7); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .16); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input.sm, .select.sm { height: 26px; font-size: var(--fs-xs); padding: 0 8px; }
.select {
  appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 9px) 55%; background-size: 4px 4px; background-repeat: no-repeat;
}
/* .select.sm's "padding: 0 8px" (two classes) beat the arrow room above, so the arrow sat on the last letter */
.select.sm { padding-right: 22px; background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%; }
.select option { background: var(--panel-2); color: var(--text); }
.textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); letter-spacing: 0; text-transform: none; }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.form-row { display: flex; gap: var(--sp-2); align-items: flex-end; flex-wrap: wrap; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 30px; height: 18px; border-radius: var(--r-pill); background: var(--tint-strong); border: 1px solid var(--border-strong); position: relative; transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-2); box-shadow: 0 1px 2px rgba(var(--shadow-rgb), .35); transition: transform var(--dur) var(--ease-out), background-color var(--dur-fast); }
.switch:hover .track { border-color: var(--border-hover); }
.switch input:checked + .track { background: var(--accent); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(12px); background: var(--accent-ink); }
.switch input:focus-visible + .track { outline: 2px solid rgba(var(--accent-rgb), .75); outline-offset: 2px; }
.search { position: relative; }
.search .input { padding-left: 28px; width: 100%; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 13px; height: 13px; color: var(--text-3); pointer-events: none; }

/* KPI tiles — sentence-case label, mono value; inside a panel the tile becomes a quiet well */
.kpi { padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); min-width: 0; }
.panel .kpi, .card .kpi { background: var(--tint); }
.kpi .label { font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); letter-spacing: 0; text-transform: none; line-height: 1.35; }
.kpi .val { font-size: var(--num-lg); font-weight: 500; letter-spacing: var(--num-track); margin-top: 3px; line-height: 1.2; }
.kpi .val.big { font-size: var(--num-xl); }
.kpi .delta { font-family: var(--font-mono); font-size: var(--fs-xs); margin-top: 2px; }
.kpi .sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 3px; line-height: 1.4; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-2); }

/* badges: short status tags — the only place uppercase is allowed, because their texts are codes or one word */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0 6px; border-radius: var(--r-xs); font-size: 10.5px; font-weight: 600; letter-spacing: .01em; border: 1px solid var(--border-strong); color: var(--text-2); white-space: nowrap; }
.badge.up { border-color: rgba(var(--up-rgb), .35); background: rgba(var(--up-rgb), .09); }
.badge.down { border-color: rgba(var(--down-rgb), .35); background: rgba(var(--down-rgb), .09); }
.badge.warn { color: var(--warn); border-color: rgba(var(--warn-rgb), .35); background: rgba(var(--warn-rgb), .09); }
.badge.info { color: var(--info); border-color: rgba(var(--info-rgb), .35); background: rgba(var(--info-rgb), .09); }
.badge.accent { color: var(--accent-text); border-color: rgba(var(--accent-rgb), .35); background: rgba(var(--accent-rgb), .09); }
/* data-source letters: neutral, told apart by the letters, not by six brand colours */
.badge-src { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: var(--r-xs); font-family: var(--font-mono); font-size: 9.5px; font-weight: 600; color: var(--text-2); background: var(--tint-strong); border: 1px solid var(--border); cursor: help; }
.badge-src.tv, .badge-src.yh, .badge-src.yhc, .badge-src.aw, .badge-src.bcb, .badge-src.fr { color: var(--text-2); background: var(--tint-strong); }
.sent { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--flat); }
.sent.bullish { background: var(--up); } .sent.bearish { background: var(--down); }

/* skeleton: shaped like the content it stands in for; the sweep is the one loop allowed (it means "loading") */
.skeleton { position: relative; overflow: hidden; background: var(--tint-strong); border-radius: var(--r-sm); min-height: 12px; color: transparent !important; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(236, 233, 229, .055), transparent); animation: shimmer 1.6s var(--ease-in-out) infinite; }
[data-theme="light"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton.line { height: 10px; margin: 7px 0; border-radius: var(--r-xs); }
.skeleton.block { height: 120px; }
.skeleton-rows { padding: 8px 12px; }
.skeleton-rows .skeleton.line:nth-child(odd) { width: 92%; } .skeleton-rows .skeleton.line:nth-child(even) { width: 70%; }

/* empty / error states */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.5; }
.empty svg { width: 24px; height: 24px; opacity: .55; }
.empty.error { color: var(--down); }
.empty .btn { margin-top: 4px; }
.notice { padding: 8px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); border: 1px solid var(--border-strong); background: var(--tint); line-height: 1.5; }
.notice.warn { border-color: rgba(var(--warn-rgb), .32); background: rgba(var(--warn-rgb), .07); color: var(--warn); }
.notice.err { border-color: rgba(var(--down-rgb), .32); background: rgba(var(--down-rgb), .07); color: var(--down); }
.notice.ok { border-color: rgba(var(--up-rgb), .32); background: rgba(var(--up-rgb), .07); color: var(--up); }
.notice.info { border-color: rgba(var(--info-rgb), .32); background: rgba(var(--info-rgb), .07); color: var(--info); }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: calc(var(--footer-h) + 12px); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: 380px; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: var(--r);
  background: var(--panel-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); font-size: var(--fs-sm); line-height: 1.45;
  border-left: 2px solid var(--info); animation: toast-in 240ms var(--ease-out);
}
.toast.ok { border-left-color: var(--up); } .toast.warn { border-left-color: var(--warn); } .toast.err { border-left-color: var(--down); } .toast.info { border-left-color: var(--info); }
.toast .msg { flex: 1; }
.toast .msg b { display: block; font-weight: 600; }
.toast .x { color: var(--text-3); font-size: 16px; line-height: 1; transition: color var(--dur-instant); }
.toast .x:hover { color: var(--text); }
.toast.out { animation: toast-out var(--dur) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

/* ---------- modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: var(--z-overlay); display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(var(--shadow-rgb), .62); animation: fade-in var(--dur) var(--ease-out) both; }
[data-theme="light"] .modal-backdrop { background: rgba(40, 32, 20, .32); }
.modal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; background: var(--panel-solid); border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); animation: modal-in 240ms var(--ease-out) both;
}
.modal.xl { width: min(1240px, calc(100vw - 32px)); }
.modal.lg { width: min(880px, calc(100vw - 32px)); }
.modal.sm { width: min(400px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: var(--fs-md); font-weight: 600; flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
@keyframes modal-in { from { opacity: 0; transform: translate(-50%, -48.5%) scale(.98); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- command palette ---------- */
.cmdk-root { position: fixed; inset: 0; z-index: var(--z-palette); display: none; }
.cmdk-root.open { display: block; }
.cmdk-root .modal-backdrop { background: rgba(var(--shadow-rgb), .5); }
.cmdk {
  position: absolute; left: 50%; top: 12vh; transform: translateX(-50%); width: min(620px, calc(100vw - 32px));
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  overflow: hidden; animation: cmdk-in 200ms var(--ease-out) both;
}
@keyframes cmdk-in { from { opacity: 0; transform: translate(-50%, -6px) scale(.985); } to { opacity: 1; transform: translateX(-50%); } }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.cmdk-input svg { width: 16px; height: 16px; color: var(--text-3); }
.cmdk-input input { flex: 1; height: 48px; background: transparent; border: 0; outline: none; font-size: var(--fs-md); color: var(--text); }
.cmdk-input input::placeholder { color: var(--text-3); }
.cmdk-input kbd { padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: var(--r-xs); color: var(--text-3); }
.cmdk-list { max-height: 50vh; overflow: auto; padding: 6px; }
.cmdk-group { padding: 10px 10px 4px; font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-3); }
.cmdk-item { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); }
.cmdk-item svg { width: 15px; height: 15px; flex: none; opacity: .8; }
.cmdk-item .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.cmdk-item .lbl mark { background: transparent; color: var(--accent-text); font-weight: 600; }
.cmdk-item .lbl .sym { font-family: var(--font-mono); font-weight: 600; margin-right: 8px; }
.cmdk-item .lbl .nm { color: var(--text-2); }
.cmdk-item .hint { font-size: var(--fs-xs); color: var(--text-3); font-family: var(--font-mono); }
.cmdk-item.active { background: var(--hover-strong); box-shadow: inset 2px 0 0 var(--accent); }
.cmdk-item .px { font-family: var(--font-mono); font-size: var(--fs-xs); }
.cmdk-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.cmdk-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-3); }
.cmdk-foot kbd { padding: 1px 5px; border: 1px solid var(--border-strong); border-radius: var(--r-xs); margin-right: 4px; }

/* ---------- context menu ---------- */
.ctx-menu { position: fixed; z-index: var(--z-menu); min-width: 200px; padding: 5px; border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); animation: ctx-in var(--dur-fast) var(--ease-out) both; transform-origin: top left; }
@keyframes ctx-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.ctx-menu .item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-2); text-align: left; }
.ctx-menu .item:hover { background: var(--hover-strong); color: var(--text); }
.ctx-menu .item svg { width: 14px; height: 14px; }
.ctx-menu .sep { height: 1px; margin: 4px 6px; background: var(--border); }
.ctx-menu .head { padding: 6px 10px 4px; font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; color: var(--text); }

/* ---------- chart helpers (charts.js draws on the canvas; the tooltip is HTML) ---------- */
.chart-box { position: relative; width: 100%; height: 260px; min-height: 120px; }
.chart-box canvas { width: 100%; height: 100%; }
.chart-box.sm { height: 160px; } .chart-box.lg { height: 380px; }
.af-tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 116px; padding: 7px 9px; border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop);
  font-family: var(--font-mono); font-size: 11px; line-height: 1.55; color: var(--text); white-space: nowrap;
  opacity: 0; transform: translateY(3px); transition: opacity 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.af-tooltip.show { opacity: 1; transform: none; }
.af-tooltip .t { font-family: var(--font-ui); font-variant-numeric: tabular-nums; color: var(--text-3); margin-bottom: 3px; font-size: 11px; }
.af-tooltip .s { display: flex; align-items: center; gap: 6px; }
.af-tooltip .s i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.af-tooltip .s .n { font-family: var(--font-ui); color: var(--text-2); }
.af-tooltip .s b { font-weight: 500; margin-left: auto; padding-left: 12px; }
/* opt-in rows (charts.js tipHtml / focus): the series in focus, a muted row, a footer line under the rows */
.af-tooltip .s.on .n, .af-tooltip .s.on b { color: var(--text); font-weight: 600; }
.af-tooltip .s.mute .n, .af-tooltip .s.mute b { color: var(--text-3); }
.af-tooltip .s em { font-family: var(--font-ui); font-style: normal; color: var(--text-3); padding-left: 6px; }
.af-tooltip .f { max-width: 42ch; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); font-family: var(--font-ui); line-height: 1.4; color: var(--text-2); white-space: normal; }
.af-tooltip .f + .f { margin-top: 2px; padding-top: 0; border-top: 0; color: var(--text-3); }
.spark { width: 60px; height: 18px; }

/* ---------- misc animations ---------- */
.pulse { animation: pulse 1.2s var(--ease-in-out) infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.fade-in { animation: fade-in var(--dur) var(--ease-out) both; }
.slide-in { animation: view-enter var(--dur) var(--ease-out) both; }
.new-item { animation: new-item 1.2s var(--ease-out) both; }
@keyframes new-item { 0% { background: rgba(var(--accent-rgb), .18); transform: translateY(-3px); opacity: 0; } 25% { opacity: 1; transform: none; } 100% { background: transparent; } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.count-up { transition: color var(--dur); }

/* ---------- responsive ---------- */
/* The header is the one row that cannot wrap, so every part of it has to be allowed to shrink. */
.hdr { min-width: 0; overflow: hidden; }
.hdr > * { min-width: 0; }
.brand { min-width: 0; overflow: hidden; }
.hdr-right { flex: 0 0 auto; }

@media (max-width: 1100px) {
  .clocks { display: none; }
  .brand .tag { display: none; }
}
@media (max-width: 1024px) {
  .shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .nav-item .label, .nav-item kbd, .sidebar-toggle span { display: none; }
  .nav-item, .sidebar-toggle { justify-content: center; padding: 0; }
  .brand .name, .brand .tag { display: none; }
  .brand .brand-sym { display: block; }
  .brand { min-width: 0; }
  .user-btn .uname { display: none; }
}
@media (max-width: 720px) {
  /* The session state also sits at the top of the markets table and in every summary, so the header
     keeps only what is unique to it: connection, search and the account. */
  .mkt-state { display: none; }
  .btn-cmd kbd { display: none; }
  .btn-cmd span { display: none; }
  .btn-cmd { padding: 0 9px; }
  .live .t { display: none; }
  .main { padding: var(--sp-2); }
  .statusbar { gap: var(--sp-2); padding: 0 var(--sp-2); }
  .statusbar .sources, .statusbar .ver { display: none; }
  /* 7 source chips filled a 390px bar and cut the tick count off at the edge: the chips scroll sideways inside
     the bar, the count keeps its place */
  .statusbar .src-chips { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .statusbar .src-chips::-webkit-scrollbar { display: none; }
  .statusbar .src-chips .src-chip { flex: none; }
  .statusbar .ticks { flex: none; }
  .view-head h1 { font-size: var(--fs-md); }
  .panel-body { padding: 10px; }
}
/* ---------- phone shell ---------- */
.nav-open-btn, .nav-backdrop { display: none; }
@media (max-width: 720px) {
  .shell, body.sidebar-collapsed .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "banner" "header" "ticker" "main" "footer";
  }
  .hdr { padding: 0 var(--sp-2); gap: var(--sp-2); }
  .brand { min-width: 0; }
  .nav-open-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 38px; height: 38px; margin-right: 2px; border-radius: var(--r-sm); color: var(--text);
    transition: background-color var(--dur-fast);
  }
  .nav-open-btn:active { background: var(--press); }
  .nav-open-btn svg { width: 22px; height: 22px; }
  .sidebar {
    position: fixed; z-index: var(--z-toast); top: 0; left: 0; bottom: 0; width: min(280px, 82vw);
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
    background: var(--panel-solid); border-right: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
    transform: translateX(-104%); transition: transform var(--dur-slow) var(--ease-drawer), visibility 0s linear var(--dur-slow); visibility: hidden;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform var(--dur-slow) var(--ease-drawer), visibility 0s; }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: calc(var(--z-toast) - 1); background: rgba(var(--shadow-rgb), .55); animation: fade-in var(--dur) var(--ease-out) both; }
  .nav-backdrop[hidden] { display: none; }
  /* the drawer has room for words: undo the icon-only rail of narrow desktops */
  .sidebar .nav-item .label, .sidebar .sidebar-toggle span { display: inline; }
  .sidebar .nav-item kbd { display: none; }
  .sidebar .nav-item, .sidebar .sidebar-toggle { justify-content: flex-start; padding: 0 12px; }
  .sidebar .nav-item { height: 44px; font-size: var(--fs-md); }
  .sidebar .nav-indicator { left: -10px; }
  .sidebar .sidebar-toggle span { display: none; }
  .sidebar .sidebar-toggle::after { content: "Fechar menu"; }
  .statusbar { padding-bottom: env(safe-area-inset-bottom); }
  .statusbar #priced-count { display: none; }
  /* iOS zooms the whole page into any field under 16px when it is tapped */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: 16px; }
  .modal, .modal.xl, .modal.lg, .modal.sm { max-height: calc(100dvh - 24px); width: calc(100vw - 16px); }
  .chip { min-height: 30px; }
  .tab { min-height: 38px; }
  /* the 16px rule above loses to .select.sm/.input.sm (two classes): iOS would still zoom on those */
  .select, .select.sm, .input.sm { font-size: 16px; }
  .input.sm, .select.sm { height: 34px; }
  .btn.sm { height: 32px; }
  /* a row of tabs wider than the phone scrolls inside itself instead of pushing the page sideways */
  .tabs:not(.pill) { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs:not(.pill)::-webkit-scrollbar { display: none; }
  .tabs:not(.pill) .tab { flex: none; white-space: nowrap; }
  .tabs.pill { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .badge, .panel-head .code { font-size: 11px; }
  .tbl thead th { font-size: 11px; }
}

@media (max-width: 480px) {
  .demo-banner { font-size: var(--fs-xs); }
  .toasts { left: var(--sp-2); right: var(--sp-2); }
}

/* ---------- interaction polish (shared) ---------- */
/* Panels are not buttons: they do not answer the pointer (a border that lights up under every passing cursor is
   the generic card-kit hover). Only keyboard focus inside a panel marks its edge, so the eye finds the field;
   a mouse click on a chip no longer outlines the whole panel. .lift keeps a hover for clickable card grids. */
.panel:has(:focus-visible) { border-color: var(--border-glow); }

/* Switching screens: the screen appears in 140 ms, as one piece. The block-by-block rise and stagger that used to
   play on every navigation was the fade-up-on-everything tell; a terminal changes page, it does not perform. */
.view.active { animation: fade-in var(--dur-fast) var(--ease-out); }

/* Keyboard focus on items that sit flush inside a scrolling or clipped container: the ring goes inside. */
.nav-item:focus-visible, .tabs .tab:focus-visible, .tape-item:focus-visible, .cmdk-item:focus-visible,
.tbl tbody tr:focus-visible, .user-dd a:focus-visible, .user-dd button:focus-visible, .ctx-menu .item:focus-visible { outline-offset: -2px; }
.chip:focus-visible, .btn:focus-visible { outline-offset: 1px; }

/* Hovering a row marks it in the gutter, the way a terminal cursor does, so the eye keeps its place while
   scanning a wide table of numbers. */
.tbl tbody tr.clickable { transition: background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.tbl tbody tr.clickable:hover { box-shadow: inset 2px 0 0 rgba(var(--accent-rgb), .55); }
.tbl tbody tr.selected:hover { box-shadow: inset 2px 0 0 var(--accent); }

/* Pressed feedback on the small controls, which are the ones clicked most. */
.chip:active, .tab:active, .btn-cmd:active, .toggle:active { transform: scale(.97); }
.chip, .tab { transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .tape { animation: none !important; }
  .live .dot::after { display: none; }
  .skeleton::after { animation: none !important; }
  .flash-up, tr.flash-up > td { background-color: rgba(var(--up-rgb), .2) !important; animation: none !important; }
  .flash-down, tr.flash-down > td { background-color: rgba(var(--down-rgb), .2) !important; animation: none !important; }
}

/* ---------- Leaflet: darken light raster tiles to match the terminal ---------- */
.leaflet-dark-tiles .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.8) contrast(.92) saturate(.45) sepia(.08); }
[data-theme="light"] .leaflet-dark-tiles .leaflet-tile-pane { filter: saturate(.85); }
.leaflet-container { background: var(--bg-3); font: var(--fs-xs) var(--font-ui); }
.leaflet-control-attribution { background: rgba(var(--shadow-rgb), .5) !important; color: var(--text-3) !important; font-size: 9.5px !important; }
.leaflet-control-attribution a { color: var(--text-2) !important; }
[data-theme="light"] .leaflet-control-attribution { background: rgba(255, 255, 255, .75) !important; }
.leaflet-bar { border: 1px solid var(--border-strong) !important; border-radius: var(--r-sm) !important; box-shadow: var(--shadow-sm) !important; overflow: hidden; }
.leaflet-bar a { background: var(--panel-2) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-bar a:hover { background: var(--bg-3) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel-2) !important; color: var(--text) !important; border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); }
.leaflet-popup-content-wrapper { border-radius: var(--r) !important; }
.leaflet-popup-content { margin: 10px 12px !important; font-size: var(--fs-sm); }
