/* ============================================================
   ANR Subcontract Creation Tool — Design System
   Premium dark-mode interface with glassmorphism accents
   ============================================================ */

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

/* ── CSS Custom Properties ── */
:root {
  /* Core Palette */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-card-hover: #1f2847;
  --bg-elevated: #232d45;
  --bg-input: #151d30;
  
  /* Glass Effect */
  --glass-bg: rgba(26, 32, 53, 0.7);
  --glass-border: rgba(99, 131, 255, 0.15);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  
  /* Accent Colors */
  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-primary-glow: rgba(99, 102, 241, 0.25);
  --accent-secondary: #06b6d4;
  --accent-secondary-glow: rgba(6, 182, 212, 0.2);
  
  /* Status Colors */
  --status-draft: #f59e0b;
  --status-draft-bg: rgba(245, 158, 11, 0.12);
  --status-negotiation: #3b82f6;
  --status-negotiation-bg: rgba(59, 130, 246, 0.12);
  --status-review: #a855f7;
  --status-review-bg: rgba(168, 85, 247, 0.12);
  --status-finalized: #10b981;
  --status-finalized-bg: rgba(16, 185, 129, 0.12);
  
  /* Diff Colors */
  --diff-added: #22c55e;
  --diff-added-bg: rgba(34, 197, 94, 0.12);
  --diff-removed: #ef4444;
  --diff-removed-bg: rgba(239, 68, 68, 0.12);
  --diff-modified: #f59e0b;
  --diff-modified-bg: rgba(245, 158, 11, 0.12);
  
  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #a5b4fc;
  
  /* Borders */
  --border-subtle: rgba(148, 163, 184, 0.1);
  --border-default: rgba(148, 163, 184, 0.15);
  --border-strong: rgba(148, 163, 184, 0.25);
  --border-accent: rgba(99, 102, 241, 0.4);
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  
  /* 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);

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

/* ── Light Mode Theme ── */
[data-theme="light"] {
  /* Core Palette */
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f2f5;
  --bg-elevated: #f8f9fb;
  --bg-input: #f0f2f5;
  
  /* Glass Effect */
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(99, 131, 255, 0.2);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  
  /* Accent Colors */
  --accent-primary: #4f46e5;
  --accent-primary-hover: #6366f1;
  --accent-primary-glow: rgba(79, 70, 229, 0.15);
  --accent-secondary: #0891b2;
  --accent-secondary-glow: rgba(8, 145, 178, 0.1);
  
  /* Status Colors — slightly deeper for light bg */
  --status-draft: #d97706;
  --status-draft-bg: rgba(217, 119, 6, 0.1);
  --status-negotiation: #2563eb;
  --status-negotiation-bg: rgba(37, 99, 235, 0.08);
  --status-review: #7c3aed;
  --status-review-bg: rgba(124, 58, 237, 0.08);
  --status-finalized: #059669;
  --status-finalized-bg: rgba(5, 150, 105, 0.08);
  
  /* Diff Colors — high contrast on light bg */
  --diff-added: #16a34a;
  --diff-added-bg: rgba(22, 163, 74, 0.12);
  --diff-removed: #dc2626;
  --diff-removed-bg: rgba(220, 38, 38, 0.1);
  --diff-modified: #d97706;
  --diff-modified-bg: rgba(217, 119, 6, 0.1);
  
  /* Text */
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-accent: #4f46e5;
  
  /* Borders */
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.18);
  --border-accent: rgba(79, 70, 229, 0.35);
  
  /* Shadows — softer for light mode */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
}

/* Light mode overrides for diff hover */
[data-theme="light"] .diff-change:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* Light mode overrides for diff text readability */
[data-theme="light"] .diff-text .removed {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.08);
}

[data-theme="light"] .diff-text .added {
  color: #15803d;
  background: rgba(22, 163, 74, 0.1);
}

/* ── Theme Toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.theme-toggle-label {
  font-weight: 500;
  font-size: 12px;
}

.theme-toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-base), border-color var(--transition-base);
}

.theme-toggle-track:hover {
  border-color: var(--accent-primary);
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--accent-primary);
  border-radius: 50%;
  transition: transform var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

[data-theme="light"] .theme-toggle-thumb {
  transform: translateX(20px);
}

/* ── Finalized Diff (read-only) ── */
.diff-readonly .diff-change-actions {
  display: none;
}

.diff-readonly .diff-change {
  opacity: 1 !important;
}

.diff-readonly .diff-text .removed {
  text-decoration: none;
}

.diff-readonly .diff-resolution-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin-top: 8px;
}

.diff-resolution-badge.accepted {
  color: var(--diff-added);
  background: var(--diff-added-bg);
}

.diff-resolution-badge.rejected {
  color: var(--diff-removed);
  background: var(--diff-removed-bg);
}

.diff-readonly .diff-comment-display {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 6px;
  padding-left: 12px;
  border-left: 2px solid var(--border-default);
}

/* ── 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;
}

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

/* ── PDF Export Helpers ── */
.pdf-page-break {
  page-break-after: always;
  break-after: page;
  height: 0;
  margin: 0;
  padding: 0;
}

/* Animated background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.06), transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(168, 85, 247, 0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-primary-hover);
}

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

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

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-logo .logo-subtext {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

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

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: var(--space-md) var(--space-sm) var(--space-sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-primary);
}

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

.nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

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

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 16px;
  text-decoration: none;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--diff-removed);
}

/* ── Unauthorized Screen ── */
.unauthorized-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: var(--space-xl);
}

.unauthorized-screen .icon {
  font-size: 64px;
  margin-bottom: var(--space-lg);
}

.unauthorized-screen h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.unauthorized-screen p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 480px;
  margin-bottom: var(--space-lg);
}

/* ── Main Content Area ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top Header Bar ── */
.top-bar {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: var(--space-xl);
  max-width: var(--max-content-width);
  width: 100%;
  margin: 0 auto;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Status Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-draft {
  background: var(--status-draft-bg);
  color: var(--status-draft);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-negotiation {
  background: var(--status-negotiation-bg);
  color: var(--status-negotiation);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-review {
  background: var(--status-review-bg);
  color: var(--status-review);
  border: 1px solid rgba(168, 85, 247, 0.2);
}

.badge-finalized {
  background: var(--status-finalized-bg);
  color: var(--status-finalized);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-cancelled {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

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

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background var(--transition-fast);
}

.btn:hover::after {
  background: rgba(255, 255, 255, 0.05);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  color: white;
  box-shadow: 0 2px 12px var(--accent-primary-glow);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px var(--accent-primary-glow);
  transform: translateY(-1px);
}

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

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--diff-removed);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-finalized);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

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

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  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: 14px;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

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

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

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

/* ── Step Wizard ── */
.wizard {
  margin-bottom: var(--space-xl);
}

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 var(--space-md);
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  position: relative;
}

.wizard-step::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--border-subtle);
  margin: 0 var(--space-sm);
  transition: background var(--transition-base);
}

.wizard-step:last-child::after {
  display: none;
}

.wizard-step.completed::after {
  background: var(--accent-primary);
}

.wizard-step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 2px solid var(--border-default);
  color: var(--text-muted);
  transition: all var(--transition-base);
  flex-shrink: 0;
}

.wizard-step.active .wizard-step-number {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
  box-shadow: 0 0 16px var(--accent-primary-glow);
}

.wizard-step.completed .wizard-step-number {
  background: var(--status-finalized);
  border-color: var(--status-finalized);
  color: white;
}

.wizard-step-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.wizard-step.active .wizard-step-label {
  color: var(--text-primary);
  font-weight: 600;
}

.wizard-step.completed .wizard-step-label {
  color: var(--status-finalized);
}

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

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

.data-table thead th {
  text-align: left;
  padding: var(--space-md) var(--space-md);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

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

.data-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

.data-table tbody td {
  padding: var(--space-md);
  font-size: 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table .subk-number {
  font-weight: 600;
  color: var(--text-accent);
}

.data-table .subk-date {
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Diff Viewer ── */
.diff-container {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.diff-stats {
  display: flex;
  gap: var(--space-lg);
}

.diff-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.diff-stat.additions { color: var(--diff-added); }
.diff-stat.deletions { color: var(--diff-removed); }
.diff-stat.modifications { color: var(--diff-modified); }

.diff-body {
  max-height: 600px;
  overflow-y: auto;
}

.diff-change {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.diff-change:hover {
  background: rgba(255, 255, 255, 0.02);
}

.diff-change.type-added {
  border-left: 3px solid var(--diff-added);
}

.diff-change.type-removed {
  border-left: 3px solid var(--diff-removed);
}

.diff-change.type-modified {
  border-left: 3px solid var(--diff-modified);
}

.diff-change-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.diff-change-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.type-added .diff-change-type { color: var(--diff-added); }
.type-removed .diff-change-type { color: var(--diff-removed); }
.type-modified .diff-change-type { color: var(--diff-modified); }

.diff-text {
  font-size: 14px;
  line-height: 1.7;
  padding: var(--space-md);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
}

.diff-text .added {
  background: var(--diff-added-bg);
  color: var(--diff-added);
  padding: 1px 4px;
  border-radius: 3px;
  text-decoration: none;
}

.diff-text .removed {
  background: var(--diff-removed-bg);
  color: var(--diff-removed);
  padding: 1px 4px;
  border-radius: 3px;
  text-decoration: line-through;
}

.diff-change-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.diff-comment {
  flex: 1;
}

.diff-comment input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 13px;
}

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-primary-glow);
}

.upload-zone-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.6;
}

.upload-zone-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.upload-zone-subtext {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Section Selector (for wizard) ── */
.section-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

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

.section-group-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-accent);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-sm);
}

.section-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.section-item:hover {
  background: rgba(99, 102, 241, 0.05);
}

.section-item-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 40px;
}

.section-item-title {
  font-size: 14px;
  color: var(--text-primary);
  flex: 1;
}

.section-item-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-primary-glow);
  color: var(--accent-primary-hover);
  font-weight: 600;
}

.section-item.reserved {
  opacity: 0.5;
}

.section-item.reserved .section-item-title {
  font-style: italic;
  color: var(--text-muted);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

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

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

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

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

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

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 300px;
  max-width: 420px;
  animation: slideInRight 0.3s ease-out;
}

.toast.success { border-left: 3px solid var(--status-finalized); }
.toast.error { border-left: 3px solid var(--diff-removed); }
.toast.warning { border-left: 3px solid var(--status-draft); }
.toast.info { border-left: 3px solid var(--status-negotiation); }

.toast-message {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

/* ── Loading States ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-3xl);
  color: var(--text-muted);
}

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

.empty-state-icon {
  font-size: 64px;
  margin-bottom: var(--space-lg);
  opacity: 0.3;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  transition: all var(--transition-base);
}

.stat-card:hover {
  border-color: var(--border-default);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.stat-icon.draft { background: var(--status-draft-bg); color: var(--status-draft); }
.stat-icon.negotiation { background: var(--status-negotiation-bg); color: var(--status-negotiation); }
.stat-icon.review { background: var(--status-review-bg); color: var(--status-review); }
.stat-icon.finalized { background: var(--status-finalized-bg); color: var(--status-finalized); }

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Preview Pane ── */
.preview-pane {
  background: white;
  color: #1a1a1a;
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-height: 600px;
  overflow-y: auto;
  font-family: 'Times New Roman', Times, serif;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: var(--shadow-lg);
}

.preview-pane h1 {
  font-size: 20px;
  text-align: center;
  margin-bottom: 16px;
}

.preview-pane h2 {
  font-size: 16px;
  margin-top: 20px;
  margin-bottom: 8px;
}

.preview-pane p {
  margin-bottom: 8px;
  text-align: justify;
}

.preview-pane .reserved {
  color: #999;
  font-style: italic;
}

/* ── Animations ── */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

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

.fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: var(--space-md);
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .wizard-step-label {
    display: none;
  }
  
  .top-bar {
    padding: 0 var(--space-md);
  }
}

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

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

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

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

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--accent-primary-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary-hover);
}

/* ── Section Editor (Admin) ── */
.section-editor {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-lg);
  min-height: 600px;
}

.section-list {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  max-height: 80vh;
}

.section-list-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.section-list-item:hover {
  background: rgba(99, 102, 241, 0.05);
}

.section-list-item.active {
  background: var(--accent-primary-glow);
  border-left: 3px solid var(--accent-primary);
}

.section-list-item-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.section-list-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-top: 2px;
}

.editor-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  overflow-y: auto;
  max-height: 80vh;
}

.variant-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-lg);
}

.variant-tab {
  flex: 1;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
  font-family: var(--font-family);
}

.variant-tab:hover {
  color: var(--text-primary);
}

.variant-tab.active {
  background: var(--accent-primary);
  color: white;
}

/* ── Subcontract Detail View ── */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.detail-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.info-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

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

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

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

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-card);
}

.timeline-item.completed::before {
  background: var(--status-finalized);
}

.timeline-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Hidden utility ── */
.hidden {
  display: none !important;
}

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

/* ── Login Screen ── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100vw;
  background: var(--bg-primary);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-3xl);
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--glass-shadow);
}

.unauthorized-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: var(--space-3xl);
}

/* ── Environment Banner ── */
.env-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(90deg, #f59e0b, #d97706);
  color: #000;
  text-align: center;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.5px;
}

.env-banner ~ .app-layout {
  padding-top: 32px;
}

.env-banner ~ .login-screen {
  padding-top: 32px;
}

/* ── Autocomplete Dropdown ── */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border-subtle);
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--bg-card-hover);
}

.autocomplete-item-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.autocomplete-item-detail {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autocomplete-item .badge {
  font-size: 9px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.autocomplete-save-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent-primary);
  cursor: pointer;
  margin-top: 4px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

.autocomplete-save-link:hover {
  opacity: 1;
  text-decoration: underline;
}
