/* Layout: sidebar + work area; summary tiles, then customer list on the left with the selected customer's controls on the right. */
:root {
  --bg: #f2f4f8; --surface: #ffffff; --surface-2: #f6f8fb; --line: #e1e6ed;
  --ink: #10151c; --ink-2: #4a5361; --ink-3: #6f7886;
  --accent: #1c5cab; --accent-ink: #ffffff; --accent-soft: #e4eefb;
  --side-bg: #111c2e; --side-ink: #d3dbe8; --side-ink-2: #8b98ad; --side-line: #22304a; --side-active: #1d2c47;
  --s1: #2a78d6; --track: #dfe5ee; --axis: #c5ccd6;
  --ok: #0ca30c; --warn: #d98e00; --bad: #d03b3b; --info: #2a78d6; --idle: #7b8492;
  --danger-ink: #b42323;
  --shadow: 0 1px 2px rgba(16,21,28,.06);
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #171b22; --surface-2: #1d222b; --line: #2a303b;
    --ink: #f1f4f8; --ink-2: #b3bcc9; --ink-3: #8a94a3;
    --accent: #6da7ec; --accent-ink: #0b1220; --accent-soft: #1a2a42;
    --side-bg: #0b0e13; --side-ink: #d3dbe8; --side-ink-2: #8b98ad; --side-line: #1e242e; --side-active: #1a2231;
    --s1: #3987e5; --track: #2a303b; --axis: #3a4250;
    --ok: #0ca30c; --warn: #fab219; --bad: #e66767; --info: #3987e5; --idle: #8a94a3;
    --danger-ink: #f08a8a;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #171b22; --surface-2: #1d222b; --line: #2a303b;
  --ink: #f1f4f8; --ink-2: #b3bcc9; --ink-3: #8a94a3;
  --accent: #6da7ec; --accent-ink: #0b1220; --accent-soft: #1a2a42;
  --side-bg: #0b0e13; --side-ink: #d3dbe8; --side-ink-2: #8b98ad; --side-line: #1e242e; --side-active: #1a2231;
  --s1: #3987e5; --track: #2a303b; --axis: #3a4250;
  --ok: #0ca30c; --warn: #fab219; --bad: #e66767; --info: #3987e5; --idle: #8a94a3;
  --danger-ink: #f08a8a;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-ink); display: flex; flex-direction: column; gap: 18px; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--s1); color: #fff; display: grid; place-items: center; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-ink-2); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--side-active); }
.nav a[aria-current="page"] { background: var(--side-active); color: #fff; font-weight: 600; }
.who { margin-top: auto; border-top: 1px solid var(--side-line); padding: 14px 8px 0; font-size: 12.5px; color: var(--side-ink-2); }
.who b { display: block; color: #fff; font-size: 13.5px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.top .date { color: var(--ink-3); font-size: 12.5px; }
.top-title { margin-right: auto; min-width: 0; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; height: 40px; width: 260px; color: var(--ink-3); }
.search input { border: 0; background: transparent; outline: 0; width: 100%; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--danger-ink); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: transparent; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm { height: 34px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
#menuBtn { display: none; }
.chip { font-size: 11.5px; font-weight: 600; color: var(--ink-2); border: 1px dashed var(--axis); border-radius: 99px; padding: 3px 10px; white-space: nowrap; }

.content { padding-block: 20px 40px; padding-inline: 24px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label { color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi-value small { font-size: 14px; font-weight: 600; color: var(--ink-3); margin-right: 3px; letter-spacing: 0; }
.kpi-foot { font-size: 12.5px; color: var(--ink-3); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 1px solid transparent; background: transparent; padding: 6px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tabs button:hover { background: var(--surface-2); }
.tabs button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.tabs button span { color: var(--ink-3); font-weight: 500; margin-left: 3px; }

.tbl-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 600px; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); padding: 10px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody tr[aria-selected="true"] { background: var(--accent-soft); }
.name-btn { border: 0; background: transparent; padding: 0; font-weight: 600; cursor: pointer; text-align: left; }
.sub { display: block; color: var(--ink-3); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.use { display: flex; flex-direction: column; gap: 5px; width: 92px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--c, var(--s1)); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: 99px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
[data-s="active"] { --c: var(--ok); } [data-s="due"] { --c: var(--warn); } [data-s="overdue"] { --c: var(--bad); } [data-s="hold"] { --c: var(--idle); }
.empty { padding: 28px 18px; color: var(--ink-3); text-align: center; }

/* Detail panel */
.detail { position: static; }
.d-head { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.d-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.d-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sec { border-top: 1px solid var(--line); padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.sec h3 { margin: 0; font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .field .lbl { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field input, .field select { height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 10px; width: 100%; }
.field .hint { font-size: 12px; color: var(--ink-3); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.note { font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.mods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 14px; }
.mod { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; font-weight: 500; cursor: pointer; }
.sw { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--track); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.sw:checked { background: var(--accent); }
.sw:checked::after { transform: translateX(14px); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.d-foot { border-top: 1px solid var(--line); padding: 14px 18px; display: flex; gap: 10px; justify-content: flex-end; }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 13px; z-index: 40; max-width: calc(100vw - 32px); }
.scrim { display: none; }

@media (max-width: 1240px) { .split { grid-template-columns: minmax(0, 1fr); } .detail { position: static; } }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .search { display: none; } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: 256px; height: auto; transform: translateX(-100%); transition: transform .2s ease; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  .side.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(8,12,18,.5); }
  #menuBtn { display: inline-flex; }
  .top { padding-inline: 16px; } .content { padding-inline: 16px; }
  .chip { display: none; }
}
@media (max-width: 480px) {
  .kpis { gap: 10px; } .kpi { padding: 13px 14px; } .kpi-value { font-size: 21px; }
  #addBtn span { display: none; } #addBtn { width: 40px; padding: 0; }
  .top h1 { font-size: 18px; } .mods { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .side, .sw, .sw::after { transition: none; } }
/* Login and signed-in shell additions on top of panel.css */
.auth { min-height: 100vh; display: grid; place-items: center; padding-block: 32px; padding-inline: 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 28px 26px; display: flex; flex-direction: column; gap: 18px; }
.auth-card .brand { padding: 0; color: var(--ink); }
.auth-card .brand small { color: var(--ink-3); }
.auth-card h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.error { color: var(--danger-ink); font-size: 12.5px; }
.field input[aria-invalid="true"] { border-color: var(--bad); }
.who form { margin-top: 10px; }
.who .btn { background: transparent; border-color: var(--side-line); color: var(--side-ink); width: 100%; }
.who .btn:hover { background: var(--side-active); }

/* Server-rendered customer pages */
.tabs a { padding: 6px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.tabs a:hover { background: var(--surface-2); }
.tabs a[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }
.tabs a span { color: var(--ink-3); font-weight: 500; margin-left: 3px; }
.name-link { font-weight: 600; }
.name-link:hover { text-decoration: underline; }
.search-form { display: contents; }
.split:not(:has(.detail)) { grid-template-columns: minmax(0, 1fr); }
img { max-width: 100%; }
.sec form { display: flex; flex-direction: column; gap: 12px; }
.sec details summary { list-style: none; display: inline-flex; }
.sec details summary::-webkit-details-marker { display: none; }
.sec details[open] summary { display: none; }
.form-card { max-width: 560px; padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.form-card form { display: flex; flex-direction: column; gap: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }
#toast { transition: opacity .3s; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }

/* Plans, payments and edit pages */
.kpis-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 720px; }
.form-title { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.form-text { margin: 0; color: var(--ink-2); font-size: 13px; max-width: 65ch; }
.form-card details summary { list-style: none; display: inline-flex; cursor: pointer; }
.form-card details summary::-webkit-details-marker { display: none; }
.form-card details[open] summary { display: none; }
.filter-form select { height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 10px; max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 12px; }
.btn[aria-disabled="true"] { opacity: .5; cursor: default; }
#toast.is-error { background: var(--bad); color: #fff; }
tbody tr { cursor: default; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.note-cell { white-space: normal; max-width: 260px; color: var(--ink-2); overflow-wrap: anywhere; }

/* Client app shell */
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-ink-2); padding: 10px 10px 6px; }
.plan { margin-top: auto; border: 1px solid var(--side-line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; }
.plan + .who { margin-top: 0; }
.plan-head { display: flex; flex-direction: column; gap: 1px; }
.plan-head b { font-size: 13.5px; color: #fff; }
.plan-head span, .plan-row span { color: var(--side-ink-2); }
.plan-row { display: flex; justify-content: space-between; gap: 8px; }
.plan-row b { white-space: nowrap; }
.plan .meter { background: var(--side-line); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.tile:hover { background: var(--surface-2); }
.tile b { font-size: 14.5px; }
.tile span { color: var(--ink-3); font-size: 12.5px; }
.tile.is-off { opacity: .6; }
.page-card { padding: 22px; display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.page-card h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.blocked { text-align: center; align-items: center; }
.role-tag { font-size: 12px; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }

/* Customers */
.field textarea { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 9px 10px; width: 100%; font: inherit; color: inherit; resize: vertical; }
.field textarea[aria-invalid="true"] { border-color: var(--bad); }
.kv-left { grid-template-columns: 130px minmax(0, 1fr); gap: 10px 16px; font-size: 14px; }
.kv-left dd { text-align: left; }
.page-card.alert { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.link { color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; }

/* Products */
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack .form-card { max-width: none; }

/* Orders */
:root { --violet: #4a3aa7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --violet: #9085e9; } }
:root[data-theme="dark"] { --violet: #9085e9; }

[data-o="pending"] { --c: var(--idle); }
[data-o="confirmed"] { --c: var(--info); }
[data-o="packed"] { --c: var(--violet); }
[data-o="dispatched"] { --c: var(--warn); }
[data-o="delivered"] { --c: var(--ok); }
[data-o="returned"] { --c: var(--bad); }
[data-o="cancelled"] { --c: var(--idle); }

.tag { font-size: 11px; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; margin-left: 6px; }
.card-foot { border-top: 1px solid var(--line); padding: 14px 18px; display: flex; justify-content: flex-end; }
.totals { min-width: 260px; font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; font-size: 15px; color: var(--ink); padding-top: 6px; border-top: 1px solid var(--line); }
.form-card .totals { min-width: 0; }

.item-rows { display: flex; flex-direction: column; gap: 10px; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 40px; gap: 10px; align-items: end; }
.item-row .btn.icon { height: 38px; }
.item-row:only-child .btn.icon { visibility: hidden; }
.item-row:not(:first-child) label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.pipe-scroll { overflow-x: auto; border-top: 1px solid var(--line); }
.pipe { display: grid; grid-template-columns: repeat(5, minmax(132px, 1fr)); min-width: 700px; }
.stage { padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--line); position: relative; }
.stage:first-child { border-left: 0; }
.stage:hover { background: var(--surface-2); }
.stage:not(:first-child)::before { content: ""; position: absolute; left: -6px; top: 50%; width: 10px; height: 10px; background: var(--surface); border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: translateY(-50%) rotate(45deg); }
.stage-name { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.stage-num { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stage-hint { font-size: 12px; color: var(--ink-3); }

@media (max-width: 480px) { .item-row { grid-template-columns: minmax(0, 1fr) 64px 40px; } }
.totals { column-gap: 0; }
.totals dt { padding-right: 14px; }

/* Order form: item rows with a type-to-search product picker */
.item-row { grid-template-columns: minmax(0, 1fr) 104px 70px 96px 40px; }
.combo { position: relative; }
.combo-list { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16, 21, 28, .14); }
.combo-list li { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.combo-list li small { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.combo-list li:hover, .combo-list li.is-active { background: var(--accent-soft); }
.combo-list li.is-out { opacity: .5; cursor: not-allowed; }
.combo-list li.is-empty { color: var(--ink-3); cursor: default; background: none; }
.amount { height: 38px; display: flex; align-items: center; justify-content: flex-end; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-row:not(:first-child) .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Bulk actions on the order list */
th.tick, td.tick { width: 36px; padding-right: 0; }
.tick input { width: 16px; height: 16px; }
.bulk { justify-content: flex-start; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.bulk select { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 8px; }

@media (max-width: 640px) {
  .item-row { grid-template-columns: minmax(0, 1fr) 64px 40px; grid-template-areas: "product product product" "price qty remove" "amount amount amount"; }
  .item-row > :nth-child(1) { grid-area: product; } .item-row > :nth-child(2) { grid-area: price; } .item-row > :nth-child(3) { grid-area: qty; }
  .item-row > :nth-child(4) { grid-area: amount; } .item-row > :nth-child(5) { grid-area: remove; }
  .item-row:not(:first-child) label, .item-row:not(:first-child) .lbl { position: static; width: auto; height: auto; clip: auto; }
  .item-row + .item-row { border-top: 1px solid var(--line); padding-top: 10px; }
}

[hidden] { display: none !important; }

/* Delivery */
.cell-input { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 8px; width: 100%; min-width: 120px; }
.cell-input[aria-invalid="true"] { border-color: var(--bad); }
.field input.mono { font-family: var(--mono); }

/* Invoices */
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bulk input[type="date"], .bulk input[type="text"] { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 0 8px; }
@media (max-width: 1000px) { .kpis-3 { grid-template-columns: minmax(0, 1fr); } }

/* Accounts */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-name { font-weight: 700; min-width: 124px; text-align: center; }
.pnl { min-width: 0; }
.pnl td { white-space: normal; }
.pnl td.num { white-space: nowrap; }
.pnl tr.sum td { font-weight: 700; border-top: 1.5px solid var(--axis); background: var(--surface-2); }
.pnl tr.grand td { font-size: 15px; }
td.note-cell { white-space: normal; max-width: 260px; color: var(--ink-2); overflow-wrap: anywhere; }

/* Reports */
:root { --s2: #eb6834; --s3: #1baf7a; --grid: #e6e9ee; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --s2: #d95926; --s3: #199e70; --grid: #262c36; } }
:root[data-theme="dark"] { --s2: #d95926; --s3: #199e70; --grid: #262c36; }

.card-body { padding: 14px 18px 18px; }
.two { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg a { padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.seg a:hover { background: var(--surface-2); }
.seg a[aria-current="true"] { background: var(--accent-soft); color: var(--accent); }

#chart { width: 100%; height: 240px; position: relative; }
#chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
#chart text { font-family: var(--sans); font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
#chart text.end { fill: var(--ink); font-weight: 600; font-size: 12px; }
#tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 8px; padding: 7px 10px; font-size: 12px; line-height: 1.4; white-space: nowrap; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.cour { display: flex; flex-direction: column; gap: 16px; }
.cour-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.cour-top span { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bar-stack { display: flex; gap: 2px; height: 14px; }
.bar-stack i { display: block; background: var(--c); min-width: 3px; }
.bar-stack i:first-child { border-radius: 4px 0 0 4px; }
.bar-stack i:last-child { border-radius: 0 4px 4px 0; }
.bar-stack i:only-child { border-radius: 4px; }
.cour-foot { margin-top: 5px; font-size: 12px; color: var(--ink-3); }

@media (max-width: 1180px) { .two { grid-template-columns: minmax(0, 1fr); } }
