: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);

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

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

@media (prefers-color-scheme: dark) {
  :root:where(: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);

    --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-plane);
  color: var(--text-primary);
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar .brand span { color: var(--series-1); }

nav.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 0 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

nav.tabs a {
  display: inline-block;
  padding: 10px 14px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  font-size: 0.92rem;
}

nav.tabs a:hover { text-decoration: none; color: var(--text-primary); }
nav.tabs a.active {
  color: var(--text-primary);
  border-bottom-color: var(--series-1);
  font-weight: 600;
}

main { max-width: 1180px; margin: 0 auto; padding: 24px; }

h1 { font-size: 1.4rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 20px;
}

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
}

.stat-tile .label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.stat-tile .value {
  font-size: 1.7rem;
  font-weight: 700;
}
.stat-tile .sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .bar-label { width: 190px; font-size: 0.85rem; color: var(--text-secondary); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--gridline); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-row .bar-value { width: 90px; text-align: right; font-size: 0.85rem; font-variant-numeric: tabular-nums; flex-shrink: 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--gridline); }
th { color: var(--text-secondary); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
tbody tr:hover { background: rgba(42, 120, 214, 0.04); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge.good { background: rgba(12,163,12,0.12); color: var(--good); }
.badge.critical { background: rgba(208,59,59,0.12); color: var(--critical); }

form .field { margin-bottom: 14px; }
form label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; }
form input, form select, form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--baseline);
  border-radius: 6px;
  font-size: 0.92rem;
  background: var(--surface-1);
  color: var(--text-primary);
}
form textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 6px;
  border: none;
  background: var(--series-1);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { opacity: 0.92; text-decoration: none; }
.btn.secondary { background: transparent; border: 1px solid var(--baseline); color: var(--text-primary); }
.btn.small { padding: 5px 10px; font-size: 0.8rem; }

.section-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 22px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--gridline);
}
.section-title:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.line-item {
  border: 1px solid var(--gridline);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
}
.line-item .remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
}

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.flash.success { background: rgba(12,163,12,0.10); color: var(--good); }
.flash.error { background: rgba(208,59,59,0.10); color: var(--critical); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card { width: 340px; }

.muted { color: var(--text-muted); font-size: 0.85rem; }
