/* Finance – mobile-first. Telefon je výchozí, od 900 px rozložení pro PC. */
:root {
	--fg: #1f2320; --muted: #6b6f69; --line: #e2e1db; --bg: #f5f4ef; --surface: #fff;
	--accent: #2f6f5e; --accent-fg: #fff; --out: #9a3b2e; --in: #2f6f5e;
	--todo: #8a5a00; --todo-bg: #fdf3dc; --radius: 10px; --tap: 44px;
	--nav-h: 60px;
}
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg); background: var(--bg);
	padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}
main { padding: 12px 16px; max-width: 1200px; margin: 0 auto; }
a { color: var(--accent); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; display: flex; justify-content: space-between; gap: 8px; }
h3.day { font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 4px 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.out { color: var(--out); } .in { color: var(--in); }

/* Navigace: na telefonu spodní lišta (palec), na PC nahoře */
header.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
.brand { font-weight: 700; font-size: 18px; color: var(--fg); text-decoration: none; }
.tabs {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--surface);
	border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
	flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
	min-height: var(--nav-h); font-size: 12px; color: var(--muted); text-decoration: none;
}
.tabs a .ico { font-size: 20px; line-height: 1; }
.tabs a.current { color: var(--accent); font-weight: 600; }
.tabs a { position: relative; }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
	background: var(--out); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }

/* Ovládací prvky – dotykové cíle ≥ 44 px, písmo 16 px (iOS nezoomuje) */
input, select, button, .btn { font: inherit; font-size: 16px; }
input, select { min-height: var(--tap); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); width: 100%; }
.btn, button.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 8px 14px;
	border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--accent-fg); text-decoration: none; cursor: pointer;
}
.btn.secondary { background: var(--surface); color: var(--accent); border-color: var(--line); }
.btn.small { min-height: 36px; padding: 4px 10px; font-size: 14px; }
.btn.icon { min-width: var(--tap); padding: 0; font-size: 22px; }
.btn.wide { width: 100%; }
.htmx-request .btn, .btn.htmx-request { opacity: .6; }

.flash { background: #e6f1ec; border: 1px solid #b8d8c9; color: var(--fg); padding: 8px 12px; border-radius: 8px; margin: 0 0 10px; }
.flash.error { background: #f9e7e3; border-color: #e6bcb2; }
.flash ul, ul.flash { list-style: none; }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); }
.tag.cat { color: var(--fg); }
.tag.manual { border-color: var(--accent); }
.tag.todo { background: var(--todo-bg); border-color: #efd9a6; color: var(--todo); }
.tag.pending { border-style: dashed; }

/* Období */
.period { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.period .label { flex: 1; text-align: center; font-weight: 600; }

/* Panely, karty */
.grid { display: grid; gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.grid .panel { margin-bottom: 0; }
section > h2:first-child { margin-top: 4px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel .card { border-color: var(--line); }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 56px; color: inherit; text-decoration: none; }
.row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.amount { font-weight: 600; }

/* Grafy na šířku displeje */
.chart { position: relative; width: 100%; }
.chart.donut { height: 240px; margin-bottom: 8px; }
.chart.line { height: 260px; }
.legend { list-style: none; margin: 0; padding: 0; }
.legend a { display: grid; grid-template-columns: 14px 1fr auto 44px; gap: 10px; align-items: center; min-height: var(--tap); padding: 4px 2px; color: inherit; text-decoration: none; border-top: 1px solid var(--line); }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; }
.legend .share { text-align: right; font-size: 13px; }

/* Transakce */
.filter { margin-bottom: 8px; }
.filter-bar { display: flex; gap: 8px; }
.filter-bar .btn { flex: none; }
.filter-more { display: grid; gap: 10px; margin-top: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filter-more label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.filter-more label.check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--fg); min-height: var(--tap); }
.filter-more label.check input { width: 22px; min-height: 22px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.summary { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 14px; margin: 8px 4px; }
.tx { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 6px; }
.tx.transfer { opacity: .7; }
.tx-head { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 60px; padding: 10px 12px; cursor: pointer; }
.tx-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.tx-head .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tx-head .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-head .meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12px; }
.tx-detail { padding: 0 12px 12px; border-top: 1px solid var(--line); }
.tx-detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0; font-size: 14px; }
.tx-detail dt { color: var(--muted); }
.tx-detail dd { margin: 0; overflow-wrap: anywhere; }
.categorize, .stack-form { display: grid; gap: 10px; margin-top: 10px; }
.categorize label, .stack-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.more { margin: 12px 0; }
.empty { text-align: center; padding: 24px; }

/* Kategorie */
details.group { border-top: 1px solid var(--line); }
details.group summary { display: flex; justify-content: space-between; gap: 10px; align-items: center; min-height: var(--tap); cursor: pointer; font-weight: 500; list-style: none; }
details.group summary::-webkit-details-marker { display: none; }
details.group summary::before { content: "›"; color: var(--muted); margin-right: 4px; transition: transform .15s; }
details.group[open] summary::before { transform: rotate(90deg); }
details.group summary .name { flex: 1; }
details.group ul { list-style: none; margin: 0 0 8px; padding: 0 0 0 16px; }
details.group li a { display: flex; justify-content: space-between; gap: 10px; min-height: 40px; align-items: center; color: inherit; text-decoration: none; }
.panel.todo { background: var(--todo-bg); border-color: #efd9a6; }

/* Plán */
.plan-links { margin-bottom: 8px; }
.plan-totals .panel { margin-bottom: 0; }
dl.totals { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0 0 10px; font-size: 14px; align-items: center; }
dl.totals dt { color: var(--muted); }
dl.totals dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.bar { flex-basis: 100%; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.plan-block { margin: 16px 0; }
.plan-num { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.tag.plan { border-style: solid; color: var(--fg); }
.tag.st-paid, .tag.st-ok { background: #e6f1ec; border-color: #b8d8c9; color: var(--in); }
.tag.st-overdue, .tag.st-missing, .tag.st-over { background: #f9e7e3; border-color: #e6bcb2; color: var(--out); }
.tag.st-partial, .tag.st-pending { background: var(--todo-bg); border-color: #efd9a6; color: var(--todo); }
.tag.st-extra { border-color: var(--accent); }
.card.st-idle { opacity: .55; }
.tile { margin-bottom: 12px; color: inherit; text-decoration: none; }
.upcoming-nav { margin-bottom: 12px; align-items: center; }
.upcoming-nav select { width: auto; flex: 1; min-width: 160px; }

/* Záložky plánu (segmentový přepínač) a sbalitelné skupiny */
.seg { display: flex; gap: 4px; padding: 4px; margin: 4px 0 12px; background: var(--line); border-radius: var(--radius); position: sticky; top: 56px; z-index: 5; }
.seg-btn { flex: 1; min-height: 40px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 15px; cursor: pointer; }
.seg-btn.current { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.plan-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.plan-group > summary { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 12px; cursor: pointer; list-style: none; }
.plan-group > summary::-webkit-details-marker { display: none; }
.plan-group > summary::before { content: "›"; color: var(--muted); transition: transform .15s; }
.plan-group[open] > summary::before { transform: rotate(90deg); }
.plan-group > summary .name { flex: 1; font-weight: 600; }
.plan-group > .cards { padding: 0 8px 8px; }
.plan-group.idle { opacity: .75; }

/* PC */
@media (min-width: 900px) {
	body { padding-bottom: 24px; }
	header.top { display: flex; align-items: center; gap: 24px; padding: 0 24px; }
	.tabs { position: static; border: 0; padding: 0; background: none; gap: 4px; }
	.tabs a { flex: none; flex-direction: row; min-height: 52px; padding: 0 14px; font-size: 15px; gap: 8px; }
	.tabs a .ico { font-size: 16px; }
	.tabs a.current { box-shadow: inset 0 -3px 0 var(--accent); }
	main { padding: 20px 24px; }
	.grid { grid-template-columns: 1fr 1fr; align-items: start; }
	.chart.donut { height: 280px; }
	.chart.line { height: 320px; }
	.cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
	.filter-more { grid-template-columns: repeat(4, 1fr); align-items: end; }
	.filter-more .actions { grid-column: 1 / -1; }
	.tx-list { max-width: 820px; }
	.tx-detail dl { grid-template-columns: 160px 1fr; }
	.stack-form { grid-template-columns: repeat(4, 1fr); align-items: end; }
	.seg { max-width: 520px; top: 60px; }
	.plan-block, .plan-group + .panel { max-width: 1000px; }
	.stack-form > .btn, .stack-form > input[type=submit] { grid-column: auto; }
	.card .stack-form { grid-template-columns: 1fr auto; padding: 0 12px 12px; }
}

/* PWA: lišta offline / uložená verze / nová verze (app.js) a zámek zápisu offline */
.netbar {
	display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
	background: var(--todo-bg); color: var(--todo); border-bottom: 1px solid #ecd9a8; padding: 6px 16px; font-size: 14px;
	padding-top: calc(6px + env(safe-area-inset-top));
}
.netbar[hidden] { display: none; }
body[data-offline] form, body[data-offline] [hx-post] { opacity: .5; pointer-events: none; }
.offline-pages { padding-left: 18px; }
.offline-pages li { margin: 6px 0; }

[hidden] { display: none !important; }

/* Upozornění na platby (Alerts/_list.latte) */
.alerts-list .row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.alerts-list .main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.alerts-list form { margin: 0; }
.card.alert-overdue { border-left: 4px solid var(--out); }
.card.alert-soon { border-left: 4px solid #efd9a6; }
.card.alert-uncertain { opacity: .8; }
.panel.alerts h2 { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.05rem; }
@media (min-width: 900px) { .badge { position: static; margin-left: 2px; } }

/* Import (Import/default.latte) */
.import-result { width: 100%; border-collapse: collapse; font-size: 14px; }
.import-result th, .import-result td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; word-break: break-all; }
.import-result .num { text-align: right; }

/* Úlohy na serveru (Settings) */
.cron-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cron-list pre { margin: 4px 0 0; padding: 6px 8px; background: var(--bg); border-radius: 6px; white-space: pre-wrap; max-height: 8em; overflow: auto; }
