/* ============================================================
   InvoiceAI — Premium Dark-Mode Design System
   ============================================================ */

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

/* ---------- Design Tokens ---------- */
:root {
  --bg-primary:        hsl(225, 25%, 8%);
  --bg-surface:        hsl(225, 20%, 12%);
  --bg-elevated:       hsl(225, 18%, 16%);
  --accent:            hsl(160, 84%, 52%);
  --accent-hover:      hsl(160, 84%, 60%);
  --accent-glow:       hsla(160, 84%, 52%, 0.15);
  --accent-glow-strong:hsla(160, 84%, 52%, 0.30);
  --text-primary:      hsl(220, 20%, 95%);
  --text-secondary:    hsl(220, 15%, 60%);
  --text-muted:        hsl(220, 10%, 40%);
  --border:            hsl(225, 15%, 18%);
  --border-light:      hsl(225, 15%, 22%);
  --confidence-high:   hsl(160, 84%, 52%);
  --confidence-medium: hsl(45, 93%, 58%);
  --confidence-low:    hsl(0, 84%, 62%);
  --font-primary:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius:            12px;
  --radius-sm:         8px;
  --radius-lg:         16px;
  --radius-xl:         24px;
  --transition:        all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast:   all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm:         0 2px 8px  hsla(225, 50%, 4%, 0.3);
  --shadow-md:         0 4px 16px hsla(225, 50%, 4%, 0.4);
  --shadow-lg:         0 8px 32px hsla(225, 50%, 4%, 0.5);
  --shadow-glow:       0 0 30px  hsla(160, 84%, 52%, 0.12);
}

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

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

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

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, hsla(160, 84%, 52%, 0.04), transparent),
    radial-gradient(ellipse 60% 50% at 80% 50%, hsla(220, 80%, 50%, 0.03), transparent),
    radial-gradient(ellipse 60% 50% at 20% 80%, hsla(280, 60%, 50%, 0.02), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent-glow-strong);
  color: var(--text-primary);
}

/* ---------- Links & Typography ---------- */
a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition-fast);
}
a:hover {
  color: var(--accent-hover);
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: hsla(225, 25%, 8%, 0.72);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.navbar.scrolled {
  background: hsla(225, 25%, 8%, 0.92);
  box-shadow: var(--shadow-md);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-logo .sparkle {
  color: var(--accent);
  font-size: 1.1rem;
  animation: sparkle-pulse 2s ease-in-out infinite;
}

@keyframes sparkle-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(1.2); }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  transition: var(--transition);
}

.nav-links a:hover {
  color: var(--text-primary);
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}

.nav-icon-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.nav-github {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.nav-github:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.nav-github svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: var(--transition);
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero-section {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6rem 2rem 4rem;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: 100px;
  background: var(--accent-glow);
  border: 1px solid hsla(160, 84%, 52%, 0.2);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  animation: fadeInUp 0.6s ease-out;
}

.hero-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-blink 1.5s ease-in-out infinite;
}

@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 1.25rem;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

.gradient-text,
.hero-title .gradient-text {
  background: linear-gradient(135deg, var(--accent) 0%, hsl(150, 70%, 55%) 50%, hsl(130, 80%, 55%) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-red {
  background: linear-gradient(135deg, hsl(0, 84%, 60%) 0%, hsl(350, 75%, 55%) 50%, hsl(340, 80%, 50%) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  max-width: 620px;
  font-size: 1.125rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 3rem;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

/* ---------- Upload Zone ---------- */
.upload-zone {
  position: relative;
  width: 100%;
  max-width: 560px;
  padding: 3.5rem 2rem;
  border-radius: var(--radius-lg);
  background: hsla(225, 20%, 12%, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: var(--transition);
  animation: fadeInUp 0.6s ease-out 0.3s both;
  overflow: hidden;
}

/* Animated gradient border */
.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 2px;
  background: linear-gradient(
    135deg,
    var(--accent),
    hsl(200, 80%, 55%),
    hsl(280, 60%, 55%),
    var(--accent)
  );
  background-size: 300% 300%;
  animation: gradient-rotate 4s ease infinite;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

@keyframes gradient-rotate {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.upload-zone:hover::before {
  opacity: 1;
}

.upload-zone:hover {
  background: hsla(225, 20%, 14%, 0.6);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.upload-zone.drag-over {
  background: hsla(160, 84%, 52%, 0.08);
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 0 40px hsla(160, 84%, 52%, 0.15);
}

.upload-zone.drag-over::before {
  opacity: 1;
  animation-duration: 1.5s;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
  animation: float 3s ease-in-out infinite;
  color: var(--accent);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.upload-text h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.upload-text p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.upload-text .file-types {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.file-type-tag {
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  background: hsla(225, 18%, 16%, 0.8);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Hidden file input */
.file-input-hidden {
  display: none;
}

/* ---------- Sample Buttons ---------- */
.sample-section {
  margin-top: 2rem;
  animation: fadeInUp 0.6s ease-out 0.4s both;
}

.sample-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sample-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.sample-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.825rem;
  font-weight: 500;
  font-family: var(--font-primary);
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.sample-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.sample-btn .emoji {
  font-size: 1rem;
}

/* ============================================================
   RESULTS SECTION
   ============================================================ */
.results-section {
  position: relative;
  z-index: 1;
  display: none;
  padding: 5rem 2rem 4rem;
  animation: fadeIn 0.5s ease-out;
}

.results-section.visible {
  display: block;
}

/* Results header */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.results-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.results-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.8rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.confidence-badge.high {
  background: hsla(160, 84%, 52%, 0.12);
  color: var(--confidence-high);
  border: 1px solid hsla(160, 84%, 52%, 0.2);
}

.confidence-badge.medium {
  background: hsla(45, 93%, 58%, 0.12);
  color: var(--confidence-medium);
  border: 1px solid hsla(45, 93%, 58%, 0.2);
}

.confidence-badge.low {
  background: hsla(0, 84%, 62%, 0.12);
  color: var(--confidence-low);
  border: 1px solid hsla(0, 84%, 62%, 0.2);
}

.results-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Split view */
.results-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* ---------- Document Viewer ---------- */
.document-viewer {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: hsla(225, 20%, 12%, 0.6);
  backdrop-filter: blur(8px);
}

.viewer-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.8rem;
  font-family: var(--font-primary);
}

.page-btn:hover:not(:disabled) {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 60px;
  text-align: center;
}

.canvas-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
  background: hsl(225, 25%, 6%);
}

.canvas-container canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

/* ---------- Extracted Data Panel ---------- */
.extracted-data {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.data-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.data-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.data-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: hsla(225, 18%, 14%, 0.5);
}

.data-card-header .card-icon {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.85rem;
}

.data-card-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-card-body {
  padding: 1.25rem;
}

/* Data fields grid */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.field-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.field-value.empty {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

/* Confidence dots */
.confidence-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.confidence-dot.high   { background: var(--confidence-high); box-shadow: 0 0 4px var(--confidence-high); }
.confidence-dot.medium { background: var(--confidence-medium); box-shadow: 0 0 4px var(--confidence-medium); }
.confidence-dot.low    { background: var(--confidence-low); box-shadow: 0 0 4px var(--confidence-low); }

/* ---------- Line Items Table ---------- */
.table-wrapper {
  overflow-x: auto;
}

.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}

.line-items-table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.line-items-table tbody tr {
  transition: var(--transition-fast);
}

.line-items-table tbody tr:nth-child(even) {
  background: hsla(225, 18%, 14%, 0.3);
}

.line-items-table tbody tr:hover {
  background: hsla(225, 18%, 16%, 0.6);
}

.line-items-table tbody td {
  padding: 0.7rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid hsla(225, 15%, 18%, 0.5);
  white-space: nowrap;
}

.line-items-table tbody td:first-child {
  white-space: normal;
  max-width: 250px;
}

.line-items-table .text-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Totals ---------- */
.totals-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.total-row .total-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.total-row .total-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.total-row.grand-total {
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  border-top: 2px solid var(--accent);
}

.total-row.grand-total .total-label {
  color: var(--text-primary);
  font-weight: 600;
}

.total-row.grand-total .total-value {
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 700;
}

/* Notes */
.notes-content {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 0.75rem 1rem;
  background: hsla(225, 18%, 14%, 0.3);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

/* ============================================================
   EXPORT BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.825rem;
  font-weight: 600;
  font-family: var(--font-primary);
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), hsl(170, 70%, 45%));
  color: hsl(225, 25%, 8%);
  box-shadow: 0 2px 12px hsla(160, 84%, 52%, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px hsla(160, 84%, 52%, 0.35);
}

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

.btn-secondary:hover {
  background: hsla(225, 18%, 20%, 1);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

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

.btn-xero {
  background: linear-gradient(135deg, hsl(195, 85%, 50%), hsl(195, 75%, 40%));
  color: #fff;
  border: 1px solid hsla(195, 85%, 55%, 0.3);
  box-shadow: 0 2px 12px hsla(195, 85%, 50%, 0.2);
}

.btn-xero:hover {
  background: linear-gradient(135deg, hsl(195, 85%, 55%), hsl(195, 75%, 45%));
  transform: translateY(-1px);
  box-shadow: 0 4px 20px hsla(195, 85%, 50%, 0.35);
}

.export-dropdown-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
}

.export-select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23b3b3b3%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem top 50%;
  background-size: 0.65rem auto;
}

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

#export-download {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.btn-icon {
  font-size: 1rem;
  line-height: 1;
}

.btn-new-upload {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-new-upload:hover {
  background: var(--accent-glow);
}

/* ============================================================
   HOW IT WORKS
   ============================================================ */
.how-it-works {
  position: relative;
  z-index: 1;
  padding: 6rem 2rem;
}

.section-header {
  text-align: center;
  margin-bottom: 4rem;
}

.section-header h2 {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.section-header p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  max-width: 1000px;
  margin: 0 auto;
}

.step-card {
  position: relative;
  padding: 2.5rem 2rem;
  background: hsla(225, 20%, 12%, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: var(--transition);
}

.step-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow: var(--shadow-glow), var(--shadow-md);
  background: hsla(225, 20%, 14%, 0.6);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  border: 1px solid hsla(160, 84%, 52%, 0.2);
}

.step-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  display: block;
}

.step-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--text-primary);
}

.step-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Step connector lines */
.step-card:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -1.3rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: var(--text-muted);
  z-index: 2;
}

/* ============================================================
   API KEY MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  background: hsla(225, 25%, 4%, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 2rem;
  animation: fadeIn 0.2s ease-out;
}

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

.modal-content {
  width: 100%;
  max-width: 480px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.5rem 0;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.modal-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.input-group {
  margin-bottom: 1.25rem;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-family: var(--font-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: var(--transition-fast);
  outline: none;
}

.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.settings-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23b3b3b3%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.65rem auto;
  padding-right: 2.5rem;
}

.settings-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.input-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  margin-bottom: 0;
}

.privacy-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: hsla(225, 18%, 14%, 0.5);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.privacy-notice .shield-icon {
  color: var(--accent);
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.privacy-notice p {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ============================================================
   PROCESSING OVERLAY
   ============================================================ */
.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.5rem;
  background: hsla(225, 25%, 4%, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.processing-overlay.visible {
  display: flex;
}

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

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

.processing-status {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

.processing-substatus {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ============================================================
   ERROR TOAST
   ============================================================ */
.error-toast {
  position: fixed;
  top: 80px;
  right: 2rem;
  z-index: 4000;
  display: none;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid hsla(0, 84%, 62%, 0.3);
  border-left: 3px solid var(--confidence-low);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease-out;
}

.error-toast.visible {
  display: flex;
}

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

.error-toast .error-icon {
  color: var(--confidence-low);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.error-toast .error-content {
  flex: 1;
}

.error-toast .error-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.error-toast .error-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.error-toast .close-toast {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: var(--transition-fast);
  font-size: 1rem;
  flex-shrink: 0;
}

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

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  position: relative;
  z-index: 1;
  padding: 3rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-content {
  max-width: 600px;
  margin: 0 auto;
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.footer-brand a {
  font-weight: 600;
  color: var(--text-primary);
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.footer-links a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-privacy {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 440px;
  margin: 0 auto;
}

.footer-privacy .lock-icon {
  color: var(--accent);
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    hsla(225, 18%, 22%, 0.5),
    transparent
  );
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

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

.skeleton-text {
  height: 14px;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 100%; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

.fade-in {
  animation: fadeIn 0.5s ease-out both;
}

.fade-in-up {
  animation: fadeInUp 0.5s ease-out both;
}

/* Staggered children */
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.20s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.30s; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet */
@media (max-width: 1024px) {
  .results-split {
    grid-template-columns: 1fr;
  }

  .document-viewer {
    position: static;
    max-height: 500px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .navbar {
    padding: 0 1rem;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1rem;
    background: hsla(225, 25%, 8%, 0.96);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-toggle {
    display: flex;
  }

  .hero-section {
    padding: 5rem 1.25rem 3rem;
  }

  .hero-title {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .upload-zone {
    padding: 2.5rem 1.5rem;
  }

  .steps-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .step-card:not(:last-child)::after {
    content: '↓';
    right: 50%;
    top: auto;
    bottom: -1.1rem;
    transform: translateX(50%);
  }

  .results-section {
    padding: 5rem 1rem 3rem;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .results-actions {
    width: 100%;
  }

  .results-actions .btn {
    flex: 1;
    justify-content: center;
  }

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

  .sample-buttons {
    flex-direction: column;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .error-toast {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* Small mobile */
@media (max-width: 400px) {
  .hero-title {
    font-size: 1.75rem;
  }

  .upload-zone {
    padding: 2rem 1rem;
  }

  .step-card {
    padding: 2rem 1.5rem;
  }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-accent { color: var(--accent); }
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   ROI CALCULATOR SECTION
   ============================================================ */
.roi-section {
  position: relative;
  z-index: 1;
  padding: 6rem 2rem 4rem;
  max-width: 1000px;
  margin: 0 auto;
}

.roi-card {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2.5rem;
  background: hsla(225, 20%, 12%, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem;
  box-shadow: var(--shadow-lg);
}

.roi-inputs {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  justify-content: center;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.slider-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  border: 1px solid hsla(160, 84%, 52%, 0.15);
}

/* Custom Range Slider */
.roi-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-elevated);
  outline: none;
  margin: 10px 0;
  transition: background 450ms ease-in;
}

.roi-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  background: var(--bg-elevated);
  border-radius: 3px;
}

.roi-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-top: -7px;
  box-shadow: 0 0 10px var(--accent-glow);
  transition: transform 0.1s ease, background-color 0.1s ease;
}

.roi-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: hsl(160, 90%, 60%);
}

.roi-outputs {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  justify-content: center;
}

.roi-outputs .output-card {
  background: hsla(225, 20%, 14%, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-align: center;
  transition: var(--transition);
}

.roi-outputs .output-savings {
  border-color: var(--accent);
  background: hsla(160, 84%, 52%, 0.03);
  box-shadow: var(--shadow-glow);
}

.output-lbl {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.5rem;
}

.output-val-large {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.25rem;
  text-shadow: 0 0 15px var(--accent-glow);
}

.output-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.output-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Tablet Responsive */
@media (max-width: 768px) {
  .roi-card {
    grid-template-columns: 1fr;
    padding: 2rem;
    gap: 2rem;
  }
}

/* ============================================================
   PAIN POINTS SECTION
   ============================================================ */
.pain-section {
  position: relative;
  z-index: 1;
  padding: 6rem 2rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.pain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.pain-card {
  background: hsla(225, 20%, 12%, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pain-card:hover {
  transform: translateY(-5px);
  border-color: hsla(0, 84%, 60%, 0.25);
  box-shadow: 0 10px 30px hsla(0, 84%, 60%, 0.04);
}

.pain-icon-wrapper {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: inline-block;
}

.pain-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pain-card p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}


