/* ui.css - folha unica das telas do app (Inicio, Dashboards, Overlay, Editor).
   REGRA: nenhuma cor literal aqui. Todas as cores vem dos tokens gravados em :root por theme.js
   (derivados das 4 cores-base). Espacamento em multiplos de 4px, escalados pela densidade. */

:root {
  --d: 1;                                   /* densidade: 1 confortavel, .75 compacta */
  --sp-1: calc(4px * var(--d)); --sp-2: calc(8px * var(--d)); --sp-3: calc(12px * var(--d));
  --sp-4: calc(16px * var(--d)); --sp-5: calc(24px * var(--d)); --sp-6: calc(32px * var(--d));
  --r-1: 6px; --r-2: 10px; --r-pill: 999px;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 28px; --fs-hero: 56px;
  --font: system-ui, "Segoe UI", Roboto, sans-serif;
  --ctl-h: calc(36px * var(--d) + 0px);     /* altura dos controles */
}
:root[data-density="compact"] { --d: .75; --fs-md: 13px; --fs-hero: 44px; }

* { box-sizing: border-box; }
html { color-scheme: dark; } :root[data-scheme="light"] { color-scheme: light; }
body.app { margin: 0; font: var(--fs-md)/1.45 var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
.app h1, .app h2, .app h3, .app p { margin: 0; }
.app :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-1); }
.app a { color: var(--primary-text); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- icones (sprite /icons.svg) ---------- */
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.ic.sm { width: 14px; height: 14px; } .ic.lg { width: 28px; height: 28px; } .ic.fill { fill: currentColor; stroke: none; }

/* ---------- barra superior / navegacao ---------- */
.topbar { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-2) var(--sp-4); background: var(--surface-1); border-bottom: 1px solid var(--border); flex-wrap: wrap; position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-lg); font-weight: 700; min-width: 0; }
.brand img { width: 24px; height: 24px; border-radius: 5px; } .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.nav { display: flex; gap: var(--sp-1); flex: 1; }
.app .nav a { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-1); color: var(--text-muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; }
.app .nav a:hover { color: var(--text); background: var(--surface-2); }
.app .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); border-bottom-color: var(--primary); border-radius: var(--r-1) var(--r-1) 0 0; }
.topbar .right { display: flex; align-items: center; gap: var(--sp-3); margin-left: auto; }

/* ---------- botoes ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--ctl-h); padding: 0 var(--sp-4); border-radius: var(--r-1); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: 600 var(--fs-md) var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.app a.btn { color: var(--text); }
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:disabled, .btn[aria-disabled="true"] { color: var(--text-disabled); border-color: var(--border); cursor: not-allowed; }
.btn.primary, .app a.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:disabled { background: var(--surface-2); border-color: var(--border); color: var(--text-disabled); }
.btn.danger { background: var(--err); border-color: var(--err); color: var(--on-err); }
.btn.danger:hover:not(:disabled) { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.icon { padding: 0; width: var(--ctl-h); }
.btn.sm { min-height: calc(28px * var(--d)); padding: 0 var(--sp-2); font-size: var(--fs-sm); } .btn.icon.sm { width: calc(28px * var(--d)); }
.btn[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }
.btn-group { display: inline-flex; gap: var(--sp-1); align-items: center; }
.sep { width: 1px; align-self: stretch; min-height: 20px; background: var(--border); margin: 0 var(--sp-1); }

/* ---------- campos ---------- */
.app input[type="text"], .app input[type="number"], .app input[type="search"], .app select, .input { min-height: calc(32px * var(--d)); padding: 0 var(--sp-2); border-radius: var(--r-1); border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text); font: inherit; min-width: 0; }
.app input:disabled, .app select:disabled { color: var(--text-disabled); border-color: var(--border); }
.app input[type="color"] { padding: 0; width: 36px; height: calc(32px * var(--d)); border: 1px solid var(--border-strong); border-radius: var(--r-1); background: var(--surface-1); cursor: pointer; }
.app input[type="range"] { accent-color: var(--primary); }
.app input[type="checkbox"], .app input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; }
.field { display: grid; grid-template-columns: minmax(90px, 40%) 1fr; gap: var(--sp-2); align-items: center; margin: var(--sp-1) 0; }
.field > label { color: var(--text-muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.field input[type="checkbox"] { justify-self: start; } .field input:not([type="checkbox"]):not([type="color"]), .field select { width: 100%; }

/* interruptor (checkbox com papel de switch) */
.switch { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-weight: 600; }
.app .switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; margin: 0; flex: none; }
.app .switch input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted); transition: transform .12s; }
.app .switch input:checked { background: var(--ok); border-color: var(--ok); }
.app .switch input:checked::after { transform: translateX(16px); background: var(--on-ok); }
.switch input:disabled { cursor: not-allowed; opacity: .5; }

/* ---------- selo de estado: sempre icone + texto (nao depende so da cor) ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--sp-1); padding: 2px var(--sp-3); border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); border-color: var(--ok); } .badge.ok .ic { color: var(--ok); }
.badge.warn { background: var(--warn-soft); border-color: var(--warn); } .badge.warn .ic { color: var(--warn); }
.badge.err { background: var(--err-soft); border-color: var(--err); } .badge.err .ic { color: var(--err); }
.badge.info { background: var(--info-soft); border-color: var(--info); } .badge.info .ic { color: var(--info); }

/* ---------- avisos em linha ---------- */
.note { display: flex; align-items: flex-start; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-1); border: 1px solid var(--border); background: var(--surface-1); }
.note.warn { border-color: var(--warn); background: var(--warn-soft); } .note.warn .ic { color: var(--warn); }
.note.err { border-color: var(--err); background: var(--err-soft); } .note.err .ic { color: var(--err); }
.note.ok { border-color: var(--ok); background: var(--ok-soft); } .note.ok .ic { color: var(--ok); }
.note:empty { display: none; }

/* ---------- painel / cartao ---------- */
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-2); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel > header { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); min-height: calc(34px * var(--d)); }
.panel > header h2 { font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel > .body { padding: var(--sp-3); flex: 1; min-height: 0; overflow: auto; }
.page { max-width: 980px; margin: 0 auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.page-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; } .page-head h1 { font-size: var(--fs-xl); flex: 1; }

/* ---------- listas (dashboards / overlays) ---------- */
.item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-2); padding: var(--sp-3) var(--sp-4); }
.item.on { border-color: var(--ok); }
.item .name { flex: 1 1 200px; min-width: 0; } .item .name b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-lg); }
.item .name span { font-size: var(--fs-xs); color: var(--text-muted); }
.list { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ---------- estados: vazio / carregando ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--text-muted); border: 1px dashed var(--border-strong); border-radius: var(--r-2); }
.empty b { color: var(--text); font-size: var(--fs-lg); }
.skeleton { height: 58px; border-radius: var(--r-2); background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-2) 50%, var(--surface-1) 75%); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .app * { transition: none !important; } }

/* ---------- modal / gaveta / menu / toast ---------- */
.modal { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 100; padding: var(--sp-4); }
.modal .box { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-2); padding: var(--sp-5); max-width: 480px; width: 100%; box-shadow: var(--shadow-2); }
.modal h3 { font-size: var(--fs-lg); margin-bottom: var(--sp-2); } .modal p { color: var(--text-muted); margin-bottom: var(--sp-5); overflow-wrap: anywhere; }
.modal .btns { display: flex; gap: var(--sp-2); justify-content: flex-end; flex-wrap: wrap; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); background: var(--surface-1); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-2); z-index: 90; display: flex; flex-direction: column; }
.drawer > header { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); } .drawer > header h2 { flex: 1; font-size: var(--fs-lg); }
.drawer > .body { padding: var(--sp-4); overflow: auto; display: flex; flex-direction: column; gap: var(--sp-4); }
.menu { position: absolute; z-index: 80; min-width: 190px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-1); box-shadow: var(--shadow-2); padding: var(--sp-1); display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; border-radius: var(--r-1); cursor: pointer; }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--surface-3); } .menu button:disabled { color: var(--text-disabled); cursor: not-allowed; }
.menu button.danger { color: var(--err); } .menu hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-1) 0; width: 100%; }
.toasts { position: fixed; bottom: var(--sp-4); left: 50%; transform: translateX(-50%); z-index: 110; display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-1); background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2); pointer-events: auto; overflow-wrap: anywhere; }
.toast.ok { border-color: var(--ok); } .toast.ok .ic { color: var(--ok); }
.toast.err { border-color: var(--err); } .toast.err .ic { color: var(--err); }
.toast.warn { border-color: var(--warn); } .toast.warn .ic { color: var(--warn); }

/* ---------- abas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tabs button { padding: var(--sp-2) var(--sp-3); border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-muted); font: 600 var(--fs-sm) var(--font); cursor: pointer; }
.tabs button:hover { color: var(--text); } .tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }

/* ---------- medidor (barra com rotulo e valor) ---------- */
.meter { display: grid; grid-template-columns: 112px 1fr 52px; gap: var(--sp-2); align-items: center; margin: var(--sp-1) 0; }
.meter .track { height: 10px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.meter .track i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: var(--r-pill); }
.meter.thr .track i { background: var(--ok); } .meter.brk .track i { background: var(--err); } .meter.acc .track i { background: var(--accent); }
.meter .val { text-align: right; font-variant-numeric: tabular-nums; } .meter .lab { color: var(--text-muted); font-size: var(--fs-sm); }

/* ---------- tabelas ---------- */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: var(--sp-1) var(--sp-2); text-align: left; white-space: nowrap; }
.tbl th { color: var(--text-muted); font-weight: 600; font-size: var(--fs-xs); position: sticky; top: 0; background: var(--surface-1); }
.tbl tbody tr { border-top: 1px solid var(--border); }
.tbl tr.me td { color: var(--accent-text); font-weight: 700; } .tbl tr.me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- teclas de atalho ---------- */
kbd { display: inline-block; padding: 0 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); font: 600 var(--fs-xs) var(--font); }

/* ---------- aba Overlay: cartao de estado ---------- */
.ov-card { display: flex; flex-direction: column; gap: var(--sp-3); }
.ov-line { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; } .ov-line #ovState { flex: 1 1 260px; }
.ov-keys { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--fs-sm); } .ov-key { display: inline-flex; align-items: center; gap: var(--sp-1); }

/* ---------- Inicio: barra de modos, replay, avisos ---------- */
.modebar, .layoutbar, .editbar, .hiddenbar, .alerts, .nodata { margin: var(--sp-3) var(--sp-4) 0; }
.modebar, .layoutbar, .editbar, .hiddenbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.seg { display: inline-flex; } .seg .btn { border-radius: 0; margin-left: -1px; } .seg .btn:first-child { border-radius: var(--r-1) 0 0 var(--r-1); margin-left: 0; } .seg .btn:last-child { border-radius: 0 var(--r-1) var(--r-1) 0; }
.seg .btn[aria-pressed="true"] { position: relative; z-index: 1; }
.btn.rec .ic { color: var(--err); }
.btn.rec.on { background: var(--err); border-color: var(--err); color: var(--on-err); } .btn.rec.on .ic { color: inherit; animation: blink 1s steps(2, start) infinite; }
.btn.rec[aria-disabled="true"] .ic { color: var(--text-disabled); }
@keyframes blink { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .btn.rec.on .ic { animation: none; } }
.alerts { display: flex; flex-direction: column; gap: var(--sp-2); } .alerts:not(:has(.note:not(:empty))) { margin-top: 0; }
.replay { margin: var(--sp-3) var(--sp-4) 0; }
.replay .line { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; } .replay .line + .line { margin-top: var(--sp-3); }
.replay #logSel { min-width: 260px; max-width: 100%; flex: 0 1 420px; } .replay #seek { flex: 1; min-width: 180px; } .replay #timeText { min-width: 110px; }
.replay #replayName.seeking { color: var(--text-muted); }
.grow { flex: 1; }
.editbar { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--primary); background: var(--primary-soft); border-radius: var(--r-2); position: sticky; top: 52px; z-index: 20; }
.editbar .ic { color: var(--primary-text); }
.nodata .empty { padding: var(--sp-4); }

/* ---------- Inicio: grade de paineis ---------- */
.grid { --cols: 12; --row-h: calc(40px * var(--d)); display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-auto-rows: var(--row-h); gap: var(--sp-3); padding: var(--sp-3) var(--sp-4) var(--sp-5); position: relative; }
.grid .panel { position: relative; overflow: hidden; }
.grid .panel > .body.flush { padding: 0; } .grid .panel > .body.chart { display: flex; flex-direction: column; gap: var(--sp-2); overflow: hidden; }
.panel-tools { display: none; gap: 2px; }
.rz { display: none; position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; color: var(--text-muted); touch-action: none; }
.rz .ic { width: 16px; height: 16px; position: absolute; right: 3px; bottom: 3px; }
body.editing .panel-tools { display: inline-flex; } body.editing .rz { display: block; }
body.editing .grid .panel { border-style: dashed; border-color: var(--border-strong); }
body.editing .grid .panel > header { cursor: grab; touch-action: none; background: var(--surface-2); }
body.editing .grid .panel.drag { border-color: var(--primary); box-shadow: var(--shadow-2); z-index: 5; } body.editing .grid .panel.drag > header { cursor: grabbing; }
body.editing .grid .panel > .body { pointer-events: none; }

/* conteudo dos paineis */
.hero { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.big { font-size: var(--fs-hero); font-weight: 700; line-height: 1; } .hero .unit { font-size: var(--fs-lg); }
.gearbox { margin-left: auto; display: inline-flex; align-items: baseline; gap: var(--sp-2); } .gearbox .big { color: var(--accent-text); min-width: 1ch; text-align: right; }
.kv { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-1) 0; border-bottom: 1px solid var(--border); } .kv:last-child { border-bottom: 0; }
.kv > span { color: var(--text-muted); } .kv > b { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter.steer .track { position: relative; } .meter.steer .track i { position: absolute; top: 0; width: 6px; margin-left: -3px; left: 50%; background: var(--text); }
.meter.steer .track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border-strong); }

/* graficos */
.legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: var(--sp-1); }
.sw { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--chart-1); } .sw.thick { border-top-width: 3px; } .sw.dash { border-top-style: dashed; }
.sw.c1 { border-top-color: var(--chart-1); } .sw.c3 { border-top-color: var(--chart-3); } .sw.c5 { border-top-color: var(--chart-5); } .sw.c6 { border-top-color: var(--chart-6); }
.plot { position: relative; flex: 1; min-height: 0; } .plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tip { position: absolute; top: 2px; padding: 2px var(--sp-2); border-radius: var(--r-1); background: var(--surface-3); border: 1px solid var(--border-strong); font-size: var(--fs-xs); white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums; }
.plot-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: var(--sp-4); }

/* ---------- painel Aparencia ---------- */
.ap { display: flex; flex-direction: column; gap: var(--sp-5); } .ap section { display: flex; flex-direction: column; gap: var(--sp-2); }
.ap h3 { font-size: var(--fs-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.ap-themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.ap-theme { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); padding: var(--sp-2); border-radius: var(--r-1); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: 600 var(--fs-sm) var(--font); cursor: pointer; position: relative; }
.ap-theme[aria-checked="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); } .ap-theme .ic { position: absolute; top: 4px; right: 4px; color: var(--primary-text); }
.ap-sample { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; height: 34px; border-radius: 4px; border: 1px solid transparent; } .ap-sample i { width: 12px; height: 12px; border-radius: 50%; }
.ap-color { display: grid; grid-template-columns: 36px 1fr 92px; gap: var(--sp-3); align-items: center; } .ap-color label { font-weight: 600; display: block; } .ap-color small { display: block; font-size: var(--fs-xs); }
.ap-check { display: grid; grid-template-columns: 16px 1fr auto auto; gap: var(--sp-2); align-items: center; } .ap-check .ic { color: var(--text-muted); }
.ap-preview { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-1); background: var(--bg); } .ap-preview p { flex-basis: 100%; }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.ap-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; position: sticky; bottom: calc(-1 * var(--sp-4)); background: var(--surface-1); padding: var(--sp-3) 0; border-top: 1px solid var(--border); }

/* ---------- aba Analise ---------- */
.an-page { padding: var(--sp-3) var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.an-page > .panel > header { flex-wrap: wrap; } .an-lab { margin-left: var(--sp-3); font-size: var(--fs-sm); }
.an-drivers { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-1) var(--sp-3); }
.an-drv { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) var(--sp-2); border-radius: var(--r-1); border: 1px solid transparent; cursor: pointer; min-width: 0; }
.an-drv span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.an-drv:hover { background: var(--surface-2); } .an-drv.on { background: var(--primary-soft); border-color: var(--primary); }
.an-drv.me span { color: var(--accent-text); font-weight: 700; }
.an-drv:has(input:disabled) { cursor: not-allowed; } .an-drv:has(input:disabled) span { color: var(--text-disabled); }
.an-hint { font-size: var(--fs-xs); margin-top: var(--sp-2); } #selWarn:not(:empty) { margin-bottom: var(--sp-2); }
.an-legend { padding: 0 var(--sp-1); } .an-charts { display: flex; flex-direction: column; gap: var(--sp-3); }
.an-chart > .body.chart { flex: none; height: calc(196px * var(--d)); display: flex; flex-direction: column; padding: var(--sp-2) var(--sp-3); }
.an-chart > header h2 { text-transform: none; letter-spacing: 0; font-size: var(--fs-md); color: var(--text); }
/* Analise, modo Log: barra de modo, log/sessao, reproducao, nome + tempo na lista e no grafico */
.an-bar, .an-line, .an-player { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.an-line + .an-line, .an-line + .note:not(:empty) { margin-top: var(--sp-2); } .an-line select { min-width: 0; max-width: 100%; }
#logFile { flex: 1 1 320px; } #sessSel { flex: 1 1 320px; }
.an-player { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-2); background: var(--surface-1); }
.an-player input[type="range"] { flex: 1 1 200px; min-width: 120px; }
.an-drv .an-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.an-drv .an-time { font-size: var(--fs-xs); color: var(--text-muted); }
.an-drv[data-nolap="1"] .an-time { font-style: italic; }
/* exibicao: 2 pilotos lado a lado (metade da tela cada) ou 4 em 2 x 2; telas estreitas voltam a empilhar */
.an-lay { display: inline-flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.an-charts.split2, .an-charts.grid4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.an-charts.split2 > .empty, .an-charts.grid4 > .empty { grid-column: 1 / -1; }
@media (max-width: 899px) { .an-charts.split2, .an-charts.grid4 { grid-template-columns: minmax(0, 1fr); } }
.an-drv .an-l2 { display: flex; gap: var(--sp-2); align-items: baseline; min-width: 0; }
.an-drv .an-ref { font-size: var(--fs-xs); font-weight: 700; color: var(--primary-text); flex: none; }
.an-chart > header { align-items: flex-start; } .an-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.an-sub { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-muted); }
.an-best { color: var(--text); font-weight: 700; } .an-delta { font-weight: 700; } .an-delta.slower { color: var(--err); } .an-delta.faster { color: var(--ok); }
