/* Base das páginas com tema claro/escuro (monitor e cadastro). */
:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #1b1f24; --muted: #6a7380; --line: #e2e5ea;
  --ok: #12805c; --warn: #b26a00; --bad: #c0392b; --accent: #1f6feb; --code: #f0f2f5;
  --okbg: #dcfce7; --badbg: #fee2e2; --infobg: #e0f2fe; --on-accent: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --card: #171b21; --text: #e6e9ee; --muted: #8b95a3; --line: #2a303a;
    --ok: #3ccf9a; --warn: #e0a030; --bad: #ff7a6b; --accent: #6aa5ff; --code: #1e242c;
    --okbg: #12301f; --badbg: #3a1a17; --infobg: #13283a; --on-accent: #0b1220;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --card: #171b21; --text: #e6e9ee; --muted: #8b95a3; --line: #2a303a;
  --ok: #3ccf9a; --warn: #e0a030; --bad: #ff7a6b; --accent: #6aa5ff; --code: #1e242c;
  --okbg: #12301f; --badbg: #3a1a17; --infobg: #13283a; --on-accent: #0b1220;
}
/* controles nativos (checkbox, rolagem) seguem o tema escolhido, não só o do sistema */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.muted { color: var(--muted); }
a { color: var(--accent); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
.banner { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; background: var(--code); border: 1px solid var(--line); }

/* utilitários (substituem estilos que estavam inline no HTML) */
.mt-8 { margin-top: 8px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.m-0 { margin: 0; }
.between { justify-content: space-between; }
.small { font-size: 12px; }
.mt-14 { margin-top: 14px; }
.ml-auto { margin-left: auto; }
.overflow-auto { overflow: auto; }
.upper { text-transform: uppercase; }


/* ---- botões: estados consistentes em todas as páginas ---- */
button, .btn {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .06s;
}
button:hover:not(:disabled), .btn:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, var(--card));
}
button:active:not(:disabled), .btn:active:not(:disabled) { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled), .btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, #000); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--code); border-color: var(--line); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* indicador de carregando dentro de um botão: <span class="spinner"></span> + classe .loading */
.spinner {
  display: none; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.who { color: var(--muted); font-size: 13px; }
.who:empty { display: none; }

select {
  font: inherit; color: var(--text); background-color: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  max-width: 100%;
}
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent); width: 18px; height: 18px; padding: 0; margin: 0;
  flex: none; vertical-align: middle; cursor: pointer;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}

::placeholder { color: var(--muted); opacity: .75; }

/* itens só para administradores (common.js põe .is-admin no <html>) */
.admin-only { display: none !important; }
.is-admin .admin-only { display: inline-block !important; }

/* medidor de bateria/sinal em barrinhas (GT06.batteryMeter / gsmMeter) */
.meter { display: inline-flex; gap: 2px; align-items: flex-end; vertical-align: middle; margin-right: 6px; }
.meter i { width: 6px; height: 12px; border-radius: 2px; background: var(--line); }
.meter.ok i.on { background: var(--ok); }
.meter.warn i.on { background: var(--warn); }
.meter.bad i.on { background: var(--bad); }

/* alvos de toque confortáveis em telas de toque estreitas */
@media (max-width: 860px) {
  button, .btn, select { min-height: 40px; }
  input[type="text"], input[type="password"], input[type="search"], input[type="tel"], textarea { font-size: 16px; }
  input:not([type="checkbox"]):not([type="radio"]) { min-height: 40px; }
}
