/* gestlance: mobile-first styles. Tokens first; every later screen reuses them. */

:root {
  color-scheme: light dark;
  --brand: #2952e3;
  --brand-strong: #1f3fb8;
  --brand-soft: #e8edfd;
  --on-brand: #ffffff;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #15171c;
  --muted: #5d6472;
  --border: #dde1e8;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --warn: #a15c00;
  --warn-soft: #fff4e0;
  --ok: #1b7a3d;
  --ok-soft: #e6f5ec;
  --focus: #2952e3;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.625rem;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --radius: 14px;
  --radius-sm: 10px;
  --touch: 48px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / 18%);
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7b97ff;
    --brand-strong: #a3b6ff;
    --brand-soft: #1d2647;
    --on-brand: #0b1020;
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #eceef2;
    --muted: #a0a7b4;
    --border: #2e333d;
    --danger: #ff8a80;
    --danger-soft: #3a1d1d;
    --warn: #ffc069;
    --warn-soft: #3a2a12;
    --ok: #74d39a;
    --ok-soft: #15301f;
    --focus: #9fb3ff;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgb(0 0 0 / 50%);
  }
}

/* --- base ------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- top bar ------------------------------------------------------------------------ */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: 56px;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  padding-top: max(var(--sp-2), env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.topbar h1 { font-size: var(--fs-xl); font-weight: 700; flex: 1; }
.topbar .sub { display: block; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); margin-top: 2px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--touch); height: var(--touch);
  border-radius: 50%;
  color: var(--text);
  text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }

/* --- page --------------------------------------------------------------------------- */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--sp-2) var(--sp-4) calc(var(--nav-h) + var(--safe-bottom) + 88px);
}
.page.bare { padding-bottom: calc(var(--sp-6) + var(--safe-bottom)); }

.section-title {
  margin: var(--sp-5) 0 var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title:first-child { margin-top: var(--sp-2); }

/* --- cards -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-4);
}
.card + .card { margin-top: var(--sp-3); }
.card h3 { font-size: var(--fs-md); font-weight: 650; }
.card p { margin: var(--sp-1) 0 0; color: var(--muted); }
.card .actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }

.alert-card { border-left: 4px solid var(--brand); }
.alert-card.k-vencida { border-left-color: var(--danger); }
.alert-card.k-hacienda { border-left-color: var(--warn); }
.alert-card.k-vence_pronto { border-left-color: var(--warn); }

.empty {
  text-align: center;
  padding: var(--sp-6) var(--sp-4) var(--sp-5);
}
.empty .check {
  display: inline-grid; place-items: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
  margin-bottom: var(--sp-3);
}
.empty .check svg { width: 32px; height: 32px; }
.empty h2 { font-size: var(--fs-lg); }
.empty p { margin: var(--sp-1) 0 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--sp-3) var(--sp-2); text-align: center; min-width: 0;
}
.stat .label { display: block; font-size: var(--fs-xs); color: var(--muted); }
.stat .value { display: block; font-weight: 700; font-size: var(--fs-md); margin-top: 2px;
               overflow-wrap: anywhere; }

/* --- buttons ------------------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  background: var(--brand); color: var(--on-brand);
}
.btn { white-space: nowrap; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { background: var(--brand-strong); }
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--border); }
.btn.block { display: flex; width: 100%; min-height: var(--touch); }
.btn[disabled] { opacity: 0.6; }

/* --- forms -------------------------------------------------------------------------- */

.form { display: grid; gap: var(--sp-4); }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 600; font-size: var(--fs-sm); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .error { font-size: var(--fs-sm); color: var(--danger); font-weight: 600; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); align-items: start; }
.row.r-1-2 { grid-template-columns: 1fr 2fr; }

input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem; /* >= 16px: no zoom on focus in mobile browsers */
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
input[type=color] {
  width: var(--touch); height: var(--touch); padding: 2px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.color-row { display: flex; align-items: center; gap: var(--sp-3); }

.switch {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: var(--touch);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.switch .text { display: grid; }
.switch .text small { color: var(--muted); font-size: var(--fs-xs); }
.switch input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }

.file {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
}
.file input[type=file] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file input[type=file]:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

.form-error {
  padding: var(--sp-3); border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--danger); font-weight: 600;
}
.note {
  padding: var(--sp-3); border-radius: var(--radius-sm);
  background: var(--brand-soft); color: var(--text); font-size: var(--fs-sm);
}

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: var(--sp-2); }

/* --- bottom nav + "+" --------------------------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 44px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current=page] { color: var(--brand); }
.tabbar a[aria-current=page] svg { background: var(--brand-soft); border-radius: 999px; padding: 4px 16px; box-sizing: content-box; }

.fab {
  position: fixed; z-index: 21;
  right: max(var(--sp-4), calc((100vw - 640px) / 2 + var(--sp-4)));
  bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--sp-4));
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border: 0; border-radius: 18px;
  background: var(--brand); color: var(--on-brand);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}
.fab svg { width: 28px; height: 28px; }
.fab:active { background: var(--brand-strong); }

.sheet {
  position: fixed; inset: auto 0 0 0;
  width: 100%; max-width: 640px; margin: 0 auto;
  border: 0; border-radius: 20px 20px 0 0;
  padding: var(--sp-2) var(--sp-4) calc(var(--sp-4) + var(--safe-bottom));
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgb(0 0 0 / 40%); }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto var(--sp-3); }
.sheet h2 { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.sheet ul { list-style: none; margin: 0; padding: 0; }
.sheet a {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 56px; padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 600;
}
.sheet a:active { background: var(--surface-2); }
.sheet a .ic {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand);
}
.sheet a .ic svg { width: 22px; height: 22px; }
.sheet .close { margin-top: var(--sp-2); }

/* --- login / onboarding -------------------------------------------------------------- */

.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + var(--safe-bottom));
}
.auth .box { width: 100%; max-width: 380px; }
.brandmark { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.brandmark img { width: 72px; height: 72px; border-radius: 18px; }
.brandmark h1 { font-size: var(--fs-xl); }
.brandmark p { margin: 0; color: var(--muted); }

.steps { margin: var(--sp-2) 0 var(--sp-4); }
.steps .label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.steps .bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.steps .bar span { height: 6px; border-radius: 3px; background: var(--border); }
.steps .bar span.on { background: var(--brand); }
.intro { margin: 0 0 var(--sp-4); color: var(--muted); }
.form-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-2); }
.form-actions .btn { flex: 1; min-height: var(--touch); }
.form-actions .btn.ghost { flex: 0 0 auto; }

.quarters { width: 100%; border-collapse: collapse; table-layout: fixed; }
.quarters th:first-child { width: 2.5em; }
.quarters th { text-align: left; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; padding: 0 0 6px; }
.quarters td { padding: 0 0 var(--sp-3); vertical-align: top; }
.quarters td + td, .quarters th + th { padding-left: var(--sp-3); }
.quarters td:first-child { font-weight: 700; padding-top: 12px; width: 2.5em; }

/* --- clients ------------------------------------------------------------------------- */

.note.warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; margin-bottom: var(--sp-3); }
.search { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.search input { flex: 1; min-width: 0; }
.search .btn { min-height: var(--touch); }
input[type=search], textarea {
  width: 100%; min-height: var(--touch); padding: 10px var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 1rem;
}
.filter-line { margin: 0 0 var(--sp-3); font-size: var(--fs-sm); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.row-link {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  min-height: 60px; padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text); text-decoration: none;
}
.row-link:active { background: var(--surface-2); }
.row-link .main { display: grid; min-width: 0; }
.row-link .title { font-weight: 650; overflow-wrap: anywhere; }
.row-link .meta { font-size: var(--fs-xs); color: var(--muted); }
.row-link .side { display: grid; text-align: right; flex: none; }
.amount.due { font-weight: 700; color: var(--warn); }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); font-weight: 600;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.facts { margin: 0; display: grid; gap: var(--sp-3); }
.facts div { display: grid; gap: 2px; }
.facts dt { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions-row { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.stat .label { overflow-wrap: anywhere; }

/* --- invoices ------------------------------------------------------------------------ */

.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.note.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; margin-bottom: var(--sp-3); }
.form-error { margin: 0 0 var(--sp-3); }
.form-error a { color: inherit; }

.chips {
  display: flex; gap: var(--sp-2); overflow-x: auto; margin: 0 calc(-1 * var(--sp-4)) var(--sp-3);
  padding: 2px var(--sp-4); scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); text-decoration: none; font-size: var(--fs-sm); font-weight: 600;
}
.chip[aria-current] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.row-link .side-meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-top: 2px; }

button.row-link { width: 100%; font: inherit; text-align: left; cursor: pointer; }
.client-pick { margin-bottom: var(--sp-2); }
.client-pick .side { max-width: 45%; overflow-wrap: anywhere; }

.btn.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); color: #fff; }
.stack-actions { display: grid; gap: var(--sp-2); margin-top: var(--sp-5); }

/* editor lines */
.lines { display: grid; gap: var(--sp-3); }
.line {
  display: grid; gap: var(--sp-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--sp-3);
}
.line.is-pct { border-style: dashed; }
.line-head { display: flex; gap: var(--sp-1); align-items: center; }
.line-head input { flex: 1; min-width: 0; font-weight: 600; }
.line-head .icon-btn { flex: none; color: var(--muted); }
.line-head .icon-btn svg { width: 20px; height: 20px; }
.line-grid { display: grid; grid-template-columns: 1fr 0.9fr 1.3fr; gap: var(--sp-2); }
.line-grid .wide { grid-column: 1 / -1; }
.line.is-pct .line-grid { grid-template-columns: 1fr; }
.mini { display: grid; gap: 2px; min-width: 0; }
.mini > span { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.mini input, .mini select { min-height: 44px; padding: 8px 10px; }
.line-foot { display: flex; align-items: end; justify-content: space-between; gap: var(--sp-3); }
.line-foot .vat { width: 7.5em; }
.line-amount { font-weight: 700; font-size: var(--fs-md); padding-bottom: 10px; }
.line .exempt { display: none; }
.line:has(select[name=vat] option[value="0"]:checked) .exempt { display: grid; }
.line-add { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.line-add .btn { flex: 1 1 auto; }
.legend { margin: 0; }

.totals dl, .totals-list { margin: 0; display: grid; gap: 6px; }
.totals dl div, .totals-list div { display: flex; justify-content: space-between; gap: var(--sp-3); }
.totals dt, .totals-list dt { color: var(--muted); }
.totals dd, .totals-list dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals .grand, .totals-list .grand {
  margin-top: 4px; padding-top: var(--sp-2); border-top: 1px solid var(--border);
  font-weight: 700; font-size: var(--fs-lg);
}
.totals .grand dt, .totals-list .grand dt { color: var(--text); }

/* sheets */
.sheet.tall { max-height: 92dvh; overflow-y: auto; }
.sheet .form { gap: var(--sp-3); }
.sheet > p { margin: 0 0 var(--sp-3); }
.sheet-number { font-size: var(--fs-lg); }
.sheet-number strong { color: var(--brand); }
.sheet .share-btn { margin-top: var(--sp-2); }
.sheet .share-btn[hidden] { display: none; }

/* detail */
.summary { text-align: center; }
.summary-top { display: flex; gap: var(--sp-2); justify-content: center; }
.summary .total-big { margin: var(--sp-2) 0 var(--sp-1); font-size: 2.25rem; font-weight: 750; color: var(--text); }
.summary .summary-meta { margin: 2px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.summary .summary-meta strong { color: var(--text); }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin: var(--sp-3) 0; }
.action-grid .btn { min-height: var(--touch); }
.action-grid > :only-child, .action-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.inv-lines { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; gap: var(--sp-3); }
.inv-lines li { display: flex; justify-content: space-between; gap: var(--sp-3); }
.inv-lines .main { display: grid; min-width: 0; }
.inv-lines .title { font-weight: 600; overflow-wrap: anywhere; }
.inv-lines .meta { font-size: var(--fs-xs); color: var(--muted); }
.legend-text { font-size: var(--fs-xs); margin-top: var(--sp-3) !important; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 var(--sp-4); border-left: 2px solid var(--border); display: grid; gap: var(--sp-3); }
.timeline li { position: relative; display: grid; }
.timeline li::before {
  content: ""; position: absolute; left: calc(-1 * var(--sp-4) - 7px); top: 5px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand);
}
.timeline .ev-cobro::before { border-color: var(--ok); background: var(--ok); }
.timeline .ev-anulada::before, .timeline .ev-recordatorio::before { border-color: var(--warn); }
.timeline .what { font-weight: 650; }
.timeline .when { font-size: var(--fs-xs); color: var(--muted); }
.timeline .detail { font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.actions-row.top { margin: 0 0 var(--sp-3); }
button.icon-btn { background: transparent; border: 0; padding: 0; cursor: pointer; font: inherit; }

/* --- expenses ------------------------------------------------------------------------ */

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.month-nav h2 { font-size: var(--fs-lg); }
.month-nav h2::first-letter { text-transform: uppercase; }
.month-nav .icon-btn { font-size: 1.75rem; line-height: 1; }
.list-gap { margin-top: var(--sp-4); }
.thumb { display: block; max-width: 100%; max-height: 360px; border-radius: var(--radius-sm); margin: 0 auto; }

/* --- números ------------------------------------------------------------------------ */

:root { --viz-1: #257de0; --viz-2: #f47230; --viz-axis: var(--border); }
@media (prefers-color-scheme: dark) { :root { --viz-1: #338ced; --viz-2: #e76624; } }

.seg { margin-bottom: var(--sp-2); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--sp-3); min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.tile .label { font-size: var(--fs-xs); color: var(--muted); }
.tile .value { font-weight: 700; font-size: var(--fs-lg); }
.tile .delta { font-size: var(--fs-xs); color: var(--muted); }
.tile.key { grid-column: 1 / -1; background: var(--brand-soft); border-color: var(--brand); }
.tile.key .value { font-size: var(--fs-xl); }
.reserve { margin-top: var(--sp-3); }
.reserve .big { font-size: var(--fs-xl); font-weight: 750; color: var(--text); margin: var(--sp-1) 0; }
.note-q { margin: var(--sp-3) 0 0; font-size: var(--fs-sm); }
.small { font-size: var(--fs-xs); }
.nlist { list-style: none; margin: 0; padding: 0; }
.nrow {
  display: grid; grid-template-columns: 1fr auto auto; gap: var(--sp-2); align-items: center;
  padding: var(--sp-2) 0; border-bottom: 1px solid var(--border);
}
.nrow:last-child { border-bottom: 0; }
.nlabel { min-width: 0; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.nlabel small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.casilla {
  display: inline-block; min-width: 2.2em; margin-right: var(--sp-2); padding: 0 6px;
  border-radius: 6px; background: var(--surface-2); color: var(--muted);
  font-size: var(--fs-xs); font-weight: 700; text-align: center;
}
.copy {
  min-height: 36px; min-width: 64px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: 999px; background: transparent; color: var(--brand);
  font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
}
.copy.done { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
table.mini { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.mini th, table.mini td { padding: 6px 0; border-bottom: 1px solid var(--border); text-align: left; font-weight: 400; }
table.mini thead th { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
table.mini .r { text-align: right; }
.legend { display: flex; gap: var(--sp-4); list-style: none; margin: 0 0 var(--sp-2); padding: 0; font-size: var(--fs-xs); color: var(--muted); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.sw.s1, rect.s1 { fill: var(--viz-1); background: var(--viz-1); }
.sw.s2, rect.s2 { fill: var(--viz-2); background: var(--viz-2); }
svg.bars { width: 100%; height: auto; display: block; }
svg.bars text { fill: var(--muted); font-size: 10px; }
svg.bars .axis { stroke: var(--viz-axis); stroke-width: 1; }
.table-view { margin-top: var(--sp-3); font-size: var(--fs-sm); }
.table-view summary { cursor: pointer; color: var(--brand); min-height: 32px; }
.disclaimer { margin: var(--sp-5) 0 0; text-align: center; font-size: var(--fs-xs); color: var(--muted); }

/* import review */
.actions-row { flex-wrap: wrap; }
.import-row.is-dup { opacity: 0.7; box-shadow: none; }
.import-head { display: flex; align-items: center; gap: var(--sp-3); }
.import-head .main { display: grid; flex: 1; min-width: 0; }
.import-head .title { font-weight: 650; overflow-wrap: anywhere; }
.import-head .meta { font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
.import-head .side { display: grid; text-align: right; flex: none; }
.import-head .side a.meta { color: var(--brand); }
.import-include { display: grid; place-items: center; min-width: 44px; min-height: 44px; margin: -6px; }
.import-include input { width: 22px; height: 22px; accent-color: var(--brand); }
.switch.compact { min-height: 40px; padding: 0; border: 0; background: none; }
.import-row details summary { cursor: pointer; color: var(--brand); font-size: var(--fs-sm); font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.import-form, .import-form .lines { grid-template-columns: minmax(0, 1fr); }
.import-row { min-width: 0; }
.import-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: var(--sp-2); }
.import-grid input, .import-grid select { width: 100%; min-width: 0; box-sizing: border-box; }
body:has(.import-form) .fab { display: none; }
.mini.has-error input, .mini.has-error select { border-color: var(--danger); }
.mini .error { font-style: normal; font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.import-row .hint { margin: var(--sp-2) 0 0; font-size: var(--fs-xs); color: var(--muted); }
.import-missing { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.sticky-actions {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-bottom)); z-index: 2;
  background: var(--bg); padding: var(--sp-2) 0; margin-top: var(--sp-4);
}
.sticky-actions .btn { white-space: normal; min-width: 0; text-align: center; line-height: 1.2; }

/* --- Ajustes: collapsible sections ---------------------------------------------------- */

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: var(--sp-3);
}
.settings-section > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: var(--sp-2) var(--sp-4);
  font-weight: 650;
}
.settings-section > summary::-webkit-details-marker { display: none; }
.settings-section > summary::after {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.settings-section[open] > summary::after { transform: rotate(-135deg); }
.settings-section > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: var(--radius); }
.settings-section .section-body { padding: 0 var(--sp-4) var(--sp-4); }
.settings-section .section-body > p { margin: 0 0 var(--sp-2); }
.settings-section .hint { font-size: var(--fs-xs); color: var(--muted); }
.settings-section .actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-3) 0; }
.sub-title { margin: var(--sp-4) 0 var(--sp-2); font-size: var(--fs-md); font-weight: 650; }
.plain-list { list-style: none; margin: 0 0 var(--sp-2); padding: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); }
.preview { width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; position: relative; }
.preview-frame { display: block; width: 794px; height: 1123px; border: 0; transform-origin: top left; }
