/* ============================================================
   BERATUNGS-SEQUENZ — Premium Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ────────────────────────────────── */
:root {
  /* Colors – Light Palette */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.6);
  --bg-input: #f1f5f9;
  --bg-input-focus: #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.04);
  --border-default: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);
  --border-accent: rgba(99, 102, 241, 0.3);

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

  /* Accent Gradients */
  --gradient-primary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #8b5cf6 100%);
  --gradient-accent: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  --gradient-success: linear-gradient(135deg, #059669 0%, #10b981 100%);
  --gradient-warning: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  --gradient-danger: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  --gradient-info: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
  --gradient-bg: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);

  /* Solid Accents */
  --accent-primary: #4f46e5;
  --accent-primary-light: #6366f1;
  --accent-secondary: #7c3aed;
  --accent-success: #059669;
  --accent-warning: #d97706;
  --accent-danger: #dc2626;
  --accent-info: #0891b2;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.875rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
  --shadow-glow-strong: 0 0 60px rgba(99, 102, 241, 0.25);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --header-height: 64px;
  --max-content-width: 1400px;
}

/* ── Dark Mode Override ───────────────────────────────────── */
body.dark-mode {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.8);
  --bg-card-hover: rgba(30, 41, 59, 0.95);
  --bg-elevated: #1e293b;
  --bg-glass: rgba(15, 23, 42, 0.7);
  --bg-input: #1e293b;
  --bg-input-focus: #334155;
  --bg-body: #0f172a;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.15);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --gradient-bg: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.7);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.8);
}

/* ── Dashboard Chart Container ────────────────────────────── */
.dashboard-chart-container {
  width: 100%;
  max-width: 320px;
  height: 260px;
  margin: var(--space-lg) auto;
}


/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#vanta-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

body {
  font-family: var(--font-family);
  background: var(--gradient-bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated background particles */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--accent-primary-light);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── App Layout ───────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition-base);
}

.sidebar-brand {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand h1 {
  font-size: var(--font-size-lg);
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-top: var(--space-xs);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
  width: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

.nav-section-title {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-lg) var(--space-xl) var(--space-sm);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xl);
  margin: 1px var(--space-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--gradient-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

.nav-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-primary-light);
}

.nav-item.active::before {
  opacity: 1;
}

.nav-item .icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-md);
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--gradient-primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: opacity var(--transition-base), transform var(--transition-base);
}

.main-content.view-transitioning {
  opacity: 0;
  transform: translateY(8px);
}

.content-header {
  padding: var(--space-xl) var(--space-2xl);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.content-header h2 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.content-header p {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  margin-top: var(--space-xs);
}

.content-body {
  padding: var(--space-2xl);
  max-width: var(--max-content-width);
}

/* ── View Sections (only active view is visible) ──────────── */
.view-section {
  display: none;
  animation: fadeSlideIn var(--transition-slow) ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── KPI Cards (Dashboard) ────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.purple::before {
  background: var(--gradient-primary);
}

.kpi-card.blue::before {
  background: var(--gradient-accent);
}

.kpi-card.green::before {
  background: var(--gradient-success);
}

.kpi-card.orange::before {
  background: var(--gradient-warning);
}

.kpi-card.cyan::before {
  background: var(--gradient-info);
}

.kpi-card.red::before {
  background: var(--gradient-danger);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-glow);
}

.kpi-card .kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: var(--space-md);
}

.kpi-card.purple .kpi-icon {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.kpi-card.blue .kpi-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.kpi-card.green .kpi-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.kpi-card.orange .kpi-icon {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.kpi-card.cyan .kpi-icon {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.kpi-card.red .kpi-icon {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.kpi-value {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  font-weight: 500;
}

/* ── Glass Card ───────────────────────────────────────────── */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: all var(--transition-base);
}

.glass-card:hover {
  border-color: var(--border-default);
}

.glass-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.glass-card-header h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

/* ── Data Table ───────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-glass);
}

.data-table tbody td {
  padding: var(--space-md);
  font-size: var(--font-size-base);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.data-table tbody td:first-child {
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Status Badge ─────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge.status-new {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.status-badge.status-new::before {
  background: #818cf8;
}

.status-badge.status-progress {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.status-badge.status-progress::before {
  background: #60a5fa;
}

.status-badge.status-waiting {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.status-badge.status-waiting::before {
  background: #fbbf24;
}

.status-badge.status-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.status-badge.status-success::before {
  background: #34d399;
}

.status-badge.status-done {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.status-badge.status-done::before {
  background: #34d399;
}

.status-badge.status-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.status-badge.status-danger::before {
  background: #f87171;
}

.status-badge.status-info {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.status-badge.status-info::before {
  background: #22d3ee;
}

/* ── Process Timeline / Stepper ───────────────────────────── */
.process-timeline {
  position: relative;
  padding-left: var(--space-2xl);
}

.process-timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-default);
}

.timeline-step {
  position: relative;
  padding-bottom: var(--space-xl);
  padding-left: var(--space-lg);
}

.timeline-step:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--space-2xl) + 4px);
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border-default);
  z-index: 2;
  transition: all var(--transition-base);
}

.timeline-step.completed .timeline-dot {
  background: var(--accent-success);
  border-color: var(--accent-success);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.timeline-step.active .timeline-dot {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
  }

  50% {
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.6);
  }
}

.timeline-step .step-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.timeline-step .step-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.timeline-step .step-detail {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.timeline-step.pending .step-title {
  color: var(--text-muted);
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.02em;
}

.form-label .required {
  color: var(--accent-danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  background: var(--bg-input-focus);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.form-check label {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  cursor: pointer;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

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

.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: var(--space-xs) var(--space-sm);
}

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

.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-md);
}

.btn-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-xl);
  animation: fadeIn 200ms ease;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-header h3 {
  font-size: var(--font-size-xl);
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-size-lg);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-xl);
}

.modal-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--space-xs);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-xl);
  overflow-x: auto;
}

.tab-item {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-item:hover {
  color: var(--text-secondary);
}

.tab-item.active {
  color: var(--accent-primary-light);
  border-bottom-color: var(--accent-primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeSlideIn var(--transition-base) ease;
}

/* ── UE Progress Tracker ──────────────────────────────────── */
.ue-tracker {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--bg-glass);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.ue-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.ue-progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  position: relative;
}

.ue-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

.ue-numbers {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  white-space: nowrap;
}

.ue-current {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.ue-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ═══════════════ AUTHENTICATION UI ═══════════════ */
.auth-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-body);
  z-index: 10000;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-2xl);
  animation: fadeIn 0.4s ease-out;
}

.auth-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-header h1 {
  font-size: var(--font-size-2xl);
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: var(--space-xs);
}

.auth-header p {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 600;
}

/* ── SWOT Table ───────────────────────────────────────────── */
.swot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.swot-cell {
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  min-height: 120px;
}

.swot-cell h4 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-sm);
}

.swot-strengths {
  background: rgba(16, 185, 129, 0.05);
}

.swot-strengths h4 {
  color: var(--accent-success);
}

.swot-weaknesses {
  background: rgba(239, 68, 68, 0.05);
}

.swot-weaknesses h4 {
  color: var(--accent-danger);
}

.swot-opportunities {
  background: rgba(59, 130, 246, 0.05);
}

.swot-opportunities h4 {
  color: #60a5fa;
}

.swot-threats {
  background: rgba(245, 158, 11, 0.05);
}

.swot-threats h4 {
  color: var(--accent-warning);
}

.swot-cell ul {
  list-style: none;
  padding: 0;
}

.swot-cell ul li {
  padding: var(--space-xs) 0;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.swot-cell ul li:last-child {
  border-bottom: none;
}

/* ── Search Bar ───────────────────────────────────────────── */
.search-bar {
  position: relative;
  max-width: 360px;
}

.search-bar input {
  width: 100%;
  padding: var(--space-sm) var(--space-md) var(--space-sm) 40px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.search-bar input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* ── Suitability Checklist ────────────────────────────────── */
.suitability-grid {
  display: grid;
  gap: var(--space-md);
}

.suitability-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  align-items: start;
}

.suitability-item .criterion-name {
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--text-primary);
}

.suitability-item .criterion-desc {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.rating-select {
  min-width: 160px;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.3;
}

.empty-state h3 {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.empty-state p {
  font-size: var(--font-size-sm);
  max-width: 400px;
  margin: 0 auto var(--space-lg);
}

/* ── Toast / Notification ─────────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
  animation: toastIn 300ms ease, toastOut 300ms ease 4s forwards;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toast.success {
  border-left: 3px solid var(--accent-success);
}

.toast.error {
  border-left: 3px solid var(--accent-danger);
}

.toast.info {
  border-left: 3px solid var(--accent-info);
}

.toast.warning {
  border-left: 3px solid var(--accent-warning);
}

@keyframes toastIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* ── Agent Research Card ──────────────────────────────────── */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.agent-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
}

.agent-card .agent-type {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary-light);
  margin-bottom: var(--space-sm);
}

.agent-card .agent-prompt {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
}

/* ── Iteration / Version List ─────────────────────────────── */
.version-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.version-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.version-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-default);
}

.version-item.final {
  border-color: var(--accent-success);
  background: rgba(16, 185, 129, 0.05);
}

.version-number {
  width: 32px;
  height: 32px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.version-item.final .version-number {
  background: var(--gradient-success);
}

.version-meta {
  flex: 1;
}

.version-meta h4 {
  font-size: var(--font-size-base);
  font-weight: 600;
}

.version-meta span {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ── Tag / Chip ───────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.tag.tag-primary {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-primary-light);
  border-color: rgba(99, 102, 241, 0.2);
}

.tag.tag-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-success);
  border-color: rgba(16, 185, 129, 0.2);
}

/* ── Utility Classes ──────────────────────────────────────── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-xs {
  gap: var(--space-xs);
}

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

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.gap-xl {
  gap: var(--space-xl);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.mb-xl {
  margin-bottom: var(--space-xl);
}

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

.text-secondary {
  color: var(--text-secondary);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.font-bold {
  font-weight: 700;
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

/* ── Mobile Menu Toggle ───────────────────────────────────── */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-lg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 200px;
  }

  /* Prevent iOS Safari Auto-Zoom */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px;
  }

  /* Optimize Touch Targets */
  .nav-item, .btn {
    min-height: 44px;
  }
  .nav-item {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .swot-grid {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .content-header {
    padding: var(--space-lg);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
    padding-top: calc(var(--space-lg) + 48px);
  }

  .content-body {
    padding: var(--space-lg);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .ue-tracker {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .ue-numbers {
    align-items: center;
  }

  .agent-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    display: block;
    overflow-x: auto;
  }

  .modal {
    margin: var(--space-md);
    max-height: calc(100vh - var(--space-xl));
  }

  .btn-group {
    flex-direction: column;
  }
}

/* ── Scrollbar Styling ────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ── Print ────────────────────────────────────────────────── */
@media print {

  .sidebar,
  .mobile-menu-toggle,
  .toast-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  body {
    background: white;
    color: black;
  }

  .glass-card {
    border: 1px solid #ddd;
    background: white;
  }
}

/* ── Signature Pad ────────────────────────────────────────── */
.signature-container {
  max-width: 100%;
}

.signature-pad-wrapper {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-strong);
  cursor: crosshair;
  overflow: hidden;
  touch-action: none;
  margin: var(--space-md) 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

#signaturePad {
  display: block;
  width: 100%;
  height: 250px;
  background: white;
}

.protocol-content-summary {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  display: grid;
  gap: var(--space-md);
}

.protocol-summary-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
}

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

.protocol-summary-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.protocol-summary-value {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  font-weight: 500;
}

/* ── Verification Badge ───────────────────────────────────── */
.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-success);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

@media (max-width: 640px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  #signaturePad {
    height: 180px;
  }
}

/* ── Suitability & Scales ─────────────────────────────────── */
.scale-container {
  display: flex !important;
  justify-content: space-between;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  background: rgba(255, 255, 255, 0.03);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.scale-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  padding: var(--space-sm) 0;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.scale-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.scale-item input {
  display: none;
}

.scale-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
}

.scale-item input:checked+.scale-dot {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}

.scale-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.scale-item input:checked~.scale-label {
  color: var(--text-primary);
}

.suitability-header-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: rgba(99, 102, 241, 0.05);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

#suitabilityAgeBadge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.age-ok {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #34d399 !important;
}

.age-warning {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
}

/* ── Contract & Print ─────────────────────────────────────── */
#contractPaperCard {
  max-width: 800px;
  margin: 0 auto;
}

/* ── Print Styles ────────────────────────────────────────── */
@media print {

  .sidebar,
  .content-header,
  .search-bar,
  .btn,
  .nav-badge,
  .sidebar-brand {
    display: none !important;
  }

  .app-layout {
    display: block !important;
  }

  /* Professional Document Layout */
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    background: white !important;
  }

  .content-header,
  .sidebar,
  .btn,
  .nav-tabs,
  .no-print {
    display: none !important;
  }

  .content-body {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .glass-card {
    background: white !important;
    border: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
    color: black !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Document specific visibility */
  body * {
    visibility: hidden;
  }

  #view-contract.active,
  #view-contract.active *,
  #view-client-detail.active #protocolPaper,
  #view-client-detail.active #protocolPaper *,
  #view-bp-lab.active #bpPaper,
  #view-bp-lab.active #bpPaper * {
    visibility: visible;
  }

  #view-contract.active,
  #protocolPaper,
  #bpPaper {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    visibility: visible !important;
  }

  #contractPaperCard,
  #protocolPaper,
  #bpPaper {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: white !important;
  }

  h1,
  h2,
  h3,
  h4,
  p,
  span,
  td,
  th {
    color: black !important;
  }

  .signature-area {
    margin-top: 3rem;
    border-top: 1px solid #ccc;
    padding-top: 1rem;
    display: flex;
    justify-content: space-between;
  }

  .signature-box {
    width: 45%;
    text-align: center;
    border-top: 1px solid #000;
    margin-top: 2rem;
    padding-top: 0.5rem;
    font-size: 10pt;
  }

  .page-break {
    page-break-before: always;
  }
}

/* ── Utilities ────────────────────────────────────────────── */
.truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.btn-xs {
  padding: 2px 5px;
  font-size: 0.7rem;
}

.flex {
  display: flex;
}

.justify-between {
  justify-content: space-between;
}

.items-center {
  align-items: center;
}

.mb-xs {
  margin-bottom: var(--space-xs);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mt-md {
  margin-top: var(--space-md);
}

.p-sm {
  padding: var(--space-sm);
}

.p-md {
  padding: var(--space-md);
}

.spinner-sm {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-accent);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 6px;
}

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