/* Cerbo App – základní vzhled (bez knihovny komponent). Světlý i tmavý režim podle systému. */
:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f0f3f7; --border: #e2e7ee;
  --text: #1c2430; --muted: #66707d; --accent: #0d6efd; --accent-soft: #e7f0ff;
  --ok: #1a9c5b; --ok-soft: #e3f6ec; --warn: #d98c00; --warn-soft: #fff4dc; --crit: #d63a3a; --crit-soft: #fde8e8;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419; --surface: #171d25; --surface-2: #1e2631; --border: #2a3441;
    --text: #e6ebf1; --muted: #8b96a5; --accent: #5aa2ff; --accent-soft: #14284a;
    --ok: #3ccf7f; --ok-soft: #10301f; --warn: #f2b03c; --warn-soft: #3a2a08; --crit: #ff6b6b; --crit-soft: #3d1414;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .05em .35em; border-radius: 5px; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h1:focus { outline: none; }
h2 { font-size: 1rem; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.warn-text { color: var(--warn); }

/* shell */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #ffb340, #ff7a1a); color: #fff; font-size: 1.05rem; }
.nav { display: flex; gap: .25rem; margin-left: .5rem; }
.nav a { display: flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .ico { display: inline-flex; line-height: 1; }
.nav .ico svg { width: 18px; height: 18px; }
.topbar-right { margin-left: auto; }
.content { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 1.25rem 1.25rem 4.5rem; }
.page-head { margin-bottom: 1rem; }
.page-head p { margin: 0; }

/* status pill */
.status-pill { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .8rem .35rem .6rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: .9rem; }
.status-pill:hover { text-decoration: none; }
.status-pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent); animation: pulse 2s infinite; }
.status-pill.warn .dot { background: var(--warn); }
.status-pill.crit .dot { background: var(--crit); box-shadow: 0 0 0 4px color-mix(in srgb, var(--crit) 25%, transparent); }
.status-pill .sub { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card.span2 { grid-column: span 2; }
@media (max-width: 680px) { .card.span2 { grid-column: span 1; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.card-body { padding: .9rem 1rem; }
.card-body > p:first-child { margin-top: 0; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); flex: 0 0 auto; }
.kv .v { text-align: right; }
.big { font-size: 2.2rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .4rem; }

/* dům teď – dlaždice */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.tile { padding: .6rem .7rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.tile-label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin: .1rem 0; }
.tile-unit { font-size: .8rem; font-weight: 500; color: var(--muted); }
.tile-sub { font-size: .78rem; color: var(--muted); }
.ok-text { color: var(--ok); } .crit-text { color: var(--crit); }
.temps { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin-top: .7rem; font-size: .85rem; color: var(--muted); }
.temps b { color: var(--text); font-weight: 600; }

/* badges, alerts */
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.crit { background: var(--crit-soft); color: var(--crit); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.alert { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.alert.crit { background: var(--crit-soft); border-color: color-mix(in srgb, var(--crit) 40%, transparent); color: var(--crit); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); }

/* ostrý provoz */
.groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .6rem; }
.group { padding: .55rem .6rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; gap: .1rem; }
.group.on { border-color: color-mix(in srgb, var(--ok) 50%, transparent); background: var(--ok-soft); }
.group.off { opacity: .75; }
.group-name { font-size: .8rem; color: var(--muted); }
.group-state { font-weight: 700; text-transform: uppercase; font-size: .9rem; }
.group.on .group-state { color: var(--ok); }

/* hlídač – komponenty */
.components { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .4rem .9rem; }
.comp { display: flex; align-items: flex-start; gap: .6rem; padding: .4rem .2rem; border-bottom: 1px dashed var(--border); }
.comp-dot { flex: 0 0 auto; width: 10px; height: 10px; margin-top: .4rem; border-radius: 50%; background: var(--muted); }
.comp.ok .comp-dot { background: var(--ok); }
.comp.warn .comp-dot { background: var(--warn); }
.comp.crit .comp-dot { background: var(--crit); }
.comp-main { flex: 1; min-width: 0; }
.comp-name { font-weight: 600; font-size: .92rem; }
.comp-detail { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.comp-age { color: var(--muted); font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.comp.crit .comp-name { color: var(--crit); }
.comp.warn .comp-name { color: var(--warn); }

/* log */
ul.log { list-style: none; margin: .4rem 0 0; padding: 0; font-size: .88rem; }
ul.log li { padding: .25rem 0; border-bottom: 1px dashed var(--border); }
ul.log li:last-child { border-bottom: 0; }
ul.log .ts { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: .4rem; }

/* tabulky */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: .65rem .8rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: .55rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.dim { opacity: .55; }
.tbl tr.row-warn td { background: var(--warn-soft); }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl .val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .reason { max-width: 320px; overflow-wrap: anywhere; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: .78rem; margin-top: .1rem; }
.detail-row td { background: var(--surface-2); }
pre.json { margin: 0; font: .8rem/1.4 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 60vh; overflow: auto; }

/* mobil: spodní navigace */
@media (max-width: 680px) {
  /* backdrop-filter na liště by z ní udělal kontejner pro position:fixed – spodní navigace by se přilepila nahoru */
  .topbar { padding: .5rem .9rem; backdrop-filter: none; background: var(--surface); }
  .brand-name { display: none; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 10; justify-content: space-around; padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
  .nav a { flex-direction: column; gap: .1rem; padding: .3rem .6rem; font-size: .72rem; }
  .nav .ico svg { width: 22px; height: 22px; }
  .content { padding: 1rem .9rem 5rem; }
  .grid { grid-template-columns: 1fr; }
  .status-pill .text { display: none; }
  .status-pill { padding: .35rem .6rem; }
  .nav a { flex: 1 1 0; min-width: 0; padding: .3rem .2rem; font-size: .68rem; white-space: nowrap; }
  .nav a.nav-desktop { display: none; }
}

/* Blazor reconnect / error */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; padding: .8rem 1rem; background: var(--warn-soft); color: var(--text); border-top: 1px solid var(--warn); }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }
#components-reconnect-modal { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.25rem 1.5rem; max-width: 26rem; box-shadow: var(--shadow); }
#components-reconnect-modal::backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(3px); }
.components-reconnect-container { display: flex; flex-direction: column; align-items: center; gap: .6rem; text-align: center; }
.components-reconnect-container p { margin: 0; }
.components-reconnect-container button { padding: .45rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--accent); color: #fff; font: inherit; cursor: pointer; }
.components-rejoining-animation { position: relative; width: 36px; height: 36px; }
.components-rejoining-animation div { position: absolute; inset: 0; border: 3px solid var(--accent); border-radius: 50%; opacity: 0; animation: rejoin 1.6s ease-out infinite; }
.components-rejoining-animation div:nth-child(2) { animation-delay: .8s; }
@keyframes rejoin { 0% { transform: scale(.2); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }

/* matice (Syncfusion Grid) */
.matrix-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.matrix-wrap .e-grid .e-content { overflow-y: visible !important; }
.matrix-wrap .e-grid .e-gridheader.e-sticky { top: 54px !important; } /* pod horní lištou */
.matrix-wrap .e-grid { border: 0; font-size: .85rem; }
.matrix-wrap .e-grid .e-headercell, .matrix-wrap .e-grid .e-headercelldiv { font-size: .75rem; font-weight: 600; padding: 4px 6px; }
.matrix-wrap .e-grid .e-rowcell { padding: 2px 6px; line-height: 24px; font-variant-numeric: tabular-nums; }
.matrix-wrap .e-grid .e-stackedheadercelldiv { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.matrix-wrap .e-grid tr.row-hour td { border-top: 2px solid color-mix(in srgb, var(--text) 35%, transparent) !important; }
.matrix-wrap .e-grid tr.row-current td { background: var(--accent-soft) !important; font-weight: 600; }
.matrix-wrap .e-grid tr.row-past td { opacity: .55; }
.matrix-wrap .e-grid .e-headercell.grp-exp, .matrix-wrap .e-grid .e-stackedheadercell.grp-exp { background: color-mix(in srgb, #2e9e6e 14%, var(--surface-2)); }
.matrix-wrap .e-grid .e-headercell.grp-dev, .matrix-wrap .e-grid .e-stackedheadercell.grp-dev { background: color-mix(in srgb, #d98c00 16%, var(--surface-2)); }
.matrix-wrap .e-grid .e-headercell.grp-bat, .matrix-wrap .e-grid .e-stackedheadercell.grp-bat { background: color-mix(in srgb, #3d7bff 14%, var(--surface-2)); }
.matrix-wrap .e-grid .e-rowcell.flag-col { padding: 0; text-align: center; }
.matrix-wrap .e-grid .e-rowcell.flag-col.grp-exp { background: color-mix(in srgb, #2e9e6e 5%, transparent); }
.matrix-wrap .e-grid .e-rowcell.flag-col.grp-dev { background: color-mix(in srgb, #d98c00 6%, transparent); }
.matrix-wrap .e-grid .e-rowcell.flag-col.grp-bat { background: color-mix(in srgb, #3d7bff 5%, transparent); }
.flag { display: inline-block; min-width: 100%; height: 24px; line-height: 24px; font-size: .95rem; position: relative; }
.flag.ov::after { content: ""; position: absolute; top: 0; right: 0; border: 5px solid transparent; border-top-color: var(--warn); border-right-color: var(--warn); }
.legend-ov { display: inline-block; width: 18px; height: 18px; min-width: 0; vertical-align: middle; border: 1px solid var(--border); border-radius: 3px; }
.flag.on { color: var(--ok); }
.grp-dev .flag.on { color: #c47a00; }
.grp-bat .flag.on { color: #3d7bff; }
.ov-text { text-decoration: underline dotted; }
.t-den { color: var(--muted); font-size: .75rem; margin-right: .2rem; }
.vt { color: var(--warn); } .nt { color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; margin-left: auto; cursor: pointer; }
details.legend { margin-top: .9rem; font-size: .85rem; }
details.legend summary { cursor: pointer; color: var(--accent); }
.legend-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; margin-top: .6rem; }
.legend-group ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.legend-group li { margin: .15rem 0; }
@media (max-width: 680px) { .matrix-wrap .e-grid { font-size: .8rem; } label.check { margin-left: 0; } }

/* historie: přepínače, grafy, záznam */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: .85rem; padding: .4rem .75rem; border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); color: var(--text); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn { font: inherit; font-size: .85rem; padding: .4rem .8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }
.charts .card-body { padding: .5rem .5rem .3rem; }
.charts .e-chart { overflow: visible; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl tr.row-sel td { background: var(--accent-soft); }
.tbl.energy td { padding: .45rem .6rem; font-variant-numeric: tabular-nums; }
.chips { gap: .35rem; }
.chip { font: inherit; font-size: .8rem; padding: .25rem .65rem; border-radius: 999px; border: 1px solid var(--border); background: var(--accent-soft); color: var(--accent); cursor: pointer; }
.chip.off { background: var(--surface); color: var(--muted); text-decoration: line-through; }
h2.day-head { margin: 1rem 0 .3rem; font-size: .95rem; text-transform: capitalize; }
ul.log.events li.ev { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .5rem; padding: .35rem 0; }
ul.log.events .src { color: var(--muted); font-size: .8rem; }
ul.log.events .txt { flex: 1 1 100%; overflow-wrap: anywhere; }
ul.log.events li.crit .txt { color: var(--crit); }
ul.log.events li.warn .txt { color: var(--warn); }
@media (min-width: 681px) { ul.log.events .txt { flex: 1 1 auto; } }

/* přihlášení a účet */
.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem 1.4rem; }
.auth-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; margin-bottom: 1rem; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: .8rem; }
.auth-form { display: flex; flex-direction: column; gap: .8rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field > span { font-size: .82rem; color: var(--muted); }
.field input, .field select, .inline-form input { font: inherit; padding: .55rem .7rem; border-radius: 9px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.field input:focus, .inline-form input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.field-err, .validation-message { color: var(--crit); font-size: .8rem; }
label.check { display: flex; align-items: center; gap: .45rem; font-size: .9rem; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.btn.wide { width: 100%; padding: .6rem; }
.btn.small { padding: .25rem .55rem; font-size: .78rem; }
.auth-or { text-align: center; color: var(--muted); font-size: .8rem; }
.auth-note { margin: 1rem 0 0; }
.alert.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ok); }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .4rem; margin: .6rem 0; }
.recovery-codes code { font-size: 1rem; padding: .35rem .5rem; text-align: center; }
.qr { max-width: 240px; margin: 0 auto .5rem; }
.qr svg { width: 100%; height: auto; display: block; border-radius: 8px; }
kbd, code.otp { font-family: var(--mono); background: var(--surface-2); padding: .15em .45em; border-radius: 5px; font-size: .95em; }
.inline-form { display: inline-flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.inline-form input { padding: .3rem .5rem; font-size: .85rem; }
.user-menu { position: relative; margin-left: .5rem; }
.user-menu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: .85rem; font-weight: 600; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu-list { position: absolute; right: 0; top: calc(100% + .35rem); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: .35rem; display: flex; flex-direction: column; z-index: 20; }
.user-menu-list a, .user-menu-list button { text-align: left; font: inherit; font-size: .9rem; padding: .45rem .7rem; border-radius: 8px; color: var(--text); background: transparent; border: 0; cursor: pointer; }
.user-menu-list a:hover, .user-menu-list button:hover { background: var(--surface-2); text-decoration: none; }
.user-menu-list form { display: contents; }
.topbar-right { display: flex; align-items: center; gap: .4rem; }
@media (max-width: 680px) { .user-name { display: none; } }
