/* =====================================================
   Space 2.0 — App Shell + Components (VeloCoach)
   Mobile-first. Desktop enhancements via min-width queries.
   Foundation tokens live in tokens.css.
   ===================================================== */

/* ============================ LAYOUT ============================ */
.app { min-height: 100vh; }

/* --- Sidebar (desktop) / Drawer (mobile) --- */
aside.nav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 264px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: linear-gradient(180deg, #070C1E 0%, #05081590 100%);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--hairline);
  transform: translateX(-100%);
  transition: transform var(--dur) var(--ease);
  overflow-y: auto;
}
body.drawer-open aside.nav { transform: translateX(0); }

.nav-overlay {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(3,5,14,0.6);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
body.drawer-open .nav-overlay { opacity: 1; pointer-events: auto; }

/* Brand block: the Sortd lockup. Owner brand first at full size, Sortd beneath, smaller. */
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; padding: 6px 10px 22px; }
.brand-owner { display: flex; align-items: center; gap: 11px; }
.brand-owner .vmark { width: 28px; height: 28px; color: var(--vc-cyan); flex-shrink: 0; display: block; }
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 1.22rem; letter-spacing: -0.01em; color: var(--text-strong); line-height: 1; white-space: nowrap; }
.brand-word .c { color: var(--vc-cyan); }
.brand-platform { display: flex; align-items: center; gap: 7px; padding-left: 3px; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter Tight", "Inter", sans-serif; font-weight: 700; font-size: 0.98rem; letter-spacing: -0.03em; color: var(--text); line-height: 1; }
.brand-platform .smark { width: 19px; height: auto; display: block; flex-shrink: 0; }
.login-brand .brand { align-items: center; padding: 0; gap: 12px; }
.login-brand .brand-owner .vmark { width: 38px; height: 38px; }
.login-brand .brand-word { font-size: 1.7rem; }
.login-brand .brand-platform { font-size: 1.3rem; }
.login-brand .brand-platform .smark { width: 25px; }

.nav-section-title {
  font-size: 0.62rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700;
  padding: 18px 12px 8px;
}
nav ul.nav-list { list-style: none; margin: 0 0 2px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
nav ul.nav-list li a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px;
  color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
  position: relative; transition: all 0.18s var(--ease);
}
nav ul.nav-list li a:hover { background: rgba(255,255,255,0.04); color: var(--text-strong); }
nav ul.nav-list li a.active { background: var(--vc-cyan-soft); color: var(--text-strong); }
nav ul.nav-list li a.active::before {
  content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--vc-cyan);
  box-shadow: 0 0 12px var(--vc-cyan);
}
.nav-icon { width: 22px; text-align: center; font-size: 1.02rem; filter: grayscale(0.15); }

.nav-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--hairline); }
.nav-footer .btn { width: 100%; justify-content: flex-start; color: var(--text-muted); }

/* --- Main content --- */
main.content { min-height: 100vh; padding-top: 58px; transition: padding var(--dur) var(--ease); }

/* Desktop top bar inside content */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: none;
  align-items: center;
  padding: 16px 32px;
  background: rgba(5,8,22,0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
}
.topbar h2 { font-size: 1.25rem; margin: 0; }

/* --- Mobile app bar --- */
.mobile-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: 58px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(5,8,22,0.82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--hairline);
}
.hamburger {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  border: 1px solid var(--hairline); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; padding: 0;
}
.hamburger span { width: 17px; height: 2px; border-radius: 2px; background: var(--text); transition: all 0.25s var(--ease); }
body.drawer-open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.drawer-open .hamburger span:nth-child(2) { opacity: 0; }
body.drawer-open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.mobile-bar-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--text-strong); letter-spacing: -0.01em; }
.mobile-vmark { margin-left: auto; display: flex; color: var(--vc-cyan); }
.mobile-vmark svg { width: 26px; height: 26px; display: block; }

/* --- View wrapper --- */
.view { padding: 22px 18px 64px; max-width: 1340px; margin: 0 auto; }

/* ============================ DESKTOP ============================ */
@media (min-width: 980px) {
  aside.nav { transform: translateX(0); }
  .nav-overlay, .mobile-bar { display: none !important; }
  main.content { padding-top: 0; margin-left: 264px; }
  .topbar { display: flex; }
  body.drawer-open aside.nav { transform: translateX(0); }
  body.drawer-open { overflow: auto; }
  .view { padding: 30px 40px 80px; }
}

/* Lock scroll when drawer open on mobile */
@media (max-width: 979px) { body.drawer-open { overflow: hidden; } }

/* ============================ HERO ============================ */
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-body); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--vc-cyan);
  padding: 5px 12px; border: 1px solid var(--vc-cyan-soft); border-radius: 999px;
  background: var(--vc-cyan-soft); margin-bottom: 16px;
}
.hero h1 { margin-bottom: 10px; }
.hero .lede { font-size: clamp(0.95rem, 2vw, 1.08rem); color: var(--text-muted); max-width: 620px; }

/* ============================ GRID ============================ */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) {
  .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ============================ TILE (KPI) ============================ */
.tile {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.tile::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--vc-cyan), transparent);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.tile:hover { border-color: var(--hairline-strong); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.tile:hover::after { opacity: 0.8; }
.tile .tile-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; }
.tile .tile-value {
  font-family: var(--font-display); font-size: clamp(1.7rem, 4vw, 2.15rem); font-weight: 600;
  line-height: 1; color: var(--text-strong); letter-spacing: -0.02em; margin-bottom: 8px;
}
.tile .tile-sub { font-size: 0.76rem; color: var(--text-muted); }
.tile .tile-delta.up   { color: var(--green); }
.tile .tile-delta.down { color: var(--red); }
.tile .tile-delta.flat { color: var(--text-muted); }
.delta { font-size: 0.74rem; margin-left: 6px; }
.delta.up { color: var(--red); } .delta.down { color: var(--green); } .delta.neutral { color: var(--text-muted); }
.delta-up { color: var(--green); font-size: 0.74rem; } .delta-down { color: var(--red); font-size: 0.74rem; }

/* ============================ SECTION HEAD ============================ */
.section-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 30px 0 16px;
}
.section-head h2 { margin: 0; }
.section-head h3 { margin: 0; }
.section-head .section-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================ CHART SURFACES ============================ */
.chart-card { padding: 20px 22px; }
.chart-card > h3 { margin: 0 0 4px; }
.chart-card .chart-sub { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 14px; }
.chart-box { width: 100%; height: 240px; }
.chart-box.tall { height: 300px; }
.chart-box.short { height: 170px; }

/* Empty / loading / error states */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px; min-height: 150px; padding: 24px; color: var(--text-muted);
}
.state .state-icon {
  width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  background: var(--vc-cyan-soft); font-size: 1.3rem; margin-bottom: 4px;
}
.state.error .state-icon { background: var(--red-soft); }
.state .state-title { font-family: var(--font-display); font-weight: 600; color: var(--text); font-size: 0.98rem; }
.state .state-hint { font-size: 0.82rem; color: var(--text-muted); max-width: 320px; }
.state code { font-size: 0.78rem; }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================ PANELS / DETAIL ============================ */
.panel { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 20px 22px; }
.detail-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 980px) { .detail-grid { grid-template-columns: 2fr 1fr; } }

.list-flush { padding: 0 !important; }
.list-flush .list-head { padding: 16px 22px 12px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.list-flush .list-body { padding: 6px 22px 8px; }

.row-line { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--hairline); }
.row-line:last-child { border-bottom: none; }

/* ============================ DATA TABLE ============================ */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: 0.74rem; letter-spacing: 0.04em; text-transform: uppercase; padding: 13px 18px; border-bottom: 1px solid var(--hairline); }
.data-table td { padding: 12px 18px; border-bottom: 1px solid var(--hairline-soft); color: var(--text); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s var(--ease); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============================ AGENT FEED ============================ */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.agent-chip {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 13px; padding: 13px 14px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.agent-chip:hover { transform: translateY(-2px); }
.agent-chip.status-active    { border-color: var(--green-soft);  box-shadow: inset 0 0 0 1px var(--green-soft); }
.agent-chip.status-needs-you { border-color: var(--orange-soft); box-shadow: inset 0 0 0 1px var(--orange-soft); }
.agent-chip.status-handoff   { border-color: var(--vc-cyan-soft); }
.agent-chip.status-unknown   { opacity: 0.5; }
.agent-name { font-size: 0.84rem; font-weight: 600; color: var(--text-strong); }
.agent-last { font-size: 0.7rem; color: var(--text-muted); }
.agent-status { font-size: 0.68rem; font-weight: 600; margin-top: 2px; }
.agent-status.active { color: var(--green); }
.agent-status.needs-you { color: var(--orange); }
.agent-status.handoff { color: var(--vc-cyan); }
.agent-status.idle, .agent-status.unknown { color: var(--text-muted); }

.task-status-badge { font-size: 0.66rem; font-weight: 700; padding: 2px 8px; border-radius: 5px; text-transform: uppercase; letter-spacing: 0.04em; }
.task-status-badge.pending { background: var(--orange-soft); color: var(--orange); }
.task-status-badge.in-progress { background: var(--vc-cyan-soft); color: var(--vc-cyan); }

.feed-day { font-size: 0.7rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; padding: 6px 0 8px; border-bottom: 1px solid var(--hairline); margin-bottom: 8px; }
.event-card { padding: 14px 16px; margin: 0; display: flex; align-items: flex-start; gap: 14px; }
.event-avatar { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.66rem; font-weight: 700; }

.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(55,214,122,0.5); } 70% { box-shadow: 0 0 0 8px rgba(55,214,122,0); } 100% { box-shadow: 0 0 0 0 rgba(55,214,122,0); } }

/* ============================ DEV / MARKETING ROWS ============================ */
.commit-sha { font-family: ui-monospace, monospace; font-size: 0.74rem; color: var(--vc-cyan); background: var(--surface-3); padding: 2px 7px; border-radius: 6px; flex-shrink: 0; }
.commit-repo { font-size: 0.7rem; color: var(--text-muted); background: var(--surface-3); padding: 2px 7px; border-radius: 6px; flex-shrink: 0; }
.service-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.service-dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.service-dot.err { background: var(--red); box-shadow: 0 0 8px var(--red); }
.note-card { padding: 14px 18px; background: var(--surface); border: 1px solid var(--hairline); border-left: 3px solid var(--vc-cyan); border-radius: 0 12px 12px 0; margin-bottom: 10px; }
.status-select { background: var(--surface-3); color: var(--text); border: 1px solid var(--hairline); border-radius: 8px; padding: 5px 10px; font-size: 0.76rem; cursor: pointer; font-family: var(--font-body); }
.status-select:hover { border-color: var(--vc-cyan); }
.repo-card { padding: 14px 16px; border: 1px solid var(--hairline); border-radius: 13px; display: flex; align-items: center; gap: 12px; background: var(--surface); transition: border-color 0.2s var(--ease), transform 0.2s var(--ease); }
.repo-card:hover { border-color: var(--vc-cyan); transform: translateY(-2px); }

.channel-badge { flex-shrink: 0; width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; color: #fff; }
.ch-ig { background: linear-gradient(135deg,#833ab4,#fd1d1d,#fcb045); }
.ch-fb { background: #1877f2; }
.ch-li { background: #0a66c2; }
.social-stat-val { color: var(--vc-cyan); font-weight: 600; }

.star-icon { font-size: 1.05rem; }
.rating-big { font-family: var(--font-display); font-size: 3rem; font-weight: 600; color: var(--text-strong); line-height: 1; }
.review-card { padding: 16px 20px; border-bottom: 1px solid var(--hairline); }
.review-card:last-child { border-bottom: none; }

/* ============================ COMING SOON ============================ */
.coming-soon { max-width: 500px; margin: 8vh auto; text-align: center; }
.coming-soon .cs-icon { font-size: 3rem; margin-bottom: 18px; }

/* ============================ LOGIN ============================ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  position: relative; width: 100%; max-width: 410px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--hairline); border-radius: var(--radius-xl);
  padding: 44px 40px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.login-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--vc-cyan), transparent); }
.login-brand { text-align: center; margin-bottom: 30px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.74rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px; }
.field {
  width: 100%; padding: 13px 15px; background: var(--surface-3);
  border: 1px solid var(--hairline); border-radius: var(--radius-md);
  color: var(--text-strong); font-family: var(--font-body); font-size: 0.95rem; outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.field:focus { border-color: var(--vc-cyan); box-shadow: 0 0 0 3px var(--vc-cyan-soft); }
/* "Remember me" — ticked keeps the session in localStorage across restarts,
   unticked scopes it to the tab via sessionStorage. */
.remember-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 18px; }
.remember-row input[type="checkbox"] {
  width: 16px; height: 16px; margin: 0; flex: none;
  accent-color: var(--vc-cyan); cursor: pointer;
}
.remember-row label {
  font-size: 0.82rem; color: var(--text-muted); cursor: pointer;
  user-select: none; letter-spacing: 0;
}
.remember-row label:hover { color: var(--text-strong); }
.btn-submit {
  width: 100%; padding: 14px; margin-top: 8px;
  background: linear-gradient(135deg, var(--vc-cyan), var(--vc-cyan-hover));
  border: none; border-radius: var(--radius-md); color: #041018;
  font-family: var(--font-display); font-size: 0.92rem; font-weight: 700; letter-spacing: 0.01em;
  cursor: pointer; transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.btn-submit:hover { transform: translateY(-1px); box-shadow: var(--shadow-glow); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.error-msg { color: var(--red); font-size: 0.82rem; margin-top: 12px; text-align: center; min-height: 20px; }

/* ============================ MOTION: reveal ============================ */
[data-reveal] { opacity: 0; transform: translateY(16px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); }
[data-reveal].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { [data-reveal] { opacity: 1 !important; transform: none !important; } }

/* ============================ LEGACY chart classes (graceful) ============================ */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 12px; }
.bar-label { font-size: 0.82rem; color: var(--text); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-3); border-radius: 5px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--vc-cyan), var(--vc-cyan-hover)); transition: width 0.8s var(--ease); }
.bar-value { font-size: 0.78rem; color: var(--text-muted); }
.sparkline-wrap { overflow-x: auto; }
.sparkline { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.spark-bar { flex: 1; min-width: 10px; border-radius: 3px 3px 0 0; background: var(--vc-cyan); opacity: 0.7; }

/* ============================ INFO DOT (tooltip trigger) ============================ */
.info-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 7px; vertical-align: middle;
  border-radius: 50%; border: 1px solid var(--hairline-strong);
  background: var(--vc-cyan-soft); color: var(--vc-cyan);
  font-family: var(--font-display); font-size: 0.62rem; font-weight: 700;
  font-style: normal; text-transform: none; letter-spacing: 0; line-height: 1;
  cursor: help; outline: none; transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.info-dot:hover, .info-dot:focus { border-color: var(--vc-cyan); background: var(--vc-cyan-glow); color: var(--text-strong); }

/* ============================ CONNECT (not-configured) CARD ============================ */
.connect-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; padding: 34px 26px; min-height: 180px;
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px dashed var(--hairline-strong); border-radius: var(--radius-lg);
}
.connect-card .connect-icon {
  width: 52px; height: 52px; border-radius: 15px; display: flex; align-items: center; justify-content: center;
  background: var(--vc-cyan-soft); font-size: 1.5rem; margin-bottom: 2px;
}
.connect-card .connect-title { font-family: var(--font-display); font-weight: 600; color: var(--text-strong); font-size: 1.02rem; }
.connect-card .connect-msg { font-size: 0.85rem; color: var(--text-muted); max-width: 380px; }
.connect-card .connect-hint {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
  font-size: 0.72rem; color: var(--text-dim); font-weight: 600;
  padding: 5px 11px; border: 1px solid var(--hairline); border-radius: 999px; background: var(--surface-3);
}

/* ============================ TABS ============================ */
.tabs {
  display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 24px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-md); max-width: 100%; overflow-x: auto;
}
.tabs button {
  padding: 8px 18px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
  font-family: var(--font-body); font-size: 0.83rem; font-weight: 600;
  letter-spacing: 0.01em; cursor: pointer; white-space: nowrap;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.tabs button:hover { color: var(--text-strong); background: var(--surface-2); }
.tabs button[aria-selected="true"] { background: var(--vc-cyan-soft); color: var(--vc-cyan); }
.tabs button:focus-visible { outline: 2px solid var(--vc-cyan); outline-offset: 2px; }
.tabpanel[hidden] { display: none; }

/* ========================= BALANCE BOOK ========================= */
/* Tabular figures — every money column must align on the decimal. */
.num {
  font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
}
.bb .data-table th.r, .bb .data-table td.r { text-align: right; }
.bb .data-table tfoot td {
  font-weight: 700; color: var(--text-strong);
  border-top: 1px solid var(--hairline-strong); border-bottom: none;
}
.bb .strike { text-decoration: line-through; color: var(--text-dim); }
.bb .sub-note { font-size: 0.8rem; color: var(--text-muted); margin: 10px 0 0; }

/* headline figure */
.bb-figure {
  font-family: var(--font-display); font-variant-numeric: tabular-nums;
  font-size: clamp(2.6rem, 8vw, 4.4rem); line-height: 1; font-weight: 700;
  letter-spacing: -0.03em; color: var(--text-strong); margin: 6px 0 0;
}
.bb-figure-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted); margin: 0;
}

/* composition meter */
.meter { display: flex; gap: 2px; height: 40px; margin: 26px 0 0; border-radius: 5px; overflow: hidden; background: var(--surface-3); }
.meter span { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 0.84rem; }
.legend li { display: flex; align-items: baseline; gap: 8px; color: var(--text); }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; transform: translateY(1px); }
.legend .lv { color: var(--text-muted); }

/* inline bar inside a table cell */
.bar-cell { min-width: 7rem; width: 22%; }
.bar-cell .bar { display: block; height: 8px; border-radius: 2px 4px 4px 2px; background: var(--vc-cyan); min-width: 2px; }

/* callout notes */
.note {
  background: var(--surface); border: 1px solid var(--hairline);
  border-left: 3px solid var(--vc-cyan); border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 16px 20px; margin: 20px 0 0;
}
.note.caution { border-left-color: var(--orange); }
.note.alert   { border-left-color: var(--red); }
.note .note-head {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px;
}
.note p { margin: 0; font-size: 0.92rem; color: var(--text); max-width: 68ch; }
.note p + p { margin-top: 10px; }
.note strong, .note b { color: var(--text-strong); }

/* the quoted justification wording */
blockquote.wording {
  margin: 20px 0 0; padding: 20px 24px;
  background: var(--vc-cyan-soft); border: 1px solid var(--vc-cyan-glow);
  border-radius: var(--radius-md);
}
blockquote.wording p {
  margin: 0; font-family: var(--font-display); font-size: 1rem; line-height: 1.6;
  color: var(--text-strong); max-width: 64ch; font-weight: 500;
}

/* numbered recommendation list */
ol.recs { list-style: none; padding: 0; margin: 12px 0 0; }
ol.recs li {
  position: relative; padding: 14px 0 14px 44px;
  border-bottom: 1px solid var(--hairline-soft); max-width: 74ch;
}
ol.recs li:last-child { border-bottom: none; }
ol.recs li .rec-n {
  position: absolute; left: 0; top: 15px;
  width: 26px; height: 22px; display: grid; place-items: center;
  font-family: 'SFMono-Regular', ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums; font-size: 0.72rem; font-weight: 700;
  color: var(--vc-cyan); background: var(--vc-cyan-soft); border-radius: 4px;
}
ol.recs b { color: var(--text-strong); }
ol.recs span { color: var(--text-muted); }

ul.plain { padding-left: 18px; margin: 12px 0 0; color: var(--text-muted); max-width: 72ch; }
ul.plain li { margin-bottom: 8px; }
ul.plain b { color: var(--text-strong); }

.bb-footer {
  margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--hairline);
  font-size: 0.78rem; color: var(--text-dim); line-height: 1.7;
}
.bb-footer em { color: var(--text-muted); font-style: italic; }

/* provenance bar — the feed is hand-maintained; never imply live data */
.provenance {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 14px 22px; padding: 14px 20px; margin: 0 0 18px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}
.provenance .prov-label {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--text-dim);
}
.provenance .prov-date {
  font-family: var(--font-display); font-size: 1.12rem; font-weight: 600;
  color: var(--text-strong); line-height: 1.3;
}
.provenance .prov-facts { display: flex; flex-wrap: wrap; gap: 8px; }

/* composition-led headline */
.lead-card { margin-top: 0 !important; }
.lead-card .bb-figure { font-size: clamp(2.4rem, 7vw, 4rem); }
.lead-card .fig-tail {
  display: block; margin-top: 8px;
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 500;
  letter-spacing: 0; color: var(--text-muted);
}
.lead-card .lead-sub {
  margin: 16px 0 0; font-size: 0.95rem; color: var(--text); max-width: 62ch;
}
.lead-card .lead-sub b { color: var(--text-strong); }

/* render-gate failure — figures deliberately withheld */
.gate-fail { border-color: var(--red); border-left: 3px solid var(--red); }
.gate-fail .gate-head h2 { color: var(--red); }

/* awaiting-upstream state */
.state.pending .state-icon { opacity: 0.75; }
.state.pending code {
  background: var(--surface-3); color: var(--vc-cyan);
  padding: 1px 6px; border-radius: 4px;
}

/* a metric with no source — not zero, not loading */
.tile.blocked { border-style: dashed; background: transparent; }
.tile.blocked .tile-value { font-size: 1.15rem; letter-spacing: 0; }

.data-table caption.tbl-cap {
  caption-side: top; text-align: left; margin: 0 0 8px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted);
}
.h3-note {
  font-family: var(--font-body); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim);
  margin-left: 8px;
}
/* renewal rows carry a severity tint on the left edge */
.data-table tr.rw-crit td:first-child { box-shadow: inset 3px 0 0 var(--red); padding-left: 22px; }
.data-table tr.rw-warn td:first-child { box-shadow: inset 3px 0 0 var(--orange); padding-left: 22px; }

/* ============================ UTILITIES ============================ */
.muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; } .mt-0 { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* basis stamp under an AI-spend tile (TASK-1244 cache accounting cutover) */
.tile .tile-basis { margin-top: 8px; }
.tile .tile-basis .pill { font-size: 0.62rem; padding: 2px 8px; }

/* ==================== WORK: tasks, tests, sequences, guides (TASK-908) ==== */
.work-list { padding: 0; overflow: hidden; }
.work-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 20px; border-bottom: 1px solid var(--hairline-soft);
}
.work-row:last-child { border-bottom: none; }
.work-row.is-done .work-title { color: var(--text-muted); text-decoration: line-through; }
.work-pos {
  flex: none; width: 26px; height: 24px; display: grid; place-items: center;
  font-family: 'SFMono-Regular', ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums; font-size: 0.72rem; font-weight: 700;
  color: var(--vc-cyan); background: var(--vc-cyan-soft); border-radius: 5px;
}
.work-check {
  flex: none; width: 24px; height: 24px; margin-top: 1px; cursor: pointer;
  border-radius: 7px; border: 1.5px solid var(--hairline-strong);
  background: var(--surface-3); color: transparent;
  font-size: 0.85rem; font-weight: 700; line-height: 1;
  transition: all 0.16s var(--ease);
}
.work-check:hover { border-color: var(--vc-cyan); }
.work-check.checked { background: var(--green); border-color: var(--green); color: #04180d; }
.work-body { flex: 1; min-width: 0; }
.work-title { font-size: 0.94rem; color: var(--text-strong); font-weight: 500; }
.work-title a { color: var(--vc-cyan); }
.work-desc { font-size: 0.83rem; color: var(--text-muted); margin-top: 3px; }
.work-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 8px; }
.work-module, .work-owner { font-size: 0.72rem; color: var(--text-dim); }
.work-open { font-size: 0.74rem; color: var(--text-dim); }
.work-actor { flex: none; text-align: right; }

/* Who closed it. Kyle and an agent must never look the same (criterion 8). */
.actor {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.73rem; font-weight: 600; white-space: nowrap;
}
.actor .actor-icon { font-size: 0.8rem; }
.actor-kyle  { background: var(--vc-cyan-soft); color: var(--vc-cyan); border: 1px solid var(--vc-cyan-glow); }
.actor-agent { background: var(--violet-soft); color: var(--violet); border: 1px solid rgba(155,140,255,0.28); }

/* sequences */
.seq-card { cursor: pointer; }
.seq-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.seq-desc { margin: 6px 0 0; font-size: 0.86rem; color: var(--text-muted); max-width: 70ch; }
.seq-progress { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.seq-bar { flex: 1; height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.seq-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--vc-cyan), var(--green)); }
.seq-count { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.seq-count b { color: var(--text-strong); }
.seq-next { margin: 14px 0 0; font-size: 0.88rem; color: var(--text); }
.seq-next b { color: var(--text-strong); }

/* guide viewer */
.doc-frame-wrap { overflow: hidden; }
.doc-frame {
  display: block; width: 100%; height: 78vh; min-height: 460px;
  border: 0; background: #fff; border-radius: var(--radius-lg);
}
@media (max-width: 620px) {
  .doc-frame { height: 70vh; min-height: 380px; }
  .work-row { padding: 13px 15px; gap: 11px; }
  .work-actor { text-align: left; }
}

/* ── TASK-1366: workstreams, owners, staleness ───────────────────────────────
   Kyle's requirement was that an item untouched since May must LOOK different
   from one raised today. Colour carries it at a glance; the label carries it
   for anyone who cannot use the colour. Both, always — never colour alone. */

.age {
  font-size: 0.68rem; padding: 2px 7px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.age-fresh   { color: var(--text-dim); }
.age-aging   { color: var(--amber);  background: var(--amber-soft);  border-color: rgba(240,180,60,0.25); }
.age-stale   { color: var(--orange); background: var(--orange-soft); border-color: rgba(240,140,60,0.3); }
.age-ancient { color: var(--red);    background: var(--red-soft);    border-color: rgba(240,90,90,0.35); font-weight: 600; }

.owner-chip {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent;
}
.owner-kyle  { background: var(--vc-cyan-soft); color: var(--vc-cyan); border-color: var(--vc-cyan-glow); font-weight: 600; }
.owner-agent { background: var(--violet-soft);  color: var(--violet);  border-color: rgba(155,140,255,0.28); }
/* Unowned is deliberately visible rather than blank. A blank owner reads as
   "fine"; it means nobody is on the hook. */
.owner-none  { background: transparent; color: var(--text-dim); border-color: var(--hairline-strong); border-style: dashed; }

.dup-badge {
  font-size: 0.68rem; padding: 2px 7px; border-radius: 999px;
  background: var(--muted-soft); color: var(--text-muted); border: 1px solid var(--hairline);
}

/* Workstream cards */
.ws-card { margin-bottom: 16px; }
.ws-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--hairline);
  cursor: pointer; user-select: none;
}
.ws-head:hover { background: rgba(255,255,255,0.02); }
.ws-caret { flex: none; color: var(--text-dim); font-size: 0.8rem; margin-top: 3px; transition: transform var(--dur) var(--ease); }
.ws-card.is-open .ws-caret { transform: rotate(90deg); }
.ws-headings { flex: 1; min-width: 0; }
.ws-title { font-family: var(--font-display); font-size: 1.02rem; color: var(--text-strong); font-weight: 600; }
.ws-desc  { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }
.ws-meta  { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 9px; }
.ws-counts { font-size: 0.74rem; color: var(--text-dim); }
.ws-kyle-count { color: var(--vc-cyan); font-weight: 600; }
.ws-body { display: none; }
.ws-card.is-open .ws-body { display: block; }

/* A written progress note, with its age. Never a percentage — see
   backend/src/utils/workstream-progress.js for why there is no bar here. */
.ws-note {
  padding: 11px 18px; font-size: 0.85rem; color: var(--text);
  border-bottom: 1px solid var(--hairline); background: rgba(255,255,255,0.015);
}
.ws-note-by { font-size: 0.72rem; color: var(--text-dim); margin-top: 4px; }
.ws-note.is-stale { border-left: 3px solid var(--amber); }
.ws-note-missing { color: var(--text-dim); font-style: italic; }

/* Coverage warnings carry their own words so they cannot be softened into a
   neutral icon by a later redesign. */
.ws-warn {
  padding: 9px 18px; font-size: 0.78rem; color: var(--amber);
  background: var(--amber-soft); border-bottom: 1px solid rgba(240,180,60,0.2);
}
.page-warn {
  padding: 11px 15px; margin-bottom: 16px; border-radius: var(--radius-md);
  background: var(--amber-soft); border: 1px solid rgba(240,180,60,0.3);
  color: var(--amber); font-size: 0.83rem;
}
.page-warn + .page-warn { margin-top: -8px; }

.row-actions { display: flex; gap: 6px; margin-top: 8px; }
.mini-btn {
  font-size: 0.7rem; padding: 3px 9px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--hairline-strong);
}
.mini-btn:hover { border-color: var(--vc-cyan); color: var(--vc-cyan); }

@media (max-width: 720px) {
  .ws-head { padding: 13px 15px; }
  .ws-note, .ws-warn { padding-left: 15px; padding-right: 15px; }
}

/* ===================== REFRESH CONTROL (TASK-1381) =====================
 * Sits in .section-actions beside the view tabs on the Tasks page and is
 * styled off .tabs button so it reads as a sibling of them, not a new idiom.
 * The stamp is a peer of the button rather than inside it: it reports the
 * last SUCCESSFUL load, and a failed refresh must leave it visibly behind. */
.refresher { display: inline-flex; align-items: center; gap: 10px; }

.refresh-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--hairline);
  color: var(--text-muted);
  font-family: var(--font-body); font-size: 0.83rem; font-weight: 600;
  letter-spacing: 0.01em; cursor: pointer; white-space: nowrap;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.refresh-btn:hover:not(:disabled) { color: var(--text-strong); background: var(--surface-2); }
.refresh-btn:focus-visible { outline: 2px solid var(--vc-cyan); outline-offset: 2px; }

/* In-flight. Deliberately loud enough to be seen on a fast response: the
 * colour change and the cursor land on the same frame as the disable, so
 * there is something to observe even when the fetch returns in 40ms. */
.refresh-btn:disabled { cursor: progress; opacity: 1; }
.refresh-btn.is-busy {
  color: var(--vc-cyan); border-color: var(--vc-cyan); background: var(--vc-cyan-soft);
}
.refresh-glyph { display: inline-block; font-size: 0.95rem; line-height: 1; }
.refresh-btn.is-busy .refresh-glyph { animation: refresh-spin 0.7s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }

.refresh-stamp {
  font-size: 0.76rem; color: var(--text-dim);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .refresh-btn.is-busy .refresh-glyph { animation: none; }
}
