:root {
  --bg: #f5f4ef; --surface: #fff; --ink: #18212f; --muted: #667085; --line: #e3e1d9; --soft: #f0eee7;
  --navy: #13203a; --navy-2: #1d2e52; --accent: #0e8a5f; --accent-ink: #086445; --accent-soft: #e2f4ec;
  --amber: #b97a06; --amber-soft: #fdf1d3; --blue: #2563c9; --blue-soft: #e4edfb; --red: #c0412c; --red-soft: #fbe9e5;
  --radius: 10px; --shadow: 0 1px 2px rgba(24, 33, 47, .05), 0 4px 14px rgba(24, 33, 47, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); display: flex; min-height: 100vh; }
a { color: var(--accent-ink); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
h2 small, h2 .more { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 13px; }
p { margin: 4px 0; } small { color: var(--muted); font-size: 12.5px; }
code, pre { font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--soft); border-radius: 5px; padding: 1px 5px; }
pre { padding: 12px; overflow-x: auto; } code.key { display: block; padding: 8px; margin-top: 6px; word-break: break-all; }
.muted { color: var(--muted); } .center { text-align: center; } .green { color: var(--accent); } .hi { color: var(--red); } .nowrap { white-space: nowrap; }

/* ---- shell ---- */
.side { width: 216px; flex: none; background: var(--navy); color: #c9d2e3; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.logo { font-weight: 700; font-size: 17px; color: #fff; padding: 2px 10px 18px; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.logo:hover { text-decoration: none; } .logo small { color: #7f8db0; font-weight: 500; font-size: 12px; letter-spacing: .08em; }
.mark { color: #f2b824; font-size: 15px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #c9d2e3; padding: 8px 10px; border-radius: 7px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.side nav a:hover { background: var(--navy-2); text-decoration: none; }
.side nav a.on { background: var(--navy-2); color: #fff; box-shadow: inset 3px 0 0 #f2b824; }
.ico { width: 18px; text-align: center; opacity: .8; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.me { display: flex; gap: 10px; align-items: center; min-width: 0; } .me b { color: #fff; display: block; font-weight: 600; } .me small { color: #8a97b8; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.side .link { color: #8a97b8; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; gap: 12px; align-items: center; padding: 12px 28px; border-bottom: 1px solid var(--line); background: rgba(245, 244, 239, .92); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 5; }
.search { flex: 1; max-width: 460px; } .search input { background: var(--surface); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.content { padding: 24px 28px 60px; max-width: 1320px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.who { display: flex; gap: 14px; align-items: center; }

/* ---- controls ---- */
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; } input[disabled] { background: var(--soft); color: var(--muted); }
input.narrow { width: 84px; } textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: 12.5px; color: #3a4557; } label input, label select, label textarea { margin-top: 4px; font-weight: 400; font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 13.5px; } label.check input { margin-top: 3px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-ink); }
.btn.wide { width: 100%; padding: 10px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); cursor: pointer; } .link:hover { text-decoration: underline; } .link.danger { color: var(--red); }
form.inline { display: inline; margin-left: 10px; }
.row { display: flex; gap: 10px; align-items: center; } .row.end { justify-content: flex-end; } .row.start { justify-content: flex-start; } .row > small { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 8px; padding: 3px; gap: 2px; }
.seg label { font-weight: 500; font-size: 13px; cursor: pointer; } .seg input { position: absolute; opacity: 0; }
.seg span, .seg a { display: block; padding: 5px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.seg input:checked + span, .seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); } .seg a:hover { text-decoration: none; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; } .filters input { max-width: 280px; } .filters select { width: auto; }
.hp { position: absolute; left: -9999px; }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; } .scroll-x { overflow-x: auto; }
.card.form { display: flex; flex-direction: column; gap: 14px; max-width: 860px; } .card.form h2 { margin: 0; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; } .fgrid.three { grid-template-columns: repeat(3, 1fr); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: var(--accent-soft); border-color: #b7e2cf; color: #0a5038; } .flash.error { background: var(--red-soft); border-color: #f0c4ba; color: #8c2a1a; } .flash.warn { background: var(--amber-soft); border-color: #f0dc9c; color: #6f4a03; }
.empty { color: var(--muted); padding: 14px 0; text-align: center; list-style: none; } td.empty { padding: 28px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; background: var(--soft); font-size: 12px; font-weight: 500; margin-right: 4px; text-transform: capitalize; white-space: nowrap; }
.st-lead { background: var(--blue-soft); color: #1c4c9c; } .st-qualified { background: var(--amber-soft); color: #7a5104; } .st-customer, .sk-won { background: var(--accent-soft); color: #0a5a3f; } .st-churned, .sk-lost { background: var(--red-soft); color: #8c2a1a; }
.tag.rot { background: var(--red-soft); color: #8c2a1a; text-transform: none; }
.pill { display: block; text-align: center; padding: 5px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; } .pill.amber { background: #f2b824; color: #3b2a00; } .pill.red { background: var(--red); color: #fff; }
.av { width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--blue-soft); color: #1c4c9c; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.side .av { background: #f2b824; color: #3b2a00; } .av.big { width: 56px; height: 56px; font-size: 19px; } .av.tiny { width: 22px; height: 22px; font-size: 10px; vertical-align: middle; }
.score { display: inline-flex; min-width: 36px; justify-content: center; padding: 2px 8px; border-radius: 6px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.score.gA { background: var(--accent); color: #fff; } .score.gB { background: var(--amber-soft); color: #7a5104; } .score.gC { background: var(--blue-soft); color: #1c4c9c; } .score.gD { background: var(--soft); color: var(--muted); }

/* ---- tables & lists ---- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: #faf9f5; white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--soft); vertical-align: middle; } .table tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; } .table tbody tr[data-href]:hover { background: #faf9f5; }
.table td small { display: block; } .table .num { text-align: right; font-variant-numeric: tabular-nums; } .table tr.off { opacity: .5; }
.table.compact td, .table.compact th { padding: 8px 10px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }
.people, .tasks, .timeline, .actions, .why { list-style: none; margin: 0; padding: 0; }
.people li a { display: flex; gap: 10px; align-items: center; padding: 8px 6px; border-radius: 7px; color: inherit; } .people li a:hover { background: var(--soft); text-decoration: none; }
.p-main { flex: 1; min-width: 0; } .p-main b, .p-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tasks li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--soft); } .tasks li:last-child { border: 0; }
.chk { width: 20px; height: 20px; border: 2px solid #b9bfca; border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 12px; line-height: 1; color: #fff; padding: 0; margin-top: 1px; }
.chk:hover { border-color: var(--accent); } .tasks .done .chk { background: var(--accent); border-color: var(--accent); } .tasks .done .t-title { text-decoration: line-through; color: var(--muted); }
.t-body { flex: 1; } .t-title { display: block; } .tasks .overdue small { color: var(--red); }
.taskadd { margin-top: 10px; } .taskadd input[type=date] { width: 150px; flex: none; } .taskadd select { width: auto; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--soft); } .timeline li:last-child { border: 0; }
.dot { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--soft); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.k-call .dot { background: var(--accent-soft); color: var(--accent-ink); } .k-email .dot, .k-form .dot { background: var(--blue-soft); color: var(--blue); } .k-meeting .dot { background: var(--amber-soft); color: var(--amber); }
.tl-head small { margin-left: 6px; } .timeline p { white-space: pre-wrap; color: #3a4557; } .timeline .k-system b { font-weight: 500; color: var(--muted); }
.actions li { display: flex; gap: 12px; padding: 10px 10px; border-left: 3px solid var(--line); margin-bottom: 6px; background: #faf9f5; border-radius: 0 7px 7px 0; }
.actions li.sev-high { border-color: var(--red); } .actions li.sev-med { border-color: #f2b824; } .actions li.empty { border: 0; background: none; }
.actions a { color: inherit; } .actions a:hover { text-decoration: none; } .actions a:hover b { text-decoration: underline; } .actions b, .actions small { display: block; }
.a-ico { font-size: 17px; }

/* ---- dashboard & charts ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi small { text-transform: uppercase; letter-spacing: .05em; font-size: 11px; font-weight: 600; } .kpi b { display: block; font-size: 26px; letter-spacing: -.02em; line-height: 1.25; font-variant-numeric: tabular-nums; } .kpi i { font-style: normal; font-size: 14px; color: var(--muted); font-weight: 500; } .kpi span { color: var(--muted); font-size: 12.5px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bar-track { height: 10px; background: var(--soft); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; min-width: 2px; } .bar-fill.red { background: var(--red); } .bar-fill.blue { background: var(--blue); }
.bar-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 70px; text-align: right; } .bar-val small { font-weight: 400; }
.cols { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; height: 190px; align-items: end; }
.col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.col-val { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; } .col-label { color: var(--muted); font-size: 12px; }
.col-stack { width: 100%; max-width: 54px; background: #cfe9dd; border-radius: 6px 6px 0 0; display: flex; align-items: flex-end; min-height: 3px; } .col-fill { width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; }
.legend { color: var(--muted); font-size: 12.5px; margin-top: 12px; } .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 8px; } .sw.fill { background: var(--accent); margin-left: 0; } .sw.track { background: #cfe9dd; }
.spark { display: flex; gap: 4px; align-items: flex-end; height: 90px; } .spark span { flex: 1; background: var(--blue); border-radius: 3px 3px 0 0; min-height: 2px; }

/* ---- pipeline board ---- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.lane { flex: 1 1 0; min-width: 158px; max-width: 290px; background: #eceae2; border-radius: var(--radius); padding: 10px; border-top: 3px solid #b9bfca; }
.lane.k-won { border-top-color: var(--accent); } .lane.k-lost { border-top-color: var(--red); } .lane.over { background: #dfece6; outline: 2px dashed var(--accent); }
.lane header { padding: 2px 4px 10px; } .lane header small { display: block; } .lane-n { margin-left: 6px; background: var(--surface); border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 600; }
.lane-body { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.deal { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); }
.deal.dragging { opacity: .4; } .deal.rot { border-left: 3px solid var(--red); }
.deal a { font-weight: 600; color: var(--ink); display: block; } .deal small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal footer { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-variant-numeric: tabular-nums; } .deal footer .av { margin-left: auto; } .deal footer .tag { margin: 0; }
.stagebar { display: flex; gap: 3px; margin-bottom: 16px; overflow-x: auto; }
.stagebar button { flex: 1; padding: 9px 12px; border: 0; background: #e6e4dc; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.stagebar button:first-of-type { border-radius: 8px 0 0 8px; } .stagebar button:last-of-type { border-radius: 0 8px 8px 0; }
.stagebar button:hover { background: #d9d6cc; } .stagebar .past { background: #bfe3d2; color: #0a5038; } .stagebar .on { background: var(--accent); color: #fff; } .stagebar .k-lost.on { background: var(--red); }

/* ---- detail pages ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.tabs button, .tabs a { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tabs .on { color: var(--ink); border-color: var(--accent); } .tabs a:hover { text-decoration: none; color: var(--ink); } .tabs.links { margin: 0 0 18px; overflow-x: auto; white-space: nowrap; }
.logform { display: flex; flex-direction: column; gap: 10px; } .logform .row { justify-content: space-between; } .logform select { width: auto; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; margin: 0; } .facts dt { color: var(--muted); } .facts dd { margin: 0; overflow-wrap: anywhere; }
.score-top { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; } .score-top h2 { margin: 0; }
.ring { --c: var(--muted); width: 62px; height: 62px; flex: none; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(closest-side, var(--surface) 76%, transparent 78%), conic-gradient(var(--c) calc(var(--p) * 1%), var(--soft) 0); }
.ring b { font-size: 19px; } .gA .ring { --c: var(--accent); } .gB .ring { --c: #e0a31a; } .gC .ring { --c: var(--blue); }
.why li { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--soft); font-size: 13px; } .why b { color: var(--accent-ink); font-variant-numeric: tabular-nums; } .why b.neg { color: var(--red); }
details summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; } details pre { margin: 8px 0 0; }

/* ---- bare pages (login, public form) ---- */
body.bare { align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, #13203a 0 46%, var(--bg) 46%); }
.bare-card { background: var(--surface); width: 100%; max-width: 420px; padding: 30px; border-radius: 14px; box-shadow: 0 12px 40px rgba(19, 32, 58, .18); display: flex; flex-direction: column; gap: 12px; }
.bare-card .logo { color: var(--navy); padding: 0 0 6px; } .bare-card .logo small { color: var(--muted); } .bare-card .mark { color: #e0a31a; }

@media (max-width: 1000px) { .grid2, .grid3, .detail { grid-template-columns: 1fr; } .fgrid.three { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 8px 10px; gap: 6px; overflow-x: auto; }
  .side .logo { padding: 0 6px; } .side .logo small, .side nav a span:last-child, .side-foot .me, .side-foot .pill { display: none; }
  .side nav { flex-direction: row; } .side nav a { padding: 8px; } .ico { font-size: 17px; width: 22px; } .side-foot { margin: 0 0 0 auto; }
  .top { padding: 10px 16px; } .top-actions .btn:not(.primary) { display: none; } .content { padding: 16px 16px 48px; }
  .fgrid, .fgrid.three { grid-template-columns: 1fr; } .taskadd { flex-wrap: wrap; } .bar-row { grid-template-columns: 84px 1fr auto; }
  .lane { flex: 0 0 78vw; max-width: none; } h1 { font-size: 21px; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .deal, .side nav a { transition: background .12s, box-shadow .12s; } }
.col-side .taskadd { flex-wrap: wrap; } .col-side .taskadd input[name=title] { flex: 1 0 100%; } .col-side .taskadd input[type=date] { flex: 1; }
.deal a { overflow-wrap: anywhere; } .deal footer { flex-wrap: wrap; }
.deal .mover { display: none; margin-top: 8px; padding: 5px 8px; font-size: 13px; }
@media (hover: none), (max-width: 760px) { .deal .mover { display: block; } .deal { cursor: default; } }
[hidden] { display: none !important; }
