:root {
  --bg: #050a14;
  --panel: #0d1626;
  --panel-alt: #132036;
  --border: #1e2d47;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --ok: #10b981;
  --warn: #f59e0b;
  --crit: #ef4444;
  --info: #38bdf8;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body.critical-alarm-active {
  box-shadow: inset 0 0 0 4px #ef4444;
  animation: screenPulse 1s infinite alternate;
}

@keyframes screenPulse {
  from { box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.7); }
  to { box-shadow: inset 0 0 28px 6px rgba(239, 68, 68, 0.95); }
}

.crit-banner {
  background: linear-gradient(90deg, #991b1b, #dc2626, #991b1b);
  color: #fff;
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 2px solid #fecaca;
  animation: bannerFlash 0.8s infinite alternate;
}

@keyframes bannerFlash {
  from { background-color: #991b1b; }
  to { background-color: #dc2626; }
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #0f2442 0%, #050a14 70%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  background: #08101e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: 7px;
  font-size: 13.5px;
}

.btn {
  border: 1px solid var(--border);
  background: #1e293b;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: #334155; }
.btn-primary { background: #0284c7; border-color: #0ea5e9; }
.btn-primary:hover { background: #0369a1; }
.btn-full { width: 100%; margin-top: 6px; }

.hidden { display: none !important; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px;
  background: #09111f;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-badge {
  background: #38bdf8;
  color: #041221;
  font-weight: 800;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 22px 0;
  background: #09111f;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--muted);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}
.tab-btn:hover { color: var(--text); background: #0f1b2e; }
.tab-btn.active {
  color: var(--info);
  background: var(--bg);
  border-color: var(--border);
}

.status-pills { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #475569; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.crit { background: var(--crit); box-shadow: 0 0 8px var(--crit); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 14px;
  padding: 16px 22px 28px;
}
@media (max-width: 1120px) { .dashboard-grid { grid-template-columns: 1fr; } }

.page-pad { padding: 18px 22px 28px; max-width: 1280px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.6px; color: #cbd5e1; }

.gauges-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.gauge-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  text-align: center;
}
.gauge-card h3 { font-size: 11.5px; color: var(--muted); text-transform: uppercase; margin-bottom: 4px; }
.gauge-svg { width: 100%; max-width: 175px; height: auto; display: block; margin: 0 auto; }

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 720px) { .charts-row { grid-template-columns: 1fr; } }

.chart-box {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
}
.chart-box h3 { font-size: 11.5px; color: var(--info); text-transform: uppercase; margin-bottom: 6px; display: flex; justify-content: space-between; }
canvas.trend-canvas { width: 100%; height: 115px; display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 10px;
}
.kpi {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.kpi h3 { font-size: 11.5px; color: var(--info); text-transform: uppercase; margin-bottom: 6px; }
.kpi-line { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; }
.kpi-line span { color: var(--muted); }

.thresholds-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.thresholds-form .field { margin-bottom: 0; }

.list-scroll { max-height: 245px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

.alert-row {
  background: var(--panel-alt);
  border-left: 4px solid var(--warn);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
}
.alert-row.CRITICAL { border-left-color: var(--crit); }

.msg-row {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
}
.msg-row.URGENT { border-left-color: var(--crit); }
.msg-row.WARNING { border-left-color: var(--warn); }

.audit-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: center;
}
.audit-toolbar input, .audit-toolbar select {
  background: #08101e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.audit-table th, .audit-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.audit-table th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; background: #09111f; }
.sev-badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}
.sev-CRITICAL { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border: 1px solid #ef4444; }
.sev-WARNING { background: rgba(245, 158, 11, 0.2); color: #fcd34d; border: 1px solid #f59e0b; }

.toast-box {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: #7f1d1d;
  border: 1px solid #ef4444;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 340px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.45);
}
