:root {
  --primary:       #1a3a52;
  --accent:        #0066cc;
  --bg:            #ffffff;
  --bg-subtle:     #f8f9fa;
  --bg-dark:       #1a3a52;
  --text:          #1a3a52;
  --text-muted:    #6b7a8d;
  --border:        #e2e8f0;

  --healthy:       #157f3b;
  --healthy-soft:  rgba(21, 127, 59, 0.10);
  --warning:       #b7791f;
  --warning-soft:  rgba(183, 121, 31, 0.12);
  --stale:         #b42318;
  --stale-soft:    rgba(180, 35, 24, 0.10);

  --font:          "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-weight-heading: 700;

  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --shadow:        0 4px 20px rgba(26, 58, 82, 0.10);
  --shadow-sm:     0 2px 8px rgba(26, 58, 82, 0.07);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Navigation ─────────────────────────────────────────── */
nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.nav-logo svg { width: 28px; height: 28px; }
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
  background: var(--bg-subtle);
}
.nav-links a.active { font-weight: 700; }
.nav-cta {
  background: var(--accent);
  color: #fff !important;
  padding: 8px 20px !important;
  border-radius: var(--radius-sm) !important;
  font-weight: 700 !important;
  font-size: 0.88rem !important;
}
.nav-cta:hover { background: #0052a3 !important; color: #fff !important; }

/* ── Page Header / Hero ──────────────────────────────────── */
.page-header {
  background: var(--primary);
  color: #fff;
  padding: 48px 24px;
}
.page-header-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.page-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.page-header p {
  opacity: 0.75;
  font-size: 0.97rem;
}
.page-header .breadcrumb {
  font-size: 0.82rem;
  opacity: 0.6;
  margin-bottom: 10px;
}
.page-header .breadcrumb a {
  color: #fff;
  text-decoration: none;
  opacity: 0.75;
}
.page-header .breadcrumb a:hover { opacity: 1; }

/* ── Main container ─────────────────────────────────────── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
  flex: 1;
  width: 100%;
}

/* ── KPI Cards ──────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}
.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px 24px;
}
.kpi-card .kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.kpi-card .kpi-value {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.kpi-card .kpi-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Filters ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 32px;
  padding: 20px 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.filter-group input,
.filter-group select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--accent);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 24px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #0052a3; }
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 22px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover { background: var(--accent); color: #fff; }

/* ── Cards / Sections ───────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px 24px;
  margin-bottom: 28px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
}
.chart-wrap {
  position: relative;
  height: 280px;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:nth-child(even) { background: var(--bg-subtle); }
tbody tr:hover { background: rgba(0,102,204,0.04); }
tbody td {
  padding: 12px 14px;
  color: var(--text);
  vertical-align: middle;
}
tbody td a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
tbody td a:hover { text-decoration: underline; }

/* ── Status Pills ───────────────────────────────────────── */
.pill {
  display: inline-block;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 3px 12px;
  white-space: nowrap;
}
.pill-healthy  { background: var(--healthy-soft);  color: var(--healthy); }
.pill-warning  { background: var(--warning-soft);  color: var(--warning); }
.pill-stale    { background: var(--stale-soft);    color: var(--stale); }
.pill-unknown  { background: rgba(107,122,141,0.12); color: var(--text-muted); }

/* ── Alert / Notice ─────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.alert-error   { background: var(--stale-soft);   color: var(--stale);   border: 1px solid rgba(180,35,24,0.2); }
.alert-success { background: var(--healthy-soft); color: var(--healthy); border: 1px solid rgba(21,127,59,0.2); }
.alert-info    { background: rgba(0,102,204,0.07); color: var(--accent);  border: 1px solid rgba(0,102,204,0.2); }

/* ── Settings Page ──────────────────────────────────────── */
.settings-card {
  max-width: 560px;
}
.form-field {
  margin-bottom: 20px;
}
.form-field label {
  display: block;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 6px;
}
.form-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.form-field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
}
.form-field input:focus { border-color: var(--accent); }
.form-field select:focus { border-color: var(--accent); }
.form-field .hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.checkbox-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px;
  max-height: 240px;
  overflow: auto;
  display: grid;
  gap: 6px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.check-item:hover {
  background: var(--bg-subtle);
}
.check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ── Loading spinner ────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 32px 0;
}
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Live refresh indicator ─────────────────────────────── */
.refresh-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
}
.refresh-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--healthy);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Footer ─────────────────────────────────────────────── */
footer {
  background: var(--primary);
  color: rgba(255,255,255,0.75);
  padding: 40px 24px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  justify-content: space-between;
  align-items: center;
}
.footer-brand {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}
.footer-copy {
  font-size: 0.82rem;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-inner {
    height: auto;
    min-height: 64px;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .nav-links {
    display: flex;
    order: 3;
    width: 100%;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .nav-links a {
    white-space: nowrap;
    padding: 7px 10px;
    font-size: 0.84rem;
  }
  .page-header { padding: 32px 20px; }
  .page-header h1 { font-size: 1.5rem; }
  main { padding: 24px 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }

  table thead { display: none; }
  tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
  }
  tbody td {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    border-bottom: none;
  }
  tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
  }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card .kpi-value { font-size: 2rem; }
}

/* ── Session / Auth ─────────────────────────────────────── */
.session-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg-subtle);
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card h1 {
  color: var(--primary);
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.auth-sub {
  color: var(--text-muted);
  margin-bottom: 18px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.auth-form input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 0.93rem;
  color: var(--text);
  background: #fff;
}

.form-field select[multiple] {
  min-height: 120px;
}

@media (max-width: 768px) {
  .session-badge { margin-left: auto; }
}
