/* NetReviews — estilos */
:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --soft: #f1f4f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --line: #7c3aed;
  --bad: #dc2626;
  --reg: #d97706;
  --good: #0891b2;
  --exc: #16a34a;
  --off: #991b1b;
  --none: #94a3b8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .06);
  color-scheme: light dark;
}
/* Tema: segue o sistema por padrão; o botão do menu força claro/escuro via data-theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --card: #111a2e;
    --soft: #0e1628;
    --text: #e5e9f2;
    --muted: #94a3b8;
    --border: #1f2a40;
    --accent: #3b82f6;
    --line: #a78bfa;
    --bad: #f87171;
    --reg: #fbbf24;
    --good: #22d3ee;
    --exc: #4ade80;
    --off: #fca5a5;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0b1120;
    --card: #111a2e;
    --soft: #0e1628;
    --text: #e5e9f2;
    --muted: #94a3b8;
    --border: #1f2a40;
    --accent: #3b82f6;
    --line: #a78bfa;
    --bad: #f87171;
    --reg: #fbbf24;
    --good: #22d3ee;
    --exc: #4ade80;
    --off: #fca5a5;
    --shadow: none;
    color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
h2 { font-size: 1rem; margin: 0 0 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
h2 small { font-weight: 400; color: var(--muted); font-size: .8rem; }
h3 { margin: 0; font-size: 1.05rem; }
code { font-size: .85em; background: var(--soft); padding: 1px 5px; border-radius: 6px; }
.muted { color: var(--muted); font-size: .85rem; margin: 10px 0 0; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; letter-spacing: -.3px; }
.brand img { border-radius: 8px; }
.top-actions { display: flex; align-items: center; gap: 10px; position: relative; }
.net-state { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.net-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--exc); }
.net-state.offline i { background: var(--bad); }

/* Layout */
.layout {
  max-width: 1120px; margin: 0 auto; padding: 16px;
  display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .now-card, .chart-card, .history-card { grid-column: 1 / -1; }
}
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  min-width: 0;
}

/* Botões */
.btn {
  font: inherit; font-weight: 600; font-size: .95rem;
  border: 1px solid var(--border); background: var(--soft); color: var(--text);
  padding: 11px 14px; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .06s, background .15s, border-color .15s;
  min-height: 44px;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary.running { background: var(--reg); border-color: var(--reg); color: #1a1200; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: .85rem; }
.btn.big { font-size: 1.1rem; min-height: 54px; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { font: inherit; background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.icon-btn:hover { background: var(--soft); }

/* Nota */
.score-card { --lvl: var(--none); border-top: 5px solid var(--lvl); }
.score-card[data-level="bad"]  { --lvl: var(--bad); }
.score-card[data-level="reg"]  { --lvl: var(--reg); }
.score-card[data-level="good"] { --lvl: var(--good); }
.score-card[data-level="exc"]  { --lvl: var(--exc); }
.score-card[data-level="off"]  { --lvl: var(--off); }
.score-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.pill { font-size: .82rem; background: var(--soft); border: 1px solid var(--border); padding: 4px 10px; border-radius: 99px; color: var(--muted); }
.pill strong { color: var(--text); }
.run-pill.on { color: var(--exc); border-color: color-mix(in srgb, var(--exc) 45%, var(--border)); }
.run-pill.on::before { content: "●"; margin-right: 5px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.score-main { text-align: center; padding: 14px 0 4px; }
.score-value {
  font-size: clamp(76px, 22vw, 128px); font-weight: 800; line-height: 1;
  color: var(--lvl); font-variant-numeric: tabular-nums; letter-spacing: -3px;
  transition: color .3s;
}
.score-label { margin-top: 6px; font-weight: 700; font-size: 1.15rem; color: var(--lvl); }
.score-bar { height: 8px; background: var(--soft); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; margin: 14px 0; }
.score-bar span { display: block; height: 100%; width: 0; background: var(--lvl); transition: width .5s ease, background .3s; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.stats div { background: var(--soft); border-radius: 10px; padding: 8px 6px; text-align: center; }
dt { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 400px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Controles */
.controls { display: flex; flex-direction: column; gap: 12px; }
.ctrl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 600; }
select, input[type="text"], input[type="url"], input[type="number"], input:not([type]) {
  font: inherit; color: var(--text); background: var(--soft);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.save-hint { margin: 0; font-size: .8rem; color: var(--muted); word-break: break-word; }

/* Agora */
.now-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.now-box { background: var(--soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.now-box strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-box small { color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
@media (max-width: 620px) { .now-grid { grid-template-columns: minmax(0, 1fr); } }
.progress { height: 4px; background: var(--soft); border-radius: 99px; overflow: hidden; margin: 12px 0; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }
.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .queue { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 980px) { .queue { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.q-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: .86rem;
}
.q-item.is-now { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.q-num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .75rem; min-width: 1.6em; }
.q-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.q-last { font-variant-numeric: tabular-nums; color: var(--muted); }
.q-eta { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4.8em; text-align: right; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--none); margin-right: 4px; vertical-align: middle; }
.dot.ok { background: var(--exc); } .dot.slow { background: var(--reg); } .dot.fail { background: var(--bad); }

/* Gráfico */
#chart { width: 100%; height: 230px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .78rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 10px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.lg-bar { background: var(--good); }
.lg-line { background: var(--line); height: 3px !important; }
.lg-fail { background: var(--bad); }

/* Tabela */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; min-width: 2.6em; text-align: center; padding: 2px 8px; border-radius: 99px; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; }
.badge.bad { background: var(--bad); } .badge.reg { background: var(--reg); color: #1a1200; }
.badge.good { background: var(--good); color: #002229; } .badge.exc { background: var(--exc); color: #032b10; }
.badge.off { background: var(--off); }
.st-ok { color: var(--exc); } .st-fail { color: var(--bad); font-weight: 600; }

/* Diálogos */
.dlg {
  border: 1px solid var(--border); border-radius: 18px; padding: 0;
  background: var(--card); color: var(--text);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
}
.dlg.wide { width: min(820px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(2, 6, 23, .55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card); z-index: 1; }
.dlg-body { padding: 16px; }
.dlg-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.spacer { flex: 1; }
.row-form { display: flex; gap: 8px; margin-top: 12px; }
.row-form input { flex: 1; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plist li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 12px; }
.plist li.active { border-color: var(--accent); }
.plist .pcount { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.plist .btn { min-height: 38px; padding: 6px 10px; font-size: .85rem; }
@media (max-width: 480px) {
  .plist li { grid-template-columns: minmax(0, 1fr) auto; }
  .plist li input { grid-column: 1 / -1; }
}
.slist { display: grid; gap: 8px; }
.srow { display: grid; grid-template-columns: auto minmax(0, .8fr) minmax(0, 1.6fr) auto; gap: 8px; align-items: center; }
.srow input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
@media (max-width: 600px) {
  .srow { grid-template-columns: auto minmax(0, 1fr) auto; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .srow input[data-f="url"] { grid-column: 1 / -1; }
}
.settings { display: flex; flex-direction: column; gap: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-size: .92rem; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.folder-box { background: var(--soft); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 140%); opacity: 0;
  max-width: min(560px, calc(100vw - 24px));
  background: var(--text); color: var(--bg);
  padding: 12px 16px; border-radius: 12px; font-size: .9rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 50;
  transition: transform .25s, opacity .25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Menu hambúrguer */
.menu-toggle {
  width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0;
  background: var(--soft); border: 1px solid var(--border); border-radius: 12px; color: var(--text); cursor: pointer;
}
.menu-toggle:hover, .menu-toggle[aria-expanded="true"] { border-color: var(--accent); }
.menu-toggle svg { width: 24px; height: 24px; }
.menu-toggle svg, .mbtn svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-backdrop { position: fixed; inset: 0; z-index: 19; background: rgba(2, 6, 23, .35); }
.menu-panel {
  position: fixed; z-index: 20;
  top: calc(60px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 12px; box-shadow: 0 14px 40px rgba(0, 0, 0, .28);
}
.menu-panel[hidden], .menu-backdrop[hidden] { display: none; }
.menu-grid { display: grid; grid-template-columns: repeat(2, 64px); gap: 10px; }
.mbtn {
  width: 64px; height: 64px; display: grid; place-items: center; padding: 0;
  background: var(--soft); border: 1px solid var(--border); border-radius: 16px;
  color: var(--text); cursor: pointer; text-decoration: none;
  transition: transform .06s, border-color .15s, background .15s, color .15s;
}
.mbtn:hover, .mbtn:focus-visible { border-color: var(--accent); color: var(--accent); outline: none; }
.mbtn:active { transform: scale(.94); }
.mbtn svg { width: 28px; height: 28px; grid-area: 1 / 1; }
/* ícones alternados: tela cheia (entrar/sair) e tema (lua/sol) */
.mbtn .ic-exit, .mbtn .ic-sun { display: none; }
html.is-fullscreen .mbtn .ic-enter { display: none; }
html.is-fullscreen .mbtn .ic-exit { display: block; }
:root[data-eff="dark"] .mbtn .ic-moon { display: none; }
:root[data-eff="dark"] .mbtn .ic-sun { display: block; }
.btn.small { white-space: nowrap; }
