/* Signtral CRM: admin.css tokens + only the crm- classes the UX spec names (docs/ux-specs/crm.md 0.2). */
@import url('/assets/admin-css/admin.css');

body.crm-hidden { visibility: hidden; }
.crm-skip { position: absolute; left: 8px; top: -60px; z-index: 20000; background: #fff; color: var(--text-primary); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.crm-skip:focus { top: 8px; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
#main-content:focus { outline: none; }

/* Nav groups */
.crm-nav-group { margin-top: 14px; }
.crm-nav-group-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .06em; color: #948FAF; padding: 6px 20px 4px; font-weight: 700; }
.sidebar-footer .crm-user { color: #fff; font-size: 0.85rem; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-footer .crm-user button { background: none; border: 0; color: #cfc9e6; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font: inherit; padding: 6px; border-radius: 8px; }
.sidebar-footer .crm-user button:hover { color: #fff; background: var(--sidebar-bg-hover); }

/* Chips (colours: UX 0.3) */
.crm-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; line-height: 1.5; white-space: nowrap; border: 1px solid transparent; }
.crm-chip svg { width: 12px; height: 12px; }
.crm-chip .crm-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.crm-chip--grey { background: #f1f5f9; color: #475569; }
.crm-chip--blue { background: #dbeafe; color: #1e3a8a; }
.crm-chip--violet { background: #ede9fe; color: #5b21b6; }
.crm-chip--amber { background: #fef3c7; color: #92400e; }
.crm-chip--green { background: #d1fae5; color: #065f46; }
.crm-chip--red { background: #fee2e2; color: #991b1b; }
.crm-chip--teal { background: #cffafe; color: #155e75; }
.crm-chip.is-inferred { border: 1px dashed currentColor; }

/* Device status dot */
.crm-devdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.crm-devdot--on { background: #15803d; }
.crm-devdot--off { background: #991b1b; }
.crm-devdot--na { background: #64748b; }
.crm-sub { display: block; font-size: 0.75rem; color: #475569; }

/* Occupancy */
.crm-occ { display: block; width: 100%; min-width: 80px; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.crm-occ-fill { display: block; height: 100%; background: #0e7490; }
.crm-occ-fill.is-mid { background: #15803d; }
.crm-occ-fill.is-high { background: #92400e; }
.crm-occ-fill.is-full { background: #991b1b; }

/* As-of line */
.crm-asof { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.82rem; color: #475569; margin-bottom: 12px; }
.crm-asof--stale { background: #fef3c7; color: #92400e; padding: 8px 12px; border-radius: 8px; }

/* Hint (amber) */
.crm-hint { color: #92400e; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 4px; }
.crm-hint svg { width: 14px; height: 14px; }
a.crm-hint { font-weight: 600; text-decoration: underline; background: none; border: 0; cursor: pointer; padding: 0; font-family: inherit; }
button.crm-hint { font-weight: 600; text-decoration: underline; background: none; border: 0; cursor: pointer; padding: 0; font-family: inherit; }

/* Drawer */
.crm-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100%; background: #fff; box-shadow: -8px 0 30px rgba(15,23,42,.15); z-index: 9000; display: flex; flex-direction: column; border-left: 1px solid #e2e8f0; }
.crm-drawer[hidden] { display: none; }
.crm-drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.crm-drawer-head h2 { margin: 0; font-size: 1.05rem; }
.crm-drawer-head h2:focus { outline: none; }
.crm-drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.crm-drawer-foot { padding: 12px 20px; border-top: 1px solid #e2e8f0; display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 576px) { .crm-drawer { width: 100%; } .crm-drawer-foot .btn { flex: 1; } }

/* Forms / page */
.crm-page { max-width: 1200px; }
.crm-caption { color: #475569; font-size: 0.85rem; margin: 0 0 12px; }
.crm-check { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.crm-check input { width: 18px; height: 18px; }
.crm-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.crm-section { margin: 20px 0 8px; font-size: 1rem; }
.crm-money-in { display: flex; align-items: center; gap: 6px; }
.crm-money-in span { color: #475569; font-weight: 600; }
.crm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.crm-iconlink { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; border-radius: 8px; color: var(--accent-dark); }
.crm-iconlink:hover { background: #ede9fe; }
.crm-iconlink svg { width: 16px; height: 16px; }
.crm-table-note td, .crm-table-note th { vertical-align: middle; }
.crm-result { font-size: 1.05rem; font-weight: 700; }
.crm-gate { max-width: 440px; margin: 15vh auto; text-align: center; padding: 32px; }
.crm-gate h1 { font-size: 1.3rem; margin: 0 0 8px; }
.crm-center { display: flex; justify-content: center; padding: 40px; }
.modal-overlay.crm-modal { display: flex; }
.crm-linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-dark); font-weight: 600; cursor: pointer; text-align: left; }
.crm-linkbtn:hover { text-decoration: underline; }
@media (max-width: 576px) {
  .crm-iconlink { min-width: 44px; min-height: 44px; }
  .bill-toolbar .form-control { max-width: none; width: 100%; }
  .crm-form-grid { grid-template-columns: 1fr; }
  .btn, .crm-linkbtn { min-height: 44px; }
}

/* Help */
.crm-help { max-width: 760px; }
.crm-help .card { margin-bottom: 24px; }
.crm-help h2 { scroll-margin-top: 80px; margin-top: 0; font-size: 1.15rem; }
.crm-help h2:focus { outline: none; }
.crm-help-wrap { display: flex; gap: 24px; align-items: flex-start; }
.crm-help-toc { position: sticky; top: 90px; width: 240px; flex: none; order: 2; font-size: 0.88rem; }
.crm-help-toc ol { padding-left: 18px; margin: 6px 0; }
.crm-help-toc a { color: var(--accent-dark); }
.crm-help-toc-mobile { display: none; }
.crm-help dt { font-weight: 700; margin-top: 10px; }
.crm-help dd { margin: 2px 0 0 0; color: #334155; }
.crm-calc { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; }
.crm-calc[aria-busy="true"] { opacity: .8; }
.crm-calc-out { margin-top: 12px; line-height: 1.7; }
.crm-help-do td:first-child, .crm-help-dont td:first-child { font-weight: 700; white-space: nowrap; }
@media (max-width: 992px) {
  .crm-help-wrap { display: block; }
  .crm-help-toc { display: none; }
  .crm-help-toc-mobile { display: block; margin-bottom: 16px; }
}
@media print {
  .sidebar, .top-header, .crm-skip, .crm-help-toc, .crm-help-toc-mobile, .crm-calc-controls, .no-print, button { display: none !important; }
  .main-content { margin: 0 !important; width: 100% !important; }
  body, .view-container { background: #fff !important; color: #000; }
  .crm-help { max-width: none; }
  .crm-help h2 { break-after: avoid; }
  .crm-help table { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.crm-code { display: inline-block; margin-left: 8px; font-size: 0.72rem; color: #475569; font-variant-numeric: tabular-nums; }
.crm-readonly { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.crm-readonly dt { font-weight: 600; } .crm-readonly dd { margin: 0; color: #334155; }

/* Sales: kanban (UX 4.2), picker, timeline helpers, mobile list-to-cards */
.crm-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x proximity; }
.crm-col { flex: 0 0 280px; min-width: 264px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px; scroll-snap-align: start; align-self: flex-start; }
.crm-col.is-over { outline: 2px solid var(--accent); background: #f5f3ff; }
.crm-col-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-bottom: 8px; }
.crm-col-head h2 { font-size: 0.95rem; margin: 0; flex: 1 1 100%; }
.crm-col-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.crm-col-empty { border: 1px dashed #cbd5e1; border-radius: 8px; padding: 12px; text-align: center; color: #475569; font-size: 0.8rem; }
.crm-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.crm-card[draggable="true"] { cursor: grab; }
.crm-card.is-dragging { opacity: .6; }
.crm-card-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.crm-card-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.crm-card-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.crm-card-move { margin-left: auto; padding: 4px 10px; font-size: 0.78rem; }
.crm-mini { display: inline-flex; gap: 6px; color: #475569; }
.crm-mini svg { width: 16px; height: 16px; }
.crm-avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: #ede9fe; color: #5b21b6; font-size: 0.7rem; font-weight: 700; }
.crm-drawer--wide { width: 520px; }
.crm-fieldset { border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 14px 4px; margin: 14px 0; min-width: 0; }
.crm-fieldset legend { font-weight: 600; font-size: 0.85rem; padding: 0 6px; }
.crm-radios { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.crm-radio { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.crm-radio.is-disabled { color: #475569; }
.crm-picklist { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid #e2e8f0; border-radius: 8px; max-height: 200px; overflow: auto; }
.crm-picklist button { display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; background: #fff; font: inherit; cursor: pointer; }
.crm-picklist button:hover { background: #f5f3ff; }
.crm-picked { display: flex; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.crm-plain { list-style: none; margin: 0; padding: 0; }
.crm-plain li { margin-bottom: 8px; }
.crm-trunc { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.crm-rowactions { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 576px) {
  .crm-board { scroll-snap-type: x mandatory; }
  .crm-col { flex-basis: 85vw; }
  .crm-drawer--wide { width: 100%; }
  .crm-card-move, .crm-rowactions .btn { min-height: 44px; }
  .table-wrap { overflow: visible; }
  .table-wrap--scroll { overflow-x: auto; }
  table.crm-stack { min-width: 0 !important; }
  .crm-stack thead { position: absolute; left: -9999px; }
  .crm-stack, .crm-stack tbody, .crm-stack tr, .crm-stack td { display: block; width: 100%; }
  .crm-stack tr { border: 1px solid #e2e8f0; border-radius: 12px; margin-bottom: 12px; padding: 8px 12px; background: #fff; }
  .crm-stack td { border: 0; padding: 4px 0; }
  .crm-stack td::before { content: attr(data-label); display: block; font-size: 0.7rem; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: .04em; }
  .crm-trunc { max-width: 100%; white-space: normal; }
}

[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* CRM-4 Customers and Finance */
.crm-health { display: grid; grid-template-columns: repeat(4, max-content); gap: 8px 12px; margin: 12px 0 16px; }
.crm-healthbtn { background: none; border: 0; padding: 0; margin: 0; font: inherit; cursor: pointer; border-radius: 999px; }
.crm-healthbtn .crm-chip { padding: 4px 12px; font-size: 0.8rem; }
.crm-healthbtn:hover .crm-chip { box-shadow: 0 0 0 2px rgba(124, 58, 237, .25); }
.crm-block { margin: 0 0 24px; }
.crm-block > h3 { margin: 0 0 8px; font-size: 1rem; }
.crm-tabpanel:focus { outline: none; }
.crm-offline td:first-child { box-shadow: inset 3px 0 0 #991b1b; }
.crm-plannedrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 0; border-bottom: 1px solid #e2e8f0; }
.crm-plannedname { flex: 1 1 180px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.bill-kpis--6 { grid-template-columns: repeat(3, 1fr); }
.crm-neg { color: #991b1b; font-weight: 700; }
.crm-ageing { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.crm-ageing a, .crm-ageing button { display: inline-flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; font: inherit; cursor: pointer; text-decoration: none; color: inherit; }
.crm-mono-wrap { word-break: break-all; }
@media (max-width: 992px) { .bill-kpis--6 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 576px) {
  .crm-health { grid-template-columns: 1fr 1fr; }
  .bill-kpis, .bill-kpis--6 { grid-template-columns: 1fr 1fr; }
  .crm-healthbtn, .crm-healthbtn .crm-chip { width: 100%; }
  .crm-healthbtn .crm-chip { min-height: 44px; justify-content: flex-start; white-space: normal; }
  .tabs { gap: 14px; }
  .tab { min-height: 44px; }
}

/* The hidden attribute must win over component display rules (.crm-sub, .crm-hint, ...). */
[hidden] { display: none !important; }

/* Operations (CRM-5): campaign drawer, snapshot columns, delivery rows */
.crm-drawer--xl { width: min(980px, 100%); }
.crm-snap { display: flex; align-items: center; gap: 3px; font-size: 0.65rem; font-weight: 600; color: #475569; text-transform: none; letter-spacing: 0; }
.crm-snap svg { width: 11px; height: 11px; }
.crm-rd-off .crm-rd { display: none; }
.crm-row-down { box-shadow: inset 3px 0 0 #991b1b; }
.crm-removed { text-decoration: line-through; }
.crm-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.crm-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; margin-top: 8px; }
.crm-moves li { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.money.strong { font-weight: 700; }
@media (max-width: 992px) { .crm-three { grid-template-columns: 1fr; } }
@media (max-width: 576px) {
  .crm-two { grid-template-columns: 1fr; }
  .crm-rd-off .crm-rd { display: block; } /* mobile cards always show rate details */
  .crm-row-down { box-shadow: none; border-left: 3px solid #991b1b !important; }
}

/* ===== Redesign (light theme): design tokens + shell. Reference: design/Signtral CRM.html. Overrides admin.css tokens/classes for the CRM only. ===== */
:root {
  --bg: #F5F3FF; --surface: #FFFFFF; --sunken: #F3F0FC; --line: #E9E4F7; --line-strong: #D8D0F0;
  --ink: #1A1433; --ink-2: #463F63; --muted: #6A6387; --faint: #A59DC2; /* --muted darkened from #756E91 for AA on tinted surfaces; --faint is decorative only, never text */
  --accent: #7C3AED; --accent-2: #C026D3; --accent-soft: #F1EAFF; --accent-line: #DCCBFD; --accent-text: #6D28D9;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --good-ink: #047857; --warn-ink: #9A4A08; --bad-ink: #BE123C; --info-ink: #1D4ED8; /* text on the soft status tints (AA); the base colours stay for fills and dots */
  --good: #059669; --good-soft: #DCFCE7; --warn: #C2610C; --warn-soft: #FFEDD5; --bad: #E11D48; --bad-soft: #FFE4E8;
  --info: #2563EB; --info-soft: #DBEAFE; --idle: #6B6585; --idle-soft: #EFEDF6;
  --c1: #7C3AED; --c2: #EC4899; --c3: #F59E0B; --c4: #06B6D4; --c5: #10B981; --c6: #3B82F6; --c7: #F43F5E;
  --shadow: 0 1px 2px rgba(28,24,48,.05), 0 8px 24px -12px rgba(28,24,48,.18);
  --shadow-lg: 0 24px 64px -16px rgba(28,24,48,.35);
  --f-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* admin.css variable names, remapped so every existing view picks the new palette up */
  --bg-main: var(--bg); --bg-surface: var(--surface);
  --text-primary: var(--ink); --text-secondary: var(--ink-2); --text-muted: var(--muted);
  --border: var(--line); --accent-dark: var(--accent-text); --accent-light: var(--accent-line);
  --success: var(--good); --warning: var(--warn); --danger: var(--bad);
}
html { color-scheme: light; }
body { font-family: var(--f-ui); font-size: 13.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; background: var(--bg); color: var(--ink); }
.mono, .num { font-family: var(--f-mono); font-size: 12.5px; }
.num, .money, table td { font-variant-numeric: tabular-nums; }

/* Sidebar */
.sidebar { width: 236px; flex: none; background: var(--surface); color: var(--ink-2); border-right: 1px solid var(--line); box-shadow: none; }
.sidebar-header { padding: 16px 16px 12px; border-bottom: 0; margin: 0; color: var(--ink); }
.crm-brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--grad); display: grid; place-items: center; color: #fff; flex: none; }
.crm-brand-mark svg { width: 16px; height: 16px; }
.crm-brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.crm-brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.sidebar-nav { padding: 4px 10px 12px; gap: 14px; }
.crm-nav-group { margin-top: 0; }
.crm-nav-group-title { font-size: 10.5px; letter-spacing: .08em; color: var(--muted); padding: 6px 8px 4px; }
.nav-item { position: relative; padding: 6px 8px; gap: 10px; border-radius: 6px; color: var(--ink-2); font-size: 13px; font-weight: 500; transition: background .12s, color .12s; }
.nav-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.nav-item:hover { background: var(--sunken); color: var(--ink); }
.nav-item.active { background: linear-gradient(90deg, var(--accent-soft), rgba(241,234,255,0) 90%); color: var(--accent-text); font-weight: 600; box-shadow: none; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 4px; bottom: 4px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-item.active svg { color: var(--accent); }
.crm-badge { margin-left: auto; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.sidebar-footer { padding: 8px 0 12px; border-top: 1px solid var(--line); }
.sidebar-footer .crm-user { color: var(--ink-2); }
.sidebar-footer .crm-user button { color: var(--muted); }
.sidebar-footer .crm-user button:hover { color: var(--ink); background: var(--sunken); }

/* Top bar */
.top-header { height: 56px; margin: 0; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); gap: 12px; }
.header-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.crm-today { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.view-container { padding: 24px; }
.crm-skip { color: var(--ink); }

/* Cards, tables, buttons, pills */
.card { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); transition: none; }
.card:hover { transform: none; box-shadow: var(--shadow); border-color: var(--line); }
.table-wrap { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
th { background: var(--sunken); color: var(--muted); font-size: 11px; letter-spacing: .06em; box-shadow: none; border-bottom: 1px solid var(--line); }
td { font-weight: 400; border-bottom: 1px solid var(--line); }
tbody tr:nth-child(even) td { background: transparent; }
tbody tr:hover td { background: var(--sunken); }
.btn { border-radius: 8px; font-size: 12.5px; }
.btn-primary { background: var(--grad); box-shadow: 0 4px 12px -4px rgba(124,58,237,.45); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.06); transform: none; box-shadow: 0 6px 16px -4px rgba(124,58,237,.5); }
.btn-secondary { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: var(--sunken); }
.crm-chip { font-weight: 600; }
.crm-chip--grey { background: var(--idle-soft); color: var(--idle); }
.crm-chip--blue { background: var(--info-soft); color: var(--info-ink); }
.crm-chip--violet { background: var(--accent-soft); color: var(--accent-text); }
.crm-chip--amber { background: var(--warn-soft); color: var(--warn-ink); }
.crm-chip--green { background: var(--good-soft); color: var(--good-ink); }
.crm-chip--red { background: var(--bad-soft); color: var(--bad-ink); }
.crm-chip--teal { background: var(--info-soft); color: var(--info-ink); }
.crm-drawer, .crm-col, .crm-card, .crm-fieldset, .crm-picklist { border-color: var(--line); }
.crm-col { background: var(--sunken); }

/* Mobile: sidebar becomes a slide-in menu under 820px; no page-level horizontal scroll */
.sidebar-toggle { display: none; }
@media (max-width: 992px) { .sidebar { width: 236px; } .sidebar-toggle { display: none !important; } }
@media (max-width: 820px) {
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; transform: translateX(-100%); transition: transform .22s ease; z-index: 9500; box-shadow: none; }
  .sidebar.active { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: inline-flex !important; align-items: center; justify-content: center; width: 40px; height: 40px; margin-right: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); cursor: pointer; }
  .crm-scrim { position: fixed; inset: 0; background: rgba(26,20,51,.4); z-index: 9400; }
  .top-header { padding: 0 12px; }
  .view-container { padding: 16px 12px; }
  .main-content { min-width: 0; }
}
@media (min-width: 821px) { .crm-scrim { display: none; } }
.crm-badge { font-family: var(--f-mono); font-weight: 600; }
.crm-chip { height: 21px; padding: 0 8px; font-size: 11.5px; line-height: 1; }
.crm-avatar-sm { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; text-transform: uppercase; }
.sidebar-footer .crm-user { gap: 10px; justify-content: flex-start; }
.sidebar-footer .crm-user #crm-username { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }

/* ===== Phase 2: shared components ===== */
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card-flat { padding: 0; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 13.5px; margin: 0; font-weight: 600; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px 16px; }

.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi-top { display: flex; align-items: center; gap: 8px; }
.kpi-chip { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.kpi-chip svg { width: 15px; height: 15px; }
.kpi-good { background: var(--good-soft); color: var(--good-ink); } .kpi-warn { background: var(--warn-soft); color: var(--warn-ink); }
.kpi-bad { background: var(--bad-soft); color: var(--bad-ink); } .kpi-info { background: var(--info-soft); color: var(--info-ink); }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi-value { font-family: var(--f-mono); font-size: 24px; font-weight: 500; letter-spacing: -.02em; color: var(--ink); }
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-height: 28px; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.spark { width: 96px; height: 28px; flex: none; }

.seg { display: inline-flex; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; flex-wrap: wrap; }
.seg button { height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-weight: 550; font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--accent-text); box-shadow: 0 1px 2px rgba(28,24,48,.1); }
.seg .c { font-family: var(--f-mono); font-size: 11px; color: var(--muted); background: var(--sunken); border-radius: 8px; padding: 0 6px; line-height: 16px; }
.seg button.on .c { background: var(--accent-soft); color: var(--accent-text); }

.dt-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.dt-search { margin-left: auto; position: relative; display: flex; align-items: center; }
.dt-search svg { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--muted); }
.dt-search input { padding-left: 30px; min-width: 220px; height: 32px; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; display: inline-flex; gap: 4px; }
.th-sort:hover { color: var(--ink); }
.th-sort .arrow { color: var(--accent); min-width: 8px; }
th.num, td.num { text-align: right; }
tr.is-click { cursor: pointer; } tr.is-click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.chart-wrap { min-width: 0; } .chart { width: 100%; height: auto; display: block; }
.chart-lbl { font-size: 9.5px; fill: var(--muted); font-family: var(--f-ui); } .chart-val { font-size: 8.5px; fill: var(--ink-2); font-family: var(--f-mono); }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; } .donut { width: 120px; height: 120px; flex: none; }
.donut-c { font-size: 11px; font-family: var(--f-mono); fill: var(--ink); } .ring { width: 120px; height: 120px; } .ring-c { font-size: 18px; font-family: var(--f-mono); fill: var(--ink); font-weight: 500; }
.legend { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 8px; } .legend b { margin-left: auto; padding-left: 12px; font-weight: 500; color: var(--ink); }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.funnel-row small { grid-column: 2 / 4; color: var(--muted); margin-top: -4px; }
.funnel-bar { height: 10px; background: var(--sunken); border-radius: 5px; overflow: hidden; } .funnel-bar i { display: block; height: 100%; border-radius: 5px; }

.search-trigger { flex: 1; max-width: 440px; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunken); color: var(--muted); cursor: pointer; text-align: left; font: inherit; }
.search-trigger:hover { border-color: var(--line-strong); } .search-trigger svg { width: 15px; height: 15px; flex: none; } .search-trigger kbd { margin-left: auto; }
kbd { font-family: var(--f-mono); font-size: 10.5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); background: var(--surface); }
.top-header .crm-today { margin-left: 0; }
.top-header .header-title { flex: none; margin-right: 8px; }
.top-header .crm-spacer { flex: 1; }
.new-wrap { position: relative; } .new-wrap .btn { height: 32px; }
.new-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 170px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 4px; z-index: 9100; }
.new-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; background: transparent; border-radius: 6px; font: inherit; color: var(--ink-2); cursor: pointer; text-align: left; }
.new-menu button:hover, .new-menu button:focus-visible { background: var(--accent-soft); color: var(--accent-text); } .new-menu svg { width: 15px; height: 15px; }

.cmdk-overlay { position: fixed; inset: 0; background: rgba(26,20,51,.45); z-index: 10500; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 12px 0; }
.cmdk { width: 100%; max-width: 560px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); overflow: hidden; }
.cmdk-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); } .cmdk-top svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.cmdk-input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--ink); min-width: 0; }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.cmdk-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.cmdk-list li svg { width: 16px; height: 16px; color: var(--muted); flex: none; } .cmdk-list li.on { background: var(--accent-soft); color: var(--accent-text); } .cmdk-list li.on svg { color: var(--accent); }
.cmdk-l { flex: 1; min-width: 0; display: flex; flex-direction: column; } .cmdk-l small { color: var(--muted); font-size: 11.5px; }
.cmdk-h { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cmdk-list .cmdk-empty { cursor: default; color: var(--muted); justify-content: center; }
@media (max-width: 820px) { .search-trigger span, .search-trigger kbd { display: none; } .search-trigger { flex: none; width: 36px; justify-content: center; padding: 0; } .crm-today { display: none; } .dt-search { margin-left: 0; width: 100%; } .dt-search input { width: 100%; } }

.btn svg { width: 15px; height: 15px; flex: none; }

/* ===== Phase 3: Today dashboard ===== */
.crm-today-page { max-width: 1280px; display: flex; flex-direction: column; gap: 18px; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 22px 24px; border-radius: 14px; color: #fff; background: linear-gradient(120deg, #7C3AED 0%, #C026D3 60%, #DB2777 100%); box-shadow: var(--shadow); }
.hero h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; font-weight: 650; color: #fff; }
.hero p { margin: 4px 0 0; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-stat { display: flex; flex-direction: column; gap: 2px; min-width: 150px; padding: 10px 14px; border-radius: 10px; background: rgba(255,255,255,.16); color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.22); }
.hero-stat:hover { background: rgba(255,255,255,.24); } .hero-stat span { font-size: 12px; } .hero-stat b { font-family: var(--f-mono); font-size: 19px; font-weight: 500; }
.hero a:focus-visible { outline-color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.flow a { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); position: relative; }
.flow a:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.flow li:not(:last-child) a::after { content: "›"; position: absolute; right: -9px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 16px; z-index: 1; }
.flow-ic { width: 24px; height: 24px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; } .flow-ic svg { width: 14px; height: 14px; }
.flow-l { color: var(--muted); font-size: 12px; } .flow b { font-family: var(--f-mono); font-size: 20px; font-weight: 500; }
.flow-alert { font-size: 11px; font-weight: 600; color: var(--bad-ink); background: var(--bad-soft); border-radius: 8px; padding: 0 6px; align-self: flex-start; }
.grid-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.occ { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; } .occ .muted { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.slotgrid { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; min-width: 180px; } .slotgrid i { aspect-ratio: 1; border-radius: 3px; background: var(--sunken); border: 1px solid var(--line); } .slotgrid i.on { background: var(--grad); border-color: transparent; }
.rows { list-style: none; margin: 0; padding: 0; } .rows li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); } .rows li:last-child { border-bottom: 0; }
.rows li > div { flex: 1; min-width: 0; } .rows a { font-weight: 550; color: var(--ink); text-decoration: none; } .rows a:hover { color: var(--accent-text); text-decoration: underline; }
.rows small { display: block; color: var(--muted); font-size: 12px; } .rows .mono { color: var(--ink-2); white-space: nowrap; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } .flow { grid-template-columns: repeat(4, minmax(0, 1fr)); } .flow li a::after { display: none; } }
@media (max-width: 700px) { .kpis, .grid-cards, .grid-two { grid-template-columns: minmax(0, 1fr); } .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero-stat { min-width: 0; flex: 1 1 140px; } .rows li { flex-wrap: wrap; } }

/* ===== Phase 4: Leads + Deals ===== */
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 5px; background: var(--sunken); color: var(--ink-2); border: 1px solid var(--line); }
.crm-tabsrow { margin-bottom: 12px; overflow-x: auto; }
.crm-more { margin: 8px 0 12px; } .crm-more summary { cursor: pointer; color: var(--accent-text); font-weight: 550; font-size: 12.5px; width: max-content; }
tr.is-closed td { color: var(--muted); }
.crm-page .bill-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.crm-page .bill-toolbar .form-control { max-width: 340px; height: 34px; }
.crm-card.is-overdue { border-left: 3px solid var(--bad); }
.crm-dealcharts { margin-bottom: 14px; }
.bill-seg { display: inline-flex; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.bill-seg button { height: 26px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-weight: 550; cursor: pointer; }
.bill-seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent-text); box-shadow: 0 1px 2px rgba(28,24,48,.1); }
td[data-label="Phone"] { white-space: nowrap; }
.dt th, .dt td { padding: 11px 8px; } .dt td .mono { white-space: nowrap; } .dt .th-sort { white-space: nowrap; }
th.num .th-sort { margin-left: auto; }

/* ===== Phase 6: Gantt, screen cards ===== */
.gantt { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow-x: auto; }
.gantt-row { display: grid; grid-template-columns: 200px minmax(520px, 1fr); border-bottom: 1px solid var(--line); min-width: 760px; } .gantt-row:last-child { border-bottom: 0; }
.gantt-head { background: var(--sunken); position: sticky; top: 0; }
.gantt-lbl { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; border-right: 1px solid var(--line); }
.gantt-lbl a, .gantt-lbl strong { font-weight: 600; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .gantt-lbl a:hover { color: var(--accent-text); text-decoration: underline; }
.gantt-lbl small { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-track { position: relative; min-height: 44px; } .gantt-head .gantt-track { min-height: 34px; }
.gantt-months { display: flex; height: 100%; } .gantt-months span { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--muted); padding: 10px 8px; border-left: 1px solid var(--line); text-transform: uppercase; } .gantt-months span:first-child { border-left: 0; }
.gantt-grid { position: absolute; inset: 0; display: flex; } .gantt-grid i { border-left: 1px solid var(--line); } .gantt-grid i:first-child { border-left: 0; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); z-index: 2; opacity: .8; }
.gantt-bar { position: absolute; top: 9px; height: 26px; border: 0; border-radius: 7px; padding: 0 8px; font: inherit; font-size: 11.5px; font-weight: 600; text-align: left; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; z-index: 1; border: 1px solid transparent; }
.gantt-bar:hover { filter: brightness(.96); box-shadow: 0 2px 8px -2px rgba(28,24,48,.3); }
.gantt-idle { background: var(--idle-soft); color: var(--idle); border-color: var(--line-strong); } .gantt-warn { background: var(--warn-soft); color: var(--warn-ink); border-color: #F6C79B; }
.gantt-good { background: var(--good-soft); color: var(--good-ink); border-color: #9FDDBE; } .gantt-info { background: var(--info-soft); color: var(--info-ink); border-color: #A9C6F3; } .gantt-accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.scr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.scr-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.scr-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; } .scr-head small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.scr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; } .scr-stat span { display: block; color: var(--muted); font-size: 11.5px; } .scr-stat b { font-family: var(--f-mono); font-size: 14px; font-weight: 500; }
.slotgrid--20 { grid-template-columns: repeat(20, 1fr); min-width: 0; }

/* ===== Phase 7: finance ===== */
.crm-warnbox { display: flex; align-items: flex-start; gap: 10px; background: var(--warn-soft); border: 1px solid #F6C79B; color: var(--warn-ink); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.crm-warnbox svg { width: 18px; height: 18px; flex: none; margin-top: 1px; } .crm-warnbox span { color: var(--ink-2); } .crm-warnbox strong { color: var(--warn-ink); }

/* ===== Review fixes: a11y ===== */
.form-control:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg button, .bill-seg button { min-height: 28px; }
@media (max-width: 820px), (pointer: coarse) { .seg button, .bill-seg button { min-height: 40px; padding: 0 14px; } }
/* Off-canvas sidebar is inert only where it really is off-canvas (the slide-in menu exists at <= 820px, never on wider touch screens). */
@media (max-width: 820px) {
  .sidebar:not(.active) { visibility: hidden; }
  .sidebar.active { visibility: visible; }
}

/* ===== CRM-7 (Costs & Rent) styles, merged from version4 ===== */
/* Costs & Rent (UX 13.1, 14-18) */
.crm-moneyfield { display: flex; align-items: center; border: 1px solid var(--border, #cbd5e1); border-radius: 8px; background: #fff; }
.crm-moneyfield:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.crm-moneyfield .form-control { border: 0; box-shadow: none; outline: none; flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.crm-moneyunit { padding: 0 4px 0 12px; color: #475569; font-weight: 600; }
.crm-moneyfield.is-suffix .crm-moneyunit { padding: 0 12px 0 4px; }
.form-group [aria-invalid="true"], .crm-moneyfield:has([aria-invalid="true"]) { border-color: #991b1b; }
.crm-lbl { font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.crm-totalline { font-weight: 700; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.crm-seg button[aria-checked="true"] { background: var(--accent); color: #fff; }
.bill-seg.crm-seg { flex-wrap: wrap; }
.crm-fileinput { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.crm-fileinput:focus-visible + .crm-attach { outline: 2px solid var(--accent); outline-offset: 2px; }
.crm-attach { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.crm-proofrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.crm-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.crm-proofname { font-weight: 600; word-break: break-all; }
fieldset.crm-bare { border: 0; padding: 0; margin: 0; min-width: 0; }
.crm-switch { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 6px 0; font: inherit; font-weight: 600; cursor: pointer; min-height: 44px; }
.crm-switch .crm-knob { width: 40px; height: 22px; border-radius: 999px; background: #94a3b8; position: relative; transition: background .15s; flex: none; }
.crm-switch .crm-knob::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.crm-switch[aria-checked="true"] .crm-knob { background: var(--accent); }
.crm-switch[aria-checked="true"] .crm-knob::after { transform: translateX(18px); }
.crm-totals { position: sticky; bottom: 0; background: #fff; border-top: 1px solid #e2e8f0; padding: 10px 4px; font-weight: 600; font-variant-numeric: tabular-nums; z-index: 2; }
tr.crm-overdue td:first-child { box-shadow: inset 3px 0 0 #991b1b; }
tr.crm-dim td { color: #475569; }
tr.is-new td { background: #f5f3ff; }
.crm-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.crm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }
.crm-rentcard { padding: 16px; }
.crm-statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 12px 0; }
.crm-statval { font-size: 1.05rem; }
.crm-genresult { margin: 4px 0 8px; font-weight: 600; }
.crm-genresult.is-warn { color: #92400e; }
.crm-badge { margin-left: auto; background: #991b1b; color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 1px 8px; }
.crm-lockicon { display: inline-flex; align-items: center; color: #475569; padding: 0 4px; }
.crm-lockicon svg { width: 16px; height: 16px; }
.crm-fab { display: none; }
.crm-hide-sm { }
@media (max-width: 576px) {
  .crm-hide-sm { display: none !important; }
  .crm-fab { display: inline-flex; align-items: center; gap: 8px; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); height: 56px; padding: 0 22px; border-radius: 999px; border: 2px solid #fff; background: var(--accent); color: #fff; font: inherit; font-weight: 700; box-shadow: 0 8px 20px rgba(15,23,42,.3); z-index: 8000; cursor: pointer; }
  body:has(.crm-drawer) .crm-fab, body:has(.modal-overlay) .crm-fab { display: none; }
  #main-content { padding-bottom: 88px; }
  .crm-drawer.crm-sheet { top: auto; height: 92%; border-radius: 16px 16px 0 0; border-left: 0; box-shadow: 0 -8px 30px rgba(15,23,42,.25); }
  .crm-drawer.crm-sheet .form-control, .crm-drawer.crm-sheet select, .modal .form-control { font-size: 16px; min-height: 48px; }
  .bill-seg.crm-seg button { min-height: 48px; flex: 1 1 33%; }
  .crm-switch { min-height: 48px; }
  .crm-totals { position: static; }
  .crm-statgrid { grid-template-columns: 1fr 1fr; }
}

.crm-fab.is-kbd { display: none !important; }

/* CRM-8: dashboard, charts, profit, alerts, social (UX 3, 17) */
:root { --ch-0: #7C3AED; --ch-1: #b45309; --ch-2: #15803d; --ch-3: #0e7490; --ch-4: #b91c1c; --ch-5: #64748b; --ch-6: #1d4ed8; --ch-7: #a21caf; }
.ch-k0 { --c: var(--ch-0); } .ch-k1 { --c: var(--ch-1); } .ch-k2 { --c: var(--ch-2); } .ch-k3 { --c: var(--ch-3); }
.ch-k4 { --c: var(--ch-4); } .ch-k5 { --c: var(--ch-5); } .ch-k6 { --c: var(--ch-6); } .ch-k7 { --c: var(--ch-7); }
.ch-fill { fill: var(--c); } .ch-line { stroke: var(--c); fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.ch-pat { stroke: #fff; stroke-width: 1.4; opacity: .7; fill: none; } .ch-pat-f { fill: #fff; opacity: .8; }
.ch-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ch-svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch-svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.ch-grid { stroke: #e2e8f0; stroke-width: 1; } .ch-zero { stroke: #475569; stroke-width: 1.25; }
.ch-t { font: 12px Inter, system-ui, sans-serif; fill: #334155; } .ch-ax { fill: #475569; } .ch-val { font-weight: 700; fill: #0f172a; font-size: 11px; } .ch-big { font-size: 20px; font-weight: 800; fill: #0f172a; }
.ch-hit { fill: transparent; cursor: default; } .ch-hit.is-active { fill: rgba(124,58,237,.10); }
.ch-slice.is-active, .ch-bar.is-active { stroke: #0f172a; stroke-width: 2; }
.ch-bar { stroke: transparent; }
.ch-fig { position: relative; min-height: 40px; } .ch-main { min-width: 0; }
.ch-tip { position: absolute; z-index: 5; pointer-events: none; background: #0f172a; color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 18px rgba(15,23,42,.3); max-width: 240px; }
.ch-tip-h { font-weight: 700; margin-bottom: 4px; } .ch-tip-r { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ch-tip .ch-swb { stroke: #fff; } .ch-tip .ch-line { stroke: #fff; } .ch-tip .ch-fill { fill: #fff; }
.ch-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.82rem; color: #334155; }
.ch-legend li { display: inline-flex; align-items: center; gap: 6px; } .ch-ld { color: #475569; }
.ch-swb { stroke: #475569; stroke-width: 0.75; }
.ch-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; } .ch-head h3 { margin: 0; font-size: 1rem; }
.ch-toggle { padding: 4px 12px; font-size: 0.8rem; } .ch-toggle[aria-pressed="true"] { background: var(--accent); color: #fff; }
.ch-cap { margin: 4px 0 8px; } .ch-table { margin-top: 10px; } .ch-table.sr-only { position: absolute; }
.ch-spark { vertical-align: middle; }
.crm-chart { margin-bottom: 18px; min-width: 0; }
.crm-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; align-items: start; }
.crm-w { min-width: 0; } .crm-w:focus { outline: none; } .crm-w .card { margin-bottom: 18px; }

.crm-dash-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.crm-filterbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin-bottom: 8px; }
.crm-filterbar .form-group { margin: 0; } .crm-filterbar .form-control { min-width: 150px; }
.crm-presets { display: flex; flex-wrap: wrap; gap: 6px; } .crm-filterbar .bill-field-err { flex: 1 1 100%; }
.crm-tabs { overflow-x: auto; gap: 18px; scrollbar-width: thin; } .bill-tabs { overflow-x: auto; max-width: 100%; }
.crm-tabs .tab { padding: 10px 4px; min-height: 44px; }
.crm-tabpanel { outline-offset: 4px; }
.crm-tile-link { font-weight: 800; font-size: inherit; color: #0f172a; text-decoration: none; } .crm-tile-link:hover { text-decoration: underline; color: var(--accent-dark); }
.crm-tile-un { font-size: 1rem; font-weight: 700; color: #475569; }
.crm-delta { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: #475569; margin-top: 4px; } .crm-delta svg { width: 14px; height: 14px; flex: none; }
.crm-delta.is-good { color: #065f46; } .crm-delta.is-bad { color: #991b1b; }
.crm-good { color: #065f46; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.crm-info { min-width: 28px; min-height: 28px; } .crm-info svg { width: 16px; height: 16px; }

.crm-alerts h4.crm-section { margin: 14px 0 8px; font-size: 0.9rem; }
.crm-alert-sum { font-weight: 700; margin: 0 0 8px; }
.crm-alert-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.crm-alert-cell { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid #e2e8f0; border-left: 3px solid #cbd5e1; border-radius: 12px; background: #fff; color: inherit; text-decoration: none; min-height: 44px; }
.crm-alert-cell:hover { box-shadow: 0 2px 10px rgba(15,23,42,.08); }
.crm-alert-cell--high { border-left-color: #991b1b; } .crm-alert-cell--medium { border-left-color: #b45309; } .crm-alert-cell--low { border-left-color: #64748b; }
.crm-alert-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; } .crm-alert-top .crm-code { margin: 0; }
.crm-alert-title { font-weight: 700; font-size: 0.9rem; } .crm-alert-count { font-size: 1.6rem; font-weight: 800; color: #0f172a; font-variant-numeric: tabular-nums; }
.crm-alert-ok { display: flex; gap: 14px; align-items: center; padding: 18px; } .crm-alert-ok svg { color: #065f46; width: 28px; height: 28px; }
.crm-alert-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; } .crm-alert-h { margin: 6px 0; font-size: 1.2rem; } .crm-alert-h:focus { outline: none; }
.crm-how { margin: 8px 0 14px; } .crm-how summary { cursor: pointer; font-weight: 600; min-height: 32px; } .crm-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }

tr.crm-loss td:first-child { box-shadow: inset 3px 0 0 #991b1b; }
.crm-sorter { font-weight: 700; color: inherit; min-height: 32px; }
th.money .crm-sorter { text-align: right; }
.crm-indent { padding-left: 22px !important; font-weight: 400; }
.crm-stmt-key th, .crm-stmt-key td { font-weight: 700; background: #f8fafc; } .crm-stmt-sub th, .crm-stmt-sub td { border-top: 1px solid #cbd5e1; font-weight: 600; }
.crm-stmt-h th { background: #fff; color: #334155; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; padding-top: 14px; }

.crm-soon { max-width: 560px; margin: 24px auto; text-align: center; padding: 36px 28px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.crm-soon h2 { margin: 0; font-size: 1.4rem; } .crm-soon h2:focus { outline: none; }
.crm-soon-icon { width: 72px; height: 72px; border-radius: 50%; background: #ede9fe; color: #5b21b6; display: flex; align-items: center; justify-content: center; } .crm-soon-icon svg { width: 34px; height: 34px; }

@media (max-width: 992px) { .crm-grid2 { grid-template-columns: 1fr; } .crm-alert-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 576px) {
  .crm-alert-grid { grid-template-columns: 1fr; }
  .crm-filterbar .form-group, .crm-filterbar .form-control { width: 100%; }
  .crm-presets .btn, .ch-toggle, .crm-sorter, .crm-info { min-height: 44px; }
  .bill-seg button { min-height: 44px; }
  .bill-kpis.crm-tiles { grid-template-columns: 1fr 1fr; }
  .crm-tile .bill-kpi-value { font-size: 1.15rem; word-break: break-word; }
}
@media print { .ch-toggle, .crm-filterbar { display: none !important; } }
.crm-page tbody th[scope="row"], .ch-table tbody th[scope="row"] { text-transform: none; letter-spacing: 0; font-weight: 600; background: transparent; border-bottom: 1px solid #f1f5f9; color: inherit; text-align: left; font-size: inherit; }
.crm-stmt-h th[scope="row"] { text-transform: uppercase; letter-spacing: .04em; font-size: 0.78rem; color: #334155; }
.crm-indent { font-weight: 400 !important; }
@media (max-width: 576px) {
  .crm-filterbar .form-control, #mg-city { min-height: 44px; font-size: 16px; }
  .crm-how summary { min-height: 44px; display: flex; align-items: center; }
  .crm-check { min-height: 44px; } .crm-check input { width: 22px; height: 22px; }
}
