/* Rompimentos — tokens de tema, base e controles compartilhados (painel e telas de acesso).
   Regra: componentes só usam as variáveis abaixo. Cor de status (crítico/atenção/ok) é reservada
   para status; o acento é para navegação, foco e ações. */

*, *::before, *::after { box-sizing: border-box; }

/* ===================== Temas ===================== */
/* Azul operacional (padrão) */
:root,
:root[data-theme="neon"] {
    color-scheme: dark;
    --bg: #0a1220;
    --bg-elev: #0c1628;
    --surface: #101b2e;
    --surface-2: #142238;
    --surface-hover: #182a45;
    --input-bg: #0b1526;
    --border: rgba(148, 180, 220, .13);
    --border-strong: rgba(148, 180, 220, .24);
    --text: #e6edf7;
    --text-2: #a8b7cc;
    --text-3: #7c8ba2;
    --accent: #5cb6ff;
    --accent-soft: rgba(92, 182, 255, .13);
    --primary: #1f6fe0;
    --primary-hover: #2a7cf0;
    --on-primary: #ffffff;
    --crit: #ff5d6c;
    --crit-soft: rgba(255, 93, 108, .14);
    --warn: #f5a524;
    --warn-soft: rgba(245, 165, 36, .14);
    --ok: #2fcf8a;
    --ok-soft: rgba(47, 207, 138, .13);
    --focus: rgba(92, 182, 255, .55);
    --backdrop: rgba(3, 8, 16, .66);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .18);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .45);
    --logo-tile: #f3f6fa;
}

/* Oceano */
:root[data-theme="ocean"] {
    color-scheme: dark;
    --bg: #071417;
    --bg-elev: #09191d;
    --surface: #0d2126;
    --surface-2: #11292f;
    --surface-hover: #153239;
    --input-bg: #081a1e;
    --border: rgba(125, 211, 222, .13);
    --border-strong: rgba(125, 211, 222, .24);
    --text: #e2f3f5;
    --text-2: #a2c3c8;
    --text-3: #72939a;
    --accent: #3fd5e8;
    --accent-soft: rgba(63, 213, 232, .13);
    --primary: #0b8aa1;
    --primary-hover: #0f9cb5;
    --on-primary: #ffffff;
    --crit: #ff6070;
    --crit-soft: rgba(255, 96, 112, .15);
    --warn: #f7b23b;
    --warn-soft: rgba(247, 178, 59, .14);
    --ok: #34d399;
    --ok-soft: rgba(52, 211, 153, .13);
    --focus: rgba(63, 213, 232, .55);
    --backdrop: rgba(2, 10, 12, .68);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .2);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .48);
    --logo-tile: #f1f7f8;
}

/* Carmesim */
:root[data-theme="crimson"] {
    color-scheme: dark;
    --bg: #140a0e;
    --bg-elev: #190c11;
    --surface: #211118;
    --surface-2: #29161e;
    --surface-hover: #331b25;
    --input-bg: #170b10;
    --border: rgba(244, 170, 190, .13);
    --border-strong: rgba(244, 170, 190, .24);
    --text: #f6e9ed;
    --text-2: #cfb0b9;
    --text-3: #a2848d;
    --accent: #f78fb3;
    --accent-soft: rgba(247, 143, 179, .14);
    --primary: #c2185b;
    --primary-hover: #d81b65;
    --on-primary: #ffffff;
    --crit: #ff5a4f;
    --crit-soft: rgba(255, 90, 79, .16);
    --warn: #f5b041;
    --warn-soft: rgba(245, 176, 65, .14);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, .13);
    --focus: rgba(247, 143, 179, .55);
    --backdrop: rgba(12, 3, 6, .7);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .5);
    --logo-tile: #faf3f5;
}

/* Claro */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f5f9;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --surface-hover: #eef2f8;
    --input-bg: #ffffff;
    --border: rgba(15, 23, 42, .1);
    --border-strong: rgba(15, 23, 42, .2);
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #64748b;
    --accent: #1d64d8;
    --accent-soft: rgba(29, 100, 216, .1);
    --primary: #1d64d8;
    --primary-hover: #1857c0;
    --on-primary: #ffffff;
    --crit: #d42a3c;
    --crit-soft: #fde8ea;
    --warn: #b45309;
    --warn-soft: #fef3e2;
    --ok: #15803d;
    --ok-soft: #e6f6ec;
    --focus: rgba(29, 100, 216, .45);
    --backdrop: rgba(15, 23, 42, .4);
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 18px rgba(15, 23, 42, .06);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, .18);
    --logo-tile: #f3f5f9;
}

/* Preto e branco (alto contraste): status por texto e borda, não por cor */
:root[data-theme="bw"] {
    color-scheme: light;
    --bg: #ffffff;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --surface-hover: #ececec;
    --input-bg: #ffffff;
    --border: #000000;
    --border-strong: #000000;
    --text: #000000;
    --text-2: #111111;
    --text-3: #333333;
    --accent: #000000;
    --accent-soft: #e6e6e6;
    --primary: #000000;
    --primary-hover: #222222;
    --on-primary: #ffffff;
    --crit: #000000;
    --crit-soft: #ffffff;
    --warn: #000000;
    --warn-soft: #ffffff;
    --ok: #000000;
    --ok-soft: #ffffff;
    --focus: rgba(0, 0, 0, .6);
    --backdrop: rgba(0, 0, 0, .45);
    --shadow: none;
    --shadow-lg: 0 12px 30px rgba(0, 0, 0, .25);
    --logo-tile: #ffffff;
}

/* ===================== Base ===================== */
:root {
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --r-sm: 6px;
    --r: 8px;
    --r-lg: 12px;
    --ctl-h: 38px;
}

html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; color: var(--text); letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
input, select, button, textarea { font: inherit; color: inherit; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ===================== Botões ===================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--ctl-h);
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--surface-hover); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: transparent; color: var(--on-primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { background: var(--crit); border-color: transparent; color: #ffffff; }
.btn.danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.block { width: 100%; }
:root[data-theme="bw"] .btn.danger { background: #000000; }
.miniBtn { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.linkBtn {
    padding: 0; border: 0; background: none;
    color: var(--accent); font-weight: 600; cursor: pointer;
    text-decoration: underline; text-underline-offset: 2px;
}
.iconbtn {
    display: inline-grid; place-items: center;
    width: var(--ctl-h); height: var(--ctl-h); flex: none;
    border: 1px solid transparent; border-radius: var(--r);
    background: transparent; color: var(--text-2);
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}
.iconbtn:hover { background: var(--surface-hover); color: var(--text); }
.iconbtn svg { width: 18px; height: 18px; }

/* ===================== Campos ===================== */
.input,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select, .field textarea {
    width: 100%;
    min-height: var(--ctl-h);
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--input-bg);
    color: var(--text);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); flex: none; }
input[type="file"] { font-size: 13px; color: var(--text-2); }
input[type="file"]::file-selector-button {
    margin-right: 10px; padding: 7px 12px;
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
select { cursor: pointer; }
textarea { resize: vertical; }
:root:not([data-theme="light"]):not([data-theme="bw"]) input[type="date"]::-webkit-calendar-picker-indicator,
:root:not([data-theme="light"]):not([data-theme="bw"]) input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(.8); }

/* ===================== Pílulas / status ===================== */
.dot { width: 8px; height: 8px; border-radius: 999px; background: var(--text-3); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }
.dot.wait { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

/* Respeitar quem pediu menos movimento */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
