:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar a { color: var(--text-secondary); text-decoration: none; font-size: 14px; }
.topbar a:hover { color: var(--text-primary); }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.filtros label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.filtros input, .filtros select {
  font-family: inherit; font-size: 14px; padding: 7px 9px;
  border-radius: 6px; border: 1px solid var(--baseline);
  background: var(--surface); color: var(--text-primary);
}
.filtros button {
  font-family: inherit; font-size: 14px; padding: 8px 16px;
  border-radius: 6px; border: none; background: var(--series-1); color: #fff;
  cursor: pointer;
}
.filtros button:hover { opacity: 0.9; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.kpi-tile .valor {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
}
.kpi-tile .rotulo { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.chart-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 800px) { .chart-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; color: var(--text-primary); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .rotulo { width: 130px; font-size: 13px; color: var(--text-secondary); flex-shrink: 0; text-align: right; }
.bar-track { flex: 1; background: var(--gridline); border-radius: 4px; height: 16px; position: relative; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--series-1); min-width: 4px; }
.bar-valor { width: 50px; font-size: 13px; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.status-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin-bottom: 12px; }
.status-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-secondary); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

table.tabela { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tabela th, table.tabela td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--gridline); }
table.tabela th { color: var(--text-muted); font-weight: 500; }
table.tabela td.num { text-align: right; font-variant-numeric: tabular-nums; }

.tooltip {
  position: absolute; pointer-events: none; background: var(--text-primary); color: var(--page);
  font-size: 12px; padding: 5px 8px; border-radius: 6px; opacity: 0; transition: opacity .1s;
  white-space: nowrap; z-index: 10;
}

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 320px;
}
.login-card h1 { font-size: 18px; margin: 0 0 20px; text-align: center; }
.login-card label { display: block; font-size: 13px; color: var(--text-muted); margin: 12px 0 4px; }
.login-card input {
  width: 100%; font-size: 14px; padding: 9px 10px; border-radius: 6px;
  border: 1px solid var(--baseline); background: var(--surface); color: var(--text-primary);
}
.login-card button {
  width: 100%; margin-top: 18px; padding: 10px; border-radius: 6px; border: none;
  background: var(--series-1); color: #fff; font-size: 14px; cursor: pointer;
}
.erro { color: var(--status-critical); font-size: 13px; margin-top: 10px; text-align: center; }
.empty-state { color: var(--text-muted); font-size: 13px; padding: 20px 0; text-align: center; }
