:root {
  --fondo: #f6f5f2;
  --tarjeta: #ffffff;
  --texto: #1d1d1b;
  --suave: #6b6a66;
  --borde: #e3e1dc;
  --marca: #0f766e;
  --marca-oscura: #115e59;
  --marca-clara: #e6f4f2;
  --aviso: #b45309;
  --error: #b91c1c;
  --ok: #15803d;
  --radio: 12px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--texto);
  background: var(--fondo);
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

.contenedor { max-width: 960px; margin: 0 auto; padding: 16px; }
.contenedor.angosto { max-width: 560px; }

.cabecera {
  background: var(--tarjeta);
  border-bottom: 1px solid var(--borde);
}
.cabecera .contenedor { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; }
.cabecera h1 { font-size: 1.15rem; margin: 0; }

h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 0 0 8px; }
p { margin: 0 0 8px; }
.suave { color: var(--suave); font-size: 0.9rem; }

.tarjeta {
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 16px;
  margin-bottom: 16px;
}

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  background: #fff;
  color: var(--texto);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marca); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 60px; resize: vertical; }
.campo { margin-bottom: 12px; }
.fila { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

button, .boton {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--marca);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover, .boton:hover { background: var(--marca-oscura); }
button:disabled { opacity: 0.6; cursor: wait; }
.secundario { background: #fff; color: var(--texto); border-color: var(--borde); }
.secundario:hover { background: var(--fondo); }
.peligro { background: #fff; color: var(--error); border-color: #f3c9c9; }
.peligro:hover { background: #fdf2f2; }
.whatsapp { background: #1f9d55; }
.whatsapp:hover { background: #17834a; }
.ancho { width: 100%; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.mensaje { padding: 10px 12px; border-radius: 8px; font-size: 0.9rem; margin-top: 8px; }
.mensaje.error { background: #fdf2f2; color: var(--error); }
.mensaje.ok { background: #effaf3; color: var(--ok); }

.enlace-caja {
  display: flex; gap: 8px; align-items: center;
  background: var(--marca-clara); border-radius: 8px; padding: 8px;
  margin-top: 8px;
}
.enlace-caja input { background: transparent; border: none; padding: 6px; font-size: 0.85rem; }

/* Panel: lista de pedidos */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filtros select, .filtros input { width: auto; flex: 1 1 180px; }
.pedido { display: grid; gap: 12px; }
.pedido-cabeza { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.pedido-cabeza h3 { margin: 0; }
.datos { display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); font-size: 0.9rem; }
.datos dt { color: var(--suave); font-size: 0.8rem; }
.datos dd { margin: 0 0 6px; word-break: break-word; }

.etiqueta {
  display: inline-block; font-size: 0.78rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; background: #eee; color: var(--texto);
}
.etiqueta.esperando_datos { background: #fff4e5; color: var(--aviso); }
.etiqueta.datos_recibidos { background: #e8f0fe; color: #1e40af; }
.etiqueta.preparado, .etiqueta.en_camino { background: var(--marca-clara); color: var(--marca-oscura); }
.etiqueta.listo_agencia { background: #f3e8ff; color: #6b21a8; }
.etiqueta.entregado { background: #effaf3; color: var(--ok); }
.etiqueta.cancelado { background: #f1f1f1; color: var(--suave); }

.vacio { text-align: center; color: var(--suave); padding: 32px 16px; }

/* Cliente: seguimiento */
.linea-tiempo { list-style: none; padding: 0; margin: 0; }
.linea-tiempo li { position: relative; padding: 0 0 14px 28px; color: var(--suave); }
.linea-tiempo li::before {
  content: ''; position: absolute; left: 6px; top: 5px; width: 12px; height: 12px;
  border-radius: 50%; border: 2px solid var(--borde); background: #fff;
}
.linea-tiempo li::after {
  content: ''; position: absolute; left: 11px; top: 19px; bottom: 0; width: 2px; background: var(--borde);
}
.linea-tiempo li:last-child::after { display: none; }
.linea-tiempo li.hecho { color: var(--texto); }
.linea-tiempo li.hecho::before { background: var(--marca); border-color: var(--marca); }
.linea-tiempo li.actual { font-weight: 700; color: var(--texto); }
.linea-tiempo li.actual::before { background: #fff; border-color: var(--marca); box-shadow: 0 0 0 3px var(--marca-clara); }

.codigo-guia { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.04em; }

/* Cliente: empresa de envío */
.couriers { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.couriers button {
  background: #fff; color: var(--texto); border-color: var(--borde); font-weight: 600;
}
.couriers button:hover { background: var(--fondo); }
.couriers button[aria-checked='true'] { background: var(--marca-clara); border-color: var(--marca); color: var(--marca-oscura); }

/* Cliente: agencias */
.buscador { display: flex; gap: 8px; margin-bottom: 8px; }
.buscador input { flex: 1; }
#mapa { height: 280px; border-radius: 8px; border: 1px solid var(--borde); margin-bottom: 8px; z-index: 0; }
.agencias { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; border: 1px solid var(--borde); border-radius: 8px; }
.agencias li { border-bottom: 1px solid var(--borde); }
.agencias li:last-child { border-bottom: none; }
.agencias button {
  width: 100%; text-align: left; display: block; background: #fff; color: var(--texto);
  border-radius: 0; font-weight: 400; padding: 10px 12px;
}
.agencias button:hover { background: var(--fondo); }
.agencias button[aria-pressed='true'] { background: var(--marca-clara); box-shadow: inset 3px 0 0 var(--marca); }
.agencias strong { display: block; font-size: 0.92rem; }
.agencias small { display: block; color: var(--suave); }
.distancia { float: right; font-size: 0.8rem; font-weight: 600; color: var(--marca-oscura); }
.elegida { background: var(--marca-clara); border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 0.9rem; }

.pie { text-align: center; font-size: 0.78rem; color: var(--suave); padding: 16px; }

/* Panel: enlaces de campaña */
.campanas { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.campana { border: 1px solid var(--borde); border-radius: 8px; padding: 10px 12px; }
.campana-cabeza { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
