:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --text: #191919;
  --muted: #666666;
  --border: rgba(11, 11, 11, 0.10);
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --accent: #257de0;
  --accent-ink: #ffffff;
  --accent-wash: rgba(37, 125, 224, 0.10);
  --good: #0aac23;
  --good-text: #006c10;
  --warning: #fbb315;
  --critical: #dc3c3d;
  --critical-text: #b42324;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111111;
    --surface: #191919;
    --surface-2: #222222;
    --text: #efefef;
    --muted: #9c9c9c;
    --border: rgba(255, 255, 255, 0.10);
    --grid: #303030;
    --axis: #474747;
    --accent: #338ced;
    --accent-wash: rgba(51, 140, 237, 0.14);
    --good-text: #53c556;
    --critical-text: #eb6263;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 4px; font-weight: 600; }
h3 { font-size: 14px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

/* ---------- Estrutura ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; padding: 0 8px; }
.brand-lg { font-size: 20px; padding: 0; justify-content: center; }
.brand-mark { width: 18px; height: 18px; border-radius: 6px; background: var(--accent); box-shadow: inset -5px -5px 0 rgba(255,255,255,.25); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 8px; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.nav-label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.main { padding: 28px 32px 48px; max-width: 1120px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }

/* ---------- Controles ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--critical-text); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-weight: 550; font-size: 13px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 64px; }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.form-error { color: var(--critical-text); font-size: 13px; margin: 8px 0 0; min-height: 0; }
.form-error:empty { display: none; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font: inherit; color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed=true] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters select { width: auto; min-width: 180px; }

/* ---------- Status (sempre ícone + texto) ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 550; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.good::before { background: var(--good); }
.status.warning::before { background: var(--warning); }
.status.critical::before { background: var(--critical); }
.status.good { color: var(--good-text); }
.status.critical { color: var(--critical-text); }
.tag { display: inline-block; background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--muted); }

/* ---------- Números ---------- */
.hero { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.hero-value { font-size: 52px; font-weight: 650; line-height: 1; letter-spacing: -0.02em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-label { color: var(--muted); font-size: 12.5px; }
.tile-value { font-size: 24px; font-weight: 650; margin-top: 2px; }
.tile-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- Gráfico ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { opacity: .35; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hover-band { fill: var(--surface-2); }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; box-shadow: 0 4px 16px rgba(0,0,0,.12); font-size: 12.5px;
  min-width: 140px; transform: translateY(calc(-100% - 10px)); white-space: nowrap; z-index: 2;
}
.tooltip b { display: block; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; }
.tooltip .tt-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* ---------- Instalação / código ---------- */
.copy-box { display: flex; gap: 8px; align-items: stretch; }
.copy-box code { flex: 1; min-width: 0; background: var(--surface-2); border-radius: 8px; padding: 9px 10px; overflow-x: auto; white-space: nowrap; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: center; }
.checklist .mark { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--axis); flex: none; display: grid; place-items: center; font-size: 12px; }
.checklist .done .mark { background: var(--good); border-color: var(--good); color: #fff; }
.checklist .done .label { color: var(--muted); text-decoration: line-through; }

/* ---------- Login / avisos ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card p { margin: 0; text-align: center; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 13px; max-width: 360px; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.error { background: var(--critical); color: #fff; }
.notice { border-left: 3px solid var(--warning); background: var(--surface-2); padding: 10px 12px; border-radius: 6px; font-size: 13px; }
.notice.error { border-color: var(--critical); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .main { padding: 20px 16px 40px; }
  .hero-value { font-size: 44px; }
}
