/* Layout: mapa do escritório à esquerda, painel da sala à direita; empilha no celular. Visual noturno único. */
:root {
  color-scheme: dark;
  --bg: #14161f;
  --panel: #1f2231;
  --panel-2: #282c3f;
  --line: #363a52;
  --ink: #eceaf4;
  --muted: #a4a7bf;
  --accent: #f2b84b;
  --accent-ink: #2a1d05;
  --ok: #5fcf93;
  --bad: #ff8a8a;
  --info: #7cc9e6;
  --display: "Pixelify Sans", "Courier New", monospace;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45;
  padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px));
  padding-bottom: 28px;
}
button, input, select, textarea { font: inherit; color: inherit; }
h2, h3 { font-family: var(--display); font-weight: 500; margin: 0; text-wrap: balance; }

.topo { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 12px; max-width: 1320px; margin: 0 auto; }
.marca { display: flex; align-items: center; gap: 10px; }
.marca b { display: block; font-family: var(--display); font-size: 20px; font-weight: 700; line-height: 1.1; }
.marca small { color: var(--muted); font-size: 13px; }
.logo { font-family: var(--display); font-weight: 700; background: var(--accent); color: var(--accent-ink); border-radius: 4px; padding: 4px 7px; font-size: 15px; }
.topo-dir { display: flex; align-items: center; gap: 10px; }
.chip { font-size: 12px; border-radius: 99px; padding: 3px 10px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.on { border-color: var(--ok); color: var(--ok); }
.chip.warn { border-color: var(--accent); color: var(--accent); }

.app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 480px); gap: 16px; align-items: start; max-width: 1320px; margin: 0 auto; }
@media (max-width: 1000px) { .app { grid-template-columns: minmax(0, 1fr); } }

.palco { display: flex; flex-direction: column; gap: 10px; min-width: 0; position: sticky; top: 10px; }
@media (max-width: 1000px) { .palco { position: static; } }
.tela { position: relative; width: 100%; aspect-ratio: 416 / 240; max-width: 100%; border: 3px solid #0b0c12; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
#escritorio { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; cursor: pointer; outline: none; }
#escritorio:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }
.placa, .tag-agente { position: absolute; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap; }
.placa { font-family: var(--display); font-size: clamp(8px, 1.15vw, 12px); background: rgba(14, 15, 23, .82); color: #fff; padding: 1px 6px 2px; border-radius: 3px; }
.placa.patio { background: var(--accent); color: var(--accent-ink); white-space: pre; text-align: center; line-height: 1.15; font-size: clamp(7px, 1vw, 11px); }
.tag-agente { transform: translate(-50%, -100%); font-size: clamp(7.5px, 1vw, 11px); background: rgba(14, 15, 23, .7); color: #dfe1ee; padding: 0 5px 1px; border-radius: 3px; }
.atalhos { display: flex; flex-wrap: wrap; gap: 6px; }
.atalhos button { all: unset; cursor: pointer; font-size: 13px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); }
.atalhos button:hover, .atalhos button:focus-visible { border-color: var(--accent); }
.atalhos button[aria-current="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.atalhos .n { margin-left: 6px; font-size: 11px; background: var(--bad); color: #2a0b0b; border-radius: 99px; padding: 0 6px; }
.dica { margin: 0; color: var(--muted); font-size: 13px; }

.painel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-width: 0; min-height: 520px; display: flex; flex-direction: column; }
.p-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.p-head img { width: 44px; height: 44px; image-rendering: pixelated; background: #2f3349; border-radius: 6px; }
.p-head h2 { font-size: 19px; line-height: 1.1; }
.p-head small { color: var(--muted); font-size: 13px; }
.p-body { padding: 14px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fala { background: var(--panel-2); border-radius: 10px; border-top-left-radius: 2px; padding: 9px 12px; font-size: 14.5px; }
.fala b { font-family: var(--display); font-weight: 500; }
.secao { display: flex; flex-direction: column; gap: 10px; }
.secao > h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.linha { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 140px; }
.campo label, .rot { font-size: 12.5px; color: var(--muted); }
input[type="text"], input[type="date"], input[type="month"], input[type="number"], input[type="search"], select, textarea {
  background: #171a26; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 70px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 13px; border-radius: 6px; font-weight: 700; font-size: 14px; background: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(1.07); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn.sec { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
.btn.sec:hover { border-color: var(--accent); }
.btn.perigo { background: transparent; color: var(--bad); border: 1px solid rgba(255, 138, 138, .4); font-weight: 400; }
.btn[disabled] { opacity: .5; cursor: default; filter: none; }
.btn-link { all: unset; cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 8px; border-radius: 4px; }
.btn-link:hover, .btn-link:focus-visible { color: var(--ink); background: var(--panel-2); }
.x { all: unset; cursor: pointer; color: var(--muted); padding: 2px 7px; border-radius: 4px; }
.x:hover, .x:focus-visible { color: var(--bad); background: rgba(255, 138, 138, .1); }

.tabela-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 400; font-size: 12px; background: #1a1d2a; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; background: #1a1d2a; }
.conf td { padding: 4px; }
.conf input, .conf select { padding: 5px 6px; font-size: 13px; }
.conf tr.duvida td { background: rgba(242, 184, 75, .1); }
.conf tr.duvida td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kpi { background: var(--panel-2); border-radius: 6px; padding: 8px 10px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi b { display: block; font-family: var(--display); font-weight: 500; font-size: 19px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.formas { display: flex; flex-wrap: wrap; gap: 6px; }
.formas span { font-size: 12.5px; background: var(--panel-2); border-radius: 99px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
.formas b { font-weight: 700; }

.pill { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; display: inline-block; }
.pill.ok { background: rgba(95, 207, 147, .14); color: var(--ok); }
.pill.warn { background: rgba(242, 184, 75, .16); color: var(--accent); }
.pill.bad { background: rgba(255, 138, 138, .14); color: var(--bad); }
.pill.info { background: rgba(124, 201, 230, .14); color: var(--info); }

.card { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; background: #1b1e2c; }
.card .topo-card { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.card p { margin: 0; font-size: 13.5px; color: #d6d8e6; }
.card .acoes { display: flex; flex-wrap: wrap; gap: 6px; }
.vazio { color: var(--muted); font-size: 14px; border: 1px dashed var(--line); border-radius: 6px; padding: 12px; }
.aviso { font-size: 13px; color: var(--accent); background: rgba(242, 184, 75, .08); border-radius: 6px; padding: 8px 10px; }
.aviso ul { margin: 4px 0 0; padding-left: 18px; }
.total-linha { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.total-linha b { font-family: var(--display); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }

.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.abas button { all: unset; cursor: pointer; padding: 7px 12px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.abas button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.abas button:focus-visible { outline: 2px solid var(--accent); }

.salas-home { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 460px) { .salas-home { grid-template-columns: minmax(0, 1fr); } }
.sala-btn { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; align-items: center; padding: 8px 10px; border-radius: 6px; background: var(--panel-2); border: 1px solid transparent; }
.sala-btn:hover, .sala-btn:focus-visible { border-color: var(--accent); }
.sala-btn img { width: 34px; height: 34px; image-rendering: pixelated; background: #2f3349; border-radius: 4px; }
.sala-btn b { display: block; font-size: 14px; }
.sala-btn small { display: block; color: var(--muted); font-size: 12px; }

.grafico svg { width: 100%; height: auto; display: block; }
.barras { display: flex; flex-direction: column; gap: 6px; }
.barra { display: grid; grid-template-columns: 110px minmax(0, 1fr) 96px; gap: 8px; align-items: center; font-size: 13px; }
.barra .trilho { height: 10px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.barra .trilho i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.barra .num { text-align: right; font-variant-numeric: tabular-nums; }
.resposta { white-space: pre-wrap; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.lavs { display: flex; flex-wrap: wrap; gap: 6px 14px; }

#toast { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #0e0f17; border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
#toast.erro { border-color: var(--bad); color: var(--bad); }
#toast.ok { border-color: var(--ok); }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
