:root {
  --bg-gradient: radial-gradient(circle at 20% 30%, rgba(56, 189, 248, 0.3), transparent),
                 radial-gradient(circle at 80% 40%, rgba(167, 139, 250, 0.3), transparent),
                 radial-gradient(circle at 40% 80%, rgba(34, 197, 94, 0.25), transparent),
                 radial-gradient(circle at 90% 10%, rgba(249, 115, 22, 0.2), transparent),
                 linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --glass: rgba(15, 23, 42, 0.4);
  --glass-border: rgba(148, 163, 184, 0.1);
  --glass-light: rgba(255, 255, 255, 0.05);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --brand: #60a5fa;
  --brand-hover: #3b82f6;
  --accent-orange: #fb923c;
  --accent-purple: #a78bfa;
  --accent-green: #34d399;
  --accent-teal: #2dd4bf;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 35px 60px -12px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

.max { max-width: 1400px; margin: 0 auto; padding: 32px 24px; }

/* Header */
header {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 32px 0;
  margin-bottom: 24px;
}

header .logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--accent-teal));
  box-shadow: var(--shadow);
  position: relative;
}

header .logo::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 700;
  background: linear-gradient(135deg, var(--text), var(--brand));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.sub { color: var(--text-muted); font-size: 16px; }

/* Header Buttons */
.header-buttons {
  position: absolute;
  top: 32px;
  right: 32px;
  display: flex;
  gap: 8px;
  z-index: 1000;
}

.header-buttons .btn {
  padding: 12px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
  position: relative;
}

.header-buttons .btn:hover { 
  background: var(--glass-light); 
  transform: scale(1.05); 
}

/* Theme Toggle */
#themeToggle .moon { display: none; }
#themeToggle .sun { display: block; }

/* Notification Badge */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--error);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-gradient);
}

.notification-badge.hidden {
  display: none;
}

/* Notifications */
.notifications-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notification {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  padding: 16px;
  box-shadow: var(--shadow);
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.notification.show {
  transform: translateX(0);
  opacity: 1;
}

.notification.expanded .notification-body {
  max-height: none;
  overflow: visible;
}

.notification.collapsed .notification-body {
  max-height: 4.8em;
  overflow: hidden;
  position: relative;
}

.notification.collapsed .notification-body::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1.2em;
  background: linear-gradient(transparent, var(--glass));
  pointer-events: none;
}

.notification-expand-btn {
  background: none;
  border: none;
  color: var(--brand);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 0;
  margin-top: 8px;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.notification-expand-btn:hover {
  color: var(--brand-hover);
}

.notification.persistent {
  border-left-width: 6px;
  box-shadow: var(--shadow-lg);
}

.notification.warning {
  border-left: 4px solid var(--warning);
  background: rgba(245, 158, 11, 0.1);
}

.notification.error {
  border-left: 4px solid var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.notification.success {
  border-left: 4px solid var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.notification.info {
  border-left: 4px solid var(--brand);
  background: rgba(96, 165, 250, 0.1);
}

.notification-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.notification-title {
  font-weight: 600;
  font-size: 14px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.notification-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.notification-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.notification-body {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
}

.notification-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.notification-action {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.notification-action:hover {
  background: rgba(255, 255, 255, 0.2);
}

.notification-action.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.notification-action.primary:hover {
  background: var(--brand-hover);
}

/* Notification Center */
.notification-center {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.notification-center.hidden {
  display: none;
}

.notification-center-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.notification-center-panel {
  position: relative;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.notification-center-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.1) 0%, rgba(167, 139, 250, 0.1) 100%);
}

.notification-center-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.notification-center-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.notification-center-actions .btn.small {
  padding: 6px 12px;
  font-size: 13px;
}

.notification-center-content {
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
}

.notification-history {
  padding: 16px 24px;
}

.notification-history-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  color: var(--text);
  transition: all 0.2s ease;
}

.notification-history-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.notification-history-item:last-child {
  margin-bottom: 0;
}

.notification-history-item.warning {
  border-left: 4px solid var(--warning);
}

.notification-history-item.error {
  border-left: 4px solid var(--error);
}

.notification-history-item.success {
  border-left: 4px solid var(--success);
}

.notification-history-item.info {
  border-left: 4px solid var(--brand);
}

.notification-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.notification-history-title {
  font-weight: 600;
  font-size: 14px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.notification-history-time {
  font-size: 12px;
  color: var(--text-muted);
}

.notification-history-body {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.notification-history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.notification-history-actions .btn {
  padding: 4px 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.notification-history-actions .btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.empty-notifications {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-notifications svg {
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-notifications p {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 500;
}

.empty-notifications .small {
  display: block;
  font-size: 14px;
  opacity: 0.8;
}

@media (max-width: 768px) {
  .notifications-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .notification-center {
    padding: 10px;
  }
  
  .notification-center-panel {
    max-height: 90vh;
  }
  
  .notification-center-header {
    padding: 16px 20px 12px;
  }
  
  .notification-history {
    padding: 12px 20px;
  }
  
  .header-buttons {
    top: 16px;
    right: 16px;
  }
}

/* Tour System */
.tour-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3000;
  pointer-events: none;
}

.tour-overlay.hidden {
  display: none;
}

.tour-overlay.active {
  pointer-events: auto;
}

.tour-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(1px);
}

.tour-spotlight {
  position: absolute;
  background: transparent;
  border: 4px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
  transition: all 0.3s ease;
  pointer-events: none;
}

.tour-tooltip {
  position: absolute;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 90vw;
  transform-origin: center;
  transition: all 0.3s ease;
}

.tour-content {
  padding: 20px 24px;
}

.tour-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.tour-step-indicator {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.tour-step-current {
  color: var(--brand);
  font-weight: 600;
}

.tour-skip-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.2s ease;
}

.tour-skip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.tour-body {
  margin-bottom: 20px;
}

.tour-title {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.tour-message {
  color: var(--text-muted);
  line-height: 1.5;
}

.tour-message p {
  margin: 0 0 12px 0;
}

.tour-message p:last-child {
  margin-bottom: 0;
}

.tour-message ul {
  margin: 8px 0;
  padding-left: 20px;
}

.tour-message li {
  margin-bottom: 4px;
}

.tour-message code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Monaco', 'Menlo', monospace;
}

.tour-message strong {
  color: var(--text);
  font-weight: 600;
}

.tour-footer {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tour-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
}

.tour-btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.tour-btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tour-btn-primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: white;
  min-width: 80px;
}

.tour-btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.tour-progress {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.tour-progress-bar {
  height: 100%;
  background: var(--brand);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.tour-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border: 10px solid transparent;
}

.tour-tooltip.arrow-top .tour-arrow {
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  border-top-color: var(--glass);
  border-bottom: none;
}

.tour-tooltip.arrow-bottom .tour-arrow {
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  border-bottom-color: var(--glass);
  border-top: none;
}

.tour-tooltip.arrow-left .tour-arrow {
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  border-left-color: var(--glass);
  border-right: none;
}

.tour-tooltip.arrow-right .tour-arrow {
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  border-right-color: var(--glass);
  border-left: none;
}

.tour-highlight {
  position: relative;
  z-index: 3001;
}

@media (max-width: 768px) {
  .tour-tooltip {
    max-width: 320px;
    width: calc(100vw - 40px);
  }
  
  .tour-content {
    padding: 16px 20px;
  }
  
  .tour-title {
    font-size: 16px;
  }
  
  .tour-footer {
    flex-direction: column;
    gap: 12px;
  }
  
  .tour-footer > * {
    width: 100%;
  }
  
  .tour-progress {
    order: -1;
  }
}

/* Tour Animations */
@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.7); }
  50% { transform: scale(1.02); box-shadow: 0 0 0 8px rgba(96, 165, 250, 0.1); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(96, 165, 250, 0); }
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  position: relative; /* ensure clicks always land */
  z-index: 2;
}
.tab-btn {
  flex: 1;
  padding: 16px 24px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(20px);
  font-weight: 500;
}
.tab-btn:hover { background: var(--glass-light); color: var(--text); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--brand), var(--accent-purple));
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* Cards */
.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px;
  margin-top: 24px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

/* Sidebar Layout for Upload */
.row { display: flex; gap: 32px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 320px; }

/* Form Elements */
label {
  display: block;
  margin-bottom: 12px;
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input, select, textarea {
  width: 100%;
  padding: 16px 18px;
  background: var(--glass);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
  font-size: 15px;
}
.input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
  text-decoration: none;
}
.btn:hover { background: var(--glass-light); transform: translateY(-2px); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--accent-purple));
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow);
}
.btn.primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* Pill Status */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--glass);
  color: var(--text-muted);
  font-size: 13px;
  backdrop-filter: blur(20px);
}

/* Status Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.status {
  border: 1px solid var(--glass-border);
  background: var(--glass);
  padding: 20px;
  border-radius: 16px;
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
}
.status.ok { border-color: var(--success); background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(52, 211, 153, 0.05)); }
.status.warn { border-color: var(--warning); background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(251, 146, 60, 0.05)); }
.status.err { border-color: var(--error); background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(248, 113, 113, 0.05)); }

/* Drop Zone */
.drop {
  border: 2px dashed var(--glass-border);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  background: var(--glass);
  color: var(--brand);
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
}
.drop.drag { border-color: var(--brand); background: rgba(96, 165, 250, 0.1); transform: scale(1.02); }

/* Utilities */
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.mono { font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace; }
.small { font-size: 13px; color: var(--text-muted); }
.kbd { border: 1px solid var(--glass-border); border-bottom-width: 3px; padding: 4px 8px; border-radius: 8px; background: var(--glass); color: var(--text); font-weight: 600; backdrop-filter: blur(20px); }
.hidden { display: none; }

pre {
  max-height: 400px;
  overflow: auto;
  background: var(--glass);
  padding: 20px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  backdrop-filter: blur(20px);
}
a.dl { color: var(--brand); text-decoration: none; }
a.dl:hover { color: var(--brand-hover); }

/* Results Subtabs */
.subtabs { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.subtab {
  padding: 10px 18px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(20px);
  font-size: 14px;
  font-weight: 500;
}
.subtab:hover { background: var(--glass-light); color: var(--text); }
.subtab.active { background: linear-gradient(135deg, var(--accent-teal), var(--accent-green)); border-color: transparent; color: white; }

.subpanels {
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(20px);
}
.subpanel { display: none; padding: 24px; }
.subpanel.active { display: block; }

/* Results Story Layout */
.results-story {
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  overflow: hidden;
}

.story-section {
  padding: 32px 24px;
  border-bottom: 1px solid var(--glass-border);
  transition: all 0.3s ease;
}

.story-section:last-child {
  border-bottom: none;
}

.story-section:hover {
  background: var(--glass-light);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--glass-border);
}

.section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--accent-purple));
  color: white;
  font-size: 20px;
  font-weight: 600;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.section-title {
  flex: 1;
}

.section-title h3 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(135deg, var(--text), var(--brand));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.section-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.8;
}

.subsection {
  margin-bottom: 32px;
}

.subsection:last-child {
  margin-bottom: 0;
}

.subsection h4 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.subsection h4::before {
  content: "";
  width: 4px;
  height: 16px;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-green));
  border-radius: 2px;
  flex-shrink: 0;
}

/* Stat Cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; }
.stat {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
}
.stat:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.stat .k { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.stat .v {
  font-size: 28px;
  font-weight: 700;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--text), var(--brand));
  background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

/* Tables */
.table-wrap { max-height: 500px; overflow: auto; border: 1px solid var(--glass-border); border-radius: 16px; backdrop-filter: blur(20px); background: var(--glass); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; border-radius: 16px; overflow: hidden; }
.table th, .table td { border-bottom: 1px solid rgba(255, 255, 255, 0.06); border-right: 1px solid rgba(255, 255, 255, 0.04); padding: 12px 16px; text-align: left; vertical-align: top; transition: all 0.2s ease; }
.table th:last-child, .table td:last-child { border-right: none; }
.table thead th { position: sticky; top: 0; background: rgba(255, 255, 255, 0.08); color: var(--text); font-weight: 600; z-index: 10; backdrop-filter: blur(20px); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--brand); }
.table tbody tr { transition: all 0.2s ease; background: rgba(255, 255, 255, 0.02); }
.table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.04); }
.table tbody tr:hover { background: rgba(96, 165, 250, 0.1); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
.table tbody tr.editing { background: rgba(96, 165, 250, 0.15); box-shadow: 0 0 0 2px var(--brand); transform: scale(1.01); z-index: 100; }
.table td { color: var(--text-muted); font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td:hover { color: var(--text); white-space: normal; word-break: break-word; }
.table td.editing-cell { padding: 4px; background: rgba(255, 255, 255, 0.1); }
.table td.editing-cell .inline-input { width: 100%; background: var(--glass); border: 2px solid var(--brand); border-radius: 6px; padding: 8px 12px; color: var(--text); font-size: 13px; transition: all 0.2s ease; }
.table td.editing-cell .inline-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.3); }
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s ease; }
.table tbody tr:hover .row-actions, .table tbody tr.editing .row-actions { opacity: 1; }
.row-actions .btn { padding: 4px 8px; font-size: 11px; border-radius: 4px; min-width: auto; height: 28px; }
.row-actions .btn.save { background: var(--success); border-color: var(--success); color: white; }
.row-actions .btn.cancel { background: var(--glass); border-color: var(--glass-border); color: var(--text-muted); }
.row-actions .btn.delete { background: var(--error); border-color: var(--error); color: white; }

/* Collapsible Add Form */
.add-form-section { margin-bottom: 24px; }
.add-form-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: var(--glass); border: 1px solid var(--glass-border); border-radius: 12px; cursor: pointer; transition: all 0.2s ease; }
.add-form-header:hover { background: var(--glass-light); transform: translateY(-1px); box-shadow: var(--shadow); }
.add-form-header.active { border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: var(--glass-light); }
.add-form-title { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.add-form-icon { transition: transform 0.3s ease; font-size: 18px; color: var(--brand); }
.add-form-header.active .add-form-icon { transform: rotate(45deg); }
.add-form-content { max-height: 0; overflow: hidden; transition: all 0.3s ease; background: var(--glass); border: 1px solid var(--glass-border); border-top: none; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
.add-form-content.active { max-height: 500px; padding: 20px; }
.add-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.add-form-field { display: flex; flex-direction: column; gap: 6px; }
.add-form-field label { font-size: 13px; font-weight: 500; color: var(--text); text-transform: uppercase; letter-spacing: 0.5px; }
.add-form-field input { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); border-radius: 8px; padding: 12px 16px; color: var(--text); font-size: 14px; transition: all 0.2s ease; }
.add-form-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2); background: rgba(255, 255, 255, 0.08); }
.add-form-field input::placeholder { color: var(--text-muted); opacity: 0.7; }
.add-form-actions { display: flex; gap: 12px; align-items: center; padding-top: 16px; border-top: 1px solid var(--glass-border); }
.add-form-summary { font-size: 13px; color: var(--text-muted); margin-left: 12px; }

.neg { color: var(--error); font-variant-numeric: tabular-nums; }

/* Sections */
.sect { margin-top: 24px; }
.sect > .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sect h3 { margin: 0; font-size: 18px; font-weight: 600; }
.actions { display: flex; gap: 12px; }

/* Print styles */
.print-only { display: none; }

@media print {
  @page { size: letter; margin: 0.5in; }
  body { background: #fff !important; color: #111 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  header, .tabs, #panel-upload, #runControls, .subtabs, .card-response, details, .actions .btn { display: none !important; }
  .card, .subpanels, #panel-run { border: none !important; background: #fff !important; box-shadow: none !important; }
  .table-wrap { max-height: none !important; overflow: visible !important; }
  .table thead th { position: static !important; background: #f3f4f6 !important; color: #111 !important; border-bottom: 1px solid #ddd !important; }
  .table th, .table td { border-bottom: 1px solid #ddd !important; color: #111 !important; }
  .neg { color: #b91c1c !important; }
  .stat { border: 1px solid #ddd !important; background: #fff !important; }
  .stat .k { color: #333 !important; }
  .stat .v { color: #000 !important; }
  .subpanel { display: block !important; page-break-inside: avoid; }
  .panel-title { display: block; font-size: 20px; margin: 24px 0 8px; color: #000 !important; }
  a, button { display: none !important; }
  #panel-staffing, #panel-overhead, #panel-encounters, #panel-ffs, #panel-vbc, #panel-financials, #panel-kpis { page-break-before: always; }
}

/* --- App utility additions (safe with light/dark) --- */
.status.clickable { cursor: pointer; border-style: solid; }
.status.clickable:hover { border-color: var(--brand); }

/* Chart containers used in Financials/Forecast */
.chart-container {
  max-width: 550px;
  max-height: 380px;
  position: relative;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 16px;
  background: var(--glass);
  backdrop-filter: blur(20px);
}
.chart-container.hidden { display: none; }

/* Paged table controls */
.pager { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.pager .input { width: auto; }
.pager button { padding: 6px 10px; }

/* Modal */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.5); z-index: 9999; }
.modal.hidden { display: none !important; }
.modal-card { width: min(100%, 900px); background: var(--glass); border: 1px solid var(--glass-border); border-radius: 14px; padding: 16px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

/* Ensure the Forecast panel gets its own page in printouts */
@media print {
  #panel-forecast { page-break-before: always; }
}

/* =========================
   Light Mode (toggle target)
   ========================= */
body.light-mode {
  --bg-gradient: radial-gradient(circle at 20% 30%, rgba(59,130,246,0.15), transparent),
                 radial-gradient(circle at 80% 40%, rgba(139,92,246,0.15), transparent),
                 radial-gradient(circle at 40% 80%, rgba(34,197,94,0.12), transparent),
                 radial-gradient(circle at 90% 10%, rgba(249,115,22,0.10), transparent),
                 linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(71, 85, 105, 0.15);
  --glass-light: rgba(255, 255, 255, 0.9);
  --text: #0f172a;
  --text-muted: #64748b;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
}
body.light-mode .table tbody tr:nth-child(even) { background: rgba(0, 0, 0, 0.02); }
body.light-mode .table tbody tr:hover { background: rgba(37, 99, 235, 0.05); }
body.light-mode .stat .v,
body.light-mode h1 {
  background: linear-gradient(135deg, var(--text), var(--brand));
  background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
/* toggle icon swap in light mode */
body.light-mode #themeToggle .moon { display: block; }
body.light-mode #themeToggle .sun  { display: none; }

/* Light mode notification center enhancements */
body.light-mode .notification-center-panel {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(71, 85, 105, 0.2);
}

body.light-mode .notification-center-header {
  background: rgba(248, 250, 252, 0.9);
  border-bottom: 1px solid rgba(71, 85, 105, 0.15);
}

body.light-mode .notification-history-item {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(71, 85, 105, 0.1);
}

body.light-mode .notification-history-item:hover {
  background: rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.2);
}

body.light-mode .notification-history-item.warning {
  border-left: 3px solid #f59e0b;
  background: rgba(245, 158, 11, 0.05);
}

body.light-mode .notification-history-item.error {
  border-left: 3px solid #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

body.light-mode .notification-history-item.success {
  border-left: 3px solid #10b981;
  background: rgba(16, 185, 129, 0.05);
}

body.light-mode .notification-history-item.info {
  border-left: 3px solid #3b82f6;
  background: rgba(59, 130, 246, 0.05);
}

/* Manager-specific styling (Date Manager & Duplicate Manager) */
.manager-instructions {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  backdrop-filter: blur(20px);
}

.manager-instructions h4 {
  margin: 0 0 8px 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.manager-instructions p {
  margin: 8px 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.manager-instructions ul {
  margin: 8px 0;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.manager-instructions li {
  margin: 4px 0;
  line-height: 1.4;
}

/* Data comparison styling */
.row-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

.comparison-side {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 12px;
}

.comparison-side h5 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.data-preview {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  color: var(--text-muted);
  max-height: 120px;
  overflow-y: auto;
}

.data-preview.duplicate-data {
  background: rgba(245, 158, 11, 0.05);
  border-color: rgba(245, 158, 11, 0.2);
}

.data-preview.multiple-dates {
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.2);
  font-family: monospace;
  white-space: pre-wrap;
}

.data-field {
  margin: 2px 0;
  font-size: 11px;
}

.data-field strong {
  color: var(--text);
}

.data-more {
  margin-top: 6px;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.7;
  font-size: 10px;
}

/* Action button styling */
.duplicate-actions, .date-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.duplicate-actions .btn, .date-actions .btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  min-width: auto;
  transition: all 0.2s ease;
}

.duplicate-actions .btn.selected, .date-actions .btn.selected {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-weight: 600;
}

.keep-btn.selected {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  border-color: #059669 !important;
  color: white !important;
}

.remove-btn.selected {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  border-color: #dc2626 !important;
  color: white !important;
}

.split-btn.selected {
  background: linear-gradient(135deg, #10b981, #059669) !important;
  border-color: #059669 !important;
  color: white !important;
}

.primary-btn.selected {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  border-color: #d97706 !important;
  color: white !important;
}

.ignore-btn.selected {
  background: linear-gradient(135deg, #6b7280, #4b5563) !important;
  border-color: #4b5563 !important;
  color: white !important;
}

/* Status styling */
.duplicate-status, .date-status {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.3s ease;
}

.duplicate-status.success, .date-status.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.duplicate-status.error, .date-status.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--error);
}

.duplicate-status.warning, .date-status.warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.duplicate-status.neutral, .date-status.neutral {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
}

/* Summary value styling */
.summary-value.warning {
  color: var(--warning);
  font-weight: 600;
}

/* Current value styling for dates */
.current-value {
  margin-bottom: 12px;
}

.current-value h5 {
  margin: 0 0 6px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.extracted-dates {
  margin-top: 8px;
}

.extracted-dates h5 {
  margin: 0 0 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.extracted-dates p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Simple manager styling without aggressive overrides */
.manager-modal .duplicate-item,
.manager-modal .date-item {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--warning);
  color: var(--text);
}

.manager-modal .notification-history-title {
  color: var(--text);
}

.manager-modal .notification-history-body {
  color: var(--text-muted);
}

/* Manager modal styling */
.manager-modal {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
}

.manager-modal .modal-head {
  background: var(--glass-light);
  border-bottom: 1px solid var(--glass-border);
}

.manager-modal .modal-head h4 {
  color: var(--text);
  margin: 0;
}

.manager-modal .modal-body {
  background: var(--glass);
  color: var(--text);
}

.manager-modal .modal-foot {
  background: var(--glass-light);
  border-top: 1px solid var(--glass-border);
}

.manager-close-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  padding: 0;
}

.manager-close-btn:hover {
  background: var(--glass-light);
  color: var(--text);
}

/* Simplified manager content colors */
.manager-modal .notification-center-summary {
  background: var(--glass);
  border: 1px solid var(--glass-border);
}

.manager-modal .summary-label {
  color: var(--text-muted);
}

.manager-modal .summary-value {
  color: var(--text);
}
