:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f8f8f5;
  --text: #1a1a18;
  --muted: #6b6b66;
  --border: #deded8;
  --accent: #f5c400;
  --accent-ink: #1a1a18;
  --accent-soft: #fff6cc;
  --primary: #1a1a18;
  --primary-ink: #ffffff;
  --danger: #c0271d;
  --danger-soft: #fdecea;
  --green: #1e7a3c;
  --green-soft: #e3f4e8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514; --surface: #1f1f1d; --surface-2: #262624; --text: #f0f0ea; --muted: #a3a39c;
    --border: #3a3a36; --accent-soft: #3a3210; --primary: #f5c400; --primary-ink: #1a1a18;
    --danger: #ff7a70; --danger-soft: #3d1c19; --green: #6fd08f; --green-soft: #173222;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; margin-bottom: .75rem; }
a { color: inherit; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.red { color: var(--danger); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.center { text-align: center; }
.boot { padding: 4rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 42px; padding: .5rem 1rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger-ghost { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: .25rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
.center-block { display: block; margin: 1rem auto 0; }
.icon-btn { background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: .3rem .5rem; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; font-weight: 600; }
label .muted { font-weight: 400; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: .6rem .7rem; width: 100%; min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
label.check { flex-direction: row; align-items: center; font-weight: 500; }
label.check input { width: auto; min-height: 0; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.stack > h2 { margin: 0; }

/* ---------- Estructura ---------- */
.demo-banner {
  background: var(--accent); color: var(--accent-ink); font-size: .85rem; padding: .5rem 16px;
  display: flex; flex-wrap: wrap; gap: .4rem 1rem; justify-content: space-between; align-items: center;
}
.demo-actions { display: flex; gap: 1rem; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  padding: .6rem 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 700; min-width: 0; }
.brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28vw; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); flex: none; position: relative;
}
.brand-mark::after { content: ""; position: absolute; inset: 8px 7px; border: 2.5px solid #1a1a18; border-radius: 2px; border-left-width: 6px; }
.brand-mark.big { width: 52px; height: 52px; border-radius: 14px; }
.brand-mark.big::after { inset: 14px 12px; border-width: 3.5px; border-left-width: 10px; }
.nav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; }
.nav a { padding: .45rem .8rem; border-radius: 8px; text-decoration: none; font-weight: 600; color: var(--muted); white-space: nowrap; }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.user { display: flex; align-items: center; gap: .7rem; }
.user-name { display: flex; flex-direction: column; font-size: .85rem; font-weight: 600; text-align: right; line-height: 1.2; }
.user-name small { color: var(--muted); font-weight: 400; }
.main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.back { font-size: .85rem; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: .3rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid2 .card { margin-bottom: 0; }
.grid2 + .card { margin-top: 1rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .btn { margin-top: 1rem; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
.chip { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); vertical-align: middle; }
.chip.red { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip.yellow { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.green { background: var(--green-soft); color: var(--green); border-color: transparent; }

/* ---------- Auth / onboarding ---------- */
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 2.5rem 16px; }
.auth-wrap.wide { max-width: 860px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.75rem 1.4rem; box-shadow: var(--shadow); }
.auth-card h1 { text-align: center; margin: .6rem 0 .2rem; }
.auth-logo { display: flex; justify-content: center; }
.auth-card > .btn.block { margin-top: 1.2rem; }
.sep { display: flex; align-items: center; gap: .8rem; color: var(--muted); margin: 1rem 0; font-size: .85rem; }
.sep::before, .sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.tabs { display: flex; background: var(--surface-2); border-radius: 10px; padding: 4px; margin: 1.1rem 0; }
.tab { flex: 1; border: 0; background: none; padding: .55rem; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.onb-head { text-align: center; margin-bottom: 1.5rem; }
.onb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.onb-grid h2 { margin: 0; }

/* ---------- Listado ---------- */
.toolbar { display: flex; gap: .6rem; margin-bottom: 1rem; }
.toolbar input { flex: 1; }
.toolbar select { width: auto; }
.sheet-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .6rem; }
.sheet-item {
  display: flex; gap: .9rem; align-items: center; padding: .75rem .9rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none;
}
.sheet-item:hover { border-color: var(--muted); }
.sheet-item.is-void { opacity: .6; }
.si-date { flex: none; width: 52px; text-align: center; border-radius: 9px; background: var(--surface-2); padding: .3rem 0; line-height: 1.1; }
.si-date b { display: block; font-size: 1.3rem; }
.si-date span { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.si-date.is-today { background: var(--accent); color: var(--accent-ink); }
.si-date.is-today span { color: var(--accent-ink); }
.si-main { flex: 1; min-width: 0; }
.si-route { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrow { color: var(--muted); }
.si-meta { display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .82rem; color: var(--muted); }
.plate { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; color: var(--text); }

/* ---------- Formulario de hoja ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .card { margin: 0; display: flex; flex-direction: column; gap: .85rem; }
.form-grid .card h2 { margin: 0; }
.span2 { grid-column: 1 / -1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.radio-list { display: flex; flex-direction: column; gap: .45rem; }
.radio { flex-direction: row; align-items: center; gap: .6rem; font-weight: 400; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.radio input { width: auto; min-height: 0; accent-color: #1a1a18; }
.radio:has(input:checked) { border-color: var(--text); background: var(--accent-soft); }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; }

/* ---------- Documento ---------- */
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.doc {
  background: #fff; color: #111; border-radius: 6px; padding: 1.6rem 1.6rem 1.3rem; margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.12); border-top: 10px solid var(--accent); position: relative; overflow: hidden;
}
.doc.is-void::after {
  content: "ANULADO"; position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg);
  font-size: clamp(3rem, 10vw, 7rem); font-weight: 900; color: rgba(200,20,20,.2); pointer-events: none;
}
.doc-head { display: grid; grid-template-columns: 120px 1fr 120px; align-items: center; gap: 1rem; }
.doc-logo img { max-width: 110px; max-height: 70px; }
.doc-title { text-align: center; }
.doc-title h2 { font-size: 1.7rem; font-weight: 500; margin: 0; }
.doc-title p { font-size: .75rem; margin: .2rem 0 0; }
.doc-qr { justify-self: end; }
.doc-qr svg { display: block; }
.doc-fields { margin: 1.2rem 0; display: flex; flex-direction: column; gap: .5rem; }
.doc-fields > div { display: grid; grid-template-columns: minmax(200px, 330px) 1fr; gap: .8rem; align-items: baseline; font-size: .85rem; }
.doc-fields dt { color: #333; }
.doc-fields dd { margin: 0; border-bottom: 1px solid #333; display: flex; gap: 2rem; flex-wrap: wrap; padding-bottom: 2px; max-width: 520px; }
.doc-table { display: grid; grid-template-columns: .7fr 1.3fr 1.5fr 1fr 1.5fr 2fr; border: 1px solid #222; font-size: .8rem; }
.dt-col { border-right: 1px solid #222; min-width: 0; }
.dt-col:last-child { border-right: 0; }
.dt-col h3 { background: #111; color: #fff; font-size: .72rem; padding: .45rem .5rem; font-weight: 700; }
.dt-col p { padding: .5rem; margin: 0; word-wrap: break-word; }
.nature-boxes { display: inline-flex; border: 1px solid #222; }
.nature-boxes span { width: 1.4rem; text-align: center; border-right: 1px solid #222; color: #999; font-size: .75rem; }
.nature-boxes span:last-child { border-right: 0; }
.nature-boxes span.on { color: #000; font-weight: 800; background: #ffe680; }
.info summary { cursor: pointer; font-weight: 600; }

.qr-full { position: fixed; inset: 0; z-index: 50; background: #fff; color: #111; display: grid; place-items: center; overflow: auto; padding: 16px; }
.qr-full-inner { text-align: center; max-width: 360px; width: 100%; }
.qr-full svg { width: min(86vw, 340px); height: auto; }
.qr-title { font-weight: 700; font-size: 1.1rem; }
.qr-full .btn { margin-top: 1rem; background: #111; color: #fff; border-color: #111; }

/* ---------- Datos / empresa ---------- */
.subtabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.subtabs a { padding: .55rem .9rem; text-decoration: none; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
.table tr.muted td { color: var(--muted); }
.table select { min-height: 34px; padding: .25rem .5rem; width: auto; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: .3rem; }
.logo-box { height: 90px; border: 1px dashed var(--border); border-radius: 10px; display: grid; place-items: center; background: #fff; }
.logo-box img { max-height: 76px; max-width: 90%; }
.invite { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.invite code { font-size: 1.5rem; font-weight: 800; letter-spacing: .15em; background: var(--accent-soft); padding: .3rem .8rem; border-radius: 8px; }

/* ---------- Modal y toast ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.3); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.1rem .4rem; }
.modal-head h2 { margin: 0; }
.modal-body { padding: .5rem 1.1rem 1rem; display: flex; flex-direction: column; gap: .8rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.1rem; border-top: 1px solid var(--border); }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 150%); z-index: 60; max-width: calc(100% - 32px);
  background: #1a1a18; color: #fff; padding: .75rem 1.1rem; border-radius: 10px; font-weight: 500; transition: transform .25s; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.toast:not(.show) { visibility: hidden; }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
@media (prefers-color-scheme: dark) { .toast.error { background: #a3221a; } }

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: .4rem .8rem; }
  .brand-text { max-width: 55vw; }
  .nav { order: 3; flex-basis: 100%; }
  .user { margin-left: auto; }
  .user-name { display: none; }
  .grid2, .onb-grid, .form-grid, .row2 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar select { width: 100%; }
  .page-head .btn.primary { width: 100%; }
  .actions .btn { flex: 1 1 calc(50% - .5rem); }
  .actions .btn.primary { flex-basis: 100%; }
  .doc { padding: 1rem; }
  .doc-head { grid-template-columns: 1fr auto; }
  .doc-logo { display: none; }
  .doc-title { text-align: left; }
  .doc-title h2 { font-size: 1.35rem; }
  .doc-qr svg { width: 90px; height: 90px; }
  .doc-fields > div { grid-template-columns: 1fr; gap: .1rem; }
  .doc-table { grid-template-columns: 1fr 1fr; }
  .dt-col { border-bottom: 1px solid #222; }
  .dt-col:nth-child(2n) { border-right: 0; }
  .dt-col:nth-child(5) { grid-column: 1 / -1; border-right: 0; }
  .dt-col.wide { grid-column: 1 / -1; border-bottom: 0; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--border); padding: .4rem 0; }
  .table td { border: 0; padding: .2rem .75rem; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .row-actions { text-align: left; padding-top: .4rem !important; }
}
@media print {
  .topbar, .actions, .info, .demo-banner, .page-head, .toast { display: none !important; }
  body, .main { background: #fff; padding: 0; }
  .doc { box-shadow: none; }
}

/* =================== v2: almacenes =================== */
.upper { text-transform: uppercase; }
.auth-wrap.xwide { max-width: 1100px; }
.onb-grid.three { grid-template-columns: repeat(3, 1fr); align-items: start; }
.narrow { max-width: 520px; }
.plain { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .4rem; }
.filter { margin-bottom: .8rem; max-width: 360px; }
.loading { padding: 2rem; text-align: center; color: var(--muted); }

/* Buscador */
.search { display: flex; flex-direction: column; gap: .75rem; }
.search-main { display: flex; gap: .5rem; }
.search-main input { flex: 1; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 .45rem; font-size: .75rem; }
.chips, .suggest { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 99px; padding: .3rem .8rem; font: inherit; font-size: .85rem; cursor: pointer; }
.chip-btn:hover { border-color: var(--muted); }
.chip-btn.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.adv { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.adv[hidden] { display: none; }
.adv-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: .5rem; }
.results-head { display: flex; justify-content: space-between; align-items: center; margin: .25rem 0 .6rem; gap: .5rem; }

/* Lista de documentos */
.doc-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
.doc-item { display: flex; gap: .9rem; align-items: center; padding: .75rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.doc-item:hover { border-color: var(--muted); }
.doc-item.is-void { opacity: .6; }
.di-date { flex: none; width: 56px; text-align: center; border-radius: 9px; background: var(--surface-2); padding: .3rem 0; line-height: 1.1; }
.di-date b { display: block; font-size: 1.3rem; }
.di-date span { font-size: .72rem; text-transform: uppercase; color: var(--muted); }
.di-date.is-today { background: var(--accent); color: var(--accent-ink); }
.di-date.is-today span { color: var(--accent-ink); }
.di-main { flex: 1; min-width: 0; }
.di-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.di-meta { display: flex; flex-wrap: wrap; gap: .15rem .8rem; font-size: .82rem; color: var(--muted); }
.di-meta .mono { word-break: normal; }
.di-goods { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.di-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; font-size: .9rem; }

/* Formulario */
.shipper { display: flex; gap: .8rem; align-items: center; background: var(--surface-2); border-radius: 10px; padding: .7rem; font-size: .9rem; }
.shipper img { max-width: 80px; max-height: 50px; background: #fff; border-radius: 4px; }
.items { display: flex; flex-direction: column; gap: .4rem; }
.item { display: grid; grid-template-columns: 1fr 90px 110px 110px 36px; gap: .4rem; align-items: center; }
.item.head { font-size: .8rem; font-weight: 600; color: var(--muted); }
.item .icon-btn:disabled { opacity: .3; cursor: default; }
.items-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.total { font-size: 1.05rem; }

/* Documento en pantalla */
.doc-head { grid-template-columns: 130px 1fr 120px; }
.doc-title h2 { text-transform: uppercase; font-size: 1.4rem; font-weight: 700; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1.1rem 0; }
.doc-grid section { border: 1px solid #333; border-radius: 3px; }
.doc-grid h3, .doc-sub { font-size: .72rem; letter-spacing: .02em; }
.doc-grid h3 { background: #eeeeea; padding: .3rem .5rem; border-bottom: 1px solid #333; }
.doc-grid p { padding: .45rem .5rem; margin: 0; font-size: .85rem; }
.doc-sub { margin: .4rem 0; }
table.goods { width: 100%; border-collapse: collapse; font-size: .85rem; margin-bottom: .6rem; }
table.goods th { background: #111; color: #fff; text-align: left; padding: .4rem .5rem; font-size: .75rem; }
table.goods td { padding: .4rem .5rem; border-bottom: 1px solid #ccc; }
table.goods tfoot td { font-weight: 800; border-top: 2px solid #111; border-bottom: 0; }
table.goods .num { text-align: right; white-space: nowrap; }

@media (max-width: 900px) {
  .onb-grid.three { grid-template-columns: 1fr; }
  .adv { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .hide-mobile { display: none; }
  .item { grid-template-columns: 1fr 1fr 36px; }
  .item.head { display: none; }
  .item input[data-k="desc"] { grid-column: 1 / 3; }
  .item .icon-btn { grid-row: 1; grid-column: 3; }
  .item { padding-bottom: .5rem; border-bottom: 1px dashed var(--border); }
  .doc-grid { grid-template-columns: 1fr; }
  .doc-head { grid-template-columns: 1fr auto; }
  .doc-title h2 { font-size: 1.1rem; }
  .di-goods { white-space: normal; }
  .results-head { flex-wrap: wrap; }
}

/* v3: envío y versiones */
.send-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.versions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.versions li { display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 9px; font-size: .88rem; }
.v-num { font-weight: 800; font-family: ui-monospace, Menlo, Consolas, monospace; min-width: 2.2rem; }
.v-main { flex: 1; }
@media (max-width: 760px) { .send-grid { grid-template-columns: 1fr; } }

/* v4: validación y cuotas */
body.ro .w-only { display: none !important; }
.ro-banner, .soon-banner { padding: .6rem 16px; font-size: .9rem; }
.ro-banner { background: var(--danger-soft); color: var(--danger); }
.soon-banner { background: var(--accent-soft); }
.ro-banner a, .soon-banner a { color: inherit; }
.demo-banner .link.cur { font-weight: 800; text-decoration: none; }
.demo-actions { flex-wrap: wrap; gap: .3rem .9rem; align-items: center; }
.chip.orange { background: #ffe2c2; color: #8a4300; border-color: transparent; }
.admin-filters { margin-bottom: .8rem; }
.admin-list { display: flex; flex-direction: column; gap: .8rem; }
.admin-list .card { margin: 0; }
.ai-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.ai-head h2 { margin: 0; }
.ai-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin: .8rem 0; }
.admin-item .actions { margin: 0; }
.notes { background: var(--surface-2); padding: .4rem .6rem; border-radius: 8px; }
.table .num { text-align: right; }
@media (max-width: 760px) { .ai-grid { grid-template-columns: 1fr; } }

/* v5 */
[hidden] { display: none !important; }
.onb-grid { align-items: start; }

/* v6: menú sencillo, mercancía en tarjetas, envío */
.topbar { padding: .5rem 16px; gap: .8rem; }
.nav { gap: .4rem; }
.nav a { display: inline-flex; align-items: center; gap: .45rem; padding: .6rem 1rem; border-radius: 10px; font-size: 1rem; border: 1px solid transparent; }
.nav a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav a.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.nav a:not(.active):hover { background: var(--surface-2); color: var(--text); }
.item { display: block; border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; background: var(--surface-2); }
.item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.item-head .icon-btn { font-size: .85rem; color: var(--danger); }
.item-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.item-grid .span2 { grid-column: span 2; }
.items { gap: .7rem; }
.items-foot { flex-wrap: wrap; }
.send-box { text-align: center; display: flex; flex-direction: column; gap: .8rem; align-items: center; }
.send-who { margin: 0; font-size: 1.05rem; }
.send-phone { font-size: 1.4rem; font-weight: 800; letter-spacing: .04em; }
.btn.big { min-height: 54px; font-size: 1.1rem; width: 100%; max-width: 360px; }
.btn.disabled { opacity: .45; pointer-events: none; }
@media (max-width: 760px) {
  .nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
  .nav a { flex-direction: column; gap: .15rem; padding: .45rem .3rem; font-size: .8rem; justify-content: center; text-align: center; white-space: normal; }
  .nav a svg { width: 24px; height: 24px; }
  .item-grid { grid-template-columns: 1fr 1fr; }
  .item { grid-template-columns: none; padding-bottom: .7rem; border-bottom: 1px solid var(--border); }
  .item input[data-k="desc"] { grid-column: auto; }
}

/* v7 */
.big-check { font-size: 1rem; padding: .6rem .8rem; background: var(--accent-soft); border-radius: 10px; }
.big-check input { width: 20px; height: 20px; accent-color: #1a1a18; }
.items.same-route .route-f { display: none; }
@media (max-width: 760px) { .nav { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); } }

/* v8: instalación en el móvil */
.install-bar { display: flex; align-items: center; gap: .6rem; padding: .55rem 16px; background: #1a1a18; color: #fff; font-size: .9rem; }
.install-bar span { flex: 1; }
.install-bar .icon-btn { color: #fff; }
.install-steps { padding-left: 1.2rem; display: flex; flex-direction: column; gap: .6rem; font-size: 1rem; }
.ios-share { display: inline-block; width: 16px; height: 18px; vertical-align: -3px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 3px 3px; position: relative; margin: 0 2px; }
.ios-share::before { content: ""; position: absolute; left: 50%; top: -9px; width: 2px; height: 14px; background: currentColor; transform: translateX(-50%); }
.ios-share::after { content: ""; position: absolute; left: 50%; top: -9px; width: 7px; height: 7px; border-left: 2px solid currentColor; border-top: 2px solid currentColor; transform: translateX(-50%) rotate(45deg); }
.install-card { text-align: center; }

/* v9: menú inferior en móvil, selección múltiple */
.bottom-nav { display: none; }
.results-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.sel-box { display: none; }
.doc-list.selecting .doc-item { cursor: pointer; }
.doc-list.selecting .sel-box { display: inline-block; width: 26px; height: 26px; border: 2px solid var(--muted); border-radius: 7px; flex: none; }
.doc-item.is-selected { border-color: var(--text); background: var(--accent-soft); }
.doc-item.is-selected .sel-box { background: var(--text); border-color: var(--text); position: relative; }
.doc-item.is-selected .sel-box::after { content: ""; position: absolute; left: 8px; top: 3px; width: 6px; height: 12px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.sel-bar { position: sticky; bottom: 0; z-index: 9; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .7rem 1rem; margin-top: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 -4px 20px rgba(0,0,0,.12); }
.sel-bar #sel-count { flex: 1; }
.nav a { font-size: 1.05rem; padding: .7rem 1.1rem; }
@media (max-width: 760px) {
  .topbar .nav { display: none; }
  .bottom-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--border); padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom)); gap: .2rem; }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .4rem .2rem; border-radius: 10px; text-decoration: none; font-weight: 700; font-size: .78rem; color: var(--muted); text-align: center; }
  .bottom-nav a svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .bottom-nav a.active { background: var(--accent); color: var(--accent-ink); }
  body.has-bottom-nav .main { padding-bottom: 6rem; }
  .sel-bar { bottom: calc(66px + env(safe-area-inset-bottom)); }
}

/* v10: cooperativas */
.chip.blue { background: #dbe8ff; color: #123c8a; border-color: transparent; }
.chip.gray { background: var(--surface-2); color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin: .8rem 0 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 12px); padding: .7rem .9rem; display: flex; flex-direction: column; gap: .15rem; }
.stat b { font-size: 1.35rem; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }
.member-chips { margin-bottom: .7rem; }
.notes { background: var(--surface-2); border-radius: 8px; padding: .45rem .7rem; }

.coop-banner { background: #dbe8ff; color: #123c8a; padding: .6rem 1rem; display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center; justify-content: space-between; font-size: .9rem; }
.coop-banner-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.coop-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.coop-banner .btn.ghost { background: #fff; color: #123c8a; border: 1px solid #123c8a; }
.coop-banner .btn.ghost:hover { background: #eef3ff; }

input.readonly { background: var(--surface-2); color: var(--muted); }

/* v11: tarifas, plazas */
.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .7rem; margin-top: .6rem; text-align: left; }
.prices.one { grid-template-columns: 1fr; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .9rem; }
.price-card h3 { margin: 0 0 .2rem; font-size: 1rem; }
.price-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.price-table td { padding: .25rem 0; border-top: 1px solid var(--border); }
.price-table td.num { text-align: right; white-space: nowrap; }
.prices-foot { grid-column: 1 / -1; color: var(--muted); margin: 0; }
.tarifas summary { cursor: pointer; }
.auth-card .prices { text-align: left; }
.price-table tr.internal td { color: var(--muted); font-style: italic; }

/* v12: desplegable de sugerencias propio */
.pick { position: relative; display: flex; align-items: stretch; }
.pick input { flex: 1; min-width: 0; padding-right: 2.4rem; }
.pick-btn { position: absolute; right: 0; top: 0; bottom: 0; width: 2.4rem; border: 0; background: transparent; color: var(--muted); font-size: 1rem; cursor: pointer; border-radius: 0 10px 10px 0; }
.pick-btn:hover { color: var(--text); background: var(--surface-2); }
.pick-menu { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; max-height: 15rem; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); margin-top: .2rem; }
.pick-item { display: flex; flex-direction: column; width: 100%; text-align: left; border: 0; background: transparent; padding: .55rem .75rem; font: inherit; cursor: pointer; border-bottom: 1px solid var(--border); }
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover, .pick-item:focus { background: var(--surface-2); }
.pick-item small { color: var(--muted); font-size: .78rem; }

/* v13: barra de carga */
body.busy::before { content: ""; position: fixed; top: 0; left: 0; height: 3px; width: 30%; background: var(--primary); z-index: 1000; animation: busy 1s ease-in-out infinite; border-radius: 0 3px 3px 0; }
@keyframes busy { 0% { left: -30%; } 100% { left: 100%; } }
.boot { display: flex; align-items: center; justify-content: center; min-height: 60vh; color: var(--muted); }

/* v14: báscula */
.scale-box { border-left: 4px solid var(--primary); }
.scale-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .8rem; margin-bottom: .5rem; }
.scale-head h2 { margin: 0; font-size: 1.05rem; }
.scale-tools { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.scale-status { font-size: .82rem; font-weight: 600; }
.scale-status.ok { color: var(--green); }
.scale-status.off { color: #b45a00; }
.scale-list { display: flex; flex-direction: column; gap: .5rem; }
.scale-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .8rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.scale-item.is-test { border-style: dashed; }
.si-main { min-width: 0; flex: 1 1 260px; }
.si-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.scale-notice { border-left: 4px solid var(--primary); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.access-box { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; background: var(--surface-2); border-radius: 10px; padding: .8rem 1rem; margin: .6rem 0; }
.access-box b { font-size: 1.15rem; }

a.center-block { text-align: center; }

/* v16 · viajes repetidos */
.doc-wrap { display: flex; flex-direction: column; }
.doc-wrap > .doc-item { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.di-again { background: var(--surface); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: .4rem .9rem; display: flex; justify-content: flex-end; }
.doc-group { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent, #f5c400); border-radius: var(--radius); }
.dg-head { display: flex; gap: .9rem; align-items: center; padding: .75rem .9rem .4rem; }
.dg-actions { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .9rem .7rem; }
.dg-list { display: flex; flex-direction: column; gap: .4rem; padding: 0 .6rem .6rem; }
.dg-list .doc-item { background: var(--surface-2, #f6f6f3); }
.trip-notice { background: #fff4c2; color: #5a4500; }

/* v17 · usuarios de la empresa */
.user-list { display: flex; flex-direction: column; }
.user-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; padding: .65rem 0; border-top: 1px solid var(--border); }
.user-row.is-off { opacity: .6; }
.user-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* v18 · empresa de transportes: transportista o cargador en cada porte */
.role-pick { background: var(--surface-2, #f6f6f3); border-radius: 12px; padding: .7rem .8rem; margin-bottom: .8rem; }
.role-pick > p { margin: 0 0 .5rem; }
.role-opts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.role-opt { display: flex; gap: .5rem; align-items: flex-start; background: var(--surface, #fff); border: 2px solid var(--border); border-radius: 10px; padding: .55rem .65rem; cursor: pointer; }
.role-opt:has(input:checked) { border-color: var(--text, #111); background: var(--accent-soft, #fff4c2); }
.role-opt input { margin-top: .2rem; }
.role-opt span { display: flex; flex-direction: column; line-height: 1.25; }
.role-opt small { color: var(--muted); font-weight: 400; }
.pick.locked .pick-btn, .pick.locked .pick-menu { display: none !important; }
.role-opt { flex-direction: row; font-weight: 400; }
.role-opt input[type=radio] { width: 1.1rem; height: 1.1rem; min-height: 0; padding: 0; margin: .15rem 0 0; flex: none; accent-color: #111; box-shadow: none; border: 0; }
.role-opt:has(input:focus-visible) { outline: 2px solid var(--accent, #f5c400); outline-offset: 2px; }
