/* Cosmos Domicilios — estilos comunes */
:root {
  --marca: #e8590c;
  --marca-suave: #fff1e6;
  --tinta: #1d1f24;
  --tinta-2: #5b616e;
  --tinta-3: #8a909c;
  --fondo: #f5f5f2;
  --tarjeta: #ffffff;
  --borde: #e3e2dd;
  --ok: #2f9e44;
  --ok-suave: #e9f7ec;
  --error: #c92a2a;
  --error-suave: #fdecec;
  --radio: 12px;
  --sombra: 0 1px 2px rgba(20, 20, 20, .05), 0 4px 16px rgba(20, 20, 20, .04);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--tinta);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--marca); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.suave { color: var(--tinta-2); }
.pequeno { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Botones y campos */
button, .boton {
  font: inherit; font-weight: 600; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--tinta);
  padding: .55rem 1rem; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: .4rem; min-height: 42px; transition: background .15s, transform .1s;
}
button:active { transform: scale(.98); }
button.principal, .boton.principal { background: var(--marca); border-color: var(--marca); color: #fff; }
button.peligro { color: var(--error); }
button.texto { border: 0; background: none; color: var(--marca); padding: .3rem .5rem; min-height: 0; }
button:disabled { opacity: .55; cursor: default; }
@media (hover: hover) {
  button:hover { background: #f0efea; }
  button.principal:hover { filter: brightness(.95); background: var(--marca); }
  button.texto:hover { background: var(--marca-suave); }
}
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .75rem; }
label > input, label > select, label > textarea { margin-top: .3rem; }
input, select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: .6rem .7rem; border: 1px solid var(--borde); border-radius: 10px;
  background: #fff; color: var(--tinta); min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--marca); outline-offset: 1px; }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--marca); transform: scale(1.2); margin-right: .5rem; }
.check { display: flex; align-items: center; font-weight: 500; }
.fila { display: flex; gap: .75rem; flex-wrap: wrap; }
.fila > * { flex: 1 1 160px; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; margin-top: 1rem; }

/* Estructura del panel */
.barra {
  position: sticky; top: 0; z-index: 10; background: var(--tinta); color: #fff; display: flex; align-items: center;
  gap: .75rem; padding: .6rem 16px; padding-top: max(.6rem, env(safe-area-inset-top));
}
.barra .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--marca); display: grid; place-items: center; flex: none; }
.barra .nombre { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra button { background: transparent; border-color: rgba(255,255,255,.25); color: #fff; min-height: 36px; padding: .3rem .7rem; }
.marco { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 54px); min-height: calc(100dvh - 54px); }
nav.menu { background: #fff; border-right: 1px solid var(--borde); padding: .75rem .5rem; }
nav.menu a {
  display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border-radius: 10px; color: var(--tinta);
  text-decoration: none; font-weight: 500; margin-bottom: 2px;
}
nav.menu a.activo { background: var(--marca-suave); color: var(--marca); font-weight: 700; }
nav.menu .grupo { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tinta-3); padding: .9rem .75rem .3rem; }
main { padding: 20px 24px 60px; max-width: 1100px; width: 100%; min-width: 0; }
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.encabezado h1 { margin: 0; }

@media (max-width: 760px) {
  .marco { display: block; }
  nav.menu {
    position: sticky; top: 54px; z-index: 9; display: flex; overflow-x: auto; gap: .25rem; padding: .4rem 16px;
    border-right: 0; border-bottom: 1px solid var(--borde); scrollbar-width: none;
  }
  nav.menu::-webkit-scrollbar { display: none; }
  nav.menu .grupo { display: none; }
  nav.menu a { white-space: nowrap; padding: .45rem .75rem; margin: 0; }
  main { padding: 16px 16px 80px; }
}

/* Tarjetas y listas */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra); margin-bottom: 1rem; }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.cifra { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px 16px; }
.cifra b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.cifra span { color: var(--tinta-2); font-size: .85rem; }
.lista { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; }
.item { display: flex; align-items: center; gap: .75rem; padding: 12px 16px; border-bottom: 1px solid var(--borde); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item .cuerpo { flex: 1; min-width: 0; }
.item .titulo { font-weight: 600; overflow-wrap: anywhere; }
.item .sub { color: var(--tinta-2); font-size: .87rem; overflow-wrap: anywhere; }
.item.inactivo { opacity: .55; }
.item.clic { cursor: pointer; }
@media (hover: hover) { .item.clic:hover { background: #fafaf7; } }
.vacio { padding: 28px 16px; text-align: center; color: var(--tinta-2); }
.chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 99px; background: #efeee9; color: var(--tinta-2); white-space: nowrap; }
.chip.marca { background: var(--marca-suave); color: var(--marca); }
.chip.ok { background: var(--ok-suave); color: var(--ok); }
.chip.error { background: var(--error-suave); color: var(--error); }
.punto { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.valor { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.buscador { display: flex; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.buscador input { flex: 1 1 200px; }
.buscador select { flex: 0 1 200px; }

/* Avisos */
.aviso { padding: 12px 14px; border-radius: 10px; margin-bottom: 1rem; background: var(--marca-suave); border: 1px solid #ffd8bf; }
.aviso.error { background: var(--error-suave); border-color: #f5c2c2; color: var(--error); }
.aviso.ok { background: var(--ok-suave); border-color: #bfe6c7; color: #1e6b2e; }
#tostada {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--tinta); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; z-index: 100; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s; pointer-events: none; font-weight: 500;
}
#tostada.ver { opacity: 1; transform: translate(-50%, 0); }
#tostada.error { background: var(--error); }

/* Ventanas */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--tinta);
}
dialog::backdrop { background: rgba(20, 20, 25, .45); }
dialog .cab { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; position: sticky; top: 0; background: #fff; z-index: 1; }
dialog .cab h2 { margin: 0; }
dialog .contenido { padding: 8px 18px 18px; }
dialog .pie { position: sticky; bottom: 0; background: #fff; padding: 12px 18px; border-top: 1px solid var(--borde); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.pin-grande { font-size: 2.2rem; letter-spacing: .3em; font-weight: 800; text-align: center; padding: .75rem; background: var(--marca-suave); border-radius: 12px; margin: .5rem 0 1rem; font-variant-numeric: tabular-nums; }
fieldset { border: 1px solid var(--borde); border-radius: 12px; padding: 12px 14px 4px; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .35rem; }

/* Detalle de tarifa */
.detalle { width: 100%; border-collapse: collapse; }
.detalle td { padding: .45rem 0; border-bottom: 1px dashed var(--borde); }
.detalle td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.detalle tr.total td { border-bottom: 0; font-weight: 800; font-size: 1.2rem; padding-top: .7rem; }

/* Mapa */
.mapa { height: 320px; border-radius: 12px; border: 1px solid var(--borde); margin-bottom: .75rem; z-index: 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Torre de control ---------- */
main.ancho { max-width: none; }
.doms { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .75rem; scrollbar-width: thin; }
.dom { display: flex; gap: .5rem; align-items: center; background: #fff; border: 1px solid var(--borde); border-radius: 12px; padding: 8px 12px; white-space: nowrap; flex: none; }
.dom.libre { border-color: #bfe6c7; }
.torre { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 1rem; align-items: start; }
.torre > * { min-width: 0; }
.torre .formulario { position: sticky; top: 70px; max-height: calc(100dvh - 86px); overflow: auto; margin: 0; }
.torre summary { cursor: pointer; list-style: none; margin-bottom: .5rem; }
.torre summary::-webkit-details-marker { display: none; }
.mas summary { color: var(--marca); font-weight: 600; margin: .25rem 0 .75rem; }
.sugerencias { display: flex; flex-direction: column; gap: 4px; margin: -.4rem 0 .75rem; }
.sugerencias button { justify-content: space-between; text-align: left; min-height: 38px; font-weight: 500; width: 100%; }
.radios { display: flex; flex-direction: column; gap: 6px; margin-bottom: .75rem; }
.radio { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; margin: 0; padding: 8px 10px; border: 1px solid var(--borde); border-radius: 10px; cursor: pointer; }
.radio:has(input:checked) { border-color: var(--marca); background: var(--marca-suave); }
.radio input { width: auto; min-height: 0; margin-top: 3px; accent-color: var(--marca); }
.tarifa { display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: var(--marca-suave); border-radius: 10px; padding: 10px 12px; margin-bottom: .75rem; min-height: 54px; }
.tarifa .grande { font-size: 1.4rem; display: block; font-variant-numeric: tabular-nums; }
.error-txt { color: var(--error); font-weight: 600; }
.pestanas { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: .75rem; scrollbar-width: none; }
.pestanas button { white-space: nowrap; min-height: 38px; font-weight: 600; }
.pestanas button.activa { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.pestanas button.activa .chip { background: rgba(255,255,255,.2); color: #fff; }
.pestanas button.alerta:not(.activa) { border-color: var(--error); color: var(--error); }
.tablero { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .75rem; }
.tablero .vacio { grid-column: 1 / -1; background: #fff; border: 1px dashed var(--borde); border-radius: 12px; }
.pedido { background: #fff; border: 1px solid var(--borde); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pedido.tarde { border-color: var(--error); box-shadow: 0 0 0 1px var(--error) inset; }
.pedido.tarde .cab-pedido .suave { color: var(--error); font-weight: 700; }
@media (hover: hover) { .pedido:hover { border-color: #c9c7bf; } }
.cab-pedido { display: flex; align-items: center; gap: .5rem; }
.cab-pedido .suave { margin-left: auto; }
.ruta { display: flex; gap: .4rem; font-weight: 600; flex-wrap: wrap; overflow-wrap: anywhere; }
.pie-pedido { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.pie-pedido .quien { margin-left: auto; font-size: .85rem; font-weight: 600; }
.pedido select.asignar { min-height: 38px; padding: .3rem .5rem; font-size: 15px; }
.linea { margin: 0; padding-left: 1.2rem; }
.linea li { margin-bottom: .35rem; }
@media (max-width: 1150px) {
  .torre { grid-template-columns: 1fr; }
  .torre .formulario { position: static; max-height: none; }
}

.pedido .sugerido { justify-content: flex-start; flex-wrap: wrap; text-align: left; min-height: 40px; background: var(--ok-suave); border-color: #bfe6c7; color: #1e6b2e; gap: .2rem .5rem; }
.pedido .sugerido .suave { color: #3d7a4b; font-weight: 500; }
