/* ============================================================
   INVOICE GENERATOR PRO — style.css
   Production-ready stylesheet. Mobile-first responsive.
   Light/Dark mode, print styles, all components.
============================================================ */

/* ─── CSS CUSTOM PROPERTIES ─────────────────────────────── */
:root {
  /* Core palette */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e3a5f;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Semantic tokens — Light Mode */
  --bg-page:       #f8f9fb;
  --bg-surface:    #ffffff;
  --bg-muted:      #f3f4f6;
  --bg-subtle:     #f9fafb;

  --text-primary:  #111827;
  --text-secondary:#4b5563;
  --text-muted:    #9ca3af;

  --border:        #e5e7eb;
  --border-focus:  #2563eb;

  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-light:  #eff6ff;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.1);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --transition: 180ms ease;
  --header-h: 64px;
}

/* ─── DARK MODE ─────────────────────────────────────────── */
body.dark-mode {
  --bg-page:       #0f1117;
  --bg-surface:    #1a1d27;
  --bg-muted:      #22263a;
  --bg-subtle:     #1e2130;

  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #475569;

  --border:        #2d3247;
  --border-focus:  #3b82f6;

  --accent:        #3b82f6;
  --accent-hover:  #2563eb;
  --accent-light:  #1e3050;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.5);
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }

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

/* ─── LAYOUT UTILITIES ──────────────────────────────────── */
.section-inner       { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.section-inner.wide  { max-width: 1400px; }
.section-inner.narrow{ max-width: 860px; }

/* ─── TYPOGRAPHY ────────────────────────────────────────── */
h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: 1.125rem; }

.section-eyebrow {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .75rem;
}

.section-header {
  text-align: center;
  margin-bottom: 3rem;
}
.section-header p {
  margin-top: .75rem;
  color: var(--text-secondary);
  font-size: 1.0625rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  line-height: 1;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-surface); border-color: var(--accent); color: var(--accent); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.btn-sm  { padding: .45rem .875rem; font-size: .8125rem; }
.btn-lg  { padding: .875rem 2rem; font-size: 1rem; }

.btn-group {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
}

/* ─── HEADER ─────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
body.dark-mode .site-header {
  background: rgba(26,29,39,.92);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}
.brand-icon { color: var(--accent); font-size: 1.4rem; }
.brand-name strong { color: var(--accent); }

.header-nav {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
}
.nav-link {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition);
}
.nav-link:hover { color: var(--accent); text-decoration: none; }

.header-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* Theme toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-icon { transition: opacity var(--transition); }
body.light-mode .theme-icon.moon { display: none; }
body.dark-mode  .theme-icon.sun  { display: none; }

/* ─── AD SLOTS ────────────────────────────────────────────── */
.ad-slot {
  background: var(--bg-muted);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .75rem;
  letter-spacing: .05em;
  position: relative;
}
.ad-label { position: absolute; top: .25rem; left: .5rem; font-size: .65rem; opacity: .6; text-transform: uppercase; }
.ad-header  { height: 90px; margin: 0; }
.ad-content { height: 120px; margin: 2rem auto; max-width: 1200px; border-radius: var(--radius); }
.ad-footer  { height: 90px; margin: 0; }
.ad-sidebar { height: 120px; border-radius: var(--radius); margin-bottom: 1rem; }

/* ─── HERO ───────────────────────────────────────────────── */
.hero {
  background: var(--bg-surface);
  padding: 6rem 1.5rem 5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -120px; left: 50%;
  transform: translateX(-50%);
  width: 900px; height: 600px;
  background: radial-gradient(ellipse, var(--blue-50) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
body.dark-mode .hero::before { background: radial-gradient(ellipse, rgba(37,99,235,.12) 0%, transparent 70%); }

.hero-inner { position: relative; z-index: 1; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--accent-light);
  color: var(--accent);
  font-size: .8125rem;
  font-weight: 600;
  padding: .375rem 1rem;
  border-radius: 100px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--blue-100);
}
body.dark-mode .hero-badge { border-color: rgba(59,130,246,.3); }

.hero-headline {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5.5vw, 4rem);
  line-height: 1.15;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}
.hero-headline em {
  font-style: normal;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--blue-100);
  text-underline-offset: 5px;
}

.hero-sub {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 3.5rem;
}

.hero-stats {
  display: inline-flex;
  align-items: center;
  gap: 2rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1rem 2.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.stat { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.stat strong { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); }
.stat span { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-div { width: 1px; height: 36px; background: var(--border); }

/* ─── FEATURES ───────────────────────────────────────────── */
.features {
  padding: 5rem 0;
  background: var(--bg-page);
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: transform var(--transition), box-shadow var(--transition);
}
.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.feature-icon { font-size: 2rem; display: block; margin-bottom: 1rem; }
.feature-card h3 { margin-bottom: .5rem; }
.feature-card p { color: var(--text-secondary); font-size: .9375rem; }

/* ─── GENERATOR SECTION ──────────────────────────────────── */
.generator-section {
  padding: 4rem 0 5rem;
  background: var(--bg-page);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.toolbar-select {
  padding: .45rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  color: var(--text-primary);
  font-size: .8125rem;
  font-weight: 500;
  cursor: pointer;
}
.toolbar-select:focus { outline: 2px solid var(--accent); }

/* App layout */
.app-layout {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ─── EDITOR PANEL ───────────────────────────────────────── */
.editor-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  max-height: calc(100vh - var(--header-h) - 2rem);
  display: flex;
  flex-direction: column;
}

.editor-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
  padding: .25rem .25rem 0;
  gap: .125rem;
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: .625rem .5rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: var(--accent); background: var(--bg-surface); }
.tab-btn.active {
  color: var(--accent);
  background: var(--bg-surface);
  border-bottom-color: var(--accent);
}
.tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.tab-panel {
  display: none;
  overflow-y: auto;
  flex: 1;
  padding: 1.25rem;
}
.tab-panel.active { display: block; }

.form-section { }
.form-section-title {
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.form-row { margin-bottom: .875rem; }
.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.form-group { display: flex; flex-direction: column; gap: .3rem; }

.form-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .02em;
}

.form-input {
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: var(--bg-surface);
}
.form-input::placeholder { color: var(--text-muted); }

.form-textarea { resize: vertical; min-height: 72px; }
.form-select { cursor: pointer; }

/* Color input */
.color-input {
  width: 100%;
  height: 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  cursor: pointer;
  background: var(--bg-subtle);
}

/* Range input */
.range-input {
  width: 100%;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* File label */
.file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .5rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: .8125rem;
  cursor: pointer;
  transition: border-color var(--transition);
  text-align: center;
}
.file-label:hover { border-color: var(--accent); color: var(--accent); }
.file-label:focus-visible { outline: 2px solid var(--accent); }

/* Logo upload area */
.logo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.logo-upload-area:hover, .logo-upload-area:focus-visible {
  border-color: var(--accent);
  background: var(--accent-light);
  outline: none;
}
.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  color: var(--text-muted);
  font-size: .875rem;
}
.logo-placeholder span:first-child { font-size: 2rem; }
.logo-placeholder small { font-size: .75rem; }
.logo-preview-img {
  max-height: 80px;
  max-width: 100%;
  object-fit: contain;
  margin: 0 auto;
}
.logo-controls {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1rem;
}
.align-btn {
  flex: 1;
  padding: .4rem;
  font-size: .75rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.align-btn:hover { border-color: var(--accent); color: var(--accent); }
.align-btn.active { border-color: var(--accent); background: var(--accent); color: #fff; }

/* Items list */
.items-list { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1rem; }

.item-row {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem;
  position: relative;
}
.item-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .625rem;
}
.item-row-number {
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: .2rem .5rem;
  border-radius: 100px;
}
.item-row-actions {
  display: flex;
  gap: .375rem;
}
.item-action-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.item-action-btn:hover { border-color: var(--accent); color: var(--accent); }
.item-action-btn.delete:hover { border-color: #ef4444; color: #ef4444; }

.item-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}
.item-grid .full-width { grid-column: 1 / -1; }

/* ─── PREVIEW PANEL ──────────────────────────────────────── */
.preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
  padding: .5rem .75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.preview-label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
}
.preview-controls { display: flex; gap: .375rem; }
.preview-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-muted);
  font-size: .875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.preview-btn:hover { border-color: var(--accent); }
.preview-btn.active { background: var(--accent); border-color: var(--accent); }

.preview-viewport {
  background: var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 2rem;
  overflow: auto;
  min-height: 500px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transition: background var(--transition);
}
body.dark-mode .preview-viewport { background: #0a0c14; }

.preview-viewport.mobile-view .invoice-wrapper {
  max-width: 375px;
  width: 100%;
}

.invoice-wrapper {
  width: 100%;
  transition: max-width var(--transition);
}

/* ─── INVOICE DOCUMENT STYLES ────────────────────────────── */
.invoice-document {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  font-family: var(--inv-font, 'Inter', sans-serif);
  font-size: var(--inv-font-size, 14px);
  color: var(--inv-body-text, #1f2937);
  overflow: hidden;
  width: 100%;
  min-height: 600px;
}

/* Template color variables applied by JS */
.invoice-document {
  --inv-accent: #2563eb;
  --inv-header-bg: #1e3a5f;
  --inv-header-text: #ffffff;
  --inv-body-text: #1f2937;
  --inv-font: 'Inter', sans-serif;
  --inv-font-size: 14px;
}

/* Invoice header */
.inv-header {
  background: var(--inv-header-bg);
  color: var(--inv-header-text);
  padding: 2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.inv-header.minimal-header {
  background: transparent;
  color: var(--inv-body-text);
  border-bottom: 3px solid var(--inv-accent);
  padding-bottom: 1.5rem;
}
.inv-header.side-stripe {
  border-left: 6px solid var(--inv-accent);
  background: #f8f9fb;
  color: var(--inv-body-text);
}
body.dark-mode .inv-header.side-stripe { background: #1a1d27; }

.inv-logo-wrap { flex-shrink: 0; }
.inv-logo-wrap img { display: block; object-fit: contain; }

.inv-company-info { flex: 1; }
.inv-company-name {
  font-size: 1.25em;
  font-weight: 700;
  margin-bottom: .25rem;
}
.inv-company-detail { font-size: .875em; opacity: .85; line-height: 1.6; }

.inv-invoice-meta { text-align: right; flex-shrink: 0; }
.inv-invoice-title {
  font-size: 2em;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: .5rem;
}
.inv-invoice-number { font-size: 1em; font-weight: 600; opacity: .9; }
.inv-invoice-date { font-size: .875em; opacity: .75; }

.inv-status-badge {
  display: inline-block;
  padding: .2em .7em;
  border-radius: 100px;
  font-size: .75em;
  font-weight: 700;
  margin-top: .5rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.status-paid    { background: #dcfce7; color: #166534; }
.status-unpaid  { background: #fee2e2; color: #991b1b; }
.status-partial { background: #fef3c7; color: #92400e; }

/* Invoice body */
.inv-body { padding: 2rem 2.5rem; }

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid #e5e7eb;
}
.inv-party-label {
  font-size: .7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--inv-accent);
  margin-bottom: .4rem;
}
.inv-party-name { font-weight: 700; font-size: 1em; margin-bottom: .2rem; }
.inv-party-detail { font-size: .875em; color: #6b7280; line-height: 1.6; }

.inv-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 2rem;
  margin-bottom: 2rem;
}
.inv-meta-item { font-size: .875em; }
.inv-meta-item .label { font-weight: 600; color: #6b7280; }
.inv-meta-item .value { color: var(--inv-body-text); }

/* Items table */
.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; font-size: .9em; }
.inv-table thead { }
.inv-table th {
  background: var(--inv-accent);
  color: #fff;
  padding: .625rem 1rem;
  text-align: left;
  font-size: .75em;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.inv-table th.right, .inv-table td.right { text-align: right; }
.inv-table td {
  padding: .625rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  color: var(--inv-body-text);
  vertical-align: top;
}
.inv-table tbody tr:last-child td { border-bottom: none; }
.inv-table tbody tr:nth-child(even) td { background: rgba(0,0,0,.02); }
.inv-table .item-name { font-weight: 600; }
.inv-table .item-desc { font-size: .85em; color: #9ca3af; margin-top: .15rem; }

/* Totals */
.inv-totals {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 2rem;
}
.inv-totals-table { width: 300px; font-size: .9em; }
.inv-totals-row {
  display: flex;
  justify-content: space-between;
  padding: .35rem 0;
  border-bottom: 1px solid #f0f0f0;
}
.inv-totals-row:last-child {
  border-bottom: none;
  font-size: 1.125em;
  font-weight: 700;
  color: var(--inv-accent);
  padding-top: .75rem;
  border-top: 2px solid var(--inv-accent);
  margin-top: .35rem;
}
.inv-totals-row .label { color: #6b7280; }

/* Footer area */
.inv-footer-area { border-top: 1px solid #e5e7eb; padding-top: 1.5rem; }
.inv-notes { margin-bottom: 1rem; }
.inv-notes-label {
  font-size: .75em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--inv-accent);
  margin-bottom: .3rem;
}
.inv-notes-text { font-size: .875em; color: #6b7280; }

.inv-sig-row {
  display: flex;
  gap: 2rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.inv-sig-box {
  flex: 1;
  min-width: 180px;
  text-align: center;
}
.inv-sig-box img {
  max-height: 60px;
  margin: 0 auto .5rem;
}
.inv-sig-line {
  border-top: 1px solid #d1d5db;
  margin-bottom: .25rem;
  margin-top: 2.5rem;
}
.inv-sig-label { font-size: .75em; color: #9ca3af; }

/* Watermark */
.inv-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-35deg);
  font-size: 6em;
  font-weight: 900;
  color: var(--inv-accent);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.invoice-document { position: relative; }

/* Template-specific overrides */
.template-minimal .inv-header.minimal-header .inv-invoice-title { color: var(--inv-accent); }
.template-creative .inv-header { clip-path: polygon(0 0, 100% 0, 100% 80%, 0 100%); padding-bottom: 3.5rem; }

/* ─── TEMPLATES SECTION ──────────────────────────────────── */
.templates-section {
  padding: 5rem 0;
  background: var(--bg-surface);
}
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}
.template-card {
  background: var(--bg-subtle);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  transition: all var(--transition);
  cursor: pointer;
}
.template-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.template-card:focus-visible { outline: 2px solid var(--accent); }
.template-card h3 { margin: .75rem 0 .25rem; font-size: 1rem; }
.template-card p { color: var(--text-muted); font-size: .8125rem; margin-bottom: 1rem; }

/* Template thumbnails */
.template-thumb {
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 90px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}
.t-header { height: 28px; background: var(--accent); }
.t-header.dark { background: #1e3a5f; }
.t-header.minimal { background: transparent; border-bottom: 3px solid var(--accent); }
.t-header.green { background: #059669; }
.t-header.purple { background: #7c3aed; }
.t-header.navy { background: #1e3a5f; }
.t-header.orange { background: #ea580c; }
.t-body { padding: .5rem .75rem; display: flex; flex-direction: column; gap: .375rem; }
.t-line { height: 6px; border-radius: 3px; background: #e5e7eb; }
.t-line.short { width: 60%; }

/* ─── HOW IT WORKS ───────────────────────────────────────── */
.how-section {
  padding: 5rem 0;
  background: var(--bg-page);
}
.steps-grid {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.step-card {
  flex: 1;
  min-width: 220px;
  max-width: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
}
.step-number {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.375rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}
.step-card h3 { margin-bottom: .5rem; }
.step-card p { color: var(--text-secondary); font-size: .9375rem; }
.step-arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
  align-self: center;
  margin-top: -1rem;
}

/* ─── TESTIMONIALS ───────────────────────────────────────── */
.testimonials-section {
  padding: 5rem 0;
  background: var(--bg-surface);
}
.testimonials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.testimonial-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  border-left: 4px solid var(--accent);
}
.testimonial-card p {
  color: var(--text-secondary);
  font-size: .9375rem;
  font-style: italic;
  margin-bottom: 1.25rem;
  line-height: 1.7;
}
.testimonial-card footer { display: flex; flex-direction: column; gap: .2rem; }
.testimonial-card footer strong { color: var(--text-primary); }
.testimonial-card footer span { color: var(--text-muted); font-size: .8125rem; }

/* ─── FAQ ────────────────────────────────────────────────── */
.faq-section { padding: 5rem 0; background: var(--bg-page); }

.faq-list { display: flex; flex-direction: column; gap: .5rem; }

.faq-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.faq-item:hover { border-color: var(--accent); }

.faq-question {
  width: 100%;
  text-align: left;
  padding: 1.125rem 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: .9375rem;
  transition: color var(--transition);
}
.faq-question:hover { color: var(--accent); }
.faq-question:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.faq-arrow {
  flex-shrink: 0;
  font-size: .875rem;
  transition: transform var(--transition);
  color: var(--text-muted);
}
.faq-item.open .faq-arrow { transform: rotate(180deg); }

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding .3s ease;
}
.faq-answer-inner {
  padding: 0 1.25rem 1.125rem;
  color: var(--text-secondary);
  font-size: .9375rem;
  line-height: 1.7;
}
.faq-item.open .faq-answer { max-height: 400px; }

/* ─── CTA ────────────────────────────────────────────────── */
.cta-section { padding: 5rem 0; background: var(--bg-page); }
.cta-card {
  background: linear-gradient(135deg, var(--blue-800) 0%, var(--blue-600) 100%);
  border-radius: var(--radius-xl);
  padding: 4rem 2rem;
  text-align: center;
  color: #fff;
}
.cta-card h2 { color: #fff; margin-bottom: .75rem; }
.cta-card p { color: rgba(255,255,255,.8); font-size: 1.0625rem; margin-bottom: 2rem; }
.cta-card .btn-primary { background: #fff; color: var(--blue-700); }
.cta-card .btn-primary:hover { background: #e0edff; transform: translateY(-2px); }

/* ─── FOOTER ─────────────────────────────────────────────── */
.site-footer {
  background: var(--gray-900);
  color: var(--gray-400);
  padding: 3rem 1.5rem 1.5rem;
}
body.dark-mode .site-footer { background: #080a10; }

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.footer-brand { flex: 1; min-width: 220px; }
.footer-brand .brand { color: #fff; margin-bottom: .75rem; }
.footer-brand p { font-size: .875rem; line-height: 1.6; max-width: 280px; }

.footer-nav {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
}
.footer-col { display: flex; flex-direction: column; gap: .5rem; }
.footer-col h4 { color: #fff; font-size: .875rem; margin-bottom: .25rem; }
.footer-col a { color: var(--gray-400); font-size: .875rem; transition: color var(--transition); }
.footer-col a:hover { color: #fff; text-decoration: none; }

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-700);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .8125rem;
}
.footer-bottom nav { display: flex; gap: 1.5rem; }
.footer-bottom a { color: var(--gray-400); }
.footer-bottom a:hover { color: #fff; text-decoration: none; }

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.0625rem; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: .875rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal-body {
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  flex: 1;
}

.saved-invoice-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  background: var(--bg-subtle);
  gap: 1rem;
  transition: border-color var(--transition);
}
.saved-invoice-item:hover { border-color: var(--accent); }
.saved-invoice-info { flex: 1; }
.saved-invoice-info strong { display: block; font-size: .9375rem; }
.saved-invoice-info span { font-size: .8125rem; color: var(--text-muted); }
.saved-invoice-actions { display: flex; gap: .375rem; }

.modal-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}
.modal-empty span { font-size: 2.5rem; display: block; margin-bottom: .75rem; }

/* ─── TOAST ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  background: var(--gray-900);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: .5rem;
  animation: toastIn .25s ease;
  max-width: 320px;
}
body.dark-mode .toast { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border); }
.toast.success { border-left: 3px solid #22c55e; }
.toast.error   { border-left: 3px solid #ef4444; }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px) scale(.95); }
}
.toast.hiding { animation: toastOut .2s ease forwards; }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 380px 1fr;
  }
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .editor-panel {
    position: static;
    max-height: none;
  }
  .header-nav { display: none; }
  .step-arrow { display: none; }
}

@media (max-width: 640px) {
  .hero-stats { gap: 1rem; padding: .875rem 1.5rem; }
  .stat-div { display: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { justify-content: center; }
  .form-row.two-col { grid-template-columns: 1fr; }
  .inv-parties { grid-template-columns: 1fr; }
  .inv-header { flex-direction: column; }
  .inv-invoice-meta { text-align: left; }
  .hide-mobile { display: none; }
  .inv-table th:nth-child(3),
  .inv-table td:nth-child(3),
  .inv-table th:nth-child(4),
  .inv-table td:nth-child(4) { display: none; }
}

/* ─── PRINT STYLES ───────────────────────────────────────── */
@media print {
  .site-header, .hero, .features, .generator-section > .section-inner > .section-header,
  .toolbar, .editor-panel, .preview-toolbar, .ad-slot,
  .templates-section, .how-section, .testimonials-section,
  .faq-section, .cta-section, .site-footer, .toast-container,
  .modal-overlay, .preview-controls, .ad-sidebar { display: none !important; }

  body { background: #fff !important; }
  .generator-section { padding: 0 !important; }
  .app-layout { grid-template-columns: 1fr !important; }
  .preview-viewport { background: transparent !important; padding: 0 !important; }
  .invoice-document { box-shadow: none !important; }
  .invoice-wrapper { max-width: 100% !important; }
  @page { margin: 1.5cm; }
}

/* ─── ACCESSIBILITY ─────────────────────────────────────────*/
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
