:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #0f5c8c; --accent-soft: #e5f0f7; --warn: #a15c00; --warn-soft: #fff4e0;
  --bad: #a3221b; --bad-soft: #fdecea; --ok: #1d6b3a; --ok-soft: #e6f4ea;
  --brand: #16324a;   /* hlavička a dlaždice Celkem; klient přepíše v theme.css */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 Calibri, Carlito, "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; font-weight: 600; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; font-weight: 600; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

header.top { background: var(--brand); color: #fff; padding: .6rem 1rem; }
.top-in { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; }
header.top a { color: #fff; }
.brand a { font-weight: 700; font-size: 1.15rem; }
.brand span { margin-left: .4rem; opacity: .65; }
header nav { display: flex; gap: .2rem; flex-wrap: wrap; justify-content: center; }
header nav a { padding: .3rem .7rem; border-radius: 4px; opacity: .85; }
header nav a.on, header nav a:hover { background: rgba(255,255,255,.14); opacity: 1; text-decoration: none; }
.user { font-size: .9rem; opacity: .85; justify-self: end; white-space: nowrap; }

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.2rem; }
.card.narrow { max-width: 380px; margin: 3rem auto; display: grid; gap: .8rem; }
label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
input, select, button { font: inherit; }
input, select { padding: .45rem .6rem; border: 1px solid #c9ced6; border-radius: 4px; background: #fff; color: var(--ink); }
button, .btn { padding: .5rem 1rem; border: 0; border-radius: 4px; background: var(--accent); color: #fff; cursor: pointer; display: inline-block; }
.btn.light { background: var(--accent-soft); color: var(--accent); }
.alert { background: var(--bad-soft); color: var(--bad); padding: .5rem .7rem; border-radius: 4px; margin: 0; }

.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.toolbar .filter { flex: 1; min-width: 200px; max-width: 420px; }
.toolbar .count { color: var(--muted); font-size: .9rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: .8rem 1rem; }
.tile .label { color: var(--muted); font-size: .85rem; }
.tile .value { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: .85rem; }
.tile.warn .value { color: var(--warn); }

.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .4rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8f9fb; font-weight: 600; font-size: .88rem; color: #3b4352; white-space: nowrap; position: sticky; top: 0; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]::after { content: ' ↕'; opacity: .3; font-size: .8em; }
th.asc::after { content: ' ↑'; opacity: .8; }
th.desc::after { content: ' ↓'; opacity: .8; }
tbody tr:hover { background: #f7fafc; }
tr.vacant td { color: var(--muted); }
tr.old td { color: var(--muted); text-decoration: line-through; text-decoration-color: #bbb; }
tfoot td { font-weight: 600; background: #f8f9fb; }
tr.group td { background: #eef1f5; font-weight: 600; }

.badge { display: inline-block; padding: .05rem .45rem; border-radius: 3px; font-size: .8rem; background: #eef1f5; color: #3b4352; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1.2rem; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

.check { margin-bottom: 1rem; }
.check h2 { display: flex; gap: .5rem; align-items: center; margin-top: 0; }
.check p { margin: .2rem 0 .6rem; color: var(--muted); }

@media (max-width: 900px) {
  .top-in { grid-template-columns: 1fr auto; }
  header nav { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
}
@media (max-width: 640px) {
  th, td { padding: .35rem .45rem; }
}

.flash { background: var(--ok-soft); color: var(--ok); padding: .5rem .8rem; border-radius: 4px; margin: 0 0 1rem; }
form.stack { display: grid; gap: .8rem; max-width: 520px; }
form.stack .row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--ink); }
.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
button.danger, .btn.danger { background: var(--bad); }

/* Průvodci */
.wizard { display: grid; gap: 1rem; }
.step h2 { margin-top: 0; display: flex; gap: .6rem; align-items: center; }
.step .n { display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--accent); color: #fff; font-size: .95rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .7rem 1rem; align-items: end; }
.grid-form .wide { grid-column: 1 / -1; }
.inline { display: flex; gap: .4rem; }
.inline input { flex: 1; min-width: 0; }
.tablewrap.scroll { max-height: 420px; overflow-y: auto; }
table.units td, table.items td { vertical-align: middle; }
table.items input:not([type=checkbox]), table.items select { width: 100%; min-width: 70px; }
table.items td:nth-child(2) input { min-width: 170px; }
table.mini { width: auto; }
tr.busy td { color: var(--muted); }
button.link { background: none; color: var(--bad); padding: .2rem .4rem; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: .8rem 0; border-top: 1px solid var(--line); margin-top: 1rem; }
.warnbox { background: var(--warn-soft); color: var(--warn); padding: .6rem .9rem; border-radius: 4px; margin-bottom: 1rem; }
.warnbox ul, .alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
div.alert { padding: .6rem .9rem; }
input[readonly] { background: #f1f3f6; }
[hidden] { display: none !important; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }   /* honeypot (formuláře přihlášení a obnovy hesla) */
.cf-turnstile { min-height: 65px; }

/* Volba měsíce */
.monthbar { background: #e9eff5; border-bottom: 1px solid #d3dde8; }
.mb-in { max-width: 1280px; margin: 0 auto; padding: .55rem 1rem; display: flex; gap: 1.6rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.mb-label { color: var(--muted); font-size: .95rem; }
.mb-label strong { color: var(--ink); font-weight: 600; }
.mb-group { display: inline-flex; align-items: center; gap: .5rem; }
.mb-group select { font-weight: 600; font-size: 1rem; padding: .35rem 2rem .35rem .8rem; min-width: 11rem; text-align: center; border-radius: 6px; border-color: #b9c6d4; }
.mb-btn { display: inline-grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: #fff; border: 1px solid #b9c6d4; color: var(--accent); transition: background .15s, color .15s; }
.mb-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }
.mb-today { font-size: .9rem; padding: .3rem .8rem; border-radius: 999px; border: 1px solid #b9c6d4; background: #fff; }
.mb-today:hover { text-decoration: none; background: var(--accent-soft); }
.mb-today.on { color: var(--muted); border-color: transparent; background: transparent; pointer-events: none; }
.notice { background: var(--accent-soft); color: var(--accent); padding: .5rem .8rem; border-radius: 4px; margin: 0 0 1rem; }

/* Přehled – dashboard */
.tiles.t4 { grid-template-columns: repeat(4, 1fr); }
.tiles.t5 { grid-template-columns: repeat(5, 1fr); }
.tiles.t6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) { .tiles.t5, .tiles.t6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px)  { .tiles.t4, .tiles.t5, .tiles.t6 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .tiles.t4, .tiles.t5, .tiles.t6 { grid-template-columns: 1fr; } }
.tile { display: flex; flex-direction: column; gap: .15rem; color: var(--ink); }
a.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile .value { font-size: 1.45rem; line-height: 1.2; white-space: nowrap; }
.tiles.t6 .tile .value, .tiles.t5 .tile .value { font-size: 1.25rem; }
.tile .sub { line-height: 1.4; }
.tile .of { font-size: .95rem; color: var(--muted); font-weight: 400; }
.tile .ln { display: flex; justify-content: space-between; gap: .5rem; font-size: .82rem; border-top: 1px dashed var(--line); padding-top: .15rem; margin-top: .15rem; }
.tile .ln span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile.cost .value { color: #7a3b12; }
.tile.est { border-style: dashed; }
.tile.placeholder { background: #f8f9fb; }
.tile.placeholder .value { color: #b0b6bf; }
.tile.ok .value { color: var(--ok); }
.tile.total { background: var(--brand); border-color: var(--brand); color: #fff; }
.tile.total .label, .tile.total .sub, .tile.total .muted { color: #c9d6e3; }
.tile.total .value { color: #7ee2a8; font-size: 1.6rem; }
.tile.total.neg .value { color: #ffb4a8; }
.tile.total .badge.warn { background: #ffe2b8; }
.tile.span2 { grid-column: span 2; }
.tile .label .op { display: inline-block; width: 1.1rem; font-weight: 700; color: var(--accent); }
.tile.total .label .op { color: #7ee2a8; }
@media (max-width: 1100px) { .sum-row .tile.span2 { grid-column: span 3; } }
@media (max-width: 800px)  { .sum-row .tile.span2 { grid-column: span 2; } }
@media (max-width: 480px)  { .sum-row .tile.span2 { grid-column: span 1; } }

/* ---------- Vývoj: grafy a roční tabulka ---------- */
.yearbar { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: .3rem 0 .2rem; }
.yearbar h1 { margin: 0; min-width: 8ch; text-align: center; }
.mb-btn.off { visibility: hidden; }
.center { text-align: center; }
.small { font-size: .82rem; }
.chartcard { margin-bottom: 1rem; }
.chartcard h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.legend i.dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--ink); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--ink); }
.s1 { fill: #2a78d6; background: #2a78d6; } .s2 { fill: #eb6834; background: #eb6834; }
.s3 { fill: #1baf7a; background: #1baf7a; } .s4 { fill: #6250d6; background: #6250d6; }
svg.chart { width: 100%; height: auto; display: block; font-family: inherit; }
svg.chart .grid { stroke: #eceef1; stroke-width: 1; } svg.chart .grid.zero { stroke: #b9c0ca; }
svg.chart .ax { fill: var(--muted); font-size: 11px; }
svg.chart g.dim { opacity: .45; }
svg.chart .ln { fill: none; stroke: var(--ink); stroke-width: 2; pointer-events: none; }
svg.chart .ln.s1 { stroke: #2a78d6; fill: none; background: none; }
svg.chart .pt { fill: var(--ink); stroke: #fff; stroke-width: 2; pointer-events: none; }
svg.chart .pt.s1 { fill: #2a78d6; } svg.chart .pt.dim { opacity: .5; }
svg.chart .hit { fill: transparent; cursor: pointer; }
svg.chart .hit:hover { fill: rgba(15, 92, 140, .06); }
.charttip { position: fixed; z-index: 50; pointer-events: none; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); padding: .45rem .65rem; font-size: .82rem; white-space: pre-line; max-width: 320px; }
table.yeartab th, table.yeartab td { white-space: nowrap; padding: .3rem .5rem; }
table.yeartab thead th { text-align: right; } table.yeartab thead th a { color: var(--ink); }
table.yeartab tbody th { font-weight: 400; text-align: left; }
table.yeartab .tag { font-size: .7rem; color: var(--muted); font-weight: 400; }
table.yeartab .dimcol .tag { color: var(--warn); }
table.yeartab tr.strong th, table.yeartab tr.strong td { font-weight: 600; }
table.yeartab tr.total td, table.yeartab tr.total th { border-top: 2px solid var(--ink); }
table.yeartab tr.sub th, table.yeartab tr.sub td { color: var(--muted); font-size: .85rem; }
table.yeartab tr.sep td { padding: .2rem; border: 0; background: var(--bg); }
table.yeartab .tot { background: #f8f9fb; font-weight: 600; }
table.yeartab .neg { color: var(--bad); }

/* Vývoj – přepínač režimu, srovnání */
.seg { display: flex; justify-content: center; gap: 0; margin: .4rem 0 .2rem; }
.seg a { padding: .35rem .9rem; border: 1px solid #b9c6d4; color: var(--accent); background: #fff; font-size: .92rem; }
.seg a:first-child { border-radius: 4px 0 0 4px; } .seg a:last-child { border-radius: 0 4px 4px 0; border-left: 0; }
.seg a.on { background: var(--accent); color: #fff; border-color: var(--accent); pointer-events: none; }
.seg a:hover { text-decoration: none; background: var(--accent-soft); }
.mb-year { font-size: 1.15rem; min-width: 4ch; text-align: center; }
svg.chart .ax.yr { font-size: 10px; font-weight: 600; }
svg.chart .pt.ghost { fill: #fff; stroke: #8a8f98; stroke-width: 2; }
.legend i.dot.ghost { background: #fff; border: 2px solid #8a8f98; box-shadow: none; }
table.yeartab .cmp { background: #fbfbfc; color: var(--muted); }
table.yeartab .pos { color: var(--ok); }

/* ---------- Energie ---------- */
.en-h3 { font-size: 1rem; margin: 1rem 0 .5rem; font-weight: 600; }
.en-drop { position: relative; display: grid; place-items: center; text-align: center; border: 2px dashed #b9c6d4; border-radius: 8px;
  background: #f8fafc; color: var(--ink); padding: 1.2rem; cursor: pointer; transition: background .15s, border-color .15s; }
.en-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.en-drop.over { background: var(--accent-soft); border-color: var(--accent); }
.en-drop-big { min-height: 9rem; }
.en-pdfcard p { margin: 0 0 .6rem; }
/* formulář: náhled PDF vlevo (svisle, sticky), pole vpravo – od 1100 px vedle sebe, jinak pod sebou */
body:has(.en-split) main { max-width: 1900px; }
.en-split { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; }
.en-preview { display: flex; flex-direction: column; gap: .5rem; }
.en-pbar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; min-height: 1.6rem; }
.en-preview { min-width: 0; }
.en-pbar .en-pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.en-pbar .actions { flex-shrink: 0; }
.en-frame { display: none; width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.en-drop-big { min-height: 12rem; }
.en-split.has-pdf .en-frame { display: block; }
.en-split.has-pdf .en-drop-big { display: none; }
.en-split.hide-pdf .en-frame, .en-split.hide-pdf .en-drop-big { display: none; }
.en-split .grid-form { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.en-split .grid-form label, .en-split .inline { min-width: 0; }
.en-split .grid-form input, .en-split .grid-form select { width: 100%; min-width: 0; }
.en-split .inline select { flex: 0 0 5.2rem; width: 5.2rem; }
table.items .p-mn, table.items .p-cena, table.items .p-zak, table.items .p-dph { text-align: right; }
table.items td:nth-child(2) input { min-width: 150px; }
#ensum.bad { color: var(--bad); font-weight: 600; }
#ensum.ok { color: var(--ok); }
@media (min-width: 1100px) {
  .en-split { grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); }
  .en-split.hide-pdf { grid-template-columns: minmax(0, 12rem) minmax(0, 1fr); }
  .en-preview { position: sticky; top: .5rem; height: calc(100vh - 1rem); }
  .en-frame, .en-drop-big { flex: 1; height: auto; min-height: 0; }
  .en-split.hide-pdf .en-pbar { flex-direction: column; align-items: flex-start; }
  .en-split.hide-pdf .en-pbar .en-pname { flex: none; width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: .82rem; }
}
