/* Dashboard de Joca. Parte de la base de las maquetas aprobadas (base.css). */
:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface-1: #fcfcfb;
  --surface-2: #f3f3f0;
  --surface-hover: #f7f7f4;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-input: rgba(11, 11, 11, 0.18);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: #e8f1fc;
  --good: #0ca30c;
  --good-ink: #0b7a0b;
  --warning: #c98a00;
  --warning-wash: #fdf3d8;
  --warning-ink: #7a5300;
  --serious: #ec835a;
  --critical: #d23b2f;
  --critical-ink: #a8271d;
  --critical-wash: #fdecea;
  --saman: #6250d6;
  --pos: #2a78d6;
  --neg: #eb6834;
  --nav: #16201c;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.ic { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; vertical-align: -0.15em; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }

/* Estructura */
.app { --side-w: 224px; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(90deg, var(--nav) var(--side-w), var(--page) var(--side-w)); }
.side {
  background: var(--nav); color: #d9ddd9; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: #fff; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: #2f6b4f; flex: none;
  display: grid; place-items: center;
}
.brand b { font-size: 15px; letter-spacing: -0.01em; }
.brand small { display: block; color: #9aa59f; font-size: 11.5px; font-weight: 400; }
.copia {
  margin: 0 8px 16px; padding: 7px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.3;
  background: rgba(255, 255, 255, 0.06); color: #d9ddd9; border: 1px solid rgba(255, 255, 255, 0.10);
}
.copia b { display: block; font-size: 14px; color: #fff; letter-spacing: 0.01em; }
.copia.prueba { background: #f2c94c; color: #3d2f00; border-color: #f2c94c; }
.copia.prueba b { color: #2a2000; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: #c9cfca; text-decoration: none; font-size: 13.5px;
}
.nav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav a.on { background: rgba(255, 255, 255, 0.09); color: #fff; font-weight: 600; }
.nav a .badge {
  margin-left: auto; background: rgba(255, 255, 255, 0.14); color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 650; padding: 0 7px; line-height: 18px;
}
.nav svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: none; }
.nav a.fuera { margin-top: 10px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); border-radius: 0 0 8px 8px; color: #9aa59f; font-size: 13px; }
.nav a.fuera .sale { margin-left: auto; color: #6f7a74; }
.side .foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 14px 10px 0; font-size: 12px; color: #9aa59f; }
.side .foot div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; white-space: nowrap; }
.side .foot span:last-child { color: #d9ddd9; text-align: right; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; flex: none; }
main { padding: 22px 28px 40px; min-width: 0; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: -0.015em; font-weight: 650; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top .sub { color: var(--text-secondary); margin-top: 2px; font-size: 13.5px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.crumb a { color: var(--accent-ink); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

/* Botones y enlaces */
.btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 550; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; line-height: 1.45;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: default; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.danger { color: var(--critical-ink); border-color: rgba(210, 59, 47, 0.35); }
.btn.danger:hover { background: var(--critical-wash); }
.btn.add { padding: 3px 9px; font-size: 12px; border-color: var(--accent); color: var(--accent-ink); background: var(--surface-1); }
.btn.add:hover { background: var(--accent-wash); }
.btn.add svg { width: 13px; height: 13px; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.btn:focus-visible, .link:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.link {
  color: var(--accent-ink); font-weight: 550; font-size: 12.5px; text-decoration: none; white-space: nowrap;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.link:hover { text-decoration: underline; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 2px; background: var(--surface-1); }
.seg a, .seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 550; color: var(--text-secondary); text-decoration: none; cursor: pointer; }
.seg .on { background: var(--surface-2); color: var(--text-primary); }

/* Tarjetas */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; min-width: 0; }
.card h2 { font-size: 14.5px; margin: 0; font-weight: 650; letter-spacing: -0.005em; }
.card .hint { color: var(--text-secondary); font-size: 12.5px; margin-top: 2px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .actions { align-self: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; align-items: start; }
.grid2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid2.wide { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 12px; }
.tiles.t7 { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.tile { padding: 14px 16px; }
.tl { font-size: 12.5px; color: var(--text-secondary); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.tv { font-size: 28px; font-weight: 650; letter-spacing: -0.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tv small { font-size: 14px; font-weight: 550; color: var(--text-secondary); letter-spacing: 0; }
.tiles.t7 .tv { font-size: 23px; }
.ts { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* Tablas */
.tabla { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; padding: 0 10px 8px; border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
td { padding: 10px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nw { white-space: nowrap; }
table.cl td { white-space: nowrap; padding: 10px 8px; font-size: 13px; }
table.cl th { padding: 0 8px 8px; }
table.compact td { padding: 7px 8px; font-size: 13px; }
table.compact th { padding: 0 8px 7px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-hover); }
tr.anul td { background: #faf9f6; color: var(--text-muted); }
tr.anul s { color: var(--text-muted); }
tr.conf td { background: var(--warning-wash); }
.sub-line { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.muted { color: var(--text-muted); }
.sec { color: var(--text-secondary); }
.small { font-size: 12.5px; }
.vacio { color: var(--text-muted); font-size: 13px; padding: 14px 0 4px; }
.vacio.ok { color: var(--good-ink); font-weight: 550; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 550; background: var(--surface-2); color: var(--text-primary); white-space: nowrap;
  line-height: 1.5; letter-spacing: 0; text-transform: none;
}
.chip .dot { margin: 0; }
.chip.azul { background: var(--accent-wash); }
.chip.aviso { background: var(--warning-wash); color: var(--warning-ink); }
.chip.mal { background: var(--critical-wash); color: var(--critical-ink); }
.chip svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; color: var(--text-secondary); background: var(--surface-2); border-radius: 5px; padding: 0 6px; line-height: 18px; vertical-align: 1px; white-space: nowrap; }
.tag.aviso { background: var(--warning-wash); color: var(--warning-ink); }
.tag.mal { background: var(--critical-wash); color: var(--critical-ink); }
.cam { display: inline-flex; align-items: center; gap: 5px; color: var(--text-secondary); }
.cam svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* Hoy */
ul.pend { list-style: none; margin: 0; padding: 0; }
ul.pend li { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
ul.pend li:last-child { border-bottom: 0; }
ul.pend li:first-child { padding-top: 2px; }
ul.pend li .btn { flex: none; }
ul.pend .pend-botones { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
ul.pend .pt { font-weight: 650; }
ul.pend .pd { color: var(--text-secondary); font-size: 12.5px; }
.chartfoot { display: flex; justify-content: space-between; gap: 12px; color: var(--text-muted); font-size: 12px; margin-top: 6px; flex-wrap: wrap; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tick { font-size: 11px; fill: var(--text-muted); font-family: var(--font); }
.chart .val { font-size: 11.5px; fill: var(--text-primary); font-weight: 600; font-family: var(--font); }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar { fill: var(--series-1); }
.tip {
  position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); border-radius: 9px; padding: 8px 10px; font-size: 12.5px;
  white-space: nowrap; z-index: 2; transform: translate(-50%, -100%); margin-top: -8px;
}
.tip b { display: block; margin-bottom: 2px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r span:last-child { font-variant-numeric: tabular-nums; }
.planilla-ult { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Filtros */
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; padding: 12px 14px; flex-wrap: wrap; }
.search { flex: 1 1 320px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border-input); border-radius: 9px; padding: 0 12px; background: #fff; }
.search svg { width: 17px; height: 17px; stroke: var(--text-secondary); fill: none; stroke-width: 1.9; flex: none; }
.search input { border: 0; outline: 0; background: transparent; padding: 9px 0; font-size: 14.5px; flex: 1; min-width: 0; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.sel { border: 1px solid var(--border); border-radius: 9px; padding: 0 4px 0 12px; background: var(--surface-1); font-size: 13px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.sel > span { color: var(--text-muted); }
.sel input, .sel select { border: 0; background: transparent; padding: 8px 6px 8px 0; font-size: 13px; outline: 0; }
.sel:focus-within { border-color: var(--accent); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; font-size: 12.5px; color: var(--text-secondary); flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; align-items: center; }

/* Ficha */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.photos figure { margin: 0; }
.photos button { padding: 0; border: 0; background: var(--surface-2); border-radius: 8px; overflow: hidden; display: block; width: 100%; aspect-ratio: 3 / 2; cursor: zoom-in; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos figcaption { font-size: 12px; color: var(--text-secondary); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.seal { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
ul.hist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
ul.hist li { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--grid); }
ul.hist li:last-child { border-bottom: 0; }
ul.hist .q { color: var(--text-muted); font-size: 12px; }
.barra { margin: 4px 0 2px; }
.barra svg { display: block; width: 100%; height: 44px; }
.barra .tick { font-size: 11px; fill: var(--text-muted); font-family: var(--font); }
.aviso-box { border-radius: 10px; padding: 10px 12px; font-size: 13px; background: var(--warning-wash); color: var(--warning-ink); }
.aviso-box.mal { background: var(--critical-wash); color: var(--critical-ink); }
.aviso-box.ok { background: #e7f5e7; color: var(--good-ink); }
.aviso-box.info { background: var(--accent-wash); color: var(--accent-ink); }
.aviso-box b { color: inherit; }
.progreso { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; display: flex; gap: 2px; min-width: 90px; }
.progreso i { display: block; height: 100%; }
.progreso .p1 { background: var(--good); }
.progreso .p2 { background: var(--series-1); }

/* Planillas: corrección en línea */
.fix { display: grid; grid-template-columns: 1.4fr repeat(5, minmax(52px, 1fr)) auto; gap: 6px; align-items: end; margin-top: 8px; }
.fix label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 2px; }
.fix input { width: 100%; border: 1px solid var(--border-input); border-radius: 7px; padding: 6px 8px; background: #fff; font-size: 13px; font-variant-numeric: tabular-nums; }
.fix input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.fix .btns { display: flex; gap: 6px; }
ul.revisar { list-style: none; margin: 0; padding: 0; }
ul.revisar > li { padding: 12px 0; border-bottom: 1px solid var(--grid); }
ul.revisar > li:last-child { border-bottom: 0; }
.datos { font-size: 12px; color: var(--text-secondary); margin-top: 2px; word-break: break-word; }
.datos code { font-family: inherit; background: var(--surface-2); border-radius: 4px; padding: 0 4px; }

/* Estado */
dl.kv { display: grid; grid-template-columns: auto 1fr; margin: 0; row-gap: 8px; column-gap: 16px; font-size: 13px; }
dl.kv dt { color: var(--text-secondary); }
dl.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.fecha-in { width: 104px; }
/* Campo de fecha con el botón del calendario adentro, a la derecha */
.campo-fecha { position: relative; display: block; }
.sel .campo-fecha { display: inline-block; }
.campo-fecha > input:not([type="date"]) { width: 100%; padding-right: 34px !important; box-sizing: border-box; }
.sel .campo-fecha > input.fecha-in { width: 132px; }
.campo-fecha > input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.btn-calendario { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--text-muted); padding: 5px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.btn-calendario:hover, .btn-calendario:focus-visible { color: var(--accent); background: var(--accent-wash); }
.btn-calendario svg { width: 17px; height: 17px; }

/* Diálogos */
.scrim { position: fixed; inset: 0; background: rgba(11, 11, 11, 0.38); display: flex; align-items: flex-start; justify-content: center; z-index: 20; overflow-y: auto; padding: 6vh 16px 32px; }
.modal { width: 540px; max-width: 100%; background: var(--surface-1); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); padding: 22px 24px; }
.modal.ancho { width: 680px; }
.modal h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.mhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.mhead .sec { font-size: 13px; margin-top: 2px; }
.cerrar { border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 2px; border-radius: 6px; flex: none; }
.cerrar:hover { color: var(--text-primary); background: var(--surface-2); }
.cerrar svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; display: block; }
.field { margin-top: 16px; }
.field > label, .field > .lbl { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.opt { font-weight: 400; color: var(--text-muted); }
.input, .modal input[type="text"], .modal input[type="tel"], .modal input[type="number"], .modal select, .modal textarea {
  width: 100%; border: 1px solid var(--border-input); border-radius: 9px; padding: 9px 12px; font-size: 15px; background: #fff;
}
.modal textarea { resize: vertical; min-height: 84px; font-size: 14px; line-height: 1.5; }
.modal input:focus, .modal select:focus, .modal textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.modal input.mal, .modal textarea.mal { border-color: var(--critical); box-shadow: 0 0 0 3px var(--critical-wash); }
.input.fijo { display: flex; justify-content: space-between; align-items: center; background: var(--surface-2); border-color: var(--border); }
.bigwrap { position: relative; }
.bigwrap input.big { font-size: 24px; font-weight: 650; padding: 10px 50px 10px 14px; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); font-variant-numeric: tabular-nums; }
.bigwrap .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; font-weight: 500; pointer-events: none; }
.row2f { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3f { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
/* Grilla de contenedores de una orden, como el resumen del packing list */
.grilla-conts { border: 1px solid var(--border-input); border-radius: 10px; overflow: auto; max-height: 340px; }
.grilla-conts table { min-width: 560px; }
.grilla-conts th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary); padding: 7px 6px; }
.grilla-conts td { padding: 3px; border-top: 1px solid var(--grid); }
.grilla-conts td.n, .grilla-conts th.n { width: 30px; text-align: center; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.grilla-conts th.c-num { width: 31%; }
.grilla-conts th.c-tara { width: 15%; }
.grilla-conts td.q, .grilla-conts th.q { width: 34px; }
.modal .grilla-conts input[type="text"] { padding: 7px 8px; font-size: 14px; border-radius: 7px; font-variant-numeric: tabular-nums; }
.modal .grilla-conts input[data-c="numero"] { font-weight: 600; letter-spacing: 0.02em; }
.grilla-conts .quitar { border: 0; background: transparent; color: var(--text-muted); padding: 6px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.grilla-conts .quitar:hover { color: var(--critical-ink); background: var(--critical-wash); }
.grilla-conts .quitar svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.grilla-pie { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.grilla-pie .fhint { margin-top: 0; }
table.previstos tr.click { cursor: pointer; }
.btn-papelera { border: 0; background: transparent; color: var(--text-muted); padding: 6px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.btn-papelera:hover, .btn-papelera:focus-visible { color: var(--critical-ink); background: var(--critical-wash); }
.btn-papelera svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }
td.q, th.q { width: 40px; padding-left: 0 !important; padding-right: 4px !important; }
/* La papelera queda siempre a la vista aunque la tabla no entre a lo ancho. */
.tabla td.q, .tabla th.q { position: sticky; right: 0; background: var(--surface-1); }
.calc { margin-top: 14px; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; row-gap: 6px; column-gap: 12px; font-size: 13.5px; }
.calc span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.mfoot .izq { margin-right: auto; }
.merror { margin-top: 12px; }
.fhint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.fhint.mal { color: var(--critical-ink); }
.fhint.ok { color: var(--good-ink); }
.fotosel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fotosel img { width: 54px; height: 40px; object-fit: cover; border-radius: 6px; }
.lista-res { max-height: 220px; overflow-y: auto; margin-top: 8px; border: 1px solid var(--grid); border-radius: 9px; }
.lista-res table td { padding: 6px 10px; font-size: 12.5px; }
.lista-res table th { padding: 8px 10px 6px; position: sticky; top: 0; background: var(--surface-1); }
.series-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.series-cols textarea { min-height: 170px; font-variant-numeric: tabular-nums; }

/* Visor de fotos */
.lightbox { position: fixed; inset: 0; background: rgba(8, 10, 9, 0.88); z-index: 30; display: grid; grid-template-rows: auto 1fr; color: #fff; }
.lightbox .lb-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; }
.lightbox .lb-top .btn { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.lightbox .lb-top .btn:hover { background: rgba(255, 255, 255, 0.18); }
.lightbox .lb-img { display: grid; place-items: center; padding: 0 64px 24px; min-height: 0; position: relative; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 90px); object-fit: contain; border-radius: 6px; background: #222; }
.lightbox .nav-l, .lightbox .nav-r { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, 0.12); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.lightbox .nav-l { left: 12px; }
.lightbox .nav-r { right: 12px; }
.lightbox .nav-l svg, .lightbox .nav-r svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Avisos cortos */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast { background: #16201c; color: #fff; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); max-width: 420px; }
.toast.mal { background: var(--critical-ink); }

.cargando-vista { color: var(--text-muted); padding: 40px 0; text-align: center; }
.actualizado { font-size: 12px; color: var(--text-muted); }

/* Pantallas de 1024 a 1280 px */
@media (max-width: 1280px) {
  .app { --side-w: 208px; }
  main { padding: 20px 20px 36px; }
  .grid2, .grid2.wide { grid-template-columns: minmax(0, 1fr); }
  .tv { font-size: 25px; }
}
.solo-angosta { display: none; }
@media (max-width: 1100px) {
  .c-ancha { display: none; }
  .solo-angosta { display: block; }
  table.cl td { padding: 9px 5px; font-size: 12.5px; }
  table.cl th { padding: 0 5px 8px; font-size: 10.5px; white-space: normal; vertical-align: bottom; }
  table.cl .chip { font-size: 11.5px; padding: 1px 8px 1px 7px; }
  .anio-actual { display: none; }
  main { padding: 18px 16px 32px; }
  .card { padding: 14px 14px; }
  .fix { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .fix .btns { grid-column: 1 / -1; justify-content: flex-end; }
}

/* Planilla con otro formato */
.modal.formato { width: 820px; }
table.mapeo td { vertical-align: middle; padding: 5px 10px; }
table.mapeo select { width: 100%; min-width: 180px; font-size: 13.5px; padding: 6px 8px; }
.modal select.mal { border-color: var(--critical); box-shadow: 0 0 0 3px var(--critical-wash); }

/* Precisión */
.grid2.prec { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.formula .ecuacion { font-size: 17px; line-height: 1.6; padding: 12px 14px; background: var(--surface-2); border-radius: 10px; font-variant-numeric: tabular-nums; }
.formula .ecuacion b { font-size: 19px; }
.formula .ecuacion .op { color: var(--text-muted); padding: 0 2px; }
table.comparar td:first-child { color: var(--text-secondary); }
table.comparar tr.fuerte td { font-weight: 650; color: var(--text-primary); }
table.compact tr.fuerte td { font-weight: 650; }
.tabla.alta { max-height: 560px; overflow: auto; border: 1px solid var(--grid); border-radius: 10px; margin: 0; padding: 0; }
.tabla.alta thead th { position: sticky; top: 0; background: var(--surface-1); padding-top: 10px; z-index: 1; }
.chart .bar.claro { opacity: 0.45; }
.chart .bar.on { filter: brightness(0.85); }
.leyenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
details.datos-mes > summary { cursor: pointer; list-style-position: inside; }
@media (max-width: 1280px) { .grid2.prec { grid-template-columns: minmax(0, 1fr); } }

/* Precinto: casilla y número */
.casilla { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; user-select: none; }
.casilla input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; cursor: pointer; }
.seal.precinto-edit { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 14px; }
.seal.precinto-edit .fhint { grid-column: 1 / -1; margin-top: 0; }
.seal.precinto-edit .fhint:empty { display: none; }
.precinto-num { display: flex; gap: 8px; min-width: 0; }
.precinto-num input { flex: 1; min-width: 0; border: 1px solid var(--border-input); border-radius: 9px; padding: 8px 12px; font-size: 15px; font-weight: 600; letter-spacing: 0.02em; background: var(--surface-1); }
.precinto-edit .dato-kg { cursor: default; padding-left: 26px; }
.con-kg { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.precinto-num .con-kg input { font-variant-numeric: tabular-nums; }
.precinto-num input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
ul.pend li.suave .pt { font-weight: 550; }
table.versiones td.motivo { white-space: normal; min-width: 180px; }
table.versiones td.motivo .coefs { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
table.versiones td.motivo .sub-line { white-space: normal; margin-top: 2px; line-height: 1.35; }

/* Opciones de los desplegables con los colores del tema (en oscuro se veían grises, como deshabilitadas). */
select option { background-color: var(--surface-1); color: var(--text-primary); }

/* Botones que responden al pasar el mouse y al tocarlos */
.btn, .btn-papelera, .btn-fila, .seg a, .seg button, .link { transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease; }
.btn:hover { border-color: var(--axis); }
.btn:active, .btn-papelera:active, .btn-fila:active, .seg a:active, .seg button:active { transform: scale(0.97); }
.seg a:hover, .seg button:hover { color: var(--text-primary); }
.seg a.on, .seg button.on { box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12); }

/* Acciones de cada fila: Reabrir y borrar */
.acciones-fila { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.btn-fila { border: 1px solid transparent; background: transparent; color: var(--text-secondary); padding: 5px 9px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.btn-fila svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.9; }
.btn-fila:hover, .btn-fila:focus-visible { color: var(--accent-ink); background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
td.q:has(.btn-fila), th.q { width: auto; }

/* Contenedores vaciados en la tablet, debajo de los cargados de una orden */
.nota-vaciados { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text-secondary); font-size: 13px; }
.nota-vaciados svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; margin-top: 1px; }
.nota-vaciados a { color: var(--accent-ink); }

/* Atajos Hoy / Ayer en Contenedores */
.filters .periodos { flex: none; }

@media (prefers-reduced-motion: reduce) {
  .btn, .btn-papelera, .btn-fila, .seg a, .seg button, .link { transition: none; }
  .btn:active, .btn-papelera:active, .btn-fila:active, .seg a:active, .seg button:active { transform: none; }
}

.orden-completa { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.orden-completa svg { flex: none; width: 20px; height: 20px; }
.aviso-box .check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; cursor: pointer; }
.aviso-box .check input { width: 18px; height: 18px; }
.aviso-booking { margin-top: 8px; font-size: 13.5px; line-height: 1.4; color: var(--warning-ink); background: var(--warning-wash); padding: 8px 12px; border-radius: 10px; }
.aviso-booking[hidden] { display: none; }
