/* ==============================================
   PilotOS Console — shared shell styles
   Used by /console, /atlas, /compass, /rennick, /nexus
   Pairs with doc-style.css (which provides :root vars + pmark animations)
   ============================================== */

:root {
  --rail-w: 240px;
  --inspector-w: 360px;
  --row-h: 44px;
}

body {
  overflow: hidden;
  height: 100vh;
}
body::before { display: none; }

.console-app {
  display: grid;
  grid-template-rows: 52px 1fr 28px;
  grid-template-columns: var(--rail-w) 1fr var(--inspector-w);
  grid-template-areas:
    "top top top"
    "rail main inspector"
    "status status status";
  height: 100vh;
  background: var(--bg);
}

/* ================= TOP BAR ================= */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  padding-right: 1rem;
  border-right: 1px solid var(--border);
  transition: opacity 0.15s;
}
.topbar .brand:hover { opacity: 0.85; }
.topbar .brand .dot { color: var(--gold); }
.topbar .brand-mark {
  width: 26px;
  height: 26px;
  display: block;
  flex-shrink: 0;
}

.portfolio-switcher {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.portfolio-switcher:hover { border-color: var(--gold-dim); }
.portfolio-switcher .pf-icon {
  width: 18px; height: 18px;
  background: linear-gradient(135deg, var(--gold), #c87800);
  border-radius: 3px;
  display: grid; place-items: center;
  color: #0a0a0b; font-weight: 800; font-size: 0.65rem;
  font-family: var(--mono);
}
.portfolio-switcher .pf-name { font-weight: 600; color: var(--text); }
.portfolio-switcher .pf-caret { color: var(--text-muted); font-size: 0.7rem; }

.topbar .breadcrumbs {
  display: flex; gap: 0.5rem; align-items: center;
  font-size: 0.82rem; color: var(--text-muted);
  font-family: var(--mono);
}
.topbar .breadcrumbs .sep { color: var(--border); }
.topbar .breadcrumbs .here { color: var(--text-dim); }

.topbar .spacer { flex: 1; }

.top-actions { display: flex; gap: 0.5rem; align-items: center; }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.icon-btn:hover { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.icon-btn.has-badge { position: relative; }
.icon-btn .badge {
  position: absolute; top: 4px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
}

.user-chip {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.5rem 0.3rem 0.3rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
}
.user-chip:hover { border-color: var(--gold-dim); }
.user-avatar {
  width: 24px; height: 24px;
  border-radius: 3px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 0.7rem;
  font-family: var(--mono);
}
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--text); }

/* ================= LEFT RAIL ================= */
.rail {
  grid-area: rail;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}
.rail-section {
  margin-bottom: 1.25rem;
}
.rail-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 0.35rem 0.65rem;
  margin-bottom: 0.25rem;
}
.rail-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: 0;
  transition: all 0.12s;
}
.rail-item:hover {
  background: var(--bg-card);
  color: var(--text);
}
.rail-item.active {
  background: var(--bg-card);
  color: var(--text);
  border-left-color: var(--gold);
}
.rail-item .icon {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 3px;
}
.rail-item.atlas .icon { background: rgba(244,163,0,0.12); color: var(--gold); }
.rail-item.compass .icon { background: rgba(99,102,241,0.15); color: #818cf8; }
.rail-item.rennick .icon { background: rgba(52,211,153,0.12); color: var(--green); }
.rail-item.nexus .icon { background: rgba(244,163,0,0.18); color: var(--gold-bright); }
.rail-item.wing .icon { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border); }

/* CodePilot — first wing live (2026-05-04). Stands out from the "coming soon" wings. */
.rail-item.codepilot .icon {
  background: rgba(34, 211, 238, 0.16);
  color: #22d3ee;
  border: 1px solid rgba(34, 211, 238, 0.32);
}
.rail-item.codepilot .live-pill {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #22d3ee;
  background: rgba(34, 211, 238, 0.1);
  padding: 0.12rem 0.4rem;
  border-radius: 3px;
  border: 1px solid rgba(34, 211, 238, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  text-transform: uppercase;
}
.rail-item.codepilot .live-pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.55);
  animation: codepilot-pulse 2.2s ease-out infinite;
}
@keyframes codepilot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(34, 211, 238, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); }
}
.rail-item.codepilot:hover .icon {
  background: rgba(34, 211, 238, 0.22);
  border-color: rgba(34, 211, 238, 0.5);
}

.rail-item .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}
.rail-item.active .count { background: rgba(244,163,0,0.12); color: var(--gold); }

/* ================= MAIN ================= */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
  background: var(--bg);
}

.main-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.main-title {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 2.1rem;
  letter-spacing: -0.025em;
  color: var(--text);
}
.main-title .accent-atlas { color: var(--gold); }
.main-title .accent-compass { color: #818cf8; }
.main-title .accent-rennick { color: var(--green); }
.main-title .accent-nexus { color: var(--gold-bright); }

.main-sub {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.main-sub .live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 0.4rem;
  vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(52,211,153, 0.4);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(52,211,153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153, 0); }
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}
@media (max-width: 1300px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.kpi-tile:hover { border-color: var(--gold-dim); }
.kpi-tile .kpi-source {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.kpi-tile .kpi-source .badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.kpi-tile.atlas .badge-dot { background: var(--gold); }
.kpi-tile.compass .badge-dot { background: #818cf8; }
.kpi-tile.rennick .badge-dot { background: var(--green); }
.kpi-tile.nexus .badge-dot { background: var(--gold-bright); }

.kpi-tile .kpi-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  font-weight: 500;
}
.kpi-tile .kpi-value {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.4rem;
}
.kpi-tile .kpi-delta {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
}
.kpi-tile .kpi-delta.up { color: var(--green); }
.kpi-tile .kpi-delta.down { color: #f87171; }
.kpi-tile .kpi-delta.flat { color: var(--text-muted); }

/* Section blocks */
.section {
  margin-bottom: 1.75rem;
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.015em;
}
.section-title .count-pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gold);
  background: rgba(244,163,0,0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.section-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--mono);
}
.section-link:hover { color: var(--gold); }

/* Approvals */
.approval {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 2px solid var(--gold);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.approval:hover { background: #1f1f25; border-color: var(--gold-dim); border-left-color: var(--gold); }
.approval.selected { background: #1f1f25; border-color: var(--gold); border-left-color: var(--gold); }

.approval-source {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.7rem;
  border-radius: 4px;
}
.approval-source.atlas { background: rgba(244,163,0,0.12); color: var(--gold); }
.approval-source.rennick { background: rgba(52,211,153,0.12); color: var(--green); }
.approval-source.nexus { background: rgba(244,163,0,0.15); color: var(--gold-bright); }
.approval-source.compass { background: rgba(99,102,241,0.15); color: #818cf8; }

.approval-body .approval-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.approval-body .approval-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.approval-body .approval-meta .pill {
  background: var(--bg);
  padding: 0.08rem 0.4rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  margin-right: 0.3rem;
}

.approval-actions { display: flex; gap: 0.4rem; }
.btn-approve, .btn-defer {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-approve {
  background: var(--gold); color: #0a0a0b; border-color: var(--gold);
}
.btn-approve:hover { background: var(--gold-bright); border-color: var(--gold-bright); }
.btn-defer:hover { color: var(--text); border-color: var(--text-muted); }

/* Activity feed */
.activity {
  display: grid;
  grid-template-columns: 70px 30px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 0.15rem;
}
.activity:hover { background: var(--bg-card); border-color: var(--border); }
.activity .when {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}
.activity .src-dot {
  width: 18px; height: 18px;
  border-radius: 3px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
}
.src-dot.atlas { background: rgba(244,163,0,0.12); color: var(--gold); }
.src-dot.compass { background: rgba(99,102,241,0.15); color: #818cf8; }
.src-dot.rennick { background: rgba(52,211,153,0.12); color: var(--green); }
.src-dot.nexus { background: rgba(244,163,0,0.18); color: var(--gold-bright); }
.activity .what {
  font-size: 0.86rem;
  color: var(--text-dim);
}
.activity .what strong { color: var(--text); font-weight: 600; }
.activity .status-tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.4rem;
  border-radius: 2px;
}
.status-tag.ok { background: rgba(52,211,153,0.1); color: var(--green); }
.status-tag.pending { background: rgba(244,163,0,0.1); color: var(--gold); }
.status-tag.fail { background: rgba(248,113,113,0.1); color: #f87171; }
.status-tag.info { background: var(--bg-card); color: var(--text-muted); border: 1px solid var(--border); }

/* Data list (used by Atlas templates, Nexus runs, Rennick threads, etc.) */
.list-row {
  display: grid;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.list-row:hover { border-color: var(--gold-dim); background: #1f1f25; }
.list-row.selected { border-color: var(--gold); background: #1f1f25; }
.list-row .lr-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}
.list-row .lr-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.list-row .lr-meta .pill {
  background: var(--bg);
  padding: 0.08rem 0.4rem;
  border-radius: 2px;
  border: 1px solid var(--border);
  margin-right: 0.3rem;
}

/* Filter chips */
.filters {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.32rem 0.7rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--gold-dim); color: var(--text); }
.chip.active {
  background: rgba(244,163,0,0.12);
  border-color: var(--gold);
  color: var(--gold);
}

/* ================= INSPECTOR ================= */
.inspector {
  grid-area: inspector;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--bg);
}
.insp-eyebrow {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin-bottom: 0.5rem;
}
.insp-eyebrow.compass { color: #818cf8; }
.insp-eyebrow.rennick { color: var(--green); }
.insp-eyebrow.nexus { color: var(--gold-bright); }

.insp-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 0.35rem;
  letter-spacing: -0.015em;
}
.insp-sub {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.insp-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.85rem;
}
.insp-block .b-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.insp-block .b-content {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.55;
}
.insp-block .b-content code {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--bg);
  padding: 0.05rem 0.35rem;
  border-radius: 2px;
  color: var(--gold);
  border: 1px solid var(--border);
}

.insp-trace {
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.7;
}
.insp-trace .step {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 0.55rem;
  align-items: baseline;
}
.insp-trace .step .marker {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-top: 6px;
  box-shadow: 0 0 0 1px var(--bg-card);
}
.insp-trace .step.done .marker { background: var(--green); }
.insp-trace .step.now .marker { background: var(--gold); animation: pulse 2s infinite; }
.insp-trace .step.todo .marker { background: var(--border); }
.insp-trace .step .text { color: var(--text-dim); }
.insp-trace .step.done .text { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border); }
.insp-trace .step.now .text { color: var(--text); font-weight: 500; }

.insp-actions {
  display: flex; gap: 0.5rem;
  margin-top: 1rem;
}
.insp-actions .btn {
  flex: 1;
  font-family: var(--sans);
  font-size: 0.83rem;
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.insp-actions .btn.primary {
  background: var(--gold);
  color: #0a0a0b;
  border-color: var(--gold);
}
.insp-actions .btn.primary:hover { background: var(--gold-bright); border-color: var(--gold-bright); }
.insp-actions .btn:hover { border-color: var(--gold-dim); }

/* ================= STATUS BAR ================= */
.statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}
.statusbar .stat { display: flex; align-items: center; gap: 0.4rem; }
.statusbar .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.statusbar .dot.ok { background: var(--green); }
.statusbar .dot.warn { background: var(--gold); }
.statusbar .stat strong { color: var(--text-dim); font-weight: 600; }
.statusbar .spacer { flex: 1; }
.statusbar .demo-tag {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* Demo banner — interest-capture widget */
.demo-banner {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.74rem;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
  max-width: calc(100% - 2rem);
}
.demo-banner .db-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.demo-banner .db-row + .db-row {
  padding-left: 0.55rem;
  border-left: 1px solid var(--border);
}
.demo-banner .db-key {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
}
.demo-banner .db-q { color: var(--text-dim); margin-right: 0.15rem; }

.demo-banner .db-emoji {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  font-family: inherit;
}
.demo-banner .db-emoji:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}
.demo-banner .db-emoji.picked {
  background: rgba(244,163,0,0.15);
  border-color: var(--gold);
  transform: scale(1.08);
}
.demo-banner .db-thanks {
  color: var(--green);
  font-weight: 600;
  margin-left: 0.3rem;
  font-size: 0.7rem;
}
.demo-banner .db-link {
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}
.demo-banner .db-link:hover {
  color: var(--text);
  border-color: var(--gold-dim);
  background: var(--bg);
}

/* Inline lead form (popover above the banner when a CTA is clicked) */
.demo-banner .db-form {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
  display: none;
  flex-direction: column;
  gap: 0.55rem;
  width: min(380px, calc(100vw - 2rem));
  font-family: var(--sans);
}
.demo-banner.db-form-open .db-form { display: flex; }

.demo-banner .db-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.demo-banner .db-form-title { color: var(--gold); font-weight: 700; }
.demo-banner .db-form-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.35rem;
  line-height: 1;
  border-radius: 3px;
}
.demo-banner .db-form-close:hover { color: var(--text); background: var(--bg); }

.demo-banner .db-form-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.demo-banner .db-form-body label {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.15rem;
}
.demo-banner .db-form-body input,
.demo-banner .db-form-body textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.demo-banner .db-form-body input:focus,
.demo-banner .db-form-body textarea:focus { border-color: var(--gold); }
.demo-banner .db-form-body textarea {
  min-height: 50px;
  resize: vertical;
  font-family: var(--sans);
}

.demo-banner .db-form-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.15rem;
}
.demo-banner .db-form-footer .db-form-status {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
}
.demo-banner .db-form-footer .db-form-status.error { color: #f87171; }
.demo-banner .db-form-footer .db-form-status.ok { color: var(--green); }
.demo-banner .db-form-submit {
  background: var(--gold);
  color: #0a0a0b;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 0.9rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.15s;
}
.demo-banner .db-form-submit:hover { background: var(--gold-bright); }
.demo-banner .db-form-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.demo-banner .db-form-fallback {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--text-muted);
}
.demo-banner .db-form-fallback a {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--gold-dim);
}
.demo-banner .db-form-fallback a:hover { color: var(--gold); }

/* ================= HAMBURGER + BACKDROP (mobile) ================= */
.menu-btn {
  display: none;
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--mono);
  flex-shrink: 0;
}
.menu-btn:hover { color: var(--text); border-color: var(--gold-dim); }

.rail-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,10,11,0.6);
  backdrop-filter: blur(2px);
  z-index: 90;
}

/* ================= TABLET (≤1100px) ================= */
@media (max-width: 1100px) {
  .console-app {
    grid-template-columns: 200px 1fr;
    grid-template-areas: "top top" "rail main" "status status";
  }
  .inspector { display: none; }
  .main { padding: 1.25rem 1.25rem; }
}

/* ================= PHONE (≤820px) ================= */
@media (max-width: 820px) {
  :root {
    --rail-w: 260px;
  }

  .console-app {
    grid-template-columns: 1fr;
    grid-template-areas: "top" "main" "status";
  }

  .menu-btn { display: inline-flex; }

  /* Off-canvas rail */
  .rail {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 28px;
    width: var(--rail-w);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 12px 0 24px rgba(0,0,0,0.4);
    grid-area: unset;
  }
  body.rail-open .rail { transform: translateX(0); }
  body.rail-open .rail-backdrop { display: block; }

  /* Topbar — strip noise on phone */
  .topbar {
    padding: 0 0.7rem;
    gap: 0.55rem;
  }
  .topbar .brand {
    padding-right: 0.7rem;
    font-size: 0.95rem;
    gap: 0.45rem;
  }
  .topbar .brand-mark { width: 22px; height: 22px; }
  .topbar .breadcrumbs { display: none; }
  .portfolio-switcher {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
  }
  .portfolio-switcher .pf-name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .portfolio-switcher .pf-caret { display: none; }

  /* Top actions — keep approvals + avatar, drop rest */
  .top-actions .icon-btn:not(.has-badge) { display: none; }
  .user-chip { padding: 0.28rem 0.4rem 0.28rem 0.28rem; }
  .user-chip .user-name { display: none; }

  /* Main — tighter */
  .main {
    padding: 1rem 0.9rem 5rem;
  }
  .main-header {
    margin-bottom: 1rem;
  }
  .main-title { font-size: 1.55rem; }
  .main-sub { font-size: 0.74rem; }
  .main-header > div:last-child { width: 100%; }
  .main-header > div:last-child button { flex: 1; }

  /* KPI grid — single column on phone */
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 0.55rem;
    margin-bottom: 1.25rem;
  }
  .kpi-tile { padding: 0.85rem 1rem; }
  .kpi-tile .kpi-value { font-size: 1.7rem; }

  /* Sub-navs and filter chips — horizontal scroll */
  body .subnav,
  body .filters,
  body .persona-switch {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
  }
  body .subnav::-webkit-scrollbar,
  body .filters::-webkit-scrollbar,
  body .persona-switch::-webkit-scrollbar { display: none; }
  body .subnav a,
  body .chip,
  body .persona { flex-shrink: 0; }

  /* Section heads stack instead of squish */
  .section-head { flex-wrap: wrap; gap: 0.4rem; }

  /* Approvals + threads + runs + attestations: simplify grid */
  .approval {
    grid-template-columns: 32px 1fr;
    grid-template-areas: "icon body" "actions actions";
    gap: 0.6rem;
  }
  .approval-source { grid-area: icon; }
  .approval-body { grid-area: body; }
  .approval-actions {
    grid-area: actions;
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
  }
  .approval-actions button { flex: 1; }

  /* Activity feed — compact */
  .activity {
    grid-template-columns: 56px 24px 1fr auto;
    gap: 0.45rem;
    padding: 0.5rem 0.4rem;
  }
  .activity .what { font-size: 0.8rem; }
  .activity .when { font-size: 0.66rem; }

  /* Atlas attestations — drop ID column on phone */
  body .attest {
    grid-template-columns: 70px 28px 1fr;
    gap: 0.55rem;
    padding: 0.6rem 0.7rem;
  }
  body .attest .a-id { display: none; }
  body .attest .a-when { font-size: 0.66rem; }
  body .attest .a-body .a-title { font-size: 0.84rem; }

  /* Adapter grid — 2 col on phone */
  body .adapter-grid { grid-template-columns: repeat(2, 1fr); }

  /* Compass anomaly — stack action below */
  body .anomaly {
    grid-template-columns: 30px 1fr;
    grid-template-areas: "icon body" "action action";
    gap: 0.55rem;
  }
  body .anomaly > .a-icon { grid-area: icon; }
  body .anomaly > .a-body { grid-area: body; }
  body .anomaly > button { grid-area: action; margin-top: 0.4rem; width: 100%; }

  /* Compass recommendation — stack action below */
  body .rec { grid-template-columns: 1fr; }
  body .rec button { width: 100%; margin-top: 0.5rem; }

  /* Cohort table — horizontal scroll */
  .cohort {
    min-width: 540px;
  }
  .cohort + .cohort,
  .cohort.head + .cohort {
    /* nothing */
  }

  /* Wrap cohort section in scroll */
  .section:has(.cohort) > .cohort,
  .section:has(.cohort) {
    /* keep default; scroll handled by parent */
  }

  /* Rennick threads — drop status column */
  body .thread {
    grid-template-columns: 28px 1fr;
    gap: 0.55rem;
  }
  body .thread .t-status { display: none; }

  /* Persona switcher: keep horizontal scroll */
  body .persona { padding: 0.4rem 0.6rem; }
  body .persona .p-role { font-size: 0.6rem; }

  /* Nexus run rows — stack progress under title, drop ID */
  body .run {
    grid-template-columns: 70px 28px 1fr;
    gap: 0.55rem;
    padding: 0.55rem 0.65rem;
  }
  body .run .r-id { display: none; }
  body .run .r-status-cell { font-size: 0.62rem; }
  body .run .r-body .r-title { font-size: 0.85rem; }

  /* Tools registry: 1 column on phone */
  body .tool-grid { grid-template-columns: 1fr; }

  /* Schedule: drop next-fire column */
  body .schedule {
    grid-template-columns: 1fr 100px;
    gap: 0.55rem;
  }
  body .schedule .s-next { display: none; }

  /* Status bar — single line scroll */
  .statusbar {
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0.85rem;
    padding: 0 0.7rem;
  }
  .statusbar::-webkit-scrollbar { display: none; }
  .statusbar .stat { flex-shrink: 0; }

  /* Demo banner — bottom-anchored, full width minus margin */
  .demo-banner {
    bottom: 36px;
    left: 0.6rem;
    right: 0.6rem;
    transform: none;
    border-radius: 6px;
    font-size: 0.68rem;
    padding: 0.45rem 0.7rem;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
  }

  /* Cost mini-chart smaller */
  .cost-chart { height: 28px; }

  /* Sparkline same shrink */
  .spark { height: 26px; }
}

/* Wrap horizontally-scrolling cohort table on phone */
@media (max-width: 820px) {
  .section:has(.cohort) {
    overflow-x: auto;
    margin-left: -0.9rem;
    margin-right: -0.9rem;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }
}

/* ================= TINY (≤380px) ================= */
@media (max-width: 380px) {
  .topbar { padding: 0 0.5rem; gap: 0.4rem; }
  .topbar .brand { padding-right: 0.5rem; font-size: 0.9rem; }
  .topbar .brand span:not(.dot) { display: none; }
  .portfolio-switcher .pf-name { max-width: 70px; }
  .main-title { font-size: 1.35rem; }
  .kpi-tile .kpi-value { font-size: 1.55rem; }
}
