/* ═══════════════════════════════════════════════════════════════════════════
   MiResta · estilos comunes (panel, tablet, plataforma, cuenta)
   Rejilla de espacios 8 / 16 / 32 (decisión del dueño, 9-ago-2026).
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --e1: 8px; --e2: 16px; --e3: 32px;
  --r1: 8px; --r2: 12px; --r3: 16px;
  --tinta: #1d1a16; --tinta-2: #4a443d; --suave: #6b6359; --linea: #e9e1d5; --linea-2: #f1ebe2;
  --fondo: #faf6ef; --hoja: #ffffff; --hoja-2: #fdfaf5;
  --acento: #e4572e; --acento-2: #b5401c;   /* acento-2: texto y botón principal (blanco encima: 5.6 de contraste; el acento claro daba 3.7) */ --acento-suave: #fdebe4;
  --ok: #1a7340; --ok-suave: #e3f4ea; --alerta: #8a5a00; --alerta-suave: #fdf3dc; --mal: #c53030; --mal-suave: #fde8e8;
  --info: #2563a8; --info-suave: #e5eef9;
  --sombra: 0 1px 2px rgba(40,30,20,.06), 0 4px 16px rgba(40,30,20,.06);
  --sombra-2: 0 8px 32px rgba(40,30,20,.16);
  --letra: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--letra); color: var(--tinta); background: var(--fondo); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--acento-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--e1); }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 0 0 var(--e2); }
.suave { color: var(--suave); }
.chico { font-size: 13px; }
.oculto, [hidden] { display: none !important; }
.marca { font-weight: 800; letter-spacing: -.5px; }
.marca b { color: var(--acento); font-weight: 800; }

/* ── botones ───────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--e1);
       min-height: 40px; padding: 0 var(--e2); border-radius: var(--r1); border: 1px solid var(--linea);
       background: var(--hoja); color: var(--tinta); font-weight: 600; cursor: pointer; text-decoration: none;
       transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--hoja-2); border-color: #dccfbd; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primario { background: var(--acento-2); border-color: var(--acento-2); color: #fff; }
.btn.primario:hover { background: #9c3716; border-color: #9c3716; }
.btn.peligro { color: var(--mal); border-color: #f2c4c4; }
.btn.peligro:hover { background: var(--mal-suave); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.fantasma { background: transparent; border-color: transparent; }
.btn.fantasma:hover { background: var(--linea-2); }
.btn.grande { min-height: 48px; font-size: 16px; padding: 0 var(--e3); border-radius: var(--r2); }
.btn.chico { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.bloque { width: 100%; }

/* ── formularios ───────────────────────────────────────────────────────── */
.campo { display: block; margin-bottom: var(--e2); }
.campo > span { display: block; font-size: 13px; font-weight: 600; color: var(--tinta-2); margin-bottom: 4px; }
.campo small { display: block; color: var(--suave); font-size: 12px; margin-top: 4px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search],
input[type=url], input[type=time], input[type=date], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--linea); border-radius: var(--r1);
  background: var(--hoja); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 80px; resize: vertical; }
/* En pantallas táctiles, 16px: con menos, iOS (Safari y la app) hace zoom al tocar el campo y la página queda cortada. */
@media (pointer: coarse) { input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=search], input[type=url], input[type=time], input[type=date], select, textarea { font-size: 16px; } }
input:focus, select:focus, textarea:focus { border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
input.mal, select.mal, textarea.mal { border-color: var(--mal); box-shadow: 0 0 0 3px var(--mal-suave); }
.fila { display: flex; gap: var(--e2); flex-wrap: wrap; }
.fila > * { flex: 1 1 160px; }

/* interruptor (switch) */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--e1); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 44px; height: 26px; border-radius: 99px; background: #d8cfc3; position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
                   background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--acento-suave); }

/* ── tarjetas, chips, etiquetas ────────────────────────────────────────── */
.tarjeta { background: var(--hoja); border: 1px solid var(--linea); border-radius: var(--r2); padding: var(--e2); box-shadow: var(--sombra); }
.tarjeta + .tarjeta { margin-top: var(--e2); }
/* En una rejilla el espacio lo pone el gap: sin esto la segunda tarjeta queda más abajo que la primera. */
.rejilla > .tarjeta, .kpis > .tarjeta { margin-top: 0; }
.etq { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700;
       background: var(--linea-2); color: var(--tinta-2); white-space: nowrap; }
.etq.ok { background: var(--ok-suave); color: var(--ok); }
.etq.alerta { background: var(--alerta-suave); color: var(--alerta); }
.etq.mal { background: var(--mal-suave); color: var(--mal); }
.etq.info { background: var(--info-suave); color: var(--info); }
.etq.acento { background: var(--acento-suave); color: var(--acento-2); }

/* ── avisos (toast) ────────────────────────────────────────────────────── */
#avisos { position: fixed; left: 50%; bottom: calc(var(--e2) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
          display: flex; flex-direction: column; gap: var(--e1); z-index: 9999; width: min(92vw, 440px); pointer-events: none; }
.aviso { background: #24201b; color: #fff; padding: 12px var(--e2); border-radius: var(--r2); box-shadow: var(--sombra-2);
         font-weight: 600; animation: entra .2s ease-out; pointer-events: auto; }
.aviso.ok { background: var(--ok); } .aviso.mal { background: var(--mal); }
@keyframes entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── ventanas (modal) ──────────────────────────────────────────────────── */
.velo { position: fixed; inset: 0; background: rgba(28,22,16,.45); display: flex; align-items: center; justify-content: center;
        padding: var(--e2); z-index: 900; animation: aparece .15s; }
@keyframes aparece { from { opacity: 0; } }
.ventana { background: var(--hoja); border-radius: var(--r3); width: min(100%, 560px); max-height: calc(100vh - 32px);
           overflow: auto; box-shadow: var(--sombra-2); }
.ventana.ancha { width: min(100%, 880px); }
.ventana > header { display: flex; align-items: center; gap: var(--e1); padding: var(--e2); border-bottom: 1px solid var(--linea);
                    position: sticky; top: 0; background: var(--hoja); z-index: 1; }
.ventana > header h2 { flex: 1; margin: 0; }
.ventana > .cuerpo { padding: var(--e2); }
.ventana > footer { display: flex; gap: var(--e1); justify-content: flex-end; padding: var(--e2); border-top: 1px solid var(--linea);
                    position: sticky; bottom: 0; background: var(--hoja); flex-wrap: wrap; }
/* «Cerrar» en texto (antes una «×» que no se leía como botón). */
.cerrar { min-height: 36px; padding: 0 var(--e2); border-radius: var(--r1); border: 0; background: var(--linea-2); color: var(--tinta-2); cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; flex: none; }
.cerrar:hover { background: var(--linea); }

.vacio { text-align: center; padding: var(--e3) var(--e2); color: var(--suave); }
.vacio b { display: block; color: var(--tinta); font-size: 17px; margin-bottom: 4px; }
.cargando { display: inline-block; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent;
            border-radius: 50%; animation: gira .7s linear infinite; vertical-align: -3px; }
@keyframes gira { to { transform: rotate(360deg); } }
table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--suave); font-weight: 700;
            padding: 8px; border-bottom: 1px solid var(--linea); }
.tabla td { padding: 8px; border-bottom: 1px solid var(--linea-2); vertical-align: middle; }
.desliza { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.estado-svc { padding: 12px var(--e2); border-radius: var(--r1); background: var(--alerta-suave); color: #6b4a0f; font-size: 14px; }

/* ═══ CELULAR ═══════════════════════════════════════════════════════════════
   Pantallas táctiles: todo lo que se toca mide al menos 40-44 px. En ≤720 px las ventanas suben desde abajo (como una hoja)
   y las tablas con la clase «apilada» se vuelven una tarjeta por fila (con data-et en cada celda como etiqueta). */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.chico { min-height: 40px; padding: 0 16px; }
  .cerrar { min-height: 44px; }
  .campo > span { font-size: 14px; }
}
@media (max-width: 560px) {
  .velo { align-items: flex-end; padding: 0; }
  .ventana { width: 100%; max-height: 92dvh; border-radius: var(--r3) var(--r3) 0 0; }
  .ventana > footer { padding-bottom: calc(var(--e2) + env(safe-area-inset-bottom, 0px)); }
  .ventana > footer .btn { flex: 1 1 auto; }
}
@media (max-width: 720px) {
  .tabla.apilada thead { display: none; }
  .tabla.apilada, .tabla.apilada tbody { display: block; }
  .tabla.apilada tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; padding: 12px var(--e2); border-bottom: 1px solid var(--linea-2); }
  .tabla.apilada td { display: block; padding: 0; border: 0; min-width: 0; }
  .tabla.apilada td::before { content: attr(data-et); display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--suave); margin-bottom: 2px; }
  .tabla.apilada td:not([data-et])::before { display: none; }
  .tabla.apilada td:first-child, .tabla.apilada td:last-child:not([data-et]) { grid-column: 1 / -1; }
  .tabla.apilada td:first-child::before { display: none; }
}

/* iPhone dentro de la app: nada queda debajo de la muesca ni de la barra de gestos (las pantallas completas lo manejan aparte) */
body.con-muesca { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
