:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1b1a18;
  --muted: #76716a;
  --faint: #9a948b;
  --line: #e7e3da;
  --line-soft: #f0ece4;
  --gold: #b1873c;
  --gold-deep: #8a6a2c;
  --gold-soft: #f4ecd9;
  --emerald: #1f7a5a;
  --emerald-soft: #e3f1ea;
  --rose: #b23b4e;
  --rose-soft: #f7e6e8;
  --blue: #3a6db0;
  --blue-soft: #e7eef8;
  --amber: #c9892f;
  --violet: #6d5bb0;
  --shadow: 0 1px 2px rgba(28,26,24,.06), 0 8px 24px rgba(28,26,24,.06);
  --shadow-lg: 0 12px 40px rgba(28,26,24,.16);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--gold-deep); }

/* ---------- layout ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; }

header.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(140deg, var(--gold) 0%, var(--gold-deep) 100%);
  display: grid; place-items: center; color: #fff; box-shadow: var(--shadow);
}
.brand .mark svg { width: 17px; height: 17px; }
.brand h1 { font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 0; letter-spacing: .2px; }
.brand h1 span { color: var(--gold-deep); }

.search { flex: 1; max-width: 420px; position: relative; }
.search input {
  width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-2); outline: none; color: var(--ink);
}
.search input:focus { border-color: var(--gold); background: #fff; box-shadow: 0 0 0 3px var(--gold-soft); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 15px; height: 15px; }

.topbar .spacer { flex: 1; }
.userpick { display: flex; align-items: center; gap: 7px; }
.userpick label { color: var(--muted); font-size: 12.5px; }
.userpick select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }

.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 13px; border-radius: 9px; font-weight: 550; display: inline-flex; align-items: center; gap: 7px;
  transition: .12s ease;
}
.btn:hover { border-color: var(--gold); background: var(--surface-2); }
.btn.primary { background: linear-gradient(140deg, var(--gold) 0%, var(--gold-deep) 100%); color: #fff; border: none; box-shadow: var(--shadow); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }

/* segmented view switch */
.viewswitch { display: inline-flex; background: var(--line-soft); border-radius: 10px; padding: 3px; gap: 2px; }
.viewswitch button {
  border: none; background: transparent; padding: 6px 13px; border-radius: 8px; color: var(--muted); font-weight: 550;
}
.viewswitch button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- filter bar ---------- */
.filterbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 22px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.filterbar select {
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
}
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px;
  font-size: 12.5px; color: var(--muted); font-weight: 550;
}
.chip:hover { border-color: var(--gold); }
.chip.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-deep); }
.filterbar .count { margin-left: auto; color: var(--faint); font-size: 12.5px; }

main { flex: 1; padding: 20px 22px 60px; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 550; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 26px; font-weight: 680; margin-top: 6px; font-family: var(--serif); }
.kpi .sub { color: var(--faint); font-size: 12px; margin-top: 3px; }
.kpi.win .value { color: var(--emerald); }
.kpi.open .value { color: var(--gold-deep); }
.kpi.warn .value { color: var(--rose); }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 880px) { .panels { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 14px; font-size: 14px; font-weight: 650; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-row .name { color: var(--muted); font-size: 12.5px; }
.bar-track { background: var(--line-soft); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--gold); }
.bar-row .n { text-align: right; color: var(--ink); font-weight: 600; font-size: 13px; }
.lead-board { display: flex; flex-direction: column; gap: 4px; }
.owner-row { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 11px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.owner-row:last-child { border-bottom: none; }
.owner-row .won { color: var(--emerald); font-weight: 650; }
.owner-row .meta { color: var(--faint); font-size: 12px; }

/* ---------- avatars / dots ---------- */
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.av-Aa { background: #3a6db0; } .av-Ak { background: #b1873c; } .av-Sh { background: #6d5bb0; } .av-Va { background: #1f7a5a; }
.av-_ { background: #b8b2a7; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.int-Hot { background: #d8442f; } .int-Warm { background: #e0962f; } .int-Cold { background: #5a86c4; } .int-Chilled { background: #8aa0b5; }

/* ---------- pipeline / kanban ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; }
.column { flex: 0 0 268px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.column.drag-over { border-color: var(--gold); background: var(--gold-soft); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.col-head .stage-dot { width: 9px; height: 9px; border-radius: 50%; }
.col-head .title { font-weight: 650; font-size: 13px; }
.col-head .n { margin-left: auto; color: var(--faint); font-size: 12px; background: var(--line-soft); padding: 1px 8px; border-radius: 999px; }
.col-head .val { color: var(--muted); font-size: 11.5px; }
.col-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.stage-Lead { color: #8a8378; } .stage-Contacted { color: #5a86c4; } .stage-Demo { color: #6d5bb0; }
.stage-Trial { color: #c9892f; } .stage-Negotiation { color: #b1873c; } .stage-Won { color: #1f7a5a; } .stage-Lost { color: #b23b4e; }
.bg-Lead { background: #b0a89b; } .bg-Contacted { background: #5a86c4; } .bg-Demo { background: #6d5bb0; }
.bg-Trial { background: #c9892f; } .bg-Negotiation { background: #b1873c; } .bg-Won { background: #1f7a5a; } .bg-Lost { background: #b23b4e; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; box-shadow: 0 1px 1px rgba(28,26,24,.04); cursor: pointer; transition: .12s ease;
}
.card:hover { border-color: var(--gold); box-shadow: var(--shadow); transform: translateY(-1px); }
.card.dragging { opacity: .5; }
.card .c-top { display: flex; align-items: center; gap: 8px; }
.card .c-name { font-weight: 620; font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .c-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.card .amount { font-weight: 650; color: var(--emerald); }
.card .pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--line-soft); color: var(--muted); }
.card .pill.pending { background: var(--gold-soft); color: var(--gold-deep); }
.card .pill.canned { background: var(--rose-soft); color: var(--rose); }
.card .pill.overdue { background: var(--rose-soft); color: var(--rose); }

/* ---------- table ---------- */
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.leads { width: 100%; border-collapse: collapse; }
table.leads th { text-align: left; padding: 11px 14px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; background: var(--surface-2); border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; position: sticky; top: 0; }
table.leads th:hover { color: var(--ink); }
table.leads td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); }
table.leads tr:hover td { background: var(--surface-2); }
table.leads tr { cursor: pointer; }
table.leads .name { font-weight: 600; }
.stage-tag { font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; display: inline-block; }
.tag-Lead { background: #efece6; color: #8a8378; } .tag-Contacted { background: var(--blue-soft); color: var(--blue); }
.tag-Demo { background: #ece8f6; color: var(--violet); } .tag-Trial { background: #fbefda; color: var(--amber); }
.tag-Negotiation { background: var(--gold-soft); color: var(--gold-deep); } .tag-Won { background: var(--emerald-soft); color: var(--emerald); }
.tag-Lost { background: var(--rose-soft); color: var(--rose); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(28,26,24,.34); opacity: 0; pointer-events: none; transition: .18s; z-index: 50; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 94vw; background: var(--surface);
  box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .22s cubic-bezier(.4,0,.2,1);
  z-index: 60; display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer .d-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 12px; }
.drawer .d-head .d-title { flex: 1; }
.drawer .d-head h2 { margin: 0; font-size: 18px; font-family: var(--serif); font-weight: 600; }
.drawer .d-head .sub { color: var(--faint); font-size: 12.5px; margin-top: 3px; }
.drawer .d-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .3px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); background: #fff; box-shadow: 0 0 0 3px var(--gold-soft); }
.field textarea { resize: vertical; min-height: 64px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.provenance { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.src-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--line-soft); color: var(--muted); }
.sectionlabel { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.activity { display: flex; flex-direction: column; gap: 0; }
.act { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.act .ic { width: 24px; height: 24px; border-radius: 50%; background: var(--line-soft); display: grid; place-items: center; flex: none; font-size: 11px; color: var(--muted); }
.act .a-main { font-size: 13px; }
.act .a-time { color: var(--faint); font-size: 11.5px; }
.addnote { display: flex; gap: 8px; margin-top: 12px; }
.addnote input { flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.d-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.d-foot .saved { color: var(--emerald); font-size: 12.5px; margin-left: auto; opacity: 0; transition: .2s; }
.d-foot .saved.show { opacity: 1; }

.iconbtn { border: none; background: var(--line-soft); width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.iconbtn:hover { background: var(--rose-soft); color: var(--rose); }
.empty { text-align: center; color: var(--faint); padding: 60px 20px; }

/* modal for new lead */
.modal-scrim { position: fixed; inset: 0; background: rgba(28,26,24,.34); display: none; place-items: center; z-index: 70; }
.modal-scrim.show { display: grid; }
.modal { background: var(--surface); border-radius: var(--radius); width: 440px; max-width: 92vw; box-shadow: var(--shadow-lg); padding: 22px; }
.modal h2 { margin: 0 0 16px; font-family: var(--serif); font-size: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .2s; z-index: 90; font-size: 13px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.muted { color: var(--muted); } .faint { color: var(--faint); }

/* ============ v2: theming ============ */
:root { --topbar-bg: rgba(255,255,255,.86); }
[data-theme="dark"] {
  --bg: #141312; --surface: #1e1c1a; --surface-2: #26231f; --ink: #efeae1; --muted: #a9a397; --faint: #7c766c;
  --line: #332f2a; --line-soft: #2a2722; --gold: #c99b4d; --gold-deep: #dcb064; --gold-soft: #3a2f1c;
  --emerald: #43b387; --emerald-soft: #16302a; --rose: #d76b78; --rose-soft: #3a2126; --blue: #5b8fd0; --blue-soft: #1b2a3d;
  --amber: #d39a45; --violet: #9182d6;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4); --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
  --topbar-bg: rgba(30,28,26,.88);
}
header.topbar { background: var(--topbar-bg); }
[data-theme="dark"] .tag-Lead { background: #2c2925; color: #b3a89a; }
[data-theme="dark"] .tag-Demo { background: #2a2440; color: #b3a6e6; }
[data-theme="dark"] .tag-Trial { background: #3a2f17; color: #e0b25e; }
[data-theme="dark"] .search input:focus, [data-theme="dark"] .field input:focus,
[data-theme="dark"] .field select:focus, [data-theme="dark"] .field textarea:focus { background: #2c2925; }
[data-theme="dark"] .brand h1 span { color: var(--gold-deep); }

/* ============ login ============ */
.login-scrim { position: fixed; inset: 0; z-index: 100; display: none; place-items: center;
  background: var(--bg); padding: 20px; }
.login-scrim.show { display: grid; }
.login-card { width: 380px; max-width: 92vw; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 30px 28px; }
.login-card .lbrand { display: flex; align-items: center; gap: 11px; margin-bottom: 4px; }
.login-card .mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(140deg, var(--gold), var(--gold-deep));
  display: grid; place-items: center; color: #fff; }
.login-card h1 { font-family: var(--serif); font-size: 22px; margin: 0; }
.login-card .tagline { color: var(--muted); font-size: 13px; margin: 4px 0 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .err { color: var(--rose); font-size: 13px; min-height: 18px; margin: 2px 0 8px; }
.login-card button { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.login-hint { color: var(--faint); font-size: 12px; text-align: center; margin-top: 16px; line-height: 1.6; }

/* ============ topbar additions ============ */
.icon-toggle { border: 1px solid var(--line); background: var(--surface); width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center; color: var(--muted); }
.icon-toggle:hover { border-color: var(--gold); color: var(--ink); }
.usermenu { position: relative; }
.usermenu .ubtn { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 5px 10px 5px 6px; }
.usermenu .ubtn:hover { border-color: var(--gold); }
.usermenu .uname { font-weight: 600; font-size: 13px; line-height: 1.1; }
.usermenu .urole { color: var(--faint); font-size: 11px; text-transform: capitalize; }
.usermenu .menu { position: absolute; right: 0; top: 46px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; display: none; z-index: 45; }
.usermenu .menu.show { display: block; }
.usermenu .menu button { width: 100%; text-align: left; border: none; background: transparent; padding: 9px 11px;
  border-radius: 8px; color: var(--ink); display: flex; align-items: center; gap: 9px; }
.usermenu .menu button:hover { background: var(--line-soft); }
.usermenu .menu .sep { height: 1px; background: var(--line); margin: 5px 0; }

/* ============ quote builder ============ */
.quote-box { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 6px; }
.qhead { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.qhead .qtotal { font-weight: 700; font-family: var(--serif); font-size: 17px; color: var(--gold-deep); }
.qprod { border-bottom: 1px solid var(--line-soft); }
.qprod:last-child { border-bottom: none; }
.qprow { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; }
.qprow:hover { background: var(--surface-2); }
.qprow .qname { font-weight: 600; flex: 1; }
.qprow .qamt { color: var(--emerald); font-weight: 650; font-size: 13.5px; }
.qbody { padding: 4px 14px 14px; display: none; }
.qbody.show { display: block; }
.qbody .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.seg { display: inline-flex; background: var(--line-soft); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 5px 12px; border-radius: 6px; color: var(--muted); font-weight: 550; font-size: 12.5px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.modchip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; color: var(--muted); }
.modchip.on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-deep); }
.qbody label.mini { font-size: 11.5px; color: var(--muted); margin-right: 4px; }
.qbody input[type=number], .qbody select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--ink); width: 90px; }
.qbody select { width: auto; }
.qnote { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.switch { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line); display: grid; place-items: center; flex: none; }
.switch.on { background: var(--gold); border-color: var(--gold); color: #fff; }
.req-banner { background: var(--gold-soft); color: var(--gold-deep); border: 1px solid var(--gold); border-radius: 9px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }

/* ============ users admin ============ */
.users-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.users-wrap .uhead { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.users-wrap h3 { margin: 0; font-size: 15px; }
.role-tag { font-size: 11px; font-weight: 650; padding: 2px 9px; border-radius: 999px; text-transform: capitalize; }
.role-owner { background: var(--gold-soft); color: var(--gold-deep); }
.role-manager { background: var(--blue-soft); color: var(--blue); }
.role-member { background: var(--line-soft); color: var(--muted); }
.uinactive { opacity: .5; }

/* ============ google sign-in ============ */
.or-sep { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 16px 0 12px; }
.or-sep::before, .or-sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
#googleBtn { display: flex; justify-content: center; min-height: 0; }
#googleBtn > div { color-scheme: light; }
.invite-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ============ intuitive lead drawer ============ */
.stage-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 16px; }
.stage-pill { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; transition: .12s ease; }
.stage-pill:hover { border-color: var(--gold); color: var(--ink); }
.stage-pill.on { color: #fff; border-color: transparent; box-shadow: var(--shadow); }
.kv { display: grid; grid-template-columns: 124px 1fr; align-items: center; gap: 8px; padding: 3px 0; }
.kv.top { align-items: start; }
.kv > label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kv > label svg { width: 14px; height: 14px; opacity: .7; }
.ghost { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 6px 8px; color: var(--ink); font-size: 13.5px; transition: .1s; font-family: inherit; }
.ghost:hover { background: var(--surface-2); }
.ghost::placeholder { color: var(--faint); }
.ghost:focus { background: #fff; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); outline: none; }
[data-theme="dark"] .ghost:focus { background: #2c2925; }
textarea.ghost { resize: vertical; min-height: 38px; }
.ownerpick { display: flex; align-items: center; gap: 8px; }
.ownerpick select { flex: 1; }
.ipills { display: flex; gap: 6px; flex-wrap: wrap; }
.ipill { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.ipill:hover { border-color: var(--gold); }
.ipill .dot { width: 8px; height: 8px; border-radius: 50%; }
.ipill.on { color: #fff; border-color: transparent; }
.ipill.on.i-Hot { background: #d8442f; } .ipill.on.i-Warm { background: #e0962f; } .ipill.on.i-Cold { background: #5a86c4; } .ipill.on.i-Chilled { background: #8aa0b5; }

/* quoted amount + history */
.quoted-wrap { border: 1px solid var(--line); border-top: none; border-radius: 0 0 12px 12px; padding: 12px 14px; background: var(--surface-2); }
.quoted-amount-row { display: flex; align-items: center; gap: 6px; }
.quoted-amount { font-family: var(--serif); font-size: 22px; font-weight: 680; color: var(--gold-deep); border: 1px solid transparent; background: transparent; width: 150px; padding: 2px 6px; border-radius: 7px; }
.quoted-amount:hover { background: var(--surface); }
.quoted-amount:focus { background: #fff; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); outline: none; }
[data-theme="dark"] .quoted-amount:focus { background: #2c2925; }
.list-price { font-size: 12px; color: var(--faint); margin-top: 6px; }
.qhistory { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.qhistory .h-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 6px; }
.qround { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0; }
.qround .rn { width: 24px; color: var(--faint); font-weight: 600; }
.qround .amt { font-weight: 650; color: var(--ink); min-width: 70px; }
.qround .meta { color: var(--faint); }

/* ============ loaders ============ */
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: -2px; margin-right: 6px; }
.spin.big { width: 26px; height: 26px; border-width: 3px; color: var(--gold); margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.busy, button.busy { opacity: .75; cursor: default; }
.loading-full { display: grid; place-items: center; min-height: 50vh; }

/* quote totals + per-product price */
.quoted-total { font-family: var(--serif); font-size: 22px; font-weight: 680; color: var(--gold-deep); }
.qprice input[type=number] { width: 110px; }
.reset-link { color: var(--gold-deep); cursor: pointer; text-decoration: underline; }
.qprow .qamt s { margin-right: 4px; font-size: 11px; }

/* ============ mobile / tablet ============ */
@media (max-width: 820px) {
  header.topbar { flex-wrap: wrap; gap: 10px 12px; padding: 10px 14px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .viewswitch { order: 4; }
  .brand h1 { font-size: 17px; }
  main { padding: 14px 14px 70px; }
  .filterbar { padding: 10px 14px; gap: 8px; }
  .filterbar select { flex: 1 1 40%; }
  .chips { flex-basis: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .panels { grid-template-columns: 1fr; }
  .column { flex-basis: calc(100vw - 56px); max-height: none; }
  .drawer { width: 100%; max-width: 100%; }
  .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.leads { min-width: 720px; }
  .newlead-label { display: none; } /* show + only */
}
@media (max-width: 520px) {
  .brand h1 span { display: none; }
  .viewswitch button { padding: 6px 10px; font-size: 12.5px; }
  .btn { padding: 11px 14px; min-height: 42px; } /* bigger tap targets */
  .stage-pill, .ipill, .chip { padding: 8px 13px; }
  .kpis { grid-template-columns: 1fr; }
  .filterbar { flex-direction: column; align-items: stretch; }
  .filterbar select { width: 100%; flex: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; align-items: start; }
  .kv > label { font-size: 11.5px; }
  .ghost { font-size: 16px; } /* avoid iOS/Android zoom on focus */
  .field input, .field select, .field textarea, .filterbar select, .search input, .quoted-amount, .qprice input { font-size: 16px; }
  .modal { width: 100%; max-width: 100%; padding: 18px 16px; }
  .modal .grid2, .drawer .grid2 { grid-template-columns: 1fr; }
  .usermenu .uname { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .column { flex-basis: calc(100vw - 40px); }
}

/* ============ field-type upgrades (feedback batch) ============ */
/* fix: selected stage pill text was invisible (base .stage-pill bg overrode .bg-*) */
.stage-pill.on.bg-Lead { background: #8a8378; } .stage-pill.on.bg-Contacted { background: #3a6db0; }
.stage-pill.on.bg-Demo { background: #6d5bb0; } .stage-pill.on.bg-Trial { background: #c9892f; }
.stage-pill.on.bg-Negotiation { background: #b1873c; } .stage-pill.on.bg-Won { background: #1f7a5a; }
.stage-pill.on.bg-Lost { background: #b23b4e; }
.stage-pill.on { color: #fff !important; }

/* multi-select product chips + source pills (editable) */
.chips-edit { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.opt-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.opt-chip:hover { border-color: var(--gold); }
.opt-chip.on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-deep); }
.opt-chip .x { color: var(--rose); font-weight: 700; margin-left: 2px; cursor: pointer; }
.opt-add { border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 5px 10px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.opt-add:hover { border-color: var(--gold); color: var(--gold-deep); }
.manage-link { font-size: 11px; color: var(--gold-deep); cursor: pointer; text-decoration: underline; margin-left: 6px; }
.lost-reason-row { background: var(--rose-soft); border: 1px solid var(--rose); border-radius: 8px; padding: 8px 10px; margin-top: 6px; }

/* ============ multi-phone contacts editor ============ */
#contactsMount { width: 100%; }
.contact-row { display: flex; gap: 6px; align-items: center; margin-bottom: 5px; }
.contact-row .cnum { flex: 0 0 44%; }
.contact-row .cnames { flex: 1; }
.contact-row .cdel { border: none; background: var(--line-soft); color: var(--muted); width: 24px; height: 28px; border-radius: 7px; flex: none; font-size: 15px; line-height: 1; }
.contact-row .cdel:hover { background: var(--rose-soft); color: var(--rose); }
#addContact { margin-top: 2px; }

/* editable drawer title (company name) */
.d-name-input { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--ink); border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 2px 6px; width: 100%; max-width: 340px; }
.d-name-input:hover { background: var(--surface-2); }
.d-name-input:focus { background: #fff; border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px var(--gold-soft); }
[data-theme="dark"] .d-name-input:focus { background: #2c2925; }

/* Stuck stage (blocked: needs customisation / waiting on a feature) */
.bg-Stuck { background: #b5683c; }
.stage-Stuck { color: #b5683c; }
.tag-Stuck { background: #f4e2d6; color: #8a4e2c; }
.stage-pill.on.bg-Stuck { background: #b5683c; }
[data-theme="dark"] .tag-Stuck { background: #3a2a1f; color: #d39b76; }
.stuck-row { background: #f7ebe2; border: 1px solid #d9a981; border-radius: 8px; padding: 8px 10px; margin-top: 6px; }
[data-theme="dark"] .stuck-row { background: #2e2117; border-color: #5a3f28; }

/* Bad Data stage (review pen for jumbled/uncertain leads) */
.bg-BadData { background: #6b6560; }
.stage-BadData { color: #6b6560; }
.tag-BadData { background: #e6e2dc; color: #5c554f; }
.stage-pill.on.bg-BadData { background: #6b6560; }
[data-theme="dark"] .tag-BadData { background: #2e2b27; color: #b3aca3; }

/* Ghosting stage (lead went silent) */
.bg-Ghosting { background: #6b7894; }
.stage-Ghosting { color: #6b7894; }
.tag-Ghosting { background: #e6e9f0; color: #515d78; }
.stage-pill.on.bg-Ghosting { background: #6b7894; }
[data-theme="dark"] .tag-Ghosting { background: #262a36; color: #9aa6c4; }
