  html, body { height: 100%; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.18s ease, color 0.18s ease;
  }

  ::selection { background: var(--accent-soft); color: var(--accent); }

  /* ── Scrollbar ── */
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 8px;
    border: 2px solid var(--bg);
  }
  *::-webkit-scrollbar-thumb:hover { background: var(--muted); }

  /* ── Layout ── */
  .layout { display: flex; min-height: 100vh; }

  /* ── Sidebar (auto-collapses; expands on hover/focus) ── */
  .sidebar {
    width: 70px;
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 20;
    transition: width 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
  }
  .sidebar:hover,
  .sidebar:focus-within {
    width: 232px;
    box-shadow: var(--shadow-lg);
  }

  /* Collapsed state: hide text labels; center the visual elements. */
  .sidebar .logo-text,
  .sidebar .logo-sub,
  .sidebar .nav-item span,
  .sidebar .nav-label,
  .sidebar .agent-pill-text,
  .sidebar .agent-pill-sub { display: none; }
  .sidebar .logo { padding: 18px 0; text-align: center; }
  .sidebar .logo-mark { justify-content: center; }
  .sidebar .nav-item { justify-content: center; padding: 10px 0; }
  .sidebar .agent-pill { justify-content: center; padding: 9px; }

  /* Expanded state: restore text + left-aligned layout. */
  .sidebar:hover .logo-text,
  .sidebar:focus-within .logo-text,
  .sidebar:hover .logo-sub,
  .sidebar:focus-within .logo-sub,
  .sidebar:hover .nav-item span,
  .sidebar:focus-within .nav-item span,
  .sidebar:hover .nav-label,
  .sidebar:focus-within .nav-label,
  .sidebar:hover .agent-pill-text,
  .sidebar:focus-within .agent-pill-text,
  .sidebar:hover .agent-pill-sub,
  .sidebar:focus-within .agent-pill-sub { display: revert; }
  .sidebar:hover .logo,
  .sidebar:focus-within .logo { padding: 20px 18px 16px; text-align: left; }
  .sidebar:hover .logo-mark,
  .sidebar:focus-within .logo-mark { justify-content: flex-start; }
  .sidebar:hover .nav-item,
  .sidebar:focus-within .nav-item { justify-content: flex-start; padding: 8px 10px; }
  .sidebar:hover .agent-pill,
  .sidebar:focus-within .agent-pill { justify-content: flex-start; padding: 9px 11px; }

  .logo {
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
  }

  .logo-mark {
    display: flex;
    align-items: center;
    gap: 11px;
  }

  .logo-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(59,130,246,0.30);
  }

  .logo-icon svg { width: 18px; height: 18px; fill: white; }

  .logo-text {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text-strong);
  }

  .logo-sub {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin-top: 1px;
    font-weight: 500;
  }

  .nav { padding: 10px 0; flex: 1; overflow-y: auto; }

  .nav-section { padding: 0 12px; margin-bottom: 6px; }

  .nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--muted);
    padding: 12px 10px 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
  }
  .nav-label:hover { color: var(--text); }
  .nav-label .nav-chevron { width: 12px; height: 12px; transition: transform 0.15s; opacity: 0.5; }
  .nav-section.collapsed .nav-label .nav-chevron { transform: rotate(-90deg); }
  .nav-section.collapsed .nav-item { display: none; }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--muted-strong);
    cursor: pointer;
    transition: background-color 0.12s, color 0.12s;
    font-size: 13.5px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font);
  }

  .nav-item:hover { background: var(--surface-hover); color: var(--text-strong); }
  .nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .nav-item.active svg { color: var(--accent); }

  .nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.9; }

  .sidebar-bottom {
    padding: 12px;
    border-top: 1px solid var(--border);
  }

  .agent-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    background: var(--surface-alt);
    border-radius: 8px;
    border: 1px solid var(--border);
  }

  .agent-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--online);
    box-shadow: 0 0 0 3px var(--online-soft);
    flex-shrink: 0;
  }

  .agent-dot.offline {
    background: var(--offline);
    box-shadow: 0 0 0 3px var(--offline-soft);
  }

  .agent-pill-text { font-size: 12px; color: var(--text); flex: 1; min-width: 0; font-weight: 500; }
  .agent-pill-sub { font-size: 10.5px; color: var(--muted); font-weight: 400; margin-top: 1px; }

  /* ── Main ── */
  .main {
    margin-left: 70px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .topbar {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 14px;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
  }

  .topbar-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-strong);
    flex: 1;
    letter-spacing: -0.2px;
  }

  .topbar-time {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
  }

  .topbar-user {
    font-size: 12.5px;
    color: var(--muted-strong);
    font-weight: 500;
  }

  .icon-btn {
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted-strong);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.12s;
    flex-shrink: 0;
  }
  .icon-btn:hover { background: var(--surface-hover); color: var(--text-strong); border-color: var(--border-strong); }
  .icon-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
  .icon-btn svg { width: 16px; height: 16px; }

  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
  }
  .btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
  .btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
  .btn svg { width: 14px; height: 14px; }
  .btn:disabled,
  .btn[disabled] {
    opacity: 0.55;
    cursor: default;
    background: var(--surface-alt);
    color: var(--muted);
    border-color: var(--border);
  }
  .btn:disabled:hover,
  .btn[disabled]:hover {
    background: var(--surface-alt);
    border-color: var(--border);
  }

  .btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
  }
  .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

  .btn.danger {
    color: var(--offline);
    border-color: var(--border);
  }
  .btn.danger:hover { background: var(--offline-soft); border-color: var(--offline); }

  .btn.spinning svg { animation: spin 1s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }

  .content { padding: 24px 28px; }

  /* ── Stat strip ── */
  .stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }

  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    position: relative;
    box-shadow: var(--shadow-sm);
  }

  .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--muted);
    margin-bottom: 8px;
    font-weight: 600;
  }

  .stat-value {
    font-size: 26px;
    font-weight: 600;
    color: var(--text-strong);
    letter-spacing: -0.8px;
    line-height: 1;
    font-family: var(--font);
  }

  .stat-sub {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 6px;
  }

  .stat-icon {
    position: absolute;
    top: 16px; right: 16px;
    width: 28px; height: 28px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
  }
  .stat-icon svg { width: 14px; height: 14px; }
  .stat-icon.blue   { background: var(--accent-soft);  color: var(--accent); }
  .stat-icon.green  { background: var(--online-soft);  color: var(--online); }
  .stat-icon.red    { background: var(--offline-soft); color: var(--offline); }
  .stat-icon.purple { background: rgba(107,59,255,0.10); color: #6b3bff; }

  /* Clickable dashboard cards — reuse the camera-tile/device-card hover lift.
     Layered on top of .stat-card / .device-card.static so the resting look is
     unchanged; overrides the .device-card.static:hover no-lift rule when opted in. */
  .stat-card, .device-card.static { transition: transform .15s, box-shadow .15s, border-color .15s; }
  .dash-clickable { cursor: pointer; }
  .dash-clickable:hover,
  .device-card.static.dash-clickable:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
  }
  .dash-clickable:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  /* Chevron affordance in a clickable panel's header */
  .dash-card-chevron { color: var(--muted); font-size: 18px; line-height: 1; }

  /* ── Section ── */
  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
    flex-wrap: wrap;
  }

  .section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-strong);
    letter-spacing: -0.1px;
  }

  .section-actions { display: flex; align-items: center; gap: 10px; }

  .section-count {
    font-size: 11.5px;
    color: var(--muted-strong);
    background: var(--surface);
    padding: 3px 9px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-weight: 500;
  }

  /* ── Adoption section ── */
  .adoption-section {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
  }
  .adoption-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
  }
  .adoption-header:hover { background: var(--hover); }
  .adoption-chevron {
    width: 16px; height: 16px;
    transition: transform 0.15s;
    flex-shrink: 0;
  }
  .adoption-chevron.open { transform: rotate(90deg); }
  .adoption-title { font-weight: 600; font-size: 14px; }
  .adoption-seats { margin-left: auto; font-size: 12px; color: var(--muted); }
  .badge {
    background: var(--accent); color: #fff;
    font-size: 11px; font-weight: 600;
    padding: 2px 7px; border-radius: 10px;
  }
  .adoption-body { padding: 0 16px 16px; }
  .adoption-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px;
  }
  .adoption-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    gap: 12px;
  }
  .adoption-tile.adopting { opacity: 0.6; pointer-events: none; }
  .adoption-tile-model { font-size: 13px; font-weight: 500; }
  .adoption-tile-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }

  /* ── Camera grid (tile/thumbnail) ── */
  .camera-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 8px;
    margin-bottom: 28px;
  }

  .camera-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    position: relative;
    box-shadow: var(--shadow-sm);
  }

  .camera-tile:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
  }

  .camera-tile.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow);
  }

  .camera-thumb {
    aspect-ratio: 16 / 9;
    background: var(--thumb-bg);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .camera-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
  }

  /* Product image fallback: contain (not crop) on lighter backdrop */
  .camera-thumb img.camera-thumb-product {
    object-fit: contain;
    padding: 16px;
    background: radial-gradient(ellipse at center, #1a2030 0%, #0a0c10 100%);
  }

  .camera-thumb-placeholder {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 8px;
    color: rgba(255,255,255,0.35);
    text-align: center;
    padding: 16px;
  }
  .camera-thumb-placeholder svg { width: 28px; height: 28px; }
  .camera-thumb-placeholder span { font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase; font-weight: 500; }

  .camera-thumb-loading {
    position: absolute;
    inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(12,16,20,0.45);
  }

  .thumb-overlay-top {
    position: absolute;
    top: 0; right: 0;
    padding: 10px 12px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    pointer-events: none;
  }

  .thumb-overlay-bottom {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 26px 14px 12px;
    background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.35) 60%, rgba(0,0,0,0) 100%);
    pointer-events: none;
  }

  .thumb-name {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.1px;
  }

  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .status-pill.online {
    background: rgba(22,163,74,0.85);
    color: white;
  }
  .status-pill.offline {
    background: rgba(220,38,38,0.85);
    color: white;
  }
  .status-pill.warn {
    background: rgba(217,119,6,0.85);
    color: white;
  }
  .status-pill.setup {
    background: rgba(59,130,246,0.85);
    color: white;
  }
  /* Firmware below the verified-minimum major version. Distinct amber-brown so
     it reads apart from the orange auth `warn` pill. */
  .status-pill.fw-unsupported {
    background: rgba(168,85,12,0.9);
    color: white;
  }

  .status-pill.fw-updating {
    background: var(--accent);
    color: white;
  }
  .status-pill.fw-updating .spinner.micro {
    width: 9px; height: 9px;
    border-width: 1.5px;
    border-color: rgba(255,255,255,0.4);
    border-top-color: white;
  }

  .status-pill .status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
  }

  /* ── Devices table ── */
  .device-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
  }
  .device-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .device-table thead th {
    background: var(--surface-alt);
    font-weight: 600;
    color: var(--muted-strong);
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
  }
  .device-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .device-table tbody tr { cursor: pointer; transition: background-color 0.1s; }
  .device-table tbody tr:hover { background: var(--surface-hover); }
  .device-table tbody tr.selected { background: var(--accent-soft); }
  .device-table tbody tr:last-child td { border-bottom: none; }
  .device-table input[type="checkbox"] { cursor: pointer; width: 15px; height: 15px; accent-color: var(--accent); }

  .bulk-action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--accent);
  }

  /* ── Generic device card (non-camera) ── */
  .device-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; margin-bottom: 28px; }

  .device-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.12s;
    box-shadow: var(--shadow-sm);
  }
  .device-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
  .device-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
  .device-card.static { cursor: default; }
  .device-card.static:hover { box-shadow: var(--shadow-sm); }

  .device-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
  }

  .device-icon {
    width: 38px; height: 38px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: var(--accent-soft);
    color: var(--accent);
  }
  .device-icon svg { width: 18px; height: 18px; }
  .device-icon.purple { background: rgba(107,59,255,0.10); color: #6b3bff; }
  .device-icon.muted  { background: var(--surface-alt); color: var(--muted); border: 1px solid var(--border); }

  .device-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-strong);
    line-height: 1.3;
  }

  .device-ip {
    font-size: 11.5px;
    color: var(--muted);
    font-family: var(--mono);
    margin-top: 2px;
  }

  .device-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    flex-shrink: 0;
  }

  .status-text-inline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
  }
  .status-text-inline .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .status-text-inline.online  { background: var(--online-soft);  color: var(--online); }
  .status-text-inline.offline { background: var(--offline-soft); color: var(--offline); }
  .status-text-inline.warn    { background: var(--warn-soft);    color: var(--warn); }
  .status-text-inline.setup   { background: var(--setup-soft);   color: var(--setup); }

  .device-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .meta-key { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
  .meta-value { font-size: 12.5px; color: var(--text); font-family: var(--mono); margin-top: 2px; }

  /* ── Snapshot detail panel ── */
  .snapshot-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 8px;
    box-shadow: var(--shadow);
  }

  .snapshot-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }

  .snapshot-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-strong);
    flex: 1;
    min-width: 0;
  }

  .snapshot-sub {
    font-size: 12px;
    color: var(--muted);
    font-family: var(--mono);
    margin-left: 8px;
    font-weight: 500;
  }

  .snapshot-body {
    background: var(--thumb-bg);
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
  }

  .snapshot-body img { width: 100%; display: block; }

  .snapshot-placeholder {
    text-align: center;
    color: rgba(255,255,255,0.4);
    padding: 40px;
  }
  .snapshot-placeholder svg { width: 36px; height: 36px; margin-bottom: 10px; opacity: 0.7; }
  .snapshot-placeholder p { font-size: 13px; font-weight: 500; }
  .snapshot-placeholder small { font-size: 11px; opacity: 0.6; display: block; margin-top: 4px; }

  .snapshot-loading {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    color: rgba(255,255,255,0.5); font-size: 13px;
  }

  .snapshot-stamp {
    position: absolute;
    bottom: 10px; right: 12px;
    background: rgba(0,0,0,0.6);
    padding: 4px 9px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--mono);
    color: rgba(255,255,255,0.85);
  }

  /* Fullscreen toggle on snapshot/live panel */
  .fs-toggle {
    position: absolute;
    z-index: 3;
    top: 10px; right: 12px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .fs-toggle svg { width: 16px; height: 16px; }
  .cam-detail-video:hover .fs-toggle,
  .cam-detail-video:focus-within .fs-toggle { opacity: 1; }
  .fs-toggle:hover { background: rgba(0,0,0,0.8); }

  /* Native Fullscreen API styling */
  .cam-detail-video:fullscreen,
  .cam-detail-video:-webkit-full-screen {
    background: #000;
    width: 100vw;
    height: 100vh;
    max-width: none;
    border: none;
    border-radius: 0;
  }
  .cam-detail-video:fullscreen img,
  .cam-detail-video:fullscreen video,
  .cam-detail-video:-webkit-full-screen img,
  .cam-detail-video:-webkit-full-screen video {
    width: 100vw; height: 100vh;
    max-width: 100vw; max-height: 100vh;
    object-fit: contain;
  }
  .cam-detail-video:fullscreen .fs-toggle,
  .cam-detail-video:-webkit-full-screen .fs-toggle { opacity: 1; }

  /* Fallback for browsers that deny requestFullscreen() */
  .cam-detail-video.fs-fallback {
    position: fixed;
    inset: 0;
    z-index: 9999;
    width: 100vw; height: 100vh;
    max-width: none;
    margin: 0;
    background: #000;
    border: none;
    border-radius: 0;
  }
  .cam-detail-video.fs-fallback img,
  .cam-detail-video.fs-fallback video {
    width: 100vw; height: 100vh;
    max-width: 100vw; max-height: 100vh;
    object-fit: contain;
    margin: auto;
  }
  .cam-detail-video.fs-fallback .fs-toggle { opacity: 1; }

  .spinner {
    width: 22px; height: 22px;
    border: 2px solid rgba(255,255,255,0.15);
    border-top-color: rgba(255,255,255,0.7);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

  .spinner.light {
    border-color: var(--border);
    border-top-color: var(--accent);
  }

  /* ── Auth banner ── */
  .banner {
    background: var(--warn-soft);
    border: 1px solid var(--warn);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--warn);
    font-weight: 500;
  }
  .banner svg { width: 16px; height: 16px; flex-shrink: 0; }

  /* ── Empty / loading states ── */
  .empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
  }
  .empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: 0.4; }
  .empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-strong); margin-bottom: 6px; }
  .empty-state p { font-size: 13px; }

  /* Access control — door controllers + doors */
  .dc-list { display: flex; flex-direction: column; gap: 14px; }
  .dc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
  .dc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .dc-name { font-size: 14px; font-weight: 600; color: var(--text-strong); }
  .dc-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .dc-empty { padding: 16px; font-size: 13px; color: var(--muted); }
  .door-list { display: flex; flex-direction: column; }
  .door-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .door-row:last-child { border-bottom: none; }
  .door-name { font-size: 13.5px; font-weight: 500; color: var(--text-strong); }
  .door-meta { margin-top: 5px; display: flex; align-items: center; gap: 8px; }
  .door-phys { font-size: 12px; color: var(--muted); }
  .door-err { font-size: 12px; color: var(--offline); }

  /* ── Filter / search ── */
  .filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
  }

  .filter-btn {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted-strong);
    font-size: 12.5px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.12s;
  }
  .filter-btn:hover { border-color: var(--border-strong); color: var(--text-strong); }
  .filter-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
  }

  .search-input {
    flex: 1;
    max-width: 320px;
    padding: 7px 12px 7px 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 11px center;
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: all 0.12s;
  }
  .search-input:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
  .search-input::placeholder { color: var(--muted); }

  /* ── Form inputs ── */
  .input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 9px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    transition: all 0.12s;
  }
  .input:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }

  .form-group { margin-bottom: 14px; }
  .form-label {
    font-size: 11.5px;
    color: var(--muted-strong);
    margin-bottom: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: block;
  }

  .form-msg { font-size: 12px; margin-top: 6px; font-weight: 500; }
  .form-msg.error   { color: var(--offline); }
  .form-msg.success { color: var(--online); }

  /* ── Toast ── */
  /* Toasts stack in a fixed bottom-right column; newest nearest the corner. */
  #toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 100;
    display: flex; flex-direction: column-reverse; gap: 10px; align-items: flex-end;
    pointer-events: none;
    max-width: min(92vw, 400px);
  }
  .toast {
    pointer-events: auto;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    padding: 10px 10px 10px 15px;
    font-size: 13px;
    color: var(--text);
    display: flex; align-items: center; gap: 9px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.2s ease;
    font-weight: 500;
    max-width: 100%;
  }
  .toast.closing { animation: toastOut 0.16s ease forwards; }
  .toast .toast-msg { flex: 1; min-width: 0; }

  .toast.success { border-color: var(--online); }
  .toast.error   { border-color: var(--offline); }
  .toast.info    { border-color: var(--accent); }
  .toast svg { width: 15px; height: 15px; flex-shrink: 0; }

  .toast-action {
    background: none; border: none; cursor: pointer;
    color: var(--accent); font-weight: 600; font-size: 13px; font-family: var(--font);
    padding: 3px 7px; border-radius: 5px; flex-shrink: 0;
  }
  .toast-action:hover { background: var(--accent-soft); }
  .toast-close {
    background: none; border: none; cursor: pointer; color: var(--muted);
    display: flex; align-items: center; padding: 3px; border-radius: 5px; flex-shrink: 0;
  }
  .toast-close:hover { color: var(--text); background: var(--surface-hover); }
  .toast-close svg { width: 14px; height: 14px; }

  @keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  @keyframes toastOut { to { transform: translateY(6px); opacity: 0; } }

  /* ── User row ── */
  .user-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
  }

  .user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
  }

  .user-info { flex: 1; min-width: 0; }

  /* ── Responsive ── */
  @media (max-width: 720px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 18px; }
    .topbar { padding: 0 18px; }
    .topbar-user, .topbar-time { display: none; }
    .camera-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
    .filter-bar .search-input { flex: 1 1 100%; }
  }

  /* Phones: single-column grids, tighter chrome, edge-to-edge toasts. */
  @media (max-width: 520px) {
    .stats { grid-template-columns: 1fr; }
    .camera-grid { grid-template-columns: 1fr; }
    .content { padding: 14px; }
    .topbar { padding: 0 14px; }
    .filter-bar { gap: 6px; }
    #toast-container { left: 12px; right: 12px; bottom: 12px; align-items: stretch; max-width: none; }
  }

  /* ── Tile gear (top-right, on hover) ── */
  .thumb-gear {
    background: rgba(0,0,0,0.50);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    border-radius: 50%;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    color: white;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.15s, background 0.12s;
  }
  .thumb-gear svg { width: 13px; height: 13px; }
  .thumb-gear:hover { background: rgba(0,0,0,0.78); }
  .camera-tile:hover .thumb-gear,
  .camera-tile:focus-within .thumb-gear { opacity: 1; }
  @media (hover: none) { .thumb-gear { opacity: 1; } }

  .thumb-overlay-top .status-pill { pointer-events: none; }

  /* ── Settings drawer ── */
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,20,25,0.30);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }
  [data-theme="dark"] .drawer-backdrop { background: rgba(0,0,0,0.55); }
  .drawer-backdrop.open { opacity: 1; pointer-events: auto; }

  .drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 760px;
    max-width: 94vw;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 91;
    box-shadow: -16px 0 48px rgba(15,20,25,0.10);
    transform: translateX(100%);
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
  }
  [data-theme="dark"] .drawer { box-shadow: -16px 0 48px rgba(0,0,0,0.55); }
  .drawer.open { transform: translateX(0); }

  .drawer-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }

  .drawer-product-img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    flex-shrink: 0;
    background: radial-gradient(ellipse at center, #1a2030 0%, #0a0c10 100%);
    border-radius: 6px;
    padding: 4px;
  }

  .drawer-title { flex: 1; min-width: 0; }
  .drawer-name {
    font-size: 15.5px;
    font-weight: 600;
    color: var(--text-strong);
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .drawer-sub {
    font-size: 12px;
    color: var(--muted);
    font-family: var(--mono);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Settings page tabs — same visual language as drawer tabs */
  .settings-page { max-width: 100%; }
  .settings-content {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 24px;
  }
  .settings-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
  }
  .settings-tab {
    background: none;
    border: none;
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted);
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.12s, border-color 0.12s;
  }
  .settings-tab:hover { color: var(--text-strong); }
  .settings-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
  .settings-pane-narrow { max-width: 100%; }
  .settings-pane-wide   { max-width: 1200px; }

  .audit-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--mono);
    font-size: 11.5px;
  }
  .audit-table th,
  .audit-table td {
    padding: 7px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }
  .audit-table th {
    color: var(--muted-strong);
    font-weight: 600;
    background: var(--surface);
    position: sticky;
    top: 0;
  }
  .audit-table tbody tr:hover { background: var(--surface-hover); }
  .audit-table .audit-detail {
    max-width: 480px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
  }

  /* Two-pane drawer body: left nav tree + right content. Mirrors the
     layout of the Axis camera UI so users familiar with the camera's own
     menus feel at home. */
  .drawer-body-2col {
    flex: 1;
    display: flex;
    overflow: hidden;        /* children handle their own scroll */
  }
  .drawer-nav {
    width: 200px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 10px 0;
    background: var(--surface-alt);
  }
  .drawer-nav-group { margin-bottom: 2px; }
  .drawer-nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: none;
    border: none;
    padding: 8px 14px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-strong);
    cursor: pointer;
    text-align: left;
  }
  .drawer-nav-group-toggle:hover { background: var(--surface-hover); }
  .drawer-nav-group-toggle svg {
    width: 12px; height: 12px;
    transition: transform 0.12s;
    opacity: 0.55;
  }
  .drawer-nav-group.open .drawer-nav-group-toggle svg { transform: rotate(90deg); }
  .drawer-nav-children { display: none; }
  .drawer-nav-group.open .drawer-nav-children { display: block; }

  .drawer-nav-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    padding: 7px 14px 7px 30px;
    font-family: var(--font);
    font-size: 13px;
    color: var(--muted-strong);
    cursor: pointer;
    text-align: left;
    transition: color 0.1s, background-color 0.1s, border-color 0.1s;
  }
  .drawer-nav-item.top-level { padding-left: 14px; font-weight: 600; color: var(--text-strong); }
  .drawer-nav-item:hover { background: var(--surface-hover); color: var(--text-strong); }
  .drawer-nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-left-color: var(--accent);
  }

  .drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    min-width: 0;
  }

  /* Placeholder section for IA leaves that aren't built yet. */
  .drawer-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    padding: 40px 24px;
    color: var(--muted);
    text-align: center;
    background: var(--surface-alt);
    border: 1px dashed var(--border);
    border-radius: 8px;
  }
  .drawer-preview {
    position: relative;
    background: var(--surface-alt);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    aspect-ratio: 16/10;
  }
  .drawer-preview img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
  }
  .drawer-preview .preview-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
  }
  .drawer-preview-bar {
    display: flex; align-items: center; justify-content: flex-end;
    margin: -10px 0 12px;
  }
  .drawer-preview-bar button {
    background: none; border: none; color: var(--muted); cursor: pointer;
    font-size: 11px; font-family: var(--font); display: flex; align-items: center; gap: 4px;
    padding: 2px 6px; border-radius: 4px;
  }
  .drawer-preview-bar button:hover { color: var(--text); background: var(--surface-hover); }
  .drawer-placeholder svg { width: 38px; height: 38px; opacity: 0.4; margin-bottom: 12px; }
  .drawer-placeholder-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
  .drawer-placeholder-desc { font-size: 13px; max-width: 360px; }

  /* Legacy single-tab drawer body — kept until all forms migrate to the
     new two-col layout. New code uses .drawer-content above. */
  .drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
  }

  .drawer-section { margin-bottom: 24px; }
  .drawer-section:last-child { margin-bottom: 0; }

  .drawer-section-title {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 12px;
  }

  textarea.input {
    resize: vertical;
    min-height: 70px;
    font-family: var(--font);
    line-height: 1.5;
  }

  select.input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 32px;
    cursor: pointer;
  }

  /* ── Segmented control ── */
  .segmented {
    display: flex;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
  }
  .segmented input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
  .segmented label {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted-strong);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
    user-select: none;
  }
  .segmented label:hover { color: var(--text-strong); }
  .segmented input[type="radio"]:checked + label {
    background: var(--surface);
    color: var(--text-strong);
    box-shadow: var(--shadow-sm);
  }
  [data-theme="dark"] .segmented input[type="radio"]:checked + label {
    background: var(--accent-soft);
    color: var(--accent);
  }

  /* ── Toggle switch ── */
  .toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    padding: 4px 0;
  }
  .toggle {
    position: relative;
    display: inline-block;
    width: 38px; height: 22px;
    flex-shrink: 0;
  }
  .toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
  .toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 22px;
    transition: background 0.18s;
    cursor: pointer;
  }
  .toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px; width: 18px;
    left: 2px; top: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.18s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  }
  .toggle input:checked + .toggle-slider { background: var(--accent); }
  .toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
  .toggle input:focus-visible + .toggle-slider { box-shadow: var(--shadow-focus); }

  /* ── Slider row ── */
  .slider-row {
    display: grid;
    grid-template-columns: 100px 1fr 36px;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
  }
  .slider-row .form-label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); font-weight: 500; }
  .slider-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    outline: none;
  }
  .slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px; height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--surface);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  }
  .slider-row input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--surface);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  }
  .slider-row input[type="range"]:focus-visible { box-shadow: var(--shadow-focus); }
  .slider-value {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--muted-strong);
    text-align: right;
    font-weight: 500;
  }

  /* ── Form rows (2-up) ── */
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
  .form-row .form-group { margin-bottom: 0; }

  /* ── Tab loading / error shells ── */
  .tab-loading, .tab-error {
    text-align: center;
    padding: 50px 24px;
    color: var(--muted);
  }
  .tab-loading .spinner { margin: 0 auto 14px; }
  .tab-error h3 { font-size: 14px; font-weight: 600; color: var(--text-strong); margin-bottom: 6px; }
  .tab-error p  { font-size: 13px; max-width: 360px; margin: 0 auto 14px; }
  .tab-error code {
    font-family: var(--mono);
    font-size: 11.5px;
    background: var(--surface-alt);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--text);
  }

  /* Drawer save bar (sticky bottom) */
  .drawer-savebar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
    margin-top: 18px;
  }

  /* ── Overlay position picker (3x3 grid, 5 active spots) ── */
  .position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    aspect-ratio: 16 / 9;
    max-width: 240px;
  }
  .position-grid input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
  .position-grid label {
    border: 1px dashed transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s;
  }
  .position-grid label.active-slot:hover { background: var(--surface-hover); border-color: var(--border-strong); }
  .position-grid label.disabled-slot { cursor: default; opacity: 0.4; }
  .position-grid input[type="radio"]:checked + label {
    background: var(--accent);
    border-color: var(--accent);
  }
  .position-grid input[type="radio"]:checked + label::after {
    content: '';
    width: 7px; height: 7px;
    background: white;
    border-radius: 50%;
  }

  /* ── Variable chips ── */
  .var-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
  }
  .var-chip {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 4px 11px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--muted-strong);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.12s;
  }
  .var-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
  .var-chip code {
    font-family: var(--mono);
    font-size: 10.5px;
    opacity: 0.7;
    margin-left: 4px;
  }

  /* ── PTZ pad ── */
  .ptz-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    padding: 16px 0;
  }
  .ptz-pad {
    display: grid;
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 56px);
    gap: 4px;
  }
  .ptz-btn {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-strong);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .ptz-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
  .ptz-btn:active, .ptz-btn.pressed {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: scale(0.96);
  }
  .ptz-btn svg { width: 18px; height: 18px; }
  .ptz-btn.empty { background: transparent; border: none; cursor: default; pointer-events: none; }
  .ptz-zoom {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  .ptz-zoom .ptz-btn { width: 56px; height: 40px; border-radius: 8px; }
  .ptz-zoom-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    font-weight: 600;
    padding: 0 8px;
  }

  /* ── Preset list ── */
  .preset-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
  }
  .preset-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .preset-id { font-size: 11px; color: var(--muted); font-family: var(--mono); }

  /* Focus / iris button group */
  .lens-row { display: flex; gap: 6px; }
  .lens-row .btn { flex: 1; padding: 7px 8px; font-size: 12.5px; }

  /* Agent bundle bar (Agents view) */
  .bundle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .bundle-bar-info { min-width: 0; }
  .bundle-bar-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
  }
  .bundle-bar-value {
    font-size: 13.5px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .bundle-bar-value code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
  }
  .bundle-bar-actions { display: flex; gap: 8px; }
  .bundle-pill {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
  }
  .bundle-pill.ok   { background: var(--online-soft); color: var(--online); border-color: rgba(34,197,94,0.3); }
  .bundle-pill.warn { background: rgba(245,158,11,0.12); color: #b45309; border-color: rgba(245,158,11,0.35); }
  [data-theme="dark"] .bundle-pill.warn { color: #f59e0b; }

  /* Tour pulse indicator (running tour) */
  .tour-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    margin-right: 6px;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: tourPulse 1.6s infinite;
    vertical-align: middle;
  }
  @keyframes tourPulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
  }

  /* Privacy mask editor */
  .privacy-canvas-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
  }
  .privacy-snapshot {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    pointer-events: none;
  }
  .privacy-snapshot-missing {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
  }
  .privacy-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
  }

  /* Image-tab advanced section (dynamic per-camera params) */
  .adv-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-alt);
    margin-bottom: 8px;
    overflow: hidden;
  }
  .adv-group > summary {
    cursor: pointer;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
  }
  .adv-group > summary:hover { background: var(--surface-hover); }
  .adv-group[open] > summary { border-bottom: 1px solid var(--border); }
  .adv-count {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 999px;
  }
  .adv-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
  .adv-body .form-group { margin: 0; }
  .adv-body .slider-row { margin: 0; }

  /* Outer Advanced accordion in the Image tab */
  .advanced-image-section > summary::-webkit-details-marker { display: none; }
  .advanced-image-section[open] .adv-chevron { transform: rotate(90deg); }

  /* ── Camera detail page (dedicated route) ── */
  .cam-detail-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .cam-detail-title { flex: 1; min-width: 0; }
  .cam-detail-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cam-detail-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 3px;
    font-family: var(--mono);
  }

  /* Fixed 16:9 box — stays the same size whether it's showing the live video,
     a recording, the snapshot poster, or a placeholder, so swapping content
     never resizes or flashes the layout. */
  .cam-detail-video {
    /* Size driven by the stream's real dimensions (set by applyStreamAspect);
       defaults to 16:9 until the video reports its native resolution. A 4:3
       (or any) camera then sizes the box to match — no pillarboxing, and the
       overlay canvas maps 1:1 to the video. */
    --cam-arw: 16; --cam-arh: 9;
    position: relative;
    width: min(100%, calc(64vh * var(--cam-arw) / var(--cam-arh)));
    aspect-ratio: var(--cam-arw) / var(--cam-arh);
    margin: 0 auto;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
  }
  .cam-detail-video img,
  .cam-detail-video video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  /* Snapshot/last-frame underlay sits behind the <video>; the video fades in
     over it once frames arrive (onplaying → .live), so a (re)connecting stream
     shows the still frame instead of going black. */
  .cam-detail-poster { z-index: 0; }
  .cam-detail-video video { z-index: 1; opacity: 0; transition: opacity 0.22s ease; }
  .cam-detail-video video.live { opacity: 1; }
  .cam-loading {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; color: rgba(255,255,255,0.7); font-size: 13px;
    pointer-events: none; transition: opacity 0.22s ease;
  }
  .cam-detail-video video.live ~ .cam-loading { opacity: 0; }
  /* Analytics overlay — bounding boxes drawn over the live video. */
  .cam-overlay { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }
  /* Playback mode: a top bar with recording info + "Back to live". */
  .cam-playback-bar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 3;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), rgba(0,0,0,0));
    color: #fff; font-size: 12.5px;
  }
  .cam-playback-bar .cam-playback-badge { color: #ef4444; font-weight: 600; letter-spacing: 0.3px; }
  .cam-playback-bar .cam-playback-info { color: rgba(255,255,255,0.9); }
  .cam-playback-bar .btn { margin-left: auto; }
  /* Playback transport + scrubber (bottom bar). */
  .cam-pb-controls {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
    display: flex; align-items: center; gap: 8px;
    padding: 12px 12px 12px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), rgba(0,0,0,0));
    color: #fff;
  }
  .cam-pb-controls button {
    background: rgba(0,0,0,0.5); color: #fff;
    border: 1px solid rgba(255,255,255,0.2); border-radius: 5px;
    padding: 4px 8px; cursor: pointer; font-size: 11px; line-height: 1; white-space: nowrap;
  }
  .cam-pb-controls button:hover { background: rgba(0,0,0,0.85); }
  .cam-pb-scrub { flex: 1; height: 16px; display: flex; align-items: center; cursor: pointer; }
  .cam-pb-track { position: relative; width: 100%; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.28); }
  .cam-pb-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); }
  .cam-pb-knob { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); box-shadow: 0 1px 3px rgba(0,0,0,0.6); }
  .cam-pb-time { font-family: var(--mono); font-size: 11px; min-width: 104px; text-align: center; }
  .cam-pb-controls button svg { display: block; }
  .cam-pb-bigplay {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.25);
    color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.12s, transform 0.12s;
  }
  .cam-pb-bigplay svg { width: 30px; height: 30px; margin-left: 3px; }
  .cam-pb-bigplay:hover { background: rgba(0,0,0,0.8); transform: scale(1.05); }
  .cam-detail-placeholder {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px;
    color: rgba(255,255,255,0.55);
    background: var(--thumb-bg);
    font-size: 13px;
  }
  .cam-detail-placeholder svg { width: 36px; height: 36px; }

  .cam-audio-btn {
    position: absolute;
    z-index: 3;
    bottom: 14px; right: 14px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.12s, color 0.12s;
  }
  .cam-audio-btn:hover { background: rgba(0,0,0,0.78); }
  .cam-audio-btn svg { width: 18px; height: 18px; }
  .cam-audio-btn.audio-on { background: rgba(59,130,246,0.85); color: white; }
  .cam-audio-btn.audio-on:hover { background: rgba(59,130,246,1); }

  /* Quality picker — mirror of audio button, opposite corner */
  .cam-quality-overlay {
    position: absolute;
    bottom: 14px; left: 14px;
    z-index: 3;   /* above the video (z-index 1) so it stays clickable */
  }
  .cam-quality-select {
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: white;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 26px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='white' stroke-width='1.6'><path d='M1 1l5 5 5-5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 9px;
  }
  .cam-quality-select:hover { background-color: rgba(0,0,0,0.78); }
  .cam-quality-select option { background: #1a1a1a; color: white; }

  /* Generic centered modal */
  .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,20,25,0.45);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
  }
  [data-theme="dark"] .modal-backdrop { background: rgba(0,0,0,0.6); }
  .modal-backdrop.open { opacity: 1; pointer-events: auto; }

  .modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    width: 560px;
    max-width: 94vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    transform: translateY(8px);
    transition: transform 0.18s ease;
  }
  .modal-backdrop.open .modal { transform: translateY(0); }
  .modal-lg { width: 720px; }

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
  }
  .modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
  .modal-close {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
  }
  .modal-close:hover { background: var(--surface-hover); color: var(--text-strong); }

  .modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: 0 0 10px 10px;
  }

  /* Bulk-edit per-field "Apply" gate */
  .bulk-field {
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
  }
  .bulk-field:last-child { border-bottom: none; }
  .bulk-field > .bulk-field-toggle {
    cursor: pointer;
    width: 16px; height: 16px;
    accent-color: var(--accent);
  }
  .bulk-field > .bulk-field-body { min-width: 0; opacity: 0.4; transition: opacity 0.12s; }
  .bulk-field.active > .bulk-field-body { opacity: 1; }
  .bulk-field-body .form-group { margin: 0; }
  .bulk-field-body .slider-row { margin: 0; }

  /* Per-field reset-to-default icon button */
  .reset-btn {
    background: none;
    border: none;
    padding: 3px;
    margin: 0;
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.55;
    transition: opacity 0.12s, color 0.12s, background-color 0.12s;
    flex-shrink: 0;
  }
  .reset-btn:hover { opacity: 1; color: var(--accent); background: var(--surface-hover); }
  .reset-btn svg { width: 13px; height: 13px; }
  .slider-row .reset-btn { margin-left: 4px; }

  /* Row that pairs a label with the reset icon to its right */
  .field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
  }
  .field-label-row .form-label { margin: 0; }

  /* Danger card */
  .danger-card {
    background: var(--offline-soft);
    border: 1px solid rgba(220,38,38,0.25);
    border-radius: 10px;
    padding: 14px;
  }
  [data-theme="dark"] .danger-card { border-color: rgba(239,68,68,0.35); }
  .danger-card .form-label { color: var(--offline); }
  /* ── User Management page ── */
  .um-layout {
    display: flex;
    height: calc(100vh - 57px);
    overflow: hidden;
  }
  .um-list-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .um-layout.has-detail .um-list-panel {
    width: 380px;
    min-width: 320px;
    flex: 0 0 380px;
    border-right: 1px solid var(--border);
  }
  .um-list-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--surface);
  }
  .um-list-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .um-search {
    padding: 7px 12px;
    font-size: 12.5px;
    max-width: 280px;
  }
  .um-filters {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  .um-user-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
  }
  .um-user-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .um-user-table thead th {
    background: var(--surface-hover);
    padding: 9px 14px;
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
  }
  .um-user-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
  }
  .um-user-table tbody tr { cursor: pointer; transition: background-color 0.1s; }
  .um-user-table tbody tr:hover { background: var(--surface-hover); }
  .um-user-table tbody tr.selected { background: var(--accent-soft); }
  .um-user-table tbody tr:last-child td { border-bottom: none; }
  .um-user-table .um-user-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .um-user-table .user-avatar {
    width: 30px; height: 30px;
    font-size: 12px;
    flex-shrink: 0;
  }
  .um-user-item-role {
    font-size: 10.5px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted-strong);
    text-transform: capitalize;
    flex-shrink: 0;
  }
  .um-detail-panel {
    display: none;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
  }
  .um-layout.has-detail .um-detail-panel {
    display: flex;
    flex: 1;
  }
  .um-detail-header {
    padding: 20px 24px 0;
    border-bottom: 1px solid var(--border);
  }
  .um-detail-user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
  }
  .um-detail-avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    font-weight: 600;
    flex-shrink: 0;
  }
  .um-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
  }
  .um-layout.has-detail .um-search { max-width: none; width: 100%; }
  .um-credential-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .um-credential-icon {
    width: 36px; height: 36px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .um-credential-icon.card { background: rgba(59,130,246,0.12); color: #3b82f6; }
  .um-credential-icon.bluetooth { background: rgba(99,102,241,0.12); color: #6366f1; }
  .um-credential-icon.pin { background: rgba(245,158,11,0.12); color: #f59e0b; }
  .um-credential-info { flex: 1; min-width: 0; }
  .um-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .um-form-grid .form-group.full { grid-column: 1 / -1; }
  .um-perm-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
  }
  .um-perm-pill {
    font-size: 11px;
    font-family: var(--mono);
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--surface-hover);
    color: var(--muted-strong);
    border: 1px solid var(--border);
  }
  @media (max-width: 960px) {
    .um-layout.has-detail { flex-direction: column; }
    .um-layout.has-detail .um-list-panel { width: 100%; height: 280px; min-width: 0; flex: 0 0 280px; border-right: none; border-bottom: 1px solid var(--border); }
    .um-form-grid { grid-template-columns: 1fr; }
  }

  /* ── Recording timeline ── */
  .rec-timeline { position: relative; }
  .rec-timeline-track {
    display: flex;
    height: 28px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--surface-hover);
    border: 1px solid var(--border);
  }
  .rec-timeline-segment {
    flex: 1;
    border-right: 1px solid var(--border);
    position: relative;
    cursor: pointer;
    transition: background 0.1s;
  }
  .rec-timeline-segment:last-child { border-right: none; }
  .rec-timeline-segment:hover { background: rgba(59,130,246,0.12); }
  .rec-timeline-segment.continuous { background: var(--accent-soft); }
  .rec-timeline-segment.motion { background: rgba(245,158,11,0.2); }
  /* Absolutely-positioned recording blocks overlaid on the 24h track. */
  .rec-timeline-blocks { position: absolute; top: 0; left: 0; right: 0; height: 28px; pointer-events: none; }
  .rec-block {
    position: absolute; top: 3px; bottom: 3px; min-width: 2px;
    border-radius: 2px; pointer-events: auto; cursor: pointer; opacity: 0.9;
  }
  .rec-block.continuous { background: var(--accent); }
  .rec-block.motion { background: #f59e0b; }
  .rec-block:hover { opacity: 1; box-shadow: 0 0 0 1px var(--text-strong); }
  .rec-now-line { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--danger, #ef4444); }
  /* Detection-log filter chips */
  .rec-filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
  .rec-filter-chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); cursor: pointer; transition: background 0.12s, border-color 0.12s;
  }
  .rec-filter-chip:hover { background: var(--surface-hover); }
  .rec-filter-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
  /* Live overlay attribute filter */
  .live-filter-bar { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
  .live-filter-chips { display: inline-flex; gap: 6px; }
  .live-filter-q { flex: 1; min-width: 180px; font-size: 12.5px; padding: 5px 10px; }
  .live-det-count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
  .live-detections { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; min-height: 22px; }
  .live-det-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
    background: var(--surface-alt); border: 1px solid var(--border); color: var(--text);
  }
  .live-det-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
  .live-det-empty { font-size: 11.5px; color: var(--muted); }
  .rec-cap-bar { height: 8px; border-radius: 4px; background: var(--surface-hover); overflow: hidden; border: 1px solid var(--border); }
  .rec-cap-fill { height: 100%; background: var(--accent); }
  .rec-cap-fill.warn { background: #f59e0b; }
  .rec-cap-fill.full { background: var(--danger, #ef4444); }
  .rec-timeline-labels {
    display: flex;
    justify-content: space-between;
    padding: 4px 0 0;
    font-size: 10px;
    color: var(--muted);
    font-family: var(--mono);
  }

  /* ── Live Wall ── */
  .wall-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-wrap: wrap;
  }
  .wall-toolbar .separator {
    width: 1px;
    height: 24px;
    background: var(--border);
  }
  .wall-toolbar-label {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
  }
  .wall-layout-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-strong);
    margin-right: auto;
  }
  .wall-grid {
    display: grid;
    gap: 2px;
    height: calc(100vh - 57px - 53px);
    background: #000;
    padding: 2px;
  }
  .wall-tile {
    position: relative;
    background: #0a0a0a;
    overflow: hidden;
    border-radius: 4px;
  }
  .wall-tile video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    display: block;
  }
  .wall-tile-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    pointer-events: none;
  }
  .wall-tile-name {
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .wall-tile-status {
    position: absolute;
    top: 6px;
    right: 6px;
  }
  .wall-tile-remove {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    transition: background 0.15s;
  }
  .wall-tile:hover .wall-tile-remove { display: flex; }
  .wall-tile-remove:hover { background: rgba(220,38,38,0.8); }
  .wall-tile-empty {
    position: relative;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
  }
  .wall-tile-empty:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
  }
  .wall-tile-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--muted);
  }
  .wall-tile-add svg { opacity: 0.4; }
  .wall-tile-empty:hover .wall-tile-add { color: var(--accent); }
  .wall-tile-empty:hover .wall-tile-add svg { opacity: 0.8; }
  .wall-picker-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .wall-picker {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 420px;
    max-height: 520px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
  }
  .wall-picker-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }
  .wall-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
  }
  .wall-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
  }
  .wall-picker-item:hover { background: var(--surface-hover); }
  .wall-picker-item.offline { opacity: 0.4; }

  .seq-view-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
  .seq-view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .seq-view-title { font-size: 13px; font-weight: 600; color: var(--text-strong); }
  .seq-view-body { display: flex; gap: 20px; align-items: flex-start; }
  .seq-view-settings { display: flex; flex-direction: column; gap: 10px; flex: 1; }
  .seq-layout-btn { width: 44px; height: 33px; border-radius: 6px; border: 2px solid var(--border); background: var(--surface-alt); cursor: pointer; padding: 3px; display: grid; gap: 2px; }
  .seq-layout-btn.active { border-color: var(--accent); background: rgba(60,133,251,0.08); }
  .seq-layout-btn div { background: var(--text); border-radius: 1px; opacity: 0.25; }
  .seq-layout-btn.active div { background: var(--accent); opacity: 0.5; }
  .seq-grid { display: grid; gap: 3px; aspect-ratio: 16/9; max-width: 340px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px; }
  .seq-grid select { width: 100%; font-size: 11px; padding: 3px 4px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 4px; color: var(--text); }
  .seq-pane { position: relative; overflow: hidden; border-radius: 4px; background: var(--surface-alt); display: flex; flex-direction: column; justify-content: flex-end; min-height: 40px; }
  .seq-pane-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .seq-pane-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted); text-align: center; padding: 2px; }
  .seq-pane .seq-pane-select { position: relative; z-index: 1; border: none; border-radius: 0; }
  .seq-pane.assigned .seq-pane-select { background: rgba(0,0,0,0.55); color: #fff; }
  .seq-remove-btn { padding: 3px 10px; border-radius: 5px; border: 1px solid rgba(239,68,68,0.3); background: rgba(239,68,68,0.06); color: var(--offline); font-size: 11px; cursor: pointer; }
  .seq-remove-btn:hover { background: rgba(239,68,68,0.14); }

  /* ── Command palette (⌘K) ── */
  .cmdk-trigger {
    display: flex; align-items: center; gap: 8px;
    height: 34px; padding: 0 10px 0 11px;
    background: var(--surface-alt); border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer;
    color: var(--muted); font-family: var(--font); font-size: 13px;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
  }
  .cmdk-trigger:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-hover); }
  .cmdk-trigger svg { width: 15px; height: 15px; }
  .cmdk-trigger span { margin-right: 6px; }
  .cmdk-trigger kbd {
    font-family: var(--mono); font-size: 10.5px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 4px; padding: 1px 5px; color: var(--muted-strong);
  }
  @media (max-width: 720px) { .cmdk-trigger span, .cmdk-trigger kbd { display: none; } }
  .cmdk-backdrop {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(15,20,25,0.45);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 14vh;
    opacity: 0; pointer-events: none;
    transition: opacity 0.12s ease;
  }
  [data-theme="dark"] .cmdk-backdrop { background: rgba(0,0,0,0.6); }
  .cmdk-backdrop.open { opacity: 1; pointer-events: auto; }
  .cmdk {
    width: 600px; max-width: 92vw; max-height: 60vh;
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: translateY(-8px) scale(0.99);
    transition: transform 0.14s ease;
  }
  .cmdk-backdrop.open .cmdk { transform: translateY(0) scale(1); }
  .cmdk-input-wrap {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .cmdk-input-wrap svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
  .cmdk-input-wrap input {
    flex: 1; border: none; outline: none; background: transparent;
    color: var(--text); font-family: var(--font); font-size: 15px;
  }
  .cmdk-input-wrap input::placeholder { color: var(--muted); }
  .cmdk-list { overflow-y: auto; padding: 6px; }
  .cmdk-group {
    font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
    color: var(--muted); padding: 10px 12px 4px;
  }
  .cmdk-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: 8px; cursor: pointer;
    color: var(--text); user-select: none;
  }
  .cmdk-item svg { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
  .cmdk-item .cmdk-label { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cmdk-item .cmdk-hint { font-size: 12px; color: var(--muted); font-family: var(--mono); flex-shrink: 0; }
  .cmdk-item.active { background: var(--accent-soft); }
  .cmdk-item.active, .cmdk-item.active svg, .cmdk-item.active .cmdk-hint { color: var(--accent); }
  .cmdk-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 13px; }
  .cmdk-footer {
    display: flex; gap: 14px; align-items: center;
    padding: 9px 14px; border-top: 1px solid var(--border);
    font-size: 11px; color: var(--muted);
  }
  .cmdk-footer kbd {
    font-family: var(--mono); font-size: 10.5px;
    background: var(--surface-alt); border: 1px solid var(--border);
    border-radius: 4px; padding: 1px 5px; color: var(--muted-strong);
  }

  /* ── Skeleton loaders ── */
  @keyframes sk-shimmer { to { background-position: -200% 0; } }
  .skeleton {
    background: linear-gradient(90deg, var(--surface-alt) 25%, var(--surface-hover) 37%, var(--surface-alt) 63%);
    background-size: 200% 100%;
    animation: sk-shimmer 1.3s linear infinite;
    border-radius: 6px;
    display: block;
  }
  .sk-line { height: 11px; }
  .sk-tile { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; }
  .sk-userrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
  .sk-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
  @media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

  /* ── Accessibility: focus rings + reduced motion ── */
  /* Baseline keyboard-focus ring for any interactive element that doesn't
     define its own. Buttons/inputs/icon-btns already set outline:none +
     box-shadow via more-specific :focus-visible rules, so they're unaffected. */
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .nav-item:focus-visible, .filter-btn:focus-visible,
  .cmdk-item:focus-visible, .tab:focus-visible { outline-offset: -2px; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
    /* Progress spinners stay animated — the motion is essential feedback. */
    .spinner, .btn.spinning svg { animation-duration: 0.8s !important; animation-iteration-count: infinite !important; }
  }
