/* Sistema de proveedores Dos Bocas. Una columna tipo libreta; números grandes primero, detalle después. */
:root {
  /* Marca Dos Bocas: crema, azul marino y el rojo del sello. */
  --bg: #f4efe3; --paper: #fffcf6; --ink: #1f2a44; --muted: #5d6476; --line: #e3dac8; --line-2: #d3c8b2;
  --marca: #a8321d; --marca-soft: #f6e3dc;
  --accent: #1f2a44; --accent-soft: #e7e9ef; --on-accent: #f4efe3;
  --ok: #2f7a4b; --ok-soft: #dfeee2; --warn: #9a5a07; --warn-soft: #f7e7c8; --bad: #b3261e; --bad-soft: #f6dcd8;
  --sombra: 0 1px 0 rgb(31 42 68 / .04), 0 10px 28px -18px rgb(31 42 68 / .35);
  --radio: 14px;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161f; --paper: #19202d; --ink: #f1ebdd; --muted: #a5abb9; --line: #2a3243; --line-2: #3a4459;
    --marca: #ec8a72; --marca-soft: #3a211b;
    --accent: #f1ebdd; --accent-soft: #263046; --on-accent: #11161f;
    --ok: #7fd39a; --ok-soft: #173126; --warn: #f2b65c; --warn-soft: #3a2b12; --bad: #ff8f84; --bad-soft: #3e1d1b;
    --sombra: 0 1px 0 rgb(0 0 0 / .2), 0 12px 30px -20px rgb(0 0 0 / .7);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
[hidden] { display: none !important; }

header.top { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.in { max-width: 1320px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px), 3vw); padding-right: max(16px, env(safe-area-inset-right, 0px), 3vw); }
@media (min-width: 1600px) { .in { padding-left: 48px; padding-right: 48px; } }
header.top .in { display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 10px; }
.marca { display: flex; align-items: center; gap: 10px; }
.marca img { width: 40px; height: 40px; flex: none; transition: transform .4s var(--ease, ease); }
.marca:hover img { transform: rotate(-12deg); }
.brand h1 span { color: var(--marca); }
.brand h1 { font: 800 21px/1.1 var(--display); margin: 0; letter-spacing: -.01em; }
.brand small { color: var(--muted); font-size: 12px; }
nav { display: flex; gap: 2px; overflow-x: auto; margin-top: 6px; scrollbar-width: none; }
nav a { flex: none; padding: 9px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; transition: color .15s; }
nav a:hover { color: var(--ink); }
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--marca); }
@media (min-width: 960px) {
  header.top .in { flex-direction: row; align-items: center; gap: 32px; }
  .brand { padding: 12px 0; flex: 1; order: 0; }
  nav { margin: 0; order: 1; gap: 4px; }
  nav a { padding: 8px 14px; border: 0; border-radius: 99px; }
  nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
  .brand small { order: 2; }
}
main.in { padding-block: 24px 72px; display: flex; flex-direction: column; gap: 20px; }
/* Computadora: 12 columnas. Por omisión todo va a lo ancho; .ancho (7), .lado (5) y .mitad (6) se acomodan en pares. */
@media (min-width: 1100px) {
  main.in { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; align-items: start; grid-auto-flow: row dense; }
  main.in > * { grid-column: 1 / -1; }
  main.in > .ancho { grid-column: span 7; }
  main.in > .lado { grid-column: span 5; }
  main.in > .mitad { grid-column: span 6; }
  .tiles .tile:first-child .big { font-size: 34px; }
}

h2 { font: 800 clamp(24px, 1.2rem + 1vw, 32px)/1.12 var(--display); margin: 0; text-wrap: balance; letter-spacing: -.015em; }
h3 { font: 600 14px/1.3 var(--body); color: var(--muted); margin: 0; }
p { margin: 0; max-width: 65ch; }
.lead { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 760px) { .tiles { gap: 16px; } }
.tile { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radio); padding: 16px 16px 16px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; box-shadow: var(--sombra); overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: 14px auto 14px 0; width: 4px; border-radius: 0 4px 4px 0; background: var(--line-2); }
.tile.ok::before { background: var(--ok); } .tile.warn::before { background: var(--warn); } .tile.bad::before { background: var(--bad); }
.big { font: 800 28px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; overflow-wrap: anywhere; }
.tile .sub { font-size: 13px; color: var(--muted); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radio); padding: 18px; min-width: 0; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--sombra); }
@media (min-width: 1100px) { .card { padding: 22px; } }
.hero { position: relative; overflow: hidden; background: var(--accent); color: var(--on-accent); border-radius: calc(var(--radio) + 2px); padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--sombra); }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; border: 18px solid var(--marca); opacity: .9; }
.hero > * { position: relative; z-index: 1; }
.hero h3 { color: inherit; opacity: .85; }
.hero .big { font-size: 38px; }
.hero .sub { opacity: .9; font-size: 14px; }

.pill { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.n { background: var(--accent-soft); color: var(--accent); }
.pill.gris { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.anulada td { color: var(--muted); text-decoration: line-through; }
.tbl tr.clic { cursor: pointer; }
.tbl tr.clic:hover td { background: var(--accent-soft); }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }

.lista { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radio); overflow: hidden; box-shadow: var(--sombra); }
.lista-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.lista-h b { font: 800 17px/1.2 var(--display); }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .who { font-weight: 600; overflow-wrap: anywhere; }
.item .meta { font-size: 12px; color: var(--muted); }
.item .acciones { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.item.hecho { opacity: .55; }

button, .btn { font: 600 14px var(--body); border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 10px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; }
button.primary, .btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button.peligro { color: var(--bad); border-color: var(--bad); }
button.chico { min-height: 34px; padding: 6px 10px; font-size: 13px; }
button.link { border: 0; background: none; padding: 4px 6px; min-height: 0; color: var(--accent); font-size: 13px; }
button, .btn { transition: background-color .15s, border-color .15s, transform .1s; }
button:hover, .btn:hover { border-color: var(--line-2); } button.primary:hover, .btn.primary:hover { filter: brightness(1.12); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.form.row-wrap { display: flex; align-items: flex-end; }
.form.row-wrap > .full { flex: 1 1 260px; }
label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
input, select, textarea { font: 500 16px var(--body); padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.full { grid-column: 1 / -1; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button { border: 0; border-radius: 0; background: var(--bg); color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.note { font-size: 14px; border-radius: 10px; padding: 10px 12px; background: var(--accent-soft); }
.note.warn { background: var(--warn-soft); } .note.bad { background: var(--bad-soft); } .note.ok { background: var(--ok-soft); }
.meter { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ok); border-radius: 99px; width: 0; }
.meter i.warn { background: var(--warn); } .meter i.bad { background: var(--bad); }
.barra-ant { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--line); }
.barra-ant i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.c0 { background: var(--ok); } .c1 { background: #7da35a; } .c2 { background: var(--warn); } .c3 { background: #c86a3a; } .c4 { background: var(--marca); }
svg text { fill: var(--muted); font: 11px var(--body); }

.mov { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mov:last-child { border-bottom: 0; }
.mov time { font-size: 12px; color: var(--muted); white-space: nowrap; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: 12px; max-width: min(92vw, 520px); z-index: 20; font-size: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / .25); }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); padding: 18px; width: min(92vw, 460px); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
.vacio { text-align: center; color: var(--muted); padding: 24px 12px; }
.solo-impresion { display: none; }

@media print {
  header.top, nav, .no-imprimir, button, .toast { display: none !important; }
  body { background: #fff; color: #000; font-size: 11px; }
  .card, .lista { border: 0; padding: 0; }
  .solo-impresion { display: block; }
  main.in { padding: 0; }
}
@media (prefers-reduced-motion: no-preference) { .item, .tile { transition: opacity .2s; } }
.stack-s > button.link { align-self: flex-start; padding-left: 0; }
ul.pedidos { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
details > summary { cursor: pointer; font-weight: 600; color: var(--ink); padding: 4px 0; }
details[open] > summary { margin-bottom: 8px; }

/* Juntar facturas: cada proveedor es un desplegable con su tabla. */
[hidden] { display: none !important; }
details.lista > summary.lista-h { margin: 0; padding: 12px 16px; list-style: none; }
details.lista > summary.lista-h::-webkit-details-marker { display: none; }
details.lista:not([open]) > summary.lista-h { border-bottom: 0; }
details.lista[open] > summary.lista-h { background: var(--accent-soft); }
.tbl td input[inputmode="decimal"] { max-width: 120px; text-align: right; }

/* Entrar y cuenta */
.entrar { max-width: 420px; margin: 8vh auto 0; }
.cuenta { display: flex; gap: 14px; align-items: center; }
.cuenta .link { font-size: 13px; color: var(--muted); }
@media (max-width: 959px) { .cuenta { grid-column: 1 / -1; } }

/* Buscador de proveedor (Compra): lista propia porque el datalist falla en iPad. */
.buscador { display: grid; gap: 6px; }
.buscador .caja { position: relative; }
.sug { list-style: none; margin: 0; padding: 4px; position: absolute; z-index: 6; top: calc(100% + 4px); left: 0; right: 0;
  max-height: min(55vh, 420px); overflow-y: auto; background: var(--paper); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(0 0 0 / .18); }
.sug button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink); padding: 12px; min-height: 48px; }
.sug button span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.sug button:hover, .sug button:focus-visible { background: var(--accent-soft); outline: none; }
.sug .sug-alta { color: var(--accent); font-weight: 600; }
.sug-nada { padding: 12px; color: var(--muted); font-size: 14px; }
input[aria-invalid="true"] { border-color: var(--warn); }

/* Compra: navegar entre semanas y la compra que se está editando */
.semana-nav { display: flex; align-items: center; gap: 8px; min-width: 0; }
.semana-nav b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.semana-nav button { min-width: 34px; padding: 4px 8px; font-size: 18px; line-height: 1; }
.semana-nav button:disabled { opacity: .35; cursor: default; }
.item.editando { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

/* Lunes: marcar transferencias hechas y referencia corta */
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; cursor: pointer; }
.item .acciones input:not([type="checkbox"]) { max-width: 240px; font-size: 14px; padding: 6px 10px; }
.hero .between b { font-variant-numeric: tabular-nums; }
