/* CollectCRM — design tokens & components */
:root {
  color-scheme: light;
  --bg: #f5f8fa; --surface: #ffffff; --surface-2: #f8fafb; --surface-3: #eef3f1;
  --border: #e1e8e5; --border-strong: #cfd9d5;
  --text: #141c24; --text-2: #4c5866; --muted: #5d6874;
  --navy: #0a2e22;
  --accent: #0f8a55; --accent-hover: #0b7346; --accent-soft: #e8f6ef; --accent-ink: #ffffff; --brand-ink: #0d2b22;
  --accent-btn: #0f8a55; --accent-btn-hover: #0b7346;
  --good: #067647; --good-soft: #ecfdf3;
  --warn: #a3400a; --warn-soft: #fffaeb;
  --serious: #b54708; --serious-soft: #fef6ee;
  --bad: #c4271b; --bad-soft: #fef3f2;
  --info: #175cd3; --info-soft: #eff8ff;
  --wa: #128344; --wa-hover: #0e6e39;
  --shadow: 0 1px 2px rgb(14 42 61 / 0.06);
  --shadow-lg: 0 20px 40px -8px rgb(14 42 61 / 0.2);
  --radius: 12px; --radius-sm: 8px; --ctl-h: 40px; --ctl-h-sm: 32px;
  --viz-grid: #e1e0d9; --viz-axis: #c3c2b7; --viz-bar: #2a78d6;
  --age-0: #86b6ef; --age-1: #5598e7; --age-2: #2a78d6; --age-3: #1c5cab; --age-4: #0d366b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #08110d; --surface: #0f1b16; --surface-2: #15241e; --surface-3: #1b2d26;
    --border: #24372f; --border-strong: #31473e;
    --text: #f2f5f4; --text-2: #b6c3bd; --muted: #a3b1aa; --navy: #f2f5f4;
    --accent: #5fd69a; --accent-hover: #8ae3b6; --accent-soft: #11301f; --accent-ink: #06180f; --brand-ink: #0d2b22;
    --accent-btn: #0f8a55; --accent-btn-hover: #12a065;
    --good: #5fd69a; --good-soft: #0f2f20; --warn: #fdba4d; --warn-soft: #35260c;
    --serious: #ffa36b; --serious-soft: #3a2010; --bad: #fd8a80; --bad-soft: #3b1714;
    --info: #7cc0fd; --info-soft: #112b45; --wa: #128344; --wa-hover: #0e6e39;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3); --shadow-lg: 0 20px 40px -8px rgb(0 0 0 / 0.6);
    --viz-grid: #2c2c2a; --viz-axis: #383835; --viz-bar: #3987e5;
    --age-0: #256abf; --age-1: #3987e5; --age-2: #6da7ec; --age-3: #9ec5f4; --age-4: #cde2fb;
  }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #08110d; --surface: #0f1b16; --surface-2: #15241e; --surface-3: #1b2d26;
    --border: #24372f; --border-strong: #31473e;
    --text: #f2f5f4; --text-2: #b6c3bd; --muted: #a3b1aa; --navy: #f2f5f4;
    --accent: #5fd69a; --accent-hover: #8ae3b6; --accent-soft: #11301f; --accent-ink: #06180f; --brand-ink: #0d2b22;
    --accent-btn: #0f8a55; --accent-btn-hover: #12a065;
    --good: #5fd69a; --good-soft: #0f2f20; --warn: #fdba4d; --warn-soft: #35260c;
    --serious: #ffa36b; --serious-soft: #3a2010; --bad: #fd8a80; --bad-soft: #3b1714;
    --info: #7cc0fd; --info-soft: #112b45; --wa: #128344; --wa-hover: #0e6e39;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3); --shadow-lg: 0 20px 40px -8px rgb(0 0 0 / 0.6);
    --viz-grid: #2c2c2a; --viz-axis: #383835; --viz-bar: #3987e5;
    --age-0: #256abf; --age-1: #3987e5; --age-2: #6da7ec; --age-3: #9ec5f4; --age-4: #cde2fb;
}

* { box-sizing: border-box; }
svg.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.banner svg.i { width: 15px; height: 15px; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12px; } .text-2 { color: var(--text-2); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.hidden { display: none !important; }

/* boot */
.boot { position: fixed; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; background: var(--bg); z-index: 50; }
.boot-text { color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; font-size: 16px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 12px 14px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.sidebar-foot .lic { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 10px 24px; }
.topbar .menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 460px; }
.search input { width: 100%; padding-left: 34px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 360px; overflow: auto; z-index: 20; }
.search-results a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; color: var(--text); border-bottom: 1px solid var(--border); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.sel { background: var(--surface-3); text-decoration: none; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.banner { padding: 9px 24px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.content { padding: 22px 24px 60px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 0; flex-wrap: wrap; }
.card-head h3 { font-size: 14px; }
.card-body { padding: 14px 16px 16px; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

.stat { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.stat .sub { color: var(--muted); font-size: 12px; }
a.stat { color: inherit; } a.stat:hover { text-decoration: none; border-color: var(--border-strong); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.icon { padding: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font: 500 13px var(--font); color: var(--text-2); cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

input, select, textarea { font: 14px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input[type="file"] { padding: 6px; }
label { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 13.5px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .grow { flex: 1; min-width: 180px; }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.t th.sortable { cursor: pointer; user-select: none; }
.t th.sortable:hover { color: var(--text); }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover { background: var(--surface-2); }
.t tr.click { cursor: pointer; }
.t tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border); }
.t .actions { text-align: right; white-space: nowrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

/* badges & chips */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.serious { background: var(--serious-soft); color: var(--serious); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge svg { width: 12px; height: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11.5px; padding: 1px 7px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font: 550 13.5px var(--font); color: var(--text-2); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

/* list rows (follow-ups) */
.fu { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; padding: 14px 16px; border-bottom: 1px solid var(--border); align-items: center; }
.fu:last-child { border-bottom: 0; }
.fu .who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.fu .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.fu .reasons { margin-top: 6px; }
.fu .amt { font-size: 16px; font-weight: 650; }
.prio { width: 4px; align-self: stretch; border-radius: 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent); flex: none; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.timeline .ic svg { width: 14px; height: 14px; }
.timeline .ic.wa { background: var(--good-soft); color: var(--wa); }
.timeline .ic.pay { background: var(--good-soft); color: var(--good); }
.timeline .ic.promise { background: var(--warn-soft); color: var(--warn); }

/* key-value */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; z-index: 40; overflow-y: auto; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; border: 1px solid var(--border); animation: pop .14s ease-out; }
.modal.wide { max-width: 860px; } .modal.xl { max-width: 1080px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(6px) scale(.99); opacity: 0; } }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 360px; animation: pop .15s ease-out; }
.toast.bad { background: var(--bad); color: #fff; } .toast.good { background: var(--good); color: #fff; }

/* charts */
.chart { width: 100%; display: block; }
.chart text { fill: var(--muted); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--viz-grid); stroke-width: 1; }
.chart .baseline { stroke: var(--viz-axis); stroke-width: 1; }
.chart .bar { fill: var(--viz-bar); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g.m:hover .bar { opacity: .85; }
.chart-tip { position: fixed; pointer-events: none; z-index: 70; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; }
.chart-tip b { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.age-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface); }
.age-bar span { display: block; height: 100%; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.age-rows { display: flex; flex-direction: column; gap: 10px; }
.age-row { display: grid; grid-template-columns: 110px 1fr 120px; gap: 10px; align-items: center; font-size: 13px; }
.age-row .track { background: var(--surface-3); border-radius: 4px; height: 12px; overflow: hidden; }
.age-row .fill { height: 100%; border-radius: 0 4px 4px 0; }

/* misc */
.callout { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.callout.info { background: var(--accent-soft); border-color: transparent; color: var(--text); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--text); }
.msg-preview { white-space: pre-wrap; background: #e7f6dd; color: #111b21; border-radius: 10px 10px 10px 2px; padding: 12px 14px; font-size: 14px; line-height: 1.5; border: 1px solid #d1e9c3; }
:root[data-theme="dark"] .msg-preview { background: #144d37; color: #e9edef; border-color: #1d5c43; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg-preview { background: #144d37; color: #e9edef; border-color: #1d5c43; } }
.qr-box { display: grid; place-items: center; background: #fff; padding: 14px; border-radius: 10px; border: 1px solid var(--border); }
.qr-box img, .qr-box canvas { image-rendering: pixelated; width: 200px; height: 200px; }
.lock-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.lock-card { width: 100%; max-width: 460px; }
.license-key { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }
.steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.steps span { padding: 4px 10px; border-radius: 99px; background: var(--surface-3); font-size: 12px; color: var(--muted); font-weight: 600; }
.steps span.on { background: var(--accent); color: #fff; }
.kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }
.sidebar-back { display: none; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--text-2); cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* responsive */
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 45; transform: translateX(-100%); transition: transform .18s ease; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar-back { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 44; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar-actions .hide-sm { display: none; }
  .content { padding: 16px 16px 60px; }
  .banner { padding: 9px 16px; }
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .fu { grid-template-columns: 1fr; }
  .age-row { grid-template-columns: 90px 1fr 96px; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
}
@media (max-width: 520px) {
  .g-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px; } .stat .value { font-size: 19px; }
  .t.responsive thead { display: none; }
  .t.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: 6px 0; }
  .t.responsive td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 4px 12px; text-align: right; }
  .t.responsive td::before { content: attr(data-l); color: var(--muted); font-size: 12px; text-align: left; }
  .t.responsive td.actions { justify-content: flex-end; }
}

/* print (statements & reports) */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .banner, .no-print, .toasts, .modal-back { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  .print-only { display: block; }
  .t th { background: #f2f2f2 !important; position: static; }
}
body.printing-modal > *:not(.modal-back) { }
@media print {
  body.printing-modal #root { display: none !important; }
  body.printing-modal .modal-back { display: block !important; position: static; background: none; padding: 0; }
  body.printing-modal .modal { box-shadow: none; border: 0; max-width: none; }
  body.printing-modal .modal-head, body.printing-modal .modal-foot { display: none; }
}

/* brand */
.logo-plate { background: #fff; border-radius: 12px; padding: 14px; display: grid; place-items: center; }
.logo-plate img { max-width: 220px; height: auto; display: block; }
.brand img { width: 30px; height: 30px; }
.btn.primary, .steps span.on { color: #fff; }
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .steps span.on { color: #06180f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary, :root:not([data-theme="light"]) .steps span.on { color: #06180f; } }
.sidebar-foot svg { width: 14px; height: 14px; flex: none; }
.stat .label svg { width: 14px; height: 14px; }
.callout svg { width: 16px; height: 16px; vertical-align: -3px; flex: none; }
.empty > svg { width: 30px; height: 30px; color: var(--good); display: block; margin: 0 auto 8px; }
.avatar svg { width: 16px; height: 16px; }


/* ================= TotalCRM look ================= */
h1 { font-size: 1.6rem; letter-spacing: -0.02em; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.shell { grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { padding: 20px 12px; gap: 2px; border-right: 1px solid var(--border); background: var(--surface); }
.brand { padding: 0 6px 16px; gap: 8px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.wordmark { display: inline-flex; flex-direction: column; line-height: 1; }
.wordmark > span { font-weight: 800; font-size: 1.3rem; letter-spacing: -0.03em; color: var(--navy); }
.wordmark b { font-weight: 800; background: linear-gradient(90deg, var(--accent), #2fd384); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.wordmark.lg > span { font-size: 1.5rem; }
.wordmark small { font-size: 0.58rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-top: 3px; }
.sidebar .search { margin: 0 2px 10px; max-width: none; flex: none; }
.sidebar .search input { height: 36px; font-size: 0.88rem; background: var(--surface-2); }
.nav { padding: 0; gap: 2px; }
.nav-label { padding: 14px 12px 6px; font-size: 0.7rem; }
.nav a { gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; font-size: 0.95rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { background: var(--bad); min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; font-size: 0.72rem; font-weight: 700; }
.sidebar-foot { border-top: 0; padding: 10px; font-size: 0.78rem; display: flex; flex-direction: column; gap: 10px; }
.foot-line { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); line-height: 1.35; }
.foot-line:hover { color: var(--text); text-decoration: none; }
.foot-line svg.i { width: 14px; height: 14px; margin-top: 1px; }
.warn-text { color: var(--warn); }
.theme-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; align-self: flex-start; }
.theme-switch button { display: inline-flex; align-items: center; height: 28px; padding: 0 9px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--border); }
.theme-switch svg.i { width: 15px; height: 15px; }
.mobile-top { display: none; }
.content { padding: 32px 40px 64px; max-width: 1400px; margin: 0 auto; }
.banner { margin: 16px 40px 0; border-radius: 10px; padding: 12px 16px; font-size: 0.9rem; }
.page-head { margin-bottom: 20px; align-items: flex-start; }
.page-head p { color: var(--muted); }

.btn { height: var(--ctl-h); padding: 0 16px; border-radius: 8px; border: 1px solid var(--border); font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow); gap: 8px; line-height: 1; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; }
.btn.primary:hover { background: var(--accent-btn-hover); border-color: var(--accent-btn-hover); }
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .steps span.on { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary, :root:not([data-theme="light"]) .steps span.on { color: #fff; } }
.btn.wa { background: var(--wa); border-color: var(--wa); }
.btn.wa:hover { background: var(--wa-hover); filter: none; }
.btn.danger { color: var(--bad); }
.btn.ghost { box-shadow: none; }
.btn.sm { height: var(--ctl-h-sm); padding: 0 12px; gap: 6px; font-size: 0.84rem; }
.btn.icon { width: var(--ctl-h); padding: 0; }
.btn.sm.icon { width: var(--ctl-h-sm); }
.btn-lg { height: 48px; padding: 0 20px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button { height: 38px; padding: 0 14px; font-size: 0.86rem; }
input, select, textarea { height: var(--ctl-h); padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.94rem; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 10px 12px; }
input[type="checkbox"], input[type="radio"] { height: auto; }
input[type="file"] { height: auto; padding: 6px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
label { font-size: 0.84rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field { margin-bottom: 14px; }

.card { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-head { padding: 18px 22px 0; }
.card-body { padding: 16px 22px 20px; }
.card-head h3 { font-size: 1rem; }
.stat { padding: 16px 18px; gap: 2px; }
.stat .label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 1.6rem; letter-spacing: -0.02em; font-weight: 700; }
.t th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; }
.t td { padding: 12px 14px; }
.badge { font-size: 0.72rem; font-weight: 600; padding: 2px 8px; }
.badge.info { background: var(--info-soft); color: var(--info); }
.tabs button { font-size: 0.92rem; padding: 10px 14px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.modal { border-radius: 16px; }
.modal-head h2 { font-size: 1.1rem; }
.callout { border-radius: 10px; }
.callout.info { background: var(--info-soft); color: var(--text); }
.error { color: var(--bad); font-size: 0.88rem; min-height: 0; }
.error:empty { display: none; }
.text-strong { color: var(--text); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form .field { margin: 0; }

/* activation (TotalCRM) */
.activate-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.activate-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; }
.activate-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.activate-card h1 { font-size: 1.4rem; }
.activate-card p { margin: 0; }
.activate-card .banner { margin: 0; }
.key-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; letter-spacing: 0.06em; height: 48px; text-transform: uppercase; }
.key-input::placeholder { text-transform: none; }
.activate-links { display: flex; flex-direction: column; gap: 8px; }
.activate-links:empty { display: none; }
.activate-foot { text-align: center; }
.device-list { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.device-rows { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem; }
.device-rows li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* folder backup */
.fb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.storage { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 8px; flex-wrap: wrap; }
.storage span { flex: 1; min-width: 200px; }
.storage.ok { background: var(--good-soft); color: var(--good); }
.storage.warn { background: var(--warn-soft); color: var(--warn); }
.rg-mock { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; font-size: 0.86rem; background: var(--surface-2); }
.rg-bar { display: flex; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); font-weight: 600; }
.rg-row { display: flex; align-items: center; gap: 8px; padding: 7px 12px; }
.rg-folder { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rg-click { margin-left: auto; font-size: 0.78rem; }
.rg-file { color: var(--muted); opacity: .6; }
.rg-foot { display: flex; justify-content: flex-end; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.rg-btn { background: var(--accent-btn); color: #fff; border-radius: 6px; padding: 4px 12px; font-weight: 600; font-size: 0.8rem; }

@media (max-width: 860px) {
  .mobile-top { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
  .mobile-top .wordmark > span { font-size: 1.15rem; }
  .content { padding: 18px 16px 60px; }
  .banner { margin: 12px 16px 0; }
}

/* admin (TotalCRM style) */
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 40px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.admin-top .activate-brand { margin: 0; }
.admin-top .wordmark > span { font-size: 1.15rem; }
.key-copy { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 3px 8px; cursor: pointer; color: var(--text); font-size: 0.82rem; }
.key-copy:hover { border-color: var(--accent); }
.key-copy svg.i { width: 13px; height: 13px; color: var(--muted); }
.key-box { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border: 1px dashed var(--accent); background: var(--accent-soft); border-radius: 10px; }
.key-box strong { font-size: 1.25rem; letter-spacing: 0.06em; }
.last-active { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.btn.icon.danger:hover { background: var(--bad-soft); }
@media (max-width: 860px) { .admin-top { padding: 12px 16px; } }
.nav a > span:not(.count) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tabs button, .seg button { white-space: nowrap; }

.fu.with-prio { grid-template-columns: 4px minmax(0, 1fr) auto; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .fu.with-prio { grid-template-columns: 4px minmax(0, 1fr); }
  .fu.with-prio > .btn-group { grid-column: 2; justify-content: flex-start !important; }
  .page-head h1 { font-size: 1.35rem; }
  .toolbar > * { flex: 1 1 auto; }
  .seg { overflow-x: auto; max-width: 100%; }
}

/* welcome / onboarding */
.welcome { max-width: 760px; margin: 0 auto; }
.welcome-body { padding: 32px 36px 28px; }
.welcome-brand { margin-bottom: 14px; }
.welcome h1 { font-size: 1.5rem; }
.welcome > .card > .welcome-body > p { margin: 4px 0 0; }
.welcome-step { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 20px; }
.welcome-step h3 { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-no { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-size: 0.8rem; font-weight: 700; flex: none; }
.welcome-step .form-grid .field { margin-bottom: 12px; }
.welcome-folder { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.welcome-folder p { margin: 0; flex: 1; min-width: 0; }
.welcome-folder-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: none; }
.start-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.start-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font: inherit; color: var(--text); box-shadow: var(--shadow); transition: border-color .15s, background .15s; }
.start-card:hover { border-color: var(--accent); background: var(--surface-2); }
.start-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.start-card.rec { border-color: var(--accent); background: var(--accent-soft); }
.start-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--accent); margin-bottom: 4px; }
.start-ic svg.i { width: 18px; height: 18px; }
.start-title { font-weight: 650; font-size: 0.95rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.start-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }
@media (max-width: 720px) {
  .welcome-body { padding: 22px 18px; }
  .welcome-folder { flex-direction: column; align-items: stretch; }
  .start-grid { grid-template-columns: 1fr; }
}
.start-top { display: flex; justify-content: space-between; align-items: flex-start; width: 100%; }
.start-title { white-space: nowrap; }
@media (max-width: 720px) { .welcome-folder-btns { grid-template-columns: minmax(0, 1fr); } }

/* dropdowns (TotalCRM style): custom chevron, consistent padding everywhere incl. modals */
:root { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235d6874' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a3b1aa' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a3b1aa' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); } }
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  height: var(--ctl-h); padding: 0 36px 0 12px; line-height: 1.2;
  background-color: var(--surface); background-image: var(--chevron); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  cursor: pointer; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
select:hover { border-color: var(--border-strong); }
select:disabled { opacity: .6; cursor: not-allowed; }
select::-ms-expand { display: none; }
select option { background: var(--surface); color: var(--text); }
.toolbar select { width: auto; min-width: 150px; max-width: 260px; }
.toolbar input[type="date"] { width: auto; }
.modal select, .card select, .field select { width: 100%; }
.btn-group select, td select { width: auto; }
.toolbar select { width: auto; }
.grid > .card + .card, .grid > .card { margin-top: 0; }
