/* Gestor DeCA — hoja de estilos única, sin dependencias externas. */
:root {
  --asphalt: #1F2A33;
  --asphalt-2: #2C3A45;
  --ink: #1F2A33;
  --muted: #5A6872;
  --paper: #F5F7F6;
  --surface: #FFFFFF;
  --line: #D3DAD7;
  --line-strong: #AEB8B4;
  --blue: #0B5CAD;
  --blue-dark: #084683;
  --blue-soft: #E7F0FA;
  --amber: #E8A400;
  --amber-soft: #FFF5D9;
  --amber-ink: #6B4A00;
  --green: #22744A;
  --green-soft: #E5F3EA;
  --red: #B42318;
  --red-soft: #FDECEA;
  --radius: 6px;
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--paper); }
img { max-width: 100%; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--amber); color: #000; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 0; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--asphalt); color: #E6ECEF; padding: 1.25rem 0 2rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem 1.25rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand-mark { min-width: 30px; height: 30px; padding: 0 .35rem; border-radius: 4px; background: var(--blue); display: grid; place-items: center; font-weight: 800; font-size: .8rem; color: #fff; letter-spacing: .02em; }
.brand small { display: block; font-weight: 400; color: #9FB0BA; font-size: .78rem; }
.nav-group { margin-top: 1rem; }
.nav-group h2 { margin: 0 1.25rem .35rem; font-size: .78rem; font-weight: 600; color: #8FA1AC; }
.nav-group a { display: flex; align-items: center; min-height: 40px; padding: .35rem 1.25rem; color: #E6ECEF; text-decoration: none; border-left: 3px solid transparent; }
.nav-group a:hover { background: var(--asphalt-2); color: #fff; }
.nav-group a[aria-current="page"] { background: var(--asphalt-2); border-left-color: var(--amber); color: #fff; font-weight: 600; }
.nav-group .soon { padding: .35rem 1.25rem; color: #7C8E99; font-size: .9rem; }
.nav-primary { margin: 0 1.25rem; }
.sidebar-foot { margin-top: 2rem; padding: 0 1.25rem; font-size: .85rem; color: #9FB0BA; }
.sidebar-foot form { margin-top: .5rem; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; min-height: auto; }

.main { min-width: 0; padding: 1.5rem 2rem 4rem; }
.container { max-width: 1180px; margin: 0 auto; }
.narrow { max-width: 760px; }

.page-head { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.page-head p { margin: .25rem 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.bottom-nav { display: none; }

/* ---------- Componentes ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.panel > h2, .panel > header h2 { margin: 0 0 .75rem; font-size: 1.1rem; }
.panel > header { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.panel.flush { padding: 0; }
.panel.flush > h2, .panel.flush > header { padding: 1rem 1.25rem 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #fff; }
.btn.big { min-height: 52px; padding: .75rem 1.4rem; font-size: 1.05rem; }
.btn.danger { color: var(--red); border-color: #E3B5B0; }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.small { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
button { font: inherit; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 3px; font-size: .8rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge.VIGENTE { background: var(--green-soft); color: var(--green); border-color: #B9DCC6; }
.badge.BORRADOR { background: #EEF1F0; color: var(--muted); border-color: var(--line); }
.badge.SUSTITUIDO { background: #fff; color: var(--muted); border-color: var(--line-strong); text-decoration: line-through; }
.badge.ANULADO { background: var(--red-soft); color: var(--red); border-color: #F0C2BD; }
.badge.IMPORTADO { background: var(--blue-soft); color: var(--blue-dark); border-color: #BCD3EC; }
.badge.warn { background: var(--amber-soft); color: var(--amber-ink); border-color: #F1D88E; }

/* La matrícula: placa española con banda azul UE */
.plate { display: inline-flex; align-items: stretch; border: 1.5px solid #222; border-radius: 4px; background: #fff; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .06em; line-height: 1; overflow: hidden; vertical-align: middle; white-space: nowrap; }
.plate::before { content: "E"; display: flex; align-items: flex-end; justify-content: center; width: 1.05em; padding: 0 .1em .18em; background: #003399; color: #fff; font-size: .62em; letter-spacing: 0; }
.plate span { padding: .28em .45em .24em; font-size: .95em; color: #111; }
.plate.lg { font-size: 1.5rem; border-width: 2px; }
.plate.empty { border-style: dashed; color: var(--muted); }
.plate.empty::before { background: var(--line-strong); }

.docid { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }

.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash.success { background: var(--green-soft); border-color: #B9DCC6; color: #15502F; }
.flash.error { background: var(--red-soft); border-color: #F0C2BD; color: #7A1A12; }
.flash.warning { background: var(--amber-soft); border-color: #F1D88E; color: var(--amber-ink); }
.flash.info { background: var(--blue-soft); border-color: #BCD3EC; color: var(--blue-dark); }

.callout { border-left: 4px solid var(--amber); background: var(--amber-soft); color: var(--amber-ink); padding: .75rem 1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 0 0 1rem; }
.callout.blue { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); }
.callout.red { border-color: var(--red); background: var(--red-soft); color: #7A1A12; }
.callout strong { display: block; margin-bottom: .15rem; }
.callout ul { margin: .35rem 0 0; padding-left: 1.2rem; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; min-width: 0; }
.field label, .field .label { font-weight: 600; font-size: .92rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
.req::after { content: " *"; color: var(--red); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=search],
input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; min-height: var(--tap); padding: .5rem .65rem; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: inherit; }
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid var(--blue-soft); outline-offset: 0; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); background: #FFFBFA; }
.field-error { color: var(--red); font-size: .85rem; font-weight: 600; }
.field.review input, .field.review select, .field.review textarea { border-color: var(--amber); background: #FFFCF2; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 1rem; }
.row.r2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row.r3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.r4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row.r-place { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.row.r-tax { grid-template-columns: minmax(7.5rem, .6fr) minmax(0, 1.2fr) minmax(0, 1.6fr); }
.check { display: flex; gap: .55rem; align-items: flex-start; min-height: var(--tap); padding: .45rem 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: .05rem 0 0; flex: none; accent-color: var(--blue); }
.choice { display: flex; gap: .5rem; flex-wrap: wrap; }
.choice label { display: inline-flex; align-items: center; gap: .45rem; min-height: var(--tap); padding: .4rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; cursor: pointer; font-weight: 600; }
.choice input { accent-color: var(--blue); width: 20px; height: 20px; margin: 0; }
.choice label:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-weight: 700; font-size: 1.05rem; margin-bottom: .6rem; }
details.more { margin: .25rem 0 1rem; }
details.more > summary { cursor: pointer; color: var(--blue); font-weight: 600; min-height: var(--tap); display: flex; align-items: center; }
.form-foot { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; padding-top: .5rem; }

/* ---------- Asistente ---------- */
.wizard-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.steps { display: flex; gap: .25rem; list-style: none; margin: 0 0 1.25rem; padding: 0; overflow-x: auto; scrollbar-width: thin; }
.steps li { flex: 1 0 auto; }
.steps button { width: 100%; display: flex; align-items: center; gap: .5rem; min-height: var(--tap); padding: .4rem .75rem; border: 0; border-bottom: 3px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; text-align: left; white-space: nowrap; }
.steps button .n { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1.5px solid currentColor; font-size: .82rem; flex: none; }
.steps button[aria-current="step"] { color: var(--ink); border-bottom-color: var(--blue); }
.steps button[aria-current="step"] .n { background: var(--blue); border-color: var(--blue); color: #fff; }
.steps button.has-error { color: var(--red); border-bottom-color: var(--red); }
.js .step[hidden] { display: none; }
.step > h2 { font-size: 1.3rem; margin: 0 0 1rem; }
.step-nav { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1rem; }
.wizard-bar { position: sticky; bottom: 0; z-index: 5; background: var(--paper); border-top: 1px solid var(--line); padding: .75rem 0; margin-top: 1rem; display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.repeat-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1rem .25rem; margin-bottom: .75rem; background: #FBFCFB; position: relative; }
.repeat-item > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.repeat-item > header h3 { margin: 0; font-size: 1rem; }
.actor { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1rem .25rem; margin-bottom: 1rem; background: #fff; }
.actor > header { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .5rem; }
.actor > header h3 { margin: 0; font-size: 1.05rem; }
.actor > header p { margin: 0; font-size: .85rem; color: var(--muted); }
.actor.key { border-left: 4px solid var(--blue); }
.search-wrap { position: relative; }
.suggestions { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin: 2px 0 0; padding: 0; list-style: none; background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); max-height: 280px; overflow-y: auto; box-shadow: 0 6px 18px rgba(31, 42, 51, .15); }
.suggestions li button { width: 100%; text-align: left; border: 0; background: none; padding: .6rem .75rem; min-height: var(--tap); cursor: pointer; }
.suggestions li button:hover, .suggestions li button:focus { background: var(--blue-soft); }
.suggestions small { color: var(--muted); }

/* ---------- Tablas e histórico ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: .84rem; padding: .55rem .6rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.data td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: #FAFBFA; }
table.data td.actions-cell { white-space: nowrap; text-align: right; }
table.data .sub { display: block; color: var(--muted); font-size: .84rem; }
.route { display: block; }
.route .arrow { color: var(--muted); }
.cards { display: none; }
.card { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .6rem; color: inherit; text-decoration: none; }
.card .top { display: flex; justify-content: space-between; gap: .5rem; align-items: center; margin-bottom: .35rem; }
.card .route { font-weight: 600; margin: .2rem 0; }
.card .meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; align-items: center; color: var(--muted); font-size: .88rem; }
.card .card-actions { display: flex; gap: .4rem; margin-top: .6rem; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem .75rem; align-items: end; }
.filters .field { margin-bottom: .25rem; }
.search-row { display: flex; gap: .5rem; margin-bottom: .75rem; }
.search-row input { flex: 1; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .9rem 0; }
.pager nav { display: flex; gap: .4rem; }
.bulk-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .6rem 0; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty p { margin: 0 0 1rem; }

/* ---------- Dashboard ---------- */
.hello { margin: 0 0 1.25rem; }
.hello h1 { margin: 0; font-size: 1.7rem; }
.hello p { margin: .2rem 0 0; color: var(--muted); }
.primary-actions { display: grid; grid-template-columns: 2fr 1fr; gap: .75rem; margin-bottom: 1.25rem; }
.primary-actions .btn { min-height: 64px; font-size: 1.1rem; justify-content: flex-start; padding: 0 1.25rem; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.25rem; }
.stat { padding: 1rem 1.25rem; border-right: 1px solid var(--line); text-decoration: none; color: inherit; }
.stat:last-child { border-right: 0; }
.stat .value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .9rem; }
.stat:hover { background: #FAFBFA; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: .6rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .75rem; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.quick { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Detalle DeCA ---------- */
.doc-head { display: grid; grid-template-columns: 1fr auto; gap: 1rem 1.5rem; align-items: start; }
.doc-head h1 { margin: 0; font-size: 1.6rem; }
.qr-box { text-align: center; }
.qr-box img { width: 168px; height: 168px; image-rendering: pixelated; border: 1px solid var(--line); background: #fff; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.fact { padding: .75rem 0; border-bottom: 1px solid var(--line); padding-right: 1rem; }
.fact .k { display: block; font-size: .84rem; color: var(--muted); }
.fact .v { font-weight: 600; }
.fact.wide { grid-column: 1 / -1; }
.letter { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; border-radius: 3px; background: var(--asphalt); color: #fff; font-size: .8rem; font-weight: 700; margin-right: .35rem; }
.versions li { align-items: flex-start; }
.url-box { display: flex; gap: .5rem; align-items: stretch; }
.url-box input { font-variant-numeric: tabular-nums; font-size: .88rem; }
.timeline-reason { font-size: .88rem; color: var(--muted); }

/* ---------- Revisión ---------- */
.review-sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.review-sheet section { padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); }
.review-sheet section:last-child { border-bottom: 0; }
.review-sheet h3 { margin: 0 0 .4rem; font-size: 1rem; display: flex; align-items: center; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--asphalt); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: var(--radius); padding: 2rem 1.75rem; }
.login-card .brand { color: var(--ink); padding: 0 0 1.25rem; }
.login-card h1 { font-size: 1.35rem; margin: 0 0 1rem; }

/* ---------- Errores ---------- */
.error-page { max-width: 560px; margin: 4rem auto; text-align: center; }
.error-page .code { font-size: 4rem; font-weight: 800; color: var(--line-strong); line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- Drop zone ---------- */
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 1.5rem; text-align: center; background: #fff; cursor: pointer; }
.dropzone.over { border-color: var(--blue); background: var(--blue-soft); }
.dropzone input[type=file] { width: 100%; margin-top: .75rem; }
.dropzone .file-name { font-weight: 600; margin-top: .5rem; }

/* ---------- Status checks ---------- */
.check-list li .badge.OK { background: var(--green-soft); color: var(--green); }
.check-list li .badge.WARNING { background: var(--amber-soft); color: var(--amber-ink); }
.check-list li .badge.ERROR { background: var(--red-soft); color: var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .shell { grid-template-columns: 210px 1fr; }
  .main { padding: 1.25rem 1.25rem 4rem; }
  .row.r4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  body { font-size: 16px; }
  .shell { display: block; }
  .sidebar { display: none; }
  .main { padding: 1rem 1rem calc(84px + env(safe-area-inset-bottom)); }
  .mobile-top { display: flex; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--asphalt); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60px; color: #CBD6DC; text-decoration: none; font-size: .74rem; gap: .15rem; }
  .bottom-nav a[aria-current="page"] { color: #fff; box-shadow: inset 0 3px 0 var(--amber); }
  .bottom-nav a.new { background: var(--blue); color: #fff; font-weight: 700; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .grid-2, .grid-3, .row.r2, .row.r3, .row.r4, .row.r-place { grid-template-columns: minmax(0, 1fr); }
  .row.r-tax { grid-template-columns: minmax(7.5rem, .5fr) minmax(0, 1fr); }
  .row.r-tax > :nth-child(3) { grid-column: 1 / -1; }
  .row { grid-template-columns: 1fr; }
  .row.keep { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head h1 { font-size: 1.35rem; }
  .table-wrap.responsive { display: none; }
  .cards { display: block; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .primary-actions { grid-template-columns: 1fr; }
  .doc-head { grid-template-columns: 1fr; }
  .qr-box { text-align: left; }
  .facts { grid-template-columns: 1fr; }
  .steps button .t { display: none; }
  .steps button[aria-current="step"] .t { display: inline; }
  .steps li { flex: 0 0 auto; }
  .wizard-bar { bottom: calc(60px + env(safe-area-inset-bottom)); margin-left: -1rem; margin-right: -1rem; padding: .6rem 1rem; }
  .wizard-bar .btn { flex: 1; }
  .panel { padding: 1rem; }
}

.mobile-top { display: none; align-items: center; justify-content: space-between; padding: .6rem 1rem; background: var(--asphalt); color: #fff; }
.mobile-top .brand { padding: 0; }
.mobile-top details summary { list-style: none; cursor: pointer; min-height: var(--tap); display: flex; align-items: center; padding: 0 .5rem; color: #fff; }
.mobile-top details[open] .mobile-menu { display: block; }
.mobile-menu { position: absolute; right: .75rem; left: .75rem; top: 56px; z-index: 40; background: var(--asphalt); border-radius: var(--radius); padding: .5rem 0; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.mobile-menu a { display: block; padding: .7rem 1rem; color: #E6ECEF; text-decoration: none; }
.mobile-menu h2 { margin: .5rem 1rem .1rem; font-size: .78rem; color: #8FA1AC; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

@media print {
  .sidebar, .bottom-nav, .mobile-top, .actions, .wizard-bar, form button { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
}

/* ---------- Utilidades (sin estilos en línea: CSP estricta) ---------- */
[hidden] { display: none !important; }
.full { width: 100%; }
.span-2 { grid-column: span 2; }
.auto-w { width: auto !important; }
.compact { min-height: 36px !important; }
.mt { margin-top: 1.25rem; }
.pad-x { padding: .75rem 1rem 0; }
.inline { display: inline-block; margin-left: .5rem; }
.center { text-align: center; }
.center-actions { justify-content: center; }
.share-qr { width: 280px; height: 280px; max-width: 100%; height: auto; image-rendering: pixelated; border: 1px solid var(--line); }
.menu-form { padding: .4rem 1rem; }
.menu-form .linkish { color: #E6ECEF; }
.side-link { color: #C6D2D9; }
.suggest-empty { display: block; padding: .6rem .75rem; color: var(--muted); font-size: .875rem; }
.h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
.inline-details { display: inline-block; margin-left: .5rem; text-align: left; }
.inline-details input { margin: .3rem 0; }
@media (max-width: 820px) { .span-2 { grid-column: auto; } }

@media (max-width: 820px) {
  .mobile-top { display: flex; position: sticky; top: 0; z-index: 35; }
  .bulk-bar, .hide-mobile { display: none !important; }
}
table.data .docid { white-space: nowrap; }
table.data .plate { font-size: .85rem; }
table.data td.plates { white-space: nowrap; }
table.data td.plates .plate + .plate { margin-left: .25rem; }
details.more:last-child { margin-bottom: 0; }

.row-actions { display: flex; gap: .9rem; margin-top: .35rem; font-size: .88rem; }
.danger-link { color: var(--red); }
@media (max-width: 1400px) { .col-carrier { display: none; } }

.field { position: relative; }
.suggest-source { padding: .35rem .75rem; font-size: .75rem; color: var(--muted); border-top: 1px solid var(--line); }
.copy-links { margin: -.4rem 0 .6rem; font-size: .88rem; }
.copy-links .linkish { color: var(--blue); }
.sheet-item + .sheet-item { margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed var(--line); }
.strong { font-weight: 700; }
.mt-xs { margin-top: .35rem; }

/* ---------- Desplegables ---------- */
select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  padding-right: 2.4rem;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='%235A6872' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; background-size: 14px;
  transition: border-color .12s;
}
select:hover { border-color: var(--asphalt-2); }
select:disabled { cursor: not-allowed; background-color: #F0F2F1; }
select.compact { padding-right: 2rem; background-position: right .5rem center; }

/* Navegadores con <select> personalizable (Chrome/Edge 135+): también la lista abierta */
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { background-image: none; display: flex; align-items: center; }
  select::picker-icon {
    content: ""; width: 14px; height: 14px; transition: rotate .15s;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='%235A6872' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
  }
  select:open::picker-icon { rotate: 180deg; }
  select:open { border-color: var(--blue); outline: 2px solid var(--blue-soft); outline-offset: 0; }
  ::picker(select) {
    border: 1px solid var(--line-strong); border-radius: 8px; padding: .3rem; margin-top: 4px;
    background: #fff; box-shadow: 0 12px 28px rgba(31, 42, 51, .18); max-height: min(340px, 60vh);
  }
  select option { padding: .55rem .7rem; border-radius: 6px; gap: .5rem; min-height: 40px; }
  select option:hover, select option:focus-visible { background: var(--blue-soft); outline: none; }
  select option:checked { font-weight: 600; color: var(--blue-dark); }
  select option::checkmark { color: var(--blue); order: 1; margin-left: auto; }
  select option[value=""] { color: var(--muted); }
}
@media (prefers-reduced-motion: reduce) { select::picker-icon { transition: none; } }
.danger-zone { border-color: #F0C2BD; }
.danger-zone h2 { color: var(--red); }
.attach-line { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: #FBFCFB; font-size: .92rem; }
.attach-icon { display: inline-grid; place-items: center; width: 2.2rem; height: 1.6rem; border-radius: 3px; background: var(--red); color: #fff; font-size: .7rem; font-weight: 700; }
code { font-size: .9em; background: #EEF1F0; padding: .05rem .3rem; border-radius: 3px; }
.span-3 { grid-column: span 3; }
@media (max-width: 820px) { .span-3 { grid-column: auto; } }

/* ---------- Asistente simplificado (v1.3) ---------- */
.client-card { padding: 0; margin: .25rem 0 1rem; }
.client-card > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1rem; cursor: pointer; min-height: 56px; }
.client-card > summary::-webkit-details-marker { display: none; }
.client-card[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: .75rem; }
.client-card > :not(summary) { margin-left: 1rem; margin-right: 1rem; }
.client-card > .row:last-child { margin-bottom: .25rem; }
.client-edit { color: var(--blue); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.client-card[open] .client-edit::after { content: " ▲"; font-size: .7rem; }
.client-card:not([open]) .client-edit::after { content: " ▼"; font-size: .7rem; }
.carrier-card { border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: var(--radius); padding: .8rem 1rem; background: #FBFCFB; margin: .5rem 0 0; }
.carrier-card .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.carrier-card .hint { display: block; margin-top: .3rem; }
.step-nav { align-items: center; }
.step-nav .btn.primary { min-width: 12rem; }
/* Botones finales: solo en el último paso y separados de «Anterior» para evitar toques accidentales */
.final-actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.final-main { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 820px) {
  .step-nav .btn { flex: 1; min-width: 0; }
  .final-actions { flex-direction: column-reverse; align-items: stretch; gap: 1.75rem; }
  .final-main { flex-direction: column; gap: 1rem; }
  .final-main .btn { width: 100%; }
}

/* v1.3 · buscador de cliente y sugerencias de empresa */
input.client-search { padding-left: 2.3rem !important; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236B7785' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat .75rem center; }
.suggestions li button.suggest-new { color: var(--blue); font-weight: 600; border-top: 1px solid var(--line); }
.client-line { display: block; font-weight: 600; font-size: .9rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-preview { white-space: pre-wrap; word-break: break-word; text-align: left; font: inherit; font-size: .9rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin: .5rem 0 0; }

/* v1.5 · plantillas */
.tpl-loader { display: flex; flex-direction: column; gap: .5rem; border-left: 4px solid var(--blue); }
.tpl-loader-row { display: flex; gap: .5rem; }
.tpl-loader-row select { flex: 1; min-width: 0; }
.tpl-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: -.25rem 0 1.25rem; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: .35rem .85rem; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem; }
.chip:hover, .chip:focus { border-color: var(--blue); background: var(--blue-soft); }
.tpl-list li { align-items: flex-start; }
.tpl-info { min-width: 0; }
@media (max-width: 640px) { .tpl-list li { flex-direction: column; align-items: stretch; } .tpl-list .actions { justify-content: flex-start; } }
input.upper { text-transform: uppercase; }
input.upper::placeholder { color: #8A96A3; }
.ext-qr { display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.ext-qr .url-box { width: 100%; max-width: 560px; }

/* =====================================================================================
   V2 · FACTURACIÓN — mismos componentes, acento naranja (DeCA conserva el azul)
   ===================================================================================== */
body.mod-billing { --blue: #C2410C; --blue-dark: #9A3412; --blue-soft: #FFF1E7; }
body.mod-billing .brand-mark { background: #C2410C; }
/* Cambio de aplicación: DeCA ⇄ Facturación (botón único en el menú lateral) */
.nav-switch { margin: 1.25rem 1.25rem 0; }
.switch-app { display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .45rem .9rem; border-radius: var(--radius); font-weight: 700; text-decoration: none; letter-spacing: .01em; }
.switch-app.to-billing { background: transparent; border: 2px solid #E8793F; color: #FFD8C2; }
.switch-app.to-billing:hover, .switch-app.to-billing:focus { background: #C2410C; border-color: #C2410C; color: #fff; }
.switch-app.to-deca { background: transparent; border: 2px solid #4D8FD6; color: #CFE2F7; }
.switch-app.to-deca:hover, .switch-app.to-deca:focus { background: #0B5CAD; border-color: #0B5CAD; color: #fff; }
.mobile-menu .switch-app { margin: .25rem 0 .5rem; }
body.mod-billing .nav-group a[aria-current="page"] { border-left-color: #F28A4B; }
.billing-accent { border-top: 3px solid #C2410C; }
.panel.accent { border-left: 4px solid #C2410C; }

/* Editor: formulario | vista previa */
.inv-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 470px); gap: 1.25rem; align-items: start; }
.inv-preview { position: sticky; top: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1rem 1rem; }
@media (max-width: 1100px) { .inv-editor { grid-template-columns: minmax(0, 1fr); } .inv-preview { position: static; order: 2; } }
.preview-toggle > summary { font-weight: 700; cursor: pointer; padding: .5rem 0; min-height: var(--tap); display: flex; align-items: center; gap: .4rem; }
.preview-pages img.preview-page { width: 100%; display: block; margin: 0 0 .75rem; background: #fff; border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(31, 42, 51, .10); }
.preview-issues { background: var(--amber-soft); color: var(--amber-ink); border: 1px solid #F1D88E; border-radius: var(--radius); padding: .5rem .75rem; margin-bottom: .75rem; font-size: .88rem; }
.preview-issues ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.inv-line { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .75rem .25rem; margin-bottom: .75rem; background: #fff; }
.inv-line-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .2rem; }
.inv-line-n { font-weight: 700; color: var(--muted); }
.inv-line-tools { display: flex; gap: .3rem; align-items: center; }
.icon-btn { min-width: 38px; min-height: 38px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); cursor: pointer; font-size: 1rem; color: var(--ink); }
.icon-btn:hover, .icon-btn:focus { border-color: var(--blue); }
.inv-line-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.rt-toolbar { display: flex; gap: .3rem; margin-bottom: .3rem; }
.rt-toolbar button { min-width: 40px; min-height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 4px; cursor: pointer; color: var(--ink); }
.rt-toolbar button:hover, .rt-toolbar button:focus { border-color: var(--blue); }
.rt-edit { min-height: 3.2em; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: .55rem .7rem; background: #fff; line-height: 1.45; overflow-wrap: anywhere; }
.rt-edit:focus { border-color: var(--blue); outline: 2px solid var(--blue-soft); }
.has-error .rt-edit { border-color: var(--red); background: #FFFBFA; }
.tpl-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.tpl-bar select { flex: 1 1 220px; width: auto; }
.adj-row { display: grid; grid-template-columns: 2fr 1fr auto; gap: .75rem; align-items: end; }
.adj-row .linkish { margin-bottom: 1.1rem; }
.totals-box { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .75rem; max-width: 420px; margin-left: auto; }
.trow { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; font-variant-numeric: tabular-nums; }
.trow.strong { font-weight: 700; }
.trow.total { font-weight: 800; font-size: 1.15rem; border-top: 1px solid var(--line); margin-top: .35rem; padding-top: .5rem; }
.combo { position: relative; }
.ph-list { columns: 2; font-size: .85rem; padding-left: 1rem; margin: .5rem 0; }
.ph-list code { font-size: .82rem; }
@media (max-width: 640px) { .ph-list { columns: 1; } .inv-line-grid { grid-template-columns: 1fr 1fr; } .adj-row { grid-template-columns: 1fr 1fr; } .adj-row .linkish { grid-column: span 2; margin: 0 0 .75rem; justify-self: start; } }
.deca-tag { color: var(--blue-dark); font-weight: 600; }

/* Modales (cliente, DeCA) */
dialog.modal { border: none; border-radius: 10px; padding: 1rem 1.25rem; width: min(720px, 96vw); max-height: 88vh; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); color: var(--ink); }
dialog.modal.wide { width: min(980px, 96vw); }
dialog.modal::backdrop { background: rgba(20, 25, 30, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-list { max-height: 55vh; overflow: auto; margin-top: .75rem; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: .75rem; flex-wrap: wrap; }
table.data tr.pick { cursor: pointer; }
table.data tr.pick:hover, table.data tr.pick:focus { background: var(--blue-soft); outline: none; }
table.data.compact td, table.data.compact th { padding: .45rem .6rem; }
.deca-filters { align-items: end; }

/* Ficha */
.action-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.action-bar form { margin: 0; }
.doc-preview .concept { flex: 1; padding-right: 1rem; }
.totals-list { border-top: 1px solid var(--line); margin-top: .5rem; }
.totals-list li { padding: .25rem 0; }
.concept-preview { display: block; }
.sig-preview { max-height: 90px; border: 1px dashed var(--line); padding: .5rem; background: #fff; }
.series-row { margin-bottom: .75rem; }
.send-options { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.deca-pick { max-height: 260px; overflow: auto; margin: .5rem 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.badge.EMITIDA, .badge.EMITIDO { background: var(--green-soft); color: var(--green); border-color: #B9DCC6; }
.badge.ACEPTADO { background: #E3F4E8; color: #17603A; border-color: #9FD1B1; }
.badge.RECTIFICADA { background: #fff; color: var(--muted); border-color: var(--line-strong); }
.badge.ANULADA, .badge.RECHAZADO { background: var(--red-soft); color: var(--red); border-color: #F0C2BD; }
.badge.CADUCADO { background: #EEF1F0; color: var(--muted); border-color: var(--line); text-decoration: line-through; }

/* Impresión: las páginas del PDF real */
body.print-page { background: #5F6B73; margin: 0; }
.print-bar { position: sticky; top: 0; z-index: 2; display: flex; gap: 1rem; align-items: center; justify-content: space-between; padding: .5rem 1rem; background: #1F2A33; color: #fff; }
.print-pages { padding: 1rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.print-sheet { width: min(210mm, 100%); background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .4); }
@media print {
  @page { size: A4; margin: 0; }
  body.print-page { background: #fff; }
  .no-print { display: none !important; }
  .print-pages { padding: 0; gap: 0; display: block; }
  .print-sheet { display: block; width: 210mm; height: 297mm; box-shadow: none; break-after: page; page-break-after: always; }
  .print-sheet:last-child { break-after: auto; page-break-after: auto; }
}

/* 2.1 · base imponible, firma, versiones */
.base-field { max-width: 420px; }
.base-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.base-row input { flex: 1 1 160px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sign-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.sign-btn { display: inline-flex; align-items: center; gap: .45rem; }
.sign-btn[aria-pressed="true"] { background: #E8F5EC; border-color: #1E7B45; color: #145A32; font-weight: 700; }
canvas.sign-pad { display: block; width: 100%; height: auto; aspect-ratio: 600 / 220; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: #fff; touch-action: none; cursor: crosshair; }
.error-text { color: var(--red); }
.sig-preview { max-width: 260px; max-height: 110px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: .25rem; }
.badge.ok { background: var(--green-soft); color: var(--green); border-color: #B9DCC6; }
.adj-value { display: flex; gap: .4rem; }
.adj-value input { flex: 1 1 auto; min-width: 0; }
.adj-value select { flex: 0 0 4.2rem; width: 4.2rem; }

/* 2.2 · cobro, papelera */
.pay-toggle { min-height: 34px; padding: .2rem .7rem; border-radius: 999px; border: 1px solid #F1D88E; background: var(--amber-soft); color: var(--amber-ink); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.pay-toggle.is-paid { border-color: #B9DCC6; background: var(--green-soft); color: var(--green); }
.pay-toggle:hover, .pay-toggle:focus { box-shadow: 0 0 0 2px var(--blue-soft); }
.pay-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: -.5rem 0 1rem; }
.card-split { padding: 0; }
.card-split .card-link { display: block; color: inherit; text-decoration: none; padding: .85rem 1rem .6rem; }
.card-split .card-actions { margin-top: 0; padding: 0 1rem .8rem; }
.card-actions form { margin: 0; }
.stat.stat-warn .value { color: var(--amber-ink); }
.stat.stat-ok .value { color: var(--green); }
.dash-more { margin: -.5rem 0 1rem; }

/* 2.2 · móvil: formularios de facturación más limpios */
.base-row input::placeholder { font-weight: 400; }
input[type="date"] { min-height: 46px; }
.inv-line-grid .field { min-width: 0; }
.inv-line-grid input { width: 100%; min-width: 0; }
@media (max-width: 640px) {
  .inv-line { padding: .6rem .65rem .2rem; }
  .inv-line-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .adj-row { grid-template-columns: 1fr; gap: 0; padding: .6rem .65rem 0; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .6rem; background: #fff; }
  .adj-row .linkish { grid-column: auto; justify-self: end; margin: 0 0 .6rem; }
  .base-field { max-width: none; }
  .tpl-bar .btn { flex: 1 1 auto; }
  .sign-row .btn { flex: 0 0 auto; }
  .final-main .btn { width: 100%; }
  .test-mail .btn { width: 100%; }
}
table.data td.num { white-space: nowrap; }

/* 2.2.1 · conexión con Microsoft */
.provider-pick { margin-bottom: .75rem; }
.ms-connect { border-top: 1px solid var(--line); padding-top: .75rem; }
.ms-code { margin-top: .75rem; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.ms-code p { margin: .35rem 0; }
.ms-user-code { font-size: 1.5rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.att-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .25rem 0; border-bottom: 1px solid var(--line); }
.att-row:last-child { border-bottom: 0; }
.att-row .check { margin: 0; }
.att-pages { max-height: 75vh; overflow: auto; background: #EEF1F0; padding: .75rem; border-radius: var(--radius); }
.att-pages img { display: block; width: 100%; max-width: 820px; margin: 0 auto .75rem; background: #fff; box-shadow: 0 2px 8px rgba(31, 42, 51, .12); }

/* 2.3: botón Atrás dentro de la app */
.mt-left { display: flex; align-items: center; gap: .25rem; min-width: 0; }
.nav-back { display: grid; place-items: center; width: var(--tap); height: var(--tap); margin-left: -.6rem; color: #fff; border-radius: 6px; }
.nav-back svg { width: 24px; height: 24px; }
.nav-back:active, .nav-back:focus-visible { background: rgba(255,255,255,.12); }
.page-back { display: none; margin-bottom: .6rem; font-size: .9rem; color: var(--muted, #5b6770); text-decoration: none; }
.page-back:hover { color: var(--ink); text-decoration: underline; }
@media (display-mode: standalone) and (min-width: 821px) { .page-back { display: inline-block; } }
/* 2.3: visor de documentos */
.viewer-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.viewer-head h1 { font-size: 1.15rem; margin: 0; overflow-wrap: anywhere; }
.viewer-pages { display: grid; gap: 1rem; justify-items: center; }
.viewer-page { margin: 0; width: 100%; max-width: 900px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.viewer-page img { display: block; width: 100%; height: auto; }
.viewer-page figcaption { font-size: .78rem; color: #6b7780; text-align: center; padding: .3rem 0; background: var(--bg, #f4f6f7); }
.viewer-image img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
@media print {
  .viewer-head, .page-back, .flash { display: none !important; }
  .viewer-page { box-shadow: none; max-width: none; break-after: page; }
  .viewer-page figcaption { display: none; }
}

/* 2.3.1: nada se sale de la pantalla en el móvil (sin deslizamiento lateral) */
.shell, .main, .container { min-width: 0; }
.grid-2 > *, .grid-3 > *, .row > *, .stats > *, .list-plain li > * { min-width: 0; }
.review-sheet, .sheet-item, .list-plain li, .panel { overflow-wrap: break-word; }
.btn, .review-sheet table { overflow-wrap: normal; }
.review-sheet table { display: block; max-width: 100%; overflow-x: auto; }
@media (max-width: 820px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  .btn { white-space: normal; text-align: center; max-width: 100%; }
}
.bottom-nav a.refreshing svg { animation: gd-spin .8s linear infinite; }
@keyframes gd-spin { to { transform: rotate(360deg); } }
.inv-line-tools .linkish { margin-left: .6rem; }

/* 2.5.1: mover conceptos (asa para arrastrar y flechas que no hacen saltar la pantalla) */
.inv-line-head { display: flex; align-items: center; gap: .4rem; }
.drag-handle { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -.35rem; border: 0; background: transparent; border-radius: var(--radius); color: var(--muted); cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; }
.drag-handle svg { width: 22px; height: 22px; fill: currentColor; }
.drag-handle:hover, .drag-handle:focus-visible { background: var(--bg, #f4f6f7); color: var(--ink); }
.inv-line.dragging { position: fixed; z-index: 60; margin: 0; box-shadow: 0 12px 28px rgba(0,0,0,.22); background: #fff; pointer-events: none; }
.inv-line.dragging .drag-handle { cursor: grabbing; pointer-events: auto; }
.inv-line-ph { border: 2px dashed var(--line-strong, #b9c3ca); border-radius: var(--radius); margin-bottom: .75rem; background: rgba(0,0,0,.02); }
body.is-dragging { -webkit-user-select: none; user-select: none; cursor: grabbing; }
.inv-line.moved { animation: line-moved 1s ease-out; }
@keyframes line-moved { from { box-shadow: 0 0 0 3px rgba(194,65,12,.45); } to { box-shadow: 0 0 0 3px rgba(194,65,12,0); } }
@media (prefers-reduced-motion: reduce) { .inv-line.moved { animation: none; } }
.inv-line-sum { display: none; }
[data-lines].reordering .inv-line { padding: .35rem .6rem; margin-bottom: .4rem; }
[data-lines].reordering .inv-line > :not(.inv-line-top) { display: none; }
[data-lines].reordering .inv-line-top { margin: 0; }
[data-lines].reordering .inv-line-tools { display: none; }
[data-lines].reordering .inv-line-head { min-width: 0; flex: 1; }
[data-lines].reordering .inv-line-sum { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
[data-lines].reordering .inv-line-ph { margin-bottom: .4rem; }
/* 2.6: ajustes habituales del cliente */
.client-adjs { border: 0; padding: 0; margin: .25rem 0 1rem; min-width: 0; }
.client-adjs legend { font-weight: 700; padding: 0; margin-bottom: .25rem; }
.client-adjs .hint { display: block; margin: 0 0 .5rem; }
.client-adjs [data-padj-prontopago] { margin-top: .25rem; }
