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

  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */

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

  --card-shadow: 0 1px 2px rgba(11,11,11,.04), 0 6px 16px rgba(11,11,11,.04);
}

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

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;

    --card-shadow: 0 1px 2px rgba(0,0,0,.25), 0 6px 16px rgba(0,0,0,.20);
  }
}

* { box-sizing: border-box; }

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

.shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.sidebar {
  flex: 0 0 220px;
  width: 220px;
  padding: 20px 14px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 10px 20px;
}
.brand-mark {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--series-1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.nav-label {
  padding: 0 10px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--gridline);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 24px 64px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.page-heading h1 {
  font-size: 20px;
  margin: 0;
}
.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .nav { flex-direction: row; }
  .sidebar-footer { margin-top: 12px; padding-top: 12px; }
  .main { padding: 16px 16px 48px; }
  .topbar { justify-content: flex-start; }
}

input[type="date"], select, button {
  font: inherit;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}

button {
  cursor: pointer;
  font-weight: 600;
}
button.primary {
  background: var(--series-1);
  color: white;
  border-color: transparent;
}
button:disabled { opacity: .55; cursor: default; }

.status-line {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  border-radius: 8px;
  font-weight: 600;
}
.tab svg { flex: 0 0 auto; opacity: .8; }
.tab:hover {
  background: color-mix(in srgb, var(--series-1) 8%, transparent);
}
.tab.active {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--series-1) 12%, transparent);
  border-left-color: var(--series-1);
}
.tab.active svg { opacity: 1; color: var(--series-1); }

@media (max-width: 760px) {
  .tab { border-left: none; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0; }
  .tab.active { border-bottom-color: var(--series-1); }
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
}
.tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}
.tile-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--series-1) 14%, transparent);
  color: var(--series-1);
}
.tile .label {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.tile .value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: proportional-nums;
}
.tile .value.good { color: var(--success-text); }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
}
.trend.up { color: var(--status-good); background: color-mix(in srgb, var(--status-good) 14%, transparent); }
.trend.down { color: var(--status-critical); background: color-mix(in srgb, var(--status-critical) 14%, transparent); }
.trend.flat { color: var(--text-muted); background: color-mix(in srgb, var(--text-muted) 14%, transparent); }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--card-shadow);
}
.panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  margin: 0 0 12px;
}
.panel h2 svg { color: var(--series-1); opacity: .85; }
.chart-wrap { position: relative; height: 320px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .02em;
}
tbody tr:hover { background: color-mix(in srgb, var(--series-1) 6%, transparent); }
.table-scroll { overflow-x: auto; }

.manager-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.good { color: var(--status-good); background: color-mix(in srgb, var(--status-good) 14%, transparent); }
.badge.neutral { color: var(--text-secondary); background: color-mix(in srgb, var(--text-secondary) 10%, transparent); }

.hint {
  color: var(--text-muted);
  font-size: 13px;
}
.hint a { color: var(--series-1); }

.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
}
