:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #172033;
  --muted: #687386;
  --line: #d9e1ec;
  --brand: #2563eb;
  --brand-2: #0f766e;
  --good: #138a52;
  --warn: #b7791f;
  --bad: #c2413a;
  --shadow: 0 14px 40px rgba(23, 32, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 7px;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  border-color: #b7c4d8;
}

button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

button.wide {
  width: 100%;
}

input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: var(--brand);
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

label input {
  margin-top: 6px;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(244, 247, 251, 0.9)),
    repeating-linear-gradient(90deg, rgba(37, 99, 235, 0.04) 0 1px, transparent 1px 80px);
}

.auth.hidden {
  display: none;
}

.login-panel {
  width: min(390px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-mark,
.brand-mark {
  display: grid;
  place-items: center;
  background: #e8f0ff;
  color: #174ea6;
  border: 1px solid #c8d9ff;
  font-weight: 900;
}

.login-mark {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  margin-bottom: 18px;
}

.login-panel h1 {
  margin: 0 0 4px;
  font-size: 28px;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-panel label {
  margin-bottom: 14px;
}

.form-note {
  min-height: 18px;
  margin-top: 12px;
  color: var(--bad);
  font-size: 12px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.shell.locked {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fbfcff;
  padding: 18px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 7px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

nav {
  display: grid;
  gap: 5px;
}

nav a {
  color: #334155;
  text-decoration: none;
  border-radius: 7px;
  padding: 10px 12px;
  font-weight: 700;
}

nav a:hover,
nav a.active {
  background: #eef4ff;
  color: #174ea6;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-pill i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
}

.status-pill.ok i {
  background: var(--good);
}

.status-pill.warn i {
  background: var(--warn);
}

.status-pill.bad i {
  background: var(--bad);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  background: linear-gradient(135deg, #ffffff, #edf5ff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.hero h2 {
  margin: 6px 0;
  font-size: clamp(34px, 5vw, 60px);
  line-height: 1;
}

.hero p {
  color: var(--muted);
  margin: 0;
}

.hero-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.hero-meta div {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
}

.hero-meta span,
.metric span,
.insight span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.hero-meta strong {
  display: block;
  margin-top: 4px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.panel,
.insight {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px;
  min-height: 114px;
}

.metric strong {
  display: block;
  margin: 8px 0 6px;
  font-size: 22px;
}

.metric b {
  font-size: 28px;
}

.metric small,
.insight small,
.panel-head p {
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  min-width: 0;
}

.panel-head {
  min-height: 72px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.panel-head p {
  margin: 3px 0 0;
  font-size: 12px;
}

.count-badge {
  min-width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #eef4ff;
  color: #174ea6;
  font-weight: 900;
}

.fault-list,
.action-list {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.fault,
.action {
  border: 1px solid var(--line);
  border-left: 4px solid var(--good);
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.fault.warn,
.action.warn {
  border-left-color: var(--warn);
}

.fault.bad,
.action.bad {
  border-left-color: var(--bad);
}

.fault strong,
.action strong {
  display: block;
}

.fault span,
.action span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.chart-panel {
  padding-bottom: 10px;
}

canvas {
  width: 100%;
  display: block;
  padding: 10px 14px 14px;
}

.insights {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.insight {
  padding: 14px;
}

.insight strong {
  display: block;
  font-size: 22px;
  margin: 8px 0 4px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

td.status-ok {
  color: var(--good);
  font-weight: 800;
}

td.status-warn {
  color: var(--warn);
  font-weight: 800;
}

td.status-bad {
  color: var(--bad);
  font-weight: 800;
}

.settings {
  margin-top: 18px;
}

.settings-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.settings-grid label:first-child {
  grid-column: span 3;
}

.settings-actions {
  display: flex;
  gap: 10px;
  padding: 0 16px 16px;
}

.security-note {
  border-top: 1px solid var(--line);
  color: var(--muted);
  margin: 0;
  padding: 14px 16px 16px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .insights {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .shell {
    display: block;
  }

  .shell.locked {
    display: none;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow-x: auto;
  }

  nav a {
    text-align: center;
  }

  .sidebar-foot {
    display: none;
  }

  .main {
    padding: 16px;
  }

  .hero,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .insights,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid label:first-child {
    grid-column: auto;
  }
}
