:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1d1f22;
  --muted: #6b6f76;
  --line: #e4e2dc;
  --soft: #f0eee9;
  --green: #1f9d55;
  --green-soft: #e3f3ea;
  --amber: #c98a12;
  --amber-soft: #fbf0d9;
  --red: #c0392b;
  --red-soft: #f9e3e0;
  --blue: #2f6fd6;
  --blue-soft: #e3ecfb;
  --purple: #7b4fd1;
  --grey: #b9bdc2;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151618; --card: #1d1f22; --ink: #ececec; --muted: #9a9ea5; --line: #2e3135; --soft: #25272b;
    --green-soft: #173726; --amber-soft: #3a2e14; --red-soft: #3d1f1b; --blue-soft: #1b2a45; --grey: #4b4f55;
  }
}
:root[data-theme="dark"] {
  --bg: #151618; --card: #1d1f22; --ink: #ececec; --muted: #9a9ea5; --line: #2e3135; --soft: #25272b;
  --green-soft: #173726; --amber-soft: #3a2e14; --red-soft: #3d1f1b; --blue-soft: #1b2a45; --grey: #4b4f55;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
[hidden] { display: none !important; }
a { color: inherit; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.2px; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.error { color: var(--red); }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons & inputs */
button, .btn { font: inherit; cursor: pointer; border: 0; border-radius: 8px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--ink); color: var(--bg); padding: 8px 14px; font-weight: 600; }
.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); padding: 7px 12px; }
.ghost:hover { border-color: var(--muted); }
.sm { padding: 4px 10px; font-size: 12.5px; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font: inherit; }
.link:hover { color: var(--ink); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--ink); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* Top bar */
.bar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.bar nav { display: flex; gap: 4px; overflow-x: auto; }
.bar nav a { padding: 6px 10px; border-radius: 7px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.bar nav a:hover { color: var(--ink); }
.bar nav a.on { background: var(--soft); color: var(--ink); font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--blue); color: #fff; font-size: 11px; text-align: center; line-height: 18px; }
.me { margin-left: auto; display: flex; gap: 14px; align-items: center; white-space: nowrap; font-size: 13px; }
.dl { color: var(--muted); }

main { max-width: 1200px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline { display: flex; gap: 6px; align-items: center; }

.seg { display: inline-flex; background: var(--soft); border-radius: 9px; padding: 3px; }
.seg a { padding: 5px 11px; border-radius: 7px; text-decoration: none; color: var(--muted); font-size: 13px; }
.seg a.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card.flush { padding: 0; overflow-x: auto; }
.narrow-card { max-width: 560px; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat .num { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.r { text-align: right; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td a { text-decoration: none; }
.table td a.link { text-decoration: underline; }
.table tr.dim td { opacity: .55; }
.table .reason { max-width: 340px; }
.card:not(.flush) .table th:first-child, .card:not(.flush) .table td:first-child { padding-left: 0; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pill.good { background: var(--green-soft); color: var(--green); }
.pill.mid { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.flag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; background: var(--amber-soft); color: var(--amber); white-space: nowrap; }
.flag.bad { background: var(--red-soft); color: var(--red); }
.flag.blue { background: var(--blue-soft); color: var(--blue); }
.flag-line { margin-top: 10px; color: var(--amber); font-size: 13px; }
.status { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.status.pending { background: var(--blue-soft); color: var(--blue); }
.status.approved { background: var(--green-soft); color: var(--green); }
.status.rejected { background: var(--red-soft); color: var(--red); }

/* Timeline */
.timeline { width: 100%; height: 46px; display: block; }
.tl-bg { fill: var(--soft); }
.tl-active { fill: var(--green); }
.tl-kept { fill: var(--blue); }
.tl-manual { fill: var(--purple); }
.tl-idle { fill: var(--amber); opacity: .55; }
.tl-removed { fill: var(--grey); }
.tl-offline { opacity: .6; }
.tl-shot { fill: var(--ink); }
.tl-shot-bad { fill: var(--red); }
.tl-hours { position: relative; height: 16px; font-size: 11px; color: var(--muted); }
.tl-hours span { position: absolute; transform: translateX(-50%); }
.tl-hours span:first-child { transform: none; }
.tl-hours span:last-child { transform: translateX(-100%); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.active { background: var(--green); } .sw.kept { background: var(--blue); } .sw.manual { background: var(--purple); }
.sw.idle { background: var(--amber); opacity: .55; } .sw.removed { background: var(--grey); } .sw.offline { background: var(--green); opacity: .6; }
.tick-sw { width: 2px; height: 10px; background: var(--ink); display: inline-block; }

/* Hour blocks */
.hours { display: flex; flex-direction: column; gap: 14px; }
.hour { display: grid; grid-template-columns: 52px 1fr; gap: 10px; }
.hlabel { font-weight: 600; font-variant-numeric: tabular-nums; padding-top: 4px; }
.blocks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.block { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.block.none .bt { color: var(--grey); }
.block.none::before { content: ""; display: block; aspect-ratio: 16 / 10; border-radius: 8px; background: var(--soft); opacity: .5; }
.thumb { position: relative; aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); padding: 0; width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { outline: 2px solid var(--ink); outline-offset: 1px; }
.thumb.empty { display: grid; place-items: center; font-size: 11.5px; color: var(--muted); cursor: default; }
.thumb.empty:hover { outline: 0; }
.more { position: absolute; right: 5px; bottom: 5px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.bt { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bm { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.bf { display: flex; gap: 4px; flex-wrap: wrap; min-height: 0; }

.adjust { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.narrow { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.narrow .logo { margin-bottom: 8px; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(10,10,12,.92); z-index: 50; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; }
.lightbox figure { margin: 0; max-width: calc(100% - 120px); max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 90px); border-radius: 6px; }
.lightbox figcaption { color: #ddd; font-size: 13px; text-align: center; }
.lightbox button { background: rgba(255,255,255,.1); color: #fff; font-size: 30px; width: 48px; height: 48px; border-radius: 50%; flex: none; }
.lightbox button:hover { background: rgba(255,255,255,.2); }
.lb-close { position: absolute; top: 14px; right: 14px; }

.dlg { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); padding: 20px; width: min(420px, calc(100% - 32px)); }
.dlg::backdrop { background: rgba(0,0,0,.4); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 9px; z-index: 60; font-size: 13.5px; max-width: calc(100% - 32px); }
.toast.bad { background: var(--red); color: #fff; }

@media (max-width: 860px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .blocks { grid-template-columns: repeat(3, 1fr); }
  .bar { gap: 12px; padding: 0 16px; }
  .me .muted, .dl { display: none; }
  main { padding: 16px; }
}
@media (max-width: 520px) {
  .hour { grid-template-columns: 1fr; }
  .blocks { grid-template-columns: repeat(2, 1fr); }
  .lightbox figure { max-width: 100%; }
  .lightbox .lb-prev, .lightbox .lb-next { position: absolute; bottom: 16px; }
  .lightbox .lb-prev { left: 16px; } .lightbox .lb-next { right: 16px; }
}
