:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --col: #ebedf0;
  --text: #1c2230;
  --muted: #6b7385;
  --line: #dfe2e8;
  --primary: #2f5bea;
  --primary-ink: #ffffff;
  --danger: #d13b3b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;

  --st-new: #2f5bea;
  --st-quoted: #e2a100;
  --st-won: #1f9d55;
  --st-lost: #d13b3b;
  --st-unqualified: #8a8f9c;

  --src-whatsapp: #128c4a;
  --src-facebook: #1877f2;
  --src-instagram: #c13584;
  --src-google: #c5221f;
  --src-website: #5b4bd6;
  --src-referral: #b85c00;
  --src-manual: #5f6675;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: #151b2b; color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand.big { font-size: 22px; color: var(--text); }
.logo { color: #6f8cff; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #c5cbe0; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.topbar nav a.active { color: #fff; background: rgba(255,255,255,.12); }
.topbar .user { margin-left: auto; color: #aab1c7; font-size: 13px; }
.topbar .user a { color: #fff; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c4c9d4; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger.ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger.ghost:hover { background: #fdeeee; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.wa { color: var(--src-whatsapp); }
.btn.full { width: 100%; }
.icon-btn { border: 0; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }

input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 91, 234, .25); border-color: var(--primary); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 4px; font-size: 14px; font-weight: 400; color: var(--text); }
.label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }

/* ---------- board ---------- */
.board-page { padding: 18px 20px 24px; }
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-right { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.toolbar-right input { width: 240px; height: 36px; }
.toolbar-right select { width: 160px; height: 36px; padding: 0 8px; }

.board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(230px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: start;
}
.column {
  background: var(--col); border-radius: var(--radius);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 150px);
  min-height: 300px;
}
.column header { padding: 12px 12px 8px; }
.col-title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.col-total { color: var(--muted); font-size: 12px; margin-top: 2px; min-height: 16px; padding-left: 18px; }
.count { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.stage-new { background: var(--st-new); }
.stage-quoted { background: var(--st-quoted); }
.stage-won { background: var(--st-won); }
.stage-lost { background: var(--st-lost); }
.stage-unqualified { background: var(--st-unqualified); }

.cards { padding: 4px 8px 10px; overflow-y: auto; flex: 1; min-height: 80px; display: flex; flex-direction: column; gap: 8px; }
.is-dragging .cards { background: rgba(47, 91, 234, .04); border-radius: 8px; }

.card {
  background: var(--panel); border-radius: 8px; padding: 10px 12px;
  box-shadow: var(--shadow); cursor: grab; border: 1px solid transparent;
  user-select: none;
}
.card:hover { border-color: #c9cfdb; }
.card:active { cursor: grabbing; }
.card-ghost { opacity: .35; }
.card-chosen { box-shadow: 0 8px 24px rgba(16,24,40,.18); }
.card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.card-name { font-weight: 650; font-size: 14.5px; overflow-wrap: anywhere; }
.card-line { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.card-msg { margin-top: 6px; font-size: 12.5px; color: #3b4252; background: #f5f6f8; border-radius: 6px; padding: 5px 7px; overflow-wrap: anywhere; }
.card-value { margin-top: 6px; font-weight: 700; color: var(--st-won); font-size: 13px; }
.age { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.pill-new { background: #e7edff; color: var(--primary); font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 4px; letter-spacing: .03em; }

.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; color: #fff; background: var(--src-manual); }
.src-whatsapp { background: var(--src-whatsapp); }
.src-facebook { background: var(--src-facebook); }
.src-instagram { background: var(--src-instagram); }
.src-google { background: var(--src-google); }
.src-website { background: var(--src-website); }
.src-referral { background: var(--src-referral); }
.src-manual { background: var(--src-manual); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 20, 35, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 50; overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 560px; padding: 18px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-foot { display: flex; gap: 8px; align-items: center; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.msg-box { white-space: pre-wrap; background: #f5f6f8; border-radius: 8px; padding: 10px; margin-bottom: 12px; max-height: 160px; overflow: auto; font-size: 13px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
details { margin: 6px 0; }
summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
#activity { list-style: none; padding: 0; margin: 8px 0 0; max-height: 160px; overflow: auto; }
#activity li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; font-size: 13px; }
#activity small { color: var(--muted); }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #151b2b; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-weight: 500; }
.toast.error { background: var(--danger); }

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--panel); padding: 28px; border-radius: 14px; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.login-card .muted { margin: 4px 0 18px; }
.alert { background: #fdeeee; color: var(--danger); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-weight: 500; }

/* ---------- reports ---------- */
.reports { padding: 18px 20px 40px; max-width: 1200px; margin: 0 auto; }
.reports .toolbar select { width: auto; height: 36px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .k-value { font-size: 26px; font-weight: 750; margin-top: 2px; }
.kpi .k-sub { color: var(--muted); font-size: 12px; }
.panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel.wide { grid-column: 1 / -1; }
.panel h2 { margin-bottom: 12px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 90px; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.bar-track { background: #eef0f4; border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; min-width: 2px; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; }
.bar-num small { color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.current td { background: #f6f8ff; font-weight: 600; }

.month-chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.mc-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.mc-bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.mc-bar { width: 40%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 1px; }
.mc-bar.won { background: var(--st-won); }
.mc-bar.lost { background: var(--st-lost); opacity: .75; }
.mc-label { display: flex; gap: 8px; }
.mc-labels { display: flex; gap: 8px; }
.mc-labels span { flex: 1; text-align: center; color: var(--muted); font-size: 11px; padding-top: 4px; min-width: 0; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .user { display: none; }
  .board-page, .reports { padding: 14px 12px; }
  .toolbar-right { margin-left: 0; width: 100%; }
  .toolbar-right input { flex: 1 1 100%; width: auto; }
  .board { grid-template-columns: repeat(var(--cols, 5), 82vw); scroll-snap-type: x mandatory; }
  .column { scroll-snap-align: start; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 70px; }
}

/* =====================================================================
   Version 2 — clients, tasks, quotes, projects
   ===================================================================== */
:root {
  --amber: #b77900;
  --amber-bg: #fff6df;
  --red-bg: #fdeeee;
  --green-bg: #e9f8ef;
  --blue-bg: #e7edff;
}

/* top bar with more items */
.topbar { gap: 18px; }
.topbar .brand { color: #fff; white-space: nowrap; }
.topbar nav { overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.topbar .user { margin-left: 0; white-space: nowrap; }
.topbar .user a.active { text-decoration: underline; }
.topbar .sep { opacity: .5; }
.nav-badge { background: #e5484d; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 6px; line-height: 17px; min-width: 18px; text-align: center; }

.flash { position: fixed; top: 66px; left: 50%; transform: translateX(-50%); background: #151b2b; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-weight: 500; max-width: calc(100vw - 32px); }

/* generic page */
.page { padding: 18px 20px 48px; max-width: 1280px; margin: 0 auto; }
.page.narrow { max-width: 900px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.thin { font-weight: 400; }
.small { font-size: 12.5px; }
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }
.right { margin-left: auto; }
.inline { display: inline; margin: 0; }
.pre { white-space: pre-wrap; }
.red { color: var(--danger); }
.owed { color: var(--danger) !important; }
.small-v { font-size: 19px !important; }
.panel.subtle { background: transparent; box-shadow: none; border: 1px dashed var(--line); }
.panel.flush { padding: 0; overflow: hidden; }
.panel h2 { display: flex; align-items: center; gap: 8px; }
.empty { padding: 40px 20px; text-align: center; }
fieldset.bare { border: 0; padding: 0; margin: 0; min-width: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
.form-foot { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.sticky-foot { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; z-index: 5; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }
.linkbtn:hover { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 500; color: var(--text); }
.check-row input { width: 18px; height: 18px; margin-top: 2px; flex: none; }
input.color { height: 38px; padding: 3px; width: 80px; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--blue-bg); }
.notice.ok { background: var(--green-bg); }
.notice.warn { background: var(--amber-bg); }

.panels.lead-layout { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.panels.quote-layout { grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr); align-items: start; }
.panels > div > .panel, .panels > aside > .panel { margin-bottom: 14px; }

/* tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs a:hover { background: #e6e8ec; }
.tabs a.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

/* tables */
.table-wrap { overflow-x: auto; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover td { background: #f7f8fb; }
.panel.flush table th, .panel.flush table td { padding: 10px 14px; }

/* badges */
.stage-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.sb-new { background: var(--blue-bg); color: var(--st-new); }
.sb-quoted { background: var(--amber-bg); color: var(--amber); }
.sb-won { background: var(--green-bg); color: var(--st-won); }
.sb-lost { background: var(--red-bg); color: var(--st-lost); }
.sb-unqualified { background: #eef0f4; color: var(--st-unqualified); }
.qs, .ps { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: #eef0f4; color: #5f6675; }
.qs-sent { background: var(--blue-bg); color: var(--primary); }
.qs-viewed { background: #efe9ff; color: #6a3fd1; }
.qs-accepted { background: var(--green-bg); color: var(--st-won); }
.qs-declined, .qs-expired { background: var(--red-bg); color: var(--st-lost); }
.ps-design { background: #efe9ff; color: #6a3fd1; }
.ps-development { background: var(--blue-bg); color: var(--primary); }
.ps-review { background: var(--amber-bg); color: var(--amber); }
.ps-launched { background: var(--green-bg); color: var(--st-won); }
.ps-on_hold { background: #eef0f4; color: #5f6675; }
.ps-cancelled { background: var(--red-bg); color: var(--st-lost); }
.paid-tag { color: var(--st-won); font-weight: 600; font-size: 12.5px; }

.progress { height: 6px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--st-won); border-radius: 999px; }

/* lists */
.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.simple-list li:last-child { border-bottom: 0; }
.activity { list-style: none; padding: 0; margin: 0; max-height: 420px; overflow: auto; }
.activity li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; font-size: 13px; gap: 2px; }
.activity li:last-child { border-bottom: 0; }
.activity small { color: var(--muted); }
.note-form { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.note-form textarea { flex: 1; }

/* tasks */
.task-list { list-style: none; margin: 0 0 10px; padding: 0; }
.task { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.task:last-child { border-bottom: 0; }
.task .check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid #c4c9d4; background: #fff; cursor: pointer; flex: none; color: #fff; font-weight: 800; font-size: 13px; line-height: 1; padding: 0; margin-top: 1px; }
.task .check:hover { border-color: var(--st-won); }
.task.done .check { background: var(--st-won); border-color: var(--st-won); }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-body { min-width: 0; flex: 1; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.ttype { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #eef0f4; padding: 1px 6px; border-radius: 4px; margin-right: 4px; vertical-align: 1px; }
.task-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.task.overdue .due { color: var(--danger); font-weight: 700; }
.task.today .due { color: var(--amber); font-weight: 700; }
.task-form { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.tf-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.tf-row input[name=title], .tf-row input[name=followup_title] { flex: 1 1 200px; }
.tf-row input[type=date] { width: 150px; }
.tf-row input[type=time] { width: 110px; }
.tf-type { width: 120px; }
.quick-dates { display: flex; gap: 4px; flex-wrap: wrap; }
.quick-dates button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; color: var(--muted); font-weight: 600; }
.quick-dates button:hover, .quick-dates button.on { border-color: var(--primary); color: var(--primary); background: var(--blue-bg); }

/* pipeline cards v2 */
.card-company { font-size: 12.5px; color: #3b4252; font-weight: 500; margin-top: -1px; }
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin: 5px 0 3px; }
.tag { font-size: 11px; background: #f0f2f6; color: #4a5263; padding: 1px 6px; border-radius: 4px; }
.card-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: #f0f2f6; color: #4a5263; }
.chip.follow.today { background: var(--amber-bg); color: var(--amber); }
.chip.follow.overdue { background: var(--red-bg); color: var(--danger); }
.chip.nofollow { background: transparent; border: 1px dashed #c9cfdb; color: var(--muted); }
.chip.quote { background: var(--blue-bg); color: var(--primary); }
.chip.quote.viewed { background: #efe9ff; color: #6a3fd1; }
.lost-reason { color: var(--danger); }
.toolbar-right select { width: auto; max-width: 190px; }
.modal-head { gap: 10px; }
.modal-head h2 { margin-right: auto; }
.followup-box { background: #f7f8fb; border-radius: 8px; padding: 10px 12px; margin: 4px 0 12px; }
.followup-box .tf-row { margin: 6px 0; }
.open-task { color: #3b4252; margin-bottom: 2px; }
.open-task.overdue { color: var(--danger); }
.small-modal { max-width: 460px; }
.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.reason-grid .btn { justify-content: flex-start; height: auto; padding: 10px 12px; white-space: normal; text-align: left; }

/* quote builder */
.items-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 110px 110px 100px 30px; gap: 8px; align-items: start; }
.items-head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 0 4px; border-bottom: 1px solid var(--line); }
.item-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.item-main { display: flex; flex-direction: column; gap: 4px; }
.item-main textarea { resize: none; font-size: 13px; color: #3b4252; }
.item-row .amount { padding-top: 9px; font-weight: 600; font-variant-numeric: tabular-nums; }
.item-row .rec { padding: 8px 6px; }
.item-actions { display: flex; gap: 8px; margin: 10px 0; position: relative; flex-wrap: wrap; }
.presets summary { list-style: none; }
.presets summary::-webkit-details-marker { display: none; }
.preset-list { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(16,24,40,.15); padding: 6px; margin-top: 6px; width: 320px; max-width: calc(100vw - 40px); }
.preset { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; }
.preset:hover { background: #f4f6fb; }
.totals-wrap { display: flex; gap: 24px; justify-content: space-between; align-items: flex-start; margin-top: 16px; flex-wrap: wrap; }
.totals-inputs { flex: 1 1 300px; max-width: 420px; }
table.totals { width: 300px; }
table.totals td { padding: 5px 4px; border: 0; }
table.totals .grand td { font-size: 17px; font-weight: 800; border-top: 2px solid var(--text); padding-top: 8px; }
.copy-row { display: flex; gap: 6px; margin: 10px 0; }
.copy-row input { font-size: 12px; color: var(--muted); }
.stack-btns { display: flex; flex-direction: column; gap: 8px; }
.btn.full { width: 100%; }

/* projects / payments */
.payments tr.paid td { color: var(--muted); }
.payments tr.paid td b { color: var(--text); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: 8px; }
.pay-pop { display: inline-block; position: relative; }
.pay-pop summary { list-style: none; cursor: pointer; }
.pay-pop summary::-webkit-details-marker { display: none; }
.pop { position: absolute; right: 0; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(16,24,40,.15); padding: 12px; width: 240px; margin-top: 6px; text-align: left; }
.add-payment { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.add-payment input[name=label] { flex: 2 1 200px; }
.add-payment input[name=amount] { flex: 1 1 110px; }
.add-payment input[type=date] { flex: 0 1 160px; }

/* reports v2 */
.mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-kpis > div { background: #f7f8fb; border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; }
.mini-kpis span { font-size: 20px; font-weight: 750; color: var(--text); }
.mini-kpis small { color: var(--muted); }

.hide-sm { }
@media (max-width: 900px) {
  .panels.lead-layout, .panels.quote-layout { grid-template-columns: minmax(0, 1fr); }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .mini-kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .page { padding: 14px 12px 40px; }
  .topbar .brand-name { display: none; }
  .topbar .user { display: block; font-size: 12px; }
  .topbar .user .sep, .topbar .user a[href="logout.php"] { display: none; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .hide-sm { display: none; }
  .items-head { display: none; }
  .item-row { grid-template-columns: 60px 1fr 1fr 30px; }
  .item-main { grid-column: 1 / -1; }
  .item-row .amount { grid-column: 1 / -2; padding-top: 0; }
  .toolbar-right select { max-width: none; flex: 1 1 140px; }
  table.totals { width: 100%; }
  .reason-grid { grid-template-columns: 1fr; }
  .flash { top: 62px; }
}
fieldset[disabled] .item-actions, fieldset[disabled] .del-item { display: none; }

/* =====================================================================
   Version 3 — project pipeline + roles
   ===================================================================== */
.pstage-unassigned { background: #8a8f9c; }
.pstage-pending_info { background: #e2a100; }
.pstage-development { background: var(--primary); }
.pstage-revision { background: #8b5cf6; }
.pstage-delivered { background: var(--st-won); }
.pst-unassigned { background: #eef0f4; color: #5f6675; }
.pst-pending_info { background: var(--amber-bg); color: var(--amber); }
.pst-development { background: var(--blue-bg); color: var(--primary); }
.pst-revision { background: #efe9ff; color: #6a3fd1; }
.pst-delivered { background: var(--green-bg); color: var(--st-won); }

a.card.pcard { display: block; color: inherit; text-decoration: none; }
.pcard .card-top { gap: 6px; }
.pcard .age { max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assignee { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: #3b4252; font-weight: 500; }
.assignee.none { color: var(--muted); font-style: italic; font-weight: 400; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.chip.owed-chip { background: var(--red-bg); color: var(--danger); }
.flash-card { animation: flashcard 1.6s ease; }
@keyframes flashcard { 0%, 40% { box-shadow: 0 0 0 3px rgba(47, 91, 234, .5); } 100% { box-shadow: var(--shadow); } }
.role-pill { background: rgba(255,255,255,.12); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; margin-right: 4px; }
tr.inactive td { color: var(--muted); }
.activity li.act-stage span, .activity li.act-assign span, .activity li.act-created span, .activity li.act-archive span, .activity li.act-deadline span { color: var(--muted); font-style: italic; }
.activity li.act-comment span { color: var(--text); }

/* ===== Version 4 — sales reps ===== */
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0 14px; }
.role-grid > div { background: #f7f8fb; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.role-grid b { color: var(--text); font-size: 13px; }
.for-who { color: var(--primary); font-weight: 600; }
.card .assignee { margin-top: 8px; padding-top: 7px; border-top: 1px solid #f0f2f6; }
.seq-chip { background: #eef0f4; color: #4a5263; }
@media (max-width: 760px) { .role-grid { grid-template-columns: 1fr; } }

/* ===== Version 5 — call logging & performance ===== */
.good { color: var(--st-won) !important; }
.nowrap { white-space: nowrap; }
.btn.disabled { opacity: .35; pointer-events: none; }

/* top-bar counter for sales reps */
.call-counter { display: flex; flex-direction: column; gap: 3px; color: #fff; text-decoration: none; padding: 4px 10px; border-radius: 8px; background: rgba(255,255,255,.08); min-width: 108px; }
.call-counter:hover { background: rgba(255,255,255,.14); }
.cc-num { font-weight: 800; font-size: 15px; line-height: 1; }
.cc-of { font-size: 11px; color: #aab1c7; margin-left: 2px; }
.cc-line { white-space: nowrap; }
.cc-bar { display: block; height: 4px; background: rgba(255,255,255,.15); border-radius: 999px; overflow: hidden; }
.cc-bar span { display: block; height: 100%; background: #f5b83d; border-radius: 999px; transition: width .3s; }
.call-counter.hit .cc-bar span { background: #3ccf7a; }
.call-counter.hit .cc-num { color: #3ccf7a; }

/* outcome picker */
.call-menu { position: absolute; z-index: 200; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(16,24,40,.22); padding: 12px; }
.cm-title { font-weight: 700; margin-bottom: 8px; }
.cm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.cm-grid button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 9px 6px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text); }
.cm-grid button:hover { border-color: var(--primary); background: var(--blue-bg); }
.cm-grid button.good { border-color: #bfe6cf; background: var(--green-bg); color: var(--st-won) !important; }
.cm-grid button:disabled { opacity: .5; }
.call-menu input { margin-bottom: 8px; font-size: 13px; }
.call-menu .cm-note { margin-bottom: 0; }

/* on pipeline cards */
.card-call { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.log-call-btn { border: 1px solid var(--line); background: #fff; color: var(--primary); font: inherit; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; cursor: pointer; }
.btn.log-call-btn { color: inherit; font-size: inherit; padding: 0 14px; }
.btn.small.log-call-btn { padding: 0 10px; font-size: 13px; }
.btn.primary.log-call-btn { color: #fff; }
.log-call-btn:hover { border-color: var(--primary); }
.calls-meta { font-size: 11.5px; color: var(--muted); }
.calls-meta.none { font-style: italic; }
.task-call { margin-top: 6px; }

/* outcome badges */
.co { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: #eef0f4; color: #4a5263; white-space: nowrap; }
.co-talked, .co-callback { background: var(--green-bg); color: var(--st-won); }
.co-not_interested, .co-wrong_number { background: var(--red-bg); color: var(--danger); }
.co-voicemail { background: var(--blue-bg); color: var(--primary); }

/* performance page */
.inline-tabs { margin: 0; }
.period-nav { align-items: center; }
.period-label { font-weight: 700; min-width: 130px; text-align: center; }
.leaderboard .big-num { font-size: 20px; font-weight: 800; }
.leaderboard .total-row td { background: #f7f8fb; font-weight: 700; }
.progress.target { height: 8px; margin-bottom: 3px; }
.progress.target.half > div { background: #e2a100; }
.progress.target.low > div { background: var(--danger); }
.day-grid { border-collapse: separate; border-spacing: 3px; }
.day-grid th { font-size: 11px; color: var(--muted); text-align: center; border: 0; padding: 2px; font-weight: 600; }
.day-grid th span { font-size: 13px; color: var(--text); }
.day-grid th.wkh span { color: var(--muted); }
.day-grid td { border: 0; padding: 0; }
.day-grid td.rep { padding-right: 10px; font-weight: 600; white-space: nowrap; font-size: 13px; }
.day-grid td.cell { width: 42px; min-width: 42px; height: 34px; text-align: center; border-radius: 6px; font-weight: 700; font-size: 13px; }
.cell.hit { background: #c9efd8; color: #126b3a; }
.cell.half { background: #fdeab8; color: #8a5a00; }
.cell.low { background: #fbd5d5; color: #a32020; }
.cell.live { background: #e7edff; color: var(--primary); outline: 2px dashed #b6c6ff; }
.cell.wk { background: #f4f5f7; color: var(--muted); }
.cell.wk.has { color: var(--text); }
.legend .lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.lg.hit { background: #c9efd8; } .lg.half { background: #fdeab8; } .lg.low { background: #fbd5d5; } .lg.wk { background: #f4f5f7; border: 1px solid var(--line); }
@media (max-width: 760px) {
  .call-counter { min-width: 0; padding: 4px 8px; }
  .cc-of { display: none; }
  .period-nav { width: 100%; justify-content: space-between; }
}

/* ===== Version 6 — proposals ===== */
.kind-badge { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: #efe9ff; color: #6a3fd1; padding: 1px 6px; border-radius: 4px; }
.qs-changes { background: var(--amber-bg); color: var(--amber); }
details.psec { border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; margin-bottom: 8px; }
details.psec[open] { padding-bottom: 6px; }
details.psec summary { padding: 10px 0; font-weight: 700; cursor: pointer; }

/* ===== 6.2 — editable stages ===== */
.stage-table td { vertical-align: middle; }
.stage-table input:not([type=color]):not([type=checkbox]) { height: 34px; }
.stage-table .pos-in { width: 64px; }
.stage-table .check-row { margin: 0; font-weight: 500; }
.add-stage { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 6px; padding: 12px; background: #f7f8fb; border-radius: 8px; }
.add-stage input[name=new_label] { flex: 1 1 200px; width: auto; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--muted); }
.inline-label select { width: auto; margin: 0; }
