:root {
  --paper: #f3f5f4;
  --surface: #ffffff;
  --ink: #15212b;
  --muted: #586874;
  --line: #d3dbdf;
  --line-soft: #e6ebed;
  --seal: #1d5aa6;
  --seal-strong: #144580;
  --seal-wash: #e8f0fa;
  --ok: #1f7a4d;
  --ok-wash: #e6f3ec;
  --void: #b23a2e;
  --void-wash: #fbebe9;
  --warn: #8a5a00;
  --warn-wash: #fdf3dc;
  --focus: #f0b429;
  --radius: 6px;
  --ui: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --doc: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f161c; --surface: #17212a; --ink: #e7edf1; --muted: #9aabb7; --line: #2c3a45; --line-soft: #22303a;
    --seal: #6aa3e8; --seal-strong: #8fbaf0; --seal-wash: #172a40; --ok: #5cc392; --ok-wash: #14301f;
    --void: #f08174; --void-wash: #3a1c19; --warn: #e8b453; --warn-wash: #33280f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f161c; --surface: #17212a; --ink: #e7edf1; --muted: #9aabb7; --line: #2c3a45; --line-soft: #22303a;
  --seal: #6aa3e8; --seal-strong: #8fbaf0; --seal-wash: #172a40; --ok: #5cc392; --ok-wash: #14301f;
  --void: #f08174; --void-wash: #3a1c19; --warn: #e8b453; --warn-wash: #33280f; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.55 var(--ui); }
a { color: var(--seal); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 3.2vw, 2.25rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.hidden { display: none !important; }

/* ---- topbar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px max(16px, calc((100vw - 1120px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.02rem; min-width: 0; }
.brand-mark { width: 28px; height: 28px; color: var(--seal); flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a, .nav button { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: var(--radius); font: 500 .94rem var(--ui); background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover { color: var(--ink); background: var(--line-soft); }
.nav a[aria-current="page"] { color: var(--seal-strong); background: var(--seal-wash); }
.nav .who { color: var(--muted); font-size: .85rem; padding: 0 6px 0 12px; border-left: 1px solid var(--line); margin-left: 6px; }

.view { max-width: 1120px; margin: 0 auto; padding: 28px 16px 64px; outline: none; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 .95rem var(--ui); padding: 10px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--seal); border-color: var(--seal); color: #fff; }
.btn.primary:hover { background: var(--seal-strong); border-color: var(--seal-strong); }
:root[data-theme="dark"] .btn.primary, .btn.primary { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0f161c; } }
.btn.danger { color: var(--void); border-color: color-mix(in srgb, var(--void) 45%, var(--line)); }
.btn.danger.solid { background: var(--void); border-color: var(--void); color: #fff; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: .86rem; }
.btn.link { border: 0; background: none; color: var(--seal); padding: 6px 4px; min-height: 0; }
.btn[disabled] { opacity: .55; cursor: progress; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
label .req { color: var(--void); font-weight: 700; }
.hint { font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: 3px; display: block; }
input, select, textarea { width: 100%; font: 400 1rem var(--ui); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; min-height: 42px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--seal); outline: 2px solid color-mix(in srgb, var(--seal) 30%, transparent); outline-offset: 0; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; vertical-align: -3px; margin: 0 8px 0 0; accent-color: var(--seal); }
.check { font-weight: 500; display: flex; align-items: center; }
.grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid .span-all { grid-column: 1 / -1; }
.field { min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 22px; }
.panel + .panel, .stack > * + * { margin-top: 18px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px 18px; margin: 0; background: var(--surface); }
fieldset + fieldset { margin-top: 16px; }
legend { font-weight: 700; padding: 0 6px; }
.subtle { border-style: dashed; background: transparent; }

.msg { padding: 12px 14px; border-radius: var(--radius); border: 1px solid; margin: 0 0 16px; }
.msg.error { background: var(--void-wash); border-color: color-mix(in srgb, var(--void) 35%, transparent); color: var(--void); }
.msg.warn { background: var(--warn-wash); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--ink); }
.msg.ok { background: var(--ok-wash); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.active { background: var(--ok-wash); color: var(--ok); }
.badge.cancelled { background: var(--void-wash); color: var(--void); }
.badge.off { background: var(--line-soft); color: var(--muted); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .84rem; background: var(--paper); }
tr:last-child td { border-bottom: 0; }
tbody tr.rowlink { cursor: pointer; }
tbody tr.rowlink:hover { background: var(--seal-wash); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.search { width: 300px; max-width: 100%; }

/* ---- verify home ---- */
.verify-hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 48px; align-items: center; padding: 24px 0 8px; }
.verify-hero h1 { font-size: clamp(1.9rem, 4.4vw, 3rem); letter-spacing: -0.02em; max-width: 14ch; }
.verify-hero .lead { font-size: 1.1rem; color: var(--muted); max-width: 46ch; }
.verify-form { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.verify-form .regno { font: 600 1.25rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .04em; text-transform: uppercase; }
.verify-form .code { font: 600 1.1rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 24px; margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.how h3 { font-size: 1rem; }
.how p { color: var(--muted); font-size: .94rem; }
.how .step { color: var(--seal); font-weight: 700; margin-right: 6px; }
.seal-art { justify-self: center; width: min(320px, 70vw); color: var(--seal); }

/* ---- verify result ---- */
.result { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 36px; align-items: start; }
.stamp { width: 200px; height: 200px; transform: rotate(-9deg); }
.stamp.ok { color: var(--ok); }
.stamp.void { color: var(--void); }
.stamp.pending { color: var(--muted); }
.result-status { font-size: 1.6rem; font-weight: 700; margin: 0 0 6px; }
.result-status.ok { color: var(--ok); }
.result-status.void { color: var(--void); }
dl.facts { display: grid; grid-template-columns: minmax(130px, 200px) minmax(0, 1fr); gap: 8px 18px; margin: 18px 0 0; }
dl.facts dt { color: var(--muted); font-size: .9rem; }
dl.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* ---- new document ---- */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.type-card { display: block; text-align: left; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; }
.type-card:hover { border-color: var(--seal); box-shadow: inset 4px 0 0 var(--seal); }
.type-card strong { display: block; font-size: 1.02rem; margin-bottom: 4px; }
.type-card span { color: var(--muted); font-size: .9rem; }
.party { position: relative; }
.party .remove { position: absolute; top: 10px; right: 12px; }
.form-foot { position: sticky; bottom: 0; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(4px); padding: 14px 0; margin-top: 18px; border-top: 1px solid var(--line); }
.conflict-list { margin: 8px 0 12px; padding-left: 20px; }

/* ---- document view ---- */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.doc-side .panel { padding: 18px; }
.history { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.history li:last-child { border-bottom: 0; }

/* Warqadda dukumentiga (A4) */
.sheet { background: #fff; color: #111; font: 400 15.5px/1.7 var(--doc); padding: 48px 56px; border: 1px solid var(--line); border-radius: 4px; position: relative; overflow: hidden; }
.sheet .s-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #1d5aa6; padding-bottom: 14px; margin-bottom: 22px; }
.sheet .s-org { font: 700 1.15rem/1.3 var(--ui); color: #144580; }
.sheet .s-meta { font: 400 .8rem/1.5 var(--ui); color: #444; }
.sheet .s-qr { text-align: right; font: 400 .75rem/1.4 var(--ui); color: #333; flex: none; }
.sheet .s-qr svg { width: 104px; height: 104px; display: block; margin-left: auto; }
.sheet .s-reg { font: 700 .9rem ui-monospace, Menlo, Consolas, monospace; color: #111; margin-top: 4px; }
.sheet h2.s-title { font: 600 1.45rem/1.25 var(--doc); text-align: center; margin: 4px 0 20px; color: #111; }
.sheet p { margin: 0 0 .85em; text-align: justify; hyphens: auto; }
.sheet blockquote { margin: 0 0 1em; padding: 6px 0 6px 16px; border-left: 3px solid #c7d3dc; font-style: italic; white-space: pre-wrap; }
.sheet h3 { font: 700 .82rem/1.3 var(--ui); color: #144580; margin: 22px 0 8px; letter-spacing: .02em; }
.sheet table { font: 400 .8rem/1.4 var(--ui); border: 1px solid #ccd5db; }
.sheet th { background: #f2f5f7; color: #333; font-size: .74rem; padding: 6px 8px; }
.sheet td { padding: 6px 8px; border-bottom: 1px solid #e3e8eb; }
.sheet .sigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 8px; }
.sheet .sig { border: 1px solid #ccd5db; border-radius: 3px; padding: 8px 10px; font: 400 .78rem/1.4 var(--ui); min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; break-inside: avoid; }
.sheet .sig .line { border-top: 1px solid #888; padding-top: 3px; margin-top: 36px; color: #555; }
.sheet .sig.thumb .box { width: 62px; height: 72px; border: 1px dashed #888; border-radius: 30px / 36px; margin: 6px 0 0 auto; }
.sheet .notary-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-top: 20px; break-inside: avoid; }
.sheet .stamp-spot { width: 120px; height: 120px; border: 1.5px dashed #9fb3c8; border-radius: 50%; display: grid; place-items: center; font: 400 .72rem var(--ui); color: #7d93a9; text-align: center; flex: none; }
.sheet .s-foot { margin-top: 26px; padding-top: 10px; border-top: 1px solid #ccd5db; font: 400 .7rem/1.5 var(--ui); color: #555; overflow-wrap: anywhere; }
.sheet .void-mark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.sheet .void-mark span { transform: rotate(-24deg); font: 800 5.4rem/1 var(--ui); color: rgba(178, 58, 46, .16); border: 10px solid rgba(178, 58, 46, .16); padding: 8px 28px; border-radius: 14px; white-space: nowrap; }

/* ---- dialog / toast ---- */
.dialog { border: 1px solid var(--line); border-radius: 10px; padding: 22px; max-width: min(480px, calc(100vw - 32px)); width: 100%; background: var(--surface); color: var(--ink); }
.dialog::backdrop { background: rgba(10, 20, 30, .45); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 8px; font-weight: 500; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.auth { max-width: 460px; margin: 24px auto; }
.auth.wide { max-width: 720px; }

@media (max-width: 860px) {
  .verify-hero { grid-template-columns: 1fr; gap: 28px; }
  .seal-art { display: none; }
  .result { grid-template-columns: 1fr; gap: 12px; }
  .stamp { width: 150px; height: 150px; }
  .doc-layout { grid-template-columns: 1fr; }
  .sheet { padding: 24px 18px; font-size: 14.5px; }
  .sheet .s-head { flex-direction: column-reverse; }
  .sheet .s-qr { text-align: left; }
  .sheet .s-qr svg { margin-left: 0; }
  dl.facts { grid-template-columns: 1fr; gap: 2px 0; }
  dl.facts dd { margin-bottom: 10px; }
  .nav .who { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@page { size: A4; margin: 14mm; }
@media print {
  body { background: #fff; }
  .no-print, .doc-side, .page-head, .topbar, .toast { display: none !important; }
  .view { padding: 0; max-width: none; }
  .doc-layout { display: block; }
  .sheet { border: 0; padding: 0; font-size: 12pt; }
  .sheet .s-head { flex-direction: row; }
  .sheet .s-qr { text-align: right; }
}

/* ---- logo ---- */
.brand-logo { width: 30px; height: 30px; object-fit: contain; flex: none; border-radius: 4px; }
.sheet .s-org-wrap { display: flex; gap: 14px; align-items: flex-start; }
.sheet .s-logo { width: 64px; height: 64px; object-fit: contain; flex: none; }

/* ---- dejinta ---- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 22px; }
.tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--seal-strong); border-bottom-color: var(--seal); font-weight: 600; }
.narrow { max-width: 760px; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 20px; align-items: start; }
.save-bar { position: sticky; bottom: 0; z-index: 2; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(4px); padding: 12px 0; border-top: 1px solid var(--line); }
.save-bar .msg { margin-bottom: 10px; }
.color-row { display: flex; gap: 10px; align-items: center; }
.color-row input[type="color"] { width: 52px; height: 42px; padding: 3px; flex: none; cursor: pointer; }
.color-row input:not([type="color"]) { max-width: 140px; }
.swatches { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.logo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-row .stack > * + * { margin-top: 8px; }
.logo-box { width: 88px; height: 88px; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; background: var(--paper); text-align: center; padding: 6px; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-panel h3 { color: var(--muted); font-size: .9rem; font-weight: 600; }
.preview-panel .sheet { padding: 28px 30px; font-size: 14px; }
.mini { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--paper); }
.mini-top { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: .9rem; }
.mini-top img { width: 22px; height: 22px; object-fit: contain; }
.mini-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--a); }
.mini-body { padding: 18px 14px; }
.mini-h { font-weight: 700; font-size: 1.15rem; line-height: 1.2; margin-bottom: 6px; }
.mini-body p { color: var(--muted); font-size: .84rem; margin-bottom: 12px; }
.mini-btn { display: inline-block; background: var(--a); color: #fff; padding: 7px 12px; border-radius: 5px; font-weight: 600; font-size: .84rem; }

.tpl-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.tpl-list { padding: 10px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); }
.tpl-list ul { list-style: none; margin: 0; padding: 0; }
.tpl-list li.sep { border-top: 1px solid var(--line-soft); margin-top: 6px; padding-top: 6px; }
.tpl-list li button { width: 100%; display: flex; gap: 6px; align-items: center; justify-content: space-between; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 6px; font: 500 .92rem var(--ui); color: var(--ink); cursor: pointer; }
.tpl-list li button:hover { background: var(--line-soft); }
.tpl-list li button[aria-current="true"] { background: var(--seal-wash); color: var(--seal-strong); font-weight: 600; }
.badge.new { background: var(--warn-wash); color: var(--warn); }
.tpl-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.edit-table td { padding: 6px 8px; vertical-align: middle; }
.edit-table input, .edit-table select { min-height: 36px; padding: 6px 8px; font-size: .92rem; }
.edit-table input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; }
.edit-table input[type="number"] { max-width: 80px; }
.row-btns { white-space: nowrap; }
.row-btns .btn[disabled] { opacity: .3; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.chip { font: 500 .8rem var(--ui); padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--seal); color: var(--seal-strong); }
.body-edit { font: 400 .9rem/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; min-height: 320px; }
.body-edit.short { min-height: 120px; }
.syntax { margin-top: 12px; }
.syntax summary { cursor: pointer; color: var(--seal); font-weight: 600; font-size: .9rem; }
.syntax ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.syntax li { margin: 4px 0; }
code { font: .86em ui-monospace, Menlo, Consolas, monospace; background: var(--line-soft); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 860px) {
  .settings-grid, .tpl-layout { grid-template-columns: 1fr; }
  .tpl-list { position: static; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; }
}

/* ---- xisaabaadka ---- */
h1 .en { font-size: .5em; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 6px; vertical-align: middle; }
.period { display: flex; flex-direction: column; gap: 2px; font-weight: 400; margin: 0; }
.period select { min-height: 40px; padding: 6px 10px; width: auto; }
.page-head .actions { align-items: flex-end; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-l { font-variant-numeric: tabular-nums; }
.neg { color: var(--void); }
.pos { color: var(--ok); }
.badge.partial { background: var(--warn-wash); color: var(--warn); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi span { color: var(--muted); font-size: .86rem; }
.kpi strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi a { font-size: .84rem; }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-bottom: 18px; align-items: start; }
.fin-grid.wide-first { grid-template-columns: minmax(0, 1fr) 300px; }
.fin-grid > * { min-width: 0; }
.table-wrap.flat { border: 0; border-radius: 0; }
.bars { display: flex; gap: 10px; align-items: flex-end; height: 180px; padding: 8px 4px 0; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-pair { flex: 1; width: 100%; display: flex; gap: 3px; align-items: flex-end; justify-content: center; }
.bar { width: 40%; max-width: 22px; min-height: 2px; border-radius: 3px 3px 0 0; }
.bar.inc, .dot.inc { background: var(--seal); }
.bar.exp, .dot.exp { background: color-mix(in srgb, var(--void) 70%, var(--surface)); }
.bar-lbl { font-size: .78rem; color: var(--muted); padding: 6px 0 4px; }
.legend { margin: 10px 0 0; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.legend .dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
ul.plain { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
ul.plain li { display: flex; gap: 8px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
ul.plain li:last-child { border-bottom: 0; }
ul.plain .right { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.narrow-wide { max-width: 980px; }
.edit-table.items tfoot th { padding: 10px 8px; }

.fin-sheet .s-doc-meta { text-align: right; font: 400 .8rem/1.6 var(--ui); color: #333; }
.fin-sheet .s-kind { font: 700 1.3rem/1.2 var(--ui); color: #144580; margin-bottom: 2px; }
.fin-sheet .bill-to { font: 400 .9rem/1.5 var(--ui); margin: 6px 0 18px; }
.fin-sheet table.lines { width: 100%; margin: 0 0 12px; }
.fin-sheet table.lines td, .fin-sheet table.lines th { font-size: .82rem; }
.fin-sheet table.totals { width: auto; min-width: 260px; margin: 0 0 16px auto; border: 0; font: 400 .9rem var(--ui); }
.fin-sheet table.totals th { background: none; text-align: left; color: #444; font-size: .86rem; padding: 4px 12px 4px 0; }
.fin-sheet table.totals td { text-align: right; font-variant-numeric: tabular-nums; padding: 4px 0; border: 0; }
.fin-sheet table.totals tr.due th, .fin-sheet table.totals tr.due td { font-weight: 700; color: #111; border-top: 1.5px solid #111; padding-top: 8px; }
.fin-sheet .notes { font: 400 .85rem/1.5 var(--ui); background: #f5f7f8; padding: 10px 12px; border-radius: 4px; margin-bottom: 8px; }
.fin-sheet .rc-amount { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 2px solid #144580; border-radius: 6px; padding: 14px 18px; margin: 8px 0 18px; font-family: var(--ui); }
.fin-sheet .rc-amount strong { font-size: 1.9rem; color: #111; font-variant-numeric: tabular-nums; }
.fin-sheet .rc-facts { font-family: var(--ui); font-size: .92rem; }
.fin-sheet .rc-facts dt { color: #555; }
.fin-sheet .paid-mark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.fin-sheet .paid-mark span { transform: rotate(-18deg); font: 800 4.6rem/1 var(--ui); color: rgba(31, 122, 77, .14); border: 9px solid rgba(31, 122, 77, .14); padding: 6px 26px; border-radius: 14px; }
@media (max-width: 860px) { .fin-grid.wide-first { grid-template-columns: 1fr; } .fin-sheet .s-doc-meta { text-align: left; } }
@media print { .tabs { display: none !important; } }

.fin-sheet table.totals th, .fin-sheet table.totals td { border-bottom: 0; }

.fin-sheet .rc-qr { text-align: center; font: 400 .72rem var(--ui); color: #555; flex: none; }
.fin-sheet .rc-qr svg { width: 104px; height: 104px; display: block; margin: 0 auto 4px; }

.fin-sheet.report h2.rep-h { font: 700 1rem var(--ui); color: #144580; margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 1px solid #ccd5db; }
.fin-sheet.report .rep-tot { margin: 0 0 8px 0; }
.fin-sheet.report .rep-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.fin-sheet.report .rep-tx td { font-size: .76rem; padding: 4px 8px; }
.fin-sheet.report table.lines { break-inside: auto; }
.fin-sheet.report tr { break-inside: avoid; }
@media (max-width: 700px) { .fin-sheet.report .rep-cols { grid-template-columns: 1fr; } }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 9px 14px; font-weight: 500; cursor: pointer; margin: 0; }
.seg label:has(input:checked) { border-color: var(--seal); background: var(--seal-wash); color: var(--seal-strong); }
.seg input { width: auto; min-height: 0; margin: 0; accent-color: var(--seal); }

[hidden] { display: none !important; }

.tabs a .tab-en { display: block; font-size: .72rem; font-weight: 400; color: var(--muted); line-height: 1.1; }
.nav a small { display: block; font-size: .68rem; font-weight: 400; line-height: 1.1; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 0 0 22px; }
.qa { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid var(--line); border-left: 4px solid var(--seal); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; }
.qa:hover { border-color: var(--seal); background: var(--seal-wash); }
.qa strong { font-size: 1rem; }
.qa span { font-size: .82rem; color: var(--muted); }

.rep-switch { margin: 0 0 16px; }
.rep-switch a { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; font-weight: 500; color: var(--ink); text-decoration: none; background: var(--surface); }
.rep-switch a small { color: var(--muted); font-weight: 400; }
.rep-switch a.on { border-color: var(--seal); background: var(--seal-wash); color: var(--seal-strong); }
.fin-sheet .rep-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 14px; font-family: var(--ui); }
.fin-sheet .rep-kpis div { border: 1px solid #ccd5db; border-radius: 4px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.fin-sheet .rep-kpis span { font-size: .76rem; color: #555; }
.fin-sheet .rep-kpis strong { font-size: 1.25rem; color: #111; font-variant-numeric: tabular-nums; }
.fin-sheet .bar-th { width: 22%; }
.fin-sheet .bar-td { vertical-align: middle; }
.fin-sheet .hbar { display: block; height: 8px; border-radius: 2px; background: #1d5aa6; opacity: .75; min-width: 2px; }
@media (max-width: 700px) { .fin-sheet .rep-kpis { grid-template-columns: 1fr 1fr; } .fin-sheet .bar-th, .fin-sheet .bar-td { display: none; } }
