/* ==========================================================================
   AutomationHub - Ultra Clean & Fast Light Theme Design System
   ========================================================================== */

:root {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;

  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-white: #ffffff;

  --border: #e2e8f0;
  --border-light: #edf2f7;
  --border-focus: #3b82f6;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --emerald: #10b981;
  --emerald-light: #ecfdf5;
  --emerald-dark: #059669;

  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --amber-dark: #d97706;

  --rose: #ef4444;
  --rose-light: #fef2f2;
  --rose-dark: #dc2626;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.03);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --sidebar-width: 250px;
  --sidebar-collapsed-width: 76px;
  --topbar-height: 64px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

/* ==========================================================================
   Layout Architecture
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
}
.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}
.brand-name b {
  color: var(--primary);
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px;
  border-radius: var(--radius-sm);
}
.sidebar-toggle-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* Site Switcher */
.site-switch-container {
  padding: 16px 16px 8px;
}
.site-switch-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-subtle);
  margin-bottom: 8px;
  padding-left: 4px;
}
.site-switch-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.site-pill {
  text-align: center;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s ease;
}
.site-pill:hover {
  text-decoration: none;
  color: var(--text-main);
}
.site-pill.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

/* Navigation Links */
.app-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
}
.nav-link:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  text-decoration: none;
}
.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.nav-icon {
  font-size: 1.1rem;
}
.nav-lock {
  margin-left: auto;
  font-size: 0.8rem;
  opacity: 0.6;
}
.nav-link.locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.nav-link.locked:hover {
  background: transparent;
  color: var(--text-muted);
}
.nav-link.locked .nav-lock {
  opacity: 0.9;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-surface);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}
.user-avatar {
  width: 34px;
  height: 34px;
  background: var(--primary);
  color: var(--text-white);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.user-details {
  overflow: hidden;
}
.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.user-role {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-superadmin { color: #7c3aed; }
.badge-admin { color: var(--primary); }
.badge-user { color: var(--text-muted); }

.logout-link {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.1rem;
  text-decoration: none;
  transition: all 0.15s ease;
}
.logout-link:hover {
  background: var(--rose-light);
  color: var(--rose);
  text-decoration: none;
}

/* Collapsed Sidebar */
.app-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}
.app-sidebar.collapsed .brand-name,
.app-sidebar.collapsed .site-switch-container,
.app-sidebar.collapsed .nav-text,
.app-sidebar.collapsed .nav-lock,
.app-sidebar.collapsed .user-details {
  display: none;
}
.app-sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 10px 0;
}
.app-sidebar.collapsed ~ .app-main {
  margin-left: var(--sidebar-collapsed-width);
}

/* Main Area */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.2s ease;
}

/* Topbar */
.app-topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 1rem;
}
.page-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-heading {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}
.site-tag {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}
.system-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}
.status-dot.online {
  background: var(--emerald);
  box-shadow: 0 0 0 2px var(--emerald-light);
}
.time-display {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* App Content Area */
.app-content {
  padding: 28px;
  max-width: 1400px;
  width: 100%;
}

/* ==========================================================================
   Metrics & KPI Cards
   ========================================================================== */

.metrics-section {
  margin-bottom: 28px;
}
.section-heading-row {
  margin-bottom: 14px;
}
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}
.section-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.wrap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.stats-grid {
  display: grid;
  gap: 16px;
}
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.sub-grid { margin-top: 12px; }

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.stat-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.stat-icon-badge {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}
.stat-icon-badge.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon-badge.gray { background: var(--bg-subtle); color: var(--text-muted); }
.stat-icon-badge.amber { background: var(--amber-light); color: var(--amber-dark); }

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}
.stat-value.large { font-size: 2.3rem; }
.stat-meta {
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-top: 6px;
}

.stat-progress-bar {
  height: 5px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  margin-top: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.progress-fill.green { background: var(--emerald); }
.progress-fill.amber { background: var(--amber); }

.stat-card.highlight-card {
  border-color: #a7f3d0;
  background: linear-gradient(to bottom, #ffffff, #f0fdf4);
}

.stat-card-compact {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.compact-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}
.compact-value {
  font-size: 1.05rem;
  font-weight: 700;
}

/* Category Grid (Gears) */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.category-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.category-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.category-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}
.category-badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--emerald-light);
  color: var(--emerald-dark);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.category-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.category-metric-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.category-metric-box.highlight {
  background: var(--emerald-light);
  border-color: #a7f3d0;
}
.box-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.box-main-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
}
.box-split {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.category-sub-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  text-align: center;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
}
.sub-stat span {
  display: block;
  font-size: 0.68rem;
  color: var(--text-subtle);
}
.sub-stat b {
  font-size: 0.85rem;
  color: var(--text-main);
}

/* ==========================================================================
   Panels, Forms & Inputs
   ========================================================================== */

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.panel-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}
.panel-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.panel-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.content-split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.backup-panel {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.backup-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.backup-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #166534;
}
.backup-sub {
  font-size: 0.82rem;
  color: #15803d;
  margin-top: 2px;
}
.backup-actions {
  display: flex;
  gap: 10px;
}

/* Form Controls */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}
.form-label-inline {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}
.required { color: var(--rose); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.88rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.form-input.sm, .form-select.sm {
  padding: 6px 10px;
  font-size: 0.82rem;
}
.form-textarea {
  font-family: monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.form-row-wrap {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.input-with-button {
  display: flex;
  gap: 8px;
}

.form-inline-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.form-inline-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  font-size: 0.88rem;
}
.btn:hover { text-decoration: none; }
.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

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

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

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--rose-light);
  border-color: #fecaca;
  color: var(--rose);
}
.btn-danger:hover {
  background: var(--rose);
  color: var(--text-white);
}

.btn-block {
  width: 100%;
}

.btn-category-export {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: all 0.16s ease;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  user-select: none;
}
.btn-category-export:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-category-export:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-category-export svg {
  transition: transform 0.15s ease;
}
.btn-category-export:hover:not(:disabled) svg {
  transform: translateY(1px);
}

@keyframes ahub-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Data Tables
   ========================================================================== */

.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}
.data-table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}
.data-table tbody tr:hover {
  background: #f8fafc;
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.table-empty {
  text-align: center;
  color: var(--text-subtle);
  padding: 24px !important;
}

/* Tabs Nav */
.tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}
.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-white);
}

/* Badges & Pills */
.stat-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.stat-badge.green { background: var(--emerald-light); color: var(--emerald-dark); }
.stat-badge.amber { background: var(--amber-light); color: var(--amber-dark); }
.stat-badge.emerald { background: #d1fae5; color: #047857; }

.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.pill-green { background: var(--emerald-light); color: var(--emerald-dark); }
.pill-red { background: var(--rose-light); color: var(--rose); }
.pill-amber { background: var(--amber-light); color: var(--amber-dark); }
.pill-grey { background: var(--bg-subtle); color: var(--text-muted); }

.tag-badge {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.tag-badge.blue { background: var(--primary-light); color: var(--primary); }

.key-box {
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 1.15rem;
  font-family: monospace;
  font-weight: 700;
  color: var(--primary);
}

/* Activity Feed */
.activity-feed-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}
.activity-feed-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.feed-user {
  font-weight: 700;
  color: var(--primary);
  margin-right: 8px;
}
.feed-action {
  flex: 1;
  color: var(--text-body);
}
.feed-time {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-left: 8px;
}
.feed-empty {
  text-align: center;
  color: var(--text-subtle);
  padding: 24px;
}

/* Modals */
.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 440px;
  width: 90%;
  padding: 24px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}
.btn-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-body {
  margin-bottom: 20px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   Authentication Pages
   ========================================================================== */

.auth-page {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.auth-container {
  max-width: 420px;
  width: 100%;
}
.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.auth-logo-badge {
  font-size: 1.4rem;
}
.auth-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}
.auth-logo b { color: var(--primary); }
.auth-subtitle {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.auth-footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 20px;
}
.badge-pill {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin: 0 auto 12px;
  text-align: center;
}

/* Toast Notifications */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--text-main);
  color: var(--text-white);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.88rem;
  animation: toastIn 0.2s ease forwards;
}
.toast.warn { background: #b45309; }
.toast.error { background: #b91c1c; }
.toast.success { background: #047857; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 0.2s; }

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

/* Text Colors */
.text-green { color: var(--emerald); }
.text-emerald { color: var(--emerald-dark); }
.text-amber { color: var(--amber); }
.text-blue { color: var(--primary); }
.text-red { color: var(--rose); }
.text-gray { color: var(--text-muted); }
.text-center { text-align: center; }

/* Responsive */
@media (max-width: 900px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.expanded {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0 !important;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .content-split-row {
    grid-template-columns: 1fr;
  }
  .app-content {
    padding: 18px;
  }
}

/* Slim Light Footer Watermark */
.app-page-footer {
  margin-top: auto;
  padding: 24px 28px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.slim-light-watermark {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.45;
  user-select: none;
  transition: opacity 0.2s ease;
}

.slim-light-watermark:hover {
  opacity: 0.8;
}

/* ==========================================================================
   Dark Theme Design System & Overrides
   ========================================================================== */

.dark-theme {
  --bg-app: #090d16;
  --bg-surface: #101726;
  --bg-subtle: #172033;
  --bg-hover: #1f2b42;

  --text-main: #f8fafc;
  --text-body: #cbd5e1;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-white: #ffffff;

  --border: #1e293b;
  --border-light: #182234;
  --border-focus: #38bdf8;

  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-light: rgba(56, 189, 248, 0.12);

  --emerald: #34d399;
  --emerald-light: rgba(52, 211, 153, 0.14);
  --emerald-dark: #10b981;

  --amber: #fbbf24;
  --amber-light: rgba(251, 191, 36, 0.14);
  --amber-dark: #f59e0b;

  --rose: #f87171;
  --rose-light: rgba(248, 113, 113, 0.14);
  --rose-dark: #ef4444;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 14px -1px rgba(0, 0, 0, 0.55), 0 2px 5px -2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 30px -4px rgba(0, 0, 0, 0.7), 0 8px 14px -4px rgba(0, 0, 0, 0.45);
}

/* Dark mode specific component refinements */
.dark-theme .app-sidebar {
  background: #0c121e;
  border-right-color: #1a2334;
}

.dark-theme .sidebar-header,
.dark-theme .sidebar-footer {
  background: #0c121e;
  border-color: #1a2334;
}

.dark-theme .app-topbar {
  background: #0e1524;
  border-bottom-color: #1a2334;
}

.dark-theme .site-pill {
  background: #141c2c;
  color: #94a3b8;
  border: 1px solid #1f2b42;
}

.dark-theme .site-pill.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.dark-theme .stat-card {
  background: #101726;
  border-color: #1e293b;
}

.dark-theme .stat-card:hover {
  border-color: #2b3952;
}

.dark-theme .panel {
  background: #101726;
  border-color: #1e293b;
}

.dark-theme .table-container {
  border-color: #1e293b;
}

.dark-theme .data-table th {
  background: #141d2e;
  border-bottom-color: #1e293b;
}

.dark-theme .data-table td {
  border-bottom-color: #162033;
}

.dark-theme .data-table tbody tr:hover {
  background: #151e30;
}

.dark-theme .form-input,
.dark-theme .form-select,
.dark-theme .form-textarea {
  background: #0a0e1a;
  border-color: #1e293b;
  color: #f8fafc;
}

.dark-theme .form-input:focus,
.dark-theme .form-select:focus,
.dark-theme .form-textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.dark-theme .tab-btn {
  background: #141c2c;
  border-color: #1f2b42;
  color: #94a3b8;
}

.dark-theme .tab-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
}

.dark-theme .app-modal-card {
  background: #101726;
  border: 1px solid #1f2b42;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.dark-theme .app-modal-overlay {
  background: rgba(3, 7, 18, 0.8);
}

.dark-theme .toast {
  background: #1a2334;
  color: #f8fafc;
  border: 1px solid #28364f;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
}

.dark-theme .auth-card {
  background: #101726;
  border: 1px solid #1e293b;
}

.dark-theme .auth-page {
  background: linear-gradient(135deg, #090d16 0%, #101726 100%);
}

.dark-theme .user-details .badge-user {
  color: #94a3b8;
}

/* ==========================================================================
   Dark / Light Mode Toggle Button & Dashboard Dark Theme Refinements
   ========================================================================== */

/* Topbar Toggle Button */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.theme-toggle-btn:active {
  transform: translateY(0);
}

.theme-toggle-btn .theme-icon {
  font-size: 0.95rem;
  line-height: 1;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle-btn:hover .theme-icon {
  transform: rotate(18deg) scale(1.15);
}

.theme-toggle-btn .sun-icon {
  display: none;
}

.theme-toggle-btn .moon-icon {
  display: inline-block;
}

/* Sidebar Theme Button */
.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-theme-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar-theme-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  transform: scale(1.08);
}

.sidebar-theme-btn:focus-visible {
  outline: 2px solid var(--primary);
}

.sidebar-theme-btn .sun-icon {
  display: none;
}

.sidebar-theme-btn .moon-icon {
  display: inline-block;
}

.app-sidebar.collapsed .sidebar-footer {
  flex-direction: column;
  padding: 12px 6px;
  gap: 10px;
}

.app-sidebar.collapsed .sidebar-footer-actions {
  flex-direction: column;
  gap: 6px;
}

/* --------------------------------------------------------------------------
   When Dark Mode is Active (.dark-theme)
   -------------------------------------------------------------------------- */
.dark-theme .theme-toggle-btn {
  background: #141c2c;
  border-color: #27354d;
  color: #f1f5f9;
}

.dark-theme .theme-toggle-btn:hover {
  background: #1e2b42;
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}

.dark-theme .theme-toggle-btn .sun-icon {
  display: inline-block;
}

.dark-theme .theme-toggle-btn .moon-icon {
  display: none;
}

.dark-theme .sidebar-theme-btn {
  color: #94a3b8;
}

.dark-theme .sidebar-theme-btn:hover {
  background: #1e2b42;
  color: #f8fafc;
}

.dark-theme .sidebar-theme-btn .sun-icon {
  display: inline-block;
}

.dark-theme .sidebar-theme-btn .moon-icon {
  display: none;
}

/* Dashboard Dark Mode Component Specifics */
.dark-theme .stat-card.highlight-card {
  border-color: rgba(52, 211, 153, 0.35);
  background: linear-gradient(180deg, #101726 0%, #0d221c 100%);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.08);
}

.dark-theme .stat-badge.emerald {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
}

.dark-theme .backup-panel {
  background: #0d2218;
  border-color: #164e32;
}

.dark-theme .backup-title {
  color: #34d399;
}

.dark-theme .backup-sub {
  color: #a7f3d0;
}

.dark-theme .backup-sub code {
  background: #091710;
  color: #6ee7b7;
  border: 1px solid #164e32;
}

.dark-theme .category-metric-box.highlight {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.25);
}

.dark-theme .category-badge {
  background: rgba(52, 211, 153, 0.18);
  color: #34d399;
}

.dark-theme .time-display {
  background: #141c2c;
  border-color: #1e293b;
  color: #cbd5e1;
}

.dark-theme .site-tag {
  background: #141c2c;
  border-color: #1e293b;
  color: #94a3b8;
}

.dark-theme .system-status-indicator {
  color: #94a3b8;
}

.dark-theme .status-dot.online {
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.25);
}

/* Mobile Responsiveness for Theme Toggle */
@media (max-width: 680px) {
  .theme-toggle-btn {
    padding: 6px 10px;
  }
  .theme-toggle-btn .theme-label {
    display: none;
  }
}

