/* ============================================================
   base.css — TradeAI-Bridge Design System
   Dark · Compact · High-Density · Autonomous Intelligence
   ============================================================ */

:root {
  /* --- Dark System Palette --- */
  --bg:           #06090f;
  --bg-2:         #090d18;
  --panel:        #0b1120;
  --panel-soft:   #0f1828;
  --panel-tint:   rgba(0, 212, 255, 0.05);
  --line:         rgba(0, 200, 240, 0.10);
  --line-2:       rgba(0, 200, 240, 0.06);
  --line-strong:  rgba(0, 212, 255, 0.24);
  --text:         #c5dff7;
  --text-soft:    #7ea8cc;
  --muted:        #3d6080;
  --muted-2:      #284560;
  --navy:         #0a1628;
  --navy-2:       #060e1c;
  --navy-3:       #000000;
  --accent:       #00d4ff;
  --accent-2:     #0099cc;
  --good:         #00e07a;
  --warn:         #f5a23e;
  --bad:          #ff4444;
  --gold:         #f5a23e;
  --cyan:         #00d4ff;

  /* --- Shadows --- */
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow:      0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-md:   0 8px 24px rgba(0, 0, 0, 0.65);
  --shadow-lg:   0 16px 48px rgba(0, 0, 0, 0.75);

  /* --- Radii (sharp/technical) --- */
  --radius-xl: 6px;
  --radius-lg: 5px;
  --radius-md: 4px;

  /* --- Layout --- */
  --sidebar-w:    240px;
  --content-max:  1380px;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }
html { scroll-behavior: smooth; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

a { text-decoration: none; color: inherit; }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

a, button, [role="button"], input, select, textarea {
  touch-action: manipulation;
}

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

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 1000;
  padding: 8px 12px; border-radius: 4px;
  background: var(--panel); color: var(--accent);
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
  transition: top .2s ease;
}
.skip-link:focus-visible { top: 16px; }

.shell { display: block; min-height: 100vh; overflow-x: hidden; }
.sidebar { display: none; }

/* -----------------------------------------
   Top Navigation Bar
   ----------------------------------------- */
.topnav {
  position: sticky; top: 0; z-index: 100;
  background: var(--panel);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 0 0 0 transparent, 0 2px 20px rgba(0, 212, 255, 0.05);
}
.topnav-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 48px;
}
.topnav-brand {
  display: flex; align-items: center; gap: 9px; flex-shrink: 0;
}
.topnav-logo {
  width: 28px; height: 28px; border-radius: 4px;
  object-fit: cover; border: 1px solid var(--line-strong);
}
.topnav-name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700; font-size: .85rem;
  color: var(--accent); letter-spacing: 0.04em;
  text-transform: uppercase;
}
.topnav-links {
  display: flex; align-items: center; gap: 2px; margin-left: 20px;
}
.topnav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 4px;
  font-size: .76rem; font-weight: 600;
  color: var(--muted);
  transition: all .15s ease; white-space: nowrap;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
}
.topnav-link i { font-size: .95rem; color: var(--muted); }
.topnav-link:hover { background: var(--panel-soft); color: var(--text-soft); border-color: var(--line); }
.topnav-link:hover i { color: var(--text-soft); }
.topnav-link.active {
  background: rgba(0, 212, 255, 0.08);
  color: var(--accent);
  font-weight: 700;
  border-color: rgba(0, 212, 255, 0.18);
}
.topnav-link.active i { color: var(--accent); }
.topnav-actions {
  margin-left: auto; display: flex; gap: 6px; align-items: center;
}
.topnav-status {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center;
  font-size: .67rem; color: var(--muted); white-space: nowrap;
  max-width: 340px; line-height: 1.4;
}
.topnav-status-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 3px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-size: .64rem; font-weight: 600; color: var(--muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.topnav-status-item .label { color: var(--muted-2); font-weight: 500; }
.topnav-status-item .value { color: var(--text-soft); }

/* Live system heartbeat on nav */
.topnav-status-item.is-live {
  border-color: rgba(0, 224, 122, 0.25);
  background: rgba(0, 224, 122, 0.05);
  color: var(--good);
}
.topnav-status-item.is-live .value { color: var(--good); }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 14px; margin-bottom: 8px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line-strong);
  overflow: hidden;
}
.brand-mark-sm { width: 30px; height: 30px; border-radius: 3px; }
.brand-logo-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand h1 { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.1; color: var(--text); }
.brand p { margin: 3px 0 0; font-size: 11px; color: var(--muted); }

.sidebar-market-card {
  padding: 10px 12px; border-radius: 4px;
  background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 14px;
}
.sidebar-market-label, .sidebar-section-label {
  font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 600; color: var(--muted);
}
.sidebar-market-main { margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.sidebar-market-sub { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.sidebar-section-label { margin: 14px 8px 6px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-secondary { margin-top: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 4px;
  font-weight: 500; font-size: 12px;
  color: var(--text-soft);
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link i { font-size: 16px; width: 18px; color: var(--muted); }
.nav-link:hover { background: var(--panel-soft); color: var(--text); }
.nav-link.active { color: var(--accent); background: rgba(0, 212, 255, 0.07); }
.nav-link.active i { color: var(--accent); }

.sidebar-footer {
  margin-top: 20px; padding: 12px 8px 4px;
  font-size: 11px; line-height: 1.6; color: var(--muted);
}

/* -----------------------------------------
   Main Layout & Structure
   ----------------------------------------- */
.main { flex: 1; min-width: 0; padding: 18px 24px; overflow-x: hidden; }
.container-shell { max-width: var(--content-max); margin: 0 auto; width: 100%; min-width: 0; }
.container-shell > * { min-width: 0; }
.page-shell-gap > * { scroll-margin-top: 80px; }

.mobile-topbar {
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--panel);
  border-bottom: 1px solid var(--line); margin-bottom: 14px;
}
.mobile-brand { display: flex; align-items: center; gap: 10px; }
.mobile-brand-title { font-weight: 600; color: var(--text); }

.market-strip {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px; align-items: start; margin-bottom: 14px;
}
.market-card {
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow-soft); border-radius: var(--radius-md);
  padding: 12px 14px; display: grid; gap: 4px; align-content: start; min-width: 0;
  transition: border-color .2s ease;
}
.market-card:hover { border-color: var(--line-strong); }

.market-card-label {
  font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 600; color: var(--muted);
}
.market-card-value {
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em;
  line-height: 1.1; font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Consolas, monospace;
  color: var(--text);
}
.market-card-sub { color: var(--muted); font-size: 11px; line-height: 1.4; }
.market-card.tone-dark { background: var(--bg-2); border-color: var(--line-strong); color: var(--text); }
.market-card.tone-dark .market-card-label,
.market-card.tone-dark .market-card-sub { color: var(--muted); }
.market-card-value.good { color: var(--good); }
.market-card-value.warn { color: var(--warn); }
.market-card-value.bad { color: var(--bad); }

.top-card, .card-panel, .rail-card {
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow-soft); border-radius: var(--radius-lg);
  transition: border-color .2s ease;
}
.card-panel:hover, .rail-card:hover { border-color: var(--line-strong); }
.top-card { padding: 14px 16px; margin-bottom: 12px; }

.card-panel, .rail-card, .hero-utility-card, .kpi, .insight-card,
.feed-item, .lane-card, .quick-link, .chip, .pill {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hero-card { position: relative; overflow: hidden; }
.hero-card::after { display: none; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.85fr);
  gap: 14px; align-items: start;
}
.hero-grid > *, .workspace-toolbar > *, .layout-grid > *,
.two-col > *, .review-grid > *, .diagnostic-grid > *, .status-sections > * { min-width: 0; }

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

.eyebrow {
  font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent);
  font-weight: 700; margin-bottom: 6px;
}

.page-title {
  margin: 0 0 6px;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 20px; line-height: 1.2; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text);
}
.page-title, .workspace-title, .workspace-display, .panel-display-title,
.card-title, .section-heading, .mini-section-title { text-wrap: balance; }

.page-desc { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; max-width: 780px; }

.hero-utility { display: grid; gap: 10px; }
.hero-utility-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 12px;
}

.page-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; padding: 12px 16px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--panel); box-shadow: var(--shadow-soft);
}
.page-bar-copy { min-width: 0; display: grid; gap: 3px; }
.page-bar-actions { min-width: 0; display: flex; gap: 6px; }
.page-bar-note {
  min-width: 0; max-width: 340px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--bg-2); font-size: 11px; line-height: 1.5; color: var(--muted);
}

.pill-row-inline { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

.workspace-toolbar {
  display: grid; grid-template-columns: 1fr;
  gap: 8px; align-items: start; margin-bottom: 12px;
}

.section-tabs {
  display: flex; gap: 3px; padding: 4px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-2); box-shadow: inset 0 1px 2px rgba(0,0,0,.3);
}
.section-tab {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 30px; padding: 0 14px; border-radius: 4px;
  border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease;
}
.section-tab:hover { background: var(--panel-soft); color: var(--text-soft); }
.section-tab.is-active {
  background: var(--panel); color: var(--accent);
  border-color: var(--line-strong); font-weight: 700;
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.1);
}

/* -----------------------------------------
   Status & Save Panels
   ----------------------------------------- */
.save-status-panel {
  display: grid; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--panel); box-shadow: var(--shadow-soft);
}
.save-status-top {
  display: flex; justify-content: space-between;
  gap: 10px; align-items: center;
}
.save-status-badge {
  position: relative; display: inline-flex; align-items: center;
  gap: 6px; padding-left: 14px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; line-height: 1.2;
}
.save-status-badge::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; transform: translateY(-50%);
}
.save-status-badge.is-live-pulse::before { animation: livePulse 2s infinite; }
.save-status-meta { color: var(--muted); font-size: 11px; text-align: right; }
.save-status-text { color: var(--text-soft); font-size: 12px; line-height: 1.5; max-width: 54ch; }

.save-tone-idle .save-status-badge,
.save-tone-saved .save-status-badge { color: var(--good); }
.save-tone-dirty .save-status-badge  { color: var(--warn); }
.save-tone-saving .save-status-badge { color: var(--accent); }
.save-tone-error .save-status-badge  { color: var(--bad); }
.save-tone-paused .save-status-badge { color: var(--muted); }

/* -----------------------------------------
   Pills, Chips, Buttons
   ----------------------------------------- */
.hero-utility-label {
  font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 600; color: var(--muted); margin-bottom: 6px;
}
.hero-utility-note { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }

.pills, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pills { margin-top: 10px; }

.pill, .chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 3px;
  border: 1px solid var(--line); background: var(--panel-soft);
  font-size: 11px; font-weight: 600; color: var(--text-soft);
}
.pill strong, .chip strong { font-weight: 600; color: var(--text); }
.pill-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
}
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn-ui {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px; border: none; border-radius: 4px;
  padding: 7px 14px; font-weight: 600; font-size: 12px;
  cursor: pointer; transition: background 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: 0.02em;
}
.btn-ui:hover { filter: brightness(1.1); }
.btn-ui:active { filter: brightness(0.95); }
.btn-ui.primary {
  background: var(--accent); color: #000;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}
.btn-ui.primary:hover { box-shadow: 0 0 18px rgba(0, 212, 255, 0.35); }
.btn-ui.success {
  background: var(--good); color: #000;
  box-shadow: 0 0 12px rgba(0, 224, 122, 0.2);
}
.btn-ui.success:hover { box-shadow: 0 0 18px rgba(0, 224, 122, 0.35); }
.btn-ui.light {
  background: var(--panel-soft); color: var(--text-soft);
  border: 1px solid var(--line);
}
.btn-ui.light:hover { border-color: var(--line-strong); color: var(--text); }

/* -----------------------------------------
   KPIs & Grids
   ----------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px; margin-bottom: 10px; align-items: start;
}
.kpi {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 10px 12px;
  box-shadow: var(--shadow-soft); display: grid; gap: 5px;
  transition: border-color .2s ease;
}
.kpi:hover { border-color: var(--line-strong); }
.kpi::after { content: none; }

.kpi-icon {
  width: 28px; height: 28px; border-radius: 4px;
  display: grid; place-items: center;
  font-size: 14px; color: var(--accent);
  background: rgba(0, 212, 255, 0.07);
  border: 1px solid rgba(0, 212, 255, 0.15);
}
.kpi-label {
  font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 700; color: var(--muted);
}
.kpi-value {
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text); font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Consolas, monospace;
}
.kpi-sub { color: var(--muted); font-size: 11px; line-height: 1.4; }
.kpi-value, .table-ui, .json-box { font-variant-numeric: tabular-nums; }

.overview-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.support-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; margin-bottom: 14px; }
.support-grid > * { min-width: 0; }

.insight-card {
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow-soft); border-radius: var(--radius-lg);
  padding: 14px; display: grid; gap: 8px;
  transition: border-color .2s ease;
}
.insight-card:hover { border-color: var(--line-strong); }
.insight-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.insight-kicker { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.insight-title { margin-top: 3px; font-size: 14px; font-weight: 600; line-height: 1.2; }
.insight-copy { color: var(--muted); font-size: 12px; line-height: 1.5; max-width: 44ch; }
.insight-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.insight-metric { padding: 9px; border-radius: var(--radius-md); background: var(--bg-2); border: 1px solid var(--line); }
.insight-metric-label { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.insight-metric-value { margin-top: 4px; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; font-family: ui-monospace, "JetBrains Mono", Consolas, monospace; }

.layout-grid { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 14px; align-items: start; }
.layout-grid-premium { grid-template-columns: minmax(0, 1.62fr) minmax(300px, 0.92fr); }
.stack { display: grid; gap: 10px; }
.stack > * { min-width: 0; }
.stack-tight { display: grid; gap: 8px; }
.stack-side { position: static; align-self: start; }

.card-panel, .rail-card { padding: 14px 16px; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.section-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 3px;
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.18);
  color: var(--accent); font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}
.card-title { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.card-desc { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* -----------------------------------------
   Badges, Forms, Tables
   ----------------------------------------- */
.mini-badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border-radius: 3px; padding: 3px 7px; font-size: 10px; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap; line-height: 1.1;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.mini-badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.mini-badge-text { white-space: nowrap; }
.mini-badge.good, .mini-badge.success {
  background: rgba(0, 224, 122, 0.1); color: var(--good);
  border-color: rgba(0, 224, 122, 0.22);
}
.mini-badge.warn {
  background: rgba(245, 162, 62, 0.1); color: var(--warn);
  border-color: rgba(245, 162, 62, 0.22);
}
.mini-badge.bad {
  background: rgba(255, 68, 68, 0.1); color: var(--bad);
  border-color: rgba(255, 68, 68, 0.22);
}
.mini-badge.info {
  background: rgba(0, 212, 255, 0.08); color: var(--accent);
  border-color: rgba(0, 212, 255, 0.2);
}

.form-label-ui { font-size: 11px; font-weight: 500; color: var(--text-soft); margin-bottom: 5px; display: block; }
.form-control, .form-select {
  min-height: 34px; border-radius: 4px; border: 1px solid var(--line);
  background: var(--bg-2); padding: 6px 10px; font-size: 12px; color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease; width: 100%;
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.12);
}
textarea.form-control { min-height: 88px; }

.table-wrap {
  overflow: auto; max-width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--panel); box-shadow: var(--shadow-soft);
}
.table-ui { width: 100%; border-collapse: collapse; }
.table-ui tbody tr { transition: background 0.15s ease; }
.table-ui tbody tr:hover { background: rgba(0, 212, 255, 0.04); }
.table-ui th {
  padding: 8px 12px; font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line-strong); font-weight: 700;
  text-align: left; background: var(--bg-2);
}
.table-ui td {
  padding: 8px 12px; border-bottom: 1px solid var(--line-2); font-size: 12px;
  vertical-align: top; color: var(--text); overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.table-ui.compact th, .table-ui.compact td { padding: 6px 10px; }
.table-ui .cell-name strong, .table-ui .cell-target,
.table-ui .cell-state, .table-ui .cell-badge { white-space: nowrap; }
.table-ui .cell-target { min-width: 170px; }
.table-ui .cell-state { min-width: 120px; width: 120px; }
.table-ui .cell-badge { min-width: 80px; width: 80px; }
.table-ui .cell-reasons { min-width: 200px; max-width: 320px; white-space: normal; }

.json-box {
  background: var(--bg-2); color: var(--text-soft); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 12px;
  font: 12px/1.6 ui-monospace, "JetBrains Mono", "Fira Code", Consolas, monospace;
  white-space: pre-wrap; overflow: auto; max-height: 480px;
}

.muted-sm { font-size: 11px; color: var(--muted); }

/* -----------------------------------------
   Components (Lane, Feed, Switch, Timelines)
   ----------------------------------------- */
.lane-card {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px;
  background: var(--panel); box-shadow: var(--shadow-soft);
  transition: border-color .2s ease;
}
.lane-card:hover { border-color: var(--line-strong); }

.feed-list { display: grid; gap: 6px; }
.feed-item {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel);
  padding: 10px 12px; box-shadow: var(--shadow-soft);
  transition: border-color .2s ease;
}
.feed-item:hover { border-color: var(--line-strong); }
.feed-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; font-size: 11px; color: var(--muted); }
.feed-title { font-weight: 700; color: var(--text); font-size: 12px; }
.feed-meta { font-size: 12px; color: var(--text-soft); margin-top: 4px; line-height: 1.5; }

.section-mini-head {
  font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  font-weight: 700; color: var(--muted); margin-bottom: 8px;
}

.switch-row {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--panel); box-shadow: var(--shadow-soft);
  transition: border-color .15s ease;
}
.switch-row:hover { border-color: var(--line-strong); }
.switch-copy { display: grid; gap: 3px; }
.switch-copy .title { font-size: 13px; font-weight: 600; color: var(--text); }
.switch-copy .sub { font-size: 11px; color: var(--muted); line-height: 1.5; }

.switch { position: relative; display: inline-flex; align-items: center; width: 38px; height: 20px; flex: 0 0 38px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-slider {
  position: absolute; inset: 0; border-radius: 4px;
  background: var(--bg-2); border: 1px solid var(--line);
  transition: 0.2s ease; cursor: pointer;
}
.switch-slider:before {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: 0.2s ease;
}
.switch input:checked + .switch-slider {
  background: rgba(0, 224, 122, 0.15);
  border-color: rgba(0, 224, 122, 0.4);
}
.switch input:checked + .switch-slider:before {
  transform: translateX(18px); background: var(--good);
  box-shadow: 0 0 8px rgba(0, 224, 122, 0.4);
}
.switch input:disabled + .switch-slider { opacity: 0.4; cursor: not-allowed; }

.choice-pill {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--panel);
}
.choice-pill .copy { display: grid; gap: 3px; }
.choice-pill .title { font-weight: 600; color: var(--text); font-size: 13px; }
.choice-pill .sub { font-size: 12px; color: var(--muted); line-height: 1.5; }

.tone-success { background: rgba(0,224,122,.08) !important; border-color: rgba(0,224,122,.2) !important; color: var(--good) !important; }
.tone-info    { background: rgba(0,212,255,.07) !important; border-color: rgba(0,212,255,.18) !important; color: var(--accent) !important; }
.tone-warn    { background: rgba(245,162,62,.08) !important; border-color: rgba(245,162,62,.2) !important; color: var(--warn) !important; }

.timeline-list { display: grid; gap: 8px; }
.timeline-item {
  display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel);
  box-shadow: var(--shadow-soft); transition: border-color .15s ease;
}
.timeline-item:hover { border-color: var(--line-strong); }
.timeline-item .time { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.timeline-item .body { font-size: 12px; color: var(--text); line-height: 1.5; }

.diag-card { cursor: pointer; transition: border-color 0.15s ease; }
.diag-card:hover { border-color: var(--line-strong); }

.ghost-note {
  padding: 12px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md); color: var(--muted);
  background: var(--bg-2); line-height: 1.6; font-size: 12px;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.details-panel {
  padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel);
}
.details-summary { list-style: none; cursor: pointer; padding: 12px; font-weight: 600; font-size: 13px; color: var(--text); }
.details-summary::-webkit-details-marker { display: none; }
.details-panel[open] .details-summary { border-bottom: 1px solid var(--line); background: var(--bg-2); }

.diagnostic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.review-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.trade-modal-shell { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow); }

.review-note-list { display: grid; gap: 8px; }
.review-note {
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--bg-2); font-size: 12px; line-height: 1.5; color: var(--text);
}

.table-state { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.table-state-badge {
  display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 3px;
  border: 1px solid transparent; font-size: 10px; font-weight: 700;
  text-transform: uppercase; white-space: nowrap; flex: 0 0 auto; letter-spacing: 0.04em;
}
.table-state-badge.success { background: rgba(0,224,122,.1); border-color: rgba(0,224,122,.22); color: var(--good); }
.table-state-badge.info    { background: rgba(0,212,255,.08); border-color: rgba(0,212,255,.18); color: var(--accent); }
.table-state-badge.warn    { background: rgba(245,162,62,.1); border-color: rgba(245,162,62,.22); color: var(--warn); }
.table-state-badge.neutral { background: var(--bg-2); border-color: var(--line); color: var(--text-soft); }

/* -----------------------------------------
   Lane Toolbar, Filter Tabs, Search (shared)
   ----------------------------------------- */
.lane-toolbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; flex-wrap: wrap; margin-bottom: 8px;
}
.lane-filter-tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.lane-filter-tab {
  display: inline-flex; align-items: center; flex: 0 0 auto; gap: 5px;
  min-height: 30px; padding: 0 11px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text-soft); font-size: 11px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s;
}
.lane-filter-tab:hover { background: var(--panel-soft); border-color: var(--line-strong); }
.lane-filter-tab strong {
  flex: 0 0 auto; min-width: 16px; height: 16px;
  display: grid; place-items: center; border-radius: 3px;
  background: var(--bg-2); color: var(--muted);
  font-size: 9px;
}
.lane-filter-tab.is-active {
  background: rgba(0, 212, 255, 0.1); color: var(--accent);
  border-color: rgba(0, 212, 255, 0.25);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.1);
}
.lane-filter-tab.is-active strong { background: rgba(0,212,255,.15); color: var(--accent); }

.lane-toolbar-controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.lane-search {
  display: flex; align-items: center; gap: 7px; flex: 1 1 260px; min-width: 200px;
  padding: 0 11px; min-height: 32px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--bg-2);
  transition: border-color .15s, box-shadow .15s;
}
.lane-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.12);
}
.lane-search i { color: var(--muted); font-size: 12px; }
.lane-search input {
  width: 100%; border: none; outline: none;
  background: transparent; color: var(--text); font-size: 12px;
}
.lane-sort-select { flex: 0 0 140px; min-width: 130px; }
.lane-filter-summary { margin-bottom: 8px; color: var(--muted); font-size: 11px; line-height: 1.5; }

/* -----------------------------------------
   Banners & Notifications
   ----------------------------------------- */
.save-banner {
  position: fixed; left: 20px; right: 20px; bottom: 20px; z-index: 1040;
  max-width: var(--content-max); margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; padding: 14px 18px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  background: var(--panel-soft); box-shadow: var(--shadow-lg),
  0 0 30px rgba(0, 212, 255, 0.08);
}
.save-banner.is-hidden { display: none; }
.save-banner-copy { min-width: 0; flex: 1; display: grid; gap: 4px; }
.save-banner-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.save-banner-badge {
  display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 3px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  background: rgba(0,212,255,.1); color: var(--accent); white-space: nowrap;
}
.save-banner-meta { font-size: 11px; color: var(--muted); }
.save-banner-title { font-weight: 600; color: var(--text); font-size: 13px; }
.save-banner-text { font-size: 12px; color: var(--muted); line-height: 1.5; }
.save-progress { width: 100%; height: 2px; border-radius: 2px; background: var(--bg-2); overflow: hidden; margin-top: 6px; }
.save-progress-bar { width: 0; height: 100%; background: var(--accent); transition: width 0.25s ease; }
.save-banner-actions { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }

.save-tone-idle .save-banner-badge,
.save-tone-saved .save-banner-badge { background: rgba(0,224,122,.1); color: var(--good); }
.save-tone-dirty .save-banner-badge  { background: rgba(245,162,62,.1); color: var(--warn); }
.save-tone-saving .save-banner-badge { background: rgba(0,212,255,.1); color: var(--accent); }
.save-tone-error .save-banner-badge  { background: rgba(255,68,68,.1); color: var(--bad); }

.detail-list { display: grid; gap: 1px; }
.detail-row {
  display: flex; justify-content: space-between; gap: 20px;
  align-items: flex-start; padding: 8px 0;
  border-bottom: 1px solid var(--line-2);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 12px; color: var(--muted); line-height: 1.5; }
.detail-value {
  font-weight: 600; color: var(--text); text-align: right;
  line-height: 1.5; overflow-wrap: anywhere; font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.autonomy-notification-stack {
  position: fixed; top: 20px; right: 20px; z-index: 1100;
  width: min(340px, calc(100vw - 40px)); display: grid; gap: 8px; pointer-events: none;
}
.autonomy-notification-stack.is-empty { display: none; }
.autonomy-notification {
  pointer-events: auto; width: 100%; display: grid; gap: 5px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  background: var(--panel-soft); box-shadow: var(--shadow-md),
  0 0 20px rgba(0, 212, 255, 0.06);
  padding: 14px; cursor: pointer; transition: border-color 0.15s ease;
}
.autonomy-notification:hover { border-color: var(--accent); box-shadow: var(--shadow-lg), 0 0 24px rgba(0,212,255,.1); }
.autonomy-notification-kicker { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.autonomy-notification-text { font-size: 13px; line-height: 1.5; color: var(--text); }

.metric-list { display: grid; gap: 1px; }
.metric-pair {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line-2);
}
.metric-pair:last-child { border-bottom: none; }
.metric-pair-label { font-size: 12px; color: var(--muted); line-height: 1.5; }
.metric-pair-value { font-weight: 600; color: var(--text); text-align: right; line-height: 1.5; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.day-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.day-chip {
  min-width: 88px; display: grid; gap: 4px; padding: 10px 12px;
  border-radius: var(--radius-lg); border: 1px solid var(--line);
  background: var(--panel); box-shadow: var(--shadow-soft);
  transition: border-color .2s ease;
}
.day-chip:hover { border-color: var(--line-strong); }
.day-chip-date { font-size: 10px; text-transform: uppercase; color: var(--muted); font-weight: 600; letter-spacing: 0.05em; }
.day-chip-value { font-size: 16px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, monospace; }
.day-chip-meta { font-size: 11px; color: var(--muted); line-height: 1.4; }

.day-chip.good  { background: rgba(0,224,122,.06); border-color: rgba(0,224,122,.18); }
.day-chip.good .day-chip-value  { color: var(--good); }
.day-chip.bad   { background: rgba(255,68,68,.06); border-color: rgba(255,68,68,.18); }
.day-chip.bad .day-chip-value   { color: var(--bad); }
.day-chip.neutral { background: rgba(0,212,255,.05); border-color: rgba(0,212,255,.14); }
.day-chip.neutral .day-chip-value { color: var(--accent); }

.rail-card { padding: 14px 16px; }
.rail-list { display: grid; gap: 8px; }
.rail-item { display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--bg-2); }
.rail-item-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 600; color: var(--text); font-size: 13px; }
.rail-item-copy { font-size: 12px; color: var(--muted); line-height: 1.5; }

.quick-link-grid { display: grid; gap: 8px; }
.quick-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel);
  font-weight: 600; font-size: 12px; color: var(--text); box-shadow: var(--shadow-soft);
  transition: border-color 0.2s ease;
}
.quick-link:hover { border-color: var(--line-strong); }
.quick-link i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 4px; background: rgba(0,212,255,.07); color: var(--accent); }

/* -----------------------------------------
   Media Queries
   ----------------------------------------- */
@media (max-width: 1420px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1220px) {
  .market-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-grid-premium { grid-template-columns: 1fr; }
  .stack-side { position: static; }
  .hero-grid { grid-template-columns: 1fr; }
  .workspace-toolbar { grid-template-columns: 1fr; }
  .page-bar { flex-direction: column; }
  .page-bar-actions { justify-items: start; }
}
@media (max-width: 992px) {
  .topnav-inner { padding: 0 14px; }
  .topnav-links { margin-left: 8px; gap: 2px; }
  .topnav-link span { display: none; }
  .topnav-link { padding: 6px 8px; }
  .mobile-topbar { display: none; }
  .main { padding: 12px 14px; }
  .container-shell { max-width: 100%; }
  .top-card, .card-panel, .rail-card { border-radius: var(--radius-md); }
  .top-card { padding: 12px; }
  .page-title { font-size: 18px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .support-grid { grid-template-columns: 1fr; }
  .two-col, .review-grid, .review-grid-wide, .diagnostic-grid { grid-template-columns: 1fr; }
  .save-status-top { flex-direction: column; }
  .save-status-meta { text-align: left; }
  .autonomy-notification-stack { top: auto; bottom: 14px; right: 14px; left: 14px; width: auto; }
  .save-banner { left: 12px; right: 12px; bottom: 12px; flex-direction: column; align-items: stretch; }
}
@media (max-width: 640px) {
  .topnav-actions { display: none; }
  .market-strip, .kpi-grid { grid-template-columns: 1fr; }
  .actions { width: 100%; }
  .actions .btn-ui { width: 100%; }
  .timeline-item { grid-template-columns: 1fr; }
  .insight-metrics { grid-template-columns: 1fr; }
  .save-banner-actions .btn-ui { width: 100%; }
}

/* -----------------------------------------
   Keyframe Animations
   ----------------------------------------- */
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 224, 122, 0.45); }
  70%  { box-shadow: 0 0 0 6px rgba(0, 224, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 224, 122, 0); }
}

@keyframes cyanPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.4); }
  70%  { box-shadow: 0 0 0 6px rgba(0, 212, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0); }
}

@keyframes sysHeartbeat {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes glowBreathe {
  0%, 100% { box-shadow: 0 0 6px rgba(0,212,255,0.12); }
  50%       { box-shadow: 0 0 16px rgba(0,212,255,0.28); }
}

@keyframes dataStream {
  0%   { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-8px); opacity: 0; }
}

/* Live dot utility */
.live-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--good); animation: livePulse 2s infinite;
  vertical-align: middle; margin-right: 5px;
}
.live-dot.cyan { background: var(--accent); animation: cyanPulse 2s infinite; }
.live-dot.warn  { background: var(--warn); animation: sysHeartbeat 1.5s infinite; }

/* -----------------------------------------
   Lifecycle Narrative
   ----------------------------------------- */
.lifecycle-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.lifecycle-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 14px;
  text-align: left; box-shadow: var(--shadow-soft); min-width: 0; overflow: hidden;
  transition: border-color .2s ease;
}
.lifecycle-card:hover { border-color: var(--line-strong); }
.lifecycle-card-header {
  display: flex; align-items: center; gap: 7px;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: .78rem; font-weight: 700; color: var(--text);
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line-2);
}
.lifecycle-card-header i { font-size: 1rem; flex-shrink: 0; }
.lifecycle-learning .lifecycle-card-header i    { color: var(--accent); }
.lifecycle-implemented .lifecycle-card-header i { color: var(--good); }
.lifecycle-blocked .lifecycle-card-header i     { color: var(--bad); }
.lifecycle-insights .lifecycle-card-header i    { color: var(--warn); }

.lifecycle-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.lifecycle-list li {
  font-size: .75rem; line-height: 1.5; color: var(--text-soft);
  padding: 6px 9px; background: var(--bg-2);
  border-radius: 3px; border: 1px solid var(--line-2);
  word-wrap: break-word; overflow-wrap: break-word; white-space: normal;
}
.lifecycle-empty { font-size: .75rem; color: var(--muted); font-style: italic; padding: 8px 0; }
.lifecycle-evolved-row {
  grid-column: 1 / -1; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: var(--radius-lg); border-left: 2px solid var(--warn);
}
.lifecycle-evolved-row .lifecycle-card-header i { color: var(--warn); }

@media (max-width: 900px) { .lifecycle-grid { grid-template-columns: 1fr; } }
