/* ══════════════════════════════════════════════════════
   MENOS VUELTAS — Panel de pedidos
   Mismos tokens que la web pública para que se sienta parte
   de lo mismo, pero con densidad de herramienta de trabajo:
   tipografías más chicas, tablas compactas, menos aire.
══════════════════════════════════════════════════════ */

:root {
  /* Superficies */
  --bg:        #FAFAF7;
  --surface:   #ffffff;
  --surface-2: #F3F4EF;
  --surface-3: #EAECE5;

  /* Bordes */
  --line:      #C8CCBF;
  --line-soft: #D6DAD0;

  /* Texto */
  --t1: #2F3430;
  --t2: #6F746E;
  --t3: #9EA39D;

  /* Marca */
  --accent:     #6E8B5B;
  --accent-2:   #587547;
  --accent-bg:  #EEF2E9;
  --accent-line:#C8D6BB;

  /* Estados */
  --rojo:    #C4543A;  --rojo-bg:  #FBEDE8;
  --ambar:   #A8792B;  --ambar-bg: #FDF4E3;
  --azul:    #3E6E8E;  --azul-bg:  #E9F1F6;

  --font:      'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Cabin', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:24px; --s6:32px;
  --r1:4px; --r2:8px; --r3:12px; --r4:16px; --rf:999px;

  --ease: cubic-bezier(.16, 1, .3, 1);
  --t: 150ms;

  --sombra-1: 0 1px 2px rgba(47,52,48,.05);
  --sombra-2: 0 4px 14px rgba(47,52,48,.09);
  --sombra-3: 0 12px 32px rgba(47,52,48,.14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--surface-3);
  font-family: var(--font);
  font-size: 14px;
  color: var(--t1);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
[hidden] { display: none !important; }


/* ══════════════════════════════════════════════════════
   BARRA SUPERIOR
══════════════════════════════════════════════════════ */
.ad-top {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.ad-top-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 58px;
  padding: 0 var(--s5);
  display: flex;
  align-items: center;
  gap: var(--s4);
}
.ad-logo { height: 26px; width: auto; display: block; }
.ad-sep { width: 1px; height: 20px; background: var(--line-soft); }
.ad-seccion {
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--t1);
}

/* Navegación entre secciones. Sin fondo: son dos lugares distintos del
   panel, no dos filtros de la misma vista. */
.ad-nav { display: flex; gap: 2px; }
.ad-nav button {
  padding: 7px 14px;
  border-radius: var(--rf);
  font-size: .86rem;
  font-weight: 600;
  color: var(--t3);
  transition: background var(--t), color var(--t);
}
.ad-nav button:hover { color: var(--t1); }
.ad-nav button.on { background: var(--surface-2); color: var(--t1); }

.ad-canal {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin-left: auto;
  background: var(--surface-2);
  border-radius: var(--rf);
}
.ad-canal[hidden] { display: none; }
.ad-canal button {
  padding: 6px 16px;
  border-radius: var(--rf);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--t3);
  transition: background var(--t), color var(--t);
}
.ad-canal button.on { background: var(--accent); color: white; }

/* Punto de estado: verde si el catálogo cargó, rojo si falló. */
.ad-estado {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
  transition: background var(--t);
}
.ad-estado.ok    { background: var(--accent); }
.ad-estado.error { background: var(--rojo); }

.ad-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--s5);
}


/* ══════════════════════════════════════════════════════
   CONTROLES
══════════════════════════════════════════════════════ */
.btn {
  height: 38px;
  padding: 0 var(--s4);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--rf);
  font-size: .82rem;
  font-weight: 600;
  color: var(--t2);
  white-space: nowrap;
  transition: border-color var(--t), color var(--t), background var(--t), transform var(--t);
}
.btn:hover { border-color: var(--accent); color: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn--pri {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 1px 3px rgba(61,107,79,.22), 0 4px 12px rgba(61,107,79,.14);
}
.btn--pri:hover { background: var(--accent-2); border-color: var(--accent-2); color: white; }

.btn--peligro { color: var(--rojo); }
.btn--peligro:hover { border-color: var(--rojo); color: var(--rojo); background: var(--rojo-bg); }

.btn--ancho { width: 100%; height: 42px; justify-content: center; }

.ad-select {
  height: 38px;
  padding: 0 var(--s3);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--rf);
  font-size: .82rem;
  font-weight: 500;
  color: var(--t2);
  cursor: pointer;
}
.ad-select:focus { outline: none; border-color: var(--accent); }


/* ══════════════════════════════════════════════════════
   LISTA DE PEDIDOS
══════════════════════════════════════════════════════ */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r3);
  padding: var(--s4);
}
.kpi-l {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--t3);
  margin-bottom: 5px;
}
.kpi-v {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
.kpi-v--verde { color: var(--accent-2); }
.kpi-s {
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: .73rem;
  color: var(--t3);
}

.ad-barra {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}
.ad-barra--editor { gap: var(--s4); }
.ad-titulo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.03em;
}
.ad-barra--editor .btn--peligro { margin-left: auto; }

.ad-buscar { position: relative; flex: 1; min-width: 220px; }
.ad-buscar svg {
  position: absolute;
  left: 14px;
  top: 11px;
  width: 16px;
  height: 16px;
  color: var(--t3);
  pointer-events: none;
}
.ad-buscar input {
  width: 100%;
  height: 38px;
  padding: 0 var(--s4) 0 38px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--rf);
}
.ad-buscar input:focus { outline: none; border-color: var(--accent); }

.tabla-wrap {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r3);
  overflow: hidden;
}
.tabla { width: 100%; border-collapse: collapse; }
.tabla th {
  text-align: left;
  padding: 11px var(--s3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t3);
  white-space: nowrap;
}
.tabla td {
  padding: 11px var(--s3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.tabla tbody tr:last-child td { border-bottom: none; }
/* La regla va con el mismo peso que ".tabla th", que también alinea a la
   izquierda: sin esto los encabezados de las columnas numéricas quedaban
   pegados a la izquierda y los valores a la derecha, descuadrados. */
.tabla th.num,
.tabla td.num,
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Solo la tabla de pedidos es clickeable; la de items no. */
#tbodyPedidos tr { cursor: pointer; transition: background var(--t); }
#tbodyPedidos tr:hover { background: var(--accent-bg); }

.celda-cliente b { font-weight: 600; }
.celda-cliente span {
  display: block;
  margin-top: 1px;
  font-family: var(--font-body);
  font-size: .72rem;
  color: var(--t3);
}

.estado {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: var(--rf);
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
}
.estado::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
/* El estado avanza en un solo sentido: Nuevo → Entregado → Cobrado.
   El color acompaña ese recorrido, de "falta hacer" a "listo". */
.estado--nuevo     { background: var(--azul-bg);   color: var(--azul); }
.estado--entregado { background: var(--ambar-bg);  color: var(--ambar); }
.estado--cobrado   { background: var(--accent-bg); color: var(--accent-2); }

.kpi-v--alerta { color: var(--ambar); }

.ganancia { font-weight: 700; color: var(--accent-2); }
.ganancia--neg { color: var(--rojo); }

.vacio {
  padding: var(--s6) var(--s4);
  text-align: center;
  font-family: var(--font-body);
  font-size: .85rem;
  color: var(--t3);
}


/* ══════════════════════════════════════════════════════
   EDITOR
══════════════════════════════════════════════════════ */
.ed-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: var(--s5);
  align-items: start;
}
.ed-col { min-width: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r3);
  padding: var(--s5);
  margin-bottom: var(--s4);
}
.panel:last-child { margin-bottom: 0; }
.panel-tit {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s4);
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.panel-chip {
  padding: 2px 9px;
  background: var(--surface-2);
  border-radius: var(--rf);
  font-size: .68rem;
  font-weight: 600;
  color: var(--t3);
}

.campos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: var(--s3);
}
.campo--full { grid-column: 1 / -1; }

/* En el editor de pedidos la grilla es de 4 columnas fijas, no auto-fit: los
   campos están agrupados por quién los completa (arriba vos, abajo el cliente)
   y con auto-fit el corte de fila cambiaba según el ancho, mezclando los dos
   grupos. */
.campos--pedido { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Empuja el campo al principio de una fila nueva, dejando vacío lo que sobre
   de la anterior. Así el bloque del cliente arranca siempre alineado. */
.campos--pedido .campo--fila-nueva { grid-column: 1 / span 2; }
.campo--sep { margin: var(--s3) 0; }

label {
  display: block;
  margin-bottom: 5px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t3);
}
.campo input, .campo select, .campo textarea,
input[type="date"], input[type="number"] {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r2);
  transition: border-color var(--t), background var(--t);
}
.campo textarea {
  height: auto;
  min-height: 60px;
  padding: 9px 11px;
  font-family: var(--font-body);
  resize: vertical;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

/* ── Buscador de productos ── */
.buscador-prod { position: relative; margin-bottom: var(--s3); }
.buscador-prod > svg {
  position: absolute;
  left: 14px;
  top: 13px;
  width: 16px;
  height: 16px;
  color: var(--t3);
  pointer-events: none;
}
.buscador-prod input {
  width: 100%;
  height: 42px;
  padding: 0 var(--s4) 0 38px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r2);
}
.buscador-prod input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.sugerencias {
  position: absolute;
  top: 46px;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r3);
  box-shadow: var(--sombra-3);
}
.sugerencias:empty { display: none; }
.sug-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 9px 13px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.sug-item:last-child { border-bottom: none; }
.sug-item:hover, .sug-item.sel { background: var(--accent-bg); }
.sug-nombre {
  flex: 1;
  min-width: 0;
  font-size: .83rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sug-dto {
  font-family: var(--font-body);
  font-size: .69rem;
  color: var(--t3);
  white-space: nowrap;
}
.sug-precio {
  font-size: .82rem;
  font-weight: 700;
  color: var(--accent-2);
  white-space: nowrap;
}

/* ── Tabla de items ── */
.tabla--items th { font-size: .58rem; }
.tabla--items td { padding: 8px var(--s2); }
.item-nombre { font-size: .81rem; font-weight: 600; }
.item-meta {
  margin-top: 1px;
  font-family: var(--font-body);
  font-size: .69rem;
  color: var(--t3);
}
.tabla--items input[type="number"] {
  width: 60px;
  height: 30px;
  padding: 0 6px;
  text-align: center;
  font-weight: 600;
}
/* Las dos rebajas se distinguen: la promo temporal en ámbar (se termina) y
   el descuento por cantidad en verde (siempre está).

   Viven en su propia columna ("Motivo"), no pegados al precio: ahí empujaban
   la cifra y desalineaban toda la columna cuando había uno o dos descuentos.
   Se apilan en vertical porque un producto puede tener los dos a la vez y
   en línea se comían el ancho de la tabla. */
.motivos {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.motivo-vacio { color: var(--t3); }

.chip-dto {
  display: inline-block;
  padding: 1px 6px;
  background: var(--accent-bg);
  border-radius: var(--rf);
  font-size: .58rem;
  font-weight: 700;
  color: var(--accent-2);
  white-space: nowrap;
}
.chip-dto--promo { background: var(--ambar-bg); color: var(--ambar); }

.sug-promo {
  padding: 1px 6px;
  border-radius: var(--rf);
  background: var(--ambar-bg);
  color: var(--ambar);
  font-size: .62rem;
  font-weight: 700;
  white-space: nowrap;
}
.quitar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--t3);
  transition: background var(--t), color var(--t);
}
.quitar:hover { background: var(--rojo-bg); color: var(--rojo); }
.quitar svg { width: 14px; height: 14px; }

/* ── Resumen ── */
.ed-resumen { position: sticky; top: 78px; }
.fila {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s4);
  margin-bottom: 6px;
  font-family: var(--font-body);
  font-size: .84rem;
  color: var(--t2);
}
.fila b {
  font-family: var(--font);
  font-weight: 600;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.fila--total {
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--line-soft);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--t1);
}
.fila--total b { font-size: 1.35rem; font-weight: 700; color: var(--accent-2); letter-spacing: -.03em; }
.fila--ganancia {
  margin-top: var(--s3);
  padding: 10px 12px;
  background: var(--accent-bg);
  border-radius: var(--r2);
  color: var(--accent-2);
}
.fila--ganancia b { color: var(--accent-2); font-weight: 700; }
.fila--ganancia.neg { background: var(--rojo-bg); color: var(--rojo); }
.fila--ganancia.neg b { color: var(--rojo); }
.fila--margen { margin-top: 7px; font-size: .76rem; }

.acciones {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-top: var(--s4);
}


/* ══════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════ */
.login {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--s5);
  background: var(--surface-3);
}
.login-caja {
  width: 100%;
  max-width: 330px;
  padding: var(--s6) var(--s5);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r4);
  box-shadow: var(--sombra-2);
  text-align: center;
}
.login-logo { height: 30px; width: auto; margin: 0 auto var(--s5); display: block; }
.login-caja h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 4px;
}
.login-caja p {
  font-family: var(--font-body);
  font-size: .83rem;
  color: var(--t2);
  margin-bottom: var(--s5);
}
.login-caja input {
  width: 100%;
  height: 42px;
  margin-bottom: var(--s3);
  padding: 0 var(--s4);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r2);
  text-align: center;
  font-size: 16px;  /* 16px evita el zoom automático de iOS */
}
.login-caja input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.login-error {
  margin-bottom: var(--s3) !important;
  font-size: .8rem !important;
  font-weight: 600;
  color: var(--rojo) !important;
}

.ad-salir {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--t3);
  transition: background var(--t), color var(--t);
}
.ad-salir:hover { background: var(--surface-2); color: var(--t1); }
.ad-salir svg { width: 15px; height: 15px; }


/* Aviso de que el panel está desconectado del Sheets. No es un error —
   se puede trabajar así — pero tiene que verse, porque desde adentro
   todo parece funcionar igual. */
.aviso-local {
  margin-bottom: var(--s4);
  padding: var(--s4);
  background: var(--ambar-bg);
  border: 1px solid #EBD9B0;
  border-radius: var(--r3);
}
.aviso-local b {
  display: block;
  margin-bottom: 4px;
  font-size: .88rem;
  color: var(--ambar);
}
.aviso-local p {
  font-family: var(--font-body);
  font-size: .82rem;
  line-height: 1.6;
  color: var(--t2);
}
.aviso-local code {
  padding: 2px 6px;
  background: var(--surface);
  border-radius: var(--r1);
  font-size: .78rem;
}
.ad-estado.local { background: var(--ambar); }


/* ══════════════════════════════════════════════════════
   AVISO DE CARGA FALLIDA
══════════════════════════════════════════════════════ */
.aviso-error {
  margin-bottom: var(--s4);
  padding: var(--s4);
  background: var(--rojo-bg);
  border: 1px solid #E8C4B8;
  border-radius: var(--r3);
}
.aviso-error b {
  display: block;
  margin-bottom: 5px;
  font-size: .88rem;
  color: var(--rojo);
}
.aviso-error p {
  font-family: var(--font-body);
  font-size: .82rem;
  line-height: 1.6;
  color: var(--t2);
}
.aviso-error code {
  padding: 2px 6px;
  background: var(--surface);
  border-radius: var(--r1);
  font-size: .78rem;
}


/* ══════════════════════════════════════════════════════
   ERROR DE GUARDADO
   Un toast se va en tres segundos; un fallo de guardado necesita
   quedarse en pantalla con la causa y la tranquilidad de que el
   trabajo no se perdió.
══════════════════════════════════════════════════════ */
.error-guardado {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  position: relative;
  margin-bottom: var(--s4);
  padding: var(--s4) var(--s5) var(--s4) var(--s4);
  background: var(--rojo-bg);
  border: 1px solid #E8C4B8;
  border-radius: var(--r3);
}
.error-guardado-ico {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(196, 84, 58, .12);
  color: var(--rojo);
}
.error-guardado-ico svg { width: 17px; height: 17px; }
.error-guardado-tx { flex: 1; min-width: 0; }
.error-guardado-tx b {
  display: block;
  margin-bottom: 3px;
  font-size: .88rem;
  color: var(--rojo);
}
.error-guardado-tx p {
  font-family: var(--font-body);
  font-size: .82rem;
  line-height: 1.55;
  color: var(--t2);
}
.error-guardado-ok {
  margin-top: 6px;
  color: var(--accent-2) !important;
  font-weight: 500;
}
.error-guardado-x {
  position: absolute;
  top: var(--s3);
  right: var(--s3);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--t3);
  transition: background var(--t), color var(--t);
}
.error-guardado-x:hover { background: rgba(196, 84, 58, .1); color: var(--rojo); }
.error-guardado-x svg { width: 12px; height: 12px; }


/* Campos que vienen del cliente: se muestran pero no se editan acá. Para
   cambiarlos hay que ir a la ficha del cliente, así el dato no queda
   distinto en cada pedido. */
.campo input[readonly] {
  background: var(--surface-2);
  color: var(--t2);
  cursor: not-allowed;
  border-color: var(--line-soft);
}
.campo input[readonly]:focus { border-color: var(--line-soft); background: var(--surface-2); }

.campo-ayuda {
  margin-top: 5px;
  font-family: var(--font-body);
  font-size: .72rem;
  color: var(--t3);
}
.campo-ayuda a { color: var(--accent-2); text-decoration: underline; cursor: pointer; }


/* ══════════════════════════════════════════════════════
   CLIENTES
══════════════════════════════════════════════════════ */
.celda-nota {
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: .72rem;
  color: var(--t3);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.celda-dir {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tel-link {
  color: var(--t1);
  text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
  transition: color var(--t), border-color var(--t);
}
.tel-link:hover { color: var(--accent-2); border-color: var(--accent); }

.icono-mapa {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--t3);
  transition: background var(--t), color var(--t);
}
.icono-mapa:hover { background: var(--accent-bg); color: var(--accent-2); }
.icono-mapa svg { width: 15px; height: 15px; }

/* Botón para abrir la ubicación desde el editor de pedidos. */
.campo-con-boton { display: flex; gap: var(--s2); }
.campo-con-boton input { flex: 1; min-width: 0; }
.btn--mapa {
  flex-shrink: 0;
  height: 36px;
  padding: 0 var(--s3);
  font-size: .78rem;
  text-decoration: none;
}
.btn--mapa[hidden] { display: none; }


/* ══════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--s5);
  background: rgba(28, 34, 28, .45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-caja {
  position: relative;
  width: 100%;
  max-width: 480px;
  padding: var(--s5);
  background: var(--surface);
  border-radius: var(--r4);
  box-shadow: 0 20px 50px rgba(28, 34, 28, .24);
}
.modal-caja h2 {
  margin-bottom: var(--s4);
  padding-right: var(--s6);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.03em;
}
.modal-x {
  position: absolute;
  top: var(--s3);
  right: var(--s3);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--t2);
  transition: background var(--t), color var(--t);
}
.modal-x:hover { background: var(--surface-3); color: var(--t1); }
.modal-x svg { width: 13px; height: 13px; }
.modal-acciones {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
  margin-top: var(--s5);
}
/* El botón de eliminar se separa de los otros dos para que no se toque
   por error al querer cancelar. */
.modal-acciones .btn--peligro { margin-right: auto; }


/* ══════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 60;
  padding: 11px 20px;
  background: var(--t1);
  color: white;
  border-radius: var(--rf);
  font-size: .84rem;
  font-weight: 600;
  box-shadow: var(--sombra-3);
  transform: translateX(-50%) translateY(80px);
  transition: transform 300ms var(--ease);
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--rojo); }


/* ══════════════════════════════════════════════════════
   RESPONSIVE
   El panel se usa sobre todo en escritorio, pero tiene que
   ser utilizable desde el celular para cargar un pedido
   sobre la marcha.
══════════════════════════════════════════════════════ */
@media (max-width: 1080px) {
  .ed-grid { grid-template-columns: 1fr; }
  .ed-resumen { position: static; }
}

/* Con menos ancho, cuatro columnas dejan los campos ilegibles. Pasa a dos y
   el agrupado se mantiene igual: dos filas para lo que cargás vos y dos para
   los datos del cliente. */
@media (max-width: 900px) {
  .campos--pedido { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .campos--pedido .campo--fila-nueva { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .campos--pedido { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .ad-top-inner { height: auto; padding: var(--s3) var(--s4); flex-wrap: wrap; gap: var(--s2); }
  .ad-sep, .ad-seccion { display: none; }
  .ad-nav button { padding: 6px 11px; font-size: .8rem; }
  .ad-canal { margin-left: auto; }
  .modal-caja { padding: var(--s4); }
  .campo-con-boton { flex-direction: column; }
  .btn--mapa { width: 100%; justify-content: center; }
  .ad-wrap { padding: var(--s4); }
  .panel { padding: var(--s4); }

  /* Las tablas anchas se recorren en horizontal en vez de romperse. */
  .tabla-wrap { overflow-x: auto; }
  .tabla { min-width: 640px; }

  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-v { font-size: 1.15rem; }

  /* 16px evita el zoom automático de iOS al enfocar un campo. */
  .campo input, .campo select, .campo textarea,
  .ad-buscar input, .buscador-prod input,
  .tabla--items input[type="number"] { font-size: 16px; }
}
