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

:root {
  /* Core Colors — Dark Theme (Form Steps) */
  --bg-dark: #070911;
  --bg-deep: #0f1225;
  --card-bg: rgba(15, 18, 37, 0.7);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  
  /* Brand Colors */
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --secondary: #a855f7;
  --accent: #00e5ff;
  
  /* Gradients */
  --grad-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --grad-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
  --grad-text: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
  
  /* Alerts */
  --success: #10b981;
  --error: #ef4444;
  --warn: #f59e0b;
  
  /* Document Theme — Light (Preview) */
  --doc-bg: #f8f9fb;
  --doc-surface: #ffffff;
  --doc-text: #1e293b;
  --doc-text-secondary: #475569;
  --doc-text-muted: #94a3b8;
  --doc-border: #e2e8f0;
  --doc-border-light: #f1f5f9;
  --doc-accent: #4f46e5;
  --doc-accent-light: #eef2ff;
  --doc-success: #059669;
  --doc-success-light: #ecfdf5;
  --doc-warn-light: #fffbeb;
  
  /* Values */
  --r-lg: 20px;
  --r-md: 12px;
  --r-sm: 8px;
  --tr: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: #f1f5f9;
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

h1, h2, h3, .font-heading {
  font-family: 'Outfit', sans-serif;
}

/* ══════════════════════════════════════════════════════════
   BACKGROUND AESTHETICS
   ══════════════════════════════════════════════════════════ */
.bg-mesh {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: 
    radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(168, 85, 247, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(15, 18, 37, 1) 0%, rgba(7, 9, 17, 1) 100%);
  transition: opacity 0.6s ease;
}

/* When preview mode is active, dim the dark background */
body.preview-mode .bg-mesh {
  opacity: 0;
}

body.preview-mode {
  background-color: var(--doc-bg);
}

/* ══════════════════════════════════════════════════════════
   LAYOUT: DASHBOARD SPLIT
   ══════════════════════════════════════════════════════════ */
.app-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
  position: relative;
  z-index: 1;
}

@media (min-width: 1100px) {
  .app-wrapper {
    grid-template-columns: 1fr 380px;
    padding: 40px;
  }
}

/* ══════════════════════════════════════════════════════════
   COMPONENTS: HEADER & NAVIGATION
   ══════════════════════════════════════════════════════════ */
.main-header {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px 0 40px;
}

.logo-box {
  display: inline-flex;
  padding: 15px;
  background: var(--grad-primary);
  border-radius: var(--r-lg);
  margin-bottom: 20px;
  box-shadow: 0 10px 30px var(--primary-glow);
  position: relative;
}

.logo-box::after {
  content: "";
  position: absolute;
  inset: -2px;
  background: var(--grad-primary);
  border-radius: inherit;
  z-index: -1;
  opacity: 0.5;
  filter: blur(10px);
}

.main-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}

.main-header p {
  color: #94a3b8;
  font-size: 1.1rem;
}

/* Preview mode header adjustments */
body.preview-mode .main-header h1 {
  background: linear-gradient(135deg, var(--doc-text) 0%, var(--doc-text-secondary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.preview-mode .main-header p {
  color: var(--doc-text-muted);
}

body.preview-mode .logo-box {
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.2);
}

/* Stepper */
.stepper-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 40px;
  grid-column: 1 / -1;
}

.step-bubble {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: #64748b;
  font-weight: 700;
  transition: var(--tr);
  cursor: pointer;
  position: relative;
}

.step-bubble.active {
  background: var(--grad-primary);
  color: white;
  border-color: transparent;
  transform: scale(1.15);
  box-shadow: 0 0 25px var(--primary-glow);
}

.step-bubble.completed {
  background: var(--success);
  border-color: transparent;
  color: white;
}

.step-bubble::after {
  content: attr(data-label);
  position: absolute;
  top: 55px;
  font-size: 10px;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(10px);
  transition: var(--tr);
}

.step-bubble.active::after {
  opacity: 1;
  transform: translateY(0);
  color: var(--primary);
}

/* Preview mode stepper */
body.preview-mode .step-bubble {
  background: var(--doc-border-light);
  border-color: var(--doc-border);
  color: var(--doc-text-muted);
}

body.preview-mode .step-bubble.active {
  background: var(--grad-primary);
  color: white;
  border-color: transparent;
}

body.preview-mode .step-bubble.completed {
  background: var(--success);
  color: white;
  border-color: transparent;
}

body.preview-mode .step-bubble.active::after {
  color: var(--doc-accent);
}

/* ══════════════════════════════════════════════════════════
   COMPONENTS: FORM CARDS
   ══════════════════════════════════════════════════════════ */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(25px);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 35px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 4px;
  background: var(--grad-primary);
  opacity: 0;
  transition: var(--tr);
}

.glass-card.active::before {
  opacity: 1;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 35px;
}

.icon-wrap {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--glass-bg);
}

.section-head h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.section-head p {
  font-size: 0.9rem;
  color: #94a3b8;
}

/* Form Styles */
.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 25px;
}

@media (min-width: 600px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }
  .full-span { grid-column: 1 / -1; }
}

.input-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-box label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-ctrl {
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 14px 18px;
  color: white;
  font-size: 1rem;
  transition: var(--tr);
  outline: none;
}

.input-ctrl:focus {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Faoliyat Cards Modern */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 15px;
}

.type-card {
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: var(--r-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--tr);
}

.type-card:hover {
  transform: translateY(-5px);
  border-color: rgba(255, 255, 255, 0.2);
}

.type-card.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
  box-shadow: 0 10px 25px var(--primary-glow);
}

.type-card .emoji { font-size: 2.5rem; margin-bottom: 10px; display: block; }
.type-card .name { font-weight: 700; font-size: 0.9rem; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR: SCORECARD
   ══════════════════════════════════════════════════════════ */
.scorecard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sticky-score {
  position: sticky;
  top: 40px;
}

.score-widget {
  background: linear-gradient(135deg, rgba(15, 18, 37, 0.9), rgba(30, 41, 59, 0.9));
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 25px;
  backdrop-filter: blur(15px);
}

.score-widget h3 {
  font-size: 1.1rem;
  margin-bottom: 20px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}

.metrics-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.metric-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--r-sm);
  border-left: 3px solid transparent;
}

.metric-item.positive { border-left-color: var(--success); }
.metric-item.negative { border-left-color: var(--error); }

.m-label { font-size: 0.8rem; color: #94a3b8; }
.m-value { font-weight: 800; font-size: 1.1rem; font-family: 'Outfit'; }

.score-progress {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  margin-top: 25px;
  overflow: hidden;
}

.score-progress-bar {
  height: 100%;
  background: var(--grad-primary);
  width: 0%;
  transition: width 1s ease;
}

/* Preview mode sidebar */
body.preview-mode .score-widget {
  background: var(--doc-surface);
  border-color: var(--doc-border);
  backdrop-filter: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

body.preview-mode .score-widget h3 {
  color: var(--doc-accent);
}

body.preview-mode .metric-item {
  background: var(--doc-border-light);
  border-radius: 8px;
}

body.preview-mode .m-label {
  color: var(--doc-text-secondary);
}

body.preview-mode .m-value {
  color: var(--doc-text);
}

body.preview-mode .score-progress {
  background: var(--doc-border-light);
}

body.preview-mode .glass-card.sidebar-contact-card {
  background: var(--doc-surface);
  border-color: var(--doc-border);
  color: var(--doc-text-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ══════════════════════════════════════════════════════════
   BUTTONS & ACTIONS
   ══════════════════════════════════════════════════════════ */
.action-group {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  gap: 15px;
}

.btn-base {
  padding: 14px 28px;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--tr);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-primary {
  background: var(--grad-primary);
  color: white;
  box-shadow: 0 10px 20px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 15px 30px var(--primary-glow);
}

.btn-outline {
  background: transparent;
  color: #94a3b8;
  border: 2px solid var(--glass-border);
}

.btn-outline:hover {
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
  background: rgba(255, 255, 255, 0.03);
}

/* ══════════════════════════════════════════════════════════
   UTILITIES & ANIMATIONS
   ══════════════════════════════════════════════════════════ */
.form-step { display: none; }
.form-step.active { display: block; animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards; }

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.hidden { display: none !important; }

/* Scrollbar Modern */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }

body.preview-mode ::-webkit-scrollbar-track { background: var(--doc-bg); }
body.preview-mode ::-webkit-scrollbar-thumb { background: var(--doc-border); }

/* Mobile Optimizations */
@media (max-width: 768px) {
  .main-header h1 { font-size: 1.8rem; }
  .glass-card { padding: 25px; }
  .action-group { flex-direction: column-reverse; }
  .btn-base { width: 100%; }
}

/* ══════════════════════════════════════════════════════════
   TABLE PREVIEW: Legacy (for step 3 credit schedule)
   ══════════════════════════════════════════════════════════ */
.preview-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.2);
  margin-top: 10px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  color: #e2e8f0;
}

.preview-table th {
  background: var(--bg-deep);
  color: var(--accent);
  text-align: left;
  padding: 12px 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.preview-table td {
  padding: 10px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.preview-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.preview-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

.preview-table td:last-child, 
.preview-table th:last-child {
  text-align: right;
}

.preview-table-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  margin-top: 30px;
}

.preview-table-title .badge {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
}

.preview-table-title h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}


/* ══════════════════════════════════════════════════════════════
   ██████████████████████████████████████████████████████████████
   STEP 8 — PROFESSIONAL DOCUMENT PREVIEW
   Bank / Investor-Ready | Light Theme | Notion-Stripe Aesthetic
   ██████████████████████████████████████████████████████████████
   ══════════════════════════════════════════════════════════════ */

/* --- Document Container Override for Step 8 --- */
#step8 .glass-card {
  transition: all 0.5s ease;
}

body.preview-mode #step8 .glass-card {
  background: transparent;
  backdrop-filter: none;
  border: none;
  box-shadow: none;
  padding: 0;
  overflow: visible;
}

body.preview-mode #step8 .glass-card::before {
  display: none;
}

body.preview-mode #step8 .section-head {
  display: none;
}

/* --- Document Shell --- */
.doc-preview {
  background: var(--doc-bg);
  border-radius: 16px;
  padding: 32px 0;
  animation: fadeInUp 0.7s ease forwards;
}

/* --- Document Page Card --- */
.doc-page {
  max-width: 860px;
  margin: 0 auto;
  background: var(--doc-surface);
  border: 1px solid var(--doc-border);
  border-radius: 12px;
  box-shadow: 
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 6px 16px rgba(0, 0, 0, 0.04),
    0 24px 60px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

/* --- Document Header (Title Bar) --- */
.doc-header {
  padding: 40px 48px 32px;
  border-bottom: 1px solid var(--doc-border);
  position: relative;
}

.doc-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #4f46e5 0%, #7c3aed 50%, #4f46e5 100%);
  border-radius: 12px 12px 0 0;
}

.doc-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: var(--doc-accent-light);
  color: var(--doc-accent);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.doc-badge-icon {
  width: 6px;
  height: 6px;
  background: var(--doc-accent);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

.doc-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--doc-success-light);
  color: var(--doc-success);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}

.doc-status-dot {
  width: 7px;
  height: 7px;
  background: var(--doc-success);
  border-radius: 50%;
}

.doc-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--doc-text);
  letter-spacing: -0.5px;
  line-height: 1.3;
  margin-bottom: 8px;
}

.doc-subtitle {
  font-size: 0.9rem;
  color: var(--doc-text-muted);
  font-weight: 400;
}

/* --- Document Meta Grid (Loyiha Pasporti) --- */
.doc-meta-section {
  padding: 28px 48px;
  border-bottom: 1px solid var(--doc-border-light);
}

.doc-meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--doc-text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-meta-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--doc-border-light);
}

.doc-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.doc-meta-item {
  padding: 14px 20px;
  border: 1px solid var(--doc-border-light);
  margin: -0.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.2s ease;
}

.doc-meta-item:hover {
  background: var(--doc-border-light);
}

.doc-meta-item:first-child {
  border-radius: 8px 0 0 0;
}

.doc-meta-item:nth-child(2) {
  border-radius: 0 8px 0 0;
}

.doc-meta-key {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--doc-text-muted);
}

.doc-meta-val {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--doc-text);
  word-break: break-word;
}

/* --- KPI Indicator Cards --- */
.doc-kpi-section {
  padding: 28px 48px;
  border-bottom: 1px solid var(--doc-border-light);
}

.doc-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.doc-kpi-card {
  padding: 18px 16px;
  border-radius: 10px;
  border: 1px solid var(--doc-border);
  background: var(--doc-bg);
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.doc-kpi-card:hover {
  border-color: var(--doc-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.08);
}

.doc-kpi-card.positive {
  border-color: rgba(5, 150, 105, 0.2);
  background: var(--doc-success-light);
}

.doc-kpi-card.negative {
  border-color: rgba(239, 68, 68, 0.2);
  background: #fef2f2;
}

.doc-kpi-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--doc-text-muted);
  margin-bottom: 8px;
}

.doc-kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--doc-text);
  letter-spacing: -0.3px;
}

.doc-kpi-card.positive .doc-kpi-value {
  color: var(--doc-success);
}

.doc-kpi-card.negative .doc-kpi-value {
  color: var(--error);
}

.doc-kpi-sub {
  font-size: 0.7rem;
  color: var(--doc-text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* --- Document Tables Section --- */
.doc-tables-section {
  padding: 28px 48px 12px;
}

.doc-table-block {
  margin-bottom: 28px;
  animation: fadeInUp 0.5s ease forwards;
  animation-delay: calc(var(--table-index, 0) * 0.1s);
  opacity: 0;
}

.doc-table-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.doc-table-badge {
  display: inline-flex;
  padding: 3px 10px;
  background: var(--doc-accent);
  color: white;
  border-radius: 6px;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.doc-table-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--doc-text);
  font-family: 'Outfit', sans-serif;
}

.doc-table-wrap {
  border: 1px solid var(--doc-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--doc-surface);
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  color: var(--doc-text);
}

.doc-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.doc-table th {
  background: var(--doc-bg);
  color: var(--doc-text-secondary);
  text-align: left;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--doc-border);
  white-space: nowrap;
}

.doc-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--doc-border-light);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.doc-table tbody tr {
  transition: background 0.15s ease;
}

.doc-table tbody tr:hover {
  background: var(--doc-border-light);
}

.doc-table tbody tr:nth-child(even) {
  background: rgba(248, 249, 251, 0.5);
}

.doc-table tbody tr:nth-child(even):hover {
  background: var(--doc-border-light);
}

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

.doc-table td:last-child,
.doc-table th:last-child {
  text-align: right;
}

.doc-table td:first-child {
  color: var(--doc-text-secondary);
  font-weight: 600;
}

/* --- Document Footer Note --- */
.doc-footer-note {
  padding: 20px 48px 28px;
  border-top: 1px solid var(--doc-border-light);
  text-align: center;
}

.doc-footer-text {
  font-size: 0.78rem;
  color: var(--doc-text-muted);
  line-height: 1.6;
}

.doc-footer-text strong {
  color: var(--doc-text-secondary);
  font-weight: 600;
}

/* --- Payment Section (Step 8, Light Mode) --- */
body.preview-mode .payment-section {
  background: var(--doc-surface);
  border: 1px solid var(--doc-border);
  border-radius: 12px;
  padding: 28px;
  margin-top: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 16px rgba(0, 0, 0, 0.04);
}

body.preview-mode .payment-section .payment-header h3 {
  color: var(--doc-text);
}

body.preview-mode .payment-section .payment-price {
  color: var(--doc-accent);
}

body.preview-mode .payment-section .type-card {
  background: var(--doc-bg);
  border-color: var(--doc-border);
  color: var(--doc-text);
}

body.preview-mode .payment-section .type-card.active {
  background: var(--doc-accent-light);
  border-color: var(--doc-accent);
}

body.preview-mode .payment-section .type-card .name {
  color: var(--doc-text);
}

body.preview-mode .payment-section .type-card:hover {
  transform: translateY(-3px);
  border-color: var(--doc-accent);
}

body.preview-mode #step8 .action-group .btn-outline {
  background: var(--doc-surface);
  border-color: var(--doc-border);
  color: var(--doc-text-secondary);
}

body.preview-mode #step8 .action-group .btn-outline:hover {
  background: var(--doc-bg);
  border-color: var(--doc-text-muted);
  color: var(--doc-text);
}

/* --- Loading Overlay (preserved) --- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 9, 17, 0.95);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}

.loading-overlay.active {
  display: flex;
}

.loading-content {
  text-align: center;
  max-width: 400px;
  padding: 40px;
}

.spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 20px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin-top: 20px;
  overflow: hidden;
}

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

/* --- Autocomplete Dropdown --- */
.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-deep);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  max-height: 380px;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.1),
    0 15px 40px rgba(0, 0, 0, 0.4);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.autocomplete-dropdown::-webkit-scrollbar { width: 6px; }
.autocomplete-dropdown::-webkit-scrollbar-track { background: transparent; }
.autocomplete-dropdown::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}
.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

.autocomplete-dropdown.show {
  display: block;
  animation: acSlideIn 0.2s ease;
}

@keyframes acSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Autocomplete Item --- */
.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.12s ease, padding-left 0.15s ease;
  position: relative;
}

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

/* Hover state */
.autocomplete-item:hover,
.autocomplete-item.ac-active {
  background: rgba(99, 102, 241, 0.1);
}

/* Keyboard active (stronger highlight) */
.autocomplete-item.ac-active {
  background: rgba(99, 102, 241, 0.15);
  padding-left: 20px;
}

.autocomplete-item.ac-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

/* --- Content layout --- */
.ac-content {
  flex: 1;
  min-width: 0;
}

.ac-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-cat {
  font-size: 0.68rem;
  color: #64748b;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}

/* --- Match highlight --- */
.ac-highlight {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  border-radius: 2px;
  padding: 0 1px;
}

/* --- Type emoji badge --- */
.ac-type-badge {
  font-size: 1.2rem;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.autocomplete-item:hover .ac-type-badge,
.autocomplete-item.ac-active .ac-type-badge {
  opacity: 1;
}

/* --- No result state --- */
.autocomplete-no-result {
  padding: 20px 16px;
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 500;
}

/* --- Alert box --- */
.alert {
  padding: 14px 20px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.alert.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* --- Required field star --- */
.req { color: var(--error); }

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 30px 0;
  font-size: 0.8rem;
  color: #475569;
}

body.preview-mode .footer {
  color: var(--doc-text-muted);
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE: Document Preview 
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .doc-header { padding: 28px 24px 24px; }
  .doc-meta-section { padding: 20px 24px; }
  .doc-kpi-section { padding: 20px 24px; }
  .doc-tables-section { padding: 20px 24px 8px; }
  .doc-footer-note { padding: 16px 24px 20px; }

  .doc-meta-grid { grid-template-columns: 1fr; }
  .doc-meta-item:first-child { border-radius: 8px 8px 0 0; }
  .doc-meta-item:nth-child(2) { border-radius: 0; }

  .doc-kpi-grid { grid-template-columns: 1fr; gap: 10px; }

  .doc-title { font-size: 1.3rem; }
  .doc-header-top { flex-direction: column; gap: 10px; }

  .doc-table { font-size: 0.72rem; }
  .doc-table th, .doc-table td { padding: 8px 10px; }

  body.preview-mode .payment-section { padding: 20px; }
}

@media (max-width: 480px) {
  .doc-header { padding: 20px 16px 18px; }
  .doc-meta-section { padding: 16px; }
  .doc-kpi-section { padding: 16px; }
  .doc-tables-section { padding: 16px 16px 4px; }
  .doc-footer-note { padding: 12px 16px 16px; }
  
  .doc-table { font-size: 0.68rem; }
}

@media (min-width: 1100px) {
  /* In preview mode: expand the form area to full width */
  body.preview-mode .app-wrapper {
    grid-template-columns: 1fr 340px;
  }
}
