:root {
  --bg: #f4f5f7; --card: #ffffff; --ink: #14181f; --muted: #667085; --line: #e6e8ec;
  --accent: #1f5fbf; --accent-ink: #ffffff; --ok: #1d7a46; --warn: #a15c00; --bad: #b42318; --chip: #eef2f8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1115; --card: #161a20; --ink: #e9ecf1; --muted: #8d97a7; --line: #252b34;
    --accent: #6ea2ff; --accent-ink: #0e1115; --ok: #5cc98a; --warn: #e3a64a; --bad: #ff7a6e; --chip: #20262f; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
.top { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { display: flex; gap: 12px; align-items: center; flex: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
main { max-width: 820px; margin: 0 auto; padding: 14px 16px calc(env(safe-area-inset-bottom) + 90px); }
.center { text-align: center; }
.muted { color: var(--muted); }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 11px 18px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer; min-height: 44px; }
button.link { background: none; color: var(--accent); padding: 4px 0; min-height: 0; font-weight: 500; }
button.small { font-size: 14px; }
.hero { max-width: 400px; margin: 12vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; text-align: center; }
.hero h1 { font-size: 22px; margin: 0 0 8px; }
.stats { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.stat { flex: 1; padding: 10px 12px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { font: inherit; font-size: 15px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); height: 40px; }
.toolbar input { flex: 1 1 100%; }
.toolbar select { flex: 1 1 0; min-width: 0; }
.list { display: grid; gap: 10px; }
.deal { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: inherit; text-decoration: none; }
.deal:active { opacity: .7; }
.row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.deal .name { font-weight: 600; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal .amt { font-weight: 600; white-space: nowrap; }
.deal .sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.meta .stage { font-weight: 600; color: var(--accent); }
.meta .stage::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.stage.s8, .stage.s9, .stage.s10 { color: var(--ok); }
.test { font-size: 11px; font-weight: 600; color: var(--warn); border: 1px solid currentColor; border-radius: 6px; padding: 0 5px; vertical-align: 2px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 17px; margin: 0 0 10px; }
dl.kv { display: grid; grid-template-columns: minmax(100px, 38%) 1fr; gap: 7px 12px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.q { border-top: 1px solid var(--line); padding: 10px 0; font-size: 14px; }
.q:first-of-type { border-top: 0; padding-top: 0; }
.q .sub { font-size: 13px; margin-top: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { font-size: 12px; background: var(--chip); border-radius: 999px; padding: 3px 9px; }
.chip.test { color: var(--warn); }
.status-Priced, .status-Received, .status-Approved, .status-Cleared { color: var(--ok); }
.status-Passed, .status-Rejected, .status-Expired { color: var(--bad); }
.back { margin-bottom: 10px; }
.err { color: var(--bad); }

.card a{color:var(--accent);text-decoration:none;font-weight:600;overflow-wrap:anywhere}.small{font-size:12px;margin:8px 0 0}

/* Editing */
.edit { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line, rgba(127,127,127,.25)); }
.edit label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted, #888); min-width: 0; flex: 1 1 180px; }
.edit select, .edit input, .c-status, textarea { font: inherit; color: inherit; background: var(--field, transparent); border: 1px solid var(--line, rgba(127,127,127,.35)); border-radius: 8px; padding: 8px 10px; max-width: 100%; }
.c-status { padding: 4px 6px; font-size: 13px; max-width: 55%; }
.c-status.ok { border-color: #2e9d5b; }
textarea { width: 100%; box-sizing: border-box; margin: 8px 0; resize: vertical; }
.notes { white-space: pre-wrap; font-size: 14px; line-height: 1.45; margin-bottom: 8px; max-height: 320px; overflow: auto; }
.saved { margin-left: 10px; font-size: 13px; color: #2e9d5b; }
.saved.bad { color: #d24c4c; }

/* Activity feed */
.feed { list-style: none; margin: 0; padding: 0; }
.ev { padding: 10px 0 10px 12px; border-left: 3px solid var(--line, rgba(127,127,127,.3)); margin-left: 2px; }
.ev + .ev { margin-top: 2px; }
.ev .row { gap: 10px; align-items: baseline; }
.ev time { font-size: 12px; color: var(--muted, #888); white-space: nowrap; flex-shrink: 0; }
.ev .sub { margin-top: 3px; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.ev a { overflow-wrap: anywhere; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 1px 6px; border-radius: 4px; background: rgba(127,127,127,.15); margin-right: 4px; }
.ev-quote { border-left-color: #2e9d5b; } .ev-pass { border-left-color: #d24c4c; } .ev-email_in, .ev-reply { border-left-color: #3b82f6; }
.ev-upload, .ev-condition { border-left-color: #a46be0; } .ev-pricing { border-left-color: #d9a43a; }

/* Tabs, add-condition, leads, AEs */
.tabs { display: flex; gap: 6px; margin: 0 0 14px; overflow-x: auto; }
.tabs a { padding: 7px 14px; border-radius: 999px; text-decoration: none; color: inherit; font-size: 14px; background: rgba(127,127,127,.12); white-space: nowrap; }
.tabs a.on { background: var(--accent, #3b6fd8); color: #fff; }
details.add { margin-top: 12px; }
details.add summary { cursor: pointer; font-size: 14px; color: var(--accent, #3b6fd8); }
details.add input { width: 100%; box-sizing: border-box; margin-top: 8px; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line, rgba(127,127,127,.35)); background: transparent; color: inherit; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; background: var(--accent, #3b6fd8); color: #fff; text-decoration: none; font-size: 14px; }
.deal.lead, .deal.ae { cursor: default; }
label.check { flex-direction: row; align-items: center; gap: 6px; flex: 0 1 auto; }
