/* Lapsa — webové rozhranie. Bez závislostí, svetlá aj tmavá téma. */

:root {
  --bg: #f5f4f1;
  --panel: #ffffff;
  --panel-2: #faf9f7;
  --line: #e4e1db;
  --line-strong: #cfcac1;
  --text: #1d1c1a;
  --muted: #6b675f;
  --faint: #9a958b;
  --accent: #d9731a;
  --accent-ink: #ffffff;
  --accent-soft: #fbeadb;
  --ok: #2f8a4c;
  --ok-soft: #e1f2e6;
  --warn: #b7791f;
  --warn-soft: #fbf0d9;
  --bad: #c2412d;
  --bad-soft: #fbe3de;
  --info: #2f6db3;
  --info-soft: #e0ebf8;
  --shadow: 0 1px 2px rgba(20, 18, 14, .06), 0 4px 16px rgba(20, 18, 14, .05);
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --panel: #1e1d1a;
    --panel-2: #23221f;
    --line: #34322d;
    --line-strong: #46433c;
    --text: #ecebe7;
    --muted: #a39e93;
    --faint: #7a766d;
    --accent: #ec8a35;
    --accent-ink: #1a1105;
    --accent-soft: #3a2a1a;
    --ok: #5cc27d;
    --ok-soft: #1c3324;
    --warn: #e0a54a;
    --warn-soft: #3a2f1a;
    --bad: #ef7a64;
    --bad-soft: #3d221d;
    --info: #74a8e6;
    --info-soft: #1c2a3b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- rozloženie */

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 17px; }
.brand svg { flex: none; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 520;
}
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 10px; color: var(--faint); font-size: 12px; border-top: 1px solid var(--line); }
.side-foot button { margin-top: 8px; width: 100%; justify-content: flex-start; }
.mobile-only { display: none !important; }

main { padding: 26px 32px 60px; max-width: 1400px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; display: block; }

.section { margin-top: 28px; }
.section > .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* ---------------------------------------------------------------- panely */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 18px; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.cams { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.vids { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.two { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }

.tile { padding: 16px 18px; }
.tile .label { color: var(--muted); font-size: 12.5px; }
.tile .value { font-size: 26px; font-weight: 680; margin-top: 6px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.tile .foot { color: var(--faint); font-size: 12.5px; margin-top: 4px; }

.meter { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.meter.bad > span { background: var(--bad); }
.meter.warn > span { background: var(--warn); }

/* ---------------------------------------------------------------- kamera kartička */

.cam { overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; }
.cam:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.thumb {
  aspect-ratio: 16 / 9; background: var(--panel-2);
  display: grid; place-items: center; color: var(--faint); font-size: 12.5px;
  position: relative; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .overlay {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0, 0, 0, .6); color: #fff;
  font-size: 11.5px; padding: 2px 7px; border-radius: 6px;
}
.cam .body { padding: 12px 14px 14px; }
.cam .title { display: flex; align-items: center; gap: 8px; font-weight: 620; }
.cam .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- tabuľky */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td .sub { color: var(--muted); font-size: 12.5px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }

/* ---------------------------------------------------------------- ovládacie prvky */

button, .btn {
  font: inherit; font-weight: 560;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { background: var(--panel-2); text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.06); background: var(--accent); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
button.danger:hover { background: var(--bad-soft); }
button.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { background: var(--panel-2); color: var(--text); }
button.sm, .btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
button svg, .btn svg { width: 16px; height: 16px; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 1px;
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }

.form { display: grid; gap: 14px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 580; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check .hint { display: block; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 580; white-space: nowrap;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 120px; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.progress.running > span {
  background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, color-mix(in srgb, var(--accent) 75%, #fff) 8px 16px);
  background-size: 22px 22px; animation: stripes 1s linear infinite;
}
@keyframes stripes { to { background-position: 22px 0; } }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; color: var(--muted); padding: 9px 14px;
}
.tabs button:hover { color: var(--text); background: none; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty button { margin-top: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.err-text { color: var(--bad); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.callout { padding: 12px 14px; border-radius: 8px; background: var(--info-soft); color: var(--text); font-size: 13.5px; }
.callout.warn { background: var(--warn-soft); }
.callout.bad { background: var(--bad-soft); }
.secret {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; white-space: pre-wrap; word-break: break-all;
}

/* ---------------------------------------------------------------- kalendár snímok */

.months { display: grid; gap: 16px; }
.month h3 { font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; text-transform: capitalize; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; max-width: 340px; }
.days .dow { font-size: 10.5px; color: var(--faint); text-align: center; padding-bottom: 2px; }
.day {
  aspect-ratio: 1; border-radius: 5px; border: 0; padding: 0;
  font-size: 11px; font-weight: 560; color: var(--muted);
  background: var(--panel-2); cursor: default;
}
.day.has { cursor: pointer; color: var(--text); }
.day.l1 { background: color-mix(in srgb, var(--accent) 18%, var(--panel)); }
.day.l2 { background: color-mix(in srgb, var(--accent) 35%, var(--panel)); }
.day.l3 { background: color-mix(in srgb, var(--accent) 55%, var(--panel)); }
.day.l4 { background: color-mix(in srgb, var(--accent) 80%, var(--panel)); color: var(--accent-ink); }
.day.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.day:hover.has { filter: brightness(1.08); }

.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.frame { border-radius: 7px; overflow: hidden; cursor: pointer; background: var(--panel-2); position: relative; border: 0; padding: 0; }
.frame img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.frame span {
  position: absolute; left: 5px; bottom: 5px;
  background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 5px;
}

/* ---------------------------------------------------------------- video kartička */

.vid { overflow: hidden; }
.vid .thumb { cursor: pointer; background: #111; }
.vid .play {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, .92); display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.vid .play svg { width: 20px; height: 20px; margin-left: 3px; color: #111; }
.vid .thumb img { position: absolute; inset: 0; opacity: .75; }
.vid .thumb .play { position: relative; }
.vid .body { padding: 12px 14px; }
.vid .title { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vid .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.vid .acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- modal, lightbox, toast */

.modal-back {
  position: fixed; inset: 0; background: rgba(12, 11, 9, .55);
  display: grid; place-items: center; padding: 20px; z-index: 50;
  animation: fade .12s ease-out;
}
.modal {
  background: var(--panel); border-radius: 12px; border: 1px solid var(--line);
  width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--panel-2); position: sticky; bottom: 0; }
.modal video { width: 100%; border-radius: 8px; background: #000; display: block; max-height: 70vh; }
@keyframes fade { from { opacity: 0; } }

.lightbox { position: fixed; inset: 0; background: rgba(8, 8, 7, .92); z-index: 60; display: flex; flex-direction: column; color: #eee; }
.lightbox .lb-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.lightbox .lb-top .spacer { flex: 1; }
.lightbox .lb-img { flex: 1; display: grid; place-items: center; min-height: 0; padding: 0 60px; position: relative; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255, 255, 255, .12); color: #fff; border: 0; width: 44px; height: 44px; border-radius: 50%;
}
.lightbox .nav-btn:hover { background: rgba(255, 255, 255, .22); }
.lightbox .prev { left: 10px; }
.lightbox .next { right: 10px; }
.lightbox button { background: rgba(255, 255, 255, .1); color: #eee; border-color: rgba(255, 255, 255, .2); }
.lightbox button:hover { background: rgba(255, 255, 255, .2); }
.lightbox button.danger { color: #ff9c87; }
.lightbox .lb-info { padding: 10px 16px 14px; font-size: 13px; color: #bbb; display: flex; gap: 18px; flex-wrap: wrap; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 80; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  background: var(--text); color: var(--bg); padding: 11px 15px; border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25); font-size: 13.5px; animation: fade .15s;
}
.toast.bad { background: var(--bad); color: #fff; }

/* ---------------------------------------------------------------- prihlásenie */

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); padding: 28px; }
.login .brand { padding: 0 0 6px; font-size: 20px; }
.login p { color: var(--muted); margin: 0 0 20px; }

.spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: rot .7s linear infinite; display: inline-block;
}
.loading { display: grid; place-items: center; padding: 60px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- mobil */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: 0; z-index: 20; height: auto;
    flex-direction: row; align-items: center; padding: 8px 12px;
    border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto;
  }
  .brand { padding: 0 8px 0 0; font-size: 15px; }
  .brand span { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { padding: 7px 9px; font-size: 13px; }
  .nav a .lbl { display: none; }
  .nav a.active .lbl { display: inline; }
  .side-foot { display: none; }
  .mobile-only { display: flex !important; }
  main { padding: 18px 16px 50px; }
  .two { grid-template-columns: 1fr; }
  .lightbox .lb-img { padding: 0 8px; }
  .lightbox .nav-btn { display: none; }
}
