/* =====================================================================
   Freeway Hub — JARVIS command-center dark theme
   Token palette adapted from design-preview/assets/tokens.css
   (open-design "agentic"). Near-black layered surfaces, cyan accent,
   glassy panels, Orbitron display + Rajdhani UI type.

   RULE: existing class names / ids are load-bearing (JS hooks + tests).
   Restyle values only; new classes may be added, none removed.
   ===================================================================== */

:root {
  /* Core palette — near-black layered surfaces */
  --bg-app:      #0b1020;   /* main body */
  --bg-sidebar:  #090d1a;   /* left rail (one layer deeper) */
  --bg-topbar:   #0b1020;   /* top rail (same as app) */
  --bg-card:     rgba(19, 27, 47, 0.72);   /* glassy cards / panels */
  --bg-card-alt: rgba(96, 165, 250, 0.07); /* nav hover + table header tint */
  --bg-input:    rgba(7, 11, 24, 0.65);    /* form inputs */

  /* Text */
  --fg-primary:  #eef3fc;
  --fg-muted:    #8ea0b8;
  --fg-dim:      #5d6a85;
  --fg-invert:   #06111f;

  /* Borders */
  --border:        rgba(120, 160, 230, 0.12);
  --border-strong: rgba(120, 160, 230, 0.24);

  /* Accents — cyan/blue is the command-center headline color.
     NOTE: --orange keeps its NAME (selectors reference it) but is
     remapped to the accent so every legacy use lights up consistently. */
  --accent:      #60a5fa;
  --accent-soft: #7dc0ff;
  --accent-on:   #06111f;   /* text on accent fills */
  --orange:      var(--accent);
  --orange-soft: var(--accent-soft);
  --blue:        #60a5fa;
  --green:       #22c55e;
  --amber:       #fbbf24;
  --red:         #fb7185;
  --success:     var(--green);
  --warn:        var(--amber);
  --danger:      var(--red);

  /* Status tag backgrounds (low-sat tints that read on near-black) */
  --tag-good-bg: rgba(34, 197, 94, 0.14);
  --tag-good-fg: #86efac;
  --tag-warn-bg: rgba(251, 191, 36, 0.14);
  --tag-warn-fg: #fde68a;
  --tag-bad-bg:  rgba(251, 113, 133, 0.16);
  --tag-bad-fg:  #fda4af;
  --tag-muted-bg: rgba(255, 255, 255, 0.07);
  --tag-muted-fg: #c2c9da;
  --tag-neutral-bg: rgba(142, 160, 184, 0.16);
  --tag-neutral-fg: #a9b4c9;

  /* Type families — Orbitron display, Rajdhani UI, with safe fallbacks */
  --font-display: "Orbitron", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-ui:      "Rajdhani", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Glow + elevation */
  --glow-accent:  0 0 14px rgba(96, 165, 250, 0.35);
  --glow-success: 0 0 10px rgba(34, 197, 94, 0.55);
  --focus-ring:   0 0 0 3px rgba(96, 165, 250, 0.25);

  --radius: 12px;
  --shadow-card: 0 14px 40px rgba(0, 0, 0, 0.40);
  --sidebar-w: 230px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background:
    radial-gradient(1100px 650px at 82% -10%, rgba(96, 165, 250, 0.10), transparent 60%),
    radial-gradient(850px 550px at -5% 110%, rgba(34, 197, 94, 0.05), transparent 55%),
    var(--bg-app);
  background-attachment: fixed;
  color: var(--fg-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #c7d2ea;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 5px;
  border-radius: 4px;
}

/* dark scrollbars so panels stay seamless */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(120, 160, 230, 0.18);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(120, 160, 230, 0.30); }

/* ---------- shell ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- sidebar ---------- */

.sidebar {
  background: linear-gradient(180deg, rgba(13, 19, 36, 0.92), rgba(9, 13, 26, 0.96));
  padding: 22px 0 16px;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 4px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-brand img {
  width: 100%;
  max-width: 180px;
  display: block;
}
.sidebar-brand .tagline {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  margin-top: 8px;
  text-shadow: 0 0 12px rgba(96, 165, 250, 0.45);
}

.sidebar-section-label {
  font-family: var(--font-display);
  color: var(--fg-dim);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  padding: 18px 20px 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg-muted);
  padding: 10px 20px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-left: 3px solid transparent;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.sidebar-nav a:hover {
  background: var(--bg-card-alt);
  color: var(--fg-primary);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.14), rgba(96, 165, 250, 0.03));
  color: var(--accent-soft);
  border-left-color: var(--accent);
  box-shadow: inset 8px 0 18px -10px rgba(96, 165, 250, 0.55);
}
.sidebar-nav .icon {
  width: 16px;
  height: 16px;
  flex: none;
  opacity: 0.85;
}
.sidebar-nav a.active .icon {
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(96, 165, 250, 0.6));
}
.sidebar-nav .count-pill {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  box-shadow: var(--glow-accent);
}

/* ---------- top bar ---------- */

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(19, 27, 47, 0.85), rgba(11, 16, 32, 0.45));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.breadcrumbs {
  color: var(--fg-muted);
  font-size: 12.5px;
  letter-spacing: 0.5px;
}
.breadcrumbs .here {
  font-family: var(--font-display);
  color: var(--accent);
  margin-right: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  text-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
}
.breadcrumbs .sep { color: var(--fg-dim); margin: 0 6px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--fg-muted);
  font-size: 13px;
}
.topbar-right .status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  box-shadow: var(--glow-success);
  animation: hub-pulse 2.4s ease-in-out infinite;
}
/* live military clock (populated by _base.html JS) */
.hub-clock {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--fg-primary);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(96, 165, 250, 0.35);
  white-space: nowrap;
}
.user-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.user-chip-name { color: var(--fg-primary); font-weight: 600; font-size: 13px; }
.user-chip-role {
  color: var(--accent);
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 600;
}
.btn-small { padding: 5px 10px; font-size: 12px; font-weight: 600; }

/* ---------- main content ---------- */

.content {
  padding: 24px 28px 40px;
  min-width: 0;   /* let tables scroll instead of blowing up grid */
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4px 0 22px;
  gap: 16px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  margin: 0;
  color: var(--fg-primary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.page-title b, .page-title strong {
  font-weight: 700;
  color: var(--accent-soft);
  text-shadow: 0 0 16px rgba(96, 165, 250, 0.40);
}
.page-subtitle {
  color: var(--fg-muted);
  font-size: 13.5px;
}

/* ---------- cards ---------- */

.card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card::before {   /* subtle accent scan-line along the top edge */
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.55), transparent);
  opacity: 0.7;
  pointer-events: none;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -4px 0 14px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 13px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-primary);
}
.card-title b { font-weight: 700; color: var(--accent-soft); }
.card-x {
  color: var(--fg-dim);
  font-size: 14px;
  line-height: 1;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi {
  position: relative;
  background: linear-gradient(180deg, rgba(24, 35, 67, 0.65), var(--bg-card));
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}
.kpi::after {   /* corner glow */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120px 80px at 100% 0%, rgba(96, 165, 250, 0.10), transparent 70%);
}
.kpi-label {
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.kpi-label b { color: var(--fg-primary); font-weight: 700; }
.kpi-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  color: var(--fg-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(96, 165, 250, 0.25);
}
.kpi-sub {
  color: var(--fg-muted);
  font-size: 12.5px;
  margin-top: 10px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.kpi-sub .num { color: var(--fg-primary); font-weight: 600; }
.kpi-sub .good { color: var(--green); }
.kpi-sub .warn { color: var(--amber); }
.kpi-sub .bad  { color: var(--red); }

/* ---------- tables ---------- */

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

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data th {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-card-alt);
}
table.data td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-primary);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(96, 165, 250, 0.04); }

/* ---------- tags / pills ---------- */

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.tag-good    { background: var(--tag-good-bg);    color: var(--tag-good-fg);    border-color: rgba(34, 197, 94, 0.30); }
.tag-warn    { background: var(--tag-warn-bg);    color: var(--tag-warn-fg);    border-color: rgba(251, 191, 36, 0.30); }
.tag-bad     { background: var(--tag-bad-bg);     color: var(--tag-bad-fg);     border-color: rgba(251, 113, 133, 0.30); }
.tag-muted   { background: var(--tag-muted-bg);   color: var(--tag-muted-fg); }
.tag-neutral { background: var(--tag-neutral-bg); color: var(--tag-neutral-fg); }

/* ---------- key/value lists ---------- */

.kv {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 8px 16px;
  font-size: 14px;
  margin: 4px 0 0;
}
.kv dt {
  color: var(--fg-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-top: 2px;
}
.kv dd {
  margin: 0;
  color: var(--fg-primary);
}

/* ---------- forms ---------- */

label.field-label {
  display: block;
  color: var(--fg-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
textarea,
select {
  width: 100%;
  background: var(--bg-input);
  color: var(--fg-primary);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 12px;
  font: inherit;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input[type="text"]:focus,
input[type="search"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
input::placeholder, textarea::placeholder { color: var(--fg-dim); }

.form-row { margin-bottom: 12px; }

button,
.btn {
  display: inline-block;
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  color: var(--accent-on);
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: box-shadow 120ms ease, filter 120ms ease;
}
button:hover, .btn:hover {
  filter: brightness(1.08);
  box-shadow: var(--glow-accent);
  text-decoration: none;
  color: var(--accent-on);
}
.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover {
  background: var(--bg-card-alt);
  color: var(--fg-primary);
  box-shadow: none;
}

/* ---------- misc ---------- */

.muted { color: var(--fg-muted); font-size: 13.5px; }
.empty {
  color: var(--fg-muted);
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-card);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ---------- search in topbar (optional) ---------- */

.topbar-search {
  flex: 1;
  max-width: 360px;
  margin: 0 32px;
}
.topbar-search input[type="search"] {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  padding: 7px 12px;
  font-size: 13px;
}

/* ---------- keyframes ---------- */

@keyframes hub-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .topbar-right .status-dot { animation: none; }
}

/* ---------- TV mode (?tv=1 — class set by _base.html before paint) ----------
   Hides nav chrome, enlarges key content. Normal mode untouched. */

html.tv-mode .sidebar { display: none; }
html.tv-mode .layout { grid-template-columns: 1fr; }
html.tv-mode .topbar-right .btn,
html.tv-mode .topbar-right .user-chip { display: none; }
html.tv-mode body { font-size: 16.5px; }
html.tv-mode .content { padding: 28px 36px 48px; }
html.tv-mode .page-title { font-size: 28px; }
html.tv-mode .kpi-value { font-size: 40px; }
html.tv-mode table.data { font-size: 15.5px; }
html.tv-mode table.data th { font-size: 11px; }
html.tv-mode .hub-clock { font-size: 19px; }

/* ---------- responsive (collapse sidebar on narrow screens) ---------- */

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .content { padding: 18px; }
  .topbar { padding: 0 18px; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { padding-top: 6px; }
}
