:root {
  --bg-deep: #07090d;
  --bg: #0c1018;
  --surface: rgba(14, 20, 28, 0.72);
  --surface-2: rgba(22, 30, 42, 0.65);
  --glass-bg: rgba(255, 255, 255, 0.045);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: 18px;
  --text: #e9eef5;
  --muted: #8a9bb2;
  --accent: #8b9cff;
  --accent-dim: rgba(139, 156, 255, 0.14);
  --border: rgba(255, 255, 255, 0.07);
  --highlight: rgba(255, 255, 255, 0.035);
  --ok: #3dd68c;
  --warn: #ffb020;
  --fail: #ff6b6b;
  --info: #4d9aff;
  --stale: #c9a227;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "IBM Plex Sans", "Inter", "Segoe UI", system-ui, sans-serif;
  --ease: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --space: 1.25rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Code", monospace; font-size: 0.85rem; }
.truncate { max-width: 6rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate-inline { max-width: 28rem; display: inline-block; vertical-align: bottom; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.display { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; margin: 0; line-height: 1.15; }
.title { font-size: 1.4rem; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.section-title { font-size: 0.72rem; font-weight: 600; color: var(--muted); margin: 0 0 1rem; text-transform: uppercase; letter-spacing: 0.08em; }
.body { font-size: 0.95rem; margin: 0.35rem 0; }
.caption { font-size: 0.8rem; }
.muted { color: var(--muted); }
.foot-note { margin-top: 1rem; opacity: 0.85; }

.card {
  background: var(--surface-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space) 1.4rem;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}
.card.glass { background: var(--glass-bg); }
.surface { background: var(--surface); }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent-dim), transparent 60%);
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), #6b7ae8);
  opacity: 0.9;
}
.brand-mark.sm { width: 28px; height: 28px; }
.brand-mark.sm::after { inset: 7px; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  position: relative;
  overflow: hidden;
}
.login-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(139, 156, 255, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(61, 214, 140, 0.06), transparent),
    var(--bg-deep);
  pointer-events: none;
}
.login-card { width: 100%; max-width: 420px; position: relative; z-index: 1; }
.login-brand { margin-bottom: 1rem; }

.login-screen .field-label,
.login-screen .caption,
.login-screen .muted { color: rgba(255, 255, 255, 0.78); }
.login-screen input {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.12);
}
.login-screen input:focus {
  border-color: rgba(139, 156, 255, 0.55);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.login-screen .btn-primary {
  background: linear-gradient(180deg, #1a2230, #0e1218);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.login-screen .btn-primary:hover:not(:disabled) {
  border-color: rgba(139, 156, 255, 0.45);
  background: linear-gradient(180deg, #222c3d, #121820);
}
.login-screen .btn-primary:disabled { opacity: 0.65; cursor: wait; }

.otp-hint { line-height: 1.45; margin: 0 0 0.25rem; }

.form-stack { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1rem; }
.field { display: block; }
.field-label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--muted); margin-bottom: 0.4rem; }
input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
  font: inherit;
  transition: border-color var(--ease), box-shadow var(--ease);
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.otp-input { letter-spacing: 0.4em; text-align: center; font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  transition: filter var(--ease), background var(--ease), border-color var(--ease);
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { cursor: not-allowed; opacity: 0.7; }
.btn-primary { background: var(--accent); color: #0a0e14; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--highlight); }
.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.8rem; }

.inline-error { color: var(--fail); font-size: 0.85rem; margin-top: 0.85rem; }

/* Shell */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 1.35rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0 0.55rem 1.35rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
}
.brand-text { font-weight: 700; font-size: 0.98rem; letter-spacing: -0.02em; }

.nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), transform var(--ease);
}
.nav-icon { font-size: 0.75rem; opacity: 0.75; width: 1.1rem; text-align: center; }
.nav-item:hover { background: var(--highlight); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sidebar-foot { padding: 0.85rem 0.55rem 0; border-top: 1px solid var(--border); }

.main {
  padding: 1.35rem 2rem 3rem;
  max-width: 1320px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.65rem;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg-deep) 65%, transparent);
  padding-bottom: 0.65rem;
  z-index: 2;
}

.topbar-meta { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; justify-content: flex-end; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--highlight);
}
.live-pill--ok { border-color: rgba(61, 214, 140, 0.25); }
.live-pill--stale { border-color: rgba(201, 162, 39, 0.35); }
.live-pill--err { border-color: rgba(255, 107, 107, 0.3); }

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.live-label { font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.live-dot--ok {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(61, 214, 140, 0.45);
  animation: pulse 2.2s ease-in-out infinite;
}
.live-dot--stale { background: var(--stale); animation: none; }
.live-dot--err { background: var(--fail); animation: none; }

#last-updated.is-stale { color: var(--stale); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.92); }
}

.view { animation: fadeIn 220ms ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Skeletons */
.skeleton-wrap { padding: 0.5rem 0; }
.skeleton {
  background: linear-gradient(90deg, var(--highlight) 25%, rgba(255,255,255,0.06) 50%, var(--highlight) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line { height: 0.85rem; margin-bottom: 0.65rem; max-width: 90%; }
.skeleton-line:nth-child(2) { max-width: 70%; }
.skeleton-line:nth-child(3) { max-width: 55%; }
.skeleton-kpi-row { height: 4rem; margin-top: 1rem; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
}
.empty-icon {
  font-size: 1.75rem;
  color: var(--muted);
  opacity: 0.5;
  margin-bottom: 0.5rem;
}
.empty-title { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.35rem; }
.empty-hint { margin-top: 0.5rem; font-family: ui-monospace, monospace; font-size: 0.72rem; }

/* KPIs & chips */
.kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.75rem;
  margin-bottom: var(--space);
  align-items: flex-end;
}
.kpi-row--hero { margin-bottom: 1.5rem; }
.kpi-row.compact { gap: 0.65rem 1.1rem; margin-bottom: 0.75rem; }

.kpi {
  display: flex;
  flex-direction: column;
  min-width: 5.5rem;
  cursor: default;
}
.kpi-n { font-size: 1.65rem; font-weight: 700; color: var(--accent); line-height: 1.15; }
.kpi-l {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}
.kpi-badge { text-transform: uppercase; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.chip-sm { font-size: 0.62rem; padding: 0.12rem 0.45rem; }
.chip-ok { background: rgba(61, 214, 140, 0.12); color: var(--ok); }
.chip-fail { background: rgba(255, 107, 107, 0.12); color: var(--fail); }
.chip-warn { background: rgba(255, 176, 32, 0.12); color: var(--warn); }
.chip-info { background: rgba(77, 154, 255, 0.12); color: var(--info); }
.chip-muted { background: var(--highlight); color: var(--muted); }
.status-chip { min-width: 4.5rem; justify-content: center; }

.kind-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.85rem; }
.kind-tag { font-size: 0.82rem; color: var(--text); opacity: 0.9; }

/* Infra */
.infra-hero {
  display: flex;
  align-items: flex-start;
  gap: 1.75rem;
  margin-bottom: var(--space);
  flex-wrap: wrap;
}
.health-ring {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: conic-gradient(var(--ok) calc(var(--pct) * 1%), var(--border) 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.health-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--surface);
}
.health-ring-n, .health-ring-l { position: relative; z-index: 1; }
.health-ring-n { font-weight: 700; font-size: 1.15rem; }

.infra-hero-meta { flex: 1; min-width: 220px; }

.plane-viz {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.plane-node {
  flex: 1;
  min-width: 72px;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--highlight);
  text-align: center;
}
.plane-node-label { display: block; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.plane-node-stat { font-size: 0.9rem; font-weight: 700; }
.plane-node--ok { border-color: rgba(61, 214, 140, 0.35); }
.plane-node--warn { border-color: rgba(255, 176, 32, 0.35); }
.plane-node--fail { border-color: rgba(255, 107, 107, 0.35); }
.plane-node--idle { opacity: 0.55; }
.plane-connector {
  width: 12px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

.plane-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.plane-collapsible { padding: 0; overflow: hidden; }
.plane-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
}
.plane-summary::-webkit-details-marker { display: none; }
.plane-summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.75rem;
  transition: transform var(--ease);
}
.plane-collapsible[open] .plane-summary::after { transform: rotate(-180deg); }
.plane-title { margin: 0; font-size: 0.88rem; font-weight: 600; }
.plane-edges { padding: 0 1.25rem 1rem; border-top: 1px solid var(--border); }

.collapsible { padding: 0; margin-top: 0.75rem; }
.collapsible-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}
.collapsible-summary::-webkit-details-marker { display: none; }
.extras-stack { max-width: 720px; }

.edge-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.edge-row:last-child { border-bottom: none; }
.edge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.4rem;
  flex-shrink: 0;
}
.edge-dot.ok { background: var(--ok); box-shadow: 0 0 6px rgba(61, 214, 140, 0.35); }
.edge-dot.fail { background: var(--fail); }
.edge-name { font-weight: 500; font-size: 0.82rem; word-break: break-word; }
.edge-detail { margin-top: 0.2rem; line-height: 1.4; }

.json-snippet {
  font-size: 0.72rem;
  overflow: auto;
  max-height: 220px;
  margin: 0;
  padding: 0 1.25rem 1rem;
  color: var(--muted);
}

/* Jobs */
.table-wrap { overflow-x: auto; padding: 0; }
.jobs-table-wrap { display: block; }
.jobs-cards { display: none; gap: 0.75rem; flex-direction: column; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  text-align: left;
  padding: 0.85rem 1.1rem;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}
.data-table td {
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--ease); }
.data-table tbody tr:hover { background: var(--highlight); }
.data-table .empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

.job-card {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  background: var(--glass-bg);
}
.job-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.65rem; }
.job-id { font-size: 0.82rem; }
.job-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
  font-size: 0.8rem;
}
.job-card-meta dt { color: var(--muted); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.job-card-meta dd { margin: 0.1rem 0 0; font-weight: 500; }

/* Operations */
.ops-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.span2 { grid-column: 1 / -1; }
.ops-disclaimer {
  margin: -0.5rem 0 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--highlight);
  line-height: 1.45;
}

.hunt-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}
.hunt-card:last-child { margin-bottom: 0; }
.hunt-head { margin-bottom: 0.75rem; }
.hunt-target { font-size: 1.05rem; letter-spacing: -0.02em; }
.hunt-run { display: block; margin-top: 0.15rem; }

.honest-callout {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--accent);
  background: rgba(139, 156, 255, 0.08);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.honest-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.honest-callout p { margin: 0; font-size: 0.92rem; line-height: 1.5; }

.target-row {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  font-size: 0.88rem;
}
.target-row:last-child { border-bottom: none; }
.target-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.target-ts { display: block; margin-top: 0.35rem; }

.timeline { list-style: none; padding: 0; margin: 0; max-height: 440px; overflow: auto; }
.timeline-item {
  display: flex;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 0.4rem;
  flex-shrink: 0;
}
.timeline-detail { word-break: break-word; margin: 0.25rem 0 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 72px 1fr; }
  .nav-label, .brand-text, .sidebar-foot p { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .nav-item { justify-content: center; padding: 0.65rem; }
  .nav-icon { width: auto; font-size: 0.85rem; }
  .ops-grid { grid-template-columns: 1fr; }
  .main { padding: 1rem 1.1rem 2rem; }
  .jobs-table-wrap { display: none; }
  .jobs-cards { display: flex; }
  .plane-viz { flex-direction: column; align-items: stretch; }
  .plane-connector { width: 2px; height: 10px; margin: 0 auto; }
}

@media (max-width: 480px) {
  .kpi-n { font-size: 1.35rem; }
  .infra-hero { flex-direction: column; align-items: center; text-align: center; }
}
