:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7873;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --hover: rgba(11, 11, 11, 0.04);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --seq-1: #1c5cab;
  --seq-2: #2a78d6;
  --seq-3: #5598e7;
  --seq-4: #86b6ef;
  --pos: #2a78d6;
  --neg: #e34948;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --bad-text: #b42f2f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #96948d;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --hover: rgba(255, 255, 255, 0.05);
    --accent: #3987e5;
    --accent-soft: #17283d;
    --series-1: #3987e5;
    --series-2: #d95926;
    --seq-1: #86b6ef;
    --seq-2: #5598e7;
    --seq-3: #2a78d6;
    --seq-4: #184f95;
    --pos: #3987e5;
    --neg: #e66767;
    --good-text: #0ca30c;
    --bad-text: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --text: #f0efec; --text-2: #c3c2b7; --muted: #96948d;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10); --hover: rgba(255, 255, 255, 0.05);
  --accent: #3987e5; --accent-soft: #17283d; --series-1: #3987e5; --series-2: #d95926;
  --seq-1: #86b6ef; --seq-2: #5598e7; --seq-3: #2a78d6; --seq-4: #184f95; --pos: #3987e5; --neg: #e66767;
  --good-text: #0ca30c; --bad-text: #e66767; --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--page); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text-2); font-weight: 600; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.boot { padding: 40px; color: var(--muted); }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* buttons + inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad-text); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn .ic { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); }
label.field.full { grid-column: 1 / -1; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); }
.req { color: var(--bad-text); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-error { background: color-mix(in srgb, var(--critical) 12%, transparent); color: var(--bad-text); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 500; padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 18px 0 4px; font-size: 22px; }
.auth-card form { display: grid; gap: 14px; margin-top: 20px; }
.auth-card .switch { margin-top: 16px; color: var(--text-2); font-size: 13px; text-align: center; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand img { width: 28px; height: 28px; }

/* shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 14px; }
.sidebar .brand { padding: 2px 8px; }
.biz-switch select { width: 100%; font-weight: 600; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group h4 { margin: 8px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--text); }
.nav-link.active .ic { color: var(--accent); }
.me-box { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.me-box .who { min-width: 0; flex: 1; font-size: 13px; }
.me-box .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 28px; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .title { flex: 1; min-width: 0; }
.topbar .sub { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-btn { display: none; }
main { padding: 24px 28px 48px; max-width: 1440px; }
.scrim { display: none; }

/* cards + layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
.card-head .muted { font-size: 12px; }
.stack { display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tile .label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.tile .value { font-size: 24px; font-weight: 600; margin: 4px 0 2px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .foot { font-size: 12px; }
.tile.hero .value { font-size: 30px; }
@media (min-width: 640px) { .tile.hero { grid-column: span 2; } }
.delta { font-weight: 600; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--bad-text); }
.delta.flat { color: var(--muted); font-weight: 500; }
.period-note { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.loading { color: var(--muted); padding: 40px 8px; text-align: center; }

/* alerts */
.alerts { display: grid; gap: 2px; }
.alert { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.alert:hover { background: var(--hover); text-decoration: none; }
.alert .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.alert .txt { flex: 1; min-width: 0; }
.alert .txt small { display: block; color: var(--muted); }
.alert .n { font-weight: 600; font-variant-numeric: tabular-nums; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--text); }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.tone-good i, .dot.tone-good { background: var(--good); }
.tone-warn i, .dot.tone-warn { background: var(--warning); }
.tone-serious i, .dot.tone-serious { background: var(--serious); }
.tone-bad i, .dot.tone-bad { background: var(--critical); }
.tone-info i, .dot.tone-info { background: var(--accent); }

/* tables */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 220px; max-width: 340px; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; margin: 0 -18px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface); position: sticky; top: 0; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .arrow { color: var(--accent); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface) 95%, var(--text)); }
.table tfoot td { font-weight: 600; border-bottom: 0; }
.table td.wrap { white-space: normal; min-width: 180px; }
.table .strong { font-weight: 600; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.pnl td:first-child { position: sticky; left: 0; background: var(--surface); }
.pnl tr.sub td { color: var(--text-2); }
.pnl tr.sub td:first-child { padding-left: 32px; }
.pnl tr.total td { font-weight: 600; border-top: 1px solid var(--axis); }
.pnl tr.section td { font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 16px; }

/* charts */
.chart { width: 100%; min-height: 40px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--hover); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; border-radius: 6px; }
.hbar:hover { background: var(--hover); }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.hbar-track { height: 14px; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; min-width: 64px; }
.hbar-value small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.viz-tip { position: fixed; z-index: 100; display: none; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 140px; }
.viz-tip .tip-title { font-weight: 600; margin-bottom: 4px; }
.viz-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.viz-tip .tip-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.viz-tip .key { width: 8px; height: 8px; border-radius: 2px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.35); display: grid; place-items: start center; padding: 6vh 16px 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); }
.modal.wide { max-width: 860px; }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal > header h2 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal > footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal > footer .spacer { flex: 1; }
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.summary-strip .tile { padding: 10px 12px; background: var(--surface-2); border: 0; }
.summary-strip .tile .value { font-size: 18px; }
.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 0 6px 6px 0; }
.items-table td { padding: 0 6px 6px 0; vertical-align: top; }
.items-table input, .items-table select { width: 100%; }
.items-table .qty { width: 70px; }
.items-table .price { width: 110px; }
.totals { margin-left: auto; width: min(100%, 280px); display: grid; gap: 4px; font-size: 13px; margin-top: 8px; }
.totals div { display: flex; justify-content: space-between; }
.totals .grand { font-weight: 700; font-size: 15px; border-top: 1px solid var(--grid); padding-top: 6px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; }
.toast { background: var(--text); color: var(--page); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; max-width: 360px; }
.toast.error { background: var(--critical); color: #fff; }

/* activity */
.activity { display: grid; gap: 0; }
.activity .row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.activity .row:last-child { border-bottom: 0; }
.activity .when { margin-left: auto; color: var(--muted); white-space: nowrap; font-size: 12px; }

/* forms + misc */
.form-ok { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); border-radius: 8px; padding: 8px 12px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; }
.seg .ic { width: 15px; height: 15px; }
kbd { font: 11px/1 var(--font); padding: 3px 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }

/* search */
.search-btn { display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font: inherit; cursor: pointer; }
.search-btn:hover { color: var(--text); }
.search-btn span { flex: 1; text-align: left; }
.modal.search-modal { max-width: 640px; }
.search-modal .modal-body { padding: 0; }
.search-box { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-box input { border: 0; outline: none; flex: 1; font-size: 16px; padding: 4px 0; background: transparent; }
.search-results { max-height: 60vh; overflow-y: auto; padding: 8px; }
.search-results > .hint, .search-results > .empty { padding: 16px 8px; }
.sr-group h4 { display: flex; align-items: center; gap: 6px; margin: 8px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.sr-group h4 .ic { width: 14px; height: 14px; }
.sr-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.sr-item:hover, .sr-item.active { background: var(--accent-soft); text-decoration: none; }
.sr-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* meters, goals, onboarding */
.meter { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.meter-fill.warning { background: var(--warning); }
.meter-fill.critical { background: var(--critical); }
.meter-row { display: flex; align-items: center; gap: 8px; }
.meter-row .meter { flex: 1; }
.over { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--bad-text); margin-top: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.goals { display: grid; gap: 14px; }
.goal-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.goal-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.onboarding .meter { margin-bottom: 14px; }
.steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-weight: 500; }
.step:hover { background: var(--hover); text-decoration: none; }
.step.done { color: var(--muted); text-decoration: line-through; }
.step-check { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--axis); display: grid; place-items: center; flex: none; }
.step.done .step-check { background: var(--good); border-color: var(--good); color: #fff; }
.step-check .ic { width: 13px; height: 13px; stroke-width: 2.5; }

/* bulk + board */
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 12px; border-radius: 10px; background: var(--accent-soft); }
.bulkbar b { margin-right: 4px; }
.table th.sel, .table td.sel { width: 36px; padding-right: 0; }
.table tbody tr.selected td { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.clip { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 12px; }
.clip .ic { width: 13px; height: 13px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.board-col { background: var(--surface-2); border-radius: 10px; padding: 10px; min-height: 200px; border: 2px dashed transparent; }
.board-col.over { border-color: var(--accent); }
.board-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.board-cards { display: grid; gap: 8px; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; font-size: 13px; }
.board-card[draggable="true"] { cursor: grab; }
.board-card:hover { border-color: var(--axis); }
.board-card.dragging { opacity: 0.5; }
.board-meta { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* sample data */
.sample-box { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--grid); font-size: 13px; }
.sample-box > div { flex: 1 1 240px; }

/* files */
.form-files { margin-top: 20px; border-top: 1px solid var(--grid); padding-top: 16px; }
.files-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.files-head h3 { display: flex; align-items: center; gap: 6px; }
.files-head .ic { width: 15px; height: 15px; }
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.files li { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.files li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files li .muted { font-size: 12px; margin-left: auto; white-space: nowrap; }

/* customer profile */
.grid.profile { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); }
.grid.profile > .span-2 { grid-column: auto; }
.profile .tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.profile-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.profile-head h2 { font-size: 17px; margin-bottom: 4px; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; margin: 0; font-size: 13px; color: var(--text-2); }
.timeline { display: grid; }
.tl-item { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; border: 0; border-bottom: 1px solid var(--grid); background: none;
  padding: 10px 6px; font: inherit; color: inherit; cursor: pointer; border-radius: 6px; }
.tl-item:hover { background: var(--hover); }
.tl-item:last-child { border-bottom: 0; }
.tl-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); flex: none; }
.tl-icon .ic { width: 15px; height: 15px; }
.tl-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tl-title { font-weight: 500; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tl-meta { font-size: 12px; color: var(--muted); }
.tl-notes { font-size: 12px; color: var(--text-2); white-space: pre-wrap; }
.tl-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* printable invoice */
.print-wrap { background: var(--page); min-height: 100vh; padding: 24px 16px 48px; }
.print-actions { max-width: 800px; margin: 0 auto 16px; display: flex; gap: 8px; }
.invoice { max-width: 800px; margin: 0 auto; background: #fff; color: #111; border-radius: 12px; padding: 48px; box-shadow: var(--shadow); }
.invoice .muted { color: #6b6a66; }
.inv-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 36px; }
.inv-biz { font-size: 20px; font-weight: 700; }
.inv-title { text-align: right; }
.inv-title h1 { font-size: 28px; letter-spacing: 0.02em; text-transform: uppercase; }
.inv-paid { display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 999px; background: #e7f6e7; color: #006300; font-weight: 600; font-size: 12px; }
.inv-meta { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 28px; font-size: 14px; }
.invoice h3 { color: #6b6a66; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.inv-items { width: 100%; border-collapse: collapse; font-size: 14px; }
.inv-items th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #6b6a66; border-bottom: 2px solid #111; padding: 8px 0; }
.inv-items td { padding: 10px 0; border-bottom: 1px solid #e5e4df; }
.inv-items .num { text-align: right; }
.inv-totals { margin-top: 16px; font-size: 14px; }
.inv-totals .grand { border-top-color: #111; }
.inv-notes { margin-top: 28px; font-size: 13px; }
.inv-foot { margin-top: 40px; color: #6b6a66; font-size: 13px; text-align: center; }
@media print {
  body, .print-wrap { background: #fff !important; padding: 0; }
  .print-actions, #toasts { display: none !important; }
  .invoice { box-shadow: none; border-radius: 0; padding: 0; max-width: none; }
}

@media (max-width: 1100px) {
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .wide-md { grid-column: 1 / -1; }
  .wide-md .alerts { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 272px; transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--shadow); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.3); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .topbar .actions { width: 100%; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile.hero { grid-column: 1 / -1; }
  .tile { padding: 12px; }
  .tile .value { font-size: 20px; }
  main { padding: 16px 16px 40px; }
  .cols-2, .cols-3, .grid.profile { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice { padding: 24px; }
  .inv-head, .inv-meta { flex-direction: column; }
  .inv-title { text-align: left; }
  .search-btn kbd { display: none; }
  .table-wrap { margin: 0 -18px; }
  .toolbar .search { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
