/* Nakladiak — smer „Domy“ s chladným podkladom. Tokeny a pravidlá: docs/design/DESIGN.md */
@font-face { font-family: "Bricolage Grotesque"; src: url("/static/fonts/BricolageGrotesque.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }

:root {
  --bg: #e9e8e3; --panel: #f7f6f2; --panel-2: #efeee9; --line: #d4d2ca; --text: #1f1e1b; --muted: #6a675f;
  --ink: #1f1e1b; --on-ink: #f1efe8; --accent: #b5572a; --on-accent: #fff;
  --ok: #2f7d4f; --warn: #9a6a12; --err: #b3362a; --accent-ink: #b5572a;
  --byt: #3461a8; --dom: #2f7d4f; --chalupa: #b5572a;
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 20px; --r-sm: 12px; --r-in: 16px;
  --tab-h: 74px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1a1a18; --panel: #262521; --panel-2: #2e2d28; --line: #3a3833; --text: #f1efe8; --muted: #a39e92; --ink: #f1efe8; --on-ink: #1a1a18;
    --ok: #6fc08d; --warn: #e0b04a; --err: #e5695a; --accent-ink: #e58a5e; }
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 17px; line-height: 1.3;
  font-feature-settings: "tnum" 1; overflow-x: hidden; min-height: 100dvh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.num { font-variation-settings: "opsz" 96; letter-spacing: -0.03em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- shell ---------- */
.app { max-width: 1120px; margin: 0 auto; padding: 0 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 4px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.brand img { border-radius: 8px; }
.nav--top { display: none; gap: 20px; font-weight: 600; color: var(--muted); }
.nav--top a { text-decoration: none; padding: 6px 0; }
.nav--top a.is-active { color: var(--text); box-shadow: inset 0 -2px 0 var(--text); }
.nav--top .badge { margin-left: 6px; }
.nav--top a.upload { background: var(--accent); color: #fff; border-radius: 999px; padding: 7px 14px; display: inline-flex; align-items: center; gap: 6px; box-shadow: none; }
.nav--top a.upload .ico { width: 16px; height: 16px; }
.top__right { display: flex; align-items: center; gap: 8px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: var(--on-ink); border: 0; display: grid; place-items: center; font-weight: 700; cursor: pointer; }
.main { min-height: 50vh; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 6px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 35%); z-index: 20; }
.tabbar a { position: relative; flex: 1 1 0; min-width: 0; text-decoration: none; color: var(--text); background: var(--panel); border: 1.5px solid var(--line); border-radius: 999px; padding: 10px 8px;
  font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; white-space: nowrap; }
.tabbar a .lbl { overflow: hidden; text-overflow: ellipsis; }
.tabbar a.is-active { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.tabbar a.fab { background: var(--accent); color: var(--on-accent); border-color: var(--accent); flex: 0 0 48px; width: 48px; padding: 0; }
.tabbar a.fab .lbl { display: none; }
.tabbar .ico { width: 22px; height: 22px; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; }
.tabbar .badge { position: absolute; top: -6px; right: -2px; }
.tabbar a.is-active .badge { background: var(--on-ink); color: var(--ink); }
@media (min-width: 430px) { .tabbar a.fab { flex: 1 1 0; width: auto; padding: 10px 12px; } .tabbar a.fab .lbl { display: inline; } }

/* ---------- icons ---------- */
.ico { display: inline-block; width: 20px; height: 20px; vertical-align: -4px; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }

/* ---------- page headers ---------- */
.page-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0 10px; flex-wrap: wrap; }
.page-h h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.page-h .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sub { color: var(--muted); font-size: 15px; }

/* ---------- hero (Prehľad) ---------- */
.monthnav { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; padding: 12px 0 0; }
.monthnav button { background: none; border: 1.5px solid var(--line); border-radius: 999px; width: 36px; height: 36px; color: var(--text); font-size: 18px; cursor: pointer; }
.monthnav .lbl { min-width: 11ch; text-align: center; color: var(--text); }
.hero { padding: 8px 0 6px; }
.hero h1 { font-size: 58px; line-height: 0.95; font-weight: 800; letter-spacing: -0.035em; font-variation-settings: "opsz" 96; }
.hero h1 small { font-size: 26px; font-weight: 600; letter-spacing: 0; margin-left: 6px; color: var(--muted); }
.hero p { margin-top: 10px; color: var(--muted); font-size: 16px; max-width: 46ch; }
.hero p b { color: var(--text); }
.todo { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; border-radius: 999px; padding: 9px 14px; font-weight: 700; font-size: 14px; min-height: 40px;
  background: var(--ink); color: var(--on-ink); border: 1.5px solid var(--ink); }
.chip--soft { background: transparent; color: var(--text); border-color: var(--line); }
.chip--warn { background: var(--accent); border-color: var(--accent); color: #fff; }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 44px; margin: 12px 0 2px; }
.hist button { flex: 1; border: 0; padding: 0; background: var(--line); border-radius: 3px 3px 0 0; min-height: 3px; cursor: pointer; }
.hist button.is-on { background: var(--ink); }
.hist button.is-now { background: repeating-linear-gradient(135deg, var(--muted) 0 3px, transparent 3px 6px); border: 1.5px solid var(--muted); border-bottom: 0; }
.hist button.is-now.is-on { background: repeating-linear-gradient(135deg, var(--ink) 0 3px, transparent 3px 6px); border-color: var(--ink); }
.hist button:hover { background: var(--muted); }
.hist-l { display: flex; gap: 4px; color: var(--muted); font-size: 11px; }
.hist-l span { flex: 1; text-align: center; }
.hist-cap { font-size: 13px; color: var(--muted); margin-top: 4px; }
.histwrap { margin-top: 8px; }

/* ---------- houses ---------- */
.houses { display: grid; gap: 14px; margin-top: 14px; }
.house { border-radius: var(--r); background: var(--c, var(--ink)); color: #fff; padding: 16px 16px 14px; }
.house__h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; text-decoration: none; color: inherit; }
.house h2 { font-size: 20px; font-weight: 800; }
.house .big { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin: 6px 0 2px; font-variation-settings: "opsz" 96; }
.house .big small { font-size: 18px; font-weight: 600; letter-spacing: 0; opacity: .85; margin-left: 2px; }
.house .note { opacity: .9; font-size: 14px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 26px; margin: 10px 0 2px; }
.spark i { flex: 1; background: rgba(255,255,255,.55); border-radius: 2px 2px 0 0; min-height: 2px; }
.spark i.none { background: rgba(255,255,255,.18); }
.list { background: var(--panel); border-radius: var(--r-in); margin: 10px -4px -2px; padding: 2px 14px; color: var(--text); }
.list .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; min-height: 44px; }
.list .row:first-child { border-top: 0; }
.list .k { min-width: 0; }
.list .k small { color: var(--muted); margin-left: 6px; font-size: 14px; }
.list .v { font-weight: 700; white-space: nowrap; }
.list .v.est { color: var(--muted); }
.list .v.est::before { content: "≈ "; }
.list .v.none { color: var(--muted); font-weight: 500; }
.list .sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------- sections / cards ---------- */
.section { margin-top: 20px; }
.section > h2, .section > h3 { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.card { background: var(--panel); border-radius: var(--r-in); padding: 12px 14px; }
.card + .card { margin-top: 10px; }
.rows { margin: 0; padding: 0; list-style: none; }
.rows > li, .rows > a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; min-height: 44px; }
.rows > li:first-child, .rows > a:first-child { border-top: 0; }
.rows .k { min-width: 0; }
.rows .k .s { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.rows .v { font-weight: 700; white-space: nowrap; text-align: right; }
.rows .v .s { display: block; font-size: 13px; color: var(--muted); font-weight: 500; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); background: var(--panel); border-radius: var(--r-in); }
.empty p { margin-bottom: 10px; }

/* ---------- pills / status ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill--ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill--warn { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent-ink); }
.pill--err { background: color-mix(in srgb, var(--err) 15%, transparent); color: var(--err); }
.pill--run::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 11px 18px; font-weight: 700; font-size: 15px;
  border: 1.5px solid var(--line); background: var(--panel); color: var(--text); text-decoration: none; cursor: pointer; min-height: 44px; }
.btn--primary { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn--accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn--ghost { background: transparent; }
.btn--danger { background: transparent; color: var(--err); border-color: var(--err); }
.btn--block { width: 100%; }
.btn--sm { padding: 7px 12px; font-size: 14px; min-height: 36px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { background: none; border: 0; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.iconbtn:hover { background: var(--panel-2); color: var(--text); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; border: 1.5px solid var(--line); background: var(--panel); border-radius: var(--r-sm); padding: 11px 12px; font-size: 16px; min-height: 44px; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); }
.field .help { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; min-height: 44px; }
.check input { appearance: auto; width: 20px; height: 20px; accent-color: var(--ink); margin: 0; }
.check .help { display: block; font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (max-width: 480px) { .grid2--stack { grid-template-columns: 1fr; } }
.alert { border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 12px; font-size: 15px; background: var(--panel-2); }
.alert--err { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }
.alert--ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.alert--warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--text); margin-top: 12px; }
.alert--warn a { font-weight: 700; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: auto; max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 8px 14px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 40px; }
.seg button.is-on { background: var(--ink); color: var(--on-ink); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 14px; }
.tabs a { text-decoration: none; border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; color: var(--muted); min-height: 40px; display: inline-flex; align-items: center; }
.tabs a.is-on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* ---------- upload ---------- */
.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 26px 16px; text-align: center; background: var(--panel); }
.drop.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.drop p { color: var(--muted); margin-bottom: 12px; }
.drop .btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-prev { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: var(--r-in); padding: 10px 12px; margin-top: 10px; }
.file-prev img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 40%; background: var(--accent); animation: slide 1.1s infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------- documents ---------- */
.doc { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border-radius: var(--r-in); padding: 12px 14px; text-decoration: none; color: inherit; }
.doc + .doc { margin-top: 8px; }
.doc .t { font-weight: 700; min-width: 0; }
.doc .m { font-size: 13px; color: var(--muted); margin-top: 2px; }
.doc .st { margin-left: auto; flex: none; }
@media (max-width: 480px) { .doc { flex-wrap: wrap; } .doc .st { margin-left: 32px; } }
.preview { background: var(--panel); border-radius: var(--r-in); padding: 10px; margin-top: 10px; }
.preview img { max-width: 100%; max-height: 60vh; display: block; margin: 0 auto; border-radius: 8px; }

/* ---------- transactions ---------- */
.tx { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 11px 0; border-top: 1px solid var(--line); align-items: center; }
.tx:first-child { border-top: 0; }
.tx .who { font-weight: 700; }
.tx .m { font-size: 13px; color: var(--muted); }
.tx .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.tx .act { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 4px; }

/* ---------- charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars .b { flex: 1; display: flex; align-items: flex-end; gap: 1px; min-width: 0; height: 100%; cursor: pointer; }
.bars .b i { display: block; flex: 3 1 0; border-radius: 2px 2px 0 0; background: var(--c, var(--ink)); min-height: 2px; }
.bars .b i.gen { flex: 1.2 1 0; }
.bars .b i.gen { background: color-mix(in srgb, var(--c, var(--ink)) 45%, var(--panel)); }
.bars .b.none i { background: var(--line); }
.bars-l { display: flex; gap: 3px; color: var(--muted); font-size: 11px; margin-top: 4px; }
.bars-l span { flex: 1; min-width: 0; text-align: left; overflow: visible; white-space: nowrap; font-size: 10px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; background: var(--c, var(--ink)); }
.legend i.gen { background: color-mix(in srgb, var(--c, var(--ink)) 45%, var(--panel)); }
.months { display: flex; align-items: flex-end; gap: 4px; height: 70px; }
.months a, .months span { flex: 1; background: var(--line); border-radius: 3px 3px 0 0; min-height: 3px; text-decoration: none; }
.months a.is-on { background: var(--ink); }

/* ---------- sheets / toast ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20,19,16,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { background: var(--bg); color: var(--text); width: 100%; max-height: 92dvh; overflow: auto; border-radius: var(--r) var(--r) 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet__grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 10px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet__head h2 { font-size: 20px; font-weight: 800; }
.toast { position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 10px); background: var(--ink); color: var(--on-ink);
  padding: 11px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 60; max-width: calc(100% - 32px); }
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-err { background: var(--err); color: #fff; }
.toast.is-top { bottom: auto; top: 14px; }

/* ---------- skeleton ---------- */
.skel { background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r-in); height: 90px; margin-top: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; }
.login__brand { text-align: center; margin-bottom: 18px; }
.login__brand img { border-radius: 14px; }
.login__brand h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; }
.login__form { background: var(--panel); border-radius: var(--r); padding: 20px 18px; }
.login__form h2 { font-size: 20px; margin-bottom: 8px; }
.login__forgot { text-align: center; margin-top: 12px; font-size: 14px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--panel-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  body { font-size: 16px; }
  .app { padding-bottom: 48px; }
  .nav--top { display: flex; }
  .tabbar { display: none; }
    .hero h1 { font-size: 84px; }
  .houses { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  .cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { width: min(560px, 100%); max-height: 86vh; border-radius: var(--r); padding: 12px 22px 22px; }
  .sheet__grip { display: none; }
  .toast { bottom: 24px; }
  .toast.is-top { bottom: auto; }
}
