:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --series-1: #2a78d6;
  --status-good: #006300;
  --status-critical: #d03b3b;
  --status-critical-bg: rgba(208,59,59,0.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255,255,255,0.10);
    --series-1: #3987e5;
    --status-good: #0ca30c;
    --status-critical: #e66767;
    --status-critical-bg: rgba(230,103,103,0.12);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
}
nav {
  display: flex;
  gap: 1.2rem;
  padding: 1rem 1.5rem;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
nav a { color: var(--text-secondary); text-decoration: none; font-weight: 600; font-size: 0.9rem; flex-shrink: 0; }
nav a:hover { color: var(--series-1); }
main { max-width: 1040px; margin: 0 auto; padding: 1.5rem; }
@media (max-width: 600px) {
  nav { gap: .9rem; padding: .8rem 1rem; }
  nav a { font-size: .85rem; }
  main { padding: 1rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  table { font-size: .78rem; }
  th, td { padding: 5px 6px; }
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin-top: 2.2rem; }
.subtitle { color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 1.5rem; }

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; margin: .75rem 0 1.5rem; }
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9rem 1rem;
}
.stat-tile .label { font-size: .78rem; color: var(--text-secondary); margin: 0 0 .35rem; }
.stat-tile .value { font-size: 1.6rem; font-weight: 600; margin: 0; font-variant-numeric: proportional-nums; }
.stat-tile .delta { font-size: .82rem; margin-top: .3rem; display: flex; align-items: center; gap: .3rem; }
.delta-bad { color: var(--status-critical); font-weight: 600; }
.delta-good { color: var(--status-good); font-weight: 600; }
.delta-neutral { color: var(--text-muted); }

/* Charts */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: .75rem 0 1.5rem; }
.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}
.chart-card h3 { font-size: .85rem; color: var(--text-secondary); margin: 0 0 .6rem; font-weight: 600; }
@media (max-width: 640px) { .chart-row { grid-template-columns: 1fr; } }

/* Table */
table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .87rem; }
th, td { border: 1px solid var(--gridline); padding: 7px 10px; text-align: left; font-variant-numeric: tabular-nums; }
th { background: var(--surface-1); color: var(--text-secondary); font-weight: 600; text-align: left; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--text-primary) 2.5%, var(--page)); }
tr.gargalo { background: var(--status-critical-bg); }
.badge-alta { color: var(--status-good); font-weight: 600; }
.badge-baixa { color: var(--status-critical); font-weight: 600; }
.valor-estimado { color: var(--text-muted); font-style: italic; }
.nota-estimativa { font-size: .8rem; color: var(--text-muted); margin-top: -.5rem; }

/* Camera capture page */
.camera-shell { max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }
.tipo-toggle { display: flex; gap: .5rem; background: var(--surface-1); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.tipo-btn { flex: 1; border: none; background: transparent; color: var(--text-secondary); font-weight: 600; font-size: .9rem; padding: 8px 0; border-radius: 999px; cursor: pointer; }
.tipo-btn.active { background: var(--series-1); color: #fff; }
.camera-frame { position: relative; width: 100%; aspect-ratio: 3 / 4; background: #000; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); }
.camera-frame video, .camera-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-status { text-align: center; padding: .6rem .8rem; border-radius: 8px; font-size: .88rem; }
.camera-status.ok { background: color-mix(in srgb, var(--status-good) 15%, var(--surface-1)); color: var(--status-good); }
.camera-status.erro { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1.5rem; text-align: center; color: #fff; background: rgba(0,0,0,.55); font-size: .9rem; }
.camera-controls { display: flex; justify-content: center; align-items: center; gap: 1rem; min-height: 64px; }
.shutter { width: 64px; height: 64px; border-radius: 50%; background: #fff; border: 4px solid var(--series-1); cursor: pointer; padding: 0; }
.shutter:active { background: var(--series-1); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.fallback { display: flex; justify-content: center; }

form { display: flex; flex-direction: column; gap: 0.7rem; max-width: 420px; }
label { font-size: 0.85rem; color: var(--text-secondary); }
input, select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-1); color: var(--text-primary); }
button, .btn { padding: 7px 14px; border: none; border-radius: 6px; background: var(--series-1); color: #fff; cursor: pointer; font-size: 0.87rem; text-decoration: none; display: inline-block; }
button.danger { background: var(--status-critical); }
.actions { display: flex; gap: 0.5rem; }
.top-actions { margin-bottom: 1rem; }
canvas { max-width: 100%; }
