:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

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

.sidebar {
  width: 260px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.5rem; }
.brand-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
}
.brand h1 { margin: 0; font-size: 1.1rem; color: #f8fafc; }
.subtitle { margin: 0.15rem 0 0; font-size: 0.75rem; opacity: 0.7; }

.nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.nav-btn {
  background: transparent; border: none; color: var(--sidebar-text);
  text-align: left; padding: 0.65rem 0.85rem; border-radius: 8px;
  cursor: pointer; font-size: 0.875rem;
}
.nav-btn:hover { background: rgba(255,255,255,0.06); color: #f1f5f9; }
.nav-btn.active { background: rgba(5, 150, 105, 0.25); color: #fff; font-weight: 600; }

.disclaimer-box {
  margin-top: 1rem; padding: 0.75rem;
  background: rgba(217, 119, 6, 0.12); border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px; font-size: 0.72rem; line-height: 1.45; color: #fde68a;
}

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h2 { margin: 0; font-size: 1.35rem; }
.topbar p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.btn {
  border: none; border-radius: 8px; padding: 0.55rem 1rem;
  font-size: 0.875rem; cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.tiny { padding: 0.35rem 0.6rem; font-size: 0.75rem; font-weight: 500; }

#main-content { padding: 1.5rem; flex: 1; }
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; border: 1px solid var(--border);
}
.card h3 { margin: 0 0 0.75rem; font-size: 1rem; }

.hero-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1rem; margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.kpi-grid.compact .kpi { padding: 0.85rem; }
.kpi-label { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { display: block; font-size: 1.35rem; font-weight: 700; margin-top: 0.25rem; }
.accent-blue { border-left: 4px solid var(--primary); }
.accent-green { border-left: 4px solid var(--green); }
.accent-amber { border-left: 4px solid var(--amber); }
.accent-red { border-left: 4px solid var(--red); }

.health-hero { text-align: center; }
.health-ring-wrap { display: flex; justify-content: center; margin: 1rem 0; }
.health-ring {
  width: 160px; height: 160px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--score, 75) * 1%), #e2e8f0 0);
  position: relative;
}
.health-ring::before {
  content: ''; position: absolute; inset: 12px; background: var(--surface); border-radius: 50%;
}
.health-score-value {
  position: relative; font-size: 2.5rem; font-weight: 800; z-index: 1;
}
.health-score-value.good { color: var(--green); }
.health-score-value.fair { color: var(--amber); }
.health-score-value.poor { color: var(--red); }
.health-ring[data-level="fair"] { background: conic-gradient(var(--amber) calc(var(--score, 75) * 1%), #e2e8f0 0); }
.health-ring[data-level="poor"] { background: conic-gradient(var(--red) calc(var(--score, 75) * 1%), #e2e8f0 0); }

.health-breakdown { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.pill {
  font-size: 0.72rem; padding: 0.25rem 0.55rem; border-radius: 999px;
  background: #f1f5f9; color: var(--muted);
}
.pill.status-overdue { background: #fef2f2; color: var(--red); }
.pill.status-due_soon { background: #fffbeb; color: var(--amber); }

.gauge-grid { display: grid; gap: 0.75rem; }
.gauge-head { display: flex; justify-content: space-between; margin-bottom: 0.35rem; }
.gauge-label { text-transform: capitalize; font-weight: 600; font-size: 0.85rem; }
.gauge-score { font-weight: 700; }
.gauge-score.good { color: var(--green); }
.gauge-score.fair { color: var(--amber); }
.gauge-score.poor { color: var(--red); }
.gauge-bar { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 999px; }
.gauge-fill.good { background: var(--green); }
.gauge-fill.fair { background: var(--amber); }
.gauge-fill.poor { background: var(--red); }
.gauge-meta { font-size: 0.72rem; color: var(--muted); margin-top: 0.35rem; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.table-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters { display: flex; gap: 1rem; }
.filters label { font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.25rem; }
.filters select { padding: 0.4rem; border-radius: 6px; border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th, .data-table td { padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.badge {
  display: inline-block; font-size: 0.7rem; font-weight: 600;
  padding: 0.2rem 0.45rem; border-radius: 6px; text-transform: uppercase;
}
.badge.action-check { background: #eff6ff; color: #1d4ed8; }
.badge.action-maintain { background: #ecfdf5; color: #047857; }
.badge.action-repair { background: #fffbeb; color: #b45309; }
.badge.action-replace { background: #fef2f2; color: #b91c1c; }
.badge.status-overdue { background: #fef2f2; color: var(--red); }
.badge.status-due_soon { background: #fffbeb; color: var(--amber); }
.badge.status-upcoming { background: #eff6ff; color: var(--primary); }
.badge.status-ok { background: #f0fdf4; color: var(--green); }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1rem; }
.form-grid label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; font-weight: 600; }
.form-grid input { padding: 0.55rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem; }
.systems-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.checkbox-grid label { font-weight: 500; font-size: 0.85rem; }

.source-list { line-height: 1.8; padding-left: 1.25rem; }
.source-list a { color: var(--primary); }

@media (max-width: 1280px) {
  .hero-grid, .grid-2 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid, .checkbox-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
}
