/* ==========================================================================
   Remitos · Expreso Oeste
   Dos tamaños: html.completo (escritorio, denso) y html.simple (letra y botones grandes)
   ========================================================================== */

:root {
  --azul: #1f4e79;            /* acento: links, títulos, bordes activos */
  --azul-oscuro: #163a5a;
  --azul-claro: #e8f0f8;      /* fondo de seleccionados */
  --primario: #1f4e79;        /* fondo de botones principales */
  --primario-hover: #163a5a;
  --encabezado: #1f4e79;
  --verde: #2e7d32;
  --verde-claro: #e8f5e9;
  --verde-borde: #b7dfb9;
  --verde-texto: #1b5e20;
  --rojo: #c62828;
  --rojo-claro: #fdecea;
  --rojo-borde: #f2b8b5;
  --rojo-texto: #7f1d1d;
  --naranja: #9a5b00;
  --naranja-claro: #fff4e0;
  --naranja-borde: #f0d199;
  --naranja-texto: #5c3a00;
  --gris: #5f6b7a;
  --gris-claro: #eef1f5;
  --borde: #cfd6de;
  --fondo: #f5f7fa;
  --blanco: #ffffff;          /* fondo de tarjetas, campos y tablas */
  --texto: #18202a;
  --hover: #f3f7fb;
  --foco: #7aa7d6;
  --tachado: #9aa3ad;
  --anulado-fondo: #f0f0f0;
  --anulado-texto: #8a8a8a;
  --presupuestado-texto: #303a45;
  /* Colores fijos (iguales en ambos temas: llevan texto blanco) */
  --fuerte-verde: #2e7d32;
  --fuerte-rojo: #c62828;
  --fuerte-naranja: #8a5300;
  --radio: 8px;
  --sombra: 0 1px 3px rgba(0, 0, 0, .12);
  color-scheme: light;
}

/* Tema oscuro: automático según el sistema, o elegido a mano (html[data-tema]) */
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
  --azul: #8cc0ff;
  --azul-oscuro: #b5d6ff;
  --azul-claro: #1d3550;
  --primario: #2f6ea5;
  --primario-hover: #3a7fbc;
  --encabezado: #14263a;
  --verde: #7ccf82;
  --verde-claro: #163019;
  --verde-borde: #2f5f34;
  --verde-texto: #a5e0a9;
  --rojo: #f08a8a;
  --rojo-claro: #3a1b1b;
  --rojo-borde: #6b3030;
  --rojo-texto: #f6b4b4;
  --naranja: #ffb74d;
  --naranja-claro: #3a2a10;
  --naranja-borde: #6b4d1c;
  --naranja-texto: #ffd59a;
  --gris: #a2acb9;
  --gris-claro: #262d37;
  --borde: #3a4350;
  --fondo: #11151b;
  --blanco: #1a2029;
  --texto: #e6e9ee;
  --hover: #222a35;
  --foco: #5b9bd5;
  --tachado: #6f7885;
  --anulado-fondo: #262b32;
  --anulado-texto: #7d8590;
  --presupuestado-texto: #cdd3db;
  --sombra: 0 1px 3px rgba(0, 0, 0, .5);
  color-scheme: dark;
  }
}
:root[data-tema="oscuro"] {
  --azul: #8cc0ff;
  --azul-oscuro: #b5d6ff;
  --azul-claro: #1d3550;
  --primario: #2f6ea5;
  --primario-hover: #3a7fbc;
  --encabezado: #14263a;
  --verde: #7ccf82;
  --verde-claro: #163019;
  --verde-borde: #2f5f34;
  --verde-texto: #a5e0a9;
  --rojo: #f08a8a;
  --rojo-claro: #3a1b1b;
  --rojo-borde: #6b3030;
  --rojo-texto: #f6b4b4;
  --naranja: #ffb74d;
  --naranja-claro: #3a2a10;
  --naranja-borde: #6b4d1c;
  --naranja-texto: #ffd59a;
  --gris: #a2acb9;
  --gris-claro: #262d37;
  --borde: #3a4350;
  --fondo: #11151b;
  --blanco: #1a2029;
  --texto: #e6e9ee;
  --hover: #222a35;
  --foco: #5b9bd5;
  --tachado: #6f7885;
  --anulado-fondo: #262b32;
  --anulado-texto: #7d8590;
  --presupuestado-texto: #cdd3db;
  --sombra: 0 1px 3px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
html.simple { font-size: 19px; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
}
.cargando-inicial { text-align: center; margin-top: 30vh; color: var(--gris); }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
a { color: var(--azul); }
.oculto { display: none !important; }
.gris { color: var(--gris); }
.chico { font-size: .85rem; }
.der { text-align: right; }
.centro { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.columna { display: flex; flex-direction: column; gap: .6rem; }
.crece { flex: 1 1 auto; min-width: 0; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.segmentado { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.segmentado .btn { padding-left: .3rem; padding-right: .3rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: inherit; font-weight: 600; padding: .5em 1em; min-height: 2.4rem;
  border: 1px solid var(--borde); border-radius: var(--radio); background: var(--blanco);
  color: var(--texto); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--gris-claro); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--foco); outline-offset: 1px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primario { background: var(--primario); border-color: var(--primario); color: white; }
.btn.primario:hover { background: var(--primario-hover); }
.btn.exito { background: var(--fuerte-verde); border-color: var(--fuerte-verde); color: white; }
.btn.exito:hover { filter: brightness(.92); }
.btn.peligro { color: var(--rojo); border-color: var(--rojo-borde); }
.btn.peligro.lleno { background: var(--fuerte-rojo); color: white; border-color: var(--fuerte-rojo); }
.btn.plano { border-color: transparent; background: transparent; }
.btn.chico { font-size: .85rem; min-height: 1.9rem; padding: .25em .7em; }
.btn.bloque { width: 100%; }

/* ---------- Formularios ---------- */
label.campo { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
input, select, textarea {
  font: inherit; padding: .45em .6em; border: 1px solid var(--borde); border-radius: var(--radio);
  background: var(--blanco); color: var(--texto); min-height: 2.4rem; width: 100%;
}
textarea { min-height: 4.5em; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input.cant { width: 5em; text-align: center; }

/* ---------- Encabezado y navegación ---------- */
.encabezado {
  background: var(--encabezado); color: white; padding: .55rem 1rem;
  display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 20;
}
.encabezado .marca { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.encabezado .btn { background: transparent; color: white; border-color: rgba(255,255,255,.4); }
.encabezado .btn:hover { background: rgba(255,255,255,.12); }
.pestanas { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.pestanas a {
  color: #dbe7f3; text-decoration: none; padding: .4rem .8rem; border-radius: var(--radio);
  font-weight: 600; white-space: nowrap;
}
.pestanas a.activa { background: rgba(255,255,255,.18); color: white; }
.contenido { padding: 1rem; max-width: 1400px; margin: 0 auto; }
html.simple .contenido { max-width: 760px; padding: 1rem .9rem 6rem; }

/* ---------- Tarjetas, tablas, chips ---------- */
.tarjeta { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; box-shadow: var(--sombra); }
.tarjeta + .tarjeta { margin-top: 1rem; }
.tabla { width: 100%; border-collapse: collapse; background: var(--blanco); }
.tabla th, .tabla td { padding: .45rem .55rem; border-bottom: 1px solid var(--gris-claro); text-align: left; vertical-align: middle; }
.tabla th { background: var(--gris-claro); font-size: .85rem; position: sticky; top: 0; cursor: default; user-select: none; }
.tabla th.ordenable { cursor: pointer; }
.tabla tr.seleccionable { cursor: pointer; }
.tabla tr.seleccionable:hover td { background: var(--hover); }
.tabla tr.seleccionada td { background: var(--azul-claro); }
.tabla tr.anulado td { color: var(--tachado); text-decoration: line-through; }
.tabla-scroll { overflow: auto; border: 1px solid var(--borde); border-radius: var(--radio); }
.chip { display: inline-block; padding: .15em .6em; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--gris-claro); white-space: nowrap; }
.estado-Presupuestado { background: var(--gris-claro); color: var(--presupuestado-texto); }
.estado-Aprobado { background: var(--naranja-claro); color: var(--naranja); }
.estado-Facturado { background: var(--azul-claro); color: var(--azul); }
.estado-Cobrado { background: var(--verde-claro); color: var(--verde); }
.estado-Anulado { background: var(--anulado-fondo); color: var(--anulado-texto); }

.aviso, .error, .ok {
  border-radius: var(--radio); padding: .6rem .8rem; border: 1px solid;
}
.aviso { background: var(--naranja-claro); border-color: var(--naranja-borde); color: var(--naranja-texto); }
.error { background: var(--rojo-claro); border-color: var(--rojo-borde); color: var(--rojo-texto); }
.ok { background: var(--verde-claro); border-color: var(--verde-borde); color: var(--verde-texto); }
.aviso ul, .error ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------- Buscador de catálogo ---------- */
.buscador { position: relative; }
.resultados { list-style: none; margin: .4rem 0 0; padding: 0; border: 1px solid var(--borde); border-radius: var(--radio); background: var(--blanco); max-height: 22rem; overflow: auto; }
.resultados li { padding: .45rem .6rem; cursor: pointer; display: flex; gap: .6rem; align-items: baseline; border-bottom: 1px solid var(--gris-claro); }
.resultados li:last-child { border-bottom: 0; }
.resultados li.activo, .resultados li:hover { background: var(--azul-claro); }
.resultados .codigo { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; color: var(--gris); min-width: 9.5em; }

/* ---------- Diálogos y avisos flotantes ---------- */
.velo { position: fixed; inset: 0; background: rgba(15, 25, 35, .45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: var(--blanco); border-radius: 12px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal.ancho { max-width: 900px; }
.modal header { padding: 1rem 1.2rem .4rem; font-weight: 700; font-size: 1.15rem; }
.modal .cuerpo { padding: .4rem 1.2rem 1rem; }
.modal footer { padding: .8rem 1.2rem 1.1rem; display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .4rem; z-index: 200; width: min(92vw, 520px); }
.toast { padding: .7rem 1rem; border-radius: var(--radio); background: #263445; color: white; box-shadow: var(--sombra); }
.toast.error { background: var(--fuerte-rojo); border: 0; color: white; }
.toast.ok { background: var(--fuerte-verde); border: 0; color: white; }
.toast.aviso { background: var(--fuerte-naranja); border: 0; color: white; }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 12vh auto 0; padding: 1rem; }
.login .tarjeta { padding: 1.6rem; }
.login h1 { color: var(--azul); }

/* ---------- Modo completo: página Trabajo / Historial ---------- */
.grilla-trabajo { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.4fr); gap: 1rem; }
.grilla-historial { display: grid; grid-template-columns: minmax(520px, 1.2fr) minmax(380px, 1fr); gap: 1rem; align-items: start; }
.panel-fijo { position: sticky; top: 4rem; max-height: calc(100vh - 5rem); overflow: auto; }
.prevision { font-weight: 700; padding: .35rem .7rem; border-radius: var(--radio); }
.prevision.nuevo { background: var(--verde-claro); color: var(--verde); }
.prevision.correccion { background: var(--naranja-claro); color: var(--naranja); }
.prevision.problema { background: var(--rojo-claro); color: var(--rojo); }
.totales { display: flex; gap: 1.5rem; justify-content: flex-end; font-weight: 700; flex-wrap: wrap; }
.resumen-dinero { display: flex; gap: 1.2rem; flex-wrap: wrap; font-weight: 700; }
details > summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
@media (max-width: 1000px) {
  .grilla-trabajo, .grilla-historial { grid-template-columns: 1fr; }
  .panel-fijo { position: static; max-height: none; }
}

/* ---------- Modo simple ---------- */
html.simple .btn { min-height: 3.2rem; border-radius: 12px; }
.btn.enorme { width: 100%; min-height: 4.6rem; font-size: 1.25rem; border-radius: 14px; justify-content: flex-start;
  padding: .8rem 1.2rem; gap: .8rem; white-space: normal; text-align: left; }
.btn.enorme .icono { font-size: 1.8rem; }
.pasos { color: var(--gris); font-weight: 600; margin-bottom: .3rem; }
.barra-pasos { display: flex; gap: .3rem; margin-bottom: 1rem; }
.barra-pasos span { flex: 1; height: .45rem; border-radius: 999px; background: var(--gris-claro); }
.barra-pasos span.hecho { background: var(--primario); }
.pregunta-grande { font-size: 1.5rem; font-weight: 700; margin: .2rem 0 1rem; }
input.grande { font-size: 2rem; text-align: center; min-height: 4.2rem; font-weight: 700; letter-spacing: .05em; }
.chips-grandes { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips-grandes .btn { min-width: 4.5rem; font-size: 1.2rem; }
.tarjetas-items { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.tarjeta-item {
  display: flex; align-items: center; gap: .8rem; text-align: left; width: 100%;
  font: inherit; color: var(--texto); background: var(--blanco); border: 2px solid var(--borde); border-radius: 12px;
  padding: .8rem 1rem; cursor: pointer; min-height: 4rem;
}
.tarjeta-item:hover { border-color: var(--foco); }
.tarjeta-item.elegido { border-color: var(--verde); background: var(--verde-claro); }
.tarjeta-item .desc { flex: 1; font-weight: 600; }
.tarjeta-item .mas { font-size: 1.8rem; color: var(--azul); font-weight: 700; }
.elegidos { display: flex; flex-direction: column; gap: .5rem; }
.elegido-fila { display: flex; align-items: center; gap: .6rem; background: var(--verde-claro); border: 2px solid var(--verde-borde); border-radius: 12px; padding: .6rem .7rem; }
.elegido-fila .desc { flex: 1; font-weight: 600; }
.contador { display: flex; align-items: center; gap: .3rem; }
.contador .btn { min-width: 3.2rem; font-size: 1.5rem; padding: 0; }
.contador .valor { min-width: 2.4rem; text-align: center; font-size: 1.4rem; font-weight: 800; }
.pie-simple {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--blanco); border-top: 1px solid var(--borde);
  padding: .7rem .9rem calc(.7rem + env(safe-area-inset-bottom)); display: flex; gap: .6rem; z-index: 30;
}
.pie-simple .btn { flex: 1; font-size: 1.15rem; min-height: 3.6rem; }
.pie-simple .btn.atras { flex: 0 0 auto; }
.resumen-simple { font-size: 1.1rem; }
.resumen-simple .linea { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px dashed var(--borde); }
.resumen-simple .total { font-size: 1.3rem; font-weight: 800; border-bottom: 0; }
.casilla { display: flex; gap: .7rem; align-items: center; font-weight: 600; cursor: pointer; }
.casilla input { width: 1.5rem; height: 1.5rem; flex: 0 0 auto; }
html.simple .toasts { bottom: calc(6rem + env(safe-area-inset-bottom)); }
.listo-icono { font-size: 4rem; text-align: center; color: var(--verde); line-height: 1; }
@media (min-width: 700px) {
  .tarjetas-items { grid-template-columns: 1fr 1fr; }
}
