/* Ecora CRM: black and white, phone-first, plain CSS.
   Colour only where it carries meaning: red for overdue and errors. */
:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --side: #fbfbfa;
  --ink: #0b0b0b;
  --ink-2: #2f2f2f;
  --muted: #737373;
  --faint: #a3a3a3;
  --line: #ebebe8;
  --line-2: #dcdcd8;
  --soft: #f2f2ef;
  --hover: #f5f5f3;
  --black: #0b0b0b;
  --white: #ffffff;
  --bad: #c42b1c;
  --bad-bg: #fdf1ef;
  --bad-line: #f2cdc7;
  --warn-bg: #fbf7ea;
  --warn-line: #ece2c2;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(16,16,16,.04), 0 1px 1px rgba(16,16,16,.02);
  --shadow-lg: 0 12px 32px rgba(16,16,16,.12);
  --side-w: 248px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.btn:hover, .side a:hover, .tabbar a:hover, .kcard:hover, .lead-list a:hover, .stat:hover, .chip:hover, .seg a:hover, .fu-main:hover, .cell-co:hover { text-decoration: none; }
h1 { font-size: 1.55rem; line-height: 1.2; letter-spacing: -.025em; margin: 0; font-weight: 700; }
h2 { font-size: .95rem; margin: 0 0 .85rem; font-weight: 650; letter-spacing: -.01em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
code { font: .78em ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); background: var(--soft); padding: .05rem .3rem; border-radius: 4px; }
details summary { cursor: pointer; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sub { margin: 0; }
.text-bad { color: var(--bad); }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; }

/* ---------- logo and avatars ---------- */
.logo-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--black); color: var(--white); font-weight: 800; font-size: 1.05rem; letter-spacing: -.03em; flex: none; }
.logo-mark.sm { width: 26px; height: 26px; border-radius: 7px; font-size: .85rem; }
.av { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--black); color: var(--white); font-size: .72rem; font-weight: 700; letter-spacing: .02em; flex: none; }
.av.xs { width: 22px; height: 22px; font-size: .58rem; }
.av.sm { width: 28px; height: 28px; font-size: .65rem; }
.av.co { border-radius: 9px; background: var(--soft); color: var(--ink-2); border: 1px solid var(--line-2); width: 38px; height: 38px; font-size: .8rem; }
.av.co.sm { width: 30px; height: 30px; border-radius: 8px; font-size: .68rem; }
.av.co.lg { width: 52px; height: 52px; border-radius: 12px; font-size: 1.05rem; background: var(--black); color: var(--white); border-color: var(--black); }
.cell-co { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink); }

/* ---------- app shell ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1rem .75rem .75rem; z-index: 30; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: .65rem; padding: .25rem .4rem .9rem; color: var(--ink); }
.side-brand b { display: block; font-size: .95rem; letter-spacing: -.01em; line-height: 1.2; }
.side-brand small { display: block; font-size: .75rem; color: var(--muted); }
.side-search { position: relative; margin-bottom: .55rem; }
.side-search .ic { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; }
.side-search input { min-height: 38px; padding: .45rem .7rem .45rem 2.1rem; font-size: .88rem; background: var(--white); border-radius: var(--r-sm); }
.side-new { width: 100%; min-height: 38px; margin-bottom: 1rem; font-size: .88rem; }
.side-nav { display: grid; gap: 1px; }
.side-nav a { display: flex; align-items: center; gap: .7rem; padding: .5rem .65rem; border-radius: var(--r-sm); color: var(--ink-2); font-size: .9rem; font-weight: 520; }
.side-nav a .ic { color: var(--muted); }
.side-nav a:hover { background: var(--hover); }
.side-nav a.on { background: var(--black); color: var(--white); }
.side-nav a.on .ic { color: var(--white); }
.side-sep { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 650; padding: 1.1rem .65rem .35rem; }
.side-user { margin-top: auto; display: flex; align-items: center; gap: .3rem; border-top: 1px solid var(--line); padding-top: .75rem; }
.side-user form { margin: 0; }
.side-me { flex: 1; display: flex; align-items: center; gap: .6rem; padding: .35rem .4rem; border-radius: var(--r-sm); min-width: 0; color: var(--ink); }
.side-me:hover, .side-me.on { background: var(--hover); }
.side-me span { min-width: 0; }
.side-me b { display: block; font-size: .86rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-me small { display: block; font-size: .74rem; color: var(--muted); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid transparent; background: none; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--hover); border-color: var(--line); }
.icon-btn.solid { background: var(--black); color: var(--white); }
.main { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }
.mtop { display: none; }
.tabbar { display: none; }
.scrim { display: none; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.6rem 2rem 1rem; flex: 1; }
.foot { text-align: center; color: var(--faint); font-size: .72rem; padding: 1.5rem 1rem 2rem; }

@media (max-width: 999px) {
  .side { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); width: 280px; padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
  body.menu-open .side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 25; }
  .main { margin-left: 0; }
  .mtop { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem .8rem .55rem 1rem; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
  .mtop-brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: .95rem; letter-spacing: -.01em; color: var(--ink); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mtop-actions { display: flex; gap: .35rem; }
  .wrap { padding: 1.1rem 1rem 1rem; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: .1rem; padding: .3rem 0; color: var(--faint); font: inherit; font-size: .66rem; font-weight: 600; background: none; border: 0; cursor: pointer; }
  .tabbar .ic { width: 21px; height: 21px; }
  .tabbar a.on { color: var(--ink); }
  .foot { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
}

/* ---------- auth (login / setup) ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; background: var(--bg); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; justify-content: center; }
.auth-brand .logo-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 1.3rem; }
.auth-co { font-weight: 750; font-size: 1.15rem; letter-spacing: -.02em; }
.auth-tag { color: var(--muted); font-size: .85rem; }
.auth .card { padding: 1.75rem; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04); max-width: none; }
.auth .card h1 { font-size: 1.3rem; margin-bottom: .3rem; }
.auth .card > .muted:first-of-type { margin-top: 0; }
.auth .btn { width: 100%; }
.auth-foot { text-align: center; color: var(--faint); font-size: .72rem; margin-top: 1.25rem; }

/* ---------- page title ---------- */
.ph { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.ph-sub { color: var(--muted); margin-top: .25rem; font-size: .92rem; }
.ph-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.wrap > h1 { margin-bottom: 1rem; }
.wrap > h1 + .muted { margin-top: -.6rem; }
.crumbs { margin: 0 0 .35rem; font-size: .82rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card .head-row { margin-bottom: .6rem; }
.head-row form, .head-row h2, .head-row h1 { margin: 0; }
.count { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.25rem; padding: 0 .35rem; border-radius: 99px; background: var(--soft); color: var(--ink-2); font-size: .72rem; font-weight: 650; margin-left: .3rem; vertical-align: 1px; }

/* ---------- cards and grids ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1.15rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 520px; }
.card.empty { text-align: center; padding: 2.5rem 1rem; }
.card.empty h2 { margin-bottom: .35rem; }
.narrow { margin-left: auto; margin-right: auto; }
.grid2 { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid2 > .card { margin-bottom: 0; }
@media (min-width: 860px) { .grid2 { grid-template-columns: 1fr 1fr; align-items: start; } .span2 { grid-column: 1 / -1; } }

/* ---------- flash ---------- */
.flash { display: flex; align-items: center; gap: .55rem; padding: .7rem .95rem; border-radius: 10px; margin-bottom: 1rem; background: var(--black); color: var(--white); font-size: .92rem; box-shadow: var(--shadow); }
.flash .ic { width: 16px; height: 16px; }
.flash-error { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-line); box-shadow: none; }
.flash-warn { display: block; background: var(--warn-bg); color: var(--ink); border: 1px solid var(--warn-line); box-shadow: none; }
.flash-warn ul { margin: .4rem 0; padding-left: 1.2rem; }

/* ---------- forms ---------- */
.form { display: grid; gap: 1rem; }
.form label, .fields label { display: grid; gap: .35rem; font-weight: 600; font-size: .85rem; color: var(--ink-2); }
.form label .muted { font-weight: 400; }
.fields { display: grid; gap: 1rem; }
@media (min-width: 640px) { .fields { grid-template-columns: 1fr 1fr; } .fields .wide { grid-column: 1 / -1; } }
.lead-form .card { margin-bottom: 0; }
input, select, textarea { width: 100%; font: inherit; font-size: .95rem; font-weight: 400; padding: .6rem .8rem; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--white); color: var(--ink); min-height: 44px; transition: border-color .12s, box-shadow .12s; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .6rem center; background-size: 16px; padding-right: 2rem; }
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #c8c8c3; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--black); box-shadow: 0 0 0 3px rgba(11,11,11,.08); }
input:disabled { background: var(--soft); color: var(--muted); }
label.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; font-size: .92rem; color: var(--ink); }
label.check input { width: auto; min-height: 0; margin-top: .3rem; accent-color: var(--black); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .85rem 1rem; margin: 0; display: grid; gap: .6rem; }
legend { font-weight: 650; padding: 0 .3rem; font-size: .88rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.money-in { display: flex; gap: .4rem; }
.money-in select { width: 6.2rem; flex: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; background: var(--black); color: var(--white); border: 1px solid var(--black); border-radius: var(--r-sm); padding: .55rem 1rem; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; min-height: 40px; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn .ic { width: 16px; height: 16px; }
.btn:hover { background: #262626; }
.btn:active { transform: translateY(1px); }
.btn-light { background: var(--white); color: var(--ink); border-color: var(--line-2); box-shadow: var(--shadow); }
.btn-light:hover { background: var(--hover); border-color: #c8c8c3; }
.btn-danger { background: var(--white); color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-small { padding: .3rem .7rem; min-height: 32px; font-size: .82rem; border-radius: 7px; }
.btn-icon { display: inline-grid; place-items: center; background: var(--white); border: 1px solid var(--line-2); border-radius: 7px; width: 34px; height: 34px; font: inherit; cursor: pointer; flex: none; color: var(--ink-2); }
.btn-icon:hover { background: var(--hover); }
.btn-icon:disabled { opacity: .3; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--faint); font: inherit; font-size: .78rem; cursor: pointer; }
.link-btn:hover { color: var(--bad); }
.danger-zone { margin: 1rem 0; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ---------- filters and tabs ---------- */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters select, .filters input { width: auto; flex: 1 1 150px; min-height: 38px; font-size: .88rem; padding-top: .4rem; padding-bottom: .4rem; }
.filters input[type=search] { flex: 3 1 240px; }
.filters .btn { min-height: 38px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; margin-bottom: 1rem; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg a { padding: .35rem .85rem; border-radius: 7px; color: var(--muted); font-size: .86rem; font-weight: 600; white-space: nowrap; }
.seg a:hover { color: var(--ink); }
.seg a.on { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.03); }

/* ---------- badges and dates ---------- */
.badge { display: inline-flex; align-items: center; font-size: .7rem; font-weight: 650; padding: .14rem .5rem; border-radius: 6px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--white); vertical-align: middle; white-space: nowrap; line-height: 1.3; }
.badge-won, .badge-q-accepted { background: var(--black); color: var(--white); border-color: var(--black); }
.badge-lost, .badge-q-rejected { color: var(--faint); background: var(--soft); border-color: var(--soft); }
.badge-q-sent { border-color: var(--black); }
.badge-q-draft { border-style: dashed; color: var(--muted); }
.tag { display: inline-block; font-size: .7rem; padding: .05rem .45rem; border-radius: 6px; background: var(--soft); color: var(--muted); font-weight: 600; }
.tag-bad { background: var(--bad-bg); color: var(--bad); }
.due { display: inline-flex; align-items: center; font-size: .76rem; font-weight: 650; white-space: nowrap; color: var(--ink-2); }
.due-overdue { color: var(--bad); }
.due-overdue::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--bad); margin-right: .35rem; }
.due-today { color: var(--white); background: var(--black); padding: .08rem .5rem; border-radius: 6px; }
.due- { color: var(--faint); font-weight: 500; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.table td { padding: .75rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: #fcfcfb; }
.table tr:last-child td { border-bottom: 0; }
.table tr.off td { color: var(--muted); }
.r { text-align: right; }
@media (max-width: 640px) {
  .table thead { display: none; }
  .table tr { display: block; padding: .7rem 0; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: flex; gap: .75rem; border: 0; padding: .15rem 0; text-align: left; }
  .table tbody tr:hover td { background: none; }
  .table td[data-label]::before { content: attr(data-label); flex: 0 0 6.5rem; color: var(--muted); font-size: .82rem; }
}

/* ---------- settings lists ---------- */
.list-edit { list-style: none; margin: 0; padding: 0; }
.list-edit li { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list-edit li:last-child { border-bottom: 0; }
.list-edit li.off input[name=label] { color: var(--faint); text-decoration: line-through; }
.row-form { display: flex; gap: .5rem; flex: 1 1 320px; margin: 0; }
.row-form input { flex: 1; }
.row-form select { width: auto; }
.row-actions { display: flex; gap: .35rem; align-items: center; margin: 0; flex-wrap: wrap; }
.links, .plain { list-style: none; padding: 0; margin: 0; }
.links li { display: flex; justify-content: space-between; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.links li:last-child { border-bottom: 0; }
.links a { font-weight: 600; }
.plain li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.plain li:last-child { border-bottom: 0; }

/* ---------- home ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: .95rem 1.1rem; color: var(--ink); box-shadow: var(--shadow); transition: border-color .12s; }
.stat:hover { border-color: var(--line-2); }
.stat span { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat b { display: block; font-size: 2rem; letter-spacing: -.04em; line-height: 1.15; margin-top: .15rem; font-weight: 700; }
.stat-bad b { color: var(--bad); }
.stat-dark { background: var(--black); border-color: var(--black); color: var(--white); }
.stat-dark span { color: rgba(255,255,255,.6); }
.fu-list { list-style: none; margin: 0; padding: 0; }
.fu-item { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.fu-item:last-child { border-bottom: 0; }
.fu-main { flex: 1; display: grid; color: var(--ink); min-width: 0; }
.fu-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.fu-main .small { color: var(--ink-2); }
.fu-side { display: grid; justify-items: end; gap: .35rem; }
.fu-links { display: flex; gap: .3rem; }
.fu-links a { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink-2); }
.fu-links a:hover { background: var(--black); color: var(--white); border-color: var(--black); }
.fu-links .ic { width: 15px; height: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { border: 1px solid var(--line-2); border-radius: 8px; padding: .35rem .75rem; font-size: .86rem; background: var(--white); color: var(--ink-2); }
.chip:hover { border-color: var(--black); }
.chip b { margin-left: .3rem; color: var(--ink); }

/* ---------- leads list ---------- */
.lead-list { list-style: none; margin: 0; padding: 0; }
.lead-list li { border-bottom: 1px solid var(--line); }
.lead-list li:last-child { border-bottom: 0; }
.lead-list a { display: flex; gap: .85rem; align-items: center; padding: .85rem 1.15rem; color: var(--ink); }
.lead-list a:hover { background: #fcfcfb; }
.ll-body { flex: 1; min-width: 0; display: grid; gap: .12rem; }
.ll-top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.ll-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.ll-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-bottom { display: flex; gap: .85rem; align-items: center; flex-wrap: wrap; }
.ll-bottom > span:first-child { font-weight: 650; }
.ll-bottom .due { margin-left: auto; }
.ll-owner { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }

/* ---------- lead page ---------- */
.lead-head { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.lh-text { flex: 1; min-width: 0; }
.lh-text h1 { margin-bottom: .2rem; }
.lead-head .sub { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .9rem; }
.lead-head > div:not(.lh-text) { flex: 1; }
.actions-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
@media (max-width: 640px) { .actions-bar .btn { flex: 1 1 calc(50% - .5rem); } .lead-head > .btn { display: none; } }
.stagebar { display: flex; gap: 3px; margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.stagebar::-webkit-scrollbar { display: none; }
.sb { flex: 1 0 auto; text-align: center; font-size: .74rem; font-weight: 650; padding: .45rem .8rem; background: var(--soft); color: var(--faint); white-space: nowrap; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%); }
.sb:first-child { clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%); border-radius: 6px 0 0 6px; }
.sb:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 8px 50%); border-radius: 0 6px 6px 0; }
.sb-done { background: #dcdcd8; color: var(--ink-2); }
.sb-cur { background: var(--black); color: var(--white); }
.sb-cur.sb-lost { background: var(--bad); }
.next-box { display: flex; gap: .75rem; align-items: flex-start; background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: .85rem 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.next-box > .ic { margin-top: .15rem; color: var(--muted); }
.next-box b { margin-right: .3rem; }
.due-box-overdue { border-color: var(--bad-line); background: var(--bad-bg); }
.due-box-overdue b, .due-box-overdue > .ic { color: var(--bad); }
.due-box-today { border-color: var(--black); }
.lead-grid { display: grid; gap: 1rem; }
@media (min-width: 960px) { .lead-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }
.dl { display: grid; grid-template-columns: 6.5rem 1fr; gap: .5rem .75rem; margin: 0; font-size: .92rem; }
.dl dt { color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; word-break: break-word; }
.notes { margin-top: 1rem; padding: .8rem .9rem; background: var(--soft); border-radius: var(--r-sm); font-size: .9rem; }
.chips-pick { display: flex; flex-wrap: wrap; gap: .4rem; }
.pick { display: inline-flex !important; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span { border: 1px solid var(--line-2); border-radius: 8px; padding: .35rem .8rem; font-size: .85rem; font-weight: 600; background: var(--white); color: var(--ink-2); transition: all .1s; }
.pick span:hover { border-color: var(--ink-2); }
.pick input:checked + span { background: var(--black); color: var(--white); border-color: var(--black); }
.pick input:focus-visible + span { outline: 2px solid var(--black); outline-offset: 2px; }
.quick-dates { display: flex; gap: .3rem; flex-wrap: wrap; }
.quick-dates button { border: 1px solid var(--line-2); background: var(--white); border-radius: 6px; padding: .2rem .55rem; font: inherit; font-size: .76rem; font-weight: 550; cursor: pointer; color: var(--ink-2); }
.quick-dates button:hover { background: var(--black); color: var(--white); border-color: var(--black); }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: .1rem 0 1.1rem 1.6rem; }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 1.1rem; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 1px; top: .35rem; width: 11px; height: 11px; border-radius: 50%; background: var(--black); box-shadow: 0 0 0 3px var(--white); }
.timeline li.tl-stage::before { background: var(--white); border: 2px solid var(--black); width: 7px; height: 7px; }
.timeline li.tl-system::before { background: var(--line-2); }
.timeline li.tl-system .tl-body { color: var(--muted); font-size: .88rem; }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; }
.tl-body { margin-top: .2rem; word-break: break-word; }
.tl-del { margin: .2rem 0 0; }
.diff { margin-top: .35rem; font-size: .84rem; border-collapse: collapse; }
.diff td { padding: .1rem .5rem .1rem 0; vertical-align: top; word-break: break-word; }
.diff td:first-child { color: var(--muted); }
.diff .before { color: var(--faint); text-decoration: line-through; }
.diff .after { font-weight: 600; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin: 1rem 0; }

/* ---------- pipeline board ---------- */
.hint-drag { margin: -.4rem 0 .8rem; }
.board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; scroll-snap-type: x proximity; margin: 0 -2rem; padding-left: 2rem; padding-right: 2rem; }
@media (max-width: 999px) { .board { margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; } }
.col { flex: 0 0 272px; background: var(--soft); border-radius: var(--r); padding: .5rem; scroll-snap-align: start; transition: background .12s, box-shadow .12s; }
.col.drop { background: #e7e7e3; box-shadow: inset 0 0 0 2px var(--black); }
.col-head { padding: .35rem .45rem .65rem; }
.col-head b { font-size: .88rem; }
.col-sum { font-size: .76rem; color: var(--muted); margin-top: .1rem; font-weight: 550; }
.col-note { font-size: .7rem; color: var(--faint); }
.col-won .col-head b::before { content: "✓ "; }
.col-body { display: grid; gap: .45rem; min-height: 60px; }
.col-empty { font-size: .8rem; color: var(--faint); text-align: center; padding: 1rem 0; border: 1px dashed var(--line-2); border-radius: 10px; }
.kcard { display: grid; gap: .35rem; background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .75rem; color: var(--ink); box-shadow: var(--shadow); cursor: grab; transition: border-color .12s, box-shadow .12s, transform .12s; }
.kcard:hover { border-color: var(--line-2); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.kcard.dragging { opacity: .45; transform: rotate(1.5deg); }
.kc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.kc-top b { font-size: .9rem; font-weight: 650; line-height: 1.3; }
.kc-meta { font-size: .78rem; color: var(--muted); }
.kc-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.kc-val { font-size: .82rem; font-weight: 700; }
.col-won .kcard { opacity: .8; }

/* ---------- quotation form ---------- */
.q-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem .6rem; padding: .85rem 0; border-bottom: 1px solid var(--line); align-items: end; }
.q-row label { display: grid; gap: .25rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.q-amt { display: grid; text-align: right; }
.q-row .btn-icon { grid-column: 3; grid-row: 1; justify-self: end; align-self: start; }
.q-desc { grid-row: 1; grid-column: 1 / 3; }
@media (min-width: 760px) {
  .q-row { grid-template-columns: 1fr 6rem 8rem 8rem 34px; }
  .q-desc { grid-column: auto; grid-row: auto; }
  .q-row .btn-icon { grid-column: auto; grid-row: auto; align-self: end; margin-bottom: 5px; }
}
.q-items + .btn { margin-top: .85rem; }
.q-totals { margin: 1rem 0 0 auto; max-width: 340px; display: grid; gap: .35rem; font-size: .92rem; }
.q-totals div { display: flex; justify-content: space-between; }
.q-totals span { color: var(--muted); }
.q-grand { border-top: 2px solid var(--black); padding-top: .5rem; font-size: 1.1rem; }
.q-grand span { color: var(--ink) !important; font-weight: 650; }
.status-bar { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }

/* ---------- printable quotation ---------- */
.doc { background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 2.6rem 2.4rem; max-width: 840px; margin: 1.25rem auto; font-size: .9rem; color: #000; box-shadow: 0 10px 40px rgba(0,0,0,.07); }
.doc-head { display: flex; justify-content: space-between; gap: 1.5rem; padding-bottom: 1.3rem; border-bottom: 2px solid #000; flex-wrap: wrap; }
.doc-co { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: .2rem; }
.doc-small { font-size: .8rem; color: #444; }
.doc-title { text-align: right; }
.doc-word { font-size: 1.05rem; font-weight: 800; letter-spacing: .3em; margin-bottom: .45rem; }
.doc-meta { margin-left: auto; font-size: .84rem; border-collapse: collapse; }
.doc-meta td { padding: .05rem 0 .05rem 1rem; text-align: right; }
.doc-meta td:first-child { color: #666; }
.doc-to { margin: 1.4rem 0; }
.doc-label { font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #666; margin-bottom: .25rem; }
.doc-items { width: 100%; border-collapse: collapse; }
.doc-items th { background: #000; color: #fff; text-align: left; font-size: .74rem; font-weight: 650; padding: .55rem .65rem; letter-spacing: .02em; }
.doc-items td { padding: .65rem; border-bottom: 1px solid #e3e3e3; vertical-align: top; }
.doc-items .n { width: 2rem; color: #777; }
.doc-items tfoot td { border: 0; padding: .3rem .65rem; }
.doc-items .doc-total td { font-weight: 800; font-size: 1.02rem; border-top: 2px solid #000; padding-top: .6rem; }
.doc-terms { margin-top: 1.7rem; font-size: .8rem; color: #333; line-height: 1.6; }
.doc-foot { margin-top: 3.2rem; display: flex; flex-direction: column; align-items: flex-end; font-size: .84rem; }
.doc-sign { margin-top: 2.6rem; border-top: 1px solid #000; padding-top: .3rem; min-width: 210px; text-align: center; }
@media (max-width: 640px) { .doc { padding: 1.3rem 1rem; font-size: .82rem; margin: 1rem -1rem; border-radius: 0; border-left: 0; border-right: 0; } .doc-title { text-align: left; } .doc-meta { margin-left: 0; } .doc-meta td { text-align: left; padding: 0 1rem 0 0; } }

/* ---------- reports ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 860px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.kpi:first-child { background: var(--black); color: var(--white); border-color: var(--black); }
.kpi:first-child span, .kpi:first-child small { color: rgba(255,255,255,.6); }
.kpi span { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
.kpi b { display: block; font-size: 2.1rem; letter-spacing: -.04em; line-height: 1.15; margin-top: .15rem; font-weight: 700; }
.kpi small { display: block; color: var(--muted); font-size: .76rem; margin-top: .1rem; }
.rtable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rtable th { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; text-align: left; padding: .4rem .45rem; border-bottom: 1px solid var(--line); }
.rtable td { padding: .55rem .45rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rtable tbody tr:last-child td { border-bottom: 0; }
.rtable tfoot td { border-top: 1px solid var(--line-2); font-weight: 650; border-bottom: 0; }
.rtable .w { width: 32%; }
.bar { display: block; height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--black); border-radius: 99px; }

/* ---------- print: only the quotation ---------- */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .side, .mtop, .tabbar, .scrim, .foot, .no-print, .flash { display: none !important; }
  .main { margin: 0; }
  .wrap { padding: 0; max-width: none; }
  .doc { border: 0; box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .doc-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-items tr { page-break-inside: avoid; }
}

/* ---------- polish ---------- */
.rtable .r, .table .r { text-align: right; }
.fields { align-items: start; }
@media (max-width: 640px) { .lead-head .av.lg { display: none; } .lead-head h1 { font-size: 1.35rem; } }
.doc-items th.r { text-align: right; }
