/* =============================================
   FACTURA RÁPIDA — styles.css
   Design System: Refined Minimal / Stripe-Notion-Linear
   ============================================= */

/* --- Google Fonts fallback declaration --- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,400&display=swap');

/* =============================================
   1. DESIGN TOKENS (CSS Variables)
   ============================================= */
:root {
  /* Typography */
  --font-sans: 'Outfit', 'Helvetica Neue', sans-serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --t-fast: 120ms ease;
  --t-base: 200ms ease;
  --t-slow: 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* LIGHT THEME */
[data-theme="light"] {
  --bg-page: #f5f4f0;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8f8f6;
  --bg-surface-3: #f0efeb;
  --border: #e2e0d9;
  --border-focus: #1a56db;
  --text-primary: #111111;
  --text-secondary: #666666;
  --text-muted: #999999;
  --accent: #1a56db;
  --accent-hover: #1347c4;
  --accent-light: #eff4ff;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --green: #059669;
  --green-light: #d1fae5;
  --red: #dc2626;
  --red-light: #fee2e2;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --paypal-blue: #003087;
  --paypal-blue-light: #e8f0fe;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.07), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.05);
  --invoice-bg: #ffffff;
  --invoice-shadow: 0 4px 24px rgba(0,0,0,0.09), 0 1px 4px rgba(0,0,0,0.05);
}

/* DARK THEME */
[data-theme="dark"] {
  --bg-page: #0d0d0f;
  --bg-surface: #18181c;
  --bg-surface-2: #1e1e24;
  --bg-surface-3: #242428;
  --border: #2a2a32;
  --border-focus: #4d7dff;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #4d7dff;
  --accent-hover: #6693ff;
  --accent-light: rgba(77,125,255,0.12);
  --amber: #f59e0b;
  --amber-light: rgba(245,158,11,0.12);
  --green: #10b981;
  --green-light: rgba(16,185,129,0.12);
  --red: #f87171;
  --red-light: rgba(248,113,113,0.12);
  --purple: #a78bfa;
  --purple-light: rgba(167,139,250,0.12);
  --paypal-blue: #5b9cf6;
  --paypal-blue-light: rgba(91,156,246,0.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --invoice-bg: #1c1c22;
  --invoice-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color var(--t-slow), color var(--t-slow);
}

img, svg { display: block; }
button { cursor: pointer; font-family: var(--font-sans); }
input, select, textarea { font-family: var(--font-sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =============================================
   3. PRIVACY BANNER
   ============================================= */
.privacy-banner {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-6);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.privacy-banner__inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.privacy-icon { font-size: 1.1rem; flex-shrink: 0; }

.privacy-banner p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex: 1;
  min-width: 200px;
}

.privacy-banner strong { color: var(--text-primary); }

.privacy-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-shrink: 0;
}

.btn-save-local {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background var(--t-fast);
}
.btn-save-local:hover { background: var(--accent); color: #fff; }

.btn-close-banner {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.btn-close-banner:hover { color: var(--text-primary); background: var(--bg-surface-3); }

/* =============================================
   4. HEADER
   ============================================= */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-6);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.logo-icon { font-size: 1.3rem; }

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-badge {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 100px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.theme-toggle {
  background: var(--bg-surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 1rem;
  transition: background var(--t-fast), transform var(--t-fast);
}
.theme-toggle:hover { background: var(--border); transform: scale(1.05); }

/* =============================================
   5. HERO
   ============================================= */
.hero {
  padding: var(--sp-12) var(--sp-6) var(--sp-8);
  text-align: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.hero-inner { max-width: 680px; margin: 0 auto; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-light);
  color: var(--green);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: var(--sp-5);
  animation: fadeUp 0.5s var(--t-slow) both;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
  margin-bottom: var(--sp-4);
  animation: fadeUp 0.5s 0.1s var(--t-slow) both;
}

.hero-accent {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.65;
  animation: fadeUp 0.5s 0.2s var(--t-slow) both;
}

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

/* =============================================
   6. APP LAYOUT (Split Pane)
   ============================================= */
.app-container {
  max-width: 1280px;
  margin: var(--sp-8) auto;
  padding: 0 var(--sp-6);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
  align-items: start;
}

/* =============================================
   7. FORM PANEL
   ============================================= */
.form-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.form-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  transition: box-shadow var(--t-base);
  animation: fadeUp 0.4s var(--t-slow) both;
}
.form-section:hover { box-shadow: var(--shadow-md); }
.form-section:nth-child(2) { animation-delay: 0.05s; }
.form-section:nth-child(3) { animation-delay: 0.1s; }
.form-section:nth-child(4) { animation-delay: 0.15s; }

.section-legend {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  padding: 0;
  border: none;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot--blue   { background: var(--accent); }
.legend-dot--amber  { background: var(--amber); }
.legend-dot--green  { background: var(--green); }
.legend-dot--purple { background: var(--purple); }
.legend-dot--gray   { background: var(--text-muted); }
/* Dot degradado para el selector de plantillas */
.legend-dot--gradient {
  background: linear-gradient(135deg, #f59e0b 0%, #3b82f6 50%, #10b981 100%);
}

/* Field Groups */
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group--flex2 { flex: 2; }

.field-row {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: 0;
}

.field-row .field-group { flex: 1; }

.form-row {
  display: flex;
  gap: var(--sp-3);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  animation: fadeUp 0.4s var(--t-slow) both;
}
.form-row--header .field-group { flex: 1; }

/* Labels */
label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  background: var(--bg-surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--text-primary);
  width: 100%;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

textarea { resize: vertical; min-height: 64px; }

/* Field spacing within sections */
.form-section .field-group + .field-group,
.form-section .field-row + .field-row,
.form-section .field-row + .field-group,
.form-section .field-group + .field-row {
  margin-top: var(--sp-3);
}

/* =============================================
   8. INVOICE LINES
   ============================================= */
.lines-header {
  display: grid;
  grid-template-columns: 1fr 56px 88px minmax(82px, auto) 28px;
  gap: var(--sp-2);
  padding: 0 4px var(--sp-2);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-2);
}

.invoice-line {
  display: grid;
  grid-template-columns: 1fr 56px 88px minmax(82px, auto) 28px;
  gap: var(--sp-2);
  align-items: center;
  padding: 4px 0;
  animation: lineIn 0.2s var(--t-slow) both;
}

.invoice-line > *,
.lines-header > * {
  min-width: 0;
}

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

.invoice-line input[type="number"] {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.line-total {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
  padding: 10px 8px;
  background: var(--bg-surface-3);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.btn-remove-line {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  flex-shrink: 0;
}
.btn-remove-line:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

.btn-add-line {
  background: none;
  border: 1.5px dashed var(--border);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  width: 100%;
  margin-top: var(--sp-3);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn-add-line:hover { background: var(--accent-light); border-color: var(--accent); }
.btn-add-line span { font-size: 1.1rem; }

/* =============================================
   9. FORM ACTIONS
   ============================================= */
.form-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 9px 16px;
  border: 1.5px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(26,86,219,0.25);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,86,219,0.35); }
.btn--primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn--large { padding: 11px 20px; font-size: 0.95rem; }

.btn--secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn--secondary:hover { background: var(--bg-surface-3); border-color: var(--text-secondary); }

.btn--ghost {
  background: none;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.btn--danger-ghost {
  background: none;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn--danger-ghost:hover { background: var(--red-light); color: var(--red); border-color: var(--red); }

/* =============================================
   10. PREVIEW PANEL
   ============================================= */
.preview-panel {
  position: sticky;
  top: 80px;
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--sp-3);
  padding: 0 var(--sp-1);
}

.preview-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.preview-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green-light);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.preview-live-text {
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 500;
}

/* =============================================
   11. INVOICE PREVIEW
   ============================================= */
.invoice-preview {
  background: var(--invoice-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--invoice-shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow var(--t-slow);
  animation: fadeUp 0.5s 0.2s var(--t-slow) both;
}

/* ─────────────────────────────────────────────
   FIX: elimina tachados en emails y direcciones
   El navegador detecta emails y aplica estilos
   UA que html2canvas captura como tachado.
   Forzamos text-decoration: none en todo el
   documento de factura para el render.
   ───────────────────────────────────────────── */
.inv-document,
.inv-document *,
.inv-document a,
.inv-document a:link,
.inv-document a:visited,
.inv-document a:hover {
  text-decoration: none !important;
  -webkit-text-decoration: none !important;
}

.inv-document {
  padding: 40px 44px;
  font-family: var(--font-sans);
  min-height: 480px;
}

/* Invoice Header */
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.inv-brand {}
.inv-brand-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
}
.inv-brand-nif {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  /* FIX: desactiva la auto-detección de emails */
  unicode-bidi: isolate;
}
.inv-brand-address {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
  /* FIX: max-width ampliado para no cortar direcciones largas */
  max-width: 320px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}

.inv-meta { text-align: right; }
.inv-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  margin-bottom: 8px;
}
.inv-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 4px;
}
.inv-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Client section */
.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.inv-party-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.inv-party-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.inv-party-detail {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-family: var(--font-mono);
  /* FIX: evita recorte de direcciones largas */
  word-break: break-word;
  overflow-wrap: break-word;
  /* FIX: impide que el navegador convierta el texto en enlace */
  unicode-bidi: isolate;
}

/* Lines table */
.inv-lines-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.83rem;
}

.inv-lines-table thead tr {
  background: var(--bg-surface-3);
}

.inv-lines-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.inv-lines-table th:last-child,
.inv-lines-table td:last-child { text-align: right; }
.inv-lines-table th:nth-child(2),
.inv-lines-table td:nth-child(2),
.inv-lines-table th:nth-child(3),
.inv-lines-table td:nth-child(3) { text-align: right; }

.inv-lines-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: top;
}

.inv-lines-table td:nth-child(1) {
  color: var(--text-primary);
  /* FIX: sin max-width fijo, crece con el contenido */
  word-break: break-word;
  overflow-wrap: break-word;
}
.inv-lines-table td:nth-child(2),
.inv-lines-table td:nth-child(3),
.inv-lines-table td:nth-child(4) {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
}

.inv-lines-table tr:last-child td { border-bottom: 2px solid var(--border); }

/* Totals */
.inv-totals {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.inv-totals-table {
  min-width: 220px;
}

.inv-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  padding: 5px 0;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.inv-totals-row span:last-child {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-primary);
  min-width: 90px;
  text-align: right;
}

.inv-totals-row--irpf span:last-child { color: var(--red); }
.inv-totals-row--iva span:last-child { color: var(--green); }

.inv-totals-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.inv-totals-row--total {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  padding: 8px 0 4px;
}

.inv-totals-row--total span:last-child {
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
}

/* Notes & conditions */
.inv-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inv-footer-row {
  display: flex;
  gap: 8px;
  /* FIX: impide que el footer se corte */
  flex-wrap: wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

.inv-footer-row strong {
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 600;
}

.inv-exempt-note {
  color: var(--amber);
  font-size: 0.75rem;
  font-style: italic;
  margin-top: 4px;
}

/* Empty state */
.inv-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
  gap: 12px;
}

.inv-empty-icon { font-size: 3rem; opacity: 0.3; }
.inv-empty-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 200px;
  line-height: 1.5;
}

/* =============================================
   12. TOAST
   ============================================= */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* =============================================
   13. SEO SECTION
   ============================================= */
.seo-section {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-16);
  padding: var(--sp-16) var(--sp-6);
}

.seo-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}

.seo-intro h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
}

.seo-intro p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--sp-3);
}

.seo-guide h3,
.seo-example h3,
.faq-section h3 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
}

.guide-steps {
  padding-left: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.guide-steps li {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-steps li strong { color: var(--text-primary); }

.example-table {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.example-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.example-table th,
.example-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.example-table th {
  background: var(--bg-surface-2);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.example-table td { color: var(--text-secondary); }
.example-table td strong { color: var(--text-primary); }
.example-table tr:last-child td { border-bottom: none; }

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-item summary {
  padding: var(--sp-4) var(--sp-5);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background var(--t-fast);
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--t-base);
}

.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary:hover { background: var(--bg-surface-2); }

.faq-item p {
  padding: 0 var(--sp-5) var(--sp-4);
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  border-top: 1px solid var(--border);
  padding-top: var(--sp-4);
}

/* =============================================
   13b. VERI*FACTU — BLOQUE EN FORMULARIO
   ============================================= */
.verifactu-block {
  background: var(--bg-surface);
  border: 1.5px solid #d97706;
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

[data-theme="dark"] .verifactu-block {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.04);
}

.verifactu-block__header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.verifactu-tag {
  background: #fef3c7;
  color: #92400e;
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

[data-theme="dark"] .verifactu-tag {
  background: rgba(245, 158, 11, 0.18);
  color: #f59e0b;
}

.verifactu-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.verifactu-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.verifactu-desc strong { color: var(--text-primary); }

.btn--verifactu {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #d97706;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--t-fast);
  align-self: flex-start;
}

.btn--verifactu:hover {
  background: #d97706;
  color: #fff;
  border-color: #d97706;
}

.btn--verifactu:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

[data-theme="dark"] .btn--verifactu {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-color: #f59e0b;
}

[data-theme="dark"] .btn--verifactu:hover {
  background: #f59e0b;
  color: #000;
}

.verifactu-chain-info {
  display: none;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 1.5;
}

.verifactu-chain-info code {
  background: var(--bg-surface-3);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.72rem;
  color: #d97706;
}

[data-theme="dark"] .verifactu-chain-info code {
  color: #f59e0b;
}

/* =============================================
   13c. VERI*FACTU — SECCIÓN DISCLAIMER
   ============================================= */
.verifactu-disclaimer {
  background: #fffbeb;
  border-top: 1px solid #fde68a;
  border-bottom: 1px solid #fde68a;
  padding: var(--sp-10) var(--sp-6);
}

[data-theme="dark"] .verifactu-disclaimer {
  background: rgba(245, 158, 11, 0.04);
  border-color: rgba(245, 158, 11, 0.18);
}

.verifactu-disclaimer__inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  gap: var(--sp-5);
  align-items: flex-start;
}

.verifactu-disclaimer__icon {
  font-size: 2rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.verifactu-disclaimer__content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.verifactu-disclaimer__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #92400e;
  letter-spacing: -0.015em;
}

[data-theme="dark"] .verifactu-disclaimer__title {
  color: #f59e0b;
}

.verifactu-disclaimer__content > p {
  font-size: 0.88rem;
  color: #78350f;
  line-height: 1.7;
}

[data-theme="dark"] .verifactu-disclaimer__content > p {
  color: #fcd34d;
}

.verifactu-disclaimer__content > p strong {
  color: #451a03;
}

[data-theme="dark"] .verifactu-disclaimer__content > p strong {
  color: #fbbf24;
}

.verifactu-disclaimer__features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-1);
}

.verifactu-disclaimer__feature {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  border: 1px solid #fde68a;
}

[data-theme="dark"] .verifactu-disclaimer__feature {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(245, 158, 11, 0.15);
}

.feature-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.verifactu-disclaimer__feature strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: #451a03;
  margin-bottom: 4px;
}

[data-theme="dark"] .verifactu-disclaimer__feature strong {
  color: #fbbf24;
}

.verifactu-disclaimer__feature p {
  font-size: 0.78rem;
  color: #78350f;
  line-height: 1.5;
  margin: 0;
}

[data-theme="dark"] .verifactu-disclaimer__feature p {
  color: #fcd34d;
}

.verifactu-disclaimer__link-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.verifactu-disclaimer__link-text a {
  color: #d97706;
  font-weight: 600;
  text-decoration: none;
}

.verifactu-disclaimer__link-text a:hover {
  color: #92400e;
  text-decoration: underline;
}

@media (max-width: 680px) {
  .verifactu-disclaimer__inner {
    flex-direction: column;
  }

  .verifactu-disclaimer__features {
    grid-template-columns: 1fr;
  }
}

/* =============================================
   14. FOOTER
   ============================================= */
.site-footer {
  background: var(--bg-surface-2);
  border-top: 1px solid var(--border);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
}

.footer-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-5);
}

.footer-donation {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6) var(--sp-8);
  width: 100%;
  box-shadow: var(--shadow-sm);
}

.footer-donation__text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 480px;
}

.btn-donate {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: #003087;
  color: #ffffff !important;
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  text-decoration: none !important;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: 0 2px 8px rgba(0, 48, 135, 0.3);
}

.btn-donate:hover {
  background: #002a75;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 48, 135, 0.4);
  text-decoration: none !important;
}

.btn-donate:active { transform: translateY(0); }

[data-theme="dark"] .btn-donate {
  background: #4a7fd4;
  box-shadow: 0 2px 8px rgba(74, 127, 212, 0.35);
}
[data-theme="dark"] .btn-donate:hover {
  background: #5b8fe0;
  box-shadow: 0 4px 14px rgba(74, 127, 212, 0.5);
}

.footer-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
}

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

.footer-copy {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.footer-author {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--t-fast);
  border-bottom: 1px solid transparent;
}

.footer-author:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
  text-decoration: none;
}

/* =============================================
   15. RESPONSIVE
   ============================================= */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
    order: -1;
  }
}

@media (max-width: 768px) {
  .app-container { padding: 0 var(--sp-4); }

  .field-row { flex-direction: column; }

  .hero { padding: var(--sp-8) var(--sp-4) var(--sp-6); }

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

  .form-row { flex-direction: column; }

  .form-actions { flex-direction: column; }
  .form-actions .btn { justify-content: center; }

  .inv-document { padding: 24px 20px; }
  .inv-header { flex-direction: column; gap: 16px; }
  .inv-meta { text-align: left; }
  .inv-parties { grid-template-columns: 1fr; }

  .privacy-banner__inner { flex-direction: column; align-items: flex-start; }

  .lines-header { display: none; }
  .invoice-line {
    grid-template-columns: 1fr 48px 78px minmax(72px, auto) 28px;
    gap: 4px;
  }

  .seo-section { padding: var(--sp-10) var(--sp-4); }

  .footer-donation { padding: var(--sp-5) var(--sp-4); }
}

/* =============================================
   16. PRINT STYLES (PDF Generation)
   ============================================= */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    background: #fff !important;
    color: #111 !important;
    font-family: 'Outfit', Helvetica, sans-serif;
  }

  .privacy-banner,
  .site-header,
  .hero,
  .form-panel,
  .preview-header,
  .preview-panel > .preview-header,
  .seo-section,
  .site-footer,
  .toast,
  button {
    display: none !important;
  }

  .app-container {
    display: block !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .preview-panel {
    position: static !important;
    box-shadow: none !important;
  }

  .invoice-preview {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
  }

  .inv-document {
    padding: 20mm 20mm !important;
    font-size: 10pt !important;
  }

  .inv-title { color: #1a56db !important; }
  .inv-totals-row--total span:last-child { color: #1a56db !important; }
}
