:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --accent-soft: #e6eefb;
  --warn: #b25e00;
  --warn-soft: #fff1df;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1e7b48;
  --ok-soft: #e4f4ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  /* Stage colors, in pipeline order. Validated as a set (adjacent CVD and normal-vision
     separation) against --surface in both modes; keep this order if you edit them. */
  --stage-1: #2a78d6;
  --stage-2: #eb6834;
  --stage-3: #1baf7a;
  --stage-4: #eda100;
  --stage-5: #e87ba4;
  --stage-6: #008300;
  --stage-7: #6250d6;
  --stage-8: #e34948;
  --stage-none: #898781;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --border: #2b313a;
    --text: #e7eaee;
    --muted: #98a2b0;
    --accent: #5b9bff;
    --accent-text: #0b1220;
    --accent-soft: #1b2a42;
    --warn: #f0a24a;
    --warn-soft: #3a2a15;
    --danger: #ff7b6e;
    --danger-soft: #3d1c19;
    --ok: #5fcf8f;
    --ok-soft: #173225;
    --shadow: none;
    --stage-1: #3987e5;
    --stage-2: #d95926;
    --stage-3: #199e70;
    --stage-4: #c98500;
    --stage-5: #d55181;
    --stage-6: #008300;
    --stage-7: #9085e9;
    --stage-8: #e66767;
    color-scheme: dark;
  }
}
/* Same dark values, for when the viewer picks dark with the theme toggle. */
:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f242c;
  --border: #2b313a;
  --text: #e7eaee;
  --muted: #98a2b0;
  --accent: #5b9bff;
  --accent-text: #0b1220;
  --accent-soft: #1b2a42;
  --warn: #f0a24a;
  --warn-soft: #3a2a15;
  --danger: #ff7b6e;
  --danger-soft: #3d1c19;
  --ok: #5fcf8f;
  --ok-soft: #173225;
  --shadow: none;
  --stage-1: #3987e5;
  --stage-2: #d95926;
  --stage-3: #199e70;
  --stage-4: #c98500;
  --stage-5: #d55181;
  --stage-6: #008300;
  --stage-7: #9085e9;
  --stage-8: #e66767;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); }
.muted { color: var(--muted); }
.spacer { flex: 1; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; color: var(--text); text-decoration: none; }

/* round top-bar buttons: refresh, and settings (shows your initials once signed in) */
.icon-round {
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
  border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; padding: 0;
}
.icon-round:hover, .icon-round.active { color: var(--text); background: var(--surface-2); }
.icon-round svg { width: 17px; height: 17px; }
.avatar.has-initials { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-size: 12px; font-weight: 700; }
.avatar.has-initials svg { display: none; }
.avatar.active { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-round.small { width: 28px; height: 28px; font-size: 14px; }
.icon-round:disabled { opacity: .35; cursor: default; background: transparent; color: var(--muted); }

/* top-bar link to the For review page, with the number of deals marked */
.review-link {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.review-link svg { width: 15px; height: 15px; flex: none; }
.review-link:hover { color: var(--text); background: var(--surface-2); }
.review-link.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.review-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-size: 11px; font-variant-numeric: tabular-nums;
}
.review-badge { margin-left: 6px; color: var(--accent); font-size: 12px; }

/* For review page */
.review-page { max-width: 900px; margin: 0 auto; padding: 20px; }
.review-head { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 4px; }
.review-head h1 { font-size: 22px; }
.review-head .btn { align-self: center; }
#review-help { margin: 0 0 14px; }
.review-empty {
  margin-top: 16px; padding: 28px 20px; text-align: center; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.review-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.review-card {
  position: relative; display: flex; gap: 14px; padding: 14px 16px 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c);
  border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
}
.review-card:hover { box-shadow: 0 2px 8px rgba(16, 24, 40, .12); }
.review-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.review-card.dragging { opacity: .5; }
.review-card.drop-before::before, .review-card.drop-after::after {
  content: ""; position: absolute; left: 0; right: 0; height: 3px; border-radius: 2px; background: var(--accent);
}
.review-card.drop-before::before { top: -7px; }
.review-card.drop-after::after { bottom: -7px; }
.review-num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; cursor: grab;
  background: color-mix(in srgb, var(--c) 18%, var(--surface)); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
}
.review-main { flex: 1; min-width: 0; }
.review-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.review-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.review-title .deal-name { font-size: 16px; }
.review-controls { display: flex; align-items: center; gap: 6px; }
.review-facts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px 16px;
  margin: 12px 0 0; font-size: 13px;
}
.review-facts dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.review-facts dd { margin: 1px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.review-facts .wide { grid-column: span 2; }
.review-facts .wide dd { font-weight: 400; }
.review-block { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.review-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.review-notes { white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.review-log { list-style: none; margin: 0; padding: 0; }
.review-log li { display: grid; grid-template-columns: 52px 72px 1fr; gap: 8px; align-items: baseline; padding: 3px 0; }
.review-added { margin-top: 10px; }

/* "New deal" menu */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " ▾"; font-size: 11px; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 180px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.menu-list button {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: none; border: 0; border-radius: 6px; padding: 8px 10px; cursor: pointer;
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--surface-2); outline: none; }

/* settings page */
.settings { max-width: 760px; margin: 0 auto; padding: 20px; }
.settings h1 { font-size: 22px; margin: 6px 0 18px; }
.back-link { color: var(--accent); text-decoration: none; font-size: 13px; }
.back-link:hover { text-decoration: underline; }
.settings-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px;
}
.settings-card > h2 { margin-bottom: 12px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.setting-name { font-weight: 600; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.segmented button {
  font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.account { padding: 14px 0; border-top: 1px solid var(--border); }
.account:first-of-type { border-top: 0; padding-top: 2px; }
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.account-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stage-none); }
.status.ok { color: var(--ok); }
.status.ok .status-dot { background: var(--ok); }
.status.neutral .status-dot { background: var(--warn); }
.account-lines { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.account-lines li { margin: 2px 0; }
.account-lines li:first-child { color: var(--text); }
.account-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.account-actions .btn { text-decoration: none; font-size: 13px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn); font-weight: 600;
}

.btn {
  font: inherit; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn.icon { padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; }
.btn.icon svg { width: 16px; height: 16px; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }
main.wide { max-width: none; }

.section-head { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 12px; flex-wrap: wrap; }
.section-head h1 { font-size: 20px; }
/* Analytics: a 10-column grid. Row 1: three counts, then the vertical and region pies side
   by side (each two rows tall); row 2: revenue and EBITDA, each with its stage bar. */
.kpis { display: grid; grid-template-columns: repeat(10, 1fr); gap: 12px; margin-bottom: 16px; grid-auto-flow: dense; }
.kpis > .kpi { grid-column: span 2; }
.kpis > .kpi-money { grid-column: span 3; }
.kpis > .kpi-pie { grid-column: span 2; grid-row: span 2; }
.delta-up { color: var(--ok); font-weight: 600; }
.delta-warn { color: var(--warn); font-weight: 600; }

/* verticals donut */
.pie { margin-top: 8px; }
.pie-chart { position: relative; width: 132px; margin: 0 auto; }
.pie-svg { display: block; width: 100%; height: auto; }
.pie-slice { transition: opacity .12s; cursor: default; }
.pie.focus .pie-slice:not(.on) { opacity: .3; }
.pie-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center; padding: 0 30px;
}
.pie-center b { font-size: 22px; font-weight: 650; line-height: 1.1; }
.pie-center span { font-size: 11px; color: var(--muted); line-height: 1.2; }
.pie-legend { flex-direction: column; gap: 4px; margin-top: 12px; }
.dist-legend.pie-legend li { display: flex; cursor: default; white-space: normal; }
.pie-legend li b { margin-left: auto; }
.pie-legend li.on { color: var(--text); }

/* revenue by stage: one stacked bar plus a legend */
.dist { margin-top: 12px; position: relative; }
.dist-bar { display: flex; gap: 2px; height: 10px; }
.dist-seg {
  flex: 1 1 0; min-width: 4px; position: relative; cursor: default;
  background: var(--c);
}
.dist-seg:first-child { border-radius: 4px 0 0 4px; }
.dist-seg:last-child { border-radius: 0 4px 4px 0; }
.dist-seg:only-child { border-radius: 4px; }
.dist-seg::before { content: ""; position: absolute; inset: -8px 0; } /* bigger hover target than the 10px bar */
.dist-bar:hover .dist-seg:not(:hover) { opacity: .45; }
.dist-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; }
.dist-legend li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); }
.dist-legend li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.dist-legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.dist-tip {
  position: absolute; bottom: calc(100% + 8px); transform: translateX(-50%); z-index: 3; pointer-events: none;
  background: var(--text); color: var(--bg); border-radius: 6px; padding: 6px 9px; font-size: 12px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.dist-tip b { display: block; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 26px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi.alert .kpi-value { color: var(--warn); }

.grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
select, input, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
textarea { resize: vertical; }

.stage-strip { display: flex; gap: 6px; padding: 12px 16px 4px; overflow-x: auto; }
.stage-pill {
  flex: 1 0 auto; min-width: 84px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font: inherit;
}
.stage-pill .n { display: block; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stage-pill .l { font-size: 11px; color: var(--muted); white-space: nowrap; }
.stage-pill.active { border-color: var(--accent); background: var(--accent-soft); }

.table-wrap { padding: 8px 8px 12px; overflow-x: auto; }
table.deals { width: 100%; border-collapse: collapse; }
.deals th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.deals td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.deals tbody tr { cursor: pointer; }
.deals tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.deal-name { font-weight: 600; }
.sub { color: var(--muted); font-size: 12px; }
.chip {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.chip.inactive.sold { background: var(--ok-soft); color: var(--ok); }
.chip.inactive.passed { background: var(--surface-2); color: var(--muted); }
.chip.inactive.nurture { background: var(--accent-soft); color: var(--accent); }
.inactive-page { max-width: 1300px; margin: 0 auto; padding: 20px; }
.inactive-panel { margin-top: 14px; }
.review-count.muted-count { background: var(--surface-2); color: var(--muted); }
.review-link.active .review-count.muted-count { background: var(--accent); color: var(--accent-text); }
.inactive-tab .n { opacity: .65; margin-left: 2px; font-variant-numeric: tabular-nums; }
.inactive-panel .panel-head { flex-wrap: wrap; }
.inactive-panel td:first-child { min-width: 180px; }
.due { color: var(--warn); font-weight: 600; }
.stale { color: var(--warn); }
.empty { color: var(--muted); padding: 16px 8px; margin: 0; }

.tabs { display: flex; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.tab { font: inherit; font-size: 12px; border: 0; background: transparent; color: var(--muted); padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.search { margin: 12px 16px 4px; width: calc(100% - 32px); }

.inbox { list-style: none; margin: 0; padding: 4px 0 8px; max-height: 70vh; overflow-y: auto; }
.inbox li { padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.inbox li:hover { background: var(--surface-2); }
.inbox li.unread .from, .inbox li.unread .subject { font-weight: 700; }
.inbox .row1 { display: flex; gap: 8px; align-items: baseline; }
.inbox .from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox .time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.inbox .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox .preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox li.open .preview { white-space: normal; }
.inbox .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.inbox .actions select { font-size: 12px; padding: 3px 6px; }
.inbox .tag { margin-top: 4px; }
.inbox.compact { max-height: 240px; border: 1px solid var(--border); border-radius: 8px; }
.inbox a { color: var(--accent); }

.welcome { max-width: 520px; margin: 12vh auto; text-align: center; padding: 0 16px; }
.welcome h1 { font-size: 26px; margin-bottom: 10px; }
.welcome p { margin-bottom: 20px; }

dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 0;
  background: var(--surface); color: var(--text); width: min(720px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog form { padding: 20px; }
dialog h2 { margin-bottom: 14px; font-size: 17px; }
/* deal pop-up header: title, Open in Salesforce and Close, pinned while the form scrolls */
.dialog-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  margin: -20px -20px 16px; padding: 14px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.dialog-head h2 { margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-open {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; font-size: 13px; font-weight: 600;
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft);
}
.sf-open:hover { background: var(--accent); color: var(--accent-text); }
.sf-open svg { width: 15px; height: 15px; flex: none; }
.btn.small.sf-open { padding: 4px 10px; font-size: 12px; }
.review-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none;
}
.review-toggle:hover { color: var(--text); background: var(--surface-2); }
.review-toggle input { margin: 0; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.review-toggle:has(input:checked) { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea { color: var(--text); font-size: 14px; }
.hint { font-size: 11px; }
.extras { line-height: 1.6; }
.extras .extra { white-space: nowrap; color: var(--text); }
.extras .icon-btn { font-size: 13px; padding: 0 2px; }
.dialog-actions { display: flex; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: calc(100vw - 32px); z-index: 20;
}

.small { font-size: 12px; }
.notice {
  background: var(--warn-soft); color: var(--text); border-left: 3px solid var(--warn);
  border-radius: 8px; padding: 10px 14px; text-align: left; font-size: 13px;
}
.welcome a { color: var(--accent); }
.search-inline { width: 180px; font-size: 13px; padding: 5px 10px; }
.clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* sortable table headers */
.deals th[data-sort] { cursor: pointer; user-select: none; }
.deals th[data-sort]:hover { color: var(--text); }
.deals th.sort-asc::after { content: " ▲"; font-size: 9px; }
.deals th.sort-desc::after { content: " ▼"; font-size: 9px; }

/* stage color: elements set --c to their stage's --stage-N */
.stage-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 2px 9px 2px 7px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text);
}
.stage-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.stage-pill { border-top: 3px solid var(--c); }
.stage-pill.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); }

/* board view: a kanban pipeline, one column per stage */
.grid.board-mode { grid-template-columns: 1fr; }
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(184px, 1fr);
  gap: 6px; padding: 14px 16px 16px; overflow-x: auto; align-items: stretch;
}
.col {
  display: flex; flex-direction: column; min-height: 460px;
  background: color-mix(in srgb, var(--c) 5%, var(--surface-2));
  border: 1px solid transparent; border-radius: 0 0 var(--radius) var(--radius);
}
.col.drop { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface-2)); }

/* chevron header, so the row of columns reads as a pipeline flowing left to right */
.col-head {
  padding: 9px 22px 10px 20px;
  background: color-mix(in srgb, var(--c) 20%, var(--surface));
  box-shadow: inset 0 3px 0 var(--c);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%);
}
.col:first-child .col-head { padding-left: 12px; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); }
.col:last-child .col-head { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%); }
.col-title { display: flex; align-items: center; gap: 8px; }
.col-name { font-weight: 650; font-size: 13px; }
.col-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--surface); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.col-total { margin-top: 2px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-share { height: 4px; margin-top: 6px; border-radius: 2px; background: color-mix(in srgb, var(--c) 18%, transparent); overflow: hidden; }
.col-share > span { display: block; height: 100%; border-radius: 2px; background: var(--c); }
.col-body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 10px 8px; overflow-y: auto; max-height: 68vh; }
.col-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 18px 4px; opacity: .7; }
/* "+ Add deal" appears when you point at (or tab into) a column, to keep the board quiet. */
.col-add {
  margin: 0 8px 8px; padding: 6px; border-radius: 8px; border: 1px dashed var(--border);
  background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
.col:hover .col-add, .col:focus-within .col-add { opacity: 1; }
.col-add:hover { color: var(--text); border-color: var(--c); background: var(--surface); }
@media (hover: none) { .col-add { opacity: 1; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c);
  border-radius: 8px; padding: 10px 10px 9px 11px; cursor: grab; box-shadow: var(--shadow); font-size: 13px;
}
.card:hover { box-shadow: 0 2px 8px rgba(16, 24, 40, .12); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.card.dragging { opacity: .5; }
.card-figures { display: flex; gap: 10px; margin-top: 4px; font-size: 12px; font-variant-numeric: tabular-nums; }
.card-figures b { font-weight: 600; }
.card-figures span { color: var(--muted); }
.card-next { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.card-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; margin-top: 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.quiet { color: var(--warn); font-weight: 600; }

/* activity log */
.log-add { display: grid; grid-template-columns: 140px 110px minmax(0, 1fr) auto; gap: 6px; }
.log-add > * { min-width: 0; }
.log-add input, .log-add select { font-size: 13px; padding: 5px 8px; }
.log { list-style: none; margin: 8px 0 0; padding: 0; max-height: 200px; overflow-y: auto; }
.log li { display: grid; grid-template-columns: 56px 72px 1fr auto; gap: 8px; align-items: baseline; padding: 6px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.log li.empty { display: block; color: var(--muted); border: 0; }
.log-date { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.log-type { text-align: center; }
.log-type.stage { background: var(--surface-2); color: var(--muted); }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.icon-btn:hover { color: var(--danger); }
dialog { max-height: calc(100vh - 32px); overflow-y: auto; }

/* Salesforce */
.badge.read { background: var(--ok-soft); color: var(--ok); }
.sf-badge {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px; vertical-align: 1px;
  font-size: 10px; font-weight: 700; letter-spacing: .3px; line-height: 16px;
  background: var(--accent-soft); color: var(--accent);
}
.sf-wrap { padding: 20px; }
.sf-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sf-head h2 { margin: 0; }
.sf-points { margin: 0 0 16px; padding-left: 18px; color: var(--muted); }
.sf-points li { margin-bottom: 4px; }
.sf-status { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; }
.sf-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sf-who { color: var(--muted); }
.sf-search { width: 100%; }
.sf-hint { margin: 10px 0 6px; }
.sf-results { list-style: none; margin: 0; padding: 0; max-height: 52vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.sf-results li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.sf-results li:last-child { border-bottom: 0; }
.sf-results li.empty { display: block; color: var(--muted); }
.sf-main { flex: 1; min-width: 0; }
.sf-box { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.sf-box-head { display: flex; align-items: center; gap: 8px; }
.sf-box-head h3 { margin: 0; color: var(--text); }
.sf-box a { color: var(--accent); }
.sf-fields { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 10px 0; font-size: 13px; }
.sf-fields dt { color: var(--muted); }
.sf-fields dd { margin: 0; }
.sf-box-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sf-box h4 { margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.sf-fields dd.long { white-space: pre-wrap; }
.sf-contacts { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.sf-contacts li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.sf-contacts li:last-child { border-bottom: 0; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* Brokers page */
.brokers-page { max-width: 1300px; margin: 0 auto; padding: 20px; }
.review-count.warn { background: var(--warn); color: var(--surface); }
.inline-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.inline-link:hover { text-decoration: underline; }
#broker-new { margin-top: 6px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 4px 0 14px; }
.inline-form input { min-width: 0; }
.inline-form .grow, .call-row .grow { flex: 1; }
.inline-form.wrap { flex-wrap: wrap; margin: 12px 0 0; }
.inline-form.wrap input { flex: 1 1 160px; }
#new-broker-form input { width: 320px; }
#broker-search { width: 260px; }
.broker-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.kpi-value.warn { color: var(--warn); }
.brokers-table td:first-child { min-width: 200px; }
.row-link { color: inherit; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.tier {
  display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px; border-radius: 5px; vertical-align: 1px;
  font-size: 11px; font-weight: 700;
}
.tier-a { background: var(--accent); color: var(--accent-text); }
.tier-b { background: var(--accent-soft); color: var(--accent); }
.tier-c { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.broker-status.active { background: var(--ok-soft); color: var(--ok); }
.broker-status.dormant { background: var(--surface-2); color: var(--muted); }

.broker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 14px; }
.broker-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.broker-title h1 { font-size: 22px; }
.broker-title .tier { margin: 0; width: 24px; height: 24px; font-size: 13px; }
.broker-links { display: flex; gap: 8px; flex-wrap: wrap; }
.broker-links a.btn { text-decoration: none; }
.broker-score { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 16px; }
.score-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); }
.score-value { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; }
.score-label { color: var(--muted); font-size: 12px; }
.broker-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.broker-col { min-width: 0; }
.broker-col .settings-card > h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-intro { margin: -6px 0 10px; }
.saved { color: var(--ok); }

.call-form, .stack-form { display: flex; flex-direction: column; gap: 10px; }
.call-form label, .stack-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.call-form input, .call-form select, .call-form textarea, .stack-form input, .stack-form select, .stack-form textarea { font-size: 14px; }
.call-row { display: flex; gap: 10px; flex-wrap: wrap; }
.call-row > label { flex: 1 1 140px; min-width: 0; }
.call-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.call-form legend { font-size: 12px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.picks { display: flex; flex-wrap: wrap; gap: 6px; }
.call-form label.pick {
  flex-direction: row; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); font-size: 13px; cursor: pointer; user-select: none;
}
.call-form label.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pick input { margin: 0; accent-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.stack-form select:disabled { opacity: .5; }
.next-call { margin-top: -4px; }
.next-call.due { color: var(--warn); font-weight: 600; }

.call-list, .row-list { list-style: none; margin: 0; padding: 0; }
.call-list > li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.call-list > li:last-child, .row-list > li:last-child { border-bottom: 0; }
.call-list > li.empty, .row-list > li.empty { padding: 8px 0; }
.call-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.call-who { font-weight: 600; }
.call-notes { margin-top: 4px; white-space: pre-wrap; }
.call-deals { margin-top: 6px; color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.chip-btn { border: 0; cursor: pointer; font: inherit; font-size: 12px; }
.chip-btn:hover { text-decoration: underline; }
.follow-up { display: flex; align-items: center; gap: 6px; margin-top: 6px; cursor: pointer; }
.follow-up input { margin: 0; accent-color: var(--accent); }
.follow-up.due > span:first-of-type { color: var(--warn); font-weight: 600; }
.follow-up.done > span { text-decoration: line-through; color: var(--muted); }

.row-list > li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
#broker-deals > li { cursor: pointer; }
#broker-deals > li:hover { background: var(--surface-2); }
#broker-deals > li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row-main { flex: 1; min-width: 0; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions select { font-size: 12px; padding: 3px 6px; }
.mandate.passed .row-main, .mandate.received .row-main { opacity: .6; }
.banker-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.banker-form input { min-width: 0; font-size: 13px; }
.banker-form .form-actions { grid-column: 1 / -1; }

@media (max-width: 1000px) {
  .grid, .broker-grid { grid-template-columns: 1fr; }
  /* three counts across, then revenue and EBITDA side by side, then the two pies side by side */
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .kpis > .kpi-pie { grid-column: span 3; grid-row: auto; order: 1; }
  .pie { display: flex; align-items: center; gap: 24px; }
  .pie-chart { margin: 0; flex: none; }
  .pie-legend { margin-top: 0; flex: 1; max-width: 360px; }
}
@media (max-width: 560px) {
  main { padding: 12px 16px; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .log-add { grid-template-columns: 1fr 1fr; }
  .log-add input#log-text { grid-column: 1 / -1; }
  .search-inline { width: 100%; order: 10; }
  .board { grid-auto-columns: minmax(240px, 82vw); }
  .col { min-height: 320px; }
  .kpi-value { font-size: 22px; }
  .kpis { grid-template-columns: 1fr; }
  .kpis > .kpi, .kpis > .kpi-money, .kpis > .kpi-pie { grid-column: auto; }
  .pie { flex-direction: column; align-items: stretch; }
  .pie-chart { margin: 0 auto; }
  /* keep the pop-up header on one line: Salesforce and the top-bar review link go icon-only */
  .sf-open-text, .review-link-text { display: none; }
  .dialog-head .sf-open { padding: 7px 9px; }
  .review-link { padding: 0 7px; gap: 3px; }
  .topbar { gap: 4px; }
  .topbar .badge { display: none; }
  .topbar .review-count { min-width: 18px; height: 18px; padding: 0 5px; }
  .review-page { padding: 12px 16px; }
  .review-card { gap: 10px; padding: 12px; }
  .review-facts .wide { grid-column: 1 / -1; }
  .brokers-page, .inactive-page { padding: 12px 16px; }
  #inactive-search { width: 100%; }
  #new-broker-form input { width: auto; flex: 1; }
  .banker-form { grid-template-columns: 1fr; }
}
