/* ShieldIngress shared design system (2026-08-19).
   Linked from every page in public/ -- see the design preview this was validated against
   (published as a Claude artifact during planning) for the reasoning behind the palette.

   Token structure follows the "three viewer states" rule: bare :root is the light palette
   (the default for an unstamped document); @media (prefers-color-scheme: dark) redefines
   the same tokens, guarded so an explicit light choice always wins; [data-theme="dark"]
   redefines them again so theme.js's in-page toggle wins in both directions. Every
   component below is styled through the tokens only -- never a literal color inside a
   media/[data-theme] block -- so it never renders one theme's text on the other's ground.
*/

:root {
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface-2: #FBFCFE;
  --border: #E2E7F0;
  --text: #131A2C;
  --text-muted: #6B7590;
  --text-faint: #9AA3BD;

  --accent: #0284C7;
  --accent-hover: #0369A1;
  --accent-wash: #E0F2FE;

  --ok: #12805C;
  --ok-wash: #E4F5EE;
  --warn: #B4650A;
  --warn-wash: #FDF1E1;
  --crit: #C4293C;
  --crit-wash: #FBE7EA;

  --shadow: 0 1px 2px rgba(19, 26, 44, 0.04), 0 1px 8px rgba(19, 26, 44, 0.03);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1120;
    --surface: #131B2E;
    --surface-2: #0F1626;
    --border: #253150;
    --text: #EEF1F8;
    --text-muted: #9AA6C4;
    --text-faint: #5D6889;

    --accent: #0284C7;
    --accent-hover: #38BDF8;
    --accent-wash: #0E293B;

    --ok: #34D399;
    --ok-wash: #10291F;
    --warn: #FBBF57;
    --warn-wash: #2E2110;
    --crit: #F0647A;
    --crit-wash: #301019;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #131B2E;
  --surface-2: #0F1626;
  --border: #253150;
  --text: #EEF1F8;
  --text-muted: #9AA6C4;
  --text-faint: #5D6889;

  --accent: #0284C7;
  --accent-hover: #38BDF8;
  --accent-wash: #0E293B;

  --ok: #34D399;
  --ok-wash: #10291F;
  --warn: #FBBF57;
  --warn-wash: #2E2110;
  --crit: #F0647A;
  --crit-wash: #301019;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-wash); color: var(--accent); }
a { color: var(--accent); }

/* ---------- App shell (sidebar + main) ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 0 8px;
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  text-decoration: none; color: var(--text);
}
.brand-mark {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 20px; line-height: 1;
}
.brand-mark svg { width: 15px; height: 15px; }

/* ---------- Brand logo (light/dark PNG swap) ----------
   Both images render in the markup; CSS shows exactly one per the same three-state
   pattern the color tokens above use, so it swaps in lockstep with them -- no JS,
   no flash of the wrong logo. inline-block (not block) so it centers correctly
   under a plain text-align:center container (login/help/reset-password's .logo)
   as well as inside .brand's flex row. */
.logo-img { height: 28px; width: auto; vertical-align: middle; }
.logo-img.logo-img-color { display: inline-block; }
.logo-img.logo-img-white { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-img.logo-img-color { display: none; }
  :root:not([data-theme="light"]) .logo-img.logo-img-white { display: inline-block; }
}
[data-theme="dark"] .logo-img.logo-img-color { display: none; }
[data-theme="dark"] .logo-img.logo-img-white { display: inline-block; }
.brand .logo-img { height: 20px; }
.nav-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 0 10px; margin-bottom: 2px;
}
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-muted); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  position: relative;
  border: 1px solid transparent;
}
.nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-wash); color: var(--accent); }
.nav a.active svg { opacity: 1; }
.nav a.nav-action {
  color: var(--accent); font-weight: 600;
  border: 1px dashed var(--border);
}
.nav a.nav-action:hover { background: var(--accent-wash); border-color: var(--accent); }
.nav a.nav-action svg { opacity: 1; }
.nav-count {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--crit-wash); color: var(--crit);
  padding: 1px 6px; border-radius: 99px;
}
.sidebar-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 9px; padding-left: 8px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-wash); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: 11px; color: var(--text-faint); }

.main { padding: 22px 28px 40px; max-width: 1180px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; margin: 0; }
.topbar p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Buttons ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
  color: var(--text-muted); font-size: 12.5px; font-weight: 600;
  font-family: inherit;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-faint); }
.theme-toggle svg { width: 14px; height: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 7px 13px;
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn-danger { background: var(--crit); }
.btn-danger:hover { filter: brightness(0.92); }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 15px 16px; box-shadow: var(--shadow);
}
.stat-label {
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  display: flex; align-items: center; justify-content: space-between;
}
.stat-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 24px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em;
}
.stat-delta { font-size: 12px; font-weight: 600; margin-top: 4px; }
.stat-delta.ok { color: var(--ok); }
.stat-delta.crit { color: var(--crit); }
.stat-delta.muted { color: var(--text-faint); }
.spark { display: block; margin-top: 8px; }

/* ---------- Panels / cards / tables ---------- */
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 12px; align-items: start; }
.card, .panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
  padding: 16px;
}
.panel { padding: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 13.5px; font-weight: 700; margin: 0; }
.panel-head .muted-link { font-size: 12px; color: var(--text-muted); text-decoration: none; font-weight: 600; }
.card-title { font-size: 13.5px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 9px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.host { font-weight: 600; }
.host-sub { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }
.help-text { color: var(--text-muted); font-size: 12.5px; }
.muted { color: var(--text-faint); }

/* ---------- Pills / badges ---------- */
.pill, .badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
}
.pill::before, .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok, .badge-ok, .badge-active, .badge-healthy, .badge-up { background: var(--ok-wash); color: var(--ok); }
.pill.warn, .badge-warn, .badge-pending, .badge-unknown { background: var(--warn-wash); color: var(--warn); }
.pill.crit, .badge-crit, .badge-failed, .badge-unhealthy, .badge-down { background: var(--crit-wash); color: var(--crit); }
.badge-check { background: var(--surface-2); color: var(--text-faint); }

.req-rate { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12.5px; }

/* ---------- Alerts / activity feed ---------- */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.sev { flex-shrink: 0; width: 3px; border-radius: 3px; margin-top: 2px; }
.sev.crit { background: var(--crit); }
.sev.warn { background: var(--warn); }
.sev.ok { background: var(--ok); }
.feed-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.feed-title { font-size: 12.5px; font-weight: 600; }
.feed-meta { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }
.feed-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin-right: 6px; }
.feed-tag.crit { color: var(--crit); }
.feed-tag.warn { color: var(--warn); }
.feed-tag.ok { color: var(--ok); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 0.9rem; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: var(--text-muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-wash); border-color: var(--accent); }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
