/* Zaybrix Billing & CRM */
:root {
  --p: #1a56db; --p-d: #1e429f; --p-dd: #233876; --p-l: #e1effe; --p-ll: #f3f8ff; --p-line: #c3ddfd;
  --ink: #111827; --ink-2: #374151; --muted: #6b7280; --line: #e5e7eb; --line-2: #f1f3f6;
  --bg: #f6f8fb; --card: #ffffff; --surface-2: #f9fafb; --col: #eef2f7; --topbar: rgba(246,248,251,.92);
  --green: #057a55; --green-l: #def7ec; --red: #e02424; --red-l: #fde8e8; --amber: #b45309; --amber-l: #fef3c7;
  --blue: #1c64f2; --blue-l: #e1effe; --gray-l: #f3f4f6; --cold: #0e7490; --cold-l: #e0f2fe;
  --ok-t: #03543f; --ok-b: #bcf0da; --err-t: #9b1c1c; --err-b: #f8b4b4; --warn-t: #8a4a07; --warn-b: #fcd9a5;
  --ring: rgba(26,86,219,.2); --r: 12px; --r-s: 8px; --sh: 0 1px 2px rgba(17,24,39,.05), 0 4px 16px rgba(17,24,39,.05);
  --side: 236px; --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --p: #3f83f8; --p-d: #1c64f2; --p-dd: #a4cafe; --p-l: rgba(63,131,248,.18); --p-ll: rgba(63,131,248,.08); --p-line: #1e3a8a; --ink: #e5e7eb; --ink-2: #cbd5e1; --muted: #94a3b8; --line: #334155; --line-2: #273449; --bg: #0f172a; --card: #1e293b; --surface-2: #1a2436; --col: #172033; --topbar: rgba(15,23,42,.9); --green: #34d399; --green-l: rgba(52,211,153,.15); --red: #f87171; --red-l: rgba(248,113,113,.15); --amber: #fbbf24; --amber-l: rgba(251,191,36,.15); --blue: #60a5fa; --blue-l: rgba(96,165,250,.15); --gray-l: #273449; --cold: #67e8f9; --cold-l: rgba(103,232,249,.12); --ok-t: #a7f3d0; --ok-b: #065f46; --err-t: #fecaca; --err-b: #7f1d1d; --warn-t: #fde68a; --warn-b: #78350f; --ring: rgba(63,131,248,.35); --sh: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; } }
:root[data-theme="dark"] { --p: #3f83f8; --p-d: #1c64f2; --p-dd: #a4cafe; --p-l: rgba(63,131,248,.18); --p-ll: rgba(63,131,248,.08); --p-line: #1e3a8a; --ink: #e5e7eb; --ink-2: #cbd5e1; --muted: #94a3b8; --line: #334155; --line-2: #273449; --bg: #0f172a; --card: #1e293b; --surface-2: #1a2436; --col: #172033; --topbar: rgba(15,23,42,.9); --green: #34d399; --green-l: rgba(52,211,153,.15); --red: #f87171; --red-l: rgba(248,113,113,.15); --amber: #fbbf24; --amber-l: rgba(251,191,36,.15); --blue: #60a5fa; --blue-l: rgba(96,165,250,.15); --gray-l: #273449; --cold: #67e8f9; --cold-l: rgba(103,232,249,.12); --ok-t: #a7f3d0; --ok-b: #065f46; --err-t: #fecaca; --err-b: #7f1d1d; --warn-t: #fde68a; --warn-b: #78350f; --ring: rgba(63,131,248,.35); --sh: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--p-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 700; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
small, .muted { color: var(--muted); }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code { background: var(--gray-l); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--side); background: var(--card); border-right: 1px solid var(--line); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; }
.brand { display: block; padding: 18px 20px 12px; text-decoration: none !important; }
.brand-logo { height: 30px; display: block; }
.brand-sub { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--ink-2); font-weight: 600; margin-bottom: 2px; }
.nav-link:hover { background: var(--p-ll); color: var(--p-d); text-decoration: none; }
.nav-link.active { background: var(--p-l); color: var(--p-dd); }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; font-weight: 700; }
.side-foot { border-top: 1px solid var(--line); padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me { display: flex; gap: 10px; align-items: center; color: var(--ink); min-width: 0; }
.me:hover { text-decoration: none; }
.me b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.me small { display: block; font-size: 11.5px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--p); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.main { flex: 1; margin-left: var(--side); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 12px 24px; background: var(--topbar); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.page-title { font-size: 1.2rem; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search { position: relative; width: min(340px, 34vw); }
.top-search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-search input[type=search] { padding-left: 34px; height: 36px; border-radius: 999px; background: var(--card); }
.content { padding: 22px 24px 40px; max-width: 1400px; width: 100%; }
.scrim { display: none; }
.bottom-nav { display: none; }
.only-mobile, .show-mobile { display: none !important; }

/* Cards / grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 18px; margin-bottom: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h h2, .card-h h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-h { padding: 14px 18px 0; }
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.grid > .card, .grid > form.card { margin-bottom: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.mt0 { margin-top: 0 } .mb0 { margin-bottom: 0 !important; } .mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.grow { flex: 1; }

/* Stats */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--sh); }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 1.45rem; font-weight: 800; margin-top: 4px; line-height: 1.2; }
.stat .v small { font-size: .8rem; font-weight: 600; }
.stat.accent { background: linear-gradient(135deg, var(--p-d), var(--p)); color: #fff; border: 0; }
.stat.accent .k { color: rgba(255,255,255,.8); }
.stat.red .v { color: var(--red); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--p-line); background: var(--p-ll); }
.btn-primary { background: var(--p); border-color: var(--p); color: #fff; }
.btn-primary:hover { background: var(--p-d); border-color: var(--p-d); }
.btn-green { background: #25D366; border-color: #25D366; color: #fff; }
.btn-green:hover { background: #1DA851; border-color: #1DA851; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-l); border-color: var(--red); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; font: inherit; }
.btn-link:hover { color: var(--p-d); }
.icon-btn { background: var(--card); border: 1px solid var(--line); border-radius: 9px; width: 38px; height: 38px; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }

/* Forms */
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=date], input[type=datetime-local], input[type=time], input[type=search], input[type=url], select, textarea {
  width: 100%; height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--card); font: inherit; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--p); box-shadow: 0 0 0 3px var(--ring); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--p); vertical-align: middle; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.fgrid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fgrid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.req::after { content: ' *'; color: var(--red); }
.inline-form { display: inline; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.t td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover { background: var(--surface-2); }
.t .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t td.cb, .t th.cb { width: 36px; }
.t a.rowlink { color: var(--ink); font-weight: 600; }
.sub { display: block; font-size: 12.5px; color: var(--muted); }
.empty { text-align: center; padding: 30px 12px; color: var(--muted); }

/* Badges & chips */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--gray-l); color: var(--ink-2); white-space: nowrap; }
.b-paid, .b-won, .b-active, .b-accepted, .b-called { background: var(--green-l); color: var(--green); }
.b-unpaid, .b-sent, .b-new, .b-contacted { background: var(--blue-l); color: var(--blue); }
.b-partial, .b-negotiation, .b-paused, .b-busy, .b-quotation { background: var(--amber-l); color: var(--amber); }
.b-overdue, .b-lost, .b-rejected, .b-wrong_number, .b-no_answer, .b-switched_off { background: var(--red-l); color: var(--red); }
.b-draft, .b-cancelled, .b-inactive, .b-ended, .b-converted, .b-not_called { background: var(--gray-l); color: var(--muted); }
.b-interested, .b-demo { background: var(--p-l); color: var(--p-dd); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--gray-l); color: var(--ink-2); }
.chip.warn { background: var(--amber-l); color: var(--amber); }
.chip.danger { background: var(--red-l); color: var(--red); }
.chip.ok { background: var(--green-l); color: var(--green); }
.chip.p { background: var(--p-l); color: var(--p-dd); }
.red { color: var(--red); } .green { color: var(--green); } .amber { color: var(--amber); }

/* Alerts */
.alert { position: relative; padding: 12px 40px 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: var(--green-l); color: var(--ok-t); border-color: var(--ok-b); }
.alert-error { background: var(--red-l); color: var(--err-t); border-color: var(--err-b); }
.alert-info { background: var(--p-ll); color: var(--p-dd); border-color: var(--p-line); }
.alert-warn { background: var(--amber-l); color: var(--warn-t); border-color: var(--warn-b); }
.alert-x { position: absolute; right: 8px; top: 7px; background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.suggest { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: linear-gradient(135deg, var(--p-l), var(--card)); border: 1px solid var(--p-line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; }
.suggest .txt { flex: 1; min-width: 200px; font-weight: 600; color: var(--p-dd); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.filters .f { min-width: 140px; flex: 1 1 140px; max-width: 220px; }
.filters label { font-size: 11.5px; margin-bottom: 3px; }
.filters input, .filters select { height: 36px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--p-dd); border-color: var(--p); }
.tabs a:hover { text-decoration: none; color: var(--p-d); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pill { padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 13px; color: var(--ink-2); }
.pill:hover { text-decoration: none; border-color: var(--p); }
.pill.active { background: var(--p); color: #fff; border-color: var(--p); }
.pill .n { opacity: .7; margin-left: 3px; }
.bulkbar { display: none; position: sticky; top: 62px; z-index: 20; background: #111827; color: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulkbar.show { display: flex; }
.bulkbar .btn { height: 30px; font-size: 13px; }
.pager { display: flex; gap: 6px; justify-content: center; padding: 14px; flex-wrap: wrap; }

/* Lists of leads (dashboard) */
.lead { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.lead:last-child { border-bottom: 0; }
.lead .who { flex: 1; min-width: 0; }
.lead .who a { color: var(--ink); font-weight: 700; }
.lead .who .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead .acts { display: flex; gap: 6px; flex: none; }
.sec-red h3 { color: var(--red); }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--p-l); color: var(--p-dd); font-size: 12px; font-weight: 800; margin-left: 6px; }
.sec-red .count { background: var(--red-l); color: var(--red); }

/* Kanban */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; scroll-snap-type: x proximity; }
.col { flex: 0 0 272px; background: var(--col); border-radius: var(--r); padding: 10px; max-height: calc(100vh - 190px); display: flex; flex-direction: column; scroll-snap-align: start; }
.col-h { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 13px; padding: 2px 4px 10px; }
.col-body { overflow-y: auto; min-height: 60px; flex: 1; border-radius: 8px; transition: background .15s; }
.col-body.over { background: var(--p-l); }
.kcard { background: var(--card); border-radius: 10px; padding: 10px 11px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.06); border: 1px solid var(--line); cursor: grab; }
.kcard.dragging { opacity: .5; }
.kcard .nm { font-weight: 700; color: var(--ink); display: block; }
.kcard .meta { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.kcard .row { gap: 4px; }
.kcard select { height: 28px; font-size: 12px; padding: 2px 6px; width: auto; }

/* Invoice editor */
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px; }
.items td { padding: 4px; vertical-align: top; }
.items input, .items textarea, .items select { height: 36px; }
.items textarea { min-height: 36px; height: 36px; }
.items .w-qty { width: 80px; } .items .w-rate { width: 120px; } .items .w-disc { width: 76px; } .items .w-amt { width: 120px; text-align: right; font-weight: 700; padding-top: 12px; } .items .w-tax { width: 50px; text-align: center; padding-top: 12px; } .items .w-x { width: 36px; }
.totals { margin-left: auto; width: min(380px, 100%); }
.totals .tr { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; align-items: center; }
.totals .grand { font-size: 1.2rem; font-weight: 800; border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; }
.totals input, .totals select { height: 32px; }

/* Detail pages */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2px solid var(--p); }
.timeline li.t-call::before { background: var(--p); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .when { font-size: 12px; color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button, .quick label.qb { border: 1px solid var(--line); background: var(--card); padding: 7px 11px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); margin: 0; }
.quick button.on, .quick label.qb:has(input:checked) { background: var(--p); color: #fff; border-color: var(--p); }
.quick label.qb input { display: none; }
.big-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-actions .btn { height: 50px; font-size: 15px; }
.dupe { background: var(--amber-l); border: 1px solid var(--warn-b); color: var(--warn-t); border-radius: 10px; padding: 10px 12px; margin: -6px 0 14px; font-size: 13.5px; }
.dupe a { font-weight: 700; color: var(--warn-t); text-decoration: underline; }

/* Dialog */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(27,21,48,.45); }
dialog .dh { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .dh h3 { margin: 0; }
dialog .db { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }
dialog .df { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* Auth */
.auth-body { background: radial-gradient(1200px 600px at 10% -10%, var(--p-l), transparent), radial-gradient(900px 500px at 110% 110%, var(--p-l), transparent), var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--card); border-radius: 18px; padding: 30px 26px; box-shadow: 0 10px 40px rgba(17,24,39,.12); border: 1px solid var(--line); }
.auth-logo { height: 36px; display: block; margin: 0 auto 22px; }
.auth-card h1 { font-size: 1.3rem; text-align: center; }
.auth-foot { color: var(--muted); font-size: 12.5px; margin-top: 18px; }

/* Public invoice page */
.public-body { background: var(--bg); }
.pub { max-width: 860px; margin: 24px auto; padding: 0 16px; }
.pub .doc { background: var(--card); border-radius: 16px; border: 1px solid var(--line); box-shadow: var(--sh); padding: 28px; }
.pub-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.pub-head img { height: 40px; }
.pay-box { background: var(--p-ll); border: 1px solid var(--p-line); border-radius: 12px; padding: 14px 16px; }

/* Responsive */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  body { font-size: 15px; }
  .only-mobile { display: inline-grid !important; }
  .show-mobile { display: block !important; }
  .hide-mobile { display: none !important; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(27,21,48,.4); z-index: 35; }
  .main { margin-left: 0; }
  .topbar { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .top-search { display: none; }
  .content { padding: 14px 12px 96px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .fgrid, .fgrid.c3 { grid-template-columns: minmax(0, 1fr); }
  .fgrid > * { grid-column: auto !important; }
  .card { padding: 14px; border-radius: 12px; }
  .stat { padding: 12px; } .stat .v { font-size: 1.15rem; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: center; }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 8px; min-width: 56px; text-decoration: none; }
  .bottom-nav a.active { color: var(--p-d); }
  .bottom-nav .i { width: 22px; height: 22px; }
  .bottom-nav .fab { background: var(--p); color: #fff; width: 52px; height: 52px; min-width: 52px; border-radius: 50%; justify-content: center; margin-top: -24px; box-shadow: 0 6px 18px rgba(26,86,219,.45); }
  .bottom-nav .fab .i { width: 26px; height: 26px; }
  .filters .f { max-width: none; flex: 1 1 45%; }
  /* tables become cards */
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { border-bottom: 1px solid var(--line); padding: 10px 12px; position: relative; }
  table.t.cards td { border: 0; padding: 2px 0; text-align: left !important; }
  table.t.cards td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); font-size: 12.5px; font-weight: 600; }
  table.t.cards td.cb { position: absolute; right: 10px; top: 10px; width: auto; }
  table.t.cards td.hide-m { display: none; }
  .items thead { display: none; }
  .items, .items tbody, .items tr { display: block; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
  .items td { padding: 0; width: auto !important; }
  .items td.w-desc { grid-column: 1 / -1; }
  .items td.w-amt { text-align: left; padding-top: 6px; }
  .items td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
  .kv { grid-template-columns: 110px 1fr; }
  .col { flex-basis: 84vw; max-height: none; }
  .bulkbar { top: 56px; }
  .pub .doc { padding: 18px; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .alert { display: none !important; }
  .main { margin: 0; } .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* ---- V2 additions ---- */
a.stat { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
a.stat:hover { border-color: var(--p); }
.stat small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.accent small { color: rgba(255,255,255,.85); }
.score { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; cursor: help; vertical-align: middle; }
.s-hot { background: var(--red-l); color: var(--red); }
.s-warm { background: var(--amber-l); color: var(--amber); }
.s-cold { background: var(--cold-l); color: var(--cold); }
.score-why { font-size: 12.5px; color: var(--muted); }
.chip.cold { background: var(--cold-l); color: var(--cold); }
.bar { height: 8px; background: var(--gray-l); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--p); border-radius: 99px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 220px; overflow-x: auto; padding-top: 10px; }
.chart-col { flex: 1 0 36px; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.chart-bars { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.bar-a { width: 40%; background: var(--p-line); border-radius: 4px 4px 0 0; min-height: 1px; }
.bar-b { width: 40%; background: var(--p); border-radius: 4px 4px 0 0; min-height: 1px; }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.dot-a { background: var(--p-line); } .dot-b { background: var(--p); }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; } :root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-light { display: none; } :root:not([data-theme="light"]) .logo-dark { display: block; } }
select { color-scheme: inherit; }
dialog { background: var(--card); color: var(--ink); }
.t tfoot th { background: var(--surface-2); color: var(--ink); text-transform: none; font-size: 13.5px; }
h2 { margin-top: 6px; }

/* Bigger touch targets on phones */
@media (max-width: 860px) {
  .btn { height: 44px; padding: 0 16px; }
  .btn-sm { height: 40px; }
  .btn-xs { height: 36px; min-width: 36px; padding: 0 10px; font-size: 13px; }
  .icon-btn { width: 44px; height: 44px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=date], input[type=datetime-local], input[type=time], input[type=search], input[type=url], select { height: 46px; font-size: 16px; }
  textarea { font-size: 16px; }
  .quick button, .quick label.qb { padding: 10px 14px; font-size: 14px; }
  .nav-link { padding: 12px 14px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .filters input, .filters select { height: 44px; }
  .bulkbar .btn { height: 38px; }
}
.content:has(.board) { max-width: none; }
