:root {
  /* Elevate ProAssist palette: blue #265B9C, light blue #A5C9E9, pink #E56CA0, green #88CB4B, burgundy #761344, navy #0B2349, slate #4D6E83 */
  --bg: #f4f7fb; --surface: #ffffff; --surface-2: #eef3f9; --text: #0B2349; --heading: #0B2349; --muted: #4D6E83; --border: #d5dfea;
  --primary: #265B9C; --primary-hover: #1E4A80; --primary-text: #ffffff; --primary-soft: #A5C9E9; --on-primary-soft: #0B2349; --primary-tint: #e3eef9;
  --accent: #E56CA0; --on-accent: #1b1b1b; --accent-soft: #fdeaf2; --neg: #A02D6A; --on-neg: #ffffff;
  --good: #88CB4B; --on-good: #14320a; --good-soft: #e6f4d6; --good-fg: #2d5410;
  --danger: #761344; --on-danger: #ffffff; --danger-fg: #761344; --danger-soft: #f7e3ec; --danger-edge: transparent;
  --warn: #E56CA0; --warn-soft: #fdeaf2; --warn-fg: #7a1f4d;
  --bad: var(--danger); --bad-soft: var(--danger-soft);
  --stage-lead: #4D6E83; --stage-qualified: #A5C9E9; --stage-discovery: #265B9C; --stage-proposal: #E56CA0; --stage-negotiation: #A02D6A; --stage-won: #88CB4B; --stage-lost: #761344;
  --focus: #265B9C; --shadow: 0 1px 2px rgba(11,35,73,.06), 0 4px 14px rgba(11,35,73,.05);
  --radius: 10px; --sidebar-w: 232px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1626; --surface: #14213a; --surface-2: #1b2c4a; --text: #e8eef7; --heading: #e8eef7; --muted: #9db3c6; --border: #2c4062;
    --primary: #A5C9E9; --primary-hover: #c4dcf1; --primary-text: #0B2349; --primary-soft: #1c3556; --on-primary-soft: #A5C9E9; --primary-tint: #172a45;
    --accent: #E56CA0; --on-accent: #1b1b1b; --accent-soft: #3a1a2c; --neg: #A02D6A; --on-neg: #ffffff;
    --good: #88CB4B; --on-good: #14320a; --good-soft: #1f3412; --good-fg: #a9de7b;
    --danger: #761344; --on-danger: #ffffff; --danger-fg: #F08DB3; --danger-soft: #3d1a2c; --danger-edge: #F08DB3;
    --warn: #E56CA0; --warn-soft: #3a1a2c; --warn-fg: #F4A3C4;
    --stage-lead: #9db3c6; --stage-qualified: #A5C9E9; --stage-discovery: #5d93d0; --stage-proposal: #E56CA0; --stage-negotiation: #cf5a96; --stage-won: #88CB4B; --stage-lost: #c0407a;
    --focus: #A5C9E9; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; color: var(--heading); }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--primary); }
.muted { color: var(--muted); } .small { font-size: .82rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 1rem .75rem; }
.brand { display: block; width: fit-content; max-width: 100%; margin: 0 0 1rem; padding: 8px 12px; border-radius: 10px; }
.brand img { display: block; width: 180px; max-width: 100%; height: auto; }
@media (prefers-color-scheme: dark) { .brand { background: #fff; } }
.sidebar nav a { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 8px; color: var(--heading); text-decoration: none; margin-bottom: 2px; }
.sidebar nav a:hover { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar nav a.active { background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
.sidebar nav .ico { width: 1.2rem; text-align: center; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; gap: .75rem; align-items: center; padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.menu-btn { display: none; }
.topbar-logo { display: none; }
@media (prefers-color-scheme: dark) { .topbar-logo img { background: #fff; border-radius: 8px; padding: 3px 6px; box-sizing: content-box; } }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; }
.search-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 70vh; overflow: auto; z-index: 30; }
.search-results h4 { margin: 0; padding: .5rem .75rem .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.search-results a { display: block; padding: .4rem .75rem; color: var(--text); text-decoration: none; }
.search-results a:hover { background: var(--surface-2); }
.view { padding: 1.25rem; flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; outline: none; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.grid { display: grid; gap: 1rem; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(min(165px,100%),1fr)); margin-bottom: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(320px,100%),1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(260px,100%),1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); min-width: 0; }
.card > h2, .card > h3 { margin-bottom: .75rem; }
.card.kpi { border-top: 3px solid var(--primary); }
.kpi .label { color: var(--muted); font-size: .8rem; }
.kpi .value { font-size: 1.5rem; font-weight: 700; margin-top: .15rem; }
.kpi .sub { color: var(--muted); font-size: .78rem; }
.btn, button { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .45rem .85rem; border-radius: 8px; }
.btn:hover, button:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger-fg); border-color: var(--danger-fg); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: .2rem .55rem; font-size: .82rem; }
.icon-btn { padding: .35rem .6rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; width: 100%; max-width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input[type=checkbox] { width: auto; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .75rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px,100%),1fr)); gap: 0 .9rem; }
.form-grid .full { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: .35rem .9rem; max-height: 150px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: .5rem; }
.checks label { display: flex; align-items: center; gap: .35rem; margin: 0; color: var(--text); font-size: .85rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }
.badge { display: inline-block; padding: .08rem .55rem; border-radius: 999px; font-size: .75rem; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.good { background: var(--good); color: var(--on-good); border-color: transparent; }
.badge.warn { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.badge.neg { background: var(--neg); color: var(--on-neg); border-color: transparent; }
.badge.bad { background: var(--danger); color: var(--on-danger); border-color: var(--danger-edge); }
.badge.info { background: var(--primary-soft); color: var(--on-primary-soft); border-color: transparent; }
.badge.solid { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 0; }
.bars { display: flex; gap: .5rem; align-items: flex-end; height: 190px; padding-top: .5rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 54px; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar.won { background: var(--good); } .bar.lost { background: var(--stage-lost); }
.bar-val { font-size: .7rem; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.bar-lbl { font-size: .68rem; color: var(--muted); text-align: center; margin-top: .3rem; line-height: 1.15; min-height: 2.3em; }
.tabs { display: flex; gap: .25rem; }
.seg button { border-radius: 0; margin: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; } .seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .75rem; align-items: flex-start; }
.col { flex: 0 0 255px; background: var(--surface-2); border: 1px solid var(--border); border-top: 4px solid var(--primary); border-radius: var(--radius); padding: .6rem; min-height: 200px; }
.col[data-stage="Lead"] { border-top-color: var(--stage-lead); } .col[data-stage="Qualified"] { border-top-color: var(--stage-qualified); }
.col[data-stage="Discovery Call"] { border-top-color: var(--stage-discovery); } .col[data-stage="Proposal Sent"] { border-top-color: var(--stage-proposal); }
.col[data-stage="Negotiation"] { border-top-color: var(--stage-negotiation); } .col[data-stage="Won"] { border-top-color: var(--stage-won); } .col[data-stage="Lost"] { border-top-color: var(--stage-lost); }
.col.over { outline: 2px dashed var(--primary); background: var(--primary-tint); }
.col-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; font-weight: 600; }
.col-head .sum { font-size: .75rem; color: var(--muted); font-weight: 400; }
.deal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; margin-bottom: .5rem; cursor: grab; box-shadow: var(--shadow); }
.deal-card.dragging { opacity: .4; }
.deal-card .t { font-weight: 600; font-size: .9rem; }
.modal-back { position: fixed; inset: 0; background: rgba(5,10,25,.55); display: flex; align-items: flex-start; justify-content: center; padding: 3vh .75rem; z-index: 100; overflow: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 720px; padding: 1.1rem 1.25rem; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal.wide { max-width: 900px; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; }
.toast { background: var(--text); color: var(--bg); padding: .6rem .9rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 340px; }
.toast.err { background: var(--danger); color: var(--on-danger); }
.callout { border-left: 4px solid var(--primary); background: var(--primary-tint); padding: .6rem .8rem; border-radius: 6px; margin-bottom: .75rem; font-size: .88rem; }
.callout.warn { border-color: var(--danger-fg); background: var(--danger-soft); }
.internal { border: 2px dashed var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: .8rem; margin-top: 1rem; }
.internal .tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--warn-fg); letter-spacing: .05em; }
.sum-row { display: flex; justify-content: space-between; padding: .3rem 0; gap: 1rem; }
.sum-row.total { font-weight: 700; border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .5rem; }
.qb { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.qb > * { min-width: 0; }
.qb .sticky { position: sticky; top: 70px; }
.line { border: 1px solid var(--border); border-radius: 8px; padding: .7rem; margin-bottom: .6rem; background: var(--surface-2); }
.line-head { display: flex; justify-content: space-between; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.line-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(120px,100%),1fr)); gap: .5rem; }
.presets { display: flex; gap: .25rem; margin-top: .25rem; flex-wrap: wrap; }
.warnline { color: var(--warn-fg); font-size: .8rem; margin-top: .25rem; }
.suggest { border: 1px solid var(--border); border-radius: 8px; padding: .5rem; margin-bottom: .75rem; background: var(--surface-2); }
.suggest .item { display: flex; justify-content: space-between; gap: .5rem; padding: .35rem .4rem; border-radius: 6px; cursor: pointer; align-items: center; }
.suggest .item:hover { background: var(--primary-tint); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 70px; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: var(--primary); }
.progress.hot > i { background: var(--accent); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; overflow-wrap: anywhere; }
/* Auth */
.login { display: none; flex: 1; align-items: center; justify-content: center; padding: 1.25rem; }
body.auth-mode .login { display: flex; }
body.auth-mode .sidebar, body.auth-mode .topbar, body.auth-mode .view, body.auth-mode .scrim { display: none; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { margin: 0 auto 1rem; }
.login-card .brand img { width: 200px; }
.login-card .btn { width: 100%; margin-top: .25rem; }
.user-box { margin-top: 1rem; padding: .75rem .5rem 0; border-top: 1px solid var(--border); font-size: .85rem; }
.user-box .uname { font-weight: 600; overflow-wrap: anywhere; }
.user-box .actions { margin-top: .5rem; }
/* Footer */
.cl-footer{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(280px,100%),1fr));gap:1.5rem 2.5rem;margin-top:3rem;padding:1.5rem 1.25rem;border-top:1px solid rgba(127,127,127,.3);font-size:.8rem;line-height:1.5;opacity:.8}
.cl-footer p{margin:0 0 .5rem}
.cl-footer__title{font-weight:600}
.cl-footer a{color:inherit;text-decoration:underline}
/* Proposal */
.proposal-bar { display: flex; gap: .5rem; justify-content: center; margin-bottom: 1rem; }
.proposal { --pp: #265B9C; --pn: #0B2349; --ps: #4D6E83; background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 2.2rem 2.4rem; border: 1px solid #ccd; border-radius: 6px; font-size: 14px; }
.proposal h1 { font-size: 1.7rem; margin: 0; color: var(--pn); } .proposal h2 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; border-bottom: 2px solid var(--pp); padding-bottom: .2rem; color: var(--pn); }
.proposal h3 { color: var(--pn); font-size: .95rem; margin: .9rem 0 .25rem; }
.proposal .ph { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 3px solid var(--pp); padding-bottom: .8rem; margin-bottom: 1rem; }
.proposal table { width: 100%; margin: .5rem 0; } .proposal th { background: #e8f1fa; color: var(--pn); } .proposal th, .proposal td { border: 1px solid #d3d9e8; }
.proposal ul { margin: .25rem 0 .5rem; padding-left: 1.2rem; columns: 2; column-gap: 2rem; } .proposal li { break-inside: avoid; margin-bottom: .1rem; }
.proposal .tot td { font-weight: 700; background: #eef3f9; }
.proposal .muted { color: var(--ps); }
.proposal .plogo { display: block; width: 180px; max-width: 100%; height: auto; margin: 0 0 .6rem; }
body.proposal-mode .sidebar, body.proposal-mode .topbar { display: none; }
body.proposal-mode .view { max-width: none; }
@media (max-width: 900px) {
  .qb { grid-template-columns: minmax(0, 1fr); } .qb .sticky { position: static; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
  body.nav-open .scrim { display: block; }
  .menu-btn { display: inline-block; flex: 0 0 auto; }
  .topbar { gap: .5rem; }
  .topbar-logo { display: flex; align-items: center; flex: 0 0 auto; }
  .topbar-logo img { display: block; height: 40px; width: auto; }
  .search { min-width: 0; flex: 1 1 auto; }
  .search input { min-width: 0; }
  .brand img { width: 130px; }
  .view { padding: .85rem; }
  .proposal { padding: 1.1rem; } .proposal ul { columns: 1; }
  .toolbar input, .toolbar select { flex: 1 1 140px; }
}
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .sidebar, .topbar, .scrim, .proposal-bar, .cl-footer, .toasts { display: none !important; }
  .app, .main { display: block; min-height: 0; }
  .view { padding: 0; max-width: none; }
  .proposal { border: none; padding: 0; max-width: none; border-radius: 0; }
  .proposal h2 { break-after: avoid; } .proposal table, .proposal .sect { break-inside: avoid; }
}
.deal-card .mv { display: none; margin-top: .4rem; font-size: .8rem; padding: .2rem .3rem; }
@media (hover: none) { .deal-card .mv { display: block; } }
