/* Module: Admin dashboard theme. Purpose: Implement the Docs/UI-Sample.html light/dark SaaS layout for Woodcock Vision management and player generator without external dependencies. */

:root {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-border: rgba(37, 99, 235, 0.25);

  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.12);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.12);
  --rose: #ef4444;
  --rose-soft: rgba(239, 68, 68, 0.12);
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.12);

  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-hover: #f1f5f9;
  --bg-sidebar: #ffffff;
  --bg-modal: #ffffff;
  --bg-input: #ffffff;

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);

  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --transition-fast: 150ms ease;
  --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-surface: #111827;
  --bg-subtle: #1e293b;
  --bg-hover: #1f2937;
  --bg-sidebar: #0f172a;
  --bg-modal: #111827;
  --bg-input: #0f172a;

  --border-color: #1e293b;
  --border-strong: #334155;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-soft: rgba(37, 99, 235, 0.2);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html, body {
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

.small { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-emerald { color: var(--emerald); }
.text-amber { color: var(--amber); }
.text-rose { color: var(--rose); }
.text-accent { color: var(--accent); }
.fw-600 { font-weight: 600; }
.mb-6 { margin-bottom: 6px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   LOGIN SHELL
   ========================================================================== */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.login-card > p {
  margin-bottom: 18px;
  font-size: 13px;
}

.login-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   APP SHELL (SIDEBAR + HEADER + MAIN)
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width var(--transition-base), transform var(--transition-base);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  height: var(--header-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.brand-text {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-text span {
  color: var(--accent);
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-footer-info {
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.nav-section-gap {
  margin-top: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-version {
  font-size: 12px;
  font-weight: 600;
}

.sidebar-sub {
  font-size: 11px;
}

.sidebar-collapse-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-base);
}

.sidebar-collapse-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 35;
  backdrop-filter: blur(2px);
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left var(--transition-base);
}

.sidebar.collapsed ~ .main-wrapper {
  margin-left: var(--sidebar-collapsed);
}

/* Sticky Top Header */
.top-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 30;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.mobile-menu-btn:hover {
  background: var(--bg-hover);
}

.global-search {
  position: relative;
  width: 100%;
  max-width: 340px;
}

.global-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.global-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.global-search input:focus {
  border-color: var(--accent);
  background: var(--bg-input);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--emerald-soft);
  color: var(--emerald);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.health-pill.muted-pill {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.health-pill.muted-pill .pulse-dot {
  background: var(--text-muted);
  animation: none;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}

.profile-btn:hover {
  background: var(--bg-hover);
}

.profile-name {
  font-size: 13px;
  font-weight: 500;
}

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

/* Dropdowns */
.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}

.dropdown-menu.open {
  display: flex;
}

.dropdown-menu.sm {
  width: 210px;
}

.dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 13px;
}

.dropdown-item {
  padding: 10px 14px;
  display: block;
  width: 100%;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  font-size: 13px;
  transition: background var(--transition-fast);
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

/* ==========================================================================
   MAIN CONTENT & SHARED COMPONENTS
   ========================================================================== */
.main-content {
  padding: 24px;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.section-view {
  animation: fadeIn 180ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-title p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

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

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--rose-soft);
  color: var(--rose);
}

.btn-danger:hover {
  background: var(--rose);
  color: #fff;
}

.btn-ghost {
  color: var(--text-secondary);
  padding: 6px 8px;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* Cards & Grids */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* KPI Stat Cards */
.kpi-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-blue { background: var(--accent-soft); color: var(--accent); }
.kpi-icon-emerald { background: var(--emerald-soft); color: var(--emerald); }
.kpi-icon-purple { background: var(--purple-soft); color: var(--purple); }
.kpi-icon-amber { background: var(--amber-soft); color: var(--amber); }

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-meta {
  font-size: 12px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-emerald { background: var(--emerald-soft); color: var(--emerald); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-rose { background: var(--rose-soft); color: var(--rose); }
.badge-blue { background: var(--accent-soft); color: var(--accent); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-neutral { background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border-color); }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  font-size: 13.5px;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-hover);
}

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

/* Toolbar, Forms & Inputs */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
}

.toolbar-search {
  flex: 1;
  min-width: 220px;
}

.input, .select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  font-size: 13px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.select {
  width: auto;
  min-width: 150px;
}

.form-group .select {
  width: 100%;
}

.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.input {
  resize: vertical;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-label {
  white-space: nowrap;
}

.actions-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Toggle Switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.switch-compact {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
}

.slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition-fast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

/* Key Box, Info Box, Banners & Feature Chips */
.key-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.secret-banner {
  border-color: var(--accent-border);
}

.secret-code {
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  overflow-wrap: anywhere;
  font-size: 13px;
}

.feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.security-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.success, .error {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
}

.success {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.error {
  background: var(--rose-soft);
  color: var(--rose);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ==========================================================================
   MODALS & VIDEO PREVIEW
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 180ms ease;
}

.modal.modal-lg {
  max-width: 700px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-subtle);
}

.modal-actions-inline {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.feed-security {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

.preview-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-stage {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #020617;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.preview-stage video {
  width: 100%;
  height: 100%;
  display: block;
  background: #020617;
}

.preview-controls {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ==========================================================================
   PLAYER GENERATOR
   ========================================================================== */
.generator-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.generator-options,
.generator-preview {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.generator-options form {
  display: grid;
  gap: 16px;
}

.generator-preview {
  position: sticky;
  top: calc(var(--header-height) + 18px);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.type-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.type-card:hover {
  border-color: var(--border-strong);
}

.type-card[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent);
}

.type-card strong {
  font-size: 11px;
  display: block;
  margin-top: 6px;
}

.type-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1.9;
  border-radius: 4px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  color: #93c5fd;
  font-size: 14px;
  position: relative;
  overflow: hidden;
}

.type-mini::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 6px;
  right: 6px;
  height: 2px;
  background: var(--accent);
}

.mini-cinema { border-top: 6px solid #020617; border-bottom: 6px solid #020617; }
.mini-minimal::after { left: 25%; right: 25%; height: 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.25); }
.mini-broadcast::before { content: "LIVE"; position: absolute; top: 4px; left: 4px; font-size: 6px; background: var(--rose); color: #fff; padding: 1px 3px; border-radius: 2px; }
.mini-sports { background: linear-gradient(150deg, #0f766e, #0f172a); }
.mini-portrait { margin: auto; width: 42%; aspect-ratio: 0.65; }
.mini-floating::after { height: 10px; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 4px; background: rgba(255, 255, 255, 0.14); }

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.color-input {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
}

.range-input {
  width: 100%;
  accent-color: var(--accent);
}

.file-input {
  padding: 6px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

.toggle-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.toggle-grid input {
  accent-color: var(--accent);
}

.apply-button {
  position: sticky;
  bottom: 16px;
  padding: 12px;
  box-shadow: var(--shadow-md);
}

.frame-wrap {
  border-radius: var(--radius-md);
  background: #020617;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  max-width: 100%;
  border: 1px solid var(--border-color);
}

.frame-wrap iframe {
  border: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.frame-wrap.portrait {
  max-width: 300px;
  margin: 0 auto;
}

.file-trigger {
  cursor: pointer;
}

.details-box {
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  font-size: 12.5px;
}

.details-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
}

.saved-design {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  padding: 10px 0;
}

.saved-design span {
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 80;
  max-width: 360px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  animation: slideIn 220ms ease;
}

.toast.success { border-left-color: var(--emerald); background: var(--bg-surface); color: var(--text-primary); }
.toast.error { border-left-color: var(--rose); background: var(--bg-surface); color: var(--text-primary); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .generator-grid { grid-template-columns: 1fr; }
  .generator-preview { position: static; grid-row: 1; }
}

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-backdrop.open {
    display: block;
  }
  .main-wrapper {
    margin-left: 0 !important;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .sidebar-collapse-btn {
    display: none;
  }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .top-header { padding: 0 14px; }
  .main-content { padding: 16px; }
  .grid-4 { grid-template-columns: 1fr; }
  .health-pill span:last-child { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(3, 1fr); }
  .profile-name { display: none; }
}
