/* styles.css · Generador Facturas IVA ES/MX/AR · 1000HW
 * Cache-bust: ?v=4
 * Vanilla CSS · mobile-first · paleta 1000HW (void/acid/concrete/softgray/text-light)
 * WCAG 2.1 AA compliant · prefers-reduced-motion respetado
 * Impresión A4 optimizada (@media print) — la factura se imprime como documento limpio.
 */

/* ============================================================
 * 0. CUSTOM PROPERTIES (design tokens)
 * ============================================================ */
:root {
  /* Paleta canónica 1000HW */
  --void:        #050505;
  --concrete:    #1A1A1E;
  --structure:   #2A2A30;
  --acid:        #CCFF00;
  --acid-dim:    #A8CC00;
  --softgray:    #9CA3AF;
  --text-light:  #E5E7EB;
  --text-mid:    #B5B7C0;
  --text-dim:    #6B6E78;
  --danger:      #FF6B6B;
  --warn:        #FFB74D;
  --success:     #4ADE80;
  --info:        #60A5FA;

  /* Tipografía */
  --font-display: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Monaco, Consolas, monospace;
  --font-body:    'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Espaciado */
  --space-1:  4px;
  --space-2:  8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Otros */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 14px;
  --shadow-md: 0 6px 22px rgba(0,0,0,0.45);
  --shadow-lg: 0 14px 50px rgba(0,0,0,0.55);

  /* Transiciones */
  --t-fast: 150ms cubic-bezier(.4,0,.2,1);
  --t-mid:  300ms cubic-bezier(.4,0,.2,1);
  --t-slow: 600ms cubic-bezier(.4,0,.2,1);
}

/* ============================================================
 * 1. RESET + BASE
 * ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background-color: var(--void);
  color: var(--text-light);
  line-height: 1.55;
  font-size: 16px;
  background-image: radial-gradient(circle at 20% 0%, rgba(204, 255, 0, 0.05) 0%, transparent 40%),
                    radial-gradient(circle at 100% 100%, rgba(204, 255, 0, 0.03) 0%, transparent 40%);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-4);
  line-height: 1.2;
}

p { margin: 0 0 var(--space-4); }

a {
  color: var(--acid);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--t-fast);
}
a:hover { color: var(--text-light); }
a:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ============================================================
 * 2. UTILIDADES + ACCESIBILIDAD
 * ============================================================ */
.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;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--acid);
  color: var(--void);
  padding: var(--space-3) var(--space-4);
  z-index: 100;
}
.skip-link:focus {
  left: var(--space-3);
  top: var(--space-3);
}

::selection { background: var(--acid); color: var(--void); }

/* ============================================================
 * 3. LAYOUT (container)
 * ============================================================ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}
@media (min-width: 768px) {
  .container { padding: 0 var(--space-5); }
}

/* ============================================================
 * 4. NAV (sticky top)
 * ============================================================ */
.nav {
  border-bottom: 1px solid var(--structure);
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: var(--space-3) var(--space-4);
  position: sticky;
  top: 0;
  z-index: 40;
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.nav-back {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.nav-back:hover { color: var(--acid); }
.nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.04em;
  color: var(--text-light);
}
.nav-brand .brand-acid { color: var(--acid); }

/* ============================================================
 * 5. HERO
 * ============================================================ */
.hero {
  padding: var(--space-7) 0 var(--space-5);
  border-bottom: 1px solid var(--structure);
}
.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 4px 10px;
  border: 1px solid var(--structure);
  color: var(--text-mid);
  background: var(--concrete);
}
.tag-acid {
  border-color: var(--acid);
  color: var(--acid);
}
.tag-priv {
  color: var(--text-dim);
}

.hero h1 {
  font-size: clamp(32px, 6vw, 52px);
  font-weight: 800;
  line-height: 1.05;
  margin: 0 0 var(--space-4);
  color: var(--text-light);
}
.hero h1 .accent { color: var(--acid); }
.hero-lede {
  font-size: clamp(15px, 2vw, 18px);
  color: var(--text-mid);
  max-width: 60ch;
  margin: 0 0 var(--space-4);
}
.hero-disclaimer {
  font-size: 13px;
  color: var(--text-light);
  background: rgba(255, 183, 77, 0.08);
  border: 1px solid rgba(255, 183, 77, 0.3);
  border-left: 3px solid var(--warn);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-4);
  border-radius: var(--radius-sm);
  max-width: 65ch;
}
.hero-disclaimer strong { color: var(--warn); }

/* ============================================================
 * 6. SECCIÓN TOOL (formulario + preview)
 * ============================================================ */
.tool-section { padding: var(--space-6) 0; }

/* Country selector at top of tool */
.country-bar {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  background: var(--concrete);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  padding: var(--space-4);
}
.country-bar-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-mid);
}
.country-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 600px) {
  .country-options { grid-template-columns: repeat(3, 1fr); }
}
.country-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--void);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--t-fast);
}
.country-option:hover { border-color: var(--text-dim); }
.country-option input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--acid);
  cursor: pointer;
}
.country-option-text { flex: 1; min-width: 0; }
.country-option-name {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-light);
  font-size: 16px;
  display: block;
}
.country-option-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.country-option input:checked + .country-option-text .country-option-name { color: var(--acid); }
.country-option:has(input:checked) {
  border-color: var(--acid);
  background: rgba(204, 255, 0, 0.04);
}

.tool-card {
  background: var(--concrete);
  border: 1px solid var(--structure);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}
.tool-card-inner { position: relative; }

.tool-intro {
  font-size: 15px;
  color: var(--text-mid);
  margin-bottom: var(--space-5);
  max-width: 65ch;
}

/* Field group */
.fieldset {
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--void);
}
.fieldset legend {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--acid);
  padding: 0 var(--space-2);
}
.fieldset-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin: var(--space-2) 0 var(--space-3);
}

/* Form rows */
.form-row {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.form-row label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mid);
  font-weight: 600;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  background: var(--concrete);
  border: 1px solid var(--structure);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-light);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-row textarea { min-height: 60px; resize: vertical; font-family: var(--font-body); font-size: 14px; }
.form-row input:hover,
.form-row select:hover,
.form-row textarea:hover { border-color: var(--text-dim); }
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--acid);
  box-shadow: 0 0 0 3px rgba(204, 255, 0, 0.15);
}
.form-row input::placeholder,
.form-row textarea::placeholder { color: var(--text-dim); }
.form-row input[aria-invalid="true"] {
  border-color: var(--danger);
}

.form-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
}
@media (min-width: 600px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .form-row.full { grid-column: 1 / -1; }
}

.form-row .hint {
  font-size: 12px;
  color: var(--text-dim);
}

.inline-confirm {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: rgba(204, 255, 0, 0.08);
  border: 1px solid var(--acid);
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.inline-confirm button {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  min-width: 44px;
  min-height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--acid);
  background: transparent;
  color: var(--acid);
  transition: all var(--t-fast);
}
.inline-confirm button:hover {
  background: var(--acid);
  color: var(--void);
}
.inline-confirm button.cancel {
  border-color: var(--text-dim);
  color: var(--text-dim);
}
.inline-confirm button.cancel:hover {
  background: var(--text-dim);
  color: var(--void);
}

/* ============================================================
 * 7. LÍNEAS DE FACTURA (tabla dinámica)
 * ============================================================ */
.lines-section {
  background: var(--concrete);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.lines-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-3);
}
.lines-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--acid);
}

.lines-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-3);
}
.lines-table th,
.lines-table td {
  padding: var(--space-2);
  text-align: left;
  border-bottom: 1px solid var(--structure);
  vertical-align: middle;
}
.lines-table th {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mid);
  font-weight: 700;
}
.lines-table input,
.lines-table select {
  width: 100%;
  background: var(--void);
  border: 1px solid var(--structure);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-light);
}
.lines-table input:focus,
.lines-table select:focus {
  outline: none;
  border-color: var(--acid);
  box-shadow: 0 0 0 3px rgba(204, 255, 0, 0.15);
}
.lines-table .col-desc { min-width: 200px; }
.lines-table .col-qty, .lines-table .col-price, .lines-table .col-vat { width: 100px; }
.lines-table .col-subtotal { width: 110px; text-align: right; }
.lines-table td.line-subtotal {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--text-light);
  font-weight: 600;
  white-space: nowrap;
}
.lines-table .col-remove { width: 60px; text-align: center; }
.line-remove-btn {
  background: transparent;
  border: 1px solid var(--structure);
  color: var(--text-mid);
  font-family: var(--font-mono);
  font-size: 16px;
  min-width: 44px;
  min-height: 44px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.line-remove-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}
.lines-mobile-labels td {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-2);
}
@media (max-width: 720px) {
  .lines-table, .lines-table thead, .lines-table tbody, .lines-table tr, .lines-table th, .lines-table td {
    display: block;
  }
  .lines-table thead { display: none; }
  .lines-table tr {
    background: var(--void);
    border: 1px solid var(--structure);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
  }
  .lines-table td {
    border-bottom: 0;
    padding: var(--space-1) 0;
  }
  .lines-table td.line-subtotal {
    text-align: left;
    padding-top: var(--space-2);
    margin-top: var(--space-2);
    border-top: 1px dashed var(--structure);
    display: flex;
    justify-content: space-between;
  }
  .lines-table td.line-subtotal::before {
    content: "Subtotal";
    color: var(--text-mid);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  .lines-table td.col-remove::before {
    content: "";
    margin: 0;
  }
}

.add-line-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: transparent;
  border: 1px dashed var(--structure);
  color: var(--acid);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  transition: all var(--t-fast);
  min-height: 44px;
}
.add-line-btn:hover {
  border-color: var(--acid);
  background: rgba(204, 255, 0, 0.04);
}

/* ============================================================
 * 8. ACCIONES + BOTONES
 * ============================================================ */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 14px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
  min-height: 44px;
  min-width: 44px;
}
.btn-primary { background: var(--acid); color: var(--void); border-color: var(--acid); }
.btn-primary:hover { background: var(--acid-dim); border-color: var(--acid-dim); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--text-light); border-color: var(--structure); }
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text-light); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.form-message {
  font-size: 13px;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  margin-top: var(--space-3);
}
.form-message[data-kind="error"] {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: var(--danger);
}
.form-message[data-kind="warn"] {
  background: rgba(255, 183, 77, 0.1);
  border: 1px solid rgba(255, 183, 77, 0.3);
  color: var(--warn);
}
.form-message[data-kind="info"] {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.3);
  color: var(--info);
}

/* ============================================================
 * 9. PREVIEW FACTURA (oculto hasta submit)
 * ============================================================ */
.preview-wrap {
  margin-top: var(--space-6);
}
.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  gap: var(--space-3);
  flex-wrap: wrap;
}
.preview-title {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--acid);
}
.preview-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.preview-action-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--concrete);
  border: 1px solid var(--structure);
  color: var(--text-light);
  min-height: 36px;
  transition: all var(--t-fast);
}
.preview-action-btn:hover {
  border-color: var(--acid);
  color: var(--acid);
}

.preview-card {
  background: #FFFFFF;
  color: #1F2937;
  border-radius: var(--radius);
  padding: var(--space-5);
  font-family: var(--font-body);
  box-shadow: var(--shadow-md);
  color-scheme: light;
}
.preview-card[hidden] { display: none; }

.preview-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  border-bottom: 2px solid #1F2937;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
}
@media (min-width: 720px) {
  .preview-header { grid-template-columns: 1.4fr 1fr; align-items: start; }
}

.preview-issuer-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: #111827;
  margin: 0 0 var(--space-1);
  letter-spacing: -0.02em;
}
.preview-doc-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: #111827;
  margin: 0 0 var(--space-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
}
.preview-issuer-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #4B5563;
  margin: 0;
  line-height: 1.4;
}

.preview-doc-meta {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #4B5563;
}
.preview-doc-meta-row { display: block; line-height: 1.5; }
.preview-doc-number {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: #111827;
}

.preview-parties {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
@media (min-width: 720px) {
  .preview-parties { grid-template-columns: 1fr 1fr; }
}
.preview-party {
  background: #F9FAFB;
  border-left: 3px solid #CCFF00;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
}
.preview-party-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #6B7280;
  margin: 0 0 var(--space-1);
}
.preview-party-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  margin: 0 0 var(--space-1);
}
.preview-party-line {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #4B5563;
  margin: 0;
  line-height: 1.4;
}

.preview-invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
  font-family: var(--font-body);
}
.preview-invoice-table caption {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #6B7280;
  margin-bottom: var(--space-2);
  caption-side: top;
}
.preview-invoice-table th,
.preview-invoice-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid #E5E7EB;
  text-align: left;
  font-size: 13px;
}
.preview-invoice-table th {
  background: #F3F4F6;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #374151;
  font-weight: 700;
}
.preview-invoice-table td.num,
.preview-invoice-table th.num { text-align: right; }
.preview-invoice-table .col-vat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #6B7280;
  white-space: nowrap;
}

.preview-totals {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-3);
}
.preview-totals-table {
  width: 100%;
  max-width: 380px;
  font-family: var(--font-mono);
  font-size: 13px;
  border-collapse: collapse;
}
.preview-totals-table tr td {
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid #E5E7EB;
}
.preview-totals-table tr td:first-child {
  color: #4B5563;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.preview-totals-table tr td:last-child {
  text-align: right;
  font-weight: 600;
  color: #111827;
}
.preview-totals-table tr.subtotal td { color: #374151; }
.preview-totals-table tr.retention td { color: #6B7280; }
.preview-totals-table tr.vat-line td { color: #374151; }
.preview-totals-table tr.total td {
  border-top: 2px solid #111827;
  border-bottom: 2px solid #111827;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: #111827;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}
.preview-totals-table tr.retention td:last-child::before {
  content: "− ";
  color: var(--danger);
}

.preview-doc-disclaimer {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #6B7280;
  text-align: center;
  margin-top: var(--space-4);
  border-top: 1px dashed #D1D5DB;
  padding-top: var(--space-3);
  font-style: italic;
}

.preview-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--concrete);
  border: 1px dashed var(--structure);
  border-radius: var(--radius);
}

/* ============================================================
 * 10. MODAL — Por qué necesitas validación profesional
 * ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--concrete);
  border: 1px solid var(--structure);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--space-5);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-light);
  margin: 0;
}
.modal-close {
  background: transparent;
  border: 1px solid var(--structure);
  color: var(--text-mid);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 16px;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.modal-close:hover {
  border-color: var(--text-light);
  color: var(--text-light);
}
.modal-body {
  color: var(--text-mid);
  font-size: 14px;
  line-height: 1.6;
}
.modal-body p { margin: 0 0 var(--space-3); }
.modal-body ul { padding-left: var(--space-5); margin: var(--space-3) 0; }
.modal-body li { margin-bottom: var(--space-2); }

/* ============================================================
 * 11. SECCIONES DE CONTENIDO CORTO
 * ============================================================ */
.content-section {
  margin-top: var(--space-7);
  padding: var(--space-6) 0;
  border-top: 1px solid var(--structure);
}
.content-section h2 {
  font-size: clamp(22px, 3.5vw, 28px);
  margin: 0 0 var(--space-4);
  color: var(--text-light);
}
.content-section h3 {
  font-size: 17px;
  margin: var(--space-5) 0 var(--space-3);
  color: var(--text-light);
}
.content-section p,
.content-section li {
  color: var(--text-mid);
  font-size: 15px;
}
.content-section ul,
.content-section ol {
  padding-left: var(--space-5);
  margin: var(--space-3) 0 var(--space-4);
}
.content-section li { margin-bottom: var(--space-2); }

.nota {
  font-size: 13px;
  color: var(--text-dim);
  border-left: 3px solid var(--structure);
  padding-left: var(--space-3);
  margin: var(--space-4) 0;
}

.callout-pro {
  background: rgba(255, 183, 77, 0.08);
  border: 1px solid rgba(255, 183, 77, 0.25);
  border-left: 3px solid var(--warn);
  padding: var(--space-4);
  border-radius: var(--radius);
  margin: var(--space-4) 0;
}
.callout-pro h3 {
  margin: 0 0 var(--space-3);
  color: var(--warn);
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.callout-pro p {
  color: var(--text-mid);
  margin: 0 0 var(--space-2);
  font-size: 14px;
}
.callout-pro button {
  margin-top: var(--space-2);
  background: transparent;
  border: 1px solid var(--warn);
  color: var(--warn);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 36px;
  transition: all var(--t-fast);
}
.callout-pro button:hover {
  background: rgba(255, 183, 77, 0.12);
}

/* ============================================================
 * 12. FAQ
 * ============================================================ */
.faq details {
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  background: var(--concrete);
  transition: border-color var(--t-fast);
}
.faq details[open] { border-color: var(--acid); }
.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-light);
  padding: var(--space-2) 0;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--acid);
  transition: transform var(--t-fast);
}
.faq details[open] summary::after { content: '−'; }
.faq summary:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
  border-radius: 2px;
}
.faq p {
  margin-top: var(--space-3);
  color: var(--text-mid);
}

/* ============================================================
 * 13. GLOSARIO
 * ============================================================ */
.glossary {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
  margin-top: var(--space-4);
}
@media (min-width: 720px) {
  .glossary { grid-template-columns: 1fr 1fr; }
}
.glossary dt {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--acid);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-1);
}
.glossary dd {
  margin: 0 0 var(--space-3);
  font-size: 14px;
  color: var(--text-mid);
}

/* ============================================================
 * 14. FOOTER
 * ============================================================ */
footer {
  border-top: 1px solid var(--structure);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: var(--space-7);
}
footer p { margin: 0 0 var(--space-1); }

/* ============================================================
 * 15. BANNER OFFLINE-READY
 * ============================================================ */
.offline-banner {
  position: fixed;
  top: var(--space-3);
  left: 50%;
  transform: translate(-50%, -200%);
  z-index: 60;
  max-width: 92vw;
  width: 560px;
  background: var(--concrete);
  border: 1px solid var(--acid);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-lg);
  transition: transform var(--t-slow);
}
.offline-banner[hidden] { display: none !important; }
.offline-banner.is-visible { transform: translate(-50%, 0); }
.offline-banner-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-light);
}
.offline-banner-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--acid);
  color: var(--void);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-mono);
}
.offline-banner-close {
  background: transparent;
  border: 1px solid var(--structure);
  color: var(--text-mid);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-family: var(--font-mono);
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.offline-banner-close:hover {
  border-color: var(--text-light);
  color: var(--text-light);
}

/* ============================================================
 * 16. DONATION TOAST
 * ============================================================ */
.donation-toast {
  position: fixed;
  bottom: var(--space-3);
  right: var(--space-3);
  z-index: 50;
  max-width: 92vw;
  width: 380px;
  background: var(--concrete);
  border: 1px solid var(--structure);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(40px);
  transition: opacity var(--t-mid), transform var(--t-mid);
}
.donation-toast[hidden] { display: none !important; }
.donation-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.donation-toast-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.donation-toast-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: var(--acid);
  color: var(--void);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.donation-toast-content { flex: 1; min-width: 0; }
.donation-toast-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-light);
  margin: 0 0 2px;
}
.donation-toast-subtitle {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-mid);
  line-height: 1.4;
  margin: 0;
}
.donation-toast-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-left: var(--space-3);
  border-left: 1px solid var(--structure);
}
.donation-toast-donate {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--acid);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}
.donation-toast-donate:hover {
  color: var(--text-light);
  text-decoration: underline;
}
.donation-toast-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}
.donation-toast-close:hover { color: var(--text-light); }

@media (max-width: 480px) {
  .donation-toast { width: calc(100vw - 24px); right: 12px; bottom: 12px; }
}

/* ============================================================
 * 17. REDUCED MOTION
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
 * 18. FOCUS VISIBLE (regla global)
 * ============================================================ */
:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 2px;
}

/* ============================================================
 * 19. IMPRESIÓN — la factura sale como A4 limpio sin chrome
 * ============================================================ */
@media print {
  body { background: white; color: #111827; }
  /* Ocultar todo lo que no es la factura */
  .nav,
  .country-bar,
  .fieldset,
  .lines-section,
  .form-actions,
  .form-message,
  .offline-banner,
  .donation-toast,
  .modal-backdrop,
  footer,
  .content-section,
  .hero,
  .tool-intro,
  .country-bar + .tool-card > .tool-card-inner > .tool-intro,
  .callout-pro,
  .preview-bar {
    display: none !important;
  }
  .preview-card {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }
  /* Botón "Imprimir" del preview no debe aparecer */
  .preview-bar { display: none !important; }
  .preview-wrap { margin: 0; }
  @page {
    size: A4;
    margin: 18mm;
  }
  /* Evitar saltos feos */
  .preview-parties,
  .preview-invoice-table,
  .preview-totals {
    break-inside: avoid;
  }
  a { color: #111827; text-decoration: none; }
}
