@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/fonts/inter-var.v1.woff2') format('woff2');
}

:root {
  --bg: #151116;
  --bg-2: #1c171d;
  --bg-3: #241e26;
  --bg-4: #2e2630;
  --line: #3a313c;
  --line-2: #4a3f4d;
  --fg: #efe7e4;
  --fg-dim: #b9adab;
  --fg-muted: #857a7d;
  --hl: #d8992f;
  --hl-ink: #1a1418;
  --accent: #b94738;
  --ok: #5fbf7a;
  --warn: #e0a73a;
  --bad: #e5604f;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.dim { color: var(--fg-muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: #d8992f55; }

#app { min-height: 100vh; display: flex; flex-direction: column; }
#app:not(.ready) .boot { display: flex; }
.boot { display: none; min-height: 60vh; align-items: center; justify-content: center; color: var(--fg-muted); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px; background: rgba(21, 17, 22, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { text-decoration: none; font-weight: 700; letter-spacing: -0.01em; font-size: 15px; white-space: nowrap; }
.brand .l { color: var(--hl); }
.brand .p { color: var(--fg-dim); font-weight: 500; }
.topbar nav { display: flex; gap: 2px; }
.topbar nav a { text-decoration: none; padding: 6px 10px; border-radius: 7px; color: var(--fg-dim); }
.topbar nav a:hover { background: var(--bg-3); color: var(--fg); }
.topbar nav a.on { background: var(--bg-3); color: var(--fg); }
.spacer { flex: 1; }
.newmenu { display: flex; gap: 6px; }

.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; text-decoration: none; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--fg-dim); white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pill-warn .dot { background: var(--warn); }
.pill-bad { border-color: #e5604f66; color: var(--fg); }
.pill-bad .dot { background: var(--bad); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--fg); text-decoration: none; cursor: pointer;
  font-weight: 500; font-size: 13.5px; white-space: nowrap; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--bg-4); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--hl); color: var(--hl-ink); border-color: var(--hl); font-weight: 600; }
.btn.primary:hover { background: #e6a83f; }
.btn.danger { background: transparent; border-color: #e5604f88; color: #ff8f80; }
.btn.danger:hover { background: #e5604f22; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-3); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.icon-btn { background: none; border: 0; color: var(--fg-muted); cursor: pointer; font-size: 17px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover:not(:disabled) { color: var(--fg); background: var(--bg-4); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

input[type='text'], input[type='email'], input[type='date'], input[type='search'], input:not([type]), select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; outline: none; transition: border-color 0.12s, box-shadow 0.12s; min-width: 0;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--hl); box-shadow: 0 0 0 3px #d8992f22; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.75; background: transparent; border-style: dashed; }
input.bad { border-color: var(--bad); }
input[type='date'] { color-scheme: dark; }
input[type='color'] { width: 30px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.in-num { text-align: right; font-variant-numeric: tabular-nums; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-size: 12px; color: var(--fg-dim); font-weight: 500; }
.field.wide { grid-column: 1 / -1; }
.hint { font-size: 11.5px; color: var(--fg-muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.join { display: flex; gap: 6px; }
.join select { width: auto; }
.sub-label { font-size: 12px; color: var(--fg-dim); font-weight: 600; margin: 14px 0 8px; }

.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; padding: 6px 0; font-size: 13px; }
.toggle input { position: absolute; opacity: 0; }
.toggle .track { width: 34px; height: 20px; border-radius: 99px; background: var(--bg-4); border: 1px solid var(--line-2); position: relative; transition: background 0.15s; flex: none; }
.toggle .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--fg-dim); transition: transform 0.15s, background 0.15s; }
.toggle input:checked + .track { background: #d8992f44; border-color: var(--hl); }
.toggle input:checked + .track::after { transform: translateX(14px); background: var(--hl); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px #d8992f33; }

.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { background: none; border: 0; padding: 5px 11px; border-radius: 6px; cursor: pointer; color: var(--fg-dim); font-size: 13px; white-space: nowrap; }
.seg button.on { background: var(--bg-4); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }

.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--bg-4); color: var(--fg-dim); white-space: nowrap; }
.chip-paid, .chip-accepted, .chip-converted { background: #5fbf7a22; color: #85d99c; }
.chip-overdue, .chip-overdue_partial, .chip-declined { background: #e5604f22; color: #ff8f80; }
.chip-partial, .chip-issued, .chip-sent { background: #d8992f22; color: #f0bd62; }
.chip-void, .chip-expired { text-decoration: line-through; }

.banner { display: flex; align-items: center; gap: 14px; justify-content: space-between; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-2); font-size: 13px; margin-bottom: 14px; color: var(--fg-dim); }
.banner strong { color: var(--fg); }
.banner.warn { border-color: #e0a73a66; background: #e0a73a12; }
.banner.bad { border-color: #e5604f66; background: #e5604f12; color: var(--fg); }
.banner.info { background: var(--bg-2); }

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.page { width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; }
.page-head h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; }
.toolbar { display: flex; gap: 12px; align-items: center; margin: 18px 0 12px; }
.toolbar .search { max-width: 320px; margin-left: auto; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-l { font-size: 12px; color: var(--fg-muted); }
.stat-v { font-size: 18px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat.bad .stat-v { color: #ff8f80; }

table.grid { width: 100%; border-collapse: collapse; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.grid th { text-align: left; font-size: 12px; font-weight: 500; color: var(--fg-muted); padding: 9px 14px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr[tabindex] { cursor: pointer; }
table.grid tbody tr[tabindex]:hover, table.grid tbody tr[tabindex]:focus { background: var(--bg-3); outline: none; }
table.grid .num { text-align: right; }
table.grid.compact td { padding: 6px 10px; }

.empty { text-align: center; padding: 56px 20px; border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--fg-dim); }
.empty h2 { margin: 0 0 6px; font-size: 18px; color: var(--fg); }
.empty p { margin: 0 0 18px; }

.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editbar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 49px; z-index: 15; }
.doc-title { font-weight: 600; font-size: 15px; }
.save-state { font-size: 12px; min-width: 60px; }
.panes { flex: 1; display: grid; grid-template-columns: minmax(520px, 1fr) minmax(420px, 1.05fr); min-height: 0; }
.form { padding: 16px 20px 80px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.preview { border-left: 1px solid var(--line); background: #0f0c10; position: relative; min-width: 0; }
.preview-bar { position: sticky; top: 104px; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; font-size: 12px; color: var(--fg-muted); background: #0f0c10ee; }
.totals-box { font-size: 14px; color: var(--fg); }
.totals-box strong { margin-left: 6px; }
.preview-scroll { position: sticky; top: 146px; padding: 4px 16px 40px; display: flex; justify-content: center; }
.preview-inner { position: relative; }
.preview-inner .sheet { transform-origin: top left; position: absolute; top: 0; left: 0; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55); }

.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.card > summary { list-style: none; display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; cursor: pointer; user-select: none; }
.card > summary::-webkit-details-marker { display: none; }
.card > summary::before { content: '▸'; color: var(--fg-muted); font-size: 11px; transition: transform 0.15s; display: inline-block; }
.card[open] > summary::before { transform: rotate(90deg); }
.card-t { font-weight: 600; font-size: 14px; }
.card-s { color: var(--fg-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.card-b { padding: 4px 16px 16px; }

.items { display: flex; flex-direction: column; gap: 6px; }
.item-head, .item { display: grid; grid-template-columns: minmax(150px, 1fr) 62px 86px 92px 62px 118px 86px 52px; gap: 6px; align-items: start; }
.item-head { font-size: 11.5px; color: var(--fg-muted); padding: 0 2px; }
.item-head .num { text-align: right; }
.item { padding: 8px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.c-item { display: flex; flex-direction: column; gap: 4px; }
.in-desc { font-size: 12.5px; min-height: 30px; }
.amt { text-align: right; padding-top: 8px; font-weight: 600; font-size: 13px; }
.row-actions { display: flex; padding-top: 3px; }
.row-add { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.charges { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.charge { display: grid; grid-template-columns: 1fr 110px 150px 32px; gap: 6px; }

.notes-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--fg-dim); line-height: 1.4; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--hl); }
.check.auto { color: var(--fg); }
.check em { color: var(--hl); font-style: normal; }

.logo-box { display: flex; align-items: center; gap: 14px; padding: 10px; border: 1px dashed var(--line-2); border-radius: 8px; }
.logo-box img { max-height: 48px; max-width: 160px; background: #fff; border-radius: 4px; padding: 4px; }
.logo-actions { display: flex; gap: 6px; }
.swatches { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px var(--line-2); }
.swatch.on { border-color: var(--fg); }

.pay-sum { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 2px; font-size: 14px; }

.more { position: relative; }
.menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 9px; padding: 5px; min-width: 200px; box-shadow: var(--shadow); z-index: 30; }
.more.open .menu { display: flex; flex-direction: column; }
.menu button { background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--bg-4); }
.menu button.danger { color: #ff8f80; }

.modal-wrap { position: fixed; inset: 0; background: rgba(8, 6, 9, 0.66); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; z-index: 100; animation: fade 0.12s ease-out; }
.modal { width: 100%; max-width: 460px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); }
.modal.wide { max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 6px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 6px 18px 12px; color: var(--fg-dim); }
.modal-body p { margin: 6px 0 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 18px 16px; }
.issues { margin: 6px 0; padding-left: 18px; color: var(--fg); }
.issues.warn li { color: #f0bd62; }
@keyframes fade { from { opacity: 0; } }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; }
.toast { background: var(--bg-4); border: 1px solid var(--line-2); padding: 9px 14px; border-radius: 9px; box-shadow: var(--shadow); font-size: 13px; max-width: 520px; transition: opacity 0.3s, transform 0.3s; }
.toast-err { border-color: #e5604f88; }
.toast.out { opacity: 0; transform: translateY(6px); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { text-decoration: none; padding: 8px 12px; color: var(--fg-dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--fg); border-color: var(--hl); }
.settings .card { margin-bottom: 14px; }
.rates { display: flex; flex-direction: column; gap: 6px; }
.rate { display: grid; grid-template-columns: 1fr 90px 190px 32px; gap: 6px; align-items: center; }
.rate.head { font-size: 11.5px; color: var(--fg-muted); }
.series { display: flex; flex-direction: column; gap: 10px; }
.serie { display: grid; grid-template-columns: 110px 1fr 120px auto 150px; gap: 10px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts { padding-left: 18px; color: var(--fg-dim); }
.facts li { margin: 6px 0; }
.facts .btn { margin-left: 8px; }
.about p { color: var(--fg-dim); }

.site-foot { border-top: 1px solid var(--line); padding: 28px 20px 40px; color: var(--fg-muted); font-size: 13px; }
.site-foot .in { max-width: 1080px; margin: 0 auto; display: flex; gap: 14px; flex-wrap: wrap; justify-content: space-between; }
.site-foot a { color: var(--fg-dim); }
.prose { max-width: 760px; margin: 0 auto; padding: 48px 20px 24px; color: var(--fg-dim); font-size: 15px; line-height: 1.7; }
.prose h1, .prose h2, .prose h3 { color: var(--fg); letter-spacing: -0.015em; line-height: 1.25; }
.prose h1 { font-size: 28px; margin: 0 0 12px; }
.prose h2 { font-size: 20px; margin: 36px 0 10px; }
.prose h3 { font-size: 16px; margin: 22px 0 6px; }
.prose a { color: var(--fg); text-decoration-color: var(--hl); text-underline-offset: 3px; }
.prose ul { padding-left: 20px; }
.prose .lede { font-size: 17px; color: var(--fg); }
.prose .affiliate { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px; background: var(--bg-2); }
.prose details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.prose summary { cursor: pointer; color: var(--fg); font-weight: 600; }

.sheet {
  --accent: #b94738;
  width: 794px; min-height: 1123px; background: #fff; color: #16161a;
  padding: 58px 58px 70px; font-family: 'Inter', sans-serif; font-size: 12px; line-height: 1.45;
  position: relative; font-feature-settings: 'cv11';
}
.sheet .s-draft { position: absolute; top: 44%; left: 0; right: 0; text-align: center; font-size: 140px; font-weight: 800; color: #16161a; opacity: 0.045; transform: rotate(-30deg); pointer-events: none; letter-spacing: 0.02em; }
.sheet.tpl-classic::before { content: ''; position: absolute; top: 36px; left: 58px; width: 56px; height: 4px; background: var(--accent); }
.sheet.tpl-bold::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 8px; background: var(--accent); }
.s-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid #e3e3e8; margin-bottom: 22px; }
.s-seller { max-width: 56%; }
.s-logo { max-width: 200px; max-height: 72px; display: block; margin-bottom: 14px; }
.s-name { font-weight: 600; font-size: 16.5px; margin-bottom: 3px; }
.s-dim { color: #686872; font-size: 11.3px; }
.s-titlebox { text-align: right; }
.s-title { font-weight: 700; font-size: 32px; letter-spacing: -0.02em; line-height: 1.05; color: var(--accent); }
.tpl-minimal .s-title { color: #16161a; }
.s-number { color: #686872; font-size: 14.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.s-parties { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.s-client { max-width: 56%; }
.s-label { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #686872; margin-bottom: 5px; }
.s-cname { font-weight: 600; font-size: 14.5px; margin-bottom: 2px; }
.s-meta { border-collapse: collapse; }
.s-meta th { text-align: left; font-weight: 400; color: #686872; padding: 1.5px 18px 1.5px 0; white-space: nowrap; vertical-align: top; }
.s-meta td { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; padding: 1.5px 0; }
.s-parties .s-meta { min-width: 250px; align-self: flex-start; }
.s-ref { color: #686872; margin: -12px 0 16px; }
.s-items { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.s-items th { font-size: 10px; font-weight: 600; color: #686872; text-align: left; padding: 0 5px 7px; border-bottom: 1.3px solid var(--accent); }
.tpl-minimal .s-items th { border-color: #16161a; }
.tpl-bold .s-items th { background: var(--accent); color: #fff; border: 0; padding: 7px 5px; }
.tpl-bold .s-items th:first-child { border-radius: 4px 0 0 4px; }
.tpl-bold .s-items th:last-child { border-radius: 0 4px 4px 0; }
.s-items td { padding: 8px 5px; border-bottom: 1px solid #ececf0; vertical-align: top; font-variant-numeric: tabular-nums; }
.s-items .c-no { width: 22px; color: #9c9ca6; font-size: 11px; }
.s-items .c-num { text-align: right; white-space: nowrap; }
.s-items td:last-child { font-weight: 600; }
.s-iname { font-weight: 600; font-size: 12.5px; }
.s-idesc { color: #686872; font-size: 11.3px; white-space: pre-line; margin-top: 2px; }
.s-sum { display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; margin: 6px 0 18px; }
.s-vatsum { border-collapse: collapse; font-size: 11.3px; min-width: 300px; font-variant-numeric: tabular-nums; }
.s-vatsum caption { text-align: left; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #686872; padding-bottom: 6px; }
.s-vatsum th { font-weight: 400; color: #9c9ca6; text-align: right; padding: 0 0 4px 12px; border-bottom: 1px solid #e3e3e8; }
.s-vatsum th:first-child, .s-vatsum td:first-child { text-align: left; padding-left: 0; }
.s-vatsum td { text-align: right; padding: 4px 0 0 12px; }
.s-totals { border-collapse: collapse; min-width: 300px; font-variant-numeric: tabular-nums; }
.s-totals th { text-align: left; font-weight: 400; color: #686872; padding: 3px 24px 3px 0; }
.s-totals td { text-align: right; padding: 3px 0; }
.s-totals tr.strong th, .s-totals tr.strong td { font-weight: 700; font-size: 15px; color: #16161a; padding-top: 10px; border-top: 1.3px solid var(--accent); }
.s-totals tr.strong td { color: var(--accent); }
.tpl-minimal .s-totals tr.strong th, .tpl-minimal .s-totals tr.strong td { border-color: #16161a; color: #16161a; }
.s-totals tr.muted th, .s-totals tr.muted td { color: #9c9ca6; font-size: 11px; }
.s-national { color: #686872; font-size: 11.3px; margin-bottom: 10px; }
.s-legal { font-size: 11.3px; margin-bottom: 16px; }
.s-legal div + div { margin-top: 4px; }
.s-pay { display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid #e3e3e8; padding-top: 16px; margin-bottom: 16px; }
.s-paydetails .s-meta td { text-align: left; }
.s-qr { text-align: center; font-size: 10px; color: #686872; width: 124px; flex: none; }
.s-qr svg { width: 124px; height: 124px; display: block; }
.s-notes { white-space: pre-line; margin-bottom: 14px; }
.s-footer { position: absolute; left: 58px; right: 58px; bottom: 28px; border-top: 1px solid #e3e3e8; padding-top: 8px; color: #9c9ca6; font-size: 10px; white-space: pre-line; }

#print-root { display: none; }

@media (max-width: 1180px) {
  .panes { grid-template-columns: minmax(500px, 1fr) minmax(360px, 0.9fr); }
}
@media (max-width: 980px) {
  .panes { grid-template-columns: 1fr; }
  .preview { border-left: 0; border-top: 1px solid var(--line); }
  .preview-bar, .preview-scroll { position: static; }
  .editbar { flex-wrap: wrap; position: static; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .newmenu .btn:not(.primary) { display: none; }
}
@media (max-width: 640px) {
  .grid2, .grid3, .stats { grid-template-columns: 1fr; }
  .item-head { display: none; }
  .item { grid-template-columns: 1fr 1fr 1fr; }
  .item .c-item { grid-column: 1 / -1; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .pill { display: none; }
  .serie, .rate, .charge { grid-template-columns: 1fr 1fr; }
  .page { padding: 16px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { max-width: none; margin: 0; }
}

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root .sheet { width: 210mm; min-height: 297mm; box-shadow: none; transform: none; padding: 15mm 15mm 18mm; }
  #print-root .s-items tr { break-inside: avoid; }
  #print-root .s-sum, #print-root .s-pay { break-inside: avoid; }
}
