:root {
  color-scheme: dark;

  --bg-base: #07101a;
  --bg-elevated: #0b1521;
  --bg-strong: #101c2a;
  --bg-panel: rgba(14, 24, 38, 0.82);
  --bg-panel-strong: rgba(18, 31, 47, 0.92);
  --bg-panel-soft: rgba(17, 28, 44, 0.72);
  --bg-input: rgba(11, 20, 31, 0.9);
  --bg-code: rgba(8, 15, 24, 0.96);
  --overlay-subtle: rgba(255, 255, 255, 0.03);
  --overlay-strong: rgba(255, 255, 255, 0.07);

  --text-primary: #edf4ff;
  --text-secondary: #9babc0;
  --text-tertiary: #6f8198;
  --text-muted: #5f7188;

  --border-subtle: rgba(132, 158, 191, 0.14);
  --border-strong: rgba(146, 176, 214, 0.22);
  --border-accent: rgba(120, 168, 237, 0.3);

  --accent: #78a8ed;
  --accent-strong: #9dc5ff;
  --accent-soft: rgba(120, 168, 237, 0.18);
  --accent-glow: rgba(120, 168, 237, 0.18);

  --status-neutral: #7f96b5;
  --status-info: #7ab5ff;
  --status-success: #4bc78e;
  --status-warning: #efb564;
  --status-danger: #ee7a7a;
  --status-critical: #ff616d;

  --shadow-0: none;
  --shadow-1: 0 10px 28px rgba(0, 0, 0, 0.22);
  --shadow-2: 0 18px 48px rgba(0, 0, 0, 0.28);
  --shadow-3: 0 28px 72px rgba(0, 0, 0, 0.38);

  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 30px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;

  --font-sans: "Segoe UI Variable Display", "IBM Plex Sans", "Bahnschrift", "Trebuchet MS", sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", "Consolas", monospace;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 28px;

  --line-tight: 1.2;
  --line-copy: 1.55;

  --header-height: 56px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-base);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--line-copy);
  color: var(--text-primary);
  background:
    radial-gradient(circle at 0% 0%, rgba(88, 140, 225, 0.14), transparent 26%),
    radial-gradient(circle at 100% 0%, rgba(79, 210, 176, 0.08), transparent 18%),
    radial-gradient(circle at 50% 100%, rgba(255, 97, 109, 0.06), transparent 24%),
    linear-gradient(180deg, #08111b 0%, #09121d 34%, #07101a 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018), rgba(255, 255, 255, 0.018)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 100% 100%, 64px 64px, 64px 64px;
  mask-image: radial-gradient(circle at center, black 28%, transparent 88%);
  opacity: 0.08;
}

body[data-busy="true"] .topbar {
  border-bottom-color: rgba(120, 168, 237, 0.18);
}

body[data-busy="true"] .card-panel {
  box-shadow:
    0 0 0 1px rgba(120, 168, 237, 0.05),
    var(--shadow-2);
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
pre {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: rgba(157, 197, 255, 0.78);
  box-shadow:
    0 0 0 1px rgba(157, 197, 255, 0.78),
    0 0 0 4px rgba(120, 168, 237, 0.16);
}

/* ── App header ─────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  border-bottom: 1px solid var(--border-subtle);
  background:
    linear-gradient(180deg, rgba(8, 15, 24, 0.97), rgba(10, 17, 26, 0.94)),
    var(--bg-base);
  backdrop-filter: blur(20px);
}

.app-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(154, 183, 224, 0.2), transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  height: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.header-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
  line-height: 1.15;
}

.header-eyebrow {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.header-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 var(--space-2);
}

.header-nav::-webkit-scrollbar {
  display: none;
}

.header-nav-link {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  font-weight: 520;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  transition:
    color 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease;
}

.header-nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(154, 183, 224, 0.1);
}

.header-nav-link.active {
  color: var(--text-primary);
  background:
    linear-gradient(180deg, rgba(120, 168, 237, 0.12), rgba(120, 168, 237, 0.04)),
    rgba(255, 255, 255, 0.04);
  border-color: rgba(120, 168, 237, 0.22);
  font-weight: 590;
}

.header-end {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.header-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-session {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.session-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.session-input {
  width: 160px;
  min-height: 34px;
  font-size: var(--text-sm);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
}

.session-logout {
  display: none;
}

.header-session.connected .session-form {
  display: none;
}

.header-session.connected .session-logout {
  display: flex;
}

.compact-btn {
  min-height: 34px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

/* ── Tier pill (header) ──────────────────────────────────────── */

.tier-pill {
  font-size: var(--text-xs);
  min-height: 24px;
}

.tier-pill.hidden {
  display: none;
}

/* ── Welcome overlay ─────────────────────────────────────────── */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 16, 26, 0.85);
  backdrop-filter: blur(12px);
  animation: welcome-fade-in 0.35s ease-out;
}

.welcome-overlay.hidden {
  display: none;
}

@keyframes welcome-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-9) var(--space-8);
  max-width: 420px;
  text-align: center;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  animation: welcome-card-in 0.4s ease-out;
}

@keyframes welcome-card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-tier-badge {
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-4);
}

.welcome-heading {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
}

.welcome-sub {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.welcome-dismiss {
  margin-top: var(--space-3);
}

/* ── Workspace (full-width, no sidebar) ─────────────────────── */

.workspace-full {
  min-height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: var(--header-height);
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: var(--space-5);
  padding: var(--space-6) var(--space-7) var(--space-5);
  background:
    linear-gradient(180deg, rgba(7, 16, 26, 0.92), rgba(7, 16, 26, 0.68) 72%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(132, 158, 191, 0.08);
}

.topbar-copy {
  min-width: 0;
}

.topbar-copy h2 {
  margin: 0;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.02;
  letter-spacing: -0.04em;
  font-weight: 620;
}

.topbar .meta-line {
  margin-top: var(--space-2);
  max-width: 820px;
}

.content {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: var(--space-6) var(--space-7) var(--space-9);
}

/* ── Cards & panels ─────────────────────────────────────────── */

.card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 24%),
    linear-gradient(180deg, var(--bg-panel), var(--bg-panel-strong));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 36%);
}

.card {
  padding: var(--space-5);
}

.card.compact {
  padding: var(--space-5);
}

.card-panel {
  min-height: 100%;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: var(--space-4);
}

.card-title-group {
  min-width: 0;
}

.card h2,
.card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 590;
}

/* ── Sections ──────────────────────────────────────────────── */

.section-block {
  margin-bottom: var(--space-7);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.section-header h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 620;
}

.section-note {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  text-align: right;
}

/* ── Typography helpers ────────────────────────────────────── */

.eyebrow {
  margin-bottom: var(--space-2);
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.label,
.meta-line,
.field span {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.meta-line {
  line-height: 1.4;
}

.field {
  display: grid;
  gap: var(--space-2);
}

.compact-field {
  min-width: 180px;
}

/* ── Buttons & inputs ──────────────────────────────────────── */

.toolbar,
.button-row {
  display: flex;
  align-items: end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent),
    var(--bg-input);
  color: var(--text-primary);
  padding: 0 var(--space-4);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

input::placeholder {
  color: var(--text-muted);
}

button {
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent),
    rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-1);
}

button.primary {
  border-color: rgba(120, 168, 237, 0.42);
  background:
    linear-gradient(180deg, rgba(157, 197, 255, 0.15), rgba(120, 168, 237, 0.04)),
    rgba(120, 168, 237, 0.14);
  color: #f5f9ff;
  box-shadow: 0 8px 24px rgba(37, 85, 155, 0.28);
}

button.secondary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent),
    rgba(255, 255, 255, 0.02);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
  box-shadow: var(--shadow-0);
}

/* ── Note / info ───────────────────────────────────────────── */

.note {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(154, 183, 224, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
}

/* ── Summary tiles ─────────────────────────────────────────── */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.summary-tile {
  position: relative;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(154, 183, 224, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    var(--bg-panel-soft);
}

.summary-tile::after {
  content: "";
  position: absolute;
  inset: 1px auto auto 1px;
  width: 42%;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.22), transparent);
}

.summary-tile strong {
  display: block;
  margin-top: var(--space-2);
  font-size: 20px;
  font-weight: 620;
  letter-spacing: -0.03em;
}

.summary-tile[data-tone="success"] {
  border-color: rgba(75, 199, 142, 0.2);
}

.summary-tile[data-tone="warning"] {
  border-color: rgba(239, 181, 100, 0.22);
}

.summary-tile[data-tone="danger"] {
  border-color: rgba(255, 97, 109, 0.24);
}

/* ── Grid layouts ──────────────────────────────────────────── */

.grid {
  display: grid;
  gap: var(--space-5);
}

.overview-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.two-up {
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
}

/* ── Badges & pills ────────────────────────────────────────── */

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 28px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(154, 183, 224, 0.16);
  background: rgba(255, 255, 255, 0.04);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge::before,
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
  opacity: 0.72;
}

.badge.neutral,
.pill.neutral,
.badge.info,
.pill.info {
  color: var(--status-info);
  background: rgba(122, 181, 255, 0.12);
  border-color: rgba(122, 181, 255, 0.2);
}

.badge.green,
.pill.green,
.badge.success,
.pill.success {
  color: var(--status-success);
  background: rgba(75, 199, 142, 0.12);
  border-color: rgba(75, 199, 142, 0.2);
}

.badge.amber,
.pill.amber,
.badge.warn,
.pill.warn {
  color: var(--status-warning);
  background: rgba(239, 181, 100, 0.12);
  border-color: rgba(239, 181, 100, 0.22);
}

.badge.red,
.pill.red,
.badge.black,
.pill.black,
.badge.danger,
.pill.danger,
.badge.critical,
.pill.critical {
  color: var(--status-critical);
  background: rgba(255, 97, 109, 0.12);
  border-color: rgba(255, 97, 109, 0.24);
}

/* Header badge (smaller for fit) */
.header-session .badge {
  min-height: 24px;
  font-size: 10px;
}

/* ── Lists ─────────────────────────────────────────────────── */

.list {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.list.empty,
.key-value.empty,
.detail.empty {
  color: var(--text-secondary);
}

.list button,
.list .item {
  position: relative;
  width: 100%;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  text-align: left;
  border: 1px solid rgba(154, 183, 224, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 26%),
    rgba(9, 18, 29, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.list button:hover,
.list .item:hover {
  border-color: rgba(154, 183, 224, 0.24);
}

.list button.active {
  border-color: rgba(120, 168, 237, 0.42);
  background:
    linear-gradient(180deg, rgba(120, 168, 237, 0.18), rgba(120, 168, 237, 0.03)),
    rgba(10, 20, 33, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(120, 168, 237, 0.1);
}

.list button strong,
.list .item strong {
  display: block;
  font-size: var(--text-md);
  line-height: 1.35;
  font-weight: 590;
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: var(--space-4);
}

.item-copy {
  min-width: 0;
}

.item-copy .eyebrow {
  margin-bottom: var(--space-2);
}

.item-body {
  margin-top: var(--space-4);
}

.item-footer {
  margin-top: var(--space-4);
}

.list-nav {
  gap: var(--space-2);
}

/* ── Key-Value ─────────────────────────────────────────────── */

.key-value {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.metric-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.metric-cell {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(154, 183, 224, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    rgba(8, 15, 24, 0.64);
}

.metric-cell span {
  display: block;
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.metric-cell strong {
  display: block;
  margin-top: var(--space-2);
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 620;
}

.kv-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid rgba(154, 183, 224, 0.08);
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-row .label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── Detail sections ───────────────────────────────────────── */

.detail {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.detail-stack {
  display: grid;
  gap: var(--space-3);
}

.detail-section {
  border-radius: var(--radius-md);
  border: 1px solid rgba(154, 183, 224, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 24%),
    rgba(9, 18, 29, 0.7);
  padding: var(--space-4);
}

.detail-section h4 {
  margin: 0 0 var(--space-3);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.subpanel {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(154, 183, 224, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 24%),
    rgba(7, 15, 24, 0.52);
}

.subpanel h4 {
  margin: 0 0 var(--space-3);
  font-size: 14px;
  font-weight: 590;
  letter-spacing: -0.01em;
}

.summary-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding-left: calc(var(--space-4) + 2px);
  color: var(--text-secondary);
}

.summary-list li {
  line-height: 1.55;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

pre {
  margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(154, 183, 224, 0.12);
  background: var(--bg-code);
  color: #d7e5fb;
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  border: 1px dashed rgba(154, 183, 224, 0.16);
  background: rgba(255, 255, 255, 0.02);
}

.empty-state strong {
  font-size: var(--text-lg);
  font-weight: 580;
}

.empty-state p {
  margin: 0;
  color: var(--text-secondary);
}

/* ── Status stacks ─────────────────────────────────────────── */

.status-stack,
.meta-stack {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.inline-stat {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.inline-stat strong {
  color: var(--text-primary);
  font-size: var(--text-md);
}

/* ── Meta grids in lists ───────────────────────────────────── */

.list .meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
}

.list .meta-grid span {
  display: block;
  color: var(--text-tertiary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.list .meta-grid strong {
  margin-top: 2px;
  font-size: var(--text-md);
  font-weight: 570;
  text-transform: none;
  letter-spacing: normal;
}

.detail-section .item + .item {
  margin-top: var(--space-3);
}

.detail-section .item {
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(154, 183, 224, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

.detail-section .item-footer pre,
.detail-section > pre,
.subpanel pre {
  margin-top: var(--space-3);
}

/* ── Breadcrumbs ───────────────────────────────────────────── */

.breadcrumb-line {
  display: flex;
  align-items: center;
  gap: 0;
  color: var(--text-tertiary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.breadcrumb-link {
  color: var(--accent);
  text-decoration: none;
  transition: color 120ms ease;
}

.breadcrumb-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.breadcrumb-sep {
  margin: 0 var(--space-2);
  color: var(--text-muted);
  user-select: none;
}

.breadcrumb-current {
  color: var(--text-secondary);
}

/* ── Page loading ──────────────────────────────────────────── */

.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-height: 200px;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.loading-bar {
  width: 120px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--bg-strong);
  overflow: hidden;
  position: relative;
}

.loading-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes loading-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ── Toolbar & routing ─────────────────────────────────────── */

.topbar-routed {
  align-items: flex-start;
  gap: var(--space-4);
}

.toolbar-routed {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.field.grow,
.compact-field.grow {
  flex: 1 1 320px;
}

.content-routed {
  display: grid;
  gap: var(--space-5);
}

.page-content {
  display: grid;
  gap: var(--space-5);
}

/* ── Scope switcher (in-page) ──────────────────────────────── */

.scope-switcher {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 1360px) {
  .overview-grid,
  .two-up {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .header-inner {
    padding: 0 var(--space-4);
    gap: var(--space-3);
  }

  .header-nav-link {
    padding: 0 var(--space-2);
    font-size: var(--text-xs);
  }

  .session-input {
    width: 120px;
  }

  .topbar {
    padding: var(--space-5) var(--space-5) var(--space-4);
  }

  .content {
    padding: var(--space-4) var(--space-5) var(--space-7);
  }
}

@media (max-width: 760px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
  }

  .app-header {
    height: auto;
  }

  .header-nav {
    order: 3;
    width: 100%;
    padding: var(--space-2) 0 0;
  }

  .topbar {
    top: 0;
    align-items: start;
  }

  .toolbar {
    width: 100%;
  }

  .compact-field {
    min-width: 100%;
  }

  .summary-grid,
  .metric-band,
  .list .meta-grid {
    grid-template-columns: 1fr;
  }

  .kv-row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  .session-input {
    width: 100px;
  }
}

/* ── Footer ── */

.app-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  padding: var(--space-4) var(--space-6);
}

.footer-inner {
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.footer-brand {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.footer-nav {
  display: flex;
  gap: var(--space-5);
}

.footer-nav a {
  font-size: 12px;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-nav a:hover {
  color: var(--accent);
}

/* ── Legal pages (ToS / Privacy) ── */

.legal-page {
  max-width: 780px;
  margin: 0 auto;
  padding: var(--space-6) 0;
}

.legal-header {
  margin-bottom: var(--space-7);
}

.legal-header .eyebrow {
  margin-bottom: var(--space-2);
}

.legal-header h2 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-2);
}

.legal-updated {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.legal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.legal-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-3);
}

.legal-section p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 var(--space-3);
}

.legal-section p:last-child {
  margin-bottom: 0;
}

.legal-section ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.legal-section li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.legal-section li strong {
  color: var(--text-primary);
  font-weight: 500;
}

.legal-section a {
  color: var(--accent);
  text-decoration: none;
}

.legal-section a:hover {
  text-decoration: underline;
}

.legal-footer {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

.legal-nav-link {
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.legal-nav-link:hover {
  text-decoration: underline;
}

/* ── PHP dashboard additions ───────────────────────────────── */

.list a.item {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.list a.item:hover {
  border-color: rgba(154, 183, 224, 0.24);
}

.list .item.active {
  border-color: rgba(120, 168, 237, 0.42);
  background:
    linear-gradient(180deg, rgba(120, 168, 237, 0.18), rgba(120, 168, 237, 0.03)),
    rgba(10, 20, 33, 0.92);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 0 0 1px rgba(120, 168, 237, 0.1);
}

.scope-switcher a.item {
  display: block;
  text-decoration: none;
  color: inherit;
}
