/* SnugVid Admin Dark Theme - Mobile-First High-Contrast Ops Console (A41) */
:root {
  --bg-main: #0c0f14;
  --bg-card: #141922;
  --bg-elevated: #1d2432;
  --bg-input: #10141d;
  --border: #283141;
  --border-focus: #3b82f6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;
  --success: #10b981;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.08) 0%, rgba(12, 15, 20, 0.98) 60%),
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
  background-position: 0 0, -1px -1px, -1px -1px;
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 3rem;
}

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

/* Sticky Header & Red-Flag Strip */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 15, 20, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(40, 49, 65, 0.85);
  position: relative;
}

.top-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 50%, #3b82f6 100%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  font-weight: 800;
  font-size: 0.875rem;
  letter-spacing: -0.02em;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-env {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.brand-env.degraded {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: var(--danger);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.refresh-control {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-card);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  transition: opacity 0.3s;
}

.pulse-indicator.pulsing {
  opacity: 0.3;
}

.pulse-indicator.paused {
  background: var(--text-dim);
}

/* Red-Flag Strip (Mobile Glanceable at 3 AM) */
.red-flag-strip {
  background: rgba(16, 21, 30, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(40, 49, 65, 0.6);
  padding: 0.4rem 1rem;
}

.red-flag-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 1400px;
  margin: 0 auto;
  padding-bottom: 2px;
}

.flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid transparent;
  min-height: 36px;
  transition: all 0.15s ease;
}

.flag-badge.flag-green {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.flag-badge.flag-amber {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.flag-badge.flag-red {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
  animation: flash-red 1.2s infinite alternate;
}

@keyframes flash-red {
  0% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
}

.flag-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.flag-label {
  color: var(--text-muted);
  font-weight: 500;
}

.flag-val {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* Tabs Navigation */
.nav-tabs {
  background: transparent;
  padding: 0.85rem 1rem 0;
  border-bottom: none;
}

.nav-tabs-scroll {
  display: flex;
  background: rgba(15, 19, 26, 0.85);
  border: 1px solid rgba(40, 49, 65, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 1400px;
  margin: 0 auto;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 7px;
  padding: 0.5rem 1rem;
  font-size: 0.84375rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: all 0.15s ease;
}

.tab-btn:hover:not(.active) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

/* Main Layout */
.main-content {
  max-width: 1400px;
  margin: 1.25rem auto;
  padding: 0 1rem;
}

.pane {
  display: none;
}

.pane.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.header-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Workers Grid */
.workers-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .workers-grid {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  }
}

.worker-card {
  background: rgba(20, 25, 34, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(40, 49, 65, 0.85);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.02);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.worker-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 14px 28px -5px rgba(0, 0, 0, 0.6), 0 0 20px -8px rgba(59, 130, 246, 0.2);
}

.worker-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.worker-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.worker-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.worker-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.worker-badge.ready {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.worker-badge.draining {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.worker-badge.offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.worker-metrics {
  margin-bottom: 1rem;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
}

.metric-row .label {
  color: var(--text-muted);
}

.metric-row .val {
  font-family: var(--font-mono);
  font-weight: 600;
}

.progress-bar-bg {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.worker-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

/* Data Tables */
.table-container {
  background: rgba(20, 25, 34, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(40, 49, 65, 0.85);
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
  white-space: nowrap;
}

.data-table th {
  background: rgba(13, 17, 23, 0.95);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(40, 49, 65, 0.85);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(40, 49, 65, 0.45);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background: rgba(59, 130, 246, 0.04);
}

.data-table .mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.loading-td {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

/* Filter Pills */
.filter-pills {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0.85rem;
  padding-bottom: 2px;
}

.pill {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* State Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.badge-queued { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-running { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.badge-complete { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-failed { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-upload { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.metric-card {
  background: rgba(20, 25, 34, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(40, 49, 65, 0.85);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.02);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 14px 28px -5px rgba(0, 0, 0, 0.6), 0 0 20px -8px rgba(59, 130, 246, 0.2);
}

.metric-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.metric-desc {
  display: block;
  color: var(--text-dim);
  font-size: 0.75rem;
}

.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }

/* ==========================================================================
   BUTTONS & ACTIONS (Obsidian Glassmorphic System)
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.65rem 1.15rem;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.4);
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border-color: rgba(96, 165, 250, 0.4);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4b92ff 0%, #2b6df5 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Secondary Button */
.btn-secondary {
  background: rgba(19, 24, 34, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #e2e8f0;
  border: 1px solid rgba(59, 70, 89, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(29, 36, 50, 0.95);
  color: #ffffff;
  border-color: rgba(96, 165, 250, 0.45);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 12px rgba(59, 130, 246, 0.15);
  transform: translateY(-1px);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
  background: rgba(16, 20, 29, 0.95);
}

/* Danger Button */
.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border-color: rgba(248, 113, 113, 0.4);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #f85656 0%, #e62e2e 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-danger:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Warning Button */
.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border-color: rgba(251, 191, 36, 0.4);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-warning:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
}

/* Success Button */
.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

/* Sizes & Modifiers */
.btn-sm {
  min-height: 34px;
  padding: 0.35rem 0.8rem;
  font-size: 0.8125rem;
  border-radius: 6px;
  gap: 0.35rem;
}

.btn-lg {
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: 10px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Table action buttons */
.data-table .btn-sm {
  min-height: 28px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 5px;
}

/* Form Controls & Inputs */
.form-input, .form-select {
  min-height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  font-family: inherit;
}

.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
}

.form-input-sm, .form-select-sm {
  min-height: 36px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

.search-bar input {
  min-width: 250px;
}

.input-inline {
  display: flex;
  gap: 0.5rem;
  max-width: 400px;
  margin-bottom: 1rem;
}

.user-lookup-card, .maintenance-box {
  background: rgba(20, 25, 34, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(40, 49, 65, 0.85);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.user-lookup-card h3, .maintenance-box h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.user-inspect-result {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--border);
}

.maintenance-warning {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.maintenance-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Modals */
.hidden,
.modal-backdrop.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: rgba(20, 25, 34, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(40, 49, 65, 0.9);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.03), 0 0 40px -10px rgba(59, 130, 246, 0.15);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  position: relative;
  overflow: hidden;
  animation: auth-card-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 50%, #3b82f6 100%);
}

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

.modal-sm {
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Mobile Bottom Sheet Behavior */
@media (max-width: 768px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    border-bottom: none;
  }

  .btn-label-desktop {
    display: none;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slide-in 0.2s ease-out;
}

.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); color: #fca5a5; }

@keyframes slide-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   AUTHENTICATION & SECURITY SETUP PAGES (A41 Dark Theme)
   ========================================================================== */

.auth-body,
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 50% 25%, rgba(59, 130, 246, 0.1) 0%, rgba(12, 15, 20, 0.95) 60%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
  background-position: 0 0, -1px -1px, -1px -1px;
}

.auth-card,
.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(20, 25, 34, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(40, 49, 65, 0.9);
  border-radius: 16px;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(255, 255, 255, 0.03),
    0 0 40px -10px rgba(59, 130, 246, 0.15);
  padding: 2.25rem 2rem;
  position: relative;
  overflow: hidden;
  animation: auth-card-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-card-wide {
  max-width: 500px;
}

.auth-card::before,
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 50%, #3b82f6 100%);
}

@keyframes auth-card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-header,
.brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo-badge,
.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  margin-bottom: 0.85rem;
}

.auth-title,
.brand h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #f8fafc;
  margin-bottom: 0.35rem;
}

.auth-subtitle,
.subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.auth-badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.auth-segmented-switch {
  display: flex;
  background: #0f131a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
  margin-bottom: 1.5rem;
}

.auth-switch-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.auth-switch-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.auth-switch-btn:hover:not(.active) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.auth-field {
  margin-bottom: 1.25rem;
}

.auth-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 0.45rem;
}

.auth-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.4rem;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.auth-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input {
  width: 100%;
  height: 44px;
  padding: 0.65rem 0.875rem;
  background: #0f131a;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #131822;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.auth-input-otp {
  height: 52px;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-align: center;
  color: #60a5fa;
  background: #0a0d13;
  border-color: rgba(59, 130, 246, 0.4);
}

.auth-input-otp:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.auth-input-toggle-btn {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 44px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 8px 8px 0;
  transition: color 0.15s ease;
}

.auth-input-toggle-btn:hover {
  color: var(--text-main);
}

.auth-input-with-btn {
  padding-right: 44px;
}

.auth-qr-panel {
  background: #0a0d13;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.auth-qr-frame {
  display: inline-block;
  padding: 10px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  line-height: 0;
  margin-bottom: 0.75rem;
}

.auth-qr-img {
  width: 176px;
  height: 176px;
  display: block;
}

.auth-secret-widget {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #10151f;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  gap: 0.5rem;
}

.auth-secret-code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #60a5fa;
  letter-spacing: 0.04em;
  word-break: break-all;
  user-select: all;
}

.auth-copy-btn {
  background: transparent;
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.auth-copy-btn:hover {
  color: #ffffff;
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
}

.auth-copy-btn.copied {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--success);
  color: var(--success);
}

.auth-submit-btn {
  width: 100%;
  height: 46px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  transition: all 0.15s ease;
  margin-top: 0.5rem;
}

.auth-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
  filter: brightness(1.05);
}

.auth-submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 0.65rem 0.875rem;
  color: #fca5a5;
  font-size: 0.8125rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  animation: slide-in 0.2s ease-out;
}

.auth-footer,
.login-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(40, 49, 65, 0.5);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.auth-footer-icon {
  color: var(--success);
}

