:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #eaeef4; --border: #dbe1e9; --border-strong: #c3ccd8;
  --ink: #1a2230; --ink-muted: #5d6982; --ink-faint: #7e889d;
  --accent: #2a5fad; --accent-ink: #ffffff; --accent-bg: #e4edfb;
  --success: #227a52; --success-bg: #e2f3ea; --warning: #8f5c0e; --warning-bg: #faf0dc;
  --danger: #b23a26; --danger-bg: #fbe9e5; --purple: #6a46b0; --purple-bg: #efe9fa;
  --shadow: 0 1px 2px rgba(20,30,50,.06), 0 8px 24px -12px rgba(20,30,50,.12);
  --radius: 10px;
  --font-display: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --surface: #171c25; --surface-2: #1e2530; --border: #2b3341; --border-strong: #3a4453;
    --ink: #e8ecf3; --ink-muted: #9aa5ba; --ink-faint: #7a849b;
    --accent: #7fa8ec; --accent-ink: #0b1220; --accent-bg: #1c2b46;
    --success: #5cc794; --success-bg: #163526; --warning: #e0ab52; --warning-bg: #3a2c12;
    --danger: #ee8877; --danger-bg: #3a1e18; --purple: #b79cf0; --purple-bg: #2a2140;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--ink); font-family: var(--font-display); margin: 0; padding: 0; font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
.boot { padding: 60px; text-align: center; color: var(--ink-muted); }

/* shell */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1560px; margin: 0 auto; padding: 0 clamp(14px, 3vw, 32px); display: flex; align-items: center; gap: 18px; height: 56px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1rem; white-space: nowrap; text-decoration: none; color: var(--ink); }
.brand i { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-style: normal; font-size: .8rem; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { text-decoration: none; color: var(--ink-muted); font-weight: 600; font-size: .86rem; padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-bg); color: var(--accent); }
.who { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--ink-muted); white-space: nowrap; }
.who .role { font-family: var(--font-mono); font-size: .7rem; background: var(--surface-2); border-radius: 6px; padding: 2px 6px; }
main { max-width: 1560px; margin: 0 auto; padding: 22px clamp(14px, 3vw, 32px) 70px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head h1 { font-size: 1.4rem; margin: 0; letter-spacing: -.01em; }
.page-head p { margin: 3px 0 0; color: var(--ink-muted); font-size: .88rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0; font-size: 1.25rem; }
.login p { margin: 0; color: var(--ink-muted); font-size: .86rem; }
.msg { font-size: .84rem; border-radius: 8px; padding: 9px 11px; }
.msg.err { background: var(--danger-bg); color: var(--danger); }
.msg.info { background: var(--accent-bg); color: var(--ink); }

/* panels & forms */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.panel h2 { font-size: 1rem; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.panel h3, .h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted); font-weight: 700; margin: 0 0 10px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.fields.two { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .lbl { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); }
.hint { font-size: .74rem; color: var(--ink-faint); }
.input { font: inherit; font-size: .86rem; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; width: 100%; min-width: 0; }
.input:hover:not(:disabled) { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); background: var(--accent-bg); }
.input:disabled, .cell:disabled { opacity: .75; cursor: default; }
.input.num, .cell.num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.input.bad { border-color: var(--danger); background: var(--danger-bg); }
textarea.input { resize: vertical; min-height: 60px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: fit-content; }
.seg button { border: none; background: var(--surface); color: var(--ink-muted); font-size: .8rem; font-weight: 600; padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.seg button:disabled { cursor: default; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; cursor: pointer; }

.chip { border: 1px solid var(--border); background: var(--surface); color: var(--ink-muted); border-radius: 999px; padding: 6px 13px; font-size: .8rem; font-weight: 500; cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px; padding: 9px 16px; font-size: .86rem; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { filter: brightness(1.06); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); }
.btn.ghost { background: transparent; color: var(--ink-muted); }
.btn.warn { background: var(--warning); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ok { background: var(--success); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.sm { padding: 6px 11px; font-size: .78rem; }
.btn.block { width: 100%; }
.search { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 11px; min-width: 220px; }
.search input { border: none; outline: none; background: transparent; font-size: .86rem; width: 100%; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
thead th { background: var(--surface-2); text-align: left; font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted); font-weight: 600; padding: 9px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .84rem; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
tr.auto-row td { background: var(--surface-2); color: var(--ink-muted); }
tr.leg-head td { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--ink-faint); padding-top: 12px; }
tr.off td { opacity: .5; }
#lineTable td, #lineTable th { padding-left: 5px; padding-right: 5px; }
.cell { border: 1px solid transparent; background: transparent; font: inherit; font-size: .84rem; width: 100%; padding: 4px 5px; border-radius: 5px; min-width: 0; color: var(--ink); }
.cell:hover:not(:disabled) { border-color: var(--border-strong); }
.cell:focus { outline: none; border-color: var(--accent); background: var(--accent-bg); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.small { font-size: .76rem; }
.x { border: none; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 1rem; padding: 3px 7px; border-radius: 6px; }
.x:hover { background: var(--danger-bg); color: var(--danger); }
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; color: var(--ink-muted); cursor: pointer; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warning-bg); color: var(--warning); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--accent-bg); color: var(--accent); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }
.badge.neutral { background: var(--surface-2); color: var(--ink-muted); }
.st-request { background: var(--surface-2); color: var(--ink-muted); }
.st-pricing { background: var(--accent-bg); color: var(--accent); }
.st-approval { background: var(--purple-bg); color: var(--purple); }
.st-sent { background: var(--warning-bg); color: var(--warning); }
.st-won { background: var(--success-bg); color: var(--success); }
.st-lost, .st-expired { background: var(--danger-bg); color: var(--danger); }

/* pipeline */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow); }
.stat-card .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted); font-weight: 600; }
.stat-card .value { font-family: var(--font-mono); font-size: 1.45rem; font-weight: 600; margin-top: 4px; }
.stat-card .hint { margin-top: 2px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.board { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: start; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.col-head { display: flex; justify-content: space-between; align-items: center; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-muted); padding: 2px 4px 4px; }
.qcard { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; color: var(--ink); text-decoration: none; }
.qcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.qcard .top { display: flex; justify-content: space-between; gap: 6px; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-faint); }
.qcard .cust { font-weight: 600; font-size: .86rem; }
.qcard .lane { font-size: .78rem; color: var(--ink-muted); }
.qcard .bot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: .8rem; margin-top: 2px; }
.empty { font-size: .78rem; color: var(--ink-faint); padding: 6px; }

/* desk */
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 1240px) { .grid-main { grid-template-columns: 1fr; } }
.stack-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sticky { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 1240px) { .sticky { position: static; } }
.deskbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.deskbar .title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.deskbar h1 { font-size: 1.3rem; margin: 0; font-family: var(--font-mono); font-weight: 600; }
.dirty { font-size: .76rem; color: var(--warning); font-weight: 600; }
.sum-row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: .86rem; color: var(--ink-muted); }
.sum-row .mono { color: var(--ink); font-weight: 500; }
.sum-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.sum-row.total .mono { font-size: 1.3rem; font-weight: 600; color: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.kpi { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.kpi .lbl { display: block; }
.kpi .v { font-family: var(--font-mono); font-size: 1.02rem; font-weight: 600; margin-top: 2px; }
.v.pos { color: var(--success); } .v.neg { color: var(--danger); } .v.mid { color: var(--warning); }
.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin: 10px 0 6px; }
.bar span { display: block; height: 100%; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .72rem; color: var(--ink-muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.checks li { display: flex; gap: 8px; align-items: flex-start; font-size: .8rem; line-height: 1.4; padding: 7px 9px; border-radius: 8px; }
.checks li .ic { flex: none; font-family: var(--font-mono); font-weight: 700; width: 14px; text-align: center; }
.checks li.ok { background: var(--success-bg); color: var(--success); }
.checks li.warn { background: var(--warning-bg); color: var(--warning); }
.checks li.approve { background: var(--purple-bg); color: var(--purple); }
.checks li.block { background: var(--danger-bg); color: var(--danger); }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); max-height: 360px; overflow: auto; }
.timeline li { position: relative; padding: 0 0 12px 14px; font-size: .8rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline .when { font-family: var(--font-mono); font-size: .7rem; color: var(--ink-faint); }
.linkbox { display: flex; gap: 6px; align-items: center; background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.linkbox input { flex: 1; border: none; background: transparent; font-family: var(--font-mono); font-size: .74rem; min-width: 0; }
.banner { border-radius: var(--radius); padding: 11px 14px; font-size: .86rem; border: 1px solid var(--border); background: var(--surface); }
.banner.approval { background: var(--purple-bg); color: var(--purple); border-color: transparent; }
.banner.sent { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.banner.won { background: var(--success-bg); color: var(--success); border-color: transparent; }
.banner.lost, .banner.expired { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

/* auto-quote */
.opt-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.opt { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.opt .kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--accent); }
.opt .price { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 600; }
.opt dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: .8rem; }
.opt dt { color: var(--ink-faint); } .opt dd { margin: 0; text-align: right; }

/* overlay */
.overlay { position: fixed; inset: 0; background: rgba(10,14,22,.55); z-index: 100; display: flex; padding: 16px; }
.modal { margin: auto; width: min(720px, 100%); max-height: calc(100vh - 32px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.modal.wide { width: min(900px, 100%); }
.ov-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.ov-body { padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.ov-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.doc { border: 1px solid var(--border-strong); border-radius: 8px; padding: 22px; background: var(--surface); }
.doc-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 3px solid var(--ink); padding-bottom: 10px; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.doc-head h3 { margin: 0; font-size: 1.15rem; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 5px 12px; font-size: .86rem; margin: 0; }
.kv dt { color: var(--ink-faint); } .kv dd { margin: 0; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-family: var(--font-mono); font-size: .74rem; overflow-x: auto; margin: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(12px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-size: .84rem; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 200; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); color: #fff; }
@media (max-width: 700px) { .who .nm { display: none; } .fields.two { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } }
