:root {
  --accent: #1f5fd1; --bg: #f5f6f8; --card: #fff; --ink: #1b2230; --muted: #6b7385; --line: #e5e7ec;
  --ok: #18794e; --ok-bg: #e3f5ec; --err: #b42318; --err-bg: #fdecea; --warn-bg: #fff4e0; --info-bg: #eef3fd;
  --side: #10192b; --side-ink: #c4cde0; --radius: 10px; --shadow: 0 1px 2px rgba(16,25,43,.06), 0 1px 3px rgba(16,25,43,.04);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
h3 { font-size: 1.02rem; margin: 0 0 .8rem; }
h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .4rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }
.muted { color: var(--muted); } .small, small { font-size: .85rem; } .center { text-align: center; } .right { text-align: right; }
.neg { color: var(--err); } .pad { padding: .8rem 1.2rem; margin: 0; }
code { background: #eef0f4; padding: 0 .3em; border-radius: 4px; }
[hidden] { display: none !important; }
.print-only { display: none; }

/* ---------- layout aplikace ---------- */
body.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-top { padding: 1.1rem 1rem .6rem; display: grid; gap: .7rem; }
.logo { color: #fff; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .4rem; }
.logo:hover { text-decoration: none; }
.logo-mark { color: var(--accent); filter: brightness(1.6); }
.switcher select { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.15); }
.switcher select option { color: var(--ink); }
.new-doc { justify-content: center; }
.sidenav { display: flex; flex-direction: column; padding: .4rem .6rem; gap: 1px; flex: 1; }
.sidenav a { color: var(--side-ink); padding: .5rem .7rem; border-radius: 7px; font-size: .95rem; }
.sidenav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidenav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav-sep { height: 1px; background: rgba(255,255,255,.1); margin: .6rem .4rem; }
.side-bottom { padding: 1rem; font-size: .85rem; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: .6rem; }
.donate-link { color: #ffb4c6; }
.who { color: var(--side-ink); word-break: break-all; }
.who form { margin: .2rem 0 0; }
.linkbtn { background: none; border: 0; color: var(--side-ink); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.mobilebar { display: none; }
.content { padding: 1.6rem 2rem 2rem; max-width: 1280px; width: 100%; }
body.plain .content { margin: 0 auto; padding: 1.5rem 1rem; }
.sitefoot { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; text-align: center; }

/* ---------- karty a mřížky ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow-wide { max-width: 760px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.cols > .card, .cols > form.card { margin-bottom: 0; }
.cols { margin-bottom: 1rem; }
.cols.tight { gap: 1.5rem; margin: 0; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead h1 { margin: 0; }
.crumbs { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.btns { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.auth { max-width: 430px; margin: 6vh auto 0; }
.auth-brand { text-align: center; font-size: 1.5rem; font-weight: 800; }
.auth-claim { text-align: center; color: var(--muted); margin: .2rem 0 1.2rem; }
.auth h1 { font-size: 1.3rem; }
.prose { max-width: 820px; } .prose li { margin-bottom: .5rem; }
.danger-zone { border-color: #f3c8c3; }
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.company-card { margin: 0; } .company-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1rem; align-items: start; }
.doc-layout > form { min-width: 0; }
.doc-side .card { padding: 1rem; }
.doc-side h3 { margin-bottom: .6rem; }
.doc-side .grid { grid-template-columns: 1fr; }
.pay-row { display: flex; gap: .5rem; align-items: center; justify-content: space-between; font-size: .9rem; padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.pay-row span { color: var(--muted); }
.pay-form { margin-top: .8rem; }
.public-actions { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 0 auto 1rem; max-width: 860px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 1rem 0 .4rem; }
.sticky { position: sticky; top: 1rem; }

/* ---------- formuláře ---------- */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem 1rem; }
.grid.three { grid-template-columns: 1fr 1fr 2fr; } .grid.four { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; }
.fld { display: block; margin-bottom: .8rem; }
.fld > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .2rem; font-weight: 500; }
.fld small { display: block; color: var(--muted); margin-top: .2rem; }
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: .5rem .65rem; border: 1px solid #cfd4dd; border-radius: 7px; background: #fff; }
input[type=color] { padding: .15rem; height: 2.4rem; }
input[type=file] { padding: .35rem; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--accent) 22%, transparent); border-color: var(--accent); }
input[readonly] { background: #f3f4f6; }
.input-group { display: flex; gap: .4rem; } .input-group input { flex: 1; min-width: 0; }
.check { display: flex; align-items: flex-start; gap: .5rem; margin: .4rem 0 .8rem; }
.check input { width: auto; margin-top: .25rem; }
.inline-check { display: inline-flex; margin: 0; }
.filters { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; padding: .9rem 1.2rem; }
.filters .fld { margin: 0; min-width: 130px; } .filters .grow { flex: 1; min-width: 200px; }
.filters .spacer { flex: 1; }
.kv-inline { display: flex; flex-direction: column; font-size: .85rem; } .kv-inline span { color: var(--muted); }
.small-input { width: auto; padding: .3rem .5rem; font-size: .9rem; }
form.inline { display: inline-flex; gap: .3rem; align-items: center; margin: 0; }
.hp { position: absolute; left: -9999px; }
.pair-form { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.pair-form select { width: auto; max-width: 300px; padding: .3rem; }
.pair-other { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.pair-other input, .pair-other select { width: 140px; padding: .3rem; }

/* ---------- tlačítka ---------- */
.btn { display: inline-flex; align-items: center; gap: .3rem; padding: .5rem .95rem; border-radius: 7px; border: 1px solid #cfd4dd;
  background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: #f3f5f9; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.92); }
.btn.danger { color: var(--err); border-color: #f0c4bf; } .btn.danger:hover { background: var(--err-bg); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn.wide { width: 100%; justify-content: center; }
details.menu { position: relative; }
details.menu > summary { list-style: none; } details.menu > summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16,25,43,.12); min-width: 240px; z-index: 20; padding: .3rem; display: grid; }
.menu-body form { display: block; }
.menu-item { display: block; width: 100%; text-align: left; padding: .5rem .7rem; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; border-radius: 6px; }
.menu-item:hover { background: #f3f5f9; text-decoration: none; } .menu-item.danger { color: var(--err); }

/* ---------- záložky ---------- */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { background: #eceef2; border-radius: 999px; padding: 0 .45rem; font-size: .78rem; margin-left: .2rem; color: var(--muted); }
.small-tabs { border: 0; margin: 0; } .small-tabs a { padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px; margin: 0; font-size: .88rem; }
.small-tabs a.active { border-color: var(--accent); color: var(--accent); }

/* ---------- tabulky ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.card.flush .tbl th:first-child, .card.flush .tbl td:first-child { padding-left: 1.2rem; }
.tbl th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.tbl tfoot td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--line); background: #fafbfc; }
.tbl.small td { padding: .4rem .55rem; font-size: .9rem; }
.tbl tr.clickable { cursor: pointer; } .tbl tr.clickable:hover td { background: #f7f9fc; }
.tbl tr.dim td { opacity: .5; }
.tbl tr.sec td { font-weight: 600; background: #f6f7f9; font-size: .85rem; }
.tbl td:first-child { white-space: nowrap; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
input.num { text-align: right; }
.actions { white-space: nowrap; }
.items td { padding: .3rem; }
.w-full { width: 100%; } .w-xs { width: 4.5rem; } .w-sm { width: 6rem; } .w-md { width: 9rem; }
.totals { margin-top: 1rem; display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.totals div { display: flex; gap: 2rem; } .totals span { color: var(--muted); }
.totals .grand { font-size: 1.25rem; font-weight: 700; }
.tag { color: var(--muted); font-size: .8rem; margin-left: .3rem; }

/* ---------- štítky, hlášky, statistiky ---------- */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; background: #eef0f4; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.err { background: var(--err-bg); color: var(--err); }
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.flash-ok { background: var(--ok-bg); color: var(--ok); } .flash-err { background: var(--err-bg); color: var(--err); }
.flash-info { background: var(--info-bg); color: #1a3f86; }
.flash-warn { background: var(--warn-bg); color: #7a4a00; justify-content: space-between; }
.disclaimer { background: var(--warn-bg); border-color: #f3dcae; color: #5c3b00; font-size: .9rem; padding: .7rem 1rem; }
.disclaimer-list { background: var(--warn-bg); border: 1px solid #f3dcae; border-radius: 8px; padding: .7rem 1rem .7rem 1.2rem; font-size: .88rem; color: #5c3b00; margin: .8rem 0; }
.disclaimer-list ul { margin: .4rem 0 0; padding-left: 1rem; } ul.disclaimer-list { padding-left: 2rem; } .disclaimer-list li { margin-bottom: .35rem; }
.wide-auth { max-width: 620px; }
.archive-card { border-left: 4px solid var(--accent); }
.filters.flat { padding: 0; margin: .6rem 0; box-shadow: none; border: 0; }
.import-form { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; } .import-form .fld { margin: 0; }
.scroll-x { overflow-x: auto; }
.sitefoot p { margin: .3rem 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: .82rem; }
.stat strong { display: block; font-size: 1.3rem; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.stat em { font-style: normal; font-size: .8rem; color: var(--muted); }
.stat.accent { border-top: 3px solid var(--accent); } .stat.warn { background: var(--warn-bg); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem 2rem; margin: 1rem 0 1.5rem; }
.kv div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--line); padding: .3rem 0; }
.kv span { color: var(--muted); } .kv .big { grid-column: span 2; font-size: 1.15rem; border-bottom: 0; }
.onboarding { border-left: 4px solid var(--accent); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.checklist li.done { color: var(--ok); } .checklist li.done a { color: var(--ok); text-decoration: line-through; }
.toprow { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; margin-bottom: .6rem; font-size: .92rem; }
.topbar { grid-column: span 2; height: 6px; background: #eef0f4; border-radius: 3px; overflow: hidden; }
.topbar i { display: block; height: 100%; background: var(--accent); }
.donate-box { display: flex; gap: 2rem; align-items: center; justify-content: space-between; background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.2rem; margin: 1rem 0; flex-wrap: wrap; }
.donate-box .big { font-size: 1.3rem; }

/* ---------- graf ---------- */
.bars { display: flex; align-items: flex-end; gap: .4rem; height: 170px; padding-top: .5rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar { width: 40%; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar.in, .dot.in { background: var(--accent); } .bar.out, .dot.out { background: #e3833b; }
.bar-col small { color: var(--muted); } .legend { font-size: .85rem; color: var(--muted); }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin: 0 .3rem 0 .8rem; vertical-align: middle; }

/* ---------- doklad ---------- */
.invoice { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 2.5rem; max-width: 860px; margin: 0 auto; box-shadow: var(--shadow); }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 3px solid var(--accent); padding-bottom: .9rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.inv-supplier-name { color: var(--accent); font-weight: 700; }
.inv-head h1 { margin: .1rem 0 0; font-size: 1.45rem; }
.inv-vs { text-align: right; font-size: .85rem; color: var(--muted); } .inv-vs strong { font-size: 1.2rem; color: var(--ink); }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-bottom: 1.5rem; }
.inv-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem 1.5rem; background: #f6f7f9; padding: 1rem; border-radius: 8px; margin-bottom: 1.5rem; }
.inv-meta span { display: block; font-size: .72rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
.inv-items { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.inv-items th { border-bottom: 2px solid var(--ink); text-align: left; padding: .4rem; font-size: .76rem; text-transform: uppercase; }
.inv-items td { border-bottom: 1px solid var(--line); padding: .5rem .4rem; vertical-align: top; }
.inv-bottom { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-start; }
.inv-qr { text-align: center; min-width: 150px; } .inv-qr img, .inv-qr canvas { margin: 0 auto; }
.inv-sum { flex: 1; max-width: 460px; }
.recap { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: .6rem; }
.recap th, .recap td { padding: .25rem .4rem; border-bottom: 1px solid var(--line); text-align: left; }
.inv-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 3px solid var(--ink); padding-top: .6rem; margin-top: .4rem; }
.inv-total strong { font-size: 1.55rem; }
.paid-stamp { color: var(--ok); font-weight: 700; text-align: right; }
.inv-note { margin-top: 1.5rem; }
.inv-foot { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: .8rem; font-size: .85rem; color: var(--muted); }

/* ---------- mobil ---------- */
@media (max-width: 1100px) { .doc-layout { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  body.app { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .mobilebar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem 1rem; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 40; }
  .content { padding: 1rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: .5rem; } .stat strong { font-size: 1.05rem; }
  .cols, .grid, .grid.three, .grid.four, .inv-parties, .kv { grid-template-columns: 1fr; }
  .span2, .kv .big { grid-column: auto; }
  .inv-meta { grid-template-columns: 1fr 1fr; }
  .inv-bottom { flex-direction: column-reverse; }
  .invoice { padding: 1.2rem; }
  .tbl { display: block; overflow-x: auto; }
}

/* ---------- tisk ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body, body.app { background: #fff; font-size: 10.5pt; display: block; }
  .no-print, .sidebar, .mobilebar, .flash, .sitefoot, .doc-side, .tabs { display: none !important; }
  .print-only { display: block; }
  .content { padding: 0; max-width: none; }
  .doc-layout { display: block; }
  .invoice { border: 0; padding: 0; max-width: none; box-shadow: none; }
  .card { border: 0; padding: 0; box-shadow: none; }
  a { color: inherit; }
  .inv-meta { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
