/* ==========================================================================
   Consolo Workspace — application shell
   --------------------------------------------------------------------------
   Tokens are lifted verbatim from the consolo.bashara.pt design system so the
   product and the marketing site read as one brand: ink/paper surfaces, amber
   as the single accent, teal for secondary signal, Inter throughout.

   Structure follows the Pure Essence workspace: fixed dark sidebar with
   collapsible nav groups, one <section class="view"> per screen, tables and a
   detail modal for drill-downs.

   Contrast rule (inherited from the site): every text/surface pair meets
   WCAG 2.2 AA — 4.5:1 for body, 3:1 for large text and UI borders. Surfaces
   that are always dark (the sidebar) re-bind the semantic tokens via .on-dark
   so a component can never inherit the wrong pairing.
   ========================================================================== */

/* -------------------------------------------------- 1. Fonts ------------- */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* -------------------------------------------------- 2. Tokens ------------ */

:root {
  /* raw palette — consolo.bashara.pt */
  --ink-900: #05161d;
  --ink-800: #0b1e26;
  --ink-700: #122e38;
  --ink-600: #1b3f4b;
  --ink-500: #2a5461;

  --paper-000: #ffffff;
  --paper-100: #f6f8f7;
  --paper-200: #eef2f1;
  --paper-300: #e2e8e7;

  --amber-300: #f5c684;
  --amber-400: #f2b661;
  --amber-500: #e9a23b;
  --amber-600: #d98b1f;
  --amber-800: #8a5a12;   /* 5.54:1 on --paper-100 — safe for small text */

  --teal-400: #7cc0b8;
  --teal-500: #5fa8a0;
  --teal-700: #33716b;

  --mint-400: #7ae8b0;
  --danger-600: #b3261e;

  /* semantic: light surfaces (default) */
  --surface: var(--paper-100);
  --surface-raised: var(--paper-000);
  --surface-sunken: var(--paper-200);

  --text: var(--ink-800);
  --text-muted: #4a5c63;
  --text-subtle: #55666d;
  --text-accent: var(--amber-800);
  --text-inverse: var(--paper-000);

  --border: rgba(11, 30, 38, 0.10);
  --border-strong: rgba(11, 30, 38, 0.18);
  --focus-ring: var(--ink-800);

  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;

  --fs-h1: 1.5rem;
  --fs-h2: 1.15rem;
  --fs-body: 0.9375rem;
  --fs-sm: 0.875rem;
  --fs-xs: 0.8rem;
  --fs-2xs: 0.72rem;

  --tracking-heading: -0.02em;
  --tracking-eyebrow: 0.14em;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(5, 22, 29, 0.06), 0 2px 8px rgba(5, 22, 29, 0.04);
  --shadow-md: 0 4px 12px rgba(5, 22, 29, 0.08), 0 12px 32px rgba(5, 22, 29, 0.06);
  --shadow-lg: 0 12px 32px rgba(5, 22, 29, 0.12), 0 32px 64px rgba(5, 22, 29, 0.10);

  --dur-fast: 140ms;
  --dur: 240ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --side-w: 15.5rem;
}

/* Dark mode flips the content surfaces. The sidebar is always dark and keeps
   its own .on-dark binding, so it is unaffected. */
:root[data-theme="dark"] {
  --surface: #0e1a1f;
  --surface-raised: #14242b;
  --surface-sunken: #0a1418;

  --text: #eaf1f2;
  --text-muted: #b3c3c7;
  --text-subtle: #9db0b5;
  --text-accent: var(--amber-400);
  --text-inverse: var(--ink-800);

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.24);
  --focus-ring: var(--amber-400);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30), 0 2px 8px rgba(0, 0, 0, 0.20);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.30), 0 16px 40px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.38), 0 40px 80px rgba(0, 0, 0, 0.30);
}

/* Any element inside inherits the correct on-dark pairing. */
.on-dark {
  --surface: var(--ink-800);
  --surface-raised: rgba(255, 255, 255, 0.07);
  --surface-sunken: rgba(255, 255, 255, 0.03);

  --text: var(--paper-000);
  --text-muted: #cfdadd;
  --text-subtle: #b9c6ca;
  --text-accent: var(--amber-500);
  --text-inverse: var(--ink-800);

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.24);
  --focus-ring: var(--amber-400);

  color: var(--text);
}

/* -------------------------------------------------- 3. Reset & base ------ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  font-feature-settings: 'cv11' 1, 'ss01' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 800;
  letter-spacing: var(--tracking-heading);
  line-height: 1.25;
}

a { color: var(--text-accent); }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.eyebrow {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-subtle);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* -------------------------------------------------- 4. Shell ------------- */

.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */

.side {
  background: var(--ink-800);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-md) var(--space-sm) var(--space-sm);
}
.side-brand svg { width: 30px; height: 30px; flex: none; }
.side-brand .wm { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.side-brand .wm b {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--paper-000);
}
.side-brand .wm span {
  font-size: var(--fs-2xs);
  letter-spacing: 0.04em;
  color: var(--text-subtle);
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2xs) var(--space-2xs) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tab {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.tab svg { width: 17px; height: 17px; flex: none; }
.tab .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab:hover { background: rgba(255, 255, 255, 0.06); color: var(--paper-000); }
.tab[aria-selected="true"] {
  background: rgba(233, 162, 59, 0.14);
  color: var(--paper-000);
  font-weight: 600;
}
/* Amber rail marks the active screen — the one accent in the nav. */
.tab[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--amber-500); }

.subtab { padding-left: 2.1rem; font-size: var(--fs-sm); }
.subtab svg { width: 15px; height: 15px; }

.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navgroup .navsec {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  max-height: 20rem;
  transition: max-height var(--dur) var(--ease);
}
.navgroup.collapsed .navsec { max-height: 0; }
.chev {
  width: 14px; height: 14px; flex: none;
  transition: transform var(--dur) var(--ease);
}
.navgroup.collapsed .chev { transform: rotate(-90deg); }

/* An empty count must not leave a floating chip behind. */
.pill:empty { display: none; }
.pill {
  font-size: var(--fs-2xs);
  font-weight: 700;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-muted);
}

.side-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: var(--space-2xs);
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
}
.side-user { flex: 1; min-width: 0; line-height: 1.2; }
.side-user b {
  display: block;
  font-size: var(--fs-xs);
  color: var(--paper-000);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-user span { font-size: var(--fs-2xs); color: var(--text-subtle); }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--paper-000); }
.icon-btn svg { width: 15px; height: 15px; }

/* ---- Main ---- */

.main {
  min-width: 0;
  padding: var(--space-md) var(--space-lg) var(--space-xl);
}

.view { display: none; }
.view.is-active { display: block; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}
.view-head h1 { font-size: var(--fs-h1); }
.view-head p { margin: 0.25rem 0 0; color: var(--text-muted); font-size: var(--fs-sm); max-width: 62ch; }

/* -------------------------------------------------- 5. Components -------- */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-md);
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--ink-800);
  color: var(--paper-000);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--ink-700); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.btn-accent { background: var(--amber-500); color: var(--ink-900); }
.btn-accent:hover { background: var(--amber-600); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-sunken); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: var(--fs-xs); }

/* ---- Form controls ---- */

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
  font: inherit;
  font-size: var(--fs-sm);
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber-500);
  box-shadow: 0 0 0 3px rgba(233, 162, 59, 0.22);
}
input::placeholder { color: var(--text-subtle); }
input[type="checkbox"] { accent-color: var(--amber-600); width: 15px; height: 15px; cursor: pointer; }

/* ---- Segmented tabs (Companies / Contacts) ---- */

.segtabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  margin-bottom: var(--space-md);
}
.segtab {
  padding: 0.4rem 0.9rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segtab.is-on {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---- Search + filter bar ---- */

.searchbar {
  display: flex;
  gap: var(--space-2xs);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-2xs);
}
.searchbar input[type="text"] { min-width: 15rem; flex: 1 1 15rem; max-width: 26rem; }
.searchbar .spacer { margin-left: auto; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs) var(--space-sm);
  align-items: center;
  padding: var(--space-2xs) 0 var(--space-sm);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-sm);
}
.filters .flabel { font-size: var(--fs-xs); color: var(--text-muted); }
.frange { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-xs); color: var(--text-muted); }
.frange input { width: 5.5rem; }

.levels { display: inline-flex; align-items: center; gap: 0.3rem 0.85rem; flex-wrap: wrap; font-size: var(--fs-xs); }
.lvl { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; white-space: nowrap; color: var(--text); }

/* Multi-select dropdown (industries) */
.multi { position: relative; }
.multi > summary {
  list-style: none;
  cursor: pointer;
  font-size: var(--fs-sm);
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
}
.multi > summary::-webkit-details-marker { display: none; }
.multi > summary::after { content: "▾"; color: var(--text-subtle); font-size: 0.7rem; }
.multi[open] > summary { border-color: var(--amber-500); }
.multi-n {
  background: var(--amber-500);
  color: var(--ink-900);
  border-radius: var(--radius-pill);
  font-size: var(--fs-2xs);
  font-weight: 700;
  padding: 0.05rem 0.4rem;
}
.multi-panel {
  position: absolute;
  z-index: 30;
  margin-top: 0.3rem;
  min-width: 16rem;
  max-height: 17rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: var(--space-xs);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}

/* ---- Result summary ---- */

.summary {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  min-height: 1.4rem;
  margin-bottom: var(--space-2xs);
}
.summary b { color: var(--text); }
.ok { color: var(--teal-700); font-weight: 600; }
:root[data-theme="dark"] .ok { color: var(--teal-400); }
.err { color: var(--danger-600); font-weight: 600; }
:root[data-theme="dark"] .err { color: #f28b84; }

/* ---- Tables ---- */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
table.grid th {
  text-align: left;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.grid td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr.row { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
table.grid tbody tr.row:hover { background: var(--surface-sunken); }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid .strong { font-weight: 650; color: var(--text); }
table.grid .is-saved { background: rgba(95, 168, 160, 0.08); }

.empty, .loading {
  padding: var(--space-lg);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-2xs);
  font-weight: 600;
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.chip-saved { background: rgba(95, 168, 160, 0.16); color: var(--teal-700); border-color: rgba(95, 168, 160, 0.35); }
:root[data-theme="dark"] .chip-saved { color: var(--teal-400); }

/* The "$" marker on actions that spend a ZoomInfo enrichment credit. */
.cost { color: var(--amber-800); font-weight: 800; }
:root[data-theme="dark"] .cost { color: var(--amber-400); }

.linkish {
  color: var(--text-accent);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.linkish:hover { text-decoration: underline; }

/* ---- Detail modal ---- */

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-sm);
  background: rgba(5, 22, 29, 0.55);
  backdrop-filter: blur(2px);
}
.modal-card {
  width: min(46rem, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface-raised);
  z-index: 1;
}
.modal-head h2 { flex: 1; font-size: var(--fs-h2); }
/* The close button sits on a light surface, so it can't use the sidebar's on-dark hover. */
.modal-head .icon-btn { color: var(--text-muted); }
.modal-head .icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.modal-body { padding: var(--space-md); }

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: var(--space-xs) var(--space-md);
}
.kv .k {
  display: block;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.kv .v { display: block; font-size: var(--fs-sm); word-break: break-word; }

.modal-sec {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-subtle);
}
.modal-prose { font-size: var(--fs-sm); color: var(--text-muted); margin-top: var(--space-2xs); }
.modal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  flex-wrap: wrap;
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  right: var(--space-md);
  bottom: var(--space-md);
  z-index: 200;
  max-width: 24rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  background: var(--ink-800);
  color: var(--paper-000);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.is-on { opacity: 1; transform: none; }

/* ---- Empty-state panel for the not-yet-built screens ---- */

.placeholder {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  padding: var(--space-xl) var(--space-lg);
  max-width: 46rem;
}
.placeholder h2 { font-size: var(--fs-h2); margin-bottom: var(--space-2xs); }
.placeholder p { color: var(--text-muted); font-size: var(--fs-sm); margin: 0 0 var(--space-xs); }
.placeholder ul { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; padding-left: 1.1rem; }
.placeholder li { margin-bottom: 0.3rem; }
.placeholder code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-sunken);
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
}

/* ---- Section heading inside a view ---- */

.sec-head {
  font-size: var(--fs-h2);
  margin: var(--space-lg) 0 var(--space-2xs);
}
.lede {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  max-width: 68ch;
  margin: 0 0 var(--space-sm);
}

/* Scope banner: "showing everyone at X" */
.scope-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  flex-wrap: wrap;
  padding: var(--space-2xs) var(--space-xs);
  margin-bottom: var(--space-2xs);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber-500);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-size: var(--fs-sm);
}

/* Inline config warning */
.notice {
  padding: var(--space-xs) var(--space-sm);
  margin-bottom: var(--space-sm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber-500);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  max-width: 76ch;
}
.notice b { color: var(--text); }
.notice code, .placeholder code, .empty code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-sunken);
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
}

.chip-warn { background: rgba(233, 162, 59, 0.18); color: var(--amber-800); border-color: rgba(233, 162, 59, 0.4); }
:root[data-theme="dark"] .chip-warn { color: var(--amber-300); }
.chip-active { background: rgba(95, 168, 160, 0.12); color: var(--teal-700); border-color: rgba(95, 168, 160, 0.3); }
:root[data-theme="dark"] .chip-active { color: var(--teal-400); }
.chip-signal { background: var(--ink-800); color: var(--paper-000); border-color: transparent; }

/* ---- Card grid (templates, sequences) ---- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr));
  gap: var(--space-sm);
}

.tpl h3 { font-size: 1rem; margin-bottom: var(--space-3xs); }
.tpl-subject { font-size: var(--fs-sm); color: var(--text); margin: 0 0 var(--space-2xs); font-weight: 600; }
/* Clipped preview — fade the cut rather than slicing a sentence in half. */
.tpl-body {
  position: relative;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0 0 var(--space-sm);
  white-space: pre-wrap;
  max-height: 7rem;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
}
.tpl-actions { display: flex; gap: var(--space-3xs); }

/* ---- Sequence card + funnel ---- */

.seq-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2xs);
  margin-bottom: var(--space-sm);
}
.seq-head h3 { font-size: 1rem; }
.seq-head p { margin: 0.15rem 0 0; font-size: var(--fs-xs); }
.seq-btns { display: flex; gap: var(--space-3xs); flex: none; }

.funnel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4.5rem, 1fr));
  gap: var(--space-2xs);
  padding-top: var(--space-2xs);
  border-top: 1px solid var(--border);
}
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 1.15rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { font-size: var(--fs-2xs); color: var(--text-subtle); }
.stat-good b { color: var(--teal-700); }
:root[data-theme="dark"] .stat-good b { color: var(--teal-400); }
.stat-bad b { color: var(--danger-600); }
:root[data-theme="dark"] .stat-bad b { color: #f28b84; }

.reply {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  max-width: 22rem;
}

/* ---- Scoops (buying signals) ---- */

.scoops { display: grid; gap: var(--space-2xs); }
.scoop {
  padding: var(--space-sm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal-500);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}
.scoop header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2xs); }
.scoop header b { font-size: var(--fs-body); }
.scoop header span { font-size: var(--fs-xs); }
.scoop p { margin: var(--space-3xs) 0 var(--space-2xs); font-size: var(--fs-sm); color: var(--text-muted); }
.scoop footer { display: flex; align-items: center; gap: var(--space-2xs); flex-wrap: wrap; }

/* ---- Forms in the modal ---- */

.form { display: flex; flex-direction: column; }
.field-lbl {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin: var(--space-2xs) 0 0.2rem;
}
.form input[type="text"], .form input[type="number"], .form select, .form textarea { width: 100%; }
.form textarea { font-family: inherit; line-height: 1.55; resize: vertical; }

.tokens { display: flex; align-items: center; gap: var(--space-3xs); flex-wrap: wrap; margin-top: var(--space-2xs); }
.tok { cursor: pointer; font-family: var(--font-mono); }
.tok:hover { background: var(--surface-raised); border-color: var(--amber-500); color: var(--text); }

.preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  padding: var(--space-sm);
  margin-top: var(--space-2xs);
}
.preview-subject { font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--space-2xs); }
.preview-body, .note-text {
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: pre-wrap;
  margin: 0;
}

/* ---- Sequence step editor ---- */

.step {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2xs) var(--space-xs) var(--space-xs);
  margin-bottom: var(--space-2xs);
  background: var(--surface-sunken);
}
.step-head { display: flex; align-items: center; gap: var(--space-2xs); flex-wrap: wrap; margin-bottom: var(--space-2xs); }
.step-head label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: var(--fs-xs); }
.step-inline { display: flex; flex-direction: column; gap: var(--space-3xs); }
.step-inline[hidden] { display: none; }

/* ---- Pipeline board ---- */

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(11.5rem, 1fr);   /* all six stages fit a laptop; scrolls below that */
  gap: var(--space-2xs);
  overflow-x: auto;
  padding-bottom: var(--space-2xs);
  align-items: start;
}
.col {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  min-width: 0;
}
.col-head {
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
  padding: var(--space-2xs) var(--space-xs);
  border-bottom: 1px solid var(--border);
}
.col-head b { font-size: var(--fs-sm); }
.col-head .subtle { margin-left: auto; font-size: var(--fs-2xs); }
.col-body { display: flex; flex-direction: column; gap: var(--space-3xs); padding: var(--space-2xs); }
.col-empty { text-align: center; color: var(--text-subtle); font-size: var(--fs-xs); padding: var(--space-2xs); }

.deal {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.deal:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.deal b { font-size: var(--fs-sm); }
.deal .subtle { font-size: var(--fs-2xs); }
.deal footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3xs); margin-top: var(--space-3xs); }

/* ---- Deal history ---- */

.timeline { list-style: none; margin: var(--space-2xs) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2xs); }
.timeline li { padding-left: var(--space-2xs); border-left: 2px solid var(--border); }
.timeline .subtle { font-size: var(--fs-2xs); display: block; }

/* -------------------------------------------------- 6. Login ------------- */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-md);
  background:
    radial-gradient(60rem 32rem at 80% -10%, rgba(233, 162, 59, 0.10), transparent 60%),
    radial-gradient(48rem 28rem at 0% 110%, rgba(95, 168, 160, 0.10), transparent 60%),
    var(--ink-800);
}
.login-card {
  width: min(24rem, 100%);
  background: var(--paper-000);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-lg);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-bottom: var(--space-md);
}
.login-brand svg { width: 34px; height: 34px; }
.login-brand b { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; color: var(--ink-800); }
.login-brand span { display: block; font-size: var(--fs-2xs); color: #55666d; letter-spacing: 0.04em; }
.field { margin-bottom: var(--space-sm); }
.field label {
  display: block;
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #55666d;
  margin-bottom: 0.3rem;
}
.field input { width: 100%; }
.login-card .btn { width: 100%; justify-content: center; }
.login-msg { margin-top: var(--space-2xs); font-size: var(--fs-sm); min-height: 1.2rem; }
.login-hint { margin-top: var(--space-sm); font-size: var(--fs-2xs); color: #55666d; text-align: center; }

/* -------------------------------------------------- 7. Responsive -------- */

@media (max-width: 60rem) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .side-brand { padding: var(--space-2xs) var(--space-sm); }
  .nav { flex-direction: row; align-items: center; padding: var(--space-2xs); overflow-x: auto; }
  .navgroup { flex-direction: row; align-items: center; }
  .navgroup .navsec { flex-direction: row; max-height: none; }
  .navgroup.collapsed .navsec { max-height: none; }
  .tab { width: auto; white-space: nowrap; }
  .subtab { padding-left: 0.625rem; }
  .side-foot { border-top: 0; border-left: 1px solid rgba(255, 255, 255, 0.08); }
  .side-user { display: none; }
  .main { padding: var(--space-sm); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
