/* ============================================================================
   Application shell. Inherits the §1 palette and §3 type stack from
   invoice.css, which loads first.

   §1 approved combinations only:
     Negro sobre Blanco  · default
     Negro sobre Verde Neón · key messages and CALLS TO ACTION
     Blanco sobre Negro  · dark surfaces
   Lime text on black is NOT an approved combination and is not used here.
   ========================================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--niebla);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
.app { display: grid; grid-template-columns: 400px 1fr; min-height: 100vh; }

.editor {
  background: var(--paper);
  border-right: 1px solid var(--soporte);
  padding: 0 22px 60px;
  overflow-y: auto;
  max-height: 100vh;
}

/* Brand bar — blanco sobre negro, with the Verde Neón hairline beneath,
   the same letterhead motif as the document itself. */
.brand {
  display: flex; align-items: center; gap: 12px;
  margin: 0 -22px 18px; padding: 26px 22px 18px;
  background: var(--ink);
  border-bottom: 2px solid var(--lime);
}
/* Isotipo-alone (§2) on the dark brand bar — blanco sobre negro. AR 0.912;
   30px tall ≈ 27px wide, above the 24px digital isotipo minimum. */
.brand .mark { height: 30px; flex: 0 0 auto; }
.brand .mark img { height: 100%; width: auto; display: block; }
.brand h1 {
  font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  margin: 0; font-weight: 700; color: var(--paper);
}
.brand p { margin: 2px 0 0; font-size: 11px; font-weight: 300; color: var(--soporte); }

/* Prefill row — neutral template loaders (EN / ES). */
.prefill { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
.prefill-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--meta); font-weight: 700;
}
.prefill button { flex: 0 0 auto; padding: 6px 12px; }

.tabs { display: flex; gap: 6px; margin-bottom: 4px; }
.tabs button {
  flex: 1; padding: 9px 6px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--soporte); background: var(--paper);
  color: var(--ink); border-radius: 6px; cursor: pointer;
}
/* Selected tab — negro sobre verde neón. */
.tabs button[aria-selected="true"] {
  background: var(--lime); color: var(--ink); border-color: var(--lime);
}

fieldset { border: 0; border-top: 1px solid var(--soporte); padding: 16px 0 4px; margin: 0; }
legend {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--meta); font-weight: 700; padding: 0 8px 0 0;
}
label { display: block; font-size: 11px; font-weight: 700; color: var(--ink); margin: 12px 0 5px; }
input[type="text"], input[type="date"], textarea, select {
  width: 100%; padding: 9px; border: 1px solid var(--soporte); border-radius: 6px;
  font: inherit; font-size: 13px; background: var(--paper); color: var(--ink);
}
textarea { resize: vertical; min-height: 62px; line-height: 1.45; }
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--lime); outline-offset: 1px; border-color: var(--meta);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-card {
  border: 1px solid var(--soporte); border-radius: 8px;
  padding: 10px; margin-top: 10px; background: var(--niebla);
}
.row-card .top { display: flex; gap: 8px; align-items: center; }
.row-card select { flex: 1; font-size: 12px; padding: 6px; }

button {
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  border-radius: 6px; border: 1px solid var(--soporte);
  background: var(--paper); color: var(--ink); padding: 8px 12px;
}
button:hover { border-color: var(--meta); }
button[disabled] { opacity: .5; cursor: default; }
.icon-btn { padding: 5px 9px; line-height: 1.2; }

/* Primary CTA — negro sobre verde neón, the manual's recommended treatment
   for llamados a la acción. */
.btn-dark {
  background: var(--lime); color: var(--ink); border-color: var(--lime);
}
.btn-dark:hover { filter: brightness(.94); border-color: var(--lime); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
#delete-invoice { color: #b00020; border-color: var(--soporte); }
#delete-invoice:hover { border-color: #b00020; }
.hint { font-size: 11px; font-weight: 300; color: var(--meta); margin: 8px 0 0; line-height: 1.5; }
.status { font-size: 11px; min-height: 15px; margin-top: 8px; color: var(--meta); }
.status.error { color: #b00020; font-weight: 700; }

/* Archive */
.archive { padding-top: 12px; }
.archive .search { margin-bottom: 10px; }
.inv-card {
  border: 1px solid var(--soporte); border-radius: 8px; padding: 12px;
  margin-bottom: 8px; background: var(--paper); cursor: pointer;
}
.inv-card:hover { border-color: var(--meta); }
.inv-card.active { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--lime); }
.inv-card .line1 { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 13px; }
.inv-card .line2 {
  color: var(--meta); font-size: 11px; font-weight: 300; margin-top: 4px;
  display: flex; justify-content: space-between; gap: 10px;
}
.pill {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px; background: var(--niebla); color: var(--meta);
}
/* Archived state — negro sobre verde neón. */
.pill.archived { background: var(--lime); color: var(--ink); }
.inv-card .links { margin-top: 8px; display: flex; gap: 10px; }
.inv-card .links a { font-size: 11px; font-weight: 700; color: var(--ink); }
.empty-hint { color: var(--meta); font-size: 12px; font-weight: 300; font-style: italic; padding: 14px 2px; }

.preview { padding: 34px 28px 60px; overflow-y: auto; max-height: 100vh; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .editor { max-height: none; border-right: 0; border-bottom: 1px solid var(--soporte); }
  .preview { max-height: none; padding: 20px 12px 40px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  body { background: var(--paper); }
  .editor { display: none; }
  .app { display: block; }
  .preview { padding: 0; max-height: none; overflow: visible; }
  .sheet { box-shadow: none; max-width: none; padding: 0; min-height: 0; }
  @page { margin: 16mm; }
}
