/* LCDP Express — sistema visual de La Casa del Plástico */
:root {
  --azul: #193691;
  --rojo: #E01700;
  --azul-soft: #E7EBF8;
  --rojo-soft: #FDE8E5;
  --bg: #FFFFFF;
  --surface: #F3F5FB;
  --ink: #172244;
  --ink-2: #3B4666;
  --muted: #6B7592;
  --line: #D9DEEC;
  --line-strong: #B7C0DC;
  --on-brand: #FFFFFF;
  --ok: #1E6B45;
  --ok-soft: #E3F2EA;
  --logo-plate: transparent;
  --logo-pad: 0;
  --font-display: "Bricolage Grotesque", "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --azul: #7F98F0;
    --rojo: #FF6D5A;
    --azul-soft: #1C2750;
    --rojo-soft: #3A1F1C;
    --bg: #0E152B;
    --surface: #151E3A;
    --ink: #E9EDF8;
    --ink-2: #C3CBE3;
    --muted: #95A0C2;
    --line: #2A3558;
    --line-strong: #3D4B7A;
    --on-brand: #0E152B;
    --ok: #6FD3A0;
    --ok-soft: #173427;
    --logo-plate: #FFFFFF;
    --logo-pad: 4px 8px;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2, h3 { margin: 0; font-family: var(--font-display); letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--azul); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--rojo); outline-offset: 3px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }

/* ---------- Encabezado ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 24px 10px;
  background: var(--bg); border-bottom: 3px solid var(--rojo);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.plate { display: block; background: var(--logo-plate); padding: var(--logo-pad); border-radius: 8px; }
.plate img { display: block; height: 44px; width: auto; }
.app-name { font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--azul); }
.top nav { display: flex; gap: 4px; }
.top nav a {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border-radius: 8px; color: var(--ink-2); font-weight: 600; text-decoration: none;
}
.top nav a:hover { background: var(--azul-soft); }
.top nav a.on { background: var(--azul-soft); color: var(--azul); }
.badge {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
  background: var(--rojo); color: var(--on-brand); font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink);
  font: 600 15px/1.2 var(--font-body); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--azul); color: var(--azul); }
.btn.primary { background: var(--azul); border-color: var(--azul); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.12); color: var(--on-brand); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--rojo); border-color: var(--rojo); color: var(--on-brand); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.btn.armed, .link.armed { background: var(--rojo); border-color: var(--rojo); color: var(--on-brand); }
.link {
  background: none; border: 0; padding: 6px 4px; min-height: 36px; cursor: pointer;
  color: var(--azul); font: 600 14px var(--font-body); text-decoration: underline; text-underline-offset: 3px;
}
.link.armed { border-radius: 6px; padding: 6px 10px; text-decoration: none; }

/* ---------- Estructura ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 30px; line-height: 1.15; font-weight: 700; color: var(--azul); }
.sub { margin-top: 6px; color: var(--muted); max-width: 62ch; }
.crumb { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); }
.panel { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.panel h2, .hoy h2 { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.flash { margin-bottom: 18px; padding: 12px 16px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.flash.error { background: var(--rojo-soft); color: var(--rojo); }
.empty { text-align: center; padding: 56px 20px; background: var(--bg); border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--azul); }
.empty h2 { font-size: 22px; margin: 12px 0 4px; color: var(--ink); }
.empty p { color: var(--muted); margin-bottom: 18px; }

/* ---------- Pendientes ---------- */
.sum { display: flex; gap: 28px; margin: 0; }
.sum div { text-align: right; }
.sum dt { font-size: 13px; color: var(--muted); }
.sum dd { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--azul); font-variant-numeric: tabular-nums; }
.bulkbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.check-all { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink-2); font-weight: 600; cursor: pointer; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--azul); cursor: pointer; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: start;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.card:has(input:checked) { border-color: var(--azul); box-shadow: 0 0 0 2px var(--azul-soft); }
.pick { display: grid; place-items: center; width: 36px; height: 36px; cursor: pointer; }
.row1 { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; }
.cliente { font-size: 18px; font-weight: 700; color: var(--ink); text-decoration: none; }
.cliente:hover { color: var(--azul); text-decoration: underline; }
.age { font-size: 14px; color: var(--muted); }
.card.viejo .age { color: var(--rojo); font-weight: 700; }
.dir { color: var(--ink-2); margin-top: 2px; }
.nota { margin-top: 6px; padding: 4px 10px; border-left: 3px solid var(--rojo); background: var(--rojo-soft); color: var(--ink-2); font-size: 14px; border-radius: 0 6px 6px 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.meta b { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.express { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--azul); font-variant-numeric: tabular-nums; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.cliente { background: var(--azul-soft); color: var(--azul); }
.chip.tienda { background: var(--rojo-soft); color: var(--rojo); }
.hoy { margin-top: 36px; }
.mini { list-style: none; margin: 0; padding: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.mini li { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.mini li:last-child { border-bottom: 0; }
.mini a { font-weight: 600; color: var(--ink); }
.mini form { margin-left: auto; }

/* ---------- Formulario ---------- */
.form .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.span2 { grid-column: span 2; }
.field { margin: 0; min-width: 0; }
.field > label, .field legend, .anular label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
input:not([type=checkbox]):not([type=radio]) {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink);
  font: 16px var(--font-body);
}
input:not([type=checkbox]):not([type=radio]):focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px var(--azul-soft); }
.field.bad input { border-color: var(--rojo); }
.err { margin-top: 6px; color: var(--rojo); font-size: 14px; font-weight: 600; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.qbtn {
  min-height: 36px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  font: 600 14px var(--font-body); font-variant-numeric: tabular-nums;
}
.qbtn:hover { border-color: var(--azul); color: var(--azul); }
.seg { border: 0; padding: 0; }
.seg-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 420px; }
.seg-opts label { position: relative; cursor: pointer; }
.seg-opts input { position: absolute; opacity: 0; inset: 0; }
.seg-opts span {
  display: flex; align-items: center; justify-content: center; min-height: 46px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg); font-weight: 600; color: var(--ink-2);
}
.seg-opts input:checked + span { background: var(--azul); border-color: var(--azul); color: var(--on-brand); }
.seg-opts input:focus-visible + span { outline: 2px solid var(--rojo); outline-offset: 3px; }
.seg.bad .seg-opts span { border-color: var(--rojo); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- Orden ---------- */
.two { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
.datos dt { font-size: 13px; color: var(--muted); }
.datos dd { margin: 2px 0 0; font-weight: 500; }
.acciones form { margin-bottom: 10px; }
.anular { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.anular summary { cursor: pointer; color: var(--rojo); font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.anular form { margin-top: 10px; display: grid; gap: 10px; }
.estado { display: inline-block; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.estado.sm { padding: 2px 10px; font-size: 13px; }
.estado.pendiente { background: var(--rojo-soft); color: var(--rojo); }
.estado.recogida { background: var(--ok-soft); color: var(--ok); }
.estado.anulada { background: var(--line); color: var(--muted); }
.editar summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
.editar summary::-webkit-details-marker { display: none; }
.editar summary h2 { margin: 0; }
.editar summary::after { content: "Mostrar"; font-size: 14px; color: var(--azul); font-weight: 600; }
.editar[open] summary { margin-bottom: 16px; }
.editar[open] summary::after { content: "Ocultar"; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 190px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.hist li:last-child { border-bottom: 0; }
.when { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Semana ---------- */
.weeknav { display: flex; gap: 8px; flex-wrap: wrap; }
.weeknav .btn.ghost[aria-label] { padding: 0 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi span { display: block; font-size: 13px; color: var(--muted); }
.kpi b { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi.main { border-color: var(--azul); box-shadow: inset 0 3px 0 var(--azul); }
.kpi.main b { color: var(--azul); }
.kpi.alerta b { color: var(--rojo); }
.tw { overflow-x: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; }
table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 14.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--surface); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td a { color: var(--ink); font-weight: 600; }
td:nth-child(2), td:nth-child(3) { min-width: 150px; }
.r { text-align: right; }
.nw { white-space: nowrap; }
tr.anulada td { color: var(--muted); text-decoration: line-through; }
tr.anulada td .chip, tr.anulada td .estado { text-decoration: none; }
tfoot td { font-weight: 700; border-bottom: 0; background: var(--surface); }
tfoot .strong { color: var(--azul); font-family: var(--font-display); font-size: 17px; }
.cajeras ul { list-style: none; margin: 0; padding: 0; }
.cajeras li { display: grid; grid-template-columns: 1fr auto 120px; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cajeras li:last-child { border-bottom: 0; }
.cajeras b { text-align: right; }

/* ---------- Login ---------- */
.login { max-width: 420px; margin: 8vh auto 0; text-align: center; background: var(--bg); border: 1px solid var(--line); border-top: 4px solid var(--rojo); border-radius: var(--radius); padding: 36px 28px; }
.login .plate.big { display: inline-block; padding: 8px 12px; }
.login .plate.big img { height: auto; width: 200px; }
.login h1 { font-size: 28px; font-weight: 800; color: var(--azul); margin-top: 18px; }
.login > p { color: var(--muted); margin: 4px 0 24px; }
.login .small { margin-top: 16px; }

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .top { padding-left: 16px; padding-right: 16px; gap: 8px 12px; }
  .plate img { height: 36px; }
  .app-name { font-size: 19px; }
  .top nav { order: 3; width: 100%; }
  .top nav a { flex: 1; justify-content: center; }
  .top .nueva { margin-left: auto; padding: 0 14px; }
  .who { margin-left: 0; order: 2; }
  .who span { display: none; }
  .wrap { padding: 20px 16px 72px; }
  .page-head h1 { font-size: 24px; }
  .sum { gap: 20px; }
  .sum div { text-align: left; }
  .card { grid-template-columns: 32px minmax(0, 1fr); padding: 14px; }
  .side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }
  .side .btn { width: 100%; }
  .form .grid, .datos { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .two { grid-template-columns: 1fr; }
  .hist li { grid-template-columns: 1fr; gap: 2px; }
  .actions .btn { flex: 1; }
  .cajeras li { grid-template-columns: 1fr auto; }
  .cajeras li .muted { grid-column: 1; grid-row: 2; font-size: 14px; }
  .cajeras b { grid-row: 1 / 3; grid-column: 2; align-self: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
