:root {
  --bg: #eef3fb;
  --bg-deep: #dce5f2;
  --paper: rgba(255, 255, 255, 0.9);
  --panel: rgba(245, 249, 255, 0.82);
  --ink: #0f172a;
  --muted: #5f6d86;
  --line: rgba(148, 163, 184, 0.32);
  --line-strong: rgba(71, 85, 105, 0.18);
  --accent: #1565ff;
  --accent-deep: #0c46b5;
  --accent-soft: rgba(21, 101, 255, 0.12);
  --success: #0f9d74;
  --danger: #cb2f45;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.08);
  --radius-xl: 12px;
  --radius-lg: 9px;
  --radius-md: 6px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(21, 101, 255, 0.14), transparent 26%),
    radial-gradient(circle at 88% 8%, rgba(15, 157, 116, 0.12), transparent 22%),
    linear-gradient(180deg, #f5f8fd 0%, var(--bg) 42%, var(--bg-deep) 100%);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  min-height: 100vh;
}
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input {
  font: inherit;
}
select, textarea {
  font: inherit;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 0.8rem 1.2rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
button:hover { background: var(--accent-deep); }
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(21, 101, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(21, 101, 255, 0.1);
  background: #fff;
}
label span { display: block; margin-bottom: 0.4rem; font-size: 0.95rem; color: var(--muted); }
.page { width: min(1380px, calc(100vw - 2rem)); margin: 0 auto; padding: 1rem 0 3rem; }
.page.authed { padding-top: 0; }
.page > section + section { margin-top: 1.2rem; }
.shell-header {
  width: min(1380px, calc(100vw - 2rem));
  margin: 1rem auto 0;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 14px;
  background: rgba(247, 250, 255, 0.74);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1000;
}
.brand {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tagline { margin: 0.25rem 0 0; color: var(--muted); }
.shell-nav {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav-group {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.28rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.44);
}
.nav-group-admin {
  background: rgba(21, 101, 255, 0.05);
}
.nav-group-utility {
  background: rgba(15, 23, 42, 0.04);
}
.nav-dropdown {
  position: relative;
  z-index: 1100;
}
.nav-dropdown summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.68rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(21, 101, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  font-size: 0.94rem;
}
.nav-dropdown summary::-webkit-details-marker {
  display: none;
}
.nav-dropdown summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
}
.nav-dropdown[open] summary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}
.nav-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 220px;
  display: grid;
  gap: 0.2rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(247, 250, 255, 0.96);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  z-index: 1200;
}
.nav-dropdown-menu a {
  display: block;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  color: var(--muted);
}
.nav-dropdown-menu a:hover {
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}
.shell-nav a {
  padding: 0.45rem 0.65rem;
  border-radius: 7px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.94rem;
}
.shell-nav a:hover {
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}
.inline-actions {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}
.inline-actions form {
  margin: 0;
}
.small-button {
  padding: 0.42rem 0.72rem;
  border-radius: 7px;
  font-size: 0.82rem;
  line-height: 1;
}
.secondary-button {
  background: rgba(15, 23, 42, 0.08);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}
.secondary-button:hover {
  background: rgba(15, 23, 42, 0.14);
}
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.72rem;
  border-radius: 7px;
  text-decoration: none;
}
.compact-stack {
  margin-top: 1rem;
  gap: 0.8rem;
}
.ai-actions {
  margin-top: 0.9rem;
}
.nav-form {
  margin: 0;
}
.ghost-button {
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  border: 1px solid var(--line);
  padding-inline: 0.95rem;
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-panel, .panel, .camera-card, .wall-tile, .stat-card {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}
.login-panel {
  width: min(520px, 100%);
  padding: 2rem;
}
.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent-deep);
  font-size: 0.85rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
h1, h2 { margin: 0; font-weight: 700; }
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.03em; }
h2 { font-size: 1.25rem; }
.muted { color: var(--muted); }
.alert {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(203, 47, 69, 0.12);
  color: #881d31;
  border: 1px solid rgba(203, 47, 69, 0.14);
}
.success-banner {
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(15, 157, 116, 0.1);
  color: #0c6b50;
  border: 1px solid rgba(15, 157, 116, 0.16);
}
.stack { display: grid; gap: 1rem; margin-top: 1.5rem; }
.hero, .section-header { padding: 1.6rem 0 1rem; }
.stats-grid, .content-grid, .card-grid, .wall-grid, .detail-grid {
  display: grid;
  gap: 1rem;
}
.section-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
}
.ops-triage-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1.2fr 1fr;
}
.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  row-gap: 1.3rem;
}
.stat-card {
  padding: 1.2rem;
  min-height: 132px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -18% -35% auto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(21, 101, 255, 0.12), transparent 68%);
}
.stat-card span { display: block; color: var(--muted); margin-bottom: 0.4rem; }
.stat-card strong { font-size: 2rem; letter-spacing: -0.03em; }
.content-grid { grid-template-columns: 1.4fr 1fr 1fr; align-items: start; }
.panel { padding: 1.15rem; }
.triage-panel {
  position: relative;
  overflow: hidden;
}
.triage-panel-active::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, rgba(15, 157, 116, 0.9), rgba(21, 101, 255, 0.65));
}
.panel + .panel { margin-top: 0; }
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 1rem;
}
.camera-list, .media-list { display: grid; gap: 0.75rem; }
.triage-list {
  display: grid;
  gap: 0.75rem;
}
.camera-row, .media-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.82rem 0.9rem;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
}
.camera-row-active,
.camera-card-active,
.wall-tile-active {
  border-color: rgba(15, 157, 116, 0.24);
  box-shadow:
    var(--shadow-soft),
    0 0 0 1px rgba(15, 157, 116, 0.08);
}
.camera-row-active {
  background:
    linear-gradient(90deg, rgba(15, 157, 116, 0.08), rgba(15, 157, 116, 0.02)),
    var(--panel);
}
.media-row-rich {
  align-items: flex-start;
}
.triage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0.95rem;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
}
.triage-row-hot {
  background:
    linear-gradient(90deg, rgba(15, 157, 116, 0.1), rgba(21, 101, 255, 0.03)),
    var(--panel);
  border-color: rgba(15, 157, 116, 0.22);
}
.camera-row span, .media-row span { color: var(--muted); }
.triage-row span {
  color: var(--muted);
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.row-link {
  color: var(--muted);
  font-size: 0.9rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.85rem;
  font-weight: 500;
}
.pill-active {
  background: rgba(15, 157, 116, 0.14);
  color: var(--success);
}
.card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.camera-card { padding: 1.05rem; display: grid; gap: 0.8rem; }
.card-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.wall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wall-tile { padding: 0.95rem; }
.wall-grid-mosaic {
  gap: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(8, 12, 20, 0.9);
  box-shadow: var(--shadow-soft);
}
.wall-tile-mosaic {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #0b1220;
  box-shadow: none;
  backdrop-filter: none;
  position: relative;
}
.wall-tile-mosaic + .wall-tile-mosaic {
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}
.wall-tile-mosaic header {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 2;
  width: 100%;
  margin: 0;
  padding: 0.75rem 0.85rem;
  background: linear-gradient(180deg, rgba(3, 6, 12, 0.72), rgba(3, 6, 12, 0));
}
.wall-tile-mosaic .wall-links a,
.wall-tile-mosaic header strong,
.wall-tile-mosaic .wall-indicator {
  color: #f8fbff;
}
.wall-tile-mosaic .wall-links a {
  opacity: 0.88;
}
.wall-tile-mosaic .wall-links a:hover {
  color: #ffffff;
}
.wall-tile-mosaic.wall-tile-active {
  border-color: transparent;
  box-shadow: inset 0 0 0 2px rgba(15, 157, 116, 0.42);
}
.wall-tile-active {
  background:
    linear-gradient(180deg, rgba(15, 157, 116, 0.08), rgba(255, 255, 255, 0.9)),
    var(--paper);
}
.wall-tile header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.wall-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}
.wall-links a {
  color: var(--muted);
  font-size: 0.92rem;
}
.wall-links a:hover {
  color: var(--ink);
}
.wall-ops-summary {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}
.wall-ops-summary strong {
  font-size: 1.6rem;
  letter-spacing: -0.04em;
}
.wall-ops-summary span {
  color: var(--muted);
  font-size: 0.92rem;
}
.wall-ops-summary-active {
  border-color: rgba(15, 157, 116, 0.24);
  background: linear-gradient(180deg, rgba(15, 157, 116, 0.14), rgba(255, 255, 255, 0.82));
}
.auto-refresh-note {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.wall-indicator-active {
  color: var(--success);
  font-weight: 700;
}
.wall-tile iframe, .live-panel iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius-lg);
  background: #0b1220;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}
.wall-tile-mosaic iframe {
  border-radius: 0;
  display: block;
  box-shadow: none;
}
.detail-grid { grid-template-columns: 1.5fr 1fr; }
.admin-grid { grid-template-columns: 1.2fr 1fr; }
.live-panel { grid-row: span 2; }
.playback-player {
  display: grid;
  gap: 1rem;
}
.quick-range-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.quick-range-row a {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.92rem;
}
.quick-range-row a:hover {
  text-decoration: none;
  color: var(--ink);
  border-color: rgba(21, 101, 255, 0.24);
}
.playback-player video {
  width: 100%;
  border-radius: var(--radius-lg);
  background: #0b1220;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
}
.activity-strip {
  position: relative;
  min-height: 64px;
  margin-bottom: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.02) 0, rgba(15, 23, 42, 0.02) 1px, transparent 1px) 0 0 / 12.5% 100%,
    linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(241, 246, 255, 0.95));
  overflow: hidden;
}
.activity-strip::before {
  content: "Quiet";
  position: absolute;
  left: 0.9rem;
  top: 0.7rem;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.activity-segment {
  position: absolute;
  top: 2rem;
  height: 22px;
  min-width: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, rgba(21, 101, 255, 0.88), rgba(15, 157, 116, 0.84));
  box-shadow: 0 8px 20px rgba(21, 101, 255, 0.18);
}
.activity-strip-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}
.activity-table {
  margin-top: 0.3rem;
}
.form-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-wide { grid-column: 1 / -1; }
.checkbox-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.checkbox-row {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.72rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--line);
}
.checkbox-row input {
  width: auto;
}
.details { display: grid; gap: 0.8rem; margin: 0; }
.details div { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); }
.details dd { margin: 0; text-align: right; }
.details-compact dd {
  max-width: 70%;
  word-break: break-word;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.9rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.actions-cell {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.actions-cell form {
  margin: 0;
}
.inline-form {
  display: inline-flex;
  margin: 0;
}
.compact-form {
  margin-top: 0.65rem;
}
.table-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
}
.table-form-grid-compact {
  grid-template-columns: minmax(0, 1fr) auto;
}
.table-form-grid input,
.table-form-grid select {
  padding: 0.55rem 0.7rem;
  min-width: 0;
}
.danger-button {
  background: var(--danger);
}
.danger-button:hover {
  background: #a81f38;
}
.empty-state { color: var(--muted); margin: 0; padding: 0.8rem 0; }
.ops-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.ops-card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  min-height: 106px;
}
.ops-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ops-card strong {
  display: block;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}
.ops-card p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-healthy {
  background: rgba(15, 157, 116, 0.12);
  color: var(--success);
}
.status-warning {
  background: rgba(245, 158, 11, 0.14);
  color: #b96f00;
}
.status-error {
  background: rgba(203, 47, 69, 0.12);
  color: var(--danger);
}
.status-notes {
  display: grid;
  gap: 0.22rem;
  margin-top: 0.45rem;
}
.status-notes span {
  color: var(--muted);
  font-size: 0.88rem;
}
.ops-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
}
.ops-actions a {
  white-space: nowrap;
}
.notice-list {
  display: grid;
  gap: 0.8rem;
}
.notice-item {
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel);
}
.notice-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.18);
  color: #7a4b00;
}
.form-select {
  width: 100%;
}
.permissions-subject {
  display: grid;
  gap: 0.15rem;
}
.permissions-subject strong {
  font-size: 0.95rem;
}
.permissions-subject span {
  color: var(--muted);
  font-size: 0.9rem;
}
.secret-banner {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(21, 101, 255, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(21, 101, 255, 0.08);
}
.secret-banner strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1rem;
  word-break: break-all;
}
.secret-banner p {
  margin: 0.45rem 0 0;
  color: var(--muted);
}
@media (max-width: 980px) {
  .stats-grid, .content-grid, .card-grid, .wall-grid, .detail-grid, .ops-grid, .ops-triage-grid { grid-template-columns: 1fr; }
  .table-form-grid,
  .table-form-grid-compact {
    grid-template-columns: 1fr;
  }
  .wall-grid-mosaic {
    grid-template-columns: 1fr;
  }
  .wall-tile-mosaic + .wall-tile-mosaic {
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .shell-header {
    border-radius: 12px;
    align-items: flex-start;
  }
  .shell-nav {
    justify-content: flex-start;
  }
  .section-header {
    align-items: flex-start;
  }
  .nav-dropdown-menu {
    left: 0;
    right: auto;
  }
}
