:root {
  color-scheme: dark;
  --bg: #090d16; --s1: #0f172a; --s2: #131c31; --s3: #1e293b; --s4: #334155;
  --line: #1e293b; --line2: #334155;
  --text: #f1f5f9; --text2: #cbd5e1; --muted: #94a3b8; --faint: #64748b;
  --indigo: #818cf8; --sky: #7dd3fc; --green: #34d399; --amber: #fbbf24; --rose: #fb7185;
  /* barvy řad v grafech */
  --ch-real: #6366f1; --ch-plan: #0891b2; --ch-fore: #d97706;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --stripe-we: repeating-linear-gradient(-45deg, rgba(245,158,11,.16) 0 6px, rgba(245,158,11,.09) 6px 12px);
  --stripe-hol: repeating-linear-gradient(45deg, rgba(244,63,94,.22) 0 6px, rgba(244,63,94,.12) 6px 12px);
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #334155 #0b1120; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
h1, h2, p, dl, dd { margin: 0; }
h1, h2 { font-size: 14px; }
h2 { display: flex; align-items: center; gap: 8px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.icon { width: 16px; height: 16px; flex: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: 12px; }
.error { color: var(--rose); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.side-card .c-real { color: var(--indigo); }
.side-card .c-plan { color: var(--sky); }
.side-card .c-off { color: var(--green); }

/* ---------- prvky ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--s3); color: var(--text2); font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--s4); }
.btn-sm { padding: 5px 9px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.btn-primary:hover { background: #6366f1; }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); width: 100%; }
.btn-ghost:hover { color: var(--rose); background: rgba(244,63,94,.1); }
.icon-btn { display: inline-flex; padding: 5px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: #fff; background: var(--s3); }
.badge { font: 11px var(--mono); padding: 2px 6px; border-radius: 5px; background: var(--s3); color: var(--text2); white-space: nowrap; }
.badge-off { background: rgba(16,185,129,.15); color: #6ee7b7; }
.badge-hol { background: rgba(244,63,94,.15); color: #fda4af; }
.badge-we { background: rgba(245,158,11,.15); color: #fcd34d; }
.card { padding: 18px; border-radius: 12px; background: var(--s1); border: 1px solid var(--line); min-width: 0; }
.card > * + * { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field { display: block; min-width: 0; }
.field > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.field input, .field select, .add-bar input { width: 100%; padding: 7px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line2); font-size: 13px; }
progress { display: block; width: 100%; height: 6px; appearance: none; border: 0; border-radius: 3px; overflow: hidden; background: var(--s3); }
progress::-webkit-progress-bar { background: var(--s3); }
progress::-webkit-progress-value { background: var(--ch-real); border-radius: 3px; }
progress::-moz-progress-bar { background: var(--ch-real); }

/* ---------- rozvržení ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-scroll .content { flex: 1; overflow-y: auto; padding: 20px; }
.content > * { max-width: 1320px; margin: 0 auto 18px; }
.topbar { min-height: 56px; flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 16px; background: var(--s1); border-bottom: 1px solid var(--line); }
.topbar > .btn-primary { margin-left: auto; }
.month-nav { display: flex; align-items: center; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.month-label { position: relative; min-width: 130px; text-align: center; font-weight: 600; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.month-label:hover { background: var(--s3); }
.month-label:focus-within { outline: 2px solid var(--indigo); }
.month-label input { position: absolute; inset: 0; opacity: 0; width: 100%; pointer-events: none; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid; }
.sw-weekend { background: var(--stripe-we); border-color: rgba(245,158,11,.5); }
.sw-holiday { background: var(--stripe-hol); border-color: rgba(244,63,94,.5); }
.sw-today { border-color: var(--indigo); box-shadow: inset 0 3px 0 var(--indigo); }
.add-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; background: var(--s1); border-bottom: 1px solid #4f46e5; }
.add-bar input { width: 220px; }
.add-bar #newTaskName { flex: 1; min-width: 200px; }

/* ---------- menu ---------- */
.sidebar { width: 236px; flex: none; display: flex; flex-direction: column; background: var(--s1); border-right: 1px solid var(--line); overflow: hidden auto; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.brand-logo { display: flex; padding: 7px; border-radius: 8px; color: var(--indigo); background: rgba(99,102,241,.15); border: 1px solid rgba(129,140,248,.3); }
.brand-text { flex: 1; min-width: 0; line-height: 1.25; }
.brand-text strong { display: block; }
.brand-text small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { padding: 10px; display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; border: 1px solid transparent; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--s2); color: #fff; }
.nav a[aria-current] { background: rgba(99,102,241,.15); border-color: rgba(99,102,241,.35); color: #a5b4fc; }
.nav .badge { margin-left: auto; font-style: normal; }
.side-block { padding: 10px 12px; border-top: 1px solid var(--line); }
.side-title { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.side-card { padding: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); display: grid; gap: 7px; font-size: 12px; }
dl.side-card > div { display: flex; justify-content: space-between; gap: 6px; }
.side-card dt { color: var(--muted); }
.side-card dd { font: 600 12px var(--mono); white-space: nowrap; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.file-name { font: 11px var(--mono); color: var(--muted); }
.save-state { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 400; font-size: 11px; }
.save-state i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.save-state.busy { color: var(--amber); }
.save-state.err { color: var(--rose); }
.side-foot { margin-top: auto; padding: 10px 12px; border-top: 1px solid var(--line); }
.side-person { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.collapsed .sidebar { width: 58px; }
.collapsed .side-full { display: none; }
.collapsed .brand { flex-direction: column; }
.collapsed .nav a { justify-content: center; padding: 10px 0; }
.collapsed .side-block { border: 0; }
.collapsed .side-title { justify-content: center; }

/* ---------- matice ---------- */
.sheet-wrap { flex: 1; overflow: auto; }
.sheet { --w-name: 210px; width: 100%; min-width: 1290px; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.w-c-name { width: var(--w-name); }
.w-c-cat { width: 62px; }
.w-c-md { width: 44px; }
.w-c-price { width: 84px; }
.w-c-amt { width: 50px; }
.sheet th, .sheet td { padding: 0 6px; height: 32px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background-color: var(--row, var(--bg)); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.sheet .c-md, .sheet .c-price, .sheet .c-amt { text-align: right; font: 11px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink, var(--text2)); }
.sheet td.c-amt { font-weight: 700; }
.sheet .c-cat { text-align: center; font: 11px var(--mono); color: var(--muted); }
.sheet .c-name { position: sticky; left: 0; z-index: 2; color: var(--ink, var(--text)); font-weight: 500; }
.sheet .cell { padding: 0; text-align: center; font: 11px var(--mono); letter-spacing: -.03em; color: var(--ink, var(--text2)); text-overflow: clip; }
.sheet .is-we { background-image: var(--stripe-we); }
.sheet .is-hol { background-image: var(--stripe-hol); }
.sheet .is-today { border-left: 1px solid var(--indigo); border-right-color: var(--indigo); }
.sheet thead { --row: var(--s1); }
.sheet thead th { position: sticky; z-index: 3; font-weight: 600; }
.sheet thead .c-name { z-index: 5; }
.sheet .r-week th { top: 0; height: 26px; }
.sheet .r-day th { top: 26px; height: 40px; border-bottom: 2px solid var(--line2); }
.sheet .week { text-align: center; font: 11px var(--mono); color: var(--muted); padding: 0; border-right-color: var(--line2); text-overflow: clip; }
.sheet .c-client { color: var(--indigo); font-size: 11px; text-align: right; }
.sheet .r-day .c-cat, .sheet .r-day .c-md, .sheet .r-day .c-price, .sheet .r-day .c-amt { padding: 0 4px; font: 600 10px var(--mono); color: var(--text2); white-space: normal; letter-spacing: -.03em; }
.sheet .day { padding: 0; text-align: center; line-height: 1.15; }
.day small { display: block; font-size: 10px; color: var(--muted); }
.day b { font: 600 12px var(--mono); }
.day.is-we, .day.is-we small { color: #fcd34d; }
.day.is-hol, .day.is-hol small { color: #fda4af; }
.day.is-today { box-shadow: inset 0 3px 0 var(--indigo); }
.r-vac { --row: #0b1c1b; --ink: #6ee7b7; }
.r-plan { --row: #0c1626; --ink: #a5c9e8; }
.r-pred { --row: #0d1a2c; --ink: #67e8f9; }
.sheet .r-pred > * { border-bottom: 2px solid var(--line2); }
.r-task { --row: #0b1120; }
.r-task:hover { --row: #111a2e; }
.r-real { --row: #14183a; --ink: #a5b4fc; }
.sheet tfoot > tr > * { position: sticky; bottom: 0; z-index: 3; border-top: 2px solid #3f3f9e; height: 38px; font-weight: 700; }
.sheet tfoot > tr > .c-name { z-index: 5; font-weight: 700; }
.sheet tfoot .v-none { color: var(--faint); }
.sheet tfoot .v-over { color: var(--green); }
.sheet tfoot .v-under { color: var(--amber); }
.sheet tfoot .v-bad { color: #fff; background: #be123c; }
.sheet input { display: block; width: 100%; height: 31px; padding: 0; border: 0; background: none; text-overflow: ellipsis; border-radius: 0; }
.sheet .cell input { text-align: center; font: 500 11px var(--mono); letter-spacing: -.03em; text-overflow: clip; }
.r-task .cell input { color: #fff; }
.sheet .cell input:hover { background: rgba(99,102,241,.14); }
.sheet .cell input:focus { outline: 2px solid var(--indigo); outline-offset: -2px; background: #26306b; color: #fff; }
.sheet .r-vac .cell input:focus { outline-color: var(--green); background: #0f4a3c; }
.sheet .r-task .c-cat { padding: 0; }
.r-task .c-cat input { text-align: center; }
.name-edit { display: flex; align-items: center; }
.name-edit input { min-width: 0; }
.del { opacity: 0; width: 0; padding: 0; overflow: hidden; }
.r-task:hover .del, .del:focus { opacity: 1; width: auto; padding: 4px; }
.del:hover { color: var(--rose); }

/* ---------- svátky, dashboard ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(max(230px, 22%), 1fr)); gap: 12px; }
.tile { padding: 14px 16px; border-left: 3px solid var(--tone, var(--line2)); }
.tile > * + * { margin-top: 3px; }
.tile-label, .tile-sub { color: var(--muted); font-size: 12px; }
.tile-value { font-size: 23px; font-weight: 650; }
.t-real { --tone: var(--ch-real); }
.t-plan { --tone: var(--sky); }
.t-off { --tone: var(--green); }
.t-hol { --tone: var(--rose); }
.t-we { --tone: var(--amber); }
.cols { display: grid; grid-template-columns: 5fr 7fr; gap: 18px; align-items: start; }
.cols-wide { grid-template-columns: 8fr 5fr; }
.stack { display: grid; gap: 18px; min-width: 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.row-cfg { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 10px; border-radius: 8px; background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.25); color: #a7f3d0; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.table-limit { max-height: 320px; overflow-y: auto; }
.list { width: 100%; border-collapse: collapse; font-size: 12px; }
.list th, .list td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
.list th { color: var(--muted); font-weight: 500; }
.list td.wrap { white-space: normal; }
.list .current { background: rgba(99,102,241,.1); }
.num th:not(:first-child), .num td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.breakdown { display: grid; gap: 14px; }
.bd-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; font-size: 12px; margin-bottom: 5px; }
.bd-name { overflow: hidden; text-overflow: ellipsis; }
.bd-name .badge { margin-left: 6px; font-style: normal; }

/* ---------- grafy ---------- */
.chart { overflow: hidden; }
.chart svg { display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--text2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 12px; height: 4px; border-radius: 2px; background: var(--c); }
.s-real { --c: var(--ch-real); }
.s-plan { --c: var(--ch-plan); }
.s-fore { --c: var(--ch-fore); }
.grid { stroke: var(--line); }
.ref { stroke: var(--faint); }
.cross { stroke: var(--muted); pointer-events: none; }
.axis { fill: var(--muted); font-size: 11px; }
.axis.cur { fill: #fff; font-weight: 700; }
.val { fill: var(--text); font-size: 12px; font-weight: 600; }
.end { text-anchor: end; }
.mid { text-anchor: middle; }
.line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: var(--c); stroke: var(--s1); stroke-width: 2; }
.bar { fill: var(--c); }
.hit { fill: transparent; cursor: pointer; }
.bar-g:hover .hit { fill: rgba(148,163,184,.07); }
.tooltip { position: fixed; z-index: 60; pointer-events: none; padding: 8px 10px; border-radius: 8px; background: #020617; border: 1px solid var(--line2); font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.tooltip div { display: flex; align-items: center; gap: 8px; }
.tooltip span { color: var(--muted); }
.tooltip strong { margin-left: auto; padding-left: 14px; }
.toasts { position: fixed; right: 16px; bottom: 54px; z-index: 50; display: grid; gap: 8px; max-width: 400px; }
.toast { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 10px; background: var(--s3); border: 1px solid var(--line2); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.err { border-color: var(--rose); background: #3b1220; }
.login { height: 100%; display: grid; place-items: center; }
.login-card { width: 320px; }
.login-card .brand { border: 0; padding: 0; min-height: 0; }
.login-card .btn { width: 100%; }

@media (max-width: 1400px) {
  .legend .hint { display: none; }
  .sheet { --w-name: 165px; min-width: 1210px; }
}
@media (max-width: 1000px) {
  .cols, .cols-wide { grid-template-columns: 1fr; }
  .legend { display: none; }
}
@media (max-width: 899px) {
  .app:not(.collapsed) .sidebar { position: absolute; z-index: 40; height: 100%; }
  .page-scroll .content { padding: 12px; }
}
