:root {
  --bg: #f3f5f7;
  --sidebar: #eef1f4;
  --surface: #fff;
  --fg: #1b2430;
  --muted: #667085;
  --faint: #98a2b3;
  --border: #e4e7ec;
  --primary: #1857ff;
  --primary-fg: #fff;
  --primary-hover: #0e46e0;
  --ink: #0b1220;
  --income: #0e8a5b;
  --danger: #d92d20;
  --warn: #b54708;
  --gold: #e8b800;
  --chip: #e8eefc;
  --r: 10px;
  --font: "DM Sans", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px -16px rgba(16,24,40,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { margin: 0; letter-spacing: -.02em; text-wrap: balance; }
.tabular { font-variant-numeric: tabular-nums; }

.login { min-height: 100dvh; display: grid; }
@media (min-width: 900px) { .login { grid-template-columns: 1fr 1fr; } }
.login-art { display: none; background: var(--ink); color: #f4f6f8; padding: 40px 48px; flex-direction: column; justify-content: space-between; }
@media (min-width: 900px) { .login-art { display: flex; } }
.login-art img { height: 112px; width: auto; max-width: 280px; object-fit: contain; object-position: left; }
.login-kicker { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin: 0 0 12px; }
.login-art h1 { font-size: 34px; font-weight: 600; max-width: 22ch; }
.login-art p { color: rgba(244,246,248,.7); line-height: 1.55; max-width: 42ch; }
.login-form-wrap { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 22px; }
.login-card .sub { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }

.field { display: grid; gap: 6px; margin: 0 0 14px; font-size: 13px; font-weight: 500; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field input, .field select, .field textarea, .inp {
  width: 100%; height: 42px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 0 12px; color: var(--fg);
}
.field textarea, textarea.inp { height: 88px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .inp:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--primary); color: var(--primary-fg);
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; color: var(--primary-fg); }
.btn.sec { background: #eef2f8; color: var(--fg); }
.btn.sec:hover { background: #e2e8f2; color: var(--fg); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--fg); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--income); }
.btn.sm { height: 34px; font-size: 13px; padding: 0 10px; }
.btn.block { width: 100%; }
.linkish { background: none; border: 0; color: var(--primary); padding: 0; font-weight: 500; font-size: 14px; }

.app { display: flex; min-height: 100dvh; }
.side {
  width: 232px; background: var(--sidebar); border-right: 1px solid var(--border);
  display: none; flex-direction: column; position: sticky; top: 0; height: 100dvh; flex-shrink: 0;
}
@media (min-width: 1040px) { .side { display: flex; } }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px; border-bottom: 1px solid var(--border); color: inherit; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: var(--ink); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.brand-mark img { width: 28px; height: 28px; object-fit: contain; }
.brand b { display: block; font-size: 13px; }
.brand small { display: block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); font-weight: 500; }
.create-wrap { padding: 12px 12px 4px; position: relative; }
.create-menu {
  display: none; position: absolute; left: 12px; right: 12px; top: 52px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px 0;
}
.create-wrap.open .create-menu { display: block; }
.create-menu a { display: block; padding: 8px 12px; color: var(--fg); font-size: 13px; }
.create-menu a:hover { background: var(--bg); text-decoration: none; }
.nav { flex: 1; overflow: auto; padding: 8px 8px 16px; }
.nav-item, .nav-group > button {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent;
  color: var(--muted); padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 500; text-align: left;
}
.nav-item:hover, .nav-group > button:hover { background: #fff; color: var(--fg); text-decoration: none; }
.nav-item.on { background: var(--chip); color: var(--primary); }
.nav-kids { margin: 0 0 6px 16px; border-left: 1px solid var(--border); }
.nav-kids a { display: block; padding: 6px 12px; color: var(--muted); font-size: 13px; border-radius: 0 8px 8px 0; }
.nav-kids a:hover { background: #fff; color: var(--fg); text-decoration: none; }
.nav-kids a.on { background: var(--chip); color: var(--primary); font-weight: 600; }
.side-foot { border-top: 1px solid var(--border); padding: 12px; font-size: 12px; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 56px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; position: sticky; top: 0; z-index: 20; gap: 12px;
}
@media (min-width: 1040px) { .top { padding: 0 32px; } }
.page { padding: 24px 16px 48px; }
@media (min-width: 1040px) { .page { padding: 24px 32px 64px; } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 650; }
.page-head p { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 12px; }
@media (min-width: 720px) { .g2 { grid-template-columns: 1fr 1fr; } .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .g4 { grid-template-columns: repeat(4, 1fr); } .g3 { grid-template-columns: 1fr 1fr 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.stat .lbl { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.stat .val { font-size: 20px; font-weight: 650; margin-top: 8px; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-h h2 { font-size: 14px; font-weight: 650; }
.card-h p { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafbfc; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 8px; color: var(--muted); font-size: 14px; }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 650; letter-spacing: .02em; }
.badge.draft, .badge.saved { background: #eef1f4; color: #3d4a5c; }
.badge.sent, .badge.viewed { background: #e8eefc; color: #1857ff; }
.badge.paid { background: #e6f6ee; color: #0e8a5b; }
.badge.overdue, .badge.void { background: #fde8e6; color: #d92d20; }
.badge.partial, .badge.invoiced { background: #fff4e5; color: #b54708; }

.flash { border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: #e6f6ee; color: #0e8a5b; }
.flash.err { background: #fde8e6; color: #d92d20; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search { height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; min-width: 220px; background: var(--surface); }

.paper { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.paper-head { display: flex; justify-content: space-between; gap: 16px; background: var(--ink); color: #fff; padding: 18px 22px; align-items: center; }
.paper-head img { height: 48px; width: auto; object-fit: contain; }
.paper-brand { display: flex; gap: 12px; align-items: center; }
.paper-biz { font-weight: 650; }
.paper-kicker { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.paper-id { text-align: right; }
.paper-kind { font-size: 18px; font-weight: 650; }
.paper-no { opacity: .7; }
.paper-body { padding: 20px 22px; }
.parties { display: grid; gap: 12px; margin-bottom: 16px; }
@media (min-width: 640px) { .parties { grid-template-columns: 1fr 1fr; } }
.party-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.paper table { width: 100%; border-collapse: collapse; font-size: 13px; }
.paper th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 1px solid var(--border); padding: 8px 0; }
.paper td { padding: 10px 0; border-bottom: 1px solid #f0f2f5; }
.totals { width: 220px; margin-left: auto; margin-top: 12px; font-size: 13px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-weight: 700; font-size: 15px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }

.lines { width: 100%; }
.lines th, .lines td { font-size: 13px; }
.lines input, .lines select { height: 36px; width: 100%; }
.lines textarea {
  width: 100%;
  min-height: 36px;
  height: 36px;
  resize: vertical;
  padding: 8px;
  line-height: 1.4;
  overflow: hidden;
}
.pdf-sheet { max-width: 860px; margin: 0 auto; padding: 24px 16px 48px; }
.pdf-wait { text-align: center; color: var(--muted); margin: 0 0 16px; }
.pdf-sheet .paper { margin-bottom: 24px; }
.mob { display: inline-flex; }
@media (min-width: 1040px) { .mob { display: none !important; } }
.drawer { position: fixed; inset: 0; background: rgba(11,18,32,.45); z-index: 40; display: none; }
.drawer.on { display: block; }
.drawer .side { display: flex !important; width: min(280px, 85vw); height: 100%; position: relative; z-index: 2; }
.drawer .side-scrim { position: absolute; inset: 0; }
.userchip { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.income { color: var(--income); }
.danger { color: var(--danger); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bars .stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; height: 130px; }
.bars i { display: block; width: 100%; border-radius: 3px 3px 0 0; }
.bars span { font-size: 10px; color: var(--faint); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; }
.mini { list-style: none; margin: 0; padding: 0; }
.mini li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.mini li:last-child { border-bottom: 0; }
.form-grid { display: grid; gap: 12px; }
@media (min-width: 800px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.help { font-size: 12px; color: var(--muted); }
.split { display: grid; gap: 16px; }
@media (min-width: 1100px) { .split.preview { grid-template-columns: 1.15fr .85fr; } }

@media print {
  .no-print { display: none !important; }
  body, .page { background: #fff; padding: 0; }
  .paper { border: 0; box-shadow: none; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.modal {
  border: 0;
  border-radius: 12px;
  padding: 0;
  width: min(480px, calc(100vw - 1.5rem));
  box-shadow: var(--shadow);
  color: var(--fg);
  background: var(--surface);
}
.modal::backdrop { background: rgba(11, 18, 32, 0.45); }
.modal-pad { padding: 20px; }
.modal-pad .field { margin-bottom: 0; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px -16px rgba(16, 24, 40, .2);
}
.tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: none;
  padding: 4px 2px;
}
.tabbar .tab:hover { text-decoration: none; color: var(--fg); }
.tabbar .tab.on { color: var(--primary); }
@media (min-width: 1040px) { .tabbar { display: none; } }
@media (max-width: 1039px) {
  .page { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .userchip span { display: none; }
}

.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--ink);
  color: #f4f6f8;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.install-banner[hidden] { display: none !important; }
.install-banner img { width: 40px; height: 40px; border-radius: 9px; flex-shrink: 0; }
.install-copy { flex: 1; min-width: 0; }
.install-copy strong { display: block; font-size: 13px; }
.install-copy p { margin: 2px 0 0; font-size: 12px; color: rgba(244,246,248,.7); }
.install-banner .ios-tip, .install-banner .android-tip { display: none; }
.install-banner.ios .ios-tip, .install-banner.android .android-tip { display: block; }
.install-banner .btn.ghost { border-color: rgba(244,246,248,.2); color: #f4f6f8; }
@media (min-width: 1040px) {
  .install-banner {
    left: auto;
    right: 20px;
    bottom: 20px;
    width: 380px;
  }
}

.get-app-public { min-height: 100dvh; background: var(--bg); }
.get-app-hero {
  background: var(--ink);
  color: #f4f6f8;
  padding: 40px 24px 36px;
  text-align: center;
}
.get-app-hero img { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 16px; }
.get-app-hero h1 { font-size: 28px; font-weight: 650; max-width: 18ch; margin: 0 auto 10px; }
.get-app-hero p { color: rgba(244,246,248,.72); max-width: 40ch; margin: 0 auto; line-height: 1.55; }
.get-app-url {
  margin: 16px auto 20px !important;
  font-size: 13px;
  letter-spacing: .04em;
  color: var(--gold) !important;
}
.get-app-body { padding: 20px 16px 48px; max-width: 880px; margin: 0 auto; }
.get-app-grid { display: grid; gap: 12px; }
@media (min-width: 800px) { .get-app-grid { grid-template-columns: 1fr 1fr; } }
.get-app-card h2 { font-size: 16px; margin: 4px 0 12px; }
.get-app-os {
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--primary);
}
.get-app-card ol { margin: 0; padding-left: 18px; color: var(--fg); }
.get-app-card li { margin: 0 0 8px; font-size: 14px; line-height: 1.5; }

body.standalone .mob { display: none; }

@media print {
  .tabbar, .install-banner { display: none !important; }
}

/* Phone layout — lists become cards, nothing wider than the screen */
@media (max-width: 760px) {
  .app, .main, .page { max-width: 100%; min-width: 0; }
  .top {
    height: auto;
    min-height: 56px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  .top > div:first-child { min-width: 0; flex: 1; }
  .top > div:first-child strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 42vw;
  }
  .page { padding: 16px 14px calc(96px + env(safe-area-inset-bottom, 0px)); }
  .page-head { align-items: stretch; }
  .page-head h1 { font-size: 22px; }
  .page-head > .btn, .page-head .actions { width: 100%; }
  .page-head .actions .btn, .actions .btn { flex: 1 1 auto; }
  .g4 { grid-template-columns: 1fr 1fr; }
  .g3 { grid-template-columns: 1fr 1fr 1fr; }
  .stat .val { font-size: 16px; overflow-wrap: anywhere; }
  .filters { display: grid; grid-template-columns: 1fr; }
  .search, .filters .inp, .filters .btn { width: 100%; min-width: 0; }
  .field input, .field select, .field textarea, .inp, .search,
  table.data input, table.data select, table.data textarea { font-size: 16px; }
  .bars { overflow-x: auto; }
  .mini li { flex-direction: column; align-items: stretch; }
  .mini li > div:last-child { justify-content: space-between; }
  .totals { width: 100%; }
  .paper-head, .paper-body { padding: 14px; }
  .paper-head { flex-wrap: wrap; }
  .paper td, .paper th { overflow-wrap: anywhere; }
  .login-form-wrap { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
  .get-app-hero { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
  .install-banner { flex-wrap: wrap; }
  .line-hint { display: block; margin: 8px 0 0 !important; }
  [data-add-line] { width: 100%; }

  table.data {
    display: block;
    width: 100%;
  }
  table.data thead { display: none; }
  table.data tbody { display: block; }
  table.data tr {
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  table.data tr:last-child { border-bottom: 0; }
  table.data td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: auto !important;
    padding: 5px 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }
  table.data td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 46%;
    text-align: left;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  table.data td[data-label=""]::before,
  table.data td:not([data-label])::before,
  table.data td[colspan]::before { content: none; display: none; }
  table.data td[colspan] { display: block; text-align: center; }
  table.data td.num { font-weight: 650; }
  table.lines { background: transparent; }
  table.lines tr {
    margin: 0 0 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
  }
  table.lines td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    text-align: left;
  }
  table.lines td input,
  table.lines td select { min-width: 0; width: 100%; }
  table.lines td:last-child {
    display: flex;
    justify-content: flex-end;
    grid-template-columns: none;
  }
  .drawer .side {
    height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

.dash-row { display: grid; gap: 12px; margin-top: 24px; min-width: 0; }
@media (min-width: 1280px) {
  .dash-row.two { grid-template-columns: 1fr 1fr; }
  .dash-row.split { grid-template-columns: 1fr 2fr; }
}
.dash-row > .card { min-width: 0; max-width: 100%; }
.chart-box { position: relative; height: 224px; width: 100%; max-width: 100%; overflow: hidden; }
.chart-box canvas { display: block; max-width: 100%; }
.kpi3 { display: grid; gap: 16px; }
@media (min-width: 640px) { .kpi3 { grid-template-columns: repeat(3, 1fr); } }
.kpi-l { font-size: 12px; color: var(--muted); }
.kpi-v { margin-top: 4px; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.paybox { margin-top: 20px; font-size: 13px; }
.paybox strong { color: var(--fg); }
.paper-notes { margin-top: 16px; font-size: 13px; }
.paper-foot { margin-top: 12px; font-size: 12px; }

.paper { --doc-accent: #1857FF; }
.fmt-modern { border-left: 6px solid var(--doc-accent); border-radius: 0 12px 12px 0; }
.fmt-modern .paper-kind { color: var(--doc-accent); }
.fmt-formal .paper-kind { color: var(--doc-accent); }
.fmt-minimal { border-top: 3px solid var(--doc-accent); }
.paper .col-item { font-weight: 650; width: 22%; }
.paper .col-desc { white-space: pre-wrap; }
.paper .col-qty { width: 8%; }
.paper .col-price, .paper .col-tax, .paper .col-amt { width: 14%; }
.paper.opt-no-item .col-item,
.paper.opt-no-description .col-desc,
.paper.opt-no-qty .col-qty,
.paper.opt-no-price .col-price,
.paper.opt-no-tax .col-tax,
.paper.opt-no-logo .paper-brand img,
.paper.opt-no-bank .paybox { display: none !important; }
.fmt-custom { margin: 8px 0 14px; }
.fmt-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.fmt-checks label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.fmt-previews { display: grid; gap: 16px; margin: 8px 0 16px; }
@media (min-width: 980px) { .fmt-previews { grid-template-columns: 1fr 1fr; } }
.fmt-previews .paper { font-size: 11px; }
.fmt-modern .paper-head,
.fmt-formal .paper-head,
.fmt-minimal .paper-head { background: #fff; color: var(--fg); }
.fmt-modern .paper-kicker { display: none; }
.fmt-modern .paper-kind { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--doc-accent); font-weight: 650; }
.fmt-modern .paper-no { opacity: 1; font-size: 26px; font-weight: 650; letter-spacing: -.03em; }
.fmt-modern .totals { background: var(--chip); border-radius: 10px; padding: 10px 12px; width: 240px; }
.fmt-formal .paper-head { flex-direction: column; text-align: center; border-bottom: 1px solid var(--fg); }
.fmt-formal .paper-brand { flex-direction: column; }
.fmt-formal .paper-id { text-align: center; }
.fmt-formal .paper-kicker { display: none; }
.fmt-formal .paper-kind { font-size: 18px; letter-spacing: .2em; text-transform: uppercase; color: var(--doc-accent); }
.fmt-formal .paper-no { opacity: 1; }
.fmt-formal .party { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.fmt-formal .paper th, .fmt-formal .paper td { border: 1px solid var(--border); padding: 8px; }
.fmt-formal .paybox { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.fmt-minimal { border: 0; box-shadow: none; border-radius: 0; border-top: 3px solid var(--doc-accent); }
.fmt-minimal .paper-head { border-bottom: 1px solid var(--border); }
.fmt-minimal .paper-kicker { display: none; }
.fmt-minimal .paper-kind { font-size: 14px; font-weight: 500; }
.fmt-stripe .paper-head { background: var(--doc-accent); color: #fff; border-radius: 0; }
.fmt-stripe .paper-kicker { color: rgba(255,255,255,.75); }
.fmt-stripe .paper-kind { letter-spacing: .18em; text-transform: uppercase; font-size: 13px; }
.fmt-stripe { border-radius: 0; }
.fmt-ledger { border-radius: 0; background: #fffef8; }
.fmt-ledger .paper-head { background: transparent; color: var(--fg); border-bottom: 2px solid var(--fg); }
.fmt-ledger .paper-kicker { display: none; }
.fmt-ledger .paper th, .fmt-ledger .paper td { border-bottom: 1px solid #d9d3c5; }
.fmt-ledger .paper th { color: var(--fg); }
.fmt-compact { border-radius: 8px; }
.fmt-compact .paper-head, .fmt-compact .paper-body { padding: 10px 12px; }
.fmt-compact .paper-kind { font-size: 14px; }
.fmt-compact .paper td, .fmt-compact .paper th { padding: 4px 0; font-size: 12px; }
.fmt-compact .paper-head { background: #fff; color: var(--fg); border-bottom: 1px solid var(--border); }
.fmt-compact .paper-kicker { display: none; }
.fmt-letter { border: 0; border-radius: 0; box-shadow: none; }
.fmt-letter .paper-head { background: #fff; color: var(--fg); border-bottom: 0; padding-bottom: 0; align-items: flex-start; }
.fmt-letter .paper-kicker { display: none; }
.fmt-letter .paper-kind { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--doc-accent); }
.fmt-letter .paper-no { font-size: 20px; font-weight: 650; opacity: 1; }
.fmt-lanka {
  border: 1px solid #111;
  border-radius: 0;
  color: #111;
  font-size: 12px;
  background: #fff;
}
.lk-title { margin: 0; padding: 10px 12px 4px; text-align: center; font-size: 22px; letter-spacing: .12em; font-weight: 750; }
.lk-head, .lk-lines, .lk-sum { width: 100%; border-collapse: collapse; }
.lk-head td, .lk-lines th, .lk-lines td, .lk-sum th, .lk-sum td { border: 1px solid #111; padding: 6px 8px; vertical-align: top; }
.lk-head span, .lk-sum th { font-weight: 650; }
.lk-head span { display: inline-block; min-width: 9.5em; }
.lk-lines th { font-size: 11px; text-align: left; background: #f4f4f4; }
.lk-sum { width: 100%; margin-top: 0; }
.lk-sum th { text-align: left; width: 62%; background: #fff; }
.lk-sum td { text-align: right; font-variant-numeric: tabular-nums; }
.lk-grand th, .lk-grand td { font-size: 14px; }
.lk-extra { margin: 10px 12px; font-size: 12px; }
.lk-legal { margin: 0; padding: 8px 12px 12px; font-size: 11px; color: var(--muted); }
.sw-stripe i:first-child { height: 14px; background: var(--primary); }
.sw-stripe i:nth-child(2) { height: 5px; margin: 6px 8px 0; background: var(--border); }
.sw-stripe i:nth-child(3) { height: 5px; width: 36%; margin: 4px 8px 0 auto; background: var(--chip); }
.sw-ledger { background: #fffef8; }
.sw-ledger i { height: 1px; margin: 8px 6px 0; background: #1c1917; }
.sw-compact i:first-child { height: 8px; background: var(--border); }
.sw-compact i:nth-child(2), .sw-compact i:nth-child(3) { height: 3px; margin: 3px 6px 0; background: var(--border); }
.sw-letter i:first-child { height: 10px; width: 28%; margin: 6px 0 0 8px; background: var(--primary); }
.sw-letter i:nth-child(2) { height: 4px; margin: 8px; background: var(--border); }
.sw-letter i:nth-child(3) { display: none; }
.sw-wave i:first-child { height: 10px; width: 34%; margin: 6px 0 0 6px; background: #24548c; }
.sw-wave i:nth-child(2) { height: 8px; width: 42%; margin: 6px 6px 0 auto; background: #111; }
.sw-wave i:nth-child(3) { height: 8px; margin: 6px 6px 0; background: #24548c; }
.fmt-wave { border: 0; border-radius: 0; box-shadow: none; color: #1a1a1a; background: #fff; max-width: 820px; }
.wv-top { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding: 8px 8px 16px; }
.wv-logo { height: 64px; width: auto; max-width: 240px; object-fit: contain; }
.wv-id { text-align: right; }
.wv-kind { font-size: 34px; font-weight: 500; letter-spacing: .04em; line-height: 1; }
.wv-biz { margin-top: 10px; font-size: 13px; line-height: 1.45; }
.wv-biz strong { font-size: 14px; }
.wv-gap { margin-top: 8px; }
.wv-mid { display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid #e4e4e4; padding: 16px 8px 18px; }
.wv-label { font-size: 11px; letter-spacing: .08em; color: #6b7280; font-weight: 650; margin-bottom: 6px; }
.wv-bill { font-size: 13px; line-height: 1.45; max-width: 46%; }
.wv-bill strong { font-size: 15px; }
.wv-meta { margin-left: auto; min-width: 280px; font-size: 13px; }
.wv-meta > div { display: flex; justify-content: flex-end; gap: 16px; padding: 2px 0; }
.wv-meta span { color: #111; font-weight: 650; }
.wv-duebar { background: #f2f2f2; margin-top: 6px; padding: 8px 10px !important; }
.wv-lines { width: 100%; border-collapse: collapse; margin-top: 4px; }
.wv-lines th { background: #24548c; color: #fff; font-weight: 650; font-size: 13px; text-align: left; padding: 8px 10px; }
.wv-lines th:nth-child(2), .wv-lines th:nth-child(3), .wv-lines th:nth-child(4),
.wv-lines td:nth-child(2), .wv-lines td:nth-child(3), .wv-lines td:nth-child(4) { text-align: right; }
.wv-lines td { padding: 10px; border-bottom: 1px solid #ececec; vertical-align: top; font-size: 13px; }
.wv-sub { color: #4b5563; font-size: 12px; margin-top: 2px; white-space: pre-wrap; }
.wv-totals { width: 280px; margin: 14px 8px 8px auto; font-size: 13px; }
.wv-totals > div { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; }
.wv-grand { border-top: 1px solid #d0d0d0; margin-top: 6px; padding-top: 8px !important; font-size: 15px; }
.wv-notes { padding: 22px 8px 8px; font-size: 13px; line-height: 1.5; max-width: 640px; }
.wv-notes p { margin: 8px 0 0; }
.wv-thanks { text-align: center; color: #9aa0a6; margin: 36px 0 8px; font-size: 13px; }
.wv-mark { text-align: center; font-weight: 750; letter-spacing: -.02em; margin: 0 0 12px; }
.sw-lanka { background: #fff; }
.sw-lanka i:first-child { height: 8px; margin: 6px 18px 0; background: #111; }
.sw-lanka i:nth-child(2), .sw-lanka i:nth-child(3) { height: 8px; margin: 4px 6px 0; border: 1px solid #111; }
.fmt-minimal .party-label { letter-spacing: 0; text-transform: none; font-size: 12px; }

.fmt-pick { border: 0; margin: 8px 0 4px; padding: 0; }
.fmt-pick legend { font-size: 16px; font-weight: 650; margin-bottom: 8px; }
.fmt-grid { display: grid; gap: 8px; }
@media (min-width: 720px) { .fmt-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .fmt-grid { grid-template-columns: 1fr 1fr 1fr; } }
.fmt-opt {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
  cursor: pointer;
}
.fmt-opt:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.fmt-opt input { position: absolute; opacity: 0; pointer-events: none; }
.fmt-swatch { height: 48px; border-radius: 6px; border: 1px solid var(--border); background: #fff; overflow: hidden; display: block; position: relative; }
.fmt-swatch i { display: block; }
.sw-classic { background: #fff; }
.sw-classic i:first-child { height: 16px; background: var(--ink); }
.sw-classic i:nth-child(2) { height: 6px; margin: 6px 8px 0; background: var(--border); }
.sw-classic i:nth-child(3) { height: 6px; width: 40%; margin: 4px 8px 0 auto; background: var(--chip); }
.sw-modern { border-left: 4px solid var(--primary); }
.sw-modern i:first-child { height: 8px; width: 46%; margin: 8px 8px 0; background: var(--primary); }
.sw-modern i:nth-child(2) { height: 6px; margin: 8px; background: var(--border); }
.sw-modern i:nth-child(3) { height: 8px; width: 36%; margin-left: auto; margin-right: 8px; background: var(--chip); }
.sw-formal i:first-child { height: 8px; width: 40%; margin: 8px auto 0; background: var(--fg); }
.sw-formal i:nth-child(2), .sw-formal i:nth-child(3) { height: 10px; width: 28%; margin: 6px 0 0 8px; border: 1px solid var(--border); display: inline-block; }
.sw-minimal i:first-child { height: 1px; margin-top: 14px; background: var(--border); }
.sw-minimal i:nth-child(2) { height: 4px; margin: 8px; background: var(--border); }
.sw-minimal i:nth-child(3) { display: none; }
.fmt-name { display: block; font-size: 13px; font-weight: 650; }
.fmt-desc { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; }
.logo-set { display: flex; gap: 14px; align-items: center; margin: 0 0 14px; }
.logo-set img { height: 56px; width: auto; max-width: 180px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.logo-set .field { flex: 1; margin: 0; }

@media print {
  @page { size: A4; margin: 12mm; }
  .no-print,
  .side,
  .drawer,
  .tabbar,
  .install-banner,
  .top,
  .mob,
  dialog,
  .modal { display: none !important; }
  html, body {
    background: #fff !important;
    color: #1b2430 !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
  }
  .app, .main, .page {
    display: block !important;
    width: auto !important;
    max-width: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    overflow: visible !important;
  }
  .paper {
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  .paper, .paper-head, .paper-head * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .paper-head, .paper-body { padding: 16px 0 !important; }
  .paper-head { padding-top: 0 !important; }
  .paper table, .paper thead, .paper tbody, .paper tr, .paper th, .paper td,
  table.data, table.data thead, table.data tbody, table.data tr, table.data th, table.data td {
    display: revert !important;
    width: auto !important;
    padding: revert !important;
    text-align: revert !important;
    border-radius: 0 !important;
    background: transparent !important;
  }
  table.data, .paper table { display: table !important; width: 100% !important; border-collapse: collapse !important; }
  table.data thead, .paper thead { display: table-header-group !important; }
  table.data tbody, .paper tbody { display: table-row-group !important; }
  table.data tr, .paper tr { display: table-row !important; break-inside: avoid; page-break-inside: avoid; }
  table.data th, table.data td, .paper th, .paper td { display: table-cell !important; }
  .paper th, .paper td { padding: 8px 4px !important; }
  table.data th, table.data td { padding: 8px 10px !important; }
  .paper .num, table.data .num { text-align: right !important; }
  table.data td::before, table.data th::before { content: none !important; display: none !important; }
  .paper th, .paper td { overflow-wrap: normal !important; word-break: normal !important; }
  .paper.opt-no-item .col-item,
  .paper.opt-no-description .col-desc,
  .paper.opt-no-qty .col-qty,
  .paper.opt-no-price .col-price,
  .paper.opt-no-tax .col-tax,
  .paper.opt-no-logo .paper-brand img,
  .paper.opt-no-bank .paybox { display: none !important; }
  .fmt-lanka, .fmt-lanka th, .fmt-lanka td {
    color: #111 !important;
    border-color: #111 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .fmt-lanka .lk-lines th { background: #f4f4f4 !important; }
  .fmt-wave .wv-lines th { background: #24548c !important; color: #fff !important; }
  .fmt-wave .wv-duebar { background: #f2f2f2 !important; }
  .card { box-shadow: none !important; break-inside: avoid; }
  a { text-decoration: none !important; }
  a[href]::after { content: none !important; }
}


