:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #22303e;
  --muted: #66788a;
  --accent: #c1a44d;
  --accent-dark: #966237;
  --border: #e5e9ef;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, #f7f3e8 0%, var(--bg) 100%);
  color: var(--text);
}

.page-shell { max-width: 1280px; margin: 0 auto; padding: 24px; }
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
  padding: 24px;
  background: #243a2f;
  color: #fff;
  border-radius: 18px;
}
.eyebrow { text-transform: uppercase; letter-spacing: 0.2em; font-size: 0.75rem; opacity: 0.8; margin: 0 0 8px; }
.hero h1 { margin: 0 0 8px; font-size: 1.8rem; }
.hero p { margin: 0; max-width: 700px; color: rgba(255,255,255,0.9); }
.back-link { color: white; text-decoration: none; background: rgba(255,255,255,0.14); padding: 10px 14px; border-radius: 999px; }
.layout { display: grid; grid-template-columns: 1.05fr 1fr; gap: 24px; }
.panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(18, 26, 37, 0.08);
}
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.helper-text { margin: -6px 0 16px; color: var(--muted); }
label { display: flex; flex-direction: column; gap: 8px; font-weight: 600; color: var(--text); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fcfcfd;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(193,164,77,.25); border-color: var(--accent); }
.checkboxes { display: flex; flex-wrap: wrap; gap: 14px; margin: 16px 0; }
.checkboxes label { flex-direction: row; align-items: center; font-weight: 500; color: var(--muted); }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.btn { border: none; border-radius: 999px; padding: 10px 16px; font: inherit; cursor: pointer; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #eef2f5; color: var(--text); }
.invoice-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.invoice-preview { border: 1px solid var(--border); border-radius: 16px; padding: 18px; background: #fcfcfd; }
.company-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 14px; border-bottom: 2px solid var(--accent); margin-bottom: 16px; }
.company-bar h3 { margin: 0 0 6px; font-size: 1.15rem; }
.company-bar p { margin: 2px 0; color: var(--muted); font-size: 0.95rem; }
.invoice-badge { background: #f7efe0; color: #7a4f11; padding: 10px 12px; border-radius: 12px; text-align: right; display: flex; flex-direction: column; gap: 4px; }
.invoice-meta { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.client-block, .invoice-details { background: #f8f9fb; padding: 12px 14px; border-radius: 12px; flex: 1; }
.client-block h4, .invoice-details span { margin: 0 0 6px; color: var(--muted); font-size: 0.9rem; }
.client-block p { margin: 4px 0; }
.invoice-details { display: grid; gap: 8px; }
.invoice-details div { display: flex; justify-content: space-between; gap: 10px; }
.invoice-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.invoice-table th, .invoice-table td { border-bottom: 1px solid var(--border); padding: 10px 0; text-align: left; }
.invoice-table th:last-child, .invoice-table td:last-child { text-align: right; }
.totals { margin-top: 16px; display: grid; gap: 8px; }
.totals > div { display: flex; justify-content: space-between; color: var(--muted); }
.totals .grand-total { font-size: 1.1rem; color: var(--text); border-top: 1px solid var(--border); padding-top: 8px; }
.notes { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); }
.small-note { font-size: 0.9rem; margin-top: 6px; color: #8a6b24; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  .hero, .form-panel, .actions, .back-link { display: none !important; }
  .page-shell { padding: 0; }
  .panel { box-shadow: none; border: none; padding: 0; }
  .invoice-preview { border: none; padding: 0; }
}
@media (max-width: 680px) {
  .field-grid { grid-template-columns: 1fr; }
  .hero, .invoice-header, .invoice-meta, .company-bar { flex-direction: column; align-items: flex-start; }
  .invoice-details { width: 100%; }
}

/* CFDI form sections */
.form-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 22px 0 10px;
  padding-bottom: 7px;
  border-bottom: 1.5px solid var(--border);
}
.form-section-title i { font-size: 13px; }
.field-grid .full-width { grid-column: 1 / -1; }
