:root,
[data-theme="dark"] {
  --nvr-shell-bg: var(--bg-deep);
  --nvr-shell-base: var(--bg-base);
  --nvr-shell-surface: var(--bg-surface);
  --nvr-shell-elevated: var(--bg-elevated);
  --nvr-shell-hover: var(--bg-hover);
  --nvr-shell-border: var(--border-default);
  --nvr-shell-border-strong: var(--border-strong);
  --nvr-shell-accent: var(--accent);
  --nvr-shell-accent-light: var(--accent-light);
  --nvr-shell-accent-dim: var(--accent-dim);
  --nvr-shell-success: var(--green);
  --nvr-shell-danger: var(--red);
  --nvr-shell-warning: var(--amber);
  --nvr-shell-info: var(--blue);
  --nvr-shell-text: var(--text-primary);
  --nvr-shell-secondary: var(--text-secondary);
  --nvr-shell-muted: var(--text-muted);
  --nvr-shell-inverse: var(--text-inverse);
}

[data-theme="light"] {
  --nvr-shell-bg: #f4f0ea;
  --nvr-shell-base: #faf8f3;
  --nvr-shell-surface: #ffffff;
  --nvr-shell-elevated: #f3eee7;
  --nvr-shell-hover: #ebe3d7;
  --nvr-shell-border: rgba(36, 31, 25, 0.12);
  --nvr-shell-border-strong: rgba(36, 31, 25, 0.18);
  --nvr-shell-accent: #a56638;
  --nvr-shell-accent-light: #b87746;
  --nvr-shell-accent-dim: rgba(165, 102, 56, 0.12);
  --nvr-shell-success: #2c8f5b;
  --nvr-shell-danger: #c44b39;
  --nvr-shell-warning: #bf7b18;
  --nvr-shell-info: #2e69c7;
  --nvr-shell-text: #241f19;
  --nvr-shell-secondary: #645b53;
  --nvr-shell-muted: #8b8178;
  --nvr-shell-inverse: #fff;
}

.nvr-app {
  position: relative;
  isolation: isolate;
  background: transparent;
  color: var(--nvr-shell-text);
  font-family: var(--font-body);
}

.nvr-app::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background: var(--portal-backdrop-image) var(--portal-app-backdrop-position) / var(--portal-app-backdrop-size) no-repeat;
  opacity: var(--portal-app-backdrop-opacity);
  filter: var(--portal-backdrop-filter);
  transform: scale(1.04);
  transform-origin: center center;
}

.nvr-sidebar,
.nvr-topbar {
  background: var(--nvr-shell-base);
  border-color: var(--nvr-shell-border);
}

.nvr-sidebar {
  width: 280px;
}

.nvr-sidebar-header {
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--nvr-shell-border);
  box-shadow: none;
}

.nvr-sidebar-header::before,
.nvr-sidebar-header::after,
.nvr-view-container::before,
.nvr-view-container::after,
.nvr-stat-card::before,
.nvr-stat-card::after {
  content: none;
}

.nvr-logo {
  gap: var(--space-sm);
}

.nvr-logo-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
}

.nvr-logo-text {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--nvr-shell-text);
}

.nvr-logo-subtitle {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nvr-shell-secondary);
}

.nvr-sidebar-section-label,
.nvr-category-header,
.nvr-section-header,
.nvr-tl-events-section-header {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nvr-shell-muted);
}

.nvr-sidebar-section-label {
  padding: 8px var(--space-md) 4px;
}

.nvr-sidebar-nav {
  padding: 0 0 6px;
}

.nvr-nav-item {
  gap: 8px;
  padding: 7px var(--space-md) 7px 20px;
  border-left: 2px solid transparent;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--nvr-shell-secondary);
}

.nvr-nav-item:hover {
  background: var(--nvr-shell-hover);
  color: var(--nvr-shell-text);
}

.nvr-nav-item.active {
  background: var(--nvr-shell-accent-dim);
  border-left-color: var(--nvr-shell-accent);
  color: var(--nvr-shell-accent-light);
  box-shadow: none;
}

.nvr-nav-item.active svg {
  color: currentColor;
}

.nvr-badge,
.nvr-archive-badge,
.nvr-card-live-badge {
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nvr-badge {
  background: rgba(74, 222, 128, 0.12);
  color: var(--nvr-shell-success);
  min-width: 18px;
}

.nvr-device-filter-wrap {
  padding: 0 var(--space-md) var(--space-sm);
  gap: 6px;
}

.nvr-device-filter,
.nvr-archive-input,
.nvr-mv-sync-select,
.nvr-oc-inline-controls .nvr-input,
.nvr-oc-inline-controls .nvr-select {
  background: var(--nvr-shell-elevated);
  border: 1px solid var(--nvr-shell-border);
  border-radius: var(--radius-sm);
  color: var(--nvr-shell-text);
  font-family: var(--font-body);
  font-size: 0.78rem;
}

.nvr-device-filter {
  padding: 9px 12px;
}

.nvr-device-filter:focus,
.nvr-archive-input:focus,
.nvr-mv-sync-select:focus,
.nvr-oc-inline-controls .nvr-input:focus,
.nvr-oc-inline-controls .nvr-select:focus {
  outline: none;
  border-color: var(--nvr-shell-accent);
  box-shadow: 0 0 0 2px var(--nvr-shell-accent-dim);
}

.nvr-btn-reset-order {
  border-radius: var(--radius-sm);
  color: var(--nvr-shell-muted);
  font-size: 1rem;
}

.nvr-device-list {
  padding: 0 var(--space-md) var(--space-md);
}

.nvr-device-item {
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
}

.nvr-device-item:hover {
  background: var(--nvr-shell-hover);
}

.nvr-device-item.selected {
  background: var(--nvr-shell-elevated);
}

.nvr-device-label,
.nvr-device-count,
.nvr-category-count,
.nvr-device-list-empty {
  color: var(--nvr-shell-muted);
  font-size: 0.72rem;
}

.nvr-sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--nvr-shell-border);
}

.nvr-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--nvr-shell-accent-dim);
  color: var(--nvr-shell-accent);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
}

.nvr-user-name {
  font-size: 0.78rem;
  color: var(--nvr-shell-text);
}

.nvr-btn-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--nvr-shell-muted);
}

.nvr-btn-icon:hover {
  background: var(--nvr-shell-hover);
  color: var(--nvr-shell-text);
}

.nvr-main {
  background: transparent;
}

.nvr-topbar {
  height: auto;
  min-height: 57px;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
}

.nvr-topbar-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--nvr-shell-text);
}

.nvr-topbar-status {
  gap: 12px;
  margin-left: auto;
}

.nvr-status-indicator,
.nvr-clock {
  font-size: 0.72rem;
  color: var(--nvr-shell-secondary);
}

.nvr-clock,
.nvr-card-duration,
.nvr-device-count,
.nvr-category-count,
.nvr-stat-value,
.nvr-archive-entry-filename {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.nvr-view-container {
  padding: var(--space-lg);
  background: transparent;
}

.nvr-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-md);
}

.nvr-overview-grid {
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.nvr-stat-card,
.nvr-oc-card,
.nvr-device-card,
.nvr-archive-card,
.nvr-archive-device-group,
.nvr-legal-card,
.nvr-face-card,
.nvr-face-group-card,
.nvr-card,
.nvr-tl-redact-panel,
.nvr-mv-sync-controls {
  background: var(--nvr-shell-surface);
  border: 1px solid var(--nvr-shell-border);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.nvr-stat-card,
.nvr-archive-card,
.nvr-legal-card {
  padding: 16px 20px;
}

.nvr-device-card:hover,
.nvr-archive-card:hover,
.nvr-legal-card:hover,
.nvr-face-card:hover,
.nvr-face-group-card:hover,
.nvr-card:hover,
.nvr-oc-card:hover {
  border-color: var(--nvr-shell-border-strong);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

[data-theme="light"] .nvr-device-card:hover,
[data-theme="light"] .nvr-archive-card:hover,
[data-theme="light"] .nvr-legal-card:hover,
[data-theme="light"] .nvr-face-card:hover,
[data-theme="light"] .nvr-face-group-card:hover,
[data-theme="light"] .nvr-card:hover,
[data-theme="light"] .nvr-oc-card:hover {
  box-shadow: 0 10px 20px rgba(36, 31, 25, 0.08);
}

.nvr-stat-label {
  margin-bottom: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nvr-shell-muted);
}

.nvr-stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  line-height: 1.08;
  color: var(--nvr-shell-text);
}

.nvr-stat-unit {
  font-size: 0.8rem;
  color: var(--nvr-shell-secondary);
}

.nvr-card-body,
.nvr-face-info {
  padding: 12px 14px;
}

.nvr-card-title,
.nvr-archive-title,
.nvr-legal-title,
.nvr-oc-card-header h3 {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--nvr-shell-text);
}

.nvr-card-device-id,
.nvr-card-meta,
.nvr-archive-desc,
.nvr-archive-meta,
.nvr-archive-entry,
.nvr-archive-entry-time,
.nvr-legal-meta,
.nvr-face-time,
.nvr-face-conf,
.nvr-oc-subtitle,
.nvr-oc-window,
.nvr-status-indicator,
.nvr-report-header,
.nvr-report-header p {
  font-size: 0.76rem;
  color: var(--nvr-shell-secondary);
}

.nvr-face-device {
  font-size: 0.82rem;
  color: var(--nvr-shell-text);
}

.nvr-card-thumb-placeholder,
.nvr-card-thumb-placeholder svg {
  color: var(--nvr-shell-muted);
}

.nvr-card-live-badge {
  padding: 3px 9px;
  background: rgba(74, 222, 128, 0.14);
  color: var(--nvr-shell-success);
}

.nvr-card-duration {
  font-size: 0.66rem;
  background: rgba(8, 9, 14, 0.75);
  color: #fff;
}

.nvr-archive-device-header,
.nvr-archive-player-header {
  background: var(--nvr-shell-elevated);
  border-color: var(--nvr-shell-border);
  color: var(--nvr-shell-text);
  font-size: 0.82rem;
}

.nvr-archive-entry {
  padding: 8px 14px;
  border-bottom-color: var(--nvr-shell-border);
}

.nvr-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.2;
  border: 1px solid transparent;
}

.nvr-btn-primary {
  background: var(--nvr-shell-accent);
  border-color: var(--nvr-shell-accent);
  color: var(--nvr-shell-inverse);
}

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

.nvr-btn-secondary {
  background: var(--nvr-shell-elevated);
  border-color: var(--nvr-shell-border-strong);
  color: var(--nvr-shell-text);
}

.nvr-btn-secondary:hover {
  background: var(--nvr-shell-hover);
  border-color: var(--nvr-shell-accent);
}

.nvr-btn-ghost {
  background: transparent;
  color: var(--nvr-shell-secondary);
}

.nvr-btn-ghost:hover {
  background: var(--nvr-shell-hover);
  color: var(--nvr-shell-text);
}

.nvr-btn-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.28);
  color: var(--nvr-shell-danger);
}

.nvr-btn-warning {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.28);
  color: var(--nvr-shell-warning);
}

.nvr-btn-success {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.28);
  color: var(--nvr-shell-success);
}

.nvr-toast-container .toast,
.nvr-report-header {
  color: var(--nvr-shell-text);
}

@media (max-width: 1024px) {
  .nvr-view-container {
    padding: var(--space-md);
  }
}
