/* Rechnungen — achromatic ledger.
   The chrome holds no colour: ink, greys and a stone ground taken from the truck's steel worktop. The one chart hue
   (#1d5fbf) marks the selected tax period's months; the only other colours are status (overdue, open, paid).
   Grid: 12 columns, one 12px gutter. At 1440 with a 256px sidebar and 32px padding the canvas is 1120px:
   12 × 82.33 + 11 × 12 = 1120, so 7 + 5 columns land on both canvas edges. */

@font-face {
  font-family: "Geist";
  src: url("fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ground: #f4f3f1;
  --surface: #ffffff;
  --raised: #f4f4f3;
  --active: #e8e7e4;
  --border: #e6e5e2;
  --rule: #f0efed;
  --control: #d4d3d0;
  --text: #0a0a0a;
  --muted: #6b6b6b;
  --faint: #6b6b6b;
  --accent: #141414;
  --primary: #141414;
  --primary-ink: #ffffff;
  --positive: #2e7d32;
  --negative: #c4242a;
  --warning: #92400e;
  --hue: #1d5fbf;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e;
  --pill-neutral-bg: #eeeeee; --pill-neutral-ink: #3d3d3d;
  --chart-1: #141414; --chart-muted: #d9d8d5;
  --grid: #ecebe8; --axis-ink: #6b6b6b; --ink: #0a0a0a;

  --font: "Geist", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-title: 24px; --fs-section: 16px; --fs-kpi: 30px; --fs-body: 14px; --fs-small: 12px;

  --sidebar-width: 256px;
  --pad: 32px;
  --gap: 12px;
  --card-pad: 20px;
  --radius-card: 8px;
  --radius-control: 6px;
  --control-height: 36px;
  --row-height: 44px;
  --nav-row: 32px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --t-press: 140ms; --t-hover: 150ms; --t-ui: 200ms;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: var(--fs-body)/20px var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, iframe, object { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
address { font-style: normal; }
code { font: 12px/18px ui-monospace, "SF Mono", Consolas, monospace; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, table, .kv dd, output { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.dash { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- shell: open plane ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100svh; }
.sidebar { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; gap: 2px; padding: 20px 12px 16px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; margin-bottom: 18px; }
.brand .mark { width: 28px; height: 28px; flex: none; }
.brand-text { display: grid; min-width: 0; line-height: 18px; }
.brand-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text span { color: var(--muted); font-size: var(--fs-small); }
.brand .menu-close { display: none; margin-left: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; height: var(--nav-row); padding: 0 10px; border-radius: 8px; color: var(--muted); transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.nav-item svg { width: 16px; height: 16px; flex: none; }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.group-label { margin: 24px 10px 6px; font-size: var(--fs-small); color: var(--muted); }
.sidebar .bottom { margin-top: auto; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px 0 8px; }
.avatar { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #e3e8ef; color: #2b3a4f; font-size: 12px; font-weight: 600; flex: none; }
.user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canvas { min-width: 0; padding: 32px var(--pad) 64px 8px; }
.phone-bar { display: none; }

/* ---------- title row ---------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.title-row h1 { font-size: var(--fs-title); line-height: 30px; font-weight: 600; letter-spacing: -0.01em; }
.title-row .sub { margin-top: 4px; color: var(--muted); max-width: 72ch; }
.title-row .sub.finding-neg { color: var(--negative); }
.title-actions { display: flex; gap: 8px; flex: none; }
.title-with-pill { display: flex; align-items: center; gap: 12px; }

/* ---------- grid and panels ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.grid.top { align-items: start; }
.span-12 { grid-column: 1 / -1; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 24px; }
.panel h2 { font-size: var(--fs-section); line-height: 22px; font-weight: 600; }
.meta { color: var(--muted); font-size: var(--fs-small); line-height: 18px; }
.panel-foot { margin-top: 12px; }
.side-stack, .editor-main { display: grid; gap: var(--gap); min-width: 0; }
.editor-side { display: grid; gap: var(--gap); position: sticky; top: 24px; }

.card-link { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; color: var(--text); font-weight: 500; cursor: pointer; text-underline-offset: 3px; }
.card-link::after { content: ""; width: 12px; height: 12px; flex: none; background: currentColor; -webkit-mask: var(--chevron) center / 12px no-repeat; mask: var(--chevron) center / 12px no-repeat; }
:root { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.5 2.5 8 6l-3.5 3.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.link { color: var(--text); font-weight: 500; text-underline-offset: 3px; }

/* ---------- list rows: open items, history ---------- */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 8px 0; }
.row + .row { border-top: 1px solid var(--rule); }
.row-main { display: grid; flex: 1; min-width: 0; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-underline-offset: 3px; }
.row-sub { color: var(--muted); font-size: var(--fs-small); line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-due { display: grid; width: 160px; flex: none; text-align: right; }
.row-due.late > span:first-child { color: var(--negative); font-weight: 500; }
.row-amount { width: 104px; flex: none; text-align: right; font-weight: 600; }
.row-amount.paid { font-weight: 400; color: var(--muted); }
.row-action { display: flex; justify-content: flex-end; width: 104px; flex: none; }
.subhead { margin: 20px 0 2px; padding-top: 16px; border-top: 1px solid var(--border); font-size: var(--fs-small); line-height: 18px; font-weight: 400; color: var(--muted); }
.empty + .subhead { border-top: 0; }
.late { color: var(--negative); }
.row-stack { display: grid; flex: none; text-align: right; }
.row-stack > .num { font-weight: 600; }
.status-neg { color: var(--negative); }
.status-pos { color: var(--positive); }
.status-warn { color: var(--warning); }

/* ---------- VAT panel ---------- */
.vat-head { align-items: flex-start !important; }
.vat-head > div { display: grid; }
.period-step { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -2px -8px 6px; }
.period-step strong { font-weight: 500; }
.vat-table th { height: 32px; }
.vat-table td { padding-top: 10px; padding-bottom: 10px; }
.vat-table th:first-child, .vat-table td:first-child { width: 36px; padding-left: 0; color: var(--muted); }
.vat-table th:last-child, .vat-table td:last-child { padding-right: 0; }
.vat-table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; font-weight: 500; }
.money-strong { font-weight: 700; }
.vat-note { margin: 10px 0 18px; }
#month-chart { --chart-1: var(--hue); height: 150px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.chart-head h3 { font-size: var(--fs-body); line-height: 20px; font-weight: 500; }
.chart { position: relative; min-width: 0; }

/* ---------- tables ---------- */
.list-panel > header { margin-bottom: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { height: 36px; padding: 0 12px; text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th.n, td.n { text-align: right; }
td .sub { display: block; font-size: var(--fs-small); line-height: 18px; color: var(--muted); }
.truncate { display: block; max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.show-sm, td .sub.show-sm { display: none; }
.status-col { width: 120px; }
.invoice-table td:nth-child(2) { width: 40%; }

/* ---------- pills ---------- */
.pill { display: inline-flex; flex: none; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: var(--fs-small); font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; }
.pill.pos { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }

/* ---------- tabs, filters ---------- */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { position: relative; padding: 10px 0; color: var(--muted); white-space: nowrap; transition: color var(--t-hover) ease; }
.tabs a[aria-selected="true"] { color: var(--text); }
.tabs a[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); }
.tabs .count { color: var(--muted); margin-left: 2px; }
.filters { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.search { position: relative; flex: 0 1 320px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { width: 100%; padding-left: 34px; }
.segmented { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--raised); flex: none; }
.segmented a { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border: 1px solid transparent; border-radius: 6px; color: var(--muted); transition: color var(--t-hover) ease; }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--text); border-color: var(--border); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--control-height); padding: 0 14px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); font-weight: 500; white-space: nowrap; cursor: pointer; user-select: none; transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary-soft { background: #e5e5e5; border-color: #e5e5e5; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.text { height: auto; padding: 4px 0; border: 0; background: none; }
.btn.text.neg { color: var(--negative); }
.btn.icon-only { width: var(--control-height); padding: 0; }
.btn.block { width: 100%; }
.btn:disabled { cursor: not-allowed; background: #ecebe8; border-color: #ecebe8; color: #6b6b6b; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: var(--raised); }
  .btn.primary:hover:not(:disabled) { background: #2a2a2a; }
  .btn.primary-soft:hover { background: #dcdcdc; }
  .btn.ghost:hover { background: var(--active); }
  .btn.text:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
  .nav-item:hover { background: var(--raised); color: var(--text); }
  .link:hover, .row-title:hover { text-decoration: underline; }
  .card-link:hover { text-decoration: underline; }
  .tabs a:hover, .segmented a:hover { color: var(--text); }
}

.field { display: grid; gap: 8px; align-content: start; min-width: 0; }
.field label, .field .label { font-weight: 500; }
.hint { color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
.input { width: 100%; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); transition: border-color var(--t-hover) ease; }
textarea.input { height: auto; padding: 9px 12px; line-height: 20px; resize: vertical; }
select.input { padding-right: 32px; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%236b6b6b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 10px center / 12px no-repeat; }
.filters select.input { width: auto; }
.input::placeholder { color: var(--faint); }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--negative); }
.input.file { height: auto; padding: 8px; }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 48px; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-1 { grid-column: span 1; } .form-grid .span-2 { grid-column: span 2; } .form-grid .span-3 { grid-column: span 3; } .form-grid .span-4 { grid-column: span 4; }
.form-stack { display: grid; gap: 20px; }
.form-actions { display: flex; align-items: center; gap: 8px; }
.form-actions .spacer { flex: 1; }
.gap-top { margin-top: 8px; }
.notice { margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius-control); background: var(--pill-warning-bg); color: var(--pill-warning-ink); border: 1px solid #fde68a; }
.notice.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); border-color: #f7c8c2; }
.empty { display: grid; place-items: center; min-height: 72px; padding: 16px; border: 1px dashed var(--control); border-radius: var(--radius-control); color: var(--muted); text-align: center; }

.switch { appearance: none; width: 32px; height: 20px; margin: 0; border-radius: 999px; background: var(--control); position: relative; cursor: pointer; flex: none; transition: background-color var(--t-ui) ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--t-ui) var(--ease-out); }
.switch:checked { background: var(--text); }
.switch:checked::after { transform: translateX(12px); }
.switch-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.switch-row span { display: grid; font-weight: 500; }
.switch-row small { color: var(--muted); font-size: var(--fs-small); font-weight: 400; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-cards label { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); cursor: pointer; transition: border-color var(--t-hover) ease; }
.radio-cards label:has(input:checked) { border-color: var(--text); outline: 1px solid var(--text); outline-offset: -2px; }
.radio-cards input { margin: 3px 0 0; accent-color: var(--text); }
.radio-cards span { display: grid; gap: 2px; }
.radio-cards small { color: var(--muted); font-size: var(--fs-small); line-height: 16px; }

/* ---------- editor ---------- */
.address-preview { padding: 10px 12px; border-radius: var(--radius-control); background: var(--raised); line-height: 20px; min-height: 62px; }
.item-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 92px 100px 72px 96px 60px; gap: 8px; align-items: start; }
.item-head { padding-bottom: 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: var(--fs-small); }
.item-head .n { text-align: right; }
.item-row { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.item-row label, .item-row .cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.item-row > div { position: relative; min-width: 0; }
.cell-name { display: grid; gap: 6px; }
.item-row .desc { min-height: 38px; font-size: 13px; color: var(--muted); }
.cell-qty .input, .cell-price .input { text-align: right; }
.cell-total { display: flex; align-items: center; justify-content: flex-end; height: 38px; font-weight: 500; }
/* reorder as a stacked pair beside the remove button, so the name keeps the width */
.cell-tools { display: grid; grid-template-columns: 28px 28px; grid-template-rows: 19px 19px; justify-content: end; }
.cell-tools .btn { width: 28px; height: 19px; color: var(--muted); border-radius: 4px; }
.cell-tools .btn svg { width: 14px; height: 14px; }
.cell-tools [data-move="-1"] { grid-area: 1 / 1; }
.cell-tools [data-move="1"] { grid-area: 2 / 1; }
.cell-tools [data-remove] { grid-area: 1 / 2 / 3 / 3; height: 38px; }
.item-row:first-child [data-move="-1"], .item-row:last-child [data-move="1"] { visibility: hidden; }
.item-row.entering { opacity: 0; transform: translateY(-4px); }
.item-row { transition: opacity var(--t-ui) var(--ease-out), transform var(--t-ui) var(--ease-out); }
.add-row { margin-top: 12px; }

/* product suggestions under the name field; no entrance motion, since typing opens it */
.suggest { position: absolute; top: 42px; left: 0; z-index: 30; width: max(100%, min(380px, calc(100vw - 32px))); max-height: 320px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12); } /* taste-skill-ignore: a popover floats */
.suggest .opt { display: grid; gap: 2px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.suggest .opt[aria-selected="true"] { background: var(--raised); }
.opt-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt-desc { color: var(--muted); font-size: var(--fs-small); line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-fields { margin-top: 16px; }

.kv { display: grid; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.kv dt { color: var(--muted); }
.kv dd { text-align: right; min-width: 0; overflow-wrap: anywhere; }
/* the answer figure: its label above it, so a five-digit total fits the narrow side column */
.grand { display: grid; gap: 2px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.grand span { color: var(--muted); }
.grand strong { font-size: var(--fs-kpi); line-height: 36px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }

.checklist { display: grid; gap: 2px; }
.checklist li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; padding: 6px 0; }
.checklist svg { width: 16px; height: 18px; }
.checklist li > svg:nth-of-type(2) { display: none; }
.checklist li.missing > svg:first-of-type { display: none; }
.checklist li.missing > svg:nth-of-type(2) { display: block; color: var(--muted); }
.checklist li.ok > svg:first-of-type { color: var(--positive); }
.checklist span { display: grid; }
.checklist small { color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
.checklist li.ok:not(.static) small { display: none; }
.checklist li.missing > span { font-weight: 500; }
.side-actions { display: grid; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-actions .btn.text { justify-self: start; }

/* ---------- invoice view ---------- */
.paper-wrap { min-width: 0; }
.paper { width: 100%; aspect-ratio: 210 / 297; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.paper-fallback { display: grid; place-items: center; gap: 12px; height: 100%; padding: 24px; text-align: center; color: var(--muted); }
.pay-form { display: grid; gap: 12px; }
.stack-actions { display: grid; gap: 10px; justify-items: start; }
.timeline { display: grid; gap: 0; }
.timeline li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; }
.timeline li + li { border-top: 1px solid var(--rule); }
.timeline time { color: var(--muted); font-size: var(--fs-small); white-space: nowrap; }
.hash { display: flex; justify-content: space-between; gap: 12px; margin: 10px 0 8px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); }
.hash code { color: var(--text); }

/* ---------- settings ---------- */
.settings { display: grid; }
.settings-row { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 32px; padding: 28px 0; border-bottom: 1px solid var(--border); }
.settings-row:first-child { padding-top: 8px; }
.settings-label { padding-top: 6px; }
.settings-label h2 { font-size: var(--fs-section); line-height: 22px; font-weight: 500; }
.settings-label p { margin-top: 4px; color: var(--muted); max-width: 44ch; }
.settings-panel { padding: 16px; border-radius: 16px; background: #f7f7f7; border: 1px solid var(--border); }
.settings-panel.form-grid { padding: 16px; }
.settings-panel .input { border-color: #e6e5e2; border-radius: 8px; }
.settings-panel > .field + .form-actions, .settings-panel > .field { margin-top: 16px; }
.settings-save { display: flex; justify-content: flex-end; padding-top: 16px; }
.settings + .settings .settings-row:first-child { padding-top: 28px; }
.preview-line { height: 38px; display: flex; align-items: center; font-weight: 500; }
.preview-text { padding: 10px 12px; border-radius: 8px; background: var(--surface); border: 1px dashed var(--control); }
.logo-preview { display: grid; place-items: center; height: 120px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.logo-preview img { max-height: 90px; max-width: 70%; object-fit: contain; }
.logo-placeholder { font-weight: 700; font-size: 18px; }
.line-preview-main { display: grid; gap: 2px; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--rule); }
.line-preview-main span { color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
.line-preview-main span:empty { display: none; }
.kv .strong dt { color: var(--text); }
.kv .strong dd { font-weight: 700; }
.rate-guide > div { align-items: baseline; }
.rate-guide dd { white-space: nowrap; font-weight: 500; }
.rate-guide + .meta { margin-top: 10px; }
.menu-groups { display: grid; gap: var(--gap); }

/* categories: one row per category, its own small form */
.cat-head, .cat-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 72px 236px; gap: 10px; align-items: center; }
.cat-head { padding-bottom: 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: var(--fs-small); }
.cat-head .n { text-align: right; }
.cat-row { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.cat-row:last-child { border-bottom: 0; }
.cat-count { text-align: right; color: var(--muted); }
.cat-tools { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.cat-tools .btn.icon-only { color: var(--muted); }
.cat-tools .btn.icon-only:disabled { background: none; border-color: transparent; opacity: 0.35; }
.cat-delete { position: relative; }
.cat-delete > summary { list-style: none; }
.cat-delete > summary::-webkit-details-marker { display: none; }
.cat-delete[open] > summary { background: var(--active); color: var(--negative); }
.cat-delete-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: grid; gap: 8px; width: 260px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12); } /* taste-skill-ignore: a popover floats */
.cat-delete-pop label { font-weight: 500; }
.cat-delete-pop .btn.text { justify-self: start; }
.menu-table td:first-child { width: 50%; }

/* ---------- dialogs ---------- */
.sheet { width: min(460px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16); } /* taste-skill-ignore: a dialog floats */
.sheet[open] { animation: sheet-in var(--t-ui) var(--ease-out); }
.sheet::backdrop { background: rgba(10, 10, 10, 0.32); }
.sheet h2 { font-size: 18px; line-height: 24px; font-weight: 600; margin-bottom: 8px; }
.sheet p { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.sheet.preview { width: min(860px, calc(100vw - 32px)); height: calc(100svh - 48px); padding: 16px; display: none; flex-direction: column; gap: 12px; }
.sheet.preview[open] { display: flex; }
.preview-head { display: flex; align-items: center; justify-content: space-between; }
.preview-head h2 { margin: 0; }
.sheet.preview iframe { flex: 1; width: 100%; border: 1px solid var(--border); border-radius: 8px; }
@keyframes sheet-in { from { opacity: 0; transform: scale(0.97); } }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 50; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 12px 16px; border-radius: 8px; background: #141414; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); pointer-events: auto; transition: opacity 300ms ease, transform 300ms var(--ease-out); } /* taste-skill-ignore: a toast floats */
.toast svg { width: 16px; height: 16px; flex: none; color: #8fd19e; }
.toast.neg svg { color: #ff9a8f; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition-duration: 200ms; }
@starting-style { .toast { opacity: 0; transform: translateY(8px); } }

/* ---------- sign-in and setup ---------- */
body.bare { display: grid; min-height: 100svh; place-items: start center; padding: 12vh 16px 48px; }
.bare-main { width: min(380px, 100%); display: grid; gap: 16px; }
.bare-main.wide { width: min(640px, 100%); }
.bare-main > h1 { font-size: var(--fs-title); line-height: 30px; font-weight: 600; letter-spacing: -0.01em; }
.bare-main > .sub { color: var(--muted); margin-top: -8px; }
.bare-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.bare-brand .mark { width: 28px; height: 28px; }
.install-checks h2, .form-stack h2 { margin-bottom: 4px; }

/* ---------- tablet and phone ---------- */
@media (max-width: 1180px) {
  .editor-grid > .span-9, .editor-grid > .span-3 { grid-column: 1 / -1; }
  .editor-side { position: static; }
}
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .phone-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 8px; background: var(--ground); border-bottom: 1px solid var(--border); }
  .phone-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar { position: fixed; inset: 0; z-index: 30; width: 100%; height: 100%; padding: 12px 16px; background: var(--surface); transform: translateX(-100%); visibility: hidden; transition: transform 260ms var(--ease-out), visibility 0s linear 260ms; }
  .sidebar.open { transform: none; visibility: visible; transition: transform 260ms var(--ease-out); }
  .brand .menu-close { display: inline-flex; }
  .nav-item { height: 44px; font-size: 16px; }
  .canvas { padding: 20px 24px 64px; }
  .grid > [class*="span-"] { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .canvas { padding: 16px 16px 64px; }
  .title-row { flex-wrap: wrap; align-items: flex-start; }
  .title-row h1 { font-size: 22px; }
  .title-actions { width: 100%; }
  .title-actions .btn { flex: 1; }
  .hide-sm, .truncate.hide-sm { display: none; }
  .show-sm { display: inline; }
  .truncate.show-sm { display: block; }
  td .sub.show-sm { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
  .invoice-table td:nth-child(2) { width: auto; }
  .truncate { max-width: 52vw; }
  .row { flex-wrap: wrap; gap: 4px 12px; padding: 10px 0; }
  .row-main { flex-basis: 100%; }
  .row-due { width: auto; flex: 1; text-align: left; }
  .row-due .row-sub { display: none; }
  .row-amount { width: auto; }
  .row-action .btn { height: 44px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-3, .form-grid .span-4 { grid-column: 1 / -1; }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .editor-side { grid-template-columns: 1fr; }
  .panel > header { flex-wrap: wrap; }
  .item-head { display: none; }
  .item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 16px 0; }
  .item-row .cell-name { grid-column: 1 / -1; }
  .item-row label, .item-row .cell-label { position: static; width: auto; height: auto; clip: auto; display: block; margin-bottom: 4px; font-size: var(--fs-small); line-height: 16px; color: var(--muted); }
  .item-row .cell-name label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .cell-total { display: block; height: auto; }
  .cell-total output { display: block; line-height: 44px; text-align: left; }
  .cell-tools { display: flex; align-self: end; justify-content: flex-end; gap: 4px; }
  .cell-tools .btn, .cell-tools [data-remove] { width: 44px; height: 44px; }
  .input { height: 44px; font-size: 16px; }
  .suggest { top: 48px; }
  .cat-head { display: none; }
  .cat-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 14px 0; }
  .cat-row > .input:first-of-type { grid-column: 1 / -1; }
  .cat-count::after { content: " Produkte"; }
  .cat-tools { grid-column: 1 / -1; justify-content: flex-start; }
  .cat-tools .btn.icon-only { width: 44px; height: 44px; }
  .cat-delete-pop { left: 0; right: auto; width: min(260px, calc(100vw - 64px)); }
  .settings-row { grid-template-columns: 1fr; gap: 12px; padding: 20px 0; }
  .radio-cards { grid-template-columns: 1fr; }
  .paper { aspect-ratio: auto; height: 70svh; }
  .toasts { left: 16px; right: 16px; bottom: 16px; justify-items: stretch; }
  .search { flex: 1 1 100%; }
  .filters select.input { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}
