:root {
    --bg: #101216;
    --panel: #181b21;
    --panel-2: #1f242c;
    --line: #2a3038;
    --text: #e6e8ec;
    --muted: #9aa3af;
    --accent: #4f9dff;
    --bad: #e0574c;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

header h1 {
    font-size: 16px;
    letter-spacing: .14em;
    text-transform: uppercase;
    margin: 0;
    font-weight: 600;
}

.spacer { flex: 1; }
.who { color: var(--muted); }

header nav {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

header nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 7px;
    font-size: 14px;
}
header nav a:hover { color: var(--text); background: var(--panel-2); }
header nav a.current { color: var(--text); background: var(--panel-2); }

.button {
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--line);
    background: var(--panel-2);
    border-radius: 7px;
    padding: 6px 12px;
    font-size: 13px;
}
.button:hover { border-color: var(--accent); }

/* ---------------------------------------------------------------- camera grid */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    padding: 12px;
}

.tile {
    margin: 0;
    background: #000;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.tile video {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: #000;
}

.tile figcaption {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 7px 10px;
    background: var(--panel);
    border-top: 1px solid var(--line);
    font-size: 13px;
}

.tile .label { font-weight: 600; }
.tile .meta { color: var(--muted); font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }

.overlay {
    position: absolute;
    inset: 0 0 34px 0;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.state {
    font-size: 13px;
    color: var(--muted);
    background: rgba(0, 0, 0, .6);
    padding: 5px 12px;
    border-radius: 999px;
}
.state:empty { display: none; }

.tile[data-state="error"] .state { color: var(--bad); }

/* clicking a tile blows it up; the others shrink out of the way */
body.has-focus .grid { grid-template-columns: 1fr; }
body.has-focus .tile:not(.focused) { display: none; }
body.has-focus .tile.focused video { aspect-ratio: auto; max-height: calc(100vh - 110px); }

.empty {
    color: var(--muted);
    padding: 24px;
    text-align: center;
}

/* ----------------------------------------------------------------- recordings */

.viewer {
    background: #000;
    border-bottom: 1px solid var(--line);
}

.viewer video {
    display: block;
    width: 100%;
    min-height: 240px;
    max-height: min(70vh, 720px);
    background: #000;
}

.viewer-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--panel);
    border-top: 1px solid var(--line);
    font-size: 14px;
}

.state-inline { color: var(--muted); font-size: 13px; }

.clock {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

.viewer-bar button.button { cursor: pointer; font-family: inherit; }

.recordings {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 12px;
    align-items: start;
}

.rec-camera {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px 14px;
}

.rec-camera h2 {
    margin: 0 0 10px;
    font-size: 15px;
}

.muted { color: var(--muted); font-size: 13px; margin: 0; }

ul.days {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 480px;
    overflow-y: auto;
}

ul.days button {
    width: 100%;
    display: flex;
    align-items: baseline;
    gap: 10px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
ul.days button:hover { border-color: var(--accent); }
ul.days .d { white-space: nowrap; }
ul.days .m { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

/* -------------------------------------------------------------------- sign in */

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.login {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 28px;
    width: min(340px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login h1 {
    margin: 0 0 6px;
    font-size: 18px;
    letter-spacing: .16em;
    text-transform: uppercase;
    text-align: center;
}

.login label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    color: var(--muted);
}

.login input {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    padding: 9px 11px;
    font-size: 15px;
}
.login input:focus { outline: none; border-color: var(--accent); }

.login button {
    margin-top: 4px;
    background: var(--accent);
    color: #06101d;
    border: 0;
    border-radius: 7px;
    padding: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.error {
    margin: 0;
    color: var(--bad);
    font-size: 13px;
    text-align: center;
}
