/* NVR – tmavé rozhraní pro dohled. Barvy jako proměnné, žádné externí závislosti. */
:root {
  --bg: #0d1117;
  --bg-elev: #151b23;
  --bg-elev-2: #1c2330;
  --bg-hover: #222b39;
  --border: #2a3342;
  --border-strong: #3a4556;
  --text: #e6edf3;
  --text-muted: #8b98a9;
  --text-faint: #5f6b7c;
  --accent: #3b82f6;
  --accent-hover: #2f6fe0;
  --accent-soft: rgba(59, 130, 246, .14);
  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, .14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, .14);
  --error: #ef4444;
  --error-soft: rgba(239, 68, 68, .14);
  --rec: #ef4444;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --sidebar: 224px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--bg-elev-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--text-muted); }
.hint { color: var(--text-faint); font-size: 12px; }
.text-error { color: var(--error); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.icon { flex-shrink: 0; vertical-align: -3px; }

/* --- Layout ---------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-center { justify-content: center; padding: 0 0 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .08em; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .icon { color: var(--accent); }
.nav-user {
  display: flex; align-items: center; gap: 8px;
  margin: 0 10px; padding: 10px; border-top: 1px solid var(--border);
}
.nav-user-name { flex: 1; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; color: var(--text-faint); font-size: 12px; }
.engine-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.engine-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.engine-dot.off { background: var(--error); box-shadow: 0 0 0 3px var(--error-soft); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px 28px 40px; max-width: 1600px; width: 100%; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 28px; font-weight: 500; }
.banner-error { background: var(--error-soft); color: #fca5a5; border-bottom: 1px solid rgba(239, 68, 68, .3); }

.page-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px 20px; margin-bottom: 20px;
}
.page-header > .muted { font-size: 13px; }
.header-actions, .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.page-loading { color: var(--text-muted); padding: 40px; text-align: center; }

/* --- Karty, statistiky ------------------------------------------------------ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card-header { display: flex; align-items: center; gap: 10px; margin: -2px 0 12px; }
.card-header h2 { margin: 0; }
.card-header > :last-child:not(:first-child):not(.spacer) { margin-left: auto; }
.card-header.filters { flex-wrap: wrap; }
.card-footer { display: flex; align-items: center; gap: 10px; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border); }
.info-card { display: flex; gap: 12px; align-items: flex-start; color: var(--text-muted); }
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-muted); }
.empty-state p { margin: 0 0 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border-strong); }
.stat-ok::before { background: var(--ok); }
.stat-error::before { background: var(--error); }
.stat-rec::before { background: var(--rec); }
.stat-wide { grid-column: span 2; }
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-of { font-size: 16px; color: var(--text-muted); font-weight: 500; }
.stat-note { font-size: 12px; color: var(--text-faint); }
.stat-error .stat-value { color: var(--error); }

.meter { height: 6px; background: var(--bg-elev-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter-lg { height: 10px; }
.meter-fill { height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s; }
.meter-warn { background: var(--warn); }
.meter-error { background: var(--error); }
.meter:has(.meter-limit) { position: relative; overflow: visible; }
.meter:has(.meter-limit) .meter-fill { border-radius: 99px; }
.meter-limit { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text-muted); border-radius: 1px; }
.storage-form { margin-top: 14px; }
.alert-warn { background: var(--warn-soft, rgba(245, 158, 11, .15)); color: #fcd34d; }
.alert a { color: inherit; text-decoration: underline; margin-left: 8px; }
.alert .icon { vertical-align: -3px; margin-right: 6px; }
.badge-protected { background: rgba(245, 158, 11, .15); color: #fcd34d; }
.inline-confirm { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.alert-list { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }

/* --- Tabulky ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
.table-scroll { max-height: 420px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-elev);
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-compact td { padding: 7px 10px; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .row-active { background: var(--accent-soft); }
.table .check { width: 36px; text-align: center; padding-right: 0; }
.table .check input { display: block; margin: 0 auto; cursor: pointer; }
.table .check input:disabled { cursor: not-allowed; opacity: .35; }
.table .row-selected { background: var(--bg-hover); }
/* Lišta nad tabulkou s akcemi pro vybrané řádky. */
.table-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.table tr.clickable { cursor: pointer; }
.error-cell { max-width: 360px; font-size: 12.5px; }
pre.details {
  margin: 8px 0 0; padding: 8px; background: var(--bg); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--text-muted);
}

/* --- Štítky ------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-info { background: var(--accent-soft); color: #93c5fd; }
.badge-muted { background: var(--bg-elev-2); color: var(--text-muted); }
.rec-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rec);
  animation: rec-pulse 1.6s ease-in-out infinite; vertical-align: 0;
}
@keyframes rec-pulse { 50% { opacity: .35; } }

/* --- Tlačítka a formuláře ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elev-2); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--error); border-color: var(--error); color: white; }
.btn-danger-text { color: var(--error); border-color: transparent; }
.btn-block { width: 100%; }
.btn-icon {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); cursor: pointer;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.btn-icon:disabled { opacity: .35; cursor: not-allowed; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  height: 34px; padding: 0 10px; width: 100%; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input:disabled, select:disabled { opacity: .6; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.select { width: auto; min-width: 180px; }
.input-date { width: 150px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; align-items: start; }
.form-grid .card { margin: 0; }
.form-grid .card-wide { grid-column: 1 / -1; }
.fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label, .field > span:first-child { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field-error, .validation-message { color: var(--error); font-size: 12px; }
.field-invalid input, .field-invalid select, .invalid { border-color: var(--error); }
.field-row { display: flex; gap: 12px; }
.field-row .grow { flex: 1; }
.field-row .narrow { width: 110px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.input-with-button { display: flex; gap: 8px; }
.inline-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 500; }
.alert-error { background: var(--error-soft); color: #fca5a5; }
.alert-ok { background: var(--ok-soft); color: #86efac; }
.probe { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; margin-top: 4px; }
.probe-ok { color: var(--ok); }
.probe-warn { color: var(--warn); }
.probe-error { color: var(--error); }
.probe-pending { color: var(--text-muted); }

.segmented { display: inline-flex; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--text-muted); height: 28px; min-width: 32px; padding: 0 8px;
  border-radius: 4px; cursor: pointer; font: inherit; font-weight: 600; display: grid; place-items: center;
}
.segmented button.active { background: var(--bg-hover); color: var(--text); }
.pager, .date-nav { display: inline-flex; align-items: center; gap: 4px; }

dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.props dt { color: var(--text-muted); }
dl.props dd { margin: 0; overflow-wrap: anywhere; }

.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Video ---------------------------------------------------------------------- */
.video-wrap { position: relative; width: 100%; height: 100%; background: #000; overflow: hidden; }
.video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.video-status {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; background: rgba(0, 0, 0, .55);
}
.video-status-error { color: #fca5a5; }

.live-grid {
  display: grid; gap: 6px;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}
.tile-slot { aspect-ratio: 16 / 9; border-radius: var(--radius-sm); overflow: hidden; background: #000; border: 1px solid var(--border); }
.tile-slot.dragging { opacity: .4; }
.tile-empty { background: var(--bg-elev); border-style: dashed; }
.tile, .tile .video-wrap { width: 100%; height: 100%; }
.tile { position: relative; }
.tile-overlay {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: linear-gradient(rgba(0, 0, 0, .7), transparent);
  font-size: 12.5px; font-weight: 600; text-shadow: 0 1px 2px #000;
  opacity: .92; transition: opacity .2s;
}
.tile-overlay .btn-icon { width: 28px; height: 28px; color: #fff; opacity: 0; }
.tile:hover .tile-overlay .btn-icon { opacity: .85; }
.tile-rec { display: inline-flex; align-items: center; gap: 5px; color: #fca5a5; font-size: 11px; letter-spacing: .06em; }
.tile-offline { color: #fca5a5; font-size: 11px; letter-spacing: .06em; }
.live-single { height: calc(100vh - 150px); min-height: 360px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.tile-max .tile-overlay .btn-icon { opacity: .85; }

/* --- Záznamy / časová osa -------------------------------------------------------- */
.playback-card { padding: 0; overflow: hidden; }
.playback-video { aspect-ratio: 16 / 9; max-height: 62vh; background: #000; width: 100%; }
.video-placeholder { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-faint); gap: 8px; }
.playback-controls { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.btn-play { background: var(--accent); color: white; }
.btn-play:hover { background: var(--accent-hover); color: white; }
.playback-clock { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-left: 10px; min-width: 190px; }
.timeline { position: relative; padding: 14px 14px 6px; cursor: pointer; user-select: none; }
.timeline-track { position: relative; height: 34px; background: var(--bg-elev-2); border-radius: var(--radius-sm); overflow: hidden; }
.timeline-bar { position: absolute; top: 6px; bottom: 6px; background: linear-gradient(var(--accent), #2563eb); border-radius: 2px; min-width: 1px; }
.timeline-cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, .8); transform: translateX(-1px); }
.timeline-ticks { position: relative; height: 20px; margin-top: 4px; }
.timeline-tick { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.timeline-tick::before { content: ""; position: absolute; left: 50%; top: -6px; width: 1px; height: 5px; background: var(--border-strong); }
.timeline-tooltip {
  display: none; position: absolute; top: -10px; transform: translateX(-50%); pointer-events: none;
  background: var(--bg-hover); border: 1px solid var(--border-strong); border-radius: 4px; padding: 2px 6px;
  font-family: var(--mono); font-size: 12px; margin-left: 14px;
}
.timeline-legend { display: flex; justify-content: space-between; gap: 12px; padding: 0 14px 12px; font-size: 12px; }
.legend-box { display: inline-block; width: 12px; height: 8px; background: var(--accent); border-radius: 2px; margin-right: 4px; }

/* --- Úložiště ---------------------------------------------------------------------- */
.storage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 18px; }
.storage-card { margin: 0; }
.storage-card .card-header { justify-content: space-between; }
.storage-path { color: var(--text-muted); margin-bottom: 14px; }
.storage-usage { display: flex; align-items: baseline; gap: 10px; }
.storage-used { font-size: 24px; font-weight: 600; }
.storage-card dl.props { margin-top: 16px; font-size: 13px; }

/* --- Přihlášení --------------------------------------------------------------------- */
.account-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(59, 130, 246, .12), transparent), var(--bg);
}
.account-card {
  width: 100%; max-width: 380px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 30px 28px; box-shadow: var(--shadow);
}
.account-title { text-align: center; font-size: 18px; margin-bottom: 18px; }
.account-card p.muted { font-size: 13px; text-align: center; margin: -8px 0 18px; }

/* --- Chybová lišta Blazoru ------------------------------------------------------------ */
#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
  background: #7f1d1d; color: #fff; padding: 10px 20px;
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* --- Responzivita ------------------------------------------------------------------- */
@media (max-width: 900px) {
  :root { --sidebar: 64px; }
  .nav-item span, .brand-name, .nav-user-name, .sidebar-footer span:last-child { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 18px 14px 30px; }
  .stat-wide { grid-column: span 1; }
  .form-grid { grid-template-columns: 1fr; }
  .live-grid { --cols: 1 !important; }
  .timeline-tick.minor { display: none; }
}
