:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
  --side: #111827;
  --radius: 8px;
  --tabbar-h: 0px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* dotyk: bez oneskorenia a dvojitého ťuknutia na približovanie pri ovládacích prvkoch */
a, button, .btn, input, select, textarea, label, summary, tr.click, .checkcell { touch-action: manipulation; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
@media (hover: hover) { a:hover { text-decoration: underline; } }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* rozloženie */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--side) 240px, var(--bg) 240px); }
.side { background: var(--side); color: #d1d5db; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #fff; font-weight: 700; font-size: 17px; padding: 4px 8px 12px; }
.side select { width: 100%; margin-bottom: 10px; background: #1f2937; color: #fff; border: 1px solid #374151; }
.side a { color: #d1d5db; padding: 8px 10px; border-radius: 6px; display: block; }
@media (hover: hover) { .side a:hover { background: #1f2937; text-decoration: none; } }
.side a.active { background: var(--primary); color: #fff; }
.side .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b7280; padding: 14px 10px 4px; }
.side .foot { margin-top: auto; font-size: 12px; color: #9ca3af; padding: 12px 8px 0; border-top: 1px solid #1f2937; }
.main { padding: 24px 28px 60px; min-width: 0; }
.topbar { display: none; }

/* mobilné prvky – na počítači skryté */
.tabbar, .scrim { display: none; }
@media (min-width: 861px) { .m-only { display: none !important; } }

/* panely */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }

/* formuláre */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; width: 100%; padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; flex: none; }
.field { min-width: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: 14px; }
.check input { margin-top: 3px; }

button, .btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid #d1d5db; background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.danger { color: var(--danger); border-color: #fecaca; }
@media (hover: hover) {
  button:hover, .btn:hover { background: #f9fafb; text-decoration: none; }
  button.primary:hover, .btn.primary:hover { background: var(--primary-d); }
  button.danger:hover { background: #fef2f2; }
}
button.link { border: 0; background: none; color: var(--primary); padding: 2px 4px; }
button:disabled { opacity: .55; cursor: default; }
button.sm, .btn.sm { padding: 4px 9px; font-size: 13px; }

/* tabuľky */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f9fafb; }
tr.click { cursor: pointer; }
@media (hover: hover) { tr.click:hover td { background: #f8fafc; } }
td.num, th.num { text-align: right; white-space: nowrap; }
.lines td { padding: 4px; vertical-align: middle; }
.lines input, .lines select { padding: 5px 6px; }

/* štítky */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e5e7eb; color: #374151; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.err { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.alert.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* prihlásenie */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login .box { width: 100%; max-width: 340px; background: #fff; border-radius: 12px; padding: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.08); text-align: center; }
.pin { font-size: 26px; letter-spacing: .4em; text-align: center; padding: 10px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.keypad button { justify-content: center; font-size: 20px; padding: 12px; }

/* modálne okno */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto; overscroll-behavior: contain; padding: 20px 22px; }
.modal.wide { max-width: 940px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.toast { position: fixed; bottom: 18px; right: 18px; z-index: 60; background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 420px; }
.toast.err { background: #991b1b; }

.preview { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #fff; overflow-x: auto; }
.totals { margin-left: auto; min-width: 280px; }
.totals td { border: 0; padding: 3px 8px; }
.totals tr.sum td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--line); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; }
.tabs button.on { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px; }

/* našepkávanie odberateľa */
.suggest { position: relative; }
.suggest-list { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; margin-top: 2px; background: var(--panel); border: 1px solid #d1d5db; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 360px; overflow-y: auto; }
.suggest-item { padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item.active { background: #eff6ff; }
.suggest-note { padding: 8px 10px; color: var(--muted); font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
tr.unread td { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-right: 6px; vertical-align: middle; }
.badge.tag { background: #ede9fe; color: #5b21b6; cursor: pointer; font-weight: 500; }
.badge.tag .link { padding: 0 0 0 4px; font-size: 11px; color: inherit; }

/* zabezpečenie prihlásenia (2FA) */
.method-icon { font-size: 26px; width: 40px; text-align: center; line-height: 1.2; }
.method.off { background: #f3f4f6; border-style: dashed; }
.method.off h2, .method.off .method-icon { color: #9ca3af; filter: grayscale(1); }
.method.off .muted { color: #9ca3af; }
.method-note { margin-top: 8px; font-size: 12.5px; color: #4b5563; background: #e5e7eb; border-radius: 6px; padding: 6px 10px; display: inline-block; }
.steps { margin: 0 0 12px; padding-left: 20px; }
.steps li { margin-bottom: 6px; }
.secret { display: inline-block; margin-top: 4px; padding: 4px 8px; background: #f3f4f6; border-radius: 6px; font-size: 14px; letter-spacing: .05em; user-select: all; }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 8px; line-height: 0; }
.qr svg { display: block; width: 196px; height: 196px; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 24px; padding: 12px 16px; background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; font-size: 16px; }

/* schvaľovanie prijatých faktúr – zoznam na schválenie a kontrola položiek */
.progress { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; min-width: 70px; flex: 0 0 auto; }
.progress > div { height: 100%; background: var(--ok); transition: width .2s; }
.progress.issue > div { background: var(--warn); }
.checkcell { width: 40px; text-align: center; vertical-align: middle !important; cursor: pointer; user-select: none; }
.checkcell input[type=checkbox], .bigcheck { width: 20px; height: 20px; margin: 0; cursor: pointer; accent-color: var(--ok); vertical-align: middle; }
table.checklist tr.ok td { background: #f0fdf4; }
table.checklist tr.issue td, table.checklist tr.editor td { background: #fffbeb; }
@media (hover: hover) {
  table.checklist tr.ok:hover td { background: #dcfce7; }
  table.checklist tr.issue:hover td { background: #fef3c7; }
}
table.checklist tr.editor td { border-top: 0; padding-top: 2px; }
.issue-mark { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--warn); color: #fff; font-weight: 700; font-size: 13px; }
.issue-text { color: #92400e; font-size: 12.5px; margin-top: 2px; }
button.issue-btn { color: #92400e; border-color: #fde68a; }
@media (hover: hover) { button.issue-btn:hover { background: #fffbeb; } }
.check-who { color: var(--muted); font-size: 11.5px; }
.stickybar { position: sticky; bottom: 0; z-index: 10; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px -18px -16px; padding: 10px 18px;
  background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -6px 14px rgba(0,0,0,.06); border-radius: 0 0 var(--radius) var(--radius); }
.bulkbar { position: sticky; bottom: 12px; z-index: 15; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; margin-top: 12px;
  background: var(--side); color: #fff; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.bulkbar button:not(.primary) { background: transparent; color: #e5e7eb; border-color: #4b5563; }
@media (hover: hover) { .bulkbar button:not(.primary):hover { background: #1f2937; } }
button.ok-btn { background: var(--ok); border-color: var(--ok); color: #fff; }
@media (hover: hover) { button.ok-btn:hover { background: #166534; } }
button.confirm-btn { background: #fef3c7; border-color: #f59e0b; color: #92400e; font-weight: 600; }
.result-ok { color: var(--ok); font-weight: 700; }
.result-err { color: var(--danger); font-weight: 700; }
.nav-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: #f59e0b; color: #111827; font-size: 11.5px; font-weight: 700; text-align: center; line-height: 18px; }
/* spodný panel formulára faktúry (na počítači ako doteraz) */
input[type=search] { -webkit-appearance: none; appearance: none; }
/* „Vybrať všetky“ v hlavičke zoznamu: na počítači len zaškrtávacie pole, v mobile aj s textom */
label.chk-all { display: contents; }
.formbar { position: sticky; bottom: 0; z-index: 12; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--bg); padding: 10px 0; }


/* ======================================================================
   Mobilné zariadenia (telefóny, tablety na výšku) – ovládanie dotykom a palcom.
   Na počítači (šírka nad 860 px) sa nič z tohto bloku neuplatní.
   ====================================================================== */
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 860px) {
  :root { --tabbar-h: calc(58px + env(safe-area-inset-bottom, 0px)); --gut: 12px; }
  /* pri písaní (otvorená klávesnica) spodný panel skryjeme – viac miesta pre formulár */
  body.kb, body.notab { --tabbar-h: 0px; }
  body.notab .tabbar { display: none; }
  body { font-size: 15px; -webkit-tap-highlight-color: transparent; }
  body:has(.modal-bg), body:has(.side.open) { overflow: hidden; }
  h1 { font-size: 21px; line-height: 1.25; margin-bottom: 12px; }
  h2 { font-size: 17px; }
  .small { font-size: 13px; }
  .hide-sm { display: none !important; }

  /* rozloženie: horná lišta, vysúvacie menu, obsah nad spodným panelom */
  .layout { grid-template-columns: 1fr; background: var(--bg); min-height: 0; }
  .main { padding: 14px var(--gut) calc(var(--tabbar-h) + 28px); }
  .topbar { display: flex; align-items: center; gap: 4px; padding: calc(4px + env(safe-area-inset-top, 0px)) 6px 4px; min-height: 52px;
    background: var(--side); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar button { background: none; border: 0; color: #fff; width: 44px; height: 44px; min-height: 0; padding: 0; justify-content: center; border-radius: 10px; flex: none; }
  .topbar button:active { background: rgba(255,255,255,.12); }
  .topbar svg { width: 24px; height: 24px; }
  .topbar .tb-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 8px; }
  .side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw, 320px); height: 100%; transform: translateX(-100%); transition: transform .22s ease-out;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 12px calc(16px + env(safe-area-inset-bottom, 0px)); overscroll-behavior: contain; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .side a { padding: 12px; font-size: 16px; border-radius: 10px; }
  .side a:active { background: #1f2937; }
  .side select { min-height: 44px; }
  .side .foot { display: flex; flex-direction: column; font-size: 14px; padding-top: 10px; }
  .side .foot > div { padding: 4px 12px 6px; }
  .side .foot .dotsep { display: none; }
  .side .foot button.link, .side .foot a { display: block !important; text-align: left; padding: 11px 12px !important; min-height: 44px; font-size: 15px; color: #d1d5db !important; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(17,24,39,.45); animation: fade-in .2s; }

  /* spodný panel s kartami – na dosah palca */
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    height: var(--tabbar-h); padding: 0 4px env(safe-area-inset-bottom, 0px); background: rgba(255,255,255,.96);
    -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px); border-top: 1px solid var(--line); }
  body.kb .tabbar { display: none; }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0;
    min-height: 0; padding: 4px 2px; border: 0; border-radius: 12px; background: none; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.1; white-space: nowrap; text-decoration: none; }
  .tabbar a:active, .tabbar button:active { background: #f3f4f6; }
  .tabbar .on { color: var(--primary); font-weight: 650; }
  .tabbar svg { width: 24px; height: 24px; flex: none; }
  .tabbar .tab-new .ico { display: grid; place-items: center; width: 46px; height: 34px; border-radius: 12px; background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(37,99,235,.35); }
  .tabbar .tab-new.on .ico { background: var(--primary-d); }
  .tabbar .tab-new:active { background: none; }
  .tabbar .tab-new:active .ico { transform: scale(.94); }
  .tabbar .tab-badge { position: absolute; top: 3px; left: calc(50% + 5px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #f59e0b; color: #111827;
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

  /* karty, mriežky */
  .card { padding: 14px; border-radius: 12px; margin-bottom: 12px; }
  .stat { padding: 12px 14px; border-radius: 12px; }
  .stat .v { font-size: 19px; }
  .grid { gap: 12px 10px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .g3, .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2 > [style*="grid-column"] { grid-column: 1 / -1 !important; }
  .grid > .full, .grid > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* pole s dlhším popisom zarovná vstup s vedľajším poľom */
  .grid > .field { display: flex; flex-direction: column; justify-content: flex-end; }
  .row:has(> h1) { row-gap: 8px; margin-bottom: 12px; }
  .row > h1 { margin-bottom: 0; }
  .row:has(> h1) > .btn, .row:has(> h1) > button { min-height: 40px; padding: 8px 12px; font-size: 14px; }
  .m-full { width: 100% !important; min-width: 0 !important; max-width: none !important; flex: 1 1 100% !important; }
  .kv { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 6px 12px; }
  .kv > div { overflow-wrap: anywhere; }

  /* ovládacie prvky: najmenej 44 px, písmo 16 px (iOS pri písaní nepribližuje stránku) */
  input, select, textarea { font-size: 16px; min-height: 44px; padding: 9px 11px; border-radius: 10px; }
  /* vlastný vzhľad zoznamu (Safari inak dlhý text vytlačí mimo pole) */
  select { -webkit-appearance: none; appearance: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 34px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 18px; }
  .side select { background-color: #1f2937; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
  select:disabled { background-color: #f3f4f6; }
  input[type=date] { display: block; -webkit-appearance: none; appearance: none; background: #fff; text-align: left; }
  input[type=date]::-webkit-date-and-time-value { text-align: left; }
  input[type=checkbox], input[type=radio] { min-height: 0; width: 22px; height: 22px; padding: 0; accent-color: var(--primary); }
  textarea { min-height: 96px; }
  label { font-size: 13px; margin-bottom: 4px; }
  .check { font-size: 15px; gap: 10px; padding: 8px 0; }
  .check input { margin-top: 0; }
  button, .btn { min-height: 44px; padding: 10px 16px; border-radius: 10px; justify-content: center; }
  button.sm, .btn.sm { min-height: 40px; padding: 8px 12px; font-size: 14px; }
  button.link { min-height: 40px; min-width: 40px; padding: 8px; justify-content: center; }
  button:active:not(:disabled), .btn:active { filter: brightness(.94); transform: scale(.985); }
  .pin { font-size: 26px; }
  .keypad { gap: 10px; }
  .keypad button { min-height: 56px; font-size: 22px; border-radius: 14px; }
  .login { padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); }
  .login .box { padding: 24px 20px; }
  .login .box a { display: inline-block; padding: 10px; }
  .badge { font-size: 12px; padding: 2px 9px; }
  .badge.tag { padding: 4px 10px; font-size: 13px; }
  .badge.tag:has(.link) { display: inline-flex; align-items: center; padding: 0 0 0 10px; }
  .badge.tag .link { min-height: 32px; min-width: 32px; padding: 0 8px 0 6px; font-size: 14px; }
  .alert { border-radius: 10px; }
  .tabs { flex-wrap: nowrap; gap: 0; border: 0; background: #e5e7eb; border-radius: 10px; padding: 3px; margin-bottom: 12px; }
  .tabs button { flex: 1; min-height: 38px; border: 0; border-radius: 8px; padding: 6px 8px; font-size: 14px; color: var(--muted); }
  .tabs button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); border: 0; }
  .pager { justify-content: center; gap: 10px; flex-wrap: wrap; }
  .pager > span { white-space: nowrap; }
  .pager button { min-width: 48px; font-size: 18px; }
  .pager > .muted { flex: 1 1 100%; text-align: center; }

  /* filtre zoznamov: hľadanie + tlačidlo „Filtre“, ostatné po rozbalení */
  .filters .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .filters .grid > :first-child { grid-column: 1 / 3; }
  .filters .f-toggle { align-self: end; gap: 6px; }
  .filters .f-toggle .nav-count { margin: 0; }
  .filters .f-more { grid-column: 1 / -1; }
  .filters .f-half { grid-column: span 1; }
  .filters .f-half + .f-half { grid-column: 2 / -1; }
  .filters:not(.open) .f-more { display: none; }

  /* panely akcií v detaile dokladu – mriežka rovnako veľkých tlačidiel */
  .actbar { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .actbar > .spacer { display: none; }
  .actbar > .primary, .actbar > select { grid-column: 1 / -1; width: 100% !important; }
  .actbar > button, .actbar > .btn { white-space: normal; text-align: center; line-height: 1.2; padding: 8px 6px; }
  .decide { gap: 8px; }
  .decide > button { flex: 1 1 40%; }

  /* spodný panel formulára faktúry: hlavné tlačidlo cez celú šírku, ostatné pod ním */
  .formbar { bottom: var(--tabbar-h); display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin: 0 calc(-1 * var(--gut));
    padding: 10px var(--gut) calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(244,245,247,.95); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
  .formbar > .spacer { display: none; }
  .formbar > button, .formbar > .btn { padding: 8px 6px; white-space: normal; line-height: 1.2; }
  body.kb .formbar { padding-bottom: 10px; }
  .stickybar { bottom: var(--tabbar-h); margin: 14px -14px -14px; padding: 10px 14px; border-radius: 0 0 12px 12px; }
  .stickybar > button { flex: 1 1 100%; }
  .bulkbar { bottom: calc(var(--tabbar-h) + 8px); border-radius: 14px; }
  .bulkbar > button { flex: 1 1 40%; }
  .toast { left: var(--gut); right: var(--gut); bottom: calc(var(--tabbar-h) + 12px); max-width: none; border-radius: 12px; padding: 12px 16px; text-align: center; animation: fade-in .15s; }

  /* modálne okná ako panel vysúvaný zdola (bottom sheet) */
  .modal-bg { place-items: end stretch; padding: 0; animation: fade-in .15s; }
  .modal, .modal.wide { max-width: none; max-height: calc(100dvh - 20px - env(safe-area-inset-top, 0px)); border-radius: 18px 18px 0 0; padding: 0 16px;
    animation: sheet-up .24s cubic-bezier(.2,.8,.3,1); }
  .modal::after { content: ''; display: block; height: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .modal-head { position: sticky; top: 0; z-index: 3; background: #fff; padding: 18px 0 8px; flex-wrap: nowrap !important; }
  .modal-head::before { content: ''; position: absolute; top: 7px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: #d1d5db; }
  .modal-head h2 { font-size: 18px; }
  .modal .actions { position: sticky; bottom: calc(-12px - env(safe-area-inset-bottom, 0px)); z-index: 3; background: #fff; margin: 12px -16px 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
  .modal .actions > button, .modal .actions > .btn { flex: 1 1 0; }
  .modal .actions > .spacer { display: none; }
  .preview { padding: 8px; }

  /* tabuľky */
  th, td { padding: 10px 8px; }
  .lines td { padding: 0; }
  .lines input, .lines select { padding: 9px 11px; }
  .checkcell { width: 44px; }
  .checkcell input[type=checkbox], .bigcheck { width: 24px; height: 24px; }
  tr.click:active td { background: #eef2ff; }
  table.checklist th, table.checklist td { padding: 10px 6px; }
  table.checklist td { overflow-wrap: anywhere; }
  table.checklist button.issue-btn { min-width: 44px; padding: 6px 10px; }

  /* zoznamy dokladov ako riadky v mobilnej aplikácii (bez posúvania do strany) */
  .tablewrap:has(> table.mlist), .tablewrap:has(> table.stack) { overflow: visible; }
  table.mlist, table.mlist > tbody { display: block; }
  table.mlist > thead { display: block; }
  table.mlist > thead:not(:has(.c-chk)) { display: none; }
  table.mlist > thead > tr { display: flex; align-items: center; min-height: 0; padding: 0 0 8px; border-bottom: 1px solid var(--line); }
  table.mlist > thead th { display: none; }
  table.mlist > thead label.chk-all { display: flex; align-items: center; gap: 10px; margin: 0; color: inherit; font-size: inherit; }
  table.mlist > thead th.c-chk { display: flex; align-items: center; gap: 10px; width: auto !important; padding: 4px 6px; background: none; border: 0; font-size: 14px; font-weight: 500; color: var(--text); }
  table.mlist > tbody > tr { display: grid; column-gap: 12px; row-gap: 3px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--line); }
  table.mlist > tbody > tr:last-child { border-bottom: 0; }
  table.mlist > tbody > tr > td { display: block; padding: 0; border: 0; min-width: 0; background: none !important; text-align: left; white-space: normal; }
  table.mlist > tbody > tr.click:active { background: #eef2ff; border-radius: 10px; }
  table.mlist .c-amt { text-align: right; font-weight: 650; white-space: nowrap; }
  table.mlist .c-sub, table.mlist .c-num, table.mlist .c-date, table.mlist .c-due { font-size: 13px; color: var(--muted); }
  table.mlist .c-date, table.mlist .c-due { text-align: right; white-space: nowrap; }
  table.mlist > tbody .c-chk { grid-area: chk; align-self: stretch; display: flex; align-items: center; justify-content: center; width: 36px; margin: -12px 0; }
  table.mlist .c-chk input { width: 24px; height: 24px; }
  table.mlist .c-st .row { flex-wrap: wrap; }
  /* vystavené doklady */
  table.inv > tbody > tr { grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "chk cust amt" "chk num date" "chk st due"; }
  table.inv.nochk > tbody > tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "cust amt" "num date" "st due"; }
  table.inv .c-cust { grid-area: cust; font-weight: 600; }
  table.inv .c-num { grid-area: num; }
  table.inv .c-date { grid-area: date; }
  table.inv .c-amt { grid-area: amt; }
  table.inv .c-st { grid-area: st; }
  table.inv .c-due { grid-area: due; }
  /* prijaté faktúry */
  table.recv > tbody > tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "sup amt" "num date" "st due"; }
  table.recv .c-sup { grid-area: sup; font-weight: 600; }
  table.recv tr.unread .c-sup { font-weight: 700; }
  table.recv .c-num { grid-area: num; }
  table.recv .c-date { grid-area: date; }
  table.recv .c-amt { grid-area: amt; }
  table.recv .c-st { grid-area: st; }
  table.recv .c-due { grid-area: due; }
  /* na schválenie */
  table.appr > tbody > tr { grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "chk sup amt" "chk sup due" "chk prog act"; }
  table.appr .c-sup { grid-area: sup; }
  table.appr .c-amt { grid-area: amt; }
  table.appr .c-due { grid-area: due; color: var(--text); }
  table.appr .c-prog { grid-area: prog; }
  table.appr .c-act { grid-area: act; text-align: right; }
  table.appr .c-act button { min-width: 120px; }
  /* položky v detaile vystaveného dokladu */
  table.dlines > thead { display: none; }
  table.dlines > tbody > tr { grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "name name name amt" "qty price vat vat"; column-gap: 8px; padding: 10px 0; }
  table.dlines .c-name { grid-area: name; }
  table.dlines .c-amt { grid-area: amt; font-weight: 600; }
  table.dlines .c-qty, table.dlines .c-price, table.dlines .c-vat { font-size: 13px; color: var(--muted); text-align: left; }
  table.dlines .c-qty { grid-area: qty; }
  table.dlines .c-price { grid-area: price; }
  table.dlines .c-vat { grid-area: vat; }
  table.dlines .c-vat::before { content: '· '; }
  /* odberatelia */
  table.cust > tbody > tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name pep" "ids city" "mail mail" "act act"; }
  table.cust .c-name { grid-area: name; }
  table.cust .c-pep { grid-area: pep; text-align: right; }
  table.cust .c-ids { grid-area: ids; color: var(--muted); }
  table.cust .c-ids .muted { display: inline; margin-left: 6px; }
  table.cust .c-city { grid-area: city; text-align: right; color: var(--muted); font-size: 13px; }
  table.cust .c-mail { grid-area: mail; overflow-wrap: anywhere; }
  table.cust .c-act { grid-area: act; display: flex; gap: 8px; margin-top: 6px; }
  table.cust .c-act > * { flex: 1 1 0; }
  /* položky faktúry vo formulári ako karty */
  table.mlines, table.mlines > tbody { display: block; }
  table.mlines > thead { display: none; }
  table.mlines > tbody > tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "name name" "qty unit" "price disc" "vat vat" "sum del";
    gap: 8px 10px; padding: 12px; margin-bottom: 10px; background: #f9fafb; border: 1px solid var(--line); border-radius: 12px; }
  table.mlines > tbody > tr > td { display: block; border: 0; padding: 0; min-width: 0; }
  table.mlines td[data-label]::before { content: attr(data-label); display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
  table.mlines .c-name { grid-area: name; }
  table.mlines .c-qty { grid-area: qty; }
  table.mlines .c-unit { grid-area: unit; }
  table.mlines .c-price { grid-area: price; }
  table.mlines .c-vat { grid-area: vat; }
  table.mlines .c-disc { grid-area: disc; }
  table.mlines .c-sum { grid-area: sum; align-self: center; text-align: left; font-weight: 650; white-space: normal; }
  table.mlines .c-sum::before { display: inline !important; margin-right: 6px; font-weight: 400; }
  table.mlines .c-del { grid-area: del; text-align: right; }
  table.mlines .c-del button { color: var(--danger); }
  /* hromadné schválenie: stav faktúry pod názvom */
  table.bulk, table.bulk > tbody, table.bulk > tfoot { display: block; }
  table.bulk tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  table.bulk td { display: block; padding: 0; border: 0; }
  table.bulk td:nth-child(3) { grid-column: 1 / -1; }
  table.bulk td:empty { display: none; }
  /* ostatné tabuľky (administrácia, nastavenia): riadok ako karta „popis – hodnota“ */
  table.stack, table.stack > tbody, table.stack > tbody > tr, table.stack > tbody > tr > td { display: block; width: 100%; }
  table.stack > thead { display: none; }
  table.stack > tbody > tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack > tbody > tr:last-child { border-bottom: 0; }
  table.stack > tbody > tr > td { position: relative; border: 0; padding: 3px 0 3px 40%; text-align: left; white-space: normal; max-width: none !important; min-height: 24px; }
  table.stack > tbody > tr > td::before { content: attr(data-label); position: absolute; left: 0; top: 3px; width: calc(40% - 10px); color: var(--muted); font-size: 13px; }
  table.stack > tbody > tr > td:first-child, table.stack > tbody > tr > td:not([data-label]), table.stack > tbody > tr > td[data-label=""] { padding-left: 0; }
  table.stack > tbody > tr > td:first-child::before, table.stack > tbody > tr > td[data-label=""]::before { display: none; }
  table.stack > tbody > tr > td:first-child { font-size: 15px; padding-bottom: 6px; }
  table.stack > tbody > tr > td:empty { display: none; }
  table.stack > tbody > tr > td[data-label=""] { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
  table.stack > tbody > tr > td[data-label=""] > * { flex: 1 1 auto; }
  table.stack > tbody > tr > td { overflow-wrap: anywhere; }
  table.stack input[type=number], table.stack select { width: 100% !important; max-width: 100%; }
}
/* veľmi malé displeje (iPhone SE 1. gen., menšie Androidy) */
@media (max-width: 360px) {
  :root { --gut: 10px; }
  body { font-size: 14.5px; }
  h1 { font-size: 19px; }
  .card { padding: 12px; }
  .tabbar a, .tabbar button { font-size: 10px; }
  .stat .v { font-size: 17px; }
  table.checklist th, table.checklist td { padding: 9px 4px; }
  table.checklist .checkcell { width: 36px; }
  table.checklist button.issue-btn { min-width: 40px; padding: 6px 8px; }
}
