/*
 * ADS — Aero Development System
 * High-end engineering platform theme.
 * 60% black / 30% white / 10% orange
 */

/* ─── DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Surfaces — pure black/gray, no blue tint */
  --bg:   #0a0a0a;
  --s1:   #111111;   /* sidebar */
  --s2:   #161616;   /* card */
  --s3:   #1c1c1c;   /* elevated / hover */
  --s4:   #222222;   /* input, deepest */

  /* Borders */
  --b1: rgba(255,255,255,0.06);
  --b2: rgba(255,255,255,0.09);
  --b3: rgba(255,255,255,0.15);

  /* Text — pure grays, no blue tint */
  --t1: #f0f0f0;
  --t2: #888888;
  --t3: #505050;

  /* Accent */
  --orange:     #ff630f;
  --orange-dim: #c44e0b;
  --orange-bg:  rgba(255,99,15,0.08);
  --orange-glow:rgba(255,99,15,0.18);

  /* Status */
  --sq-bg:  rgba(71,85,105,0.18);   --sq-fg:  #94a3b8;  --sq-bd:  rgba(71,85,105,0.4);
  --sr-bg:  rgba(37,99,235,0.14);   --sr-fg:  #60a5fa;  --sr-bd:  rgba(37,99,235,0.35);
  --sd-bg:  rgba(22,163,74,0.14);   --sd-fg:  #4ade80;  --sd-bd:  rgba(22,163,74,0.35);
  --sp-bg:  rgba(217,119,6,0.14);   --sp-fg:  #fbbf24;  --sp-bd:  rgba(217,119,6,0.35);
  --sf-bg:  rgba(220,38,38,0.14);   --sf-fg:  #f87171;  --sf-bd:  rgba(220,38,38,0.35);
  --sc-bg:  rgba(55,65,81,0.18);    --sc-fg:  #6b7280;  --sc-bd:  rgba(55,65,81,0.4);

  /* Semantic */
  --danger: #ef4444;
  --ok:     #22c55e;
  --info:   #3b82f6;
  --warn:   #f59e0b;
  --purple: #8b5cf6;

  /* Layout */
  --sidebar-w: 224px;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  /* Shadows */
  --sh1: 0 1px 3px rgba(0,0,0,.4);
  --sh2: 0 4px 16px rgba(0,0,0,.5);
  --sh3: 0 10px 36px rgba(0,0,0,.6);

  /* Legacy compat (old code uses these) */
  --black:       #0a0a0a;
  --black-soft:  #111111;
  --black-card:  #161616;
  --white:       #f0f0f0;
  --white-dim:   #888888;
  --white-faint: #505050;
  --efr-orange:  #ff630f;
  --radius:      10px;
  --gap:         1rem;
  --maxw:        1400px;
}

/* ─── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--t1);
  font-family: "Inter", "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--t1);
  line-height: 1.2;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.875rem; }

/* ─── APP SHELL ──────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}
/* sidebar-root is the flex child that reserves sidebar space */
#sidebar-root {
  width: var(--sidebar-w);
  flex-shrink: 0;
}
.app-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.content {
  flex: 1;
  padding: 2rem 2.25rem;
}

/* ─── SIDEBAR ────────────────────────────────────────────── */
/* Mobile topbar hidden by default — only visible on small screens */
.topbar-mobile { display: none; }
.sidebar-overlay { display: none; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--s1);
  border-right: 1px solid var(--b1);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.sb-brand img { height: 26px; width: auto; }
.sb-brand-text { display: flex; flex-direction: column; }
.sb-brand-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--t1);
  letter-spacing: -0.01em;
}
.sb-brand-sub {
  font-size: 0.7rem;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sb-section {
  padding: 1rem 0.75rem 0.25rem;
  flex: 1;
}
.sb-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--t3);
  padding: 0 0.5rem;
  margin-bottom: 0.35rem;
  margin-top: 0.75rem;
}
.sb-section-label:first-child { margin-top: 0; }
.sb-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--r-sm);
  color: var(--t2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.sb-item:hover { background: rgba(255,255,255,0.04); color: var(--t1); }
.sb-item.active {
  background: var(--orange-bg);
  color: var(--orange);
}
.sb-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  width: 2px;
  background: var(--orange);
  border-radius: 0 2px 2px 0;
}
.sb-item svg { flex-shrink: 0; opacity: 0.8; }
.sb-item.active svg { opacity: 1; }
.sb-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--b1);
  flex-shrink: 0;
}
.sb-user-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.5rem;
  margin-bottom: 0.4rem;
}
.sb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--orange-bg);
  border: 1px solid var(--orange-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--orange);
  flex-shrink: 0;
}
.sb-user-info { min-width: 0; }
.sb-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-user-email {
  font-size: 0.7rem;
  color: var(--t3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* HPC reachability pill — sits in the sidebar footer on every page so users
   can tell at a glance whether VPN→HPC is healthy. Driven by /status/hpc;
   green = monitor just SSH'd into Barnard, red = probe failed (VPN down,
   creds missing, host unreachable), gray = first poll not done yet. */
.hpc-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  margin: 0 0.5rem 0.4rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--b1);
  border: 1px solid var(--b1);
  color: var(--t3);
  cursor: help;
  user-select: none;
}
.hpc-indicator .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--t3);
  flex-shrink: 0;
}
.hpc-indicator.ok      { color: var(--ok); border-color: var(--ok); }
.hpc-indicator.ok .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.hpc-indicator.down      { color: var(--danger); border-color: var(--danger); }
.hpc-indicator.down .dot { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.hpc-indicator.unknown      { color: var(--t3); }
.hpc-indicator.unknown .dot { background: var(--t3); }

/* ─── PAGE HEADER ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { line-height: 1; }
.page-header .sub {
  color: var(--t2);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  transition: border-color 0.15s;
}
.card:last-child { margin-bottom: 0; }
.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t2);
  margin-bottom: 1rem;
}

/* ─── STAT GRID ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.stat-card:hover { border-color: var(--b2); box-shadow: var(--sh1); }
.stat-card .sc-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--t3);
}
.stat-card .sc-val {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--t1);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-card .sc-sub {
  font-size: 0.75rem;
  color: var(--t2);
}
.stat-card.accent-orange { border-color: rgba(255,99,15,0.2); }
.stat-card.accent-orange .sc-val { color: var(--orange); }
.stat-card.accent-blue   { border-color: rgba(37,99,235,0.2); }
.stat-card.accent-blue   .sc-val { color: #60a5fa; }
.stat-card.accent-green  { border-color: rgba(22,163,74,0.2); }
.stat-card.accent-green  .sc-val { color: #4ade80; }
.stat-card.accent-red    { border-color: rgba(220,38,38,0.2); }
.stat-card.accent-red    .sc-val { color: #f87171; }

/* ─── DASHBOARD GRID ─────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
  align-items: start;
}
.dash-main { min-width: 0; }
.dash-side { display: flex; flex-direction: column; gap: 1rem; }

/* ─── TABLES ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--b1);
  font-size: 0.875rem;
}
th {
  color: var(--t3);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--s2);
}
td { color: var(--t2); }
td strong, td .t1 { color: var(--t1); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.center, td.center { text-align: center; }

/* ─── STATUS PILLS ───────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status.QUEUED    { background: var(--sq-bg); color: var(--sq-fg); border-color: var(--sq-bd); }
.status.RUNNING   { background: var(--sr-bg); color: var(--sr-fg); border-color: var(--sr-bd); animation: pulse-dot 2s ease-in-out infinite; }
.status.DATA_READY{ background: var(--sd-bg); color: var(--sd-fg); border-color: var(--sd-bd); }
.status.PICS_READY{ background: var(--sp-bg); color: var(--sp-fg); border-color: var(--sp-bd); }
.status.FAILED    { background: var(--sf-bg); color: var(--sf-fg); border-color: var(--sf-bd); }
.status.CANCELLED { background: var(--sc-bg); color: var(--sc-fg); border-color: var(--sc-bd); }
.status.NONE      { background: var(--sc-bg); color: var(--sc-fg); border-color: var(--sc-bd); }

/* TU Dresden cState (status page) */
.status.ok        { background: var(--sd-bg); color: var(--sd-fg); border-color: var(--sd-bd); }
.status.notice    { background: var(--sr-bg); color: var(--sr-fg); border-color: var(--sr-bd); }
.status.disrupted { background: var(--sp-bg); color: var(--sp-fg); border-color: var(--sp-bd); }
.status.down      { background: var(--sf-bg); color: var(--sf-fg); border-color: var(--sf-bd); }
.status.unknown   { background: var(--sc-bg); color: var(--sc-fg); border-color: var(--sc-bd); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ─── SCENARIO CHIPS ─────────────────────────────────────── */
.chip {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin: 0 3px 3px 0;
  border: 1px solid transparent;
}
.chip.normal           { background: rgba(37,99,235,0.14); color: #60a5fa; border-color: rgba(37,99,235,0.3); }
.chip.topspeed_braking { background: rgba(220,38,38,0.14); color: #f87171; border-color: rgba(220,38,38,0.3); }
.chip.curve_low        { background: rgba(22,163,74,0.14); color: #4ade80; border-color: rgba(22,163,74,0.3); }
.chip.curve_high       { background: rgba(217,119,6,0.14); color: #fbbf24; border-color: rgba(217,119,6,0.3); }
.chip.braking          { background: rgba(139,92,246,0.14); color: #c4b5fd; border-color: rgba(139,92,246,0.3); }

/* ─── BUTTONS ────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--r-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.08s;
  text-decoration: none;
  white-space: nowrap;
  background: var(--orange);
  color: #000;
  border-color: var(--orange);
}
button:hover, .btn:hover {
  background: var(--orange-dim);
  border-color: var(--orange-dim);
  box-shadow: 0 0 0 3px var(--orange-glow);
}
button:active, .btn:active { transform: scale(0.98); }
button.secondary, .btn.secondary {
  background: var(--s3);
  color: var(--t1);
  border-color: var(--b2);
}
button.secondary:hover, .btn.secondary:hover {
  background: var(--s4);
  border-color: var(--b3);
  box-shadow: none;
}
button.danger, .btn.danger {
  background: rgba(220,38,38,0.15);
  color: var(--danger);
  border-color: rgba(220,38,38,0.35);
}
button.danger:hover, .btn.danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.2);
}
button:disabled, .btn.disabled {
  background: var(--s3);
  color: var(--t3);
  border-color: var(--b1);
  cursor: not-allowed;
  box-shadow: none;
}
button:disabled:hover { transform: none; }

/* Icon button (cancel/remove) */
.icon-btn {
  background: rgba(220,38,38,0.12);
  color: #f87171;
  border: 1px solid rgba(220,38,38,0.3);
  border-radius: var(--r-sm);
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}
.icon-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.2);
}

/* View/results button */
.view-btn {
  background: rgba(217,119,6,0.1);
  color: #fbbf24;
  border: 1px solid rgba(217,119,6,0.3);
  border-radius: var(--r-sm);
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.12s, box-shadow 0.12s;
}
.view-btn:hover {
  background: rgba(217,119,6,0.2);
  box-shadow: 0 0 0 3px rgba(217,119,6,0.15);
}

/* ─── FORMS & INPUTS ─────────────────────────────────────── */
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="search"],
input[type="tel"], select, textarea {
  width: 100%;
  background: var(--s4);
  color: var(--t1);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-glow);
}
input::placeholder, textarea::placeholder { color: var(--t3); }
input:disabled { opacity: 0.5; cursor: not-allowed; }
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23484860' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
input[type="search"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23484860' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 0.75rem center; padding-left: 2.25rem; }

input[type="file"] {
  background: var(--s4);
  color: var(--t2);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.75rem;
  width: 100%;
  font-size: 0.875rem;
}
input[type="file"]::file-selector-button {
  background: var(--orange);
  color: #000;
  border: none;
  border-radius: var(--r-xs);
  padding: 0.3rem 0.75rem;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  margin-right: 0.75rem;
  transition: background 0.12s;
}
input[type="file"]::file-selector-button:hover { background: var(--orange-dim); }

/* Toggle row */
.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.85rem;
  color: var(--t1);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s;
}
.toggle-row:hover { border-color: var(--orange); }
.toggle-row:has(input:checked) {
  background: var(--orange-bg);
  border-color: rgba(255,99,15,0.4);
  color: var(--orange);
}
.toggle-row input[type="checkbox"] {
  width: 1rem; height: 1rem; margin: 0;
  accent-color: var(--orange); cursor: pointer;
}

/* Form grid */
.form-grid { display: grid; gap: 0.75rem; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; }
.form-hint { font-size: 0.75rem; color: var(--t3); margin-top: 0.25rem; }

/* ─── ALERTS ─────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: var(--r-sm);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.alert:last-child { margin-bottom: 0; }
.alert.error  { background: rgba(220,38,38,0.1);  color: #fca5a5; border-color: rgba(220,38,38,0.3); }
.alert.ok     { background: rgba(22,163,74,0.1);  color: #86efac; border-color: rgba(22,163,74,0.3); }
.alert.info   { background: rgba(37,99,235,0.08); color: #93c5fd; border-color: rgba(37,99,235,0.25); }

/* ─── HOVER POPOVER (status history) ────────────────────── */
.hover-cell { position: relative; }
.hover-cell .popover {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--s3);
  border: 1px solid var(--b2);
  color: var(--t2);
  padding: 0.75rem;
  font-size: 0.8rem;
  min-width: 220px;
  z-index: 999;
  box-shadow: var(--sh2);
  border-radius: var(--r-sm);
}
.hover-cell:hover .popover { display: block; }
.popover .row { margin-bottom: 6px; display: flex; align-items: center; gap: 0.5rem; }
.popover .row:last-child { margin-bottom: 0; }
.popover .row b { color: var(--t1); }
.popover .ts { color: var(--t3); font-size: 0.75rem; }
.popover .runtime {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--b1);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--t1);
  font-size: 0.8rem;
}

/* ─── DROPDOWN MENU ──────────────────────────────────────── */
.menu {
  position: absolute;
  z-index: 500;
  background: var(--s3);
  border: 1px solid var(--b3);
  border-radius: var(--r-sm);
  padding: 0.5rem;
  box-shadow: var(--sh3);
  min-width: 200px;
  top: calc(100% + 6px);
  right: 0;
}
.menu label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.35rem 0.5rem;
  color: var(--t2);
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--r-xs);
  transition: background 0.1s, color 0.1s;
}
.menu label:hover { background: rgba(255,255,255,0.05); color: var(--t1); }
.menu input[type="checkbox"] { width: auto; accent-color: var(--orange); }
.menu .group-label {
  color: var(--t3);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.5rem 0.2rem;
  margin-top: 0.25rem;
}
.menu .group-label:first-child { margin-top: 0; }

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fade-in 0.15s ease;
}
.modal {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: var(--r-lg);
  padding: 1.75rem;
  width: min(560px, 90vw);
  box-shadow: var(--sh3);
  animation: slide-up 0.2s ease;
}
.modal h2 { margin-bottom: 1.25rem; }
.modal .log {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--t2);
}
.modal .log .step { display: flex; align-items: center; gap: 0.5rem; }
.modal .log .step::before {
  content: "✓";
  color: var(--ok);
  font-weight: 700;
  font-size: 0.9rem;
}

/* ─── UPLOAD DROP ZONE ───────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--b2);
  border-radius: var(--r-lg);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--orange);
  background: var(--orange-bg);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.drop-zone .dz-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}
.drop-zone .dz-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 0.35rem;
}
.drop-zone .dz-sub { font-size: 0.83rem; color: var(--t3); }
.drop-zone .dz-badge {
  display: inline-block;
  margin-top: 0.75rem;
  background: var(--s3);
  border: 1px solid var(--b2);
  border-radius: var(--r-sm);
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  color: var(--t2);
  font-family: ui-monospace, monospace;
}

/* Upload file cards */
.file-cards { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }
.file-card {
  background: var(--s3);
  border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: border-color 0.12s;
}
.file-card:hover { border-color: var(--b2); }
.file-card-icon { font-size: 1.25rem; flex-shrink: 0; opacity: 0.6; }
.file-card-info { flex: 1; min-width: 0; }
.file-card-name { font-size: 0.875rem; font-weight: 600; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card-meta { font-size: 0.75rem; color: var(--t3); margin-top: 0.15rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.file-card-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.file-card-scenarios { position: relative; }

/* ─── RESULTS / KPI ──────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r);
  padding: 1.25rem 1rem;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { border-color: var(--b2); box-shadow: var(--sh1); }
.kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--t3);
  margin-bottom: 0.6rem;
}
.kpi-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--t1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.kpi-unit {
  font-size: 0.72rem;
  color: var(--t3);
  margin-top: 0.35rem;
}
.kpi-card.pending .kpi-val { color: var(--t3); font-size: 1.25rem; }

/* ─── TIMELINE (results) ─────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 1.75rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--b2);
}
.tl-item {
  position: relative;
  margin-bottom: 1.25rem;
}
.tl-item:last-child { margin-bottom: 0; }
.tl-dot {
  position: absolute;
  left: -1.75rem;
  top: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--s1);
  border: 2px solid var(--b2);
}
.tl-dot.active { border-color: var(--orange); background: var(--orange); }
.tl-status { margin-bottom: 0.2rem; }
.tl-ts { font-size: 0.75rem; color: var(--t3); }

/* ─── RESULTS META ───────────────────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.meta-item { }
.meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--t3);
  margin-bottom: 0.35rem;
}
.meta-val {
  font-size: 0.9rem;
  color: var(--t1);
  font-weight: 500;
}
.meta-val.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.83rem;
}

/* ─── TU STATUS TIMELINE ─────────────────────────────────── */
.tu-status-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--b1);
}
.tu-status-row:last-child { border-bottom: none; }
.tu-status-row .label { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.tu-status-row .label .name { color: var(--t1); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tu-timeline { display: flex; width: 100%; height: 16px; border-radius: var(--r-xs); overflow: hidden; background: var(--s3); }
.tu-timeline .tick { flex: 1 1 0; min-width: 1px; }
.tu-timeline .tick.ok        { background: var(--ok); }
.tu-timeline .tick.notice    { background: var(--info); }
.tu-timeline .tick.disrupted { background: var(--warn); }
.tu-timeline .tick.down      { background: var(--danger); }
.tu-timeline .tick.unknown   { background: var(--s4); }
.tu-issue-list { margin: 0.35rem 0 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--t3); }
.tu-issue-list li::before { content: "· "; }

/* ─── LEADERBOARD ────────────────────────────────────────── */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
}
.rank-badge.r1 { background: rgba(251,191,36,0.2); color: #fbbf24; border: 1px solid rgba(251,191,36,0.4); }
.rank-badge.r2 { background: rgba(148,163,184,0.15); color: #94a3b8; border: 1px solid rgba(148,163,184,0.3); }
.rank-badge.r3 { background: rgba(180,83,9,0.15); color: #fb923c; border: 1px solid rgba(180,83,9,0.3); }
.rank-badge.rn { background: var(--s3); color: var(--t3); border: 1px solid var(--b1); }

/* ─── MISC UTILITIES ─────────────────────────────────────── */
.muted { color: var(--t2); font-size: 0.85rem; }
.empty { color: var(--t3); text-align: center; padding: 2.5rem 1rem; font-size: 0.9rem; }
.divider { height: 1px; background: var(--b1); margin: 1rem 0; }
.section-gap { margin-bottom: 1.5rem; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge.admin { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(255,99,15,0.3); }

/* ─── LOGIN PAGE ─────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 20% 120%, rgba(255,99,15,0.06) 0%, transparent 70%),
    var(--bg);
  padding: 2rem 1rem;
}
.login-card {
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sh3);
}
.login-logo {
  display: block;
  margin: 0 auto 1.5rem;
  height: 60px;
  width: auto;
}
.login-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.login-sub { text-align: center; color: var(--t2); font-size: 0.85rem; margin-bottom: 1.75rem; }

/* ─── DANGER CARD ────────────────────────────────────────── */
.card.danger-zone {
  border-color: rgba(220,38,38,0.25);
}
.card.danger-zone h2 { color: var(--danger); }

/* ─── ANIMATIONS ─────────────────────────────────────────── */
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer  {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--s3) 25%, var(--s4) 50%, var(--s3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
  color: transparent;
  user-select: none;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-side { order: -1; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid  { grid-template-columns: repeat(3, 1fr); }
  .meta-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  #sidebar-root { width: 0; } /* no space reserved — sidebar is off-canvas */
  .sidebar {
    left: -100%;
    transition: left 0.25s ease;
    z-index: 300;
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }
  .app-body { padding-top: 52px; }
  .topbar-mobile {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--s1);
    border-bottom: 1px solid var(--b1);
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    z-index: 200;
  }
  .topbar-mobile .mb-brand {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.95rem;
  }
  .topbar-mobile .mb-brand img { height: 22px; }
  .hamburger {
    background: none;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    color: var(--t2);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .hamburger:hover { color: var(--t1); box-shadow: none; }
  .content { padding: 1.25rem 1rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .kpi-grid  { grid-template-columns: repeat(2, 1fr); }
  .meta-grid { grid-template-columns: 1fr; }
  th, td { padding: 0.55rem 0.5rem; }
  .hide-mobile { display: none !important; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .tu-status-row { grid-template-columns: 140px 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .kpi-grid  { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 1.75rem 1.25rem; }
}
