/* ─── DealArena App Shell ─────────────────────────────────────── */
/* Shared styles for all logged-in product surfaces */

/* App shell tokens. --green stays as a SEMANTIC success/won-deal color
   (used by .stage-won, .won-deal-badge, .tag.won, sequence builder
   active-path indicators). Brand orange is exposed as --brand and is
   used for primary CTAs, logos, and active-state chrome. The dark-mode
   --green is dialed back from neon to a more grounded shade so it
   coexists with brand orange without screaming. */
:root, [data-theme="light"] {
  --bg-0: #f7f7f4;
  --bg-1: #ffffff;
  --bg-2: #f1f1ec;
  --bg-3: #e7e7e1;
  --line: #e3e3dd;
  --line-2: #d2d2cb;
  --ink:  #0d100e;
  --ink-2: #3b423d;
  --ink-3: #6b736d;
  --ink-4: #9aa19c;
  --green: #0a8754;
  --green-2: #0c9c61;
  --green-soft: rgba(10,135,84,0.10);
  --green-glow: rgba(10,135,84,0.25);
  --brand: #ef5920;
  --brand-2: #c4471a;
  --brand-soft: rgba(239,89,32,0.10);
  --brand-glow: rgba(239,89,32,0.30);
  --accent: #ef5920;
  --accent-2: #c79100;
  --warn: #d63060;
  --hot: #ef5920;
  --blue: #2c7be5;
  --purple: #8b5cf6;
  --shadow-sm: 0 1px 2px rgba(13,16,14,0.04), 0 0 0 1px rgba(13,16,14,0.04);
  --shadow-md: 0 4px 12px rgba(13,16,14,0.06), 0 0 0 1px rgba(13,16,14,0.05);
  --shadow-lg: 0 16px 40px rgba(13,16,14,0.08), 0 0 0 1px rgba(13,16,14,0.05);
}
[data-theme="dark"] {
  --bg-0: #141414;
  --bg-1: #1a1a1a;
  --bg-2: #232323;
  --bg-3: #2c2c2c;
  --line: #2a2a2a;
  --line-2: #353535;
  --ink:  #e8efe9;
  --ink-2: #b6c0b9;
  --ink-3: #7a857e;
  --ink-4: #4a544d;
  --green: #27d97c;
  --green-2: #5fe89b;
  --green-soft: rgba(39,217,124,0.12);
  --green-glow: rgba(39,217,124,0.35);
  --brand: #ef5920;
  --brand-2: #c4471a;
  --brand-soft: rgba(239,89,32,0.14);
  --brand-glow: rgba(239,89,32,0.40);
  --accent: #ef5920;
  --accent-2: #ffd23f;
  --warn: #ff3860;
  --hot: #ef5920;
  --blue: #5cb0ff;
  --purple: #a78bfa;
  --shadow-sm: 0 1px 0 rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.03);
  --shadow-md: 0 6px 18px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-0); color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px; line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
::selection { background: var(--green-soft); color: var(--ink); }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ─── APP SHELL ───────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 100vh;
  overflow: hidden;
}

/* Sidebar */
.side {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.side-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
}
/* Brand lockup — bracket-arrow mark + clean Inter wordmark. Same shape
   as the marketing chrome so the brand is consistent across surfaces. */
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  flex-shrink: 0;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-word {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  display: inline-block;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.brand:hover .brand-word { opacity: 0.85; }
/* Class name `.green` is legacy in the wordmark; whole word is now solid
   ink so it matches the marketing lockup. Class kept to avoid churning
   every template that references it. */
.brand-word .green { color: inherit; }

.org {
  margin-top: 14px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--bg-2); cursor: pointer;
  transition: background 0.12s;
}
.org:hover { background: var(--bg-3); }
.org .av {
  width: 22px; height: 22px; border-radius: 5px;
  background: var(--ink); color: var(--bg-1);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}
.org .nm { flex: 1; font-size: 12px; font-weight: 600; }
.org .ch { color: var(--ink-3); }

.nav-group { padding: 10px 8px; }
.nav-group + .nav-group { border-top: 1px solid var(--line); }
.nav-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-4);
  padding: 6px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 6px;
  font-size: 13px; color: var(--ink-2); font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item.active {
  background: var(--green-soft); color: var(--green); font-weight: 600;
}
.nav-item.active .ic { color: var(--green); }
.nav-item .ic { width: 14px; height: 14px; color: var(--ink-3); flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  background: var(--bg-2); color: var(--ink-3);
  padding: 1px 6px; border-radius: 4px; font-weight: 600;
}
.nav-item.active .badge { background: var(--green); color: #fff; }
[data-theme="dark"] .nav-item.active .badge { color: #ffffff; }

.side-foot {
  margin-top: auto; padding: 12px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
}
.xp-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
.xp-card .top { display: flex; justify-content: space-between; align-items: center; }
.xp-card .lvl { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--ink); }
.xp-card .pts { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--green); font-weight: 600; }
.xp-bar { height: 4px; background: var(--bg-3); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.xp-bar > div {
  height: 100%; width: 73%;
  background: linear-gradient(90deg, var(--green), var(--green-2));
  box-shadow: 0 0 6px var(--green-glow);
}
.xp-card .next { font-size: 10px; color: var(--ink-3); margin-top: 6px; font-family: 'JetBrains Mono', monospace; }

/* ─── MAIN ───────────────────────────────────────────────────── */
.main {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg-0);
}
.topbar {
  height: 52px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
}
.crumb {
  display: flex; align-items: center; gap: 8px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
}
.crumb .sep { color: var(--ink-4); }
.crumb .here { color: var(--ink); font-weight: 600; }
.crumb .there { color: var(--ink-3); }

.topbar-search {
  flex: 1; max-width: 480px; margin: 0 auto;
  position: relative;
}
.topbar-search input {
  width: 100%; height: 32px;
  padding: 0 12px 0 32px;
  background: var(--bg-2);
  border: 1px solid transparent;
  border-radius: 7px;
  font: inherit; font-size: 13px; color: var(--ink);
  outline: none;
  transition: border 0.12s, background 0.12s;
}
.topbar-search input::placeholder { color: var(--ink-3); }
.topbar-search input:focus { border-color: var(--green); background: var(--bg-1); }
.topbar-search .si { position: absolute; left: 10px; top: 9px; width: 14px; height: 14px; color: var(--ink-3); }
.topbar-search .kbd {
  position: absolute; right: 8px; top: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--ink-3);
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 4px;
  padding: 2px 5px;
}

.top-actions { display: flex; align-items: center; gap: 4px; }
.ic-btn {
  width: 32px; height: 32px; border-radius: 7px;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.ic-btn:hover { background: var(--bg-2); color: var(--ink); }
.ic-btn svg { width: 16px; height: 16px; }
.ic-btn .dot {
  position: absolute; top: 6px; right: 7px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); border: 1.5px solid var(--bg-1);
}
.ic-divider { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

.theme-toggle {
  width: 56px; height: 30px; border-radius: 99px;
  background: var(--bg-2); border: 1px solid var(--line);
  position: relative; cursor: pointer;
  display: flex; align-items: center; padding: 2px;
}
.theme-toggle .knob {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-1);
  box-shadow: var(--shadow-sm);
  transform: translateX(0);
  transition: transform 0.22s cubic-bezier(0.5, 0, 0.2, 1);
  display: grid; place-items: center;
  color: var(--accent-2);
}
.theme-toggle .knob svg { width: 13px; height: 13px; }
[data-theme="dark"] .theme-toggle .knob {
  transform: translateX(26px); color: var(--green); background: var(--bg-3);
}
.theme-toggle .ic-sun, .theme-toggle .ic-moon {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; color: var(--ink-4);
  pointer-events: none;
}
.theme-toggle .ic-sun { left: 9px; }
.theme-toggle .ic-moon { right: 9px; }
[data-theme="light"] .theme-toggle .ic-sun { opacity: 0; }
[data-theme="dark"] .theme-toggle .ic-moon { opacity: 0; }

.av-me {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  border: 0; padding: 0; cursor: pointer;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
  cursor: pointer;
  border: 1.5px solid var(--bg-1);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .av-me { color: #ffffff; }

/* ─── PAGE ─────────────────────────────────────────────────── */
.page { flex: 1; overflow: auto; padding: 24px 28px 40px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px; gap: 24px; flex-wrap: wrap;
}
.page-head h1 {
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink);
}
.page-head .meta {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--ink-3); margin-top: 4px;
}
.page-head .meta b { color: var(--green); font-weight: 600; }
.page-head .actions { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px;
  font-size: 13px; font-weight: 500;
  border-radius: 7px;
  transition: all 0.12s;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-default {
  background: var(--bg-1); color: var(--ink);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow-sm);
}
.btn-default:hover { background: var(--bg-2); border-color: var(--ink-4); }
.btn-primary {
  background: var(--brand); color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.05), 0 0 0 1px var(--brand);
}
[data-theme="dark"] .btn-primary { color: #ffffff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

/* Filter chips */
.filter-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  font-size: 12px; color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.1s;
}
.chip:hover { color: var(--ink); border-color: var(--line-2); }
.chip.active { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.chip svg { width: 12px; height: 12px; }
.chip .x { color: var(--ink-4); margin-left: 4px; }
.chip.active .x { color: var(--green); }
.chip-divider { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

/* Stats */
.stat-row {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 12px; margin-bottom: 16px;
}
.stat {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat .lbl { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; }
.stat .val { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; color: var(--ink); }
.stat .delta { font-family: 'JetBrains Mono', monospace; font-size: 11px; margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.stat .delta.up { color: var(--green); }
.stat .delta.down { color: var(--accent); }
.stat .spark { margin-top: 8px; height: 24px; display: flex; align-items: end; gap: 2px; }
.stat .spark span { flex: 1; background: var(--bg-3); border-radius: 1px; }

/* Tags */
.tag {
  font-family: 'JetBrains Mono', monospace; font-size: 9px;
  padding: 1px 5px; border-radius: 3px;
  background: var(--bg-2); color: var(--ink-3);
  text-transform: lowercase; letter-spacing: 0.02em; font-weight: 600;
  display: inline-flex; align-items: center; gap: 3px;
}
.tag.signal { background: rgba(199,145,0,0.12); color: var(--accent-2); }
[data-theme="dark"] .tag.signal { background: rgba(255,210,63,0.12); }
.tag.hot { background: rgba(217,74,44,0.12); color: var(--hot); }
[data-theme="dark"] .tag.hot { background: rgba(255,91,58,0.12); }
.tag.won { background: var(--green-soft); color: var(--green); }
.tag.warm { background: rgba(44,123,229,0.12); color: var(--blue); }
.tag.cold { background: var(--bg-2); color: var(--ink-3); }
.tag.high { background: var(--green-soft); color: var(--green); }
.tag.med { background: rgba(199,145,0,0.12); color: var(--accent-2); }
[data-theme="dark"] .tag.med { background: rgba(255,210,63,0.12); }
.tag.low { background: var(--bg-2); color: var(--ink-3); }

/* Inline keyboard shortcut hint — used outside the topbar search too */
.kbd {
  display: inline-flex; align-items: center;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--ink-3);
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 4px;
  padding: 2px 5px; line-height: 1;
}

/* Card primitive */
.panel {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.panel-head h3 {
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.panel-head .h-meta {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-3);
}
.panel-body { padding: 16px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 16px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--ink-2);
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: all 0.25s ease;
  z-index: 100;
  display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .pip { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--ink-4); background-clip: content-box; }

/* ─── USER MENU ────────────────────────────────────────────── */
.user-menu {
  position: fixed; top: 56px; right: 18px; z-index: 200;
  width: 340px; max-height: calc(100vh - 80px); overflow-y: auto;
  /* Solid background with a subtle green-tinted top fade — was previously
     `var(--bg)` (undefined token) which made the menu transparent and let
     the dashboard hero bleed through, making it unreadable. */
  background:
    radial-gradient(420px 180px at 100% 0%, rgba(39,217,124,0.06), transparent 70%),
    var(--bg-1);
  border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.35), 0 0 0 1px rgba(39,217,124,0.04);
  font-family: var(--sans); animation: umIn 0.14s ease-out;
}
[data-theme="dark"] .user-menu {
  background:
    radial-gradient(420px 180px at 100% 0%, rgba(39,217,124,0.08), transparent 70%),
    var(--bg-1);
  box-shadow: 0 24px 60px -10px rgba(0,0,0,0.7), 0 0 0 1px rgba(39,217,124,0.06);
}
@keyframes umIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.um-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-bottom: 1px solid var(--line);
}
.um-av {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  display: grid; place-items: center; color: #ffffff;
  font-family: var(--mono); font-size: 13px; font-weight: 700;
}
.um-id { min-width: 0; flex: 1; }
.um-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.um-meta { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-top: 2px; letter-spacing: 0.04em; }
.um-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.um-section:last-child { border-bottom: 0; }
.um-label {
  font-family: var(--mono); font-size: 9px; color: var(--ink-3);
  letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 8px;
}
.um-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 6px; border-radius: 6px;
  font-size: 12px; color: var(--ink-2);
  gap: 10px;
}
.um-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.um-row.meter { flex-direction: column; align-items: stretch; gap: 4px; padding-top: 4px; }
.um-row-name { font-size: 12px; color: var(--ink); font-weight: 500; }
.um-row-sub { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-top: 2px; }
.um-green { color: var(--green); }
.um-toggle {
  width: 32px; height: 18px; border-radius: 999px; border: 0;
  background: var(--bg-3); position: relative; cursor: pointer;
  transition: background 0.15s; padding: 0; flex-shrink: 0;
}
.um-toggle span {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink-3); transition: transform 0.15s, background 0.15s;
}
.um-toggle.on { background: rgba(39,217,124,0.25); }
.um-toggle.on span { transform: translateX(14px); background: var(--green); }
.um-select, .um-input {
  width: 100%; box-sizing: border-box;
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 8px 10px; font-family: var(--mono); font-size: 11px;
  color: var(--ink); outline: none;
}
.um-select:focus, .um-input:focus { border-color: var(--green); }
.um-meter { width: 100%; height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.um-meter > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--green-2)); }
.um-meter-lbl { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.um-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 6px; border-radius: 6px;
  font-size: 12px; color: var(--ink-2); text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.um-item:hover { background: var(--bg-1); color: var(--ink); }
.um-item.danger { color: #d44a4a; }
.um-item.danger:hover { background: rgba(212,74,74,0.08); }
.um-pin {
  font-family: var(--mono); font-size: 9px; color: var(--green);
  background: rgba(39,217,124,0.1); padding: 2px 6px; border-radius: 999px;
  letter-spacing: 0.08em;
}
.um-kbd {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  background: var(--bg-1); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 4px;
}

/* ─── CHEATSHEET OVERLAY ──────────────────────────────────── */
/* HTML [hidden] must beat the explicit display:grid on .cs-overlay
   and any block default on .user-menu — author CSS otherwise wins
   over the user-agent stylesheet's [hidden] { display: none } and
   the cheatsheet shows on every app-shell page load. */
.cs-overlay[hidden], .user-menu[hidden] { display: none !important; }
.cs-overlay {
  position: fixed; inset: 0; z-index: 300;
  /* Heavier dim so the white card pops cleanly. Light theme uses a soft
     warm dim, dark theme uses near-black. No backdrop blur (was glass). */
  background: rgba(0, 0, 0, 0.45);
  display: grid; place-items: center;
  animation: csIn 0.16s ease-out;
}
[data-theme="dark"] .cs-overlay { background: rgba(8, 12, 10, 0.7); }
@keyframes csIn { from { opacity: 0; } to { opacity: 1; } }
.cs-card {
  width: min(880px, 92vw); max-height: 88vh; overflow-y: auto;
  /* Solid card with subtle green-tinted corner fade. Was `var(--bg)` (undefined
     token) which rendered transparent and let the page bleed through. */
  background:
    radial-gradient(600px 240px at 100% 0%, rgba(39,217,124,0.06), transparent 70%),
    radial-gradient(400px 200px at 0% 100%, rgba(39,217,124,0.04), transparent 70%),
    var(--bg-1);
  border: 1px solid var(--line-2); border-radius: 14px;
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.5), 0 0 0 1px rgba(39,217,124,0.05);
  font-family: var(--sans);
}
.cs-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 26px 18px; border-bottom: 1px solid var(--line);
}
.cs-eye { font-family: var(--mono); font-size: 11px; color: var(--green); letter-spacing: 0.12em; }
.cs-h1 {
  font-family: var(--display, var(--sans)); font-size: 22px; font-weight: 700;
  color: var(--ink); margin-top: 4px; letter-spacing: -0.01em;
}
.cs-x {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 6px;
  width: 32px; height: 32px; cursor: pointer; color: var(--ink-2);
  font-size: 14px; line-height: 1;
}
.cs-x:hover { border-color: var(--green); color: var(--ink); }
.cs-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 28px;
  padding: 20px 26px;
}
@media (max-width: 720px) { .cs-grid { grid-template-columns: 1fr; } }
.cs-col { padding: 8px 0; }
.cs-title {
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.cs-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; gap: 14px;
}
.cs-keys { display: inline-flex; gap: 4px; flex-shrink: 0; }
.cs-keys kbd {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  color: var(--ink); background: var(--bg-1);
  border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 4px; padding: 2px 6px; min-width: 18px; text-align: center;
  line-height: 1.4;
}
.cs-act { font-size: 12px; color: var(--ink-2); text-align: right; }
.cs-foot {
  padding: 14px 26px 18px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.04em;
}
.cs-foot kbd {
  font-family: var(--mono); font-size: 10px; color: var(--ink);
  background: var(--bg-1); border: 1px solid var(--line-2);
  border-radius: 3px; padding: 1px 5px;
}

/* ─── TOPBAR DROPDOWN POPOVER (Activity / Inbox / Notifications) ─── */
.tbpop {
  position: absolute;
  width: 340px; max-width: calc(100vw - 24px);
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.45), 0 0 0 1px rgba(39,217,124,0.06);
  z-index: 250; overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
}
.tbpop[hidden] { display: none; }
.tbpop-arrow {
  position: absolute; top: -6px; right: 24px;
  width: 12px; height: 12px;
  background: var(--bg-1);
  border-left: 1px solid var(--line-2); border-top: 1px solid var(--line-2);
  transform: rotate(45deg);
}
.tbpop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.tbpop-title {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700;
  color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase;
}
.tbpop-link {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--green); text-decoration: none; font-weight: 600;
}
.tbpop-link:hover { text-decoration: underline; }
.tbpop-body {
  max-height: 400px; overflow-y: auto;
}
.tbpop-empty {
  padding: 28px 16px; text-align: center;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--ink-3);
  line-height: 1.6;
}
.tbpop-empty a { color: var(--green); text-decoration: underline; }
.tbpop-row {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: center; transition: background 0.1s;
}
.tbpop-row:last-child { border-bottom: 0; }
.tbpop-row:hover { background: var(--bg-2); }
.tbpop-ic {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700;
  background: var(--bg-2); color: var(--ink-3);
  border: 1px solid var(--line-2);
}
.tbpop-ic.act { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.tbpop-ic.hot { background: rgba(255,91,58,0.12); color: oklch(0.72 0.18 28); border-color: rgba(255,91,58,0.4); }
.tbpop-ic.warm { background: rgba(255,170,30,0.10); color: oklch(0.78 0.15 80); border-color: rgba(255,170,30,0.4); }
.tbpop-ic.badge { background: rgba(255,210,63,0.12); color: #ffd23f; border-color: rgba(255,210,63,0.5); }
.tbpop-ic.task { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.tbpop-body-row { min-width: 0; overflow: hidden; }
.tbpop-line {
  font-size: 13px; color: var(--ink); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tbpop-co { color: var(--ink-3); font-weight: 400; }
.tbpop-sub {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  color: var(--ink-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tbpop-when {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--ink-3);
  white-space: nowrap;
}

/* Red-dot indicator on each topbar icon when unread/fresh content exists */
.ic-btn { position: relative; }
.ic-btn .tbpop-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(255,91,58,0.6);
  border: 1.5px solid var(--bg-1);
  pointer-events: none;
}
.ic-btn .tbpop-dot[hidden] { display: none; }

/* ─────────────────────────────────────────────────────────────
   Shared form + modal + drawer primitives
   (2026-05-07 design refresh — theme-aware, inherits the existing
   --bg-/--ink-/--green/--line tokens so light + dark both work)
   ───────────────────────────────────────────────────────────── */

/* ─── Form atoms ─── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-3); display: flex; align-items: center; gap: 6px;
}
.label .req { color: var(--accent); }
.label .hint {
  color: var(--ink-4); text-transform: none; letter-spacing: 0.04em;
  font-weight: 500; margin-left: auto;
}
.input, .textarea, .select {
  width: 100%; box-sizing: border-box;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 7px; padding: 9px 11px; font: inherit; font-size: 13px;
  color: var(--ink); outline: none;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--green); background: var(--bg-1);
  box-shadow: 0 0 0 3px rgba(10,135,84,0.10);
}
[data-theme="dark"] .input:focus,
[data-theme="dark"] .textarea:focus,
[data-theme="dark"] .select:focus {
  box-shadow: 0 0 0 3px rgba(39,217,124,0.10);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input.error, .textarea.error, .select.error { border-color: var(--warn); }
.input.error:focus, .textarea.error:focus {
  box-shadow: 0 0 0 3px rgba(214,48,96,0.12);
}
.field .err {
  font-family: var(--mono); font-size: 10px; color: var(--warn);
  display: flex; align-items: center; gap: 5px;
}
.textarea { resize: vertical; min-height: 80px; line-height: 1.55; }

.input-group { position: relative; }
.input-group .prefix, .input-group .suffix {
  position: absolute; top: 0; bottom: 0;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; color: var(--ink-3);
  pointer-events: none;
}
.input-group .prefix { left: 11px; }
.input-group .suffix { right: 11px; }
.input-group .input.has-prefix { padding-left: 26px; }
.input-group .input.has-suffix { padding-right: 36px; }
.input-group .ic-suffix {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--ink-3); pointer-events: none;
}

.select-wrap { position: relative; }
.select-wrap .select { appearance: none; padding-right: 30px; cursor: pointer; }
.select-wrap::after {
  content: ''; position: absolute; right: 12px; top: 50%;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.toggle .sw {
  width: 36px; height: 20px; border-radius: 999px;
  background: var(--bg-3); position: relative;
  transition: background .15s; flex-shrink: 0;
}
.toggle .sw::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink-3); transition: transform .15s, background .15s;
}
.toggle.on .sw { background: var(--green-soft); }
.toggle.on .sw::after { transform: translateX(16px); background: var(--green); }
.toggle .lbl-text { font-size: 13px; color: var(--ink-2); }

.chip-multi {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 7px; min-height: 38px;
}
.chip-multi .pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; background: var(--green-soft); color: var(--green);
  border-radius: 4px; font-family: var(--mono); font-size: 11px; font-weight: 600;
}
.chip-multi .pill .x { cursor: pointer; opacity: 0.6; }
.chip-multi .pill .x:hover { opacity: 1; }
.chip-multi input {
  background: transparent; border: 0; outline: 0;
  flex: 1; min-width: 100px; color: var(--ink);
  font: inherit; font-size: 12px; padding: 3px 4px;
}

/* ─── DealArena Modal v2 (used by da-modal.js — see also v1 .da-modal* classes) ─── */
.dam-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(8,12,10,0.55); backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 40px 20px;
  animation: damOverlayIn .16s ease-out;
}
.dam-overlay.closing { animation: damOverlayOut .14s ease-in forwards; }
@keyframes damOverlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes damOverlayOut { to { opacity: 0; } }

.dam {
  width: 100%; max-width: 540px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden; max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  animation: damIn .18s cubic-bezier(.2,.7,.3,1);
  font-family: var(--sans, 'Inter', system-ui, sans-serif);
  color: var(--ink);
}
.dam.closing { animation: damOut .14s ease-in forwards; }
@keyframes damIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes damOut {
  to { opacity: 0; transform: translateY(4px) scale(.985); }
}
.dam .dam-head {
  padding: 18px 20px 14px;
  display: flex; align-items: flex-start; gap: 12px;
  border-bottom: 1px solid var(--line);
}
.dam .dam-eyebrow {
  font-family: var(--mono); font-size: 10px;
  color: var(--green); letter-spacing: 0.16em;
  text-transform: uppercase; font-weight: 700;
}
.dam .dam-head h2 {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.01em; margin: 4px 0 0;
  color: var(--ink);
}
.dam .dam-head .dam-sub {
  font-size: 12px; color: var(--ink-2); margin-top: 4px; line-height: 1.5;
}
.dam .dam-x {
  margin-left: auto; width: 28px; height: 28px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--ink-3); background: var(--bg-2);
  border: 1px solid var(--line); cursor: pointer; padding: 0;
  font-size: 18px; line-height: 1;
}
.dam .dam-x:hover { color: var(--ink); border-color: var(--line-2); }
.dam .dam-banner-error {
  margin: 0 20px 14px; padding: 10px 12px; border-radius: 7px;
  background: rgba(214,48,96,0.08);
  border: 1px solid rgba(214,48,96,0.25);
  color: var(--warn); font-family: var(--mono); font-size: 11px;
  display: flex; align-items: flex-start; gap: 8px;
}
.dam .dam-banner-error[hidden] { display: none !important; }
[data-theme="dark"] .dam .dam-banner-error {
  background: rgba(255,56,96,0.08);
  border-color: rgba(255,56,96,0.25);
}
.dam .dam-body {
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; flex: 1; min-height: 0;
}
.dam .dam-foot {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-1);
}
.dam .dam-foot .left {
  margin-right: auto; display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.dam .dam-foot .left a { color: var(--green); cursor: pointer; }
.dam .dam-foot .left a:hover { text-decoration: underline; }

/* ─── Right-rail workspace drawer (used by Origin, Tasks etc.) ─── */
.app-drawer {
  width: 380px; flex-shrink: 0;
  background: var(--bg-1); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow-y: auto;
}

/* ─── Page filter strip (used by CSM/Tasks pages) ─── */
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 0; margin-bottom: 16px;
}
