@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,600&display=swap");

/* Layout: navy masthead, then stacked sections. Each section is a panel with its own
   color band and border so one section reads clearly apart from the next. */
:root {
  /* Base */
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #17202c;
  --ink-2: #445063;
  --ink-3: #6b7689;
  --line: #dde2e9;
  --line-2: #e9edf2;
  --navy: #13294b;
  --gold: #b48a3c;
  --focus: #2f6fd1;
  --row-hover: #f2f6fb;
  --zebra: #fafbfc;

  /* Semantic */
  --won: #2f7a52; --won-soft: #e4f2ea;
  --lost: #a5432f; --lost-soft: #f8e6e1;
  --stage-soft: #f4ecdc; --stage-ink: #6d5216;

  /* Section tones: ink (band text + top rule), line (border), soft (band fill) */
  --summary-ink: #1f3a66; --summary-line: #b9c7de; --summary-soft: #e9eff8;
  --types-ink: #54468a;   --types-line: #cdc5e5;   --types-soft: #f0edf8;
  --stages-ink: #1b6763;  --stages-line: #b3d5d2;  --stages-soft: #e6f2f1;
  --deals-ink: #855814;   --deals-line: #e0cca8;   --deals-soft: #faf3e5;
  --finance-ink: #2d6a43; --finance-line: #bcd8c5; --finance-soft: #e9f4ed;
  --neutral-ink: #455266; --neutral-line: #d3d9e2; --neutral-soft: #f1f3f6;

  /* Deal types */
  --c-subto: #2c5aa0; --c-subto-soft: #e4ecf8;
  --c-hybrid: #6b4ea3; --c-hybrid-soft: #eee8f8;
  --c-sf: #2f7a52; --c-sf-soft: #e4f2ea;
  --c-review: #66707f; --c-review-soft: #eceff3;

  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(19, 41, 75, 0.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131b; --surface: #151c27; --surface-2: #1a2230; --ink: #e6ebf2; --ink-2: #b3bdcb; --ink-3: #8792a3;
    --line: #283244; --line-2: #212a3a; --navy: #0b1526; --gold: #d3a957; --focus: #7fb0ff; --row-hover: #1c2636; --zebra: #171f2b;
    --won: #6cc496; --won-soft: #173126; --lost: #e58c77; --lost-soft: #3a211c; --stage-soft: #2e2818; --stage-ink: #e2c88f;
    --summary-ink: #9dbcf0; --summary-line: #2d4266; --summary-soft: #1a2639;
    --types-ink: #c2b4ef;   --types-line: #3d3561;   --types-soft: #211d33;
    --stages-ink: #7fd0c9;  --stages-line: #22504d;  --stages-soft: #142a29;
    --deals-ink: #e3bd7a;   --deals-line: #54401e;   --deals-soft: #2a2215;
    --finance-ink: #8fd4a6; --finance-line: #285138; --finance-soft: #152a1e;
    --neutral-ink: #b3bdcb; --neutral-line: #313b4d; --neutral-soft: #1c2431;
    --c-subto: #8fb0e6; --c-subto-soft: #1c2a42; --c-hybrid: #c3a2e3; --c-hybrid-soft: #2a2238;
    --c-sf: #6cc496; --c-sf-soft: #17322a; --c-review: #a3acb9; --c-review-soft: #232b38;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e131b; --surface: #151c27; --surface-2: #1a2230; --ink: #e6ebf2; --ink-2: #b3bdcb; --ink-3: #8792a3;
  --line: #283244; --line-2: #212a3a; --navy: #0b1526; --gold: #d3a957; --focus: #7fb0ff; --row-hover: #1c2636; --zebra: #171f2b;
  --won: #6cc496; --won-soft: #173126; --lost: #e58c77; --lost-soft: #3a211c; --stage-soft: #2e2818; --stage-ink: #e2c88f;
  --summary-ink: #9dbcf0; --summary-line: #2d4266; --summary-soft: #1a2639;
  --types-ink: #c2b4ef;   --types-line: #3d3561;   --types-soft: #211d33;
  --stages-ink: #7fd0c9;  --stages-line: #22504d;  --stages-soft: #142a29;
  --deals-ink: #e3bd7a;   --deals-line: #54401e;   --deals-soft: #2a2215;
  --finance-ink: #8fd4a6; --finance-line: #285138; --finance-soft: #152a1e;
  --neutral-ink: #b3bdcb; --neutral-line: #313b4d; --neutral-soft: #1c2431;
  --c-subto: #8fb0e6; --c-subto-soft: #1c2a42; --c-hybrid: #c3a2e3; --c-hybrid-soft: #2a2238;
  --c-sf: #6cc496; --c-sf-soft: #17322a; --c-review: #a3acb9; --c-review-soft: #232b38;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font); font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--focus); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }

/* ---------- Masthead ---------- */
.topbar { background: var(--navy); color: #fff; border-bottom: 3px solid var(--gold); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding-block: 12px;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 12px; color: #fff; text-decoration: none; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: 0.005em; }
.brand-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.16em; color: var(--gold); border-left: 1px solid rgba(255,255,255,0.25); padding-left: 12px; }
.topbar-spacer { flex: 1; }
.topbar .who { font-size: 13px; color: #c3cde0; }
.topbar a.link { color: #fff; font-size: 13px; text-decoration: none; opacity: 0.85; }
.topbar a.link:hover { opacity: 1; text-decoration: underline; }

main {
  max-width: 1280px; margin: 0 auto; padding-block: 24px 48px;
  padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
  display: grid; gap: 20px;
}
main > * { min-width: 0; }

/* ---------- Page heading ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-3); }
.page-head h1 { font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1.15; color: var(--ink); }
.page-head .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.page-head .spacer { flex: 1; }

.banner { background: var(--deals-soft); border: 1px solid var(--deals-line); color: var(--ink); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: 6px; padding: 7px 14px;
  cursor: pointer; font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow);
}
.btn:hover { border-color: var(--ink-3); background: var(--surface-2); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { filter: brightness(1.15); }
:root[data-theme="dark"] .btn.primary { background: var(--gold); border-color: var(--gold); color: #10151f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { background: var(--gold); border-color: var(--gold); color: #10151f; } }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.field { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 10px; min-height: 36px; font-size: 13px; }
.field:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }

/* ---------- Panels (sections) ---------- */
.panel {
  --tone-ink: var(--neutral-ink); --tone-line: var(--neutral-line); --tone-soft: var(--neutral-soft);
  background: var(--surface); border: 1px solid var(--tone-line); border-top: 3px solid var(--tone-ink);
  border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; overflow: hidden;
}
.tone-summary { --tone-ink: var(--summary-ink); --tone-line: var(--summary-line); --tone-soft: var(--summary-soft); }
.tone-types   { --tone-ink: var(--types-ink);   --tone-line: var(--types-line);   --tone-soft: var(--types-soft); }
.tone-stages  { --tone-ink: var(--stages-ink);  --tone-line: var(--stages-line);  --tone-soft: var(--stages-soft); }
.tone-deals   { --tone-ink: var(--deals-ink);   --tone-line: var(--deals-line);   --tone-soft: var(--deals-soft); }
.tone-finance { --tone-ink: var(--finance-ink); --tone-line: var(--finance-line); --tone-soft: var(--finance-soft); }
.tone-neutral { --tone-ink: var(--neutral-ink); --tone-line: var(--neutral-line); --tone-soft: var(--neutral-soft); }

.panel-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 11px 18px; background: var(--tone-soft); border-bottom: 1px solid var(--tone-line);
}
.panel-head h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--tone-ink); }
.panel-hint { font-size: 12px; color: var(--ink-3); }
.panel-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

/* ---------- Pipeline summary ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 2px 20px; border-left: 1px solid var(--line-2); }
.kpi:first-child { border-left: 0; padding-left: 2px; }
.kpi .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.kpi .value { font-size: 30px; font-weight: 600; line-height: 1.2; margin-top: 6px; color: var(--ink); letter-spacing: -0.01em; }
.kpi.accent .value { color: var(--summary-ink); }
.kpi .meta { font-size: 12px; color: var(--ink-2); margin-top: 4px; }

/* ---------- Deal types + stages row ---------- */
.dash-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 20px; align-items: start; }

.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.type-tile {
  display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "dot name count" "dot value count";
  align-items: center; column-gap: 10px; text-align: left; padding: 12px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); transition: background 0.12s, border-color 0.12s;
}
.type-tile::before { content: ""; grid-area: dot; width: 10px; height: 10px; border-radius: 50%; background: var(--c-review); align-self: start; margin-top: 5px; }
.type-tile.cat-subto::before { background: var(--c-subto); }
.type-tile.cat-hybrid::before { background: var(--c-hybrid); }
.type-tile.cat-sf::before { background: var(--c-sf); }
.type-tile:hover { background: var(--surface-2); border-color: var(--types-line); }
.type-tile.active { background: var(--types-soft); border-color: var(--types-ink); }
.type-name { grid-area: name; font-weight: 600; font-size: 13px; }
.type-value { grid-area: value; font-size: 12px; color: var(--ink-3); }
.type-count { grid-area: count; font-size: 26px; font-weight: 600; color: var(--ink); }

.stage-list { display: grid; gap: 2px; }
.stage-row {
  display: grid; grid-template-columns: 190px minmax(0, 1fr) 52px 84px; align-items: center; gap: 14px;
  padding: 6px 8px; border-radius: 5px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left;
}
.stage-row.stage-head { cursor: default; padding-block: 0 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); border-bottom: 1px solid var(--line-2); border-radius: 0; margin-bottom: 4px; }
.stage-row:not(.stage-head):hover { background: var(--stages-soft); }
.stage-row.active { background: var(--stages-soft); box-shadow: inset 3px 0 0 var(--stages-ink); }
.stage-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-track { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.stage-fill { height: 100%; background: var(--stages-ink); border-radius: 4px; min-width: 2px; }
.stage-fill.won { background: var(--won); }
.stage-fill.lost { background: var(--lost); opacity: 0.75; }
.stage-count, .stage-amt { text-align: right; font-size: 13px; }
.stage-count { color: var(--ink-3); }
.stage-amt { font-weight: 600; }

/* ---------- Deals table ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.toolbar input[type="search"] { flex: 1 1 240px; min-width: 0; }
.toolbar .count { color: var(--ink-3); font-size: 12px; margin-left: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-2); font-size: 13px; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th button:hover { color: var(--ink); }
th button:focus-visible { outline: 2px solid var(--focus); }
th.num, td.num { text-align: right; }
table.deals tbody tr { cursor: pointer; }
table.deals tbody tr:nth-child(even) { background: var(--zebra); }
table.deals tbody tr:hover { background: var(--row-hover); }
td.deal-name { font-weight: 600; color: var(--ink); }
td.muted { color: var(--ink-3); }
td.nowrap { white-space: nowrap; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; background: var(--stage-soft); color: var(--stage-ink); white-space: nowrap; }
.pill.won { background: var(--won-soft); color: var(--won); }
.pill.lost { background: var(--lost-soft); color: var(--lost); }
.pill.cat-subto { background: var(--c-subto-soft); color: var(--c-subto); }
.pill.cat-hybrid { background: var(--c-hybrid-soft); color: var(--c-hybrid); }
.pill.cat-sf { background: var(--c-sf-soft); color: var(--c-sf); }
.pill.cat-review { background: var(--c-review-soft); color: var(--c-review); }
.manual-mark { font-size: 11px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; color: var(--ink-3); font-size: 12px; gap: 10px; flex-wrap: wrap; background: var(--surface-2); }
.empty { padding: 40px; text-align: center; color: var(--ink-3); }

/* ---------- Deal detail ---------- */
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 500; }
.back:hover { color: var(--ink); }
.detail-head { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-head .title { flex: 1 1 360px; min-width: 0; }
.detail-head .title h1 { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.detail-head .facts { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; }
.detail-head .amount { font-size: 28px; font-weight: 600; color: var(--summary-ink); }
.links { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; min-width: 0; }

.photo-main { aspect-ratio: 16 / 9; max-width: 100%; background: var(--surface-2); overflow: hidden; display: grid; place-items: center; position: relative; }
.photo-main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-main.empty { aspect-ratio: auto; min-height: 120px; }
.photo-main .placeholder { color: var(--ink-3); font-size: 13px; text-align: center; padding: 20px; max-width: 46ch; }
.photo-caption { position: absolute; left: 10px; bottom: 10px; background: rgba(15, 21, 32, 0.75); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 4px; }
.thumbs { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; border-top: 1px solid var(--line); }
.thumbs[hidden] { display: none; }
.thumbs button { border: 2px solid transparent; padding: 0; border-radius: 5px; overflow: hidden; cursor: pointer; flex: 0 0 auto; background: var(--surface-2); }
.thumbs button.active { border-color: var(--gold); }
.thumbs img { width: 96px; height: 64px; object-fit: cover; display: block; }
.thumbs .sv-thumb { width: 96px; height: 64px; display: grid; place-items: center; font-size: 11px; color: var(--ink-3); }

.fin-type { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.fin-type .label, .fin-stats .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.fin-type .pill { font-size: 13px; padding: 3px 10px; }
.fin-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; border: 1px solid var(--line-2); border-radius: 6px; }
.fin-stats > div { padding: 12px 14px; border-left: 1px solid var(--line-2); }
.fin-stats > div:first-child { border-left: 0; }
.fin-stats .big { font-size: 22px; font-weight: 600; margin-top: 2px; }
.fin-stats .meta, p.meta, div.meta { font-size: 12px; color: var(--ink-2); }
.sub-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin: 0 0 8px; font-weight: 600; }
table.mortgages { border: 1px solid var(--line-2); border-radius: 6px; }
table.mortgages th, table.mortgages td { padding: 8px 12px; }
table.mortgages tfoot td { font-weight: 600; border-bottom: 0; background: var(--surface-2); }
details.why { margin-top: 14px; font-size: 13px; }
details.why summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }
details.why ul { margin: 8px 0 0; padding-left: 20px; color: var(--ink-2); }
details.why li { margin: 3px 0; overflow-wrap: anywhere; }

form.edit { display: grid; gap: 12px; }
form.edit label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
form.edit .row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
form.edit .field { width: 100%; min-width: 0; font-weight: 400; color: var(--ink); }
form.edit .actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }
form.edit .status { font-size: 12px; color: var(--ink-3); }
form.edit .status.err { color: var(--lost); }
form.edit .status.ok { color: var(--won); }
textarea.field { min-height: 90px; resize: vertical; }

.person { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.person:first-child { padding-top: 0; }
.person:last-child { border-bottom: 0; padding-bottom: 0; }
.person .name { font-weight: 600; }
.person .meta { overflow-wrap: anywhere; }
.note { padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.note:first-child { padding-top: 0; }
.note:last-child { border-bottom: 0; padding-bottom: 0; }
.note .when { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 4px; }
.note .body { white-space: pre-wrap; font-size: 13px; overflow-wrap: anywhere; }

details.allfields summary { cursor: pointer; font-weight: 500; }
dl.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 6px 14px; margin: 12px 0 0; font-size: 13px; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

.loading { padding: 60px; text-align: center; color: var(--ink-3); }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 13px; box-shadow: 0 6px 24px rgba(0,0,0,0.2); z-index: 20; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Navigation ---------- */
.topnav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar .link-btn { all: unset; cursor: pointer; color: #fff; font-size: 13px; opacity: 0.85; }
.topbar .link-btn:hover { opacity: 1; text-decoration: underline; }
.topbar .link-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.topbar .who { display: inline-flex; flex-direction: column; line-height: 1.2; text-align: right; padding-left: 16px; border-left: 1px solid rgba(255,255,255,0.2); }
.topbar .who-role { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--gold); color: #10151f; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }

/* ---------- Sign-in screens ---------- */
.auth-wrap { width: 100%; max-width: 440px; margin: 24px auto 0; display: grid; gap: 16px; }
.auth-intro { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); }
.auth-links a { font-weight: 500; }
.field-hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.btn.wide { width: 100%; justify-content: center; padding: 10px 14px; font-size: 14px; }
.form-status { margin: 0; font-size: 13px; min-height: 1em; }
.form-status.ok { color: var(--won); }
.form-status.err { color: var(--lost); }
.demo-helper { background: var(--deals-soft); border: 1px dashed var(--deals-line); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; color: var(--ink-2); }
.demo-helper p { margin: 6px 0; }
.demo-helper code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; background: var(--surface); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-2); overflow-wrap: anywhere; }
.demo-inbox { display: grid; gap: 6px; margin-top: 8px; }
.demo-mail { background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; padding: 8px 10px; overflow-wrap: anywhere; }
.demo-mail a { display: inline-block; margin-top: 4px; font-weight: 600; }
.demo-mail.muted { color: var(--ink-3); }

/* ---------- Users ---------- */
.narrow { max-width: 520px; }
table.users td { vertical-align: middle; }
table.users td.strong { font-weight: 600; }
table.users td.actions { white-space: nowrap; }
table.users td.actions .btn + .btn { margin-left: 6px; }
table.users select.field { min-width: 120px; }
.btn.danger { color: var(--lost); }
.btn.danger.armed { background: var(--lost); border-color: var(--lost); color: #fff; }
.pill.role-admin { background: var(--summary-soft); color: var(--summary-ink); }
.pill.status-active { background: var(--won-soft); color: var(--won); }
.pill.status-disabled { background: var(--c-review-soft); color: var(--c-review); }
.empty-note { margin: 0; color: var(--ink-3); font-size: 13px; }
ul.activity { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
ul.activity li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
ul.activity li:last-child { border-bottom: 0; }
ul.activity .when { color: var(--ink-3); }
@media (max-width: 640px) {
  .topnav { gap: 12px; }
  .topbar .who { display: none; }
  table.users thead { display: none; }
  table.users, table.users tbody, table.users tr, table.users td { display: block; width: 100%; }
  table.users tr { padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
  table.users td { border: 0; padding: 3px 0 !important; text-align: left; }
  table.users td.actions { padding-top: 8px !important; }
  ul.activity li { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .dash-row { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 18px; }
  .kpi:nth-child(3) { border-left: 0; padding-left: 2px; }
  .detail-grid { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-row { grid-template-columns: 140px minmax(0, 1fr) 40px 76px; gap: 10px; }
}
@media (max-width: 640px) {
  .topbar-inner, main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  main { padding-block: 16px 32px; gap: 16px; }
  .brand-name { font-size: 16px; }
  .page-head h1 { font-size: 24px; }
  .panel-body { padding: 14px; }
  .panel-head { padding: 10px 14px; }
  .kpi .value { font-size: 24px; }
  .stage-row { grid-template-columns: minmax(0, 1fr) 72px; grid-template-areas: "name amt" "track track"; row-gap: 4px; }
  .stage-row.stage-head { display: none; }
  .stage-name { grid-area: name; } .stage-amt { grid-area: amt; } .stage-track { grid-area: track; } .stage-count { display: none; }
  .toolbar { padding: 12px 14px; }
  table.deals thead { display: none; }
  table.deals, table.deals tbody, table.deals tr, table.deals td { display: block; width: 100%; }
  table.deals tbody tr { padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
  table.deals td { border: 0; padding: 2px 0 !important; }
  table.deals td.num { text-align: left; }
  table.deals td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); font-size: 12px; }
  .fin-stats { grid-template-columns: 1fr; }
  .fin-stats > div { border-left: 0; border-top: 1px solid var(--line-2); }
  .fin-stats > div:first-child { border-top: 0; }
  form.edit .row2 { grid-template-columns: 1fr; }
  .detail-head .title h1, .detail-head .amount { font-size: 22px; }
}

/* ---------- Notes ---------- */
.pill.role-team { background: var(--types-soft); color: var(--types-ink); }
form.note-form { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.note-form-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; align-items: start; }
.note-form textarea.field { min-height: 76px; }
.note-list { display: grid; }
@media (max-width: 640px) { .note-form-row { grid-template-columns: 1fr; } }
