/* Phasewick CRM. Plain CSS, no external assets. */
:root {
  color-scheme: light;
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8f9fb; --surface-3: #eef1f5;
  --text: #18202f; --muted: #5d6679; --faint: #8a93a5; --line: #e2e6ed; --line-2: #edf0f4;
  --brand: #2b2250; --brand-ink: #ffffff; --accent: #c8660f; --accent-soft: #fff1e3;
  --primary: #2453b3; --primary-hover: #1c4596; --primary-soft: #e8eefb;
  --green: #1d7a51; --green-soft: #e1f3ea; --red: #b93434; --red-soft: #fbe9e9;
  --amber: #996300; --amber-soft: #fdf3dc; --purple: #5d45b8; --purple-soft: #eeeafb; --gray-soft: #eceff3;
  --c1: #2453b3; --c2: #3f8fd2; --c3: #6a7fd9; --c4: #c8660f; --c5: #1d7a51; --c6: #8a93a5; --c7: #b93434; --c8: #5d45b8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 8px rgba(16, 24, 40, .04);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, .22);
  --radius: 12px; --radius-sm: 8px;
  --side: 224px;
  --focus: 0 0 0 3px rgba(36, 83, 179, .35);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141c; --surface: #171d27; --surface-2: #1c2330; --surface-3: #232b3a;
  --text: #e7ebf2; --muted: #a2abbd; --faint: #7d879a; --line: #2a3242; --line-2: #222a38;
  --brand: #5a4da3; --accent: #ff9a50; --accent-soft: #3a2a18;
  --primary: #7aa2f2; --primary-hover: #9ab9f6; --primary-soft: #1f2c47;
  --green: #5fcf98; --green-soft: #173528; --red: #f08a8a; --red-soft: #3d1d20;
  --amber: #f0c060; --amber-soft: #3a2f15; --purple: #b0a0f5; --purple-soft: #2a2546; --gray-soft: #262e3c;
  --c1: #7aa2f2; --c2: #58b4f0; --c3: #a3b0f5; --c4: #f0a050; --c5: #5fcf98; --c6: #8d97aa; --c7: #f08a8a; --c8: #b0a0f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  --focus: 0 0 0 3px rgba(122, 162, 242, .45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 12px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -50px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { top: 8px; box-shadow: var(--shadow-lg), var(--focus); }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 6px; }
.logo { display: block; flex: none; width: 34px; height: 34px; border-radius: 8px; }
[data-theme="dark"] .logo, [data-theme="dark"] .auth-mark { box-shadow: 0 0 0 1px rgba(255, 255, 255, .1); }
.brand-name { font-weight: 700; line-height: 1.2; }
.brand-cap { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav .count { margin-left: auto; font-size: 11.5px; font-weight: 600; background: var(--red-soft); color: var(--red); padding: 1px 7px; border-radius: 99px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .brand { display: none; padding: 0; }
.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.gsearch input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.gsearch input:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.gresults { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; max-height: 60vh; overflow: auto; z-index: 30; }
.gresults button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.gresults button:hover, .gresults button.active { background: var(--surface-3); }
.gresults .kind { font-size: 11px; color: var(--muted); margin-left: auto; text-transform: uppercase; letter-spacing: .05em; }
.gresults .none { padding: 10px; color: var(--muted); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sample-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--amber); background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.sample-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.viewer select { height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 0 8px; }
#view { padding: 22px 24px 40px; outline: none; flex: 1; }
.footer { padding: 14px 24px 24px; font-size: 12px; color: var(--faint); }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--primary); background: var(--primary); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
[data-theme="dark"] .btn { color: #0f141c; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
[data-theme="dark"] .btn.danger { color: #1a0d0d; }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--red); }
.btn.danger-ghost:hover { background: var(--red-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn.bare { border-color: transparent; background: transparent; }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); cursor: pointer; font-weight: 600; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.title-btn { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; font-weight: 600; color: var(--text); }
.title-btn:hover { color: var(--primary); text-decoration: underline; }

/* ---------- cards & tiles ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head .sub { font-size: 12.5px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
a.tile:hover { border-color: var(--primary); }
.tile .label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tile .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; line-height: 1.15; }
.tile .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.warn .value { color: var(--red); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--gray-soft); color: var(--muted); white-space: nowrap; line-height: 1.5; }
.b-blue { background: var(--primary-soft); color: var(--primary); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-purple { background: var(--purple-soft); color: var(--purple); }
.b-accent { background: var(--accent-soft); color: var(--accent); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--primary-soft); color: var(--primary); flex: none; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 7px; background: var(--surface-3); color: var(--text); }

/* ---------- lists ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-2); min-width: 0; }
.rows > li:first-child { border-top: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .line1 { font-weight: 600; overflow-wrap: anywhere; }
.rows .line2 { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.when { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.when.late { color: var(--red); font-weight: 600; }
.when.today { color: var(--amber); font-weight: 600; }
.group-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 4px; display: flex; gap: 6px; align-items: center; }
.group-label.late { color: var(--red); }
.check-btn { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--faint); background: transparent; display: grid; place-items: center; cursor: pointer; flex: none; color: transparent; padding: 0; }
.check-btn .i { width: 14px; height: 14px; stroke-width: 2.6; }
.check-btn:hover { border-color: var(--green); color: var(--green); }
.check-btn[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
li.done .line1 { text-decoration: line-through; color: var(--muted); font-weight: 500; }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .empty-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-3); display: inline-grid; place-items: center; margin-bottom: 8px; color: var(--faint); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.empty.sm { padding: 14px 8px; font-size: 13px; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .search-in { position: relative; flex: 1 1 220px; max-width: 320px; }
.toolbar .search-in .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.toolbar input[type="search"], .toolbar select { height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 10px; min-width: 0; }
.toolbar input[type="search"] { width: 100%; padding-left: 32px; }
.toolbar select { max-width: 190px; }
.toolbar .result-count { font-size: 12.5px; color: var(--muted); margin-left: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 0 12px; height: 34px; cursor: pointer; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .line2 { font-size: 12px; color: var(--muted); }
th.num, td.num { text-align: right; }

/* ---------- pipeline board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 240px; scroll-snap-align: start; transition: background .15s, border-color .15s; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px 8px; font-weight: 700; font-size: 13px; }
.col-head .n { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-3); border-radius: 99px; padding: 0 8px; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stage, var(--c6)); }
.col-body { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 10px; flex: 1; }
.col.drop-ok { background: var(--primary-soft); border-color: var(--primary); border-style: dashed; }
.col-empty { font-size: 12.5px; color: var(--faint); text-align: center; padding: 18px 6px; border: 1px dashed var(--line); border-radius: 10px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--stage, var(--c6)); border-radius: 10px; padding: 10px 10px 8px; box-shadow: var(--shadow); cursor: grab; display: flex; flex-direction: column; gap: 6px; }
.pcard:active { cursor: grabbing; }
.pcard.dragging { opacity: .45; }
.pcard .t { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.pcard .agency { font-size: 12px; color: var(--muted); }
.pcard .foot { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.pcard .foot .left { display: flex; gap: 6px; align-items: center; min-width: 0; flex-wrap: wrap; }
.board-hint { font-size: 12.5px; color: var(--muted); margin: -6px 0 12px; }

/* ---------- partner cards ---------- */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.partner { display: flex; flex-direction: column; gap: 10px; }
.partner .ph { display: flex; align-items: flex-start; gap: 10px; }
.partner .ph .grow { flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.partner .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--line-2); }

/* ---------- charts (CSS only) ---------- */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr 34px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar-track { height: 12px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: var(--w); background: var(--bar, var(--c1)); border-radius: 99px; min-width: 2px; }
.bar-row .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.stack span { width: var(--w); background: var(--bar); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--bar); margin-right: 6px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { width: 128px; height: 128px; border-radius: 50%; background: var(--g); display: grid; place-items: center; flex: none; }
.donut::before { content: ""; grid-area: 1 / 1; width: 84px; height: 84px; border-radius: 50%; background: var(--surface); }
.donut b { grid-area: 1 / 1; z-index: 1; font-size: 22px; text-align: center; line-height: 1.1; }
.donut b small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.cols-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.cols-chart .c { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 12px; }
.cols-chart .c i { display: block; width: 100%; max-width: 44px; height: var(--h); min-height: 2px; background: var(--bar, var(--c1)); border-radius: 6px 6px 0 0; }
.cols-chart .c b { font-variant-numeric: tabular-nums; }
.cols-labels { display: flex; gap: 10px; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.cols-labels span { flex: 1; text-align: center; }

/* ---------- detail ---------- */
.detail-top { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 0 0 6px; }
.detail-grid div { min-width: 0; }
.detail-grid dt { font-size: 12px; color: var(--muted); }
.detail-grid dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.notes { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 12px 18px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 15px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .meta { font-size: 12px; color: var(--muted); }
.inline-form { display: grid; grid-template-columns: 120px 1fr auto; gap: 8px; margin-top: 8px; }
.inline-form select, .inline-form input { height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 10px; min-width: 0; }

/* ---------- modal ---------- */
dialog.modal { border: 0; padding: 0; background: transparent; color: var(--text); width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 32px); margin: auto; }
dialog.modal-sm { width: min(440px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(10, 16, 28, .5); }
.modal-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: calc(100vh - 32px); border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; overflow-wrap: anywhere; }
.modal-body { padding: 16px 20px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .spacer { margin-right: auto; }
.req-note { margin-right: auto; font-size: 12px; color: var(--muted); }
.confirm-msg { line-height: 1.55; }
@media (prefers-reduced-motion: no-preference) {
  dialog.modal[open] .modal-card { animation: pop .16s ease-out; }
  @keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
}

.stage-pick { display: flex; flex-direction: column; gap: 6px; }
.stage-opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; font-weight: 600; }
.stage-opt:hover { background: var(--surface-3); }
.stage-opt[aria-current="true"] { border-color: var(--stage); background: var(--surface-2); }
.stage-opt .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--stage); flex: none; }
#view:focus { box-shadow: none; }
.chip.link-btn { font-weight: 500; color: var(--text); }
.chip.link-btn:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.badge .i, .btn .i { width: 16px; height: 16px; }

/* ---------- match score ---------- */
.badge.score { font-variant-numeric: tabular-nums; }
.score-note { margin: -4px 0 10px; }
.why { border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface-2); padding: 12px; }
.why-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.why-head .grow { flex: 1 1 200px; min-width: 0; }
.why-total { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; align-content: center; flex: none; line-height: 1.05; }
.why-total b { font-size: 22px; font-variant-numeric: tabular-nums; }
.why-total small { font-size: 10.5px; font-weight: 600; opacity: .85; }
.why-list { list-style: none; margin: 0; padding: 0; }
.why-list li { padding: 8px 0; border-top: 1px solid var(--line-2); }
.why-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 52px; gap: 10px; align-items: center; font-size: 13px; }
.why-lbl { font-weight: 600; }
.why-pts { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.why-reason { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- partner record ---------- */
.status-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.status-box { --tone: var(--c6); border: 1px solid var(--line); border-left: 4px solid var(--tone); border-radius: 10px; padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.status-box.ok { --tone: var(--green); }
.status-box.warn { --tone: var(--amber); }
.status-box.bad { --tone: var(--red); }
.status-lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.status-val { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.status-val .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tone); }
.status-hint { font-size: 12.5px; color: var(--muted); }
.status-box .btn { margin-top: 6px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.mini-stats div { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; }
.mini-stats dt { font-size: 12px; color: var(--muted); }
.mini-stats dd { margin: 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.h-count { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--faint); margin-left: 4px; }
.opp-badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.opp-rows li.closed .line1 { color: var(--muted); }
.opp-rows .line2 .when { font-size: inherit; }

/* ---------- dashboard ---------- */
.span-all { grid-column: 1 / -1; }

/* ---------- sample import ---------- */
.callout { display: flex; gap: 10px; align-items: flex-start; background: var(--amber-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.callout .i { color: var(--amber); margin-top: 1px; }
.import-tools { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 6px; }
.import-tools [data-sel-count] { margin-left: auto; }
.import-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.imp { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface); }
.imp:hover { background: var(--surface-2); }
.imp:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.imp:has(input:focus-visible) { box-shadow: var(--focus); }
.imp input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.imp .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.imp .line1 { font-weight: 600; overflow-wrap: anywhere; }
.imp .line2 { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.imp .faint { color: var(--faint); }
.imp-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.import-list li.dup .imp { cursor: default; background: var(--surface-2); }
.import-list li.dup .line1 { color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--primary); border-color: var(--primary); }

/* ---------- respond-by queue ---------- */
.rb-note { margin: -4px 0 12px; }
.rb-list, .rb-next { list-style: none; margin: 0; padding: 0; }
.rb-list { display: flex; flex-direction: column; gap: 8px; }
.rb-next { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rb-item, .rb-mini { --tone: var(--c6); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--tone); border-radius: 10px; padding: 12px 14px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rb-item { box-shadow: var(--shadow); }
.rb-mini { background: var(--surface-2); }
.tone-late { --tone: var(--red); }
.tone-soon { --tone: var(--amber); }
.tone-near { --tone: var(--primary); }
.tone-closed { --tone: var(--line); }
.rb-item.tone-closed { background: var(--surface-2); box-shadow: none; }
.rb-item.tone-closed .line1 { color: var(--muted); }
.rb-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rb-head .rb-due { margin-left: auto; }
.rb-item .line1, .rb-mini .line1 { font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.rb-item .line2, .rb-mini .line2 { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.rb-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rb-actions .push { flex: 1; }
.rb-st .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st); flex: none; }
.rb-draft summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--primary); width: fit-content; padding: 2px 0; }
.rb-draft-body { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.draft-note { font-size: 12.5px; font-weight: 600; color: var(--amber); }
.rb-draft-text { font-size: 13px; max-height: 200px; overflow: auto; }
.rb-meta { margin: 10px 0 8px; overflow-wrap: anywhere; }
.rb-textarea { line-height: 1.5; }

/* ---------- forms ---------- */
.form-intro { color: var(--muted); margin-bottom: 12px; }
.form-summary { background: var(--red-soft); color: var(--red); border-radius: 9px; padding: 9px 12px; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.form-sec { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.form-sec legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0; margin-bottom: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.lbl { font-size: 13px; font-weight: 600; }
.req { color: var(--red); }
.field input:not([type="checkbox"]), .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 8px 10px; min-height: 38px; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.field.invalid input, .field.invalid select, .field.invalid textarea, .field.invalid .checks { border-color: var(--red); }
.help { font-size: 12px; color: var(--muted); }
.err { font-size: 12.5px; color: var(--red); font-weight: 600; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; padding: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.check:hover { background: var(--surface-3); }
.check input { margin-top: 2px; accent-color: var(--primary); }
.check small { color: var(--muted); display: block; }
.checks-filter { margin-bottom: 6px; }

/* ---------- toast ---------- */
#toasts { position: fixed; left: 12px; right: 12px; bottom: 20px; z-index: 1000; display: flex; justify-content: center; pointer-events: none; }
#toasts .toast { pointer-events: auto; max-width: 560px; }
.toast { display: flex; align-items: center; gap: 10px; background: #1b2333; color: #fff; padding: 10px 10px 10px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px); transition: opacity .18s, transform .18s; }
[data-theme="dark"] .toast { background: #e7ebf2; color: #18202f; }
.toast.show { opacity: 1; transform: none; }
.toast-btn { border: 0; background: rgba(255, 255, 255, .14); color: inherit; font-weight: 700; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
[data-theme="dark"] .toast-btn { background: rgba(0, 0, 0, .08); }
.toast-x { border: 0; background: none; color: inherit; opacity: .7; cursor: pointer; display: grid; place-items: center; padding: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; }
  .sidebar { position: sticky; top: 0; z-index: 25; height: auto; flex-direction: row; align-items: center; padding: 0 8px; border-right: 0; border-bottom: 1px solid var(--line); order: 0; }
  .sidebar .brand, .side-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 2px; padding: 6px 0; width: 100%; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: none; padding: 8px 10px; font-size: 13.5px; }
  .topbar { position: static; padding: 10px 16px; flex-wrap: wrap; }
  .topbar .brand { display: flex; }
  .gsearch { order: 3; flex: 1 1 100%; max-width: none; }
  #view { padding: 18px 16px 32px; }
  .footer { padding: 12px 16px 24px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .board { grid-auto-columns: minmax(260px, 78vw); }
  .rb-next { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px; }
  .tile .value { font-size: 24px; }
  .viewer span { display: none; }
  .viewer select { max-width: 120px; }
  .brand-cap { display: none; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .toolbar select { flex: 1 1 calc(50% - 4px); max-width: none; }
  .toolbar .search-in { max-width: none; flex-basis: 100%; }
  .toolbar .result-count { margin-left: 0; width: 100%; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .inline-form { grid-template-columns: 1fr; }
  dialog.modal, dialog.modal-sm { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: auto 0 0; }
  .modal-card { border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .modal-foot .btn { flex: 1; }
  .req-note { width: 100%; }
  .bar-row { grid-template-columns: 96px 1fr 28px; }
  .hide-sm { display: none !important; }
  .rows > li { flex-wrap: wrap; }
  .rows .when { order: 3; }
  .status-panel { grid-template-columns: 1fr; }
  .why-row { grid-template-columns: minmax(0, 1fr) 72px 44px; }
  .opp-rows .opp-badges { justify-content: flex-start; }
  .imp-side { flex-direction: row; flex-wrap: wrap; }
  .imp { flex-wrap: wrap; }
  .imp .grow { flex-basis: calc(100% - 40px); }
  .imp-side { margin-left: 28px; }
}
@media (pointer: coarse) {
  .btn, .icon-btn, .toolbar select, .toolbar input[type="search"] { min-height: 42px; }
  .icon-btn { width: 42px; height: 42px; }
  .check-btn { width: 30px; height: 30px; }
}
@media print {
  .sidebar, .topbar, .page-head .actions, .footer, #toasts { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Absolutely positioned .sr-only text must stay inside its scroll container. */
.board, .col, .pcard, .table-wrap, .nav, .modal-body, .rows > li, .rb-item, .rb-mini { position: relative; }

/* ---------- server app additions (auth pages, import, activity, users) ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(900px 460px at 50% -8%, color-mix(in srgb, var(--brand) 7%, transparent), transparent 72%); }
.auth-card { width: 100%; max-width: 400px; padding: 32px 32px 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 32px rgba(16, 24, 40, .08); }
[data-theme="dark"] .auth-card { box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
.auth-card h1 { font-size: 18px; text-align: center; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding-bottom: 18px; border-bottom: 1px solid var(--line-2); }
.auth-mark { display: block; width: 56px; height: 56px; border-radius: 13px; margin-bottom: 12px; }
.auth-brand .brand-name { font-size: 20px; font-weight: 700; letter-spacing: .01em; overflow-wrap: anywhere; }
.auth-tagline { font-size: 13px; color: var(--muted); }
.auth-about { font-size: 13px; line-height: 1.5; color: var(--muted); margin: 10px 0 0; max-width: 34ch; text-align: center; }
.auth-note { text-align: center; }
.auth-card .form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .field input { width: 100%; }
.auth-submit { width: 100%; height: 40px; justify-content: center; margin-top: 4px; }
.auth-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.who-name { font-weight: 600; }
.callout.ok { border-color: var(--green); background: var(--green-soft); }
.callout .grow { flex: 1; min-width: 0; }
.steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 14px; flex-wrap: wrap; counter-reset: step; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 13px; font-weight: 500; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); font-size: 12px; }
.steps li[aria-current="step"] { background: var(--primary-soft); color: var(--primary); }
.steps li.done { color: var(--green); }
.imp-card { margin-bottom: 14px; }
.imp-card .form-grid select, .imp-card .form-grid input[type="file"] { width: 100%; }
.imp-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 4px 0 14px; }
.imp-group { margin-top: 10px; }
.imp-group summary { cursor: pointer; padding: 8px 0; }
.imp-group .table-wrap { max-height: 420px; overflow: auto; }
.act-table td { vertical-align: top; }
.changes summary { cursor: pointer; color: var(--primary); font-size: 12.5px; margin-top: 4px; }
.changes ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); word-break: break-word; }
.err-text { color: var(--red); }
code { font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
#imp-batches { margin-top: 4px; }
@media (max-width: 560px) {
  .imp-tiles { grid-template-columns: 1fr; }
  .who-name { display: none; }
  .auth-card { padding: 24px 18px 20px; }
}
#view > .callout { margin-bottom: 14px; }
.callout.ok .i { color: var(--green); }

/* What's new note */
.whats-new { margin: 16px 24px 0; padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--blue, var(--amber)); border-radius: 10px; font-size: 13px; }
.whats-new[hidden] { display: none; }
.whats-new .grow { flex: 1; min-width: 0; }
.whats-new h2 { font-size: 14px; margin: 0 0 6px; }
.whats-new ul { margin: 0; padding-left: 18px; }
.whats-new li { margin: 2px 0; }
.whats-new time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
@media (max-width: 900px) { .whats-new { margin: 12px 16px 0; } }
.demo-footer { margin-top: 2px; text-align: center; font-weight: 600; letter-spacing: .02em; }

/* ---------- whole-card click targets ----------
   The card's title button (.card-open) stretches an invisible overlay over its card, so a click anywhere
   on the card opens the record, and Tab / Enter / Space on the title button still work natively.
   Buttons, links, form controls and <details> inside the card sit above the overlay and keep their own clicks. */
.clickable-card { position: relative; cursor: pointer; transition: border-color .15s, box-shadow .15s, background-color .15s; }
.card-open::after { content: ""; position: absolute; inset: 0; border-radius: 10px; z-index: 0; }
.partner.clickable-card .card-open::after { border-radius: var(--radius); }
.clickable-card :is(button, a, summary, input, select, textarea, label, details, [role="button"], [role="menu"], [data-stop-card]):not(.card-open) { position: relative; z-index: 1; }
.clickable-card:hover .card-open { color: var(--primary); text-decoration: underline; }
.card-open:focus-visible { box-shadow: none; }
.card-open:focus-visible::after { box-shadow: var(--focus); }
.pcard.clickable-card:hover, .partner.clickable-card:hover, .rb-item.clickable-card:hover, .rb-mini.clickable-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); box-shadow: 0 2px 6px rgba(16, 24, 40, .08), 0 6px 18px rgba(16, 24, 40, .07); }
.pcard.clickable-card:active { cursor: grabbing; }
.rows > li.clickable-card:hover { background: var(--surface-2); }
.rows > li.clickable-card { margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.rb-mini.clickable-card:hover { background: var(--surface-3); }
@media (prefers-reduced-motion: reduce) { .clickable-card { transition: none; } }
@media print { .card-open::after { display: none; } }
/* Table rows that open a record: the name is the real button (Tab, Enter, Space); client.js opens the record
   from a click anywhere else on the row unless it lands on a link, button or form control. */
tr.row-link { cursor: pointer; }
tbody tr.row-link:hover { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); }
tr.row-link:hover .title-btn { color: var(--primary); text-decoration: underline; }
tr.row-link:focus-within { outline: 2px solid color-mix(in srgb, var(--primary) 60%, transparent); outline-offset: -2px; }

/* ---------- settings ---------- */
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.subnav button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 99px; padding: 6px 13px; font-weight: 600; font-size: 13px; cursor: pointer; }
.subnav button:hover { color: var(--primary); background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.set-sec { margin-bottom: 16px; scroll-margin-top: 80px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.role-select { height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 8px; }
.role-select:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.perm-intro { margin-bottom: 10px; }
.perm-table th.c, .perm-table td.c { text-align: center; }
.perm-table th[scope="row"] { background: none; color: var(--text); font-size: 13.5px; font-weight: 600; white-space: normal; }
.perm { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; vertical-align: middle; }
.perm.yes { background: var(--green-soft); color: var(--green); }
.perm.yes .i { width: 14px; height: 14px; stroke-width: 2.6; }
.perm.no { color: var(--faint); font-weight: 700; }
.perm-note { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.profile-actions { margin-top: 14px; }
.temp-pw { display: flex; gap: 8px; }
.temp-pw input { flex: 1; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); padding: 0 12px; font-size: 15px; letter-spacing: .02em; }
.temp-pw input:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
