:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --ink: #1b2420;
  --muted: #6d746f;
  --line: #e6e2d9;
  --nav: #182420;
  --accent: #1f5c45;
  --accent-bg: #e3efe8;
  --red: #b4322f;
  --red-bg: #fbecec;
  --amber: #a86b0c;
  --amber-bg: #fbf0d6;
  --blue: #2c5d8a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(24,36,32,.06), 0 6px 18px rgba(24,36,32,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased;
}
.boot { padding: 40px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--accent); }
.neg { color: var(--red); }
.spacer { flex: 1; }
h2 { font-size: 18px; margin: 26px 2px 12px; }
h2:first-child { margin-top: 0; }
h3 { font-size: 15px; margin: 0 0 10px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1100px 600px at 20% 0%, #2b3d35 0%, var(--nav) 65%); }
.login-card { width: min(380px, 92vw); background: var(--panel); border-radius: 18px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.35); text-align: center; }
.login-ico { font-size: 40px; }
.login-card h1 { margin: 6px 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card .btn { width: 100%; margin-top: 12px; justify-content: center; }
.login-err { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 10px; }

/* ---------- Header ---------- */
.top { background: var(--nav); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 20px 0; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 10px; padding-bottom: 10px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: #2b3d35; display: grid; place-items: center; }
.brand small { color: #a8b5ae; font-weight: 500; }
.top .btn-ghost { color: #d3dcd7; border-color: #34463e; margin-bottom: 10px; }
.top .btn-ghost:hover { background: #22312b; }
.tabs { display: flex; gap: 2px; width: 100%; overflow-x: auto; scrollbar-width: none; }
.tab { appearance: none; border: 0; background: none; color: #a8b5ae; padding: 10px 14px 12px; font: inherit; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: #fff; }
.tab.on { color: #fff; border-bottom-color: #7fc4a2; }
.tab .badge { background: var(--red); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 6px; margin-left: 4px; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 80px; }

/* ---------- Buttons & inputs ---------- */
.btn { appearance: none; border: 1px solid transparent; background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #ece8df; filter: none; }
.btn-danger { background: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-link { background: none; border: 0; color: var(--muted); padding: 4px 6px; cursor: pointer; font: inherit; font-size: 13px; text-decoration: none; }
.btn-link:hover { color: var(--ink); text-decoration: underline; }
.btn-link.danger:hover { color: var(--red); }
.inp, select.inp, textarea.inp { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; color: var(--ink); }
textarea.inp { min-height: 70px; resize: vertical; }
.inp:focus { outline: 2px solid rgba(31,92,69,.25); border-color: var(--accent); }
.inp.sm { padding: 5px 8px; font-size: 13px; border-radius: 7px; }
.lbl { color: var(--muted); font-size: 12px; font-weight: 600; display: block; margin-bottom: 4px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px 18px; }
.empty { padding: 22px; color: var(--muted); font-size: 14px; text-align: center; }
.row-flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }
.quick-dates { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.quick-dates button { font-size: 12px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); background: #faf8f4; cursor: pointer; color: var(--muted); font-family: inherit; }
.quick-dates button:hover { color: var(--ink); background: #fff; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #efede7; color: var(--muted); }
.pill.ok { background: var(--accent-bg); color: var(--accent); }
.pill.bad { background: var(--red-bg); color: var(--red); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.pill.info { background: #e4edf6; color: var(--blue); }

/* ---------- Tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 5px solid var(--muted); }
.tile.in { border-top-color: var(--accent); }
.tile.out { border-top-color: var(--red); }
.tile.mar { border-top-color: var(--nav); background: linear-gradient(180deg, #f2f7f4, #fff 60%); }
.tile.adv { border-top-color: var(--amber); }
.t-lbl { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.t-val { font-size: 28px; font-weight: 750; margin: 2px 0 4px; white-space: nowrap; }
.t-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.t-sub b { color: var(--ink); font-weight: 650; }

.period-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.period-bar select { width: auto; min-width: 240px; }

.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; align-items: start; }
.stack > * + * { margin-top: 14px; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; padding: 10px 10px; border-bottom: 1px solid var(--line); background: #faf8f4; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #f0ede6; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); background: #faf8f4; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl tr.dim td { color: var(--muted); }
.tbl tr.overdue td { background: #fdf5f4; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #faf8f4; }
.tbl-wrap { overflow-x: auto; }
.cat-ico { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: #f2efe8; margin-right: 6px; font-size: 14px; }

/* ---------- Bars (náklady podle kategorií) ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 110px; gap: 10px; align-items: center; font-size: 14px; }
.bar { height: 10px; background: #efece4; border-radius: 9px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 9px; }
.bar span.svc { background: var(--amber); }

/* ---------- Chart ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.li:last-child { border-bottom: 0; }
.li .when { color: var(--muted); font-size: 13px; min-width: 86px; }
.li.done { color: var(--muted); text-decoration: line-through; }

.notice { padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.notice.warn { background: var(--amber-bg); color: #6d4708; }
.notice.bad { background: var(--red-bg); color: #7d1f1d; }
.notice.ok { background: var(--accent-bg); color: #164532; }
.notice.info { background: #eef3f8; color: #244a6c; }

.files { display: flex; gap: 6px; flex-wrap: wrap; }
.file { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: #f2efe8; color: var(--ink); text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.file:hover { background: #e8e4da; }
.file .x { color: var(--muted); cursor: pointer; border: 0; background: none; padding: 0 0 0 4px; font-size: 13px; }
.file .x:hover { color: var(--red); }

/* ---------- Result box ---------- */
.result { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-radius: 12px; margin-top: 14px; font-size: 17px; }
.result b { font-size: 24px; }
.result.pay { background: var(--red-bg); color: #7d1f1d; }
.result.refund { background: var(--accent-bg); color: #164532; }

/* ---------- Modal ---------- */
#modal:empty { display: none; }
.m-back { position: fixed; inset: 0; background: rgba(15,22,19,.45); z-index: 40; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.m-card { width: min(620px, 100%); background: #fff; border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.3); padding: 22px; max-height: calc(100vh - 32px); overflow-y: auto; }
.m-card h3 { font-size: 18px; margin-bottom: 14px; }
.m-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; align-items: center; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--nav); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; font-size: 14px; z-index: 60; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); }

/* ---------- Tiskový dokument (vyúčtování) ---------- */
#print { display: none; }
.doc { font: 13px/1.5 "Helvetica Neue", Arial, sans-serif; color: #111; max-width: 760px; margin: 0 auto; }
.doc h1 { font-size: 20px; margin: 0 0 4px; }
.doc .sub { color: #555; margin-bottom: 18px; }
.doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 16px; }
.doc .parties div { border: 1px solid #ddd; border-radius: 8px; padding: 10px 12px; }
.doc .parties b { display: block; font-size: 11px; text-transform: uppercase; color: #666; letter-spacing: .4px; margin-bottom: 3px; }
.doc table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; }
.doc th, .doc td { border-bottom: 1px solid #ddd; padding: 6px 8px; text-align: left; }
.doc th { background: #f3f3f3; font-size: 11px; text-transform: uppercase; }
.doc td.r, .doc th.r { text-align: right; }
.doc tfoot td { font-weight: 700; border-top: 2px solid #999; }
.doc .res { border: 2px solid #111; border-radius: 8px; padding: 12px 14px; font-size: 15px; margin: 14px 0; }
.doc .res b { font-size: 18px; }
.doc .note { color: #444; font-size: 12px; }
.doc .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 50px; }
.doc .sign div { border-top: 1px solid #999; padding-top: 6px; font-size: 12px; color: #555; }
.doc h4 { margin: 18px 0 4px; font-size: 13px; }

@media print {
  body.printing #app, body.printing #modal, body.printing #toast { display: none !important; }
  body.printing #print { display: block; }
  body.printing { background: #fff; }
  @page { margin: 16mm; }
}

/* ---------- Mobil ---------- */
@media (max-width: 900px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .two { grid-template-columns: 1fr; }
  .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 120px 1fr 90px; }
  .t-val { font-size: 22px; }
  .brand small { display: none; }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  main { padding: 14px 10px 80px; }
  .tbl { font-size: 13px; }
  .tbl td, .tbl th { padding: 7px 6px; }
  .hide-m { display: none; }
}
