/* ═══════════════════════════════════════════
   TINTO — PEDIDOS PWA · estilos
   Base compartida + #view-pedidos + #view-gestion
   (las dos vistas viven en el mismo documento, por eso van con ámbito)
   ═══════════════════════════════════════════ */

:root {
  --primary: #814314;
  --rojo: #7F2D11;
  --teal: #529D95;
  --mostaza: #CC9C37;
  --crema: #E8E1D5;
  --bg: #F4F0E9;
  --text: #333;
  --success: #25D366;
  --danger: #d32f2f;
  --header-h: 97px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); margin: 0;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cabecera común ── */
.app-header {
  background: var(--primary); padding: 10px 14px 0;
  position: sticky; top: 0; z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
}
.hdr-top { display: flex; gap: 10px; align-items: center; min-height: 38px; }
.hdr-brand { color: var(--crema); font-weight: 800; font-size: 16px; white-space: nowrap; letter-spacing: 3px; }
.hdr-spacer { flex: 1; }
.search-input {
  width: 100%; padding: 8px 12px; border-radius: 20px; border: none;
  font-size: 14px; outline: none; background: rgba(255,255,255,0.95); font-family: inherit;
}
.btn-hdr {
  background: rgba(255,255,255,0.18); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1; flex-shrink: 0;
}
.btn-hdr:active { background: rgba(255,255,255,0.4); }
.btn-hdr.girando { animation: spin 0.8s linear infinite; }

/* Conmutador Pedidos / Gestión (solo con permiso) */
.vista-switch { display: flex; gap: 3px; background: rgba(0,0,0,0.18); border-radius: 9px; padding: 3px; margin-top: 8px; }
.vista-switch button {
  flex: 1; padding: 7px 0; border: none; border-radius: 7px; background: transparent;
  color: rgba(255,255,255,0.75); font-size: 12px; font-weight: 800; letter-spacing: 0.5px;
  cursor: pointer; font-family: inherit;
}
.vista-switch button.active { background: var(--crema); color: var(--primary); }

.tab-bar { display: flex; gap: 4px; margin-top: 10px; }
.tab-btn {
  flex: 1; padding: 9px 0; border: none; border-radius: 8px 8px 0 0;
  background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.7);
  font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit;
  position: relative;
}
.tab-btn.active { background: var(--bg); color: var(--primary); }
.tab-badge {
  display: inline-block; min-width: 17px; padding: 0 4px; margin-left: 4px;
  background: var(--rojo); color: #fff; border-radius: 9px; font-size: 10px; line-height: 17px; vertical-align: 1px;
}
.tab-btn.active .tab-badge { background: var(--rojo); }

/* ── Pills de proveedor (compartidas) ── */
.prov-pills {
  display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto;
  background: #fff; border-bottom: 1px solid #eee; -webkit-overflow-scrolling: touch;
}
.prov-pills:empty { display: none; }
.pill {
  padding: 6px 13px; border-radius: 20px; border: 1.5px solid #ddd; background: #fff;
  font-size: 12px; font-weight: 600; cursor: pointer; color: #666;
  white-space: nowrap; flex-shrink: 0; font-family: inherit;
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.loader { padding: 40px; text-align: center; color: var(--primary); font-weight: bold; }
.empty-msg { padding: 60px 20px; text-align: center; color: #8e8e93; font-size: 16px; }

/* ── Aviso de sin conexión / guardando ── */
#barra-estado {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3000;
  padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 10px);
  font-size: 13px; font-weight: 700; text-align: center; color: #fff; background: #555;
  transform: translateY(100%); transition: transform 0.25s;
}
#barra-estado.visible { transform: translateY(0); }
#barra-estado.err { background: var(--danger); }
#barra-estado.ok { background: #2e7d32; }

/* ═══════════ LOGIN ═══════════ */
#view-login { min-height: 100vh; background: var(--primary); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 330px; text-align: center; }
.login-logo { width: 96px; height: 96px; border-radius: 24px; margin: 0 auto 16px; display: block; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.login-title { color: var(--crema); font-size: 22px; font-weight: 800; letter-spacing: 4px; margin: 0 0 4px; }
.login-sub { color: rgba(255,255,255,0.65); font-size: 13px; margin: 0 0 22px; }
.login-nombres { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.login-nombres button {
  padding: 10px 16px; border-radius: 22px; border: 2px solid rgba(255,255,255,0.3);
  background: transparent; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.login-nombres button.active { background: var(--crema); color: var(--primary); border-color: var(--crema); }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; height: 16px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.45); }
.pin-dot.on { background: var(--crema); border-color: var(--crema); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.teclado button {
  padding: 16px 0; border-radius: 14px; border: none; background: rgba(255,255,255,0.14);
  color: #fff; font-size: 22px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.teclado button:active { background: rgba(255,255,255,0.3); }
.teclado button.aux { font-size: 15px; font-weight: 800; background: transparent; }
.login-err { color: #ffcdd2; font-size: 13px; font-weight: 700; min-height: 18px; margin-top: 14px; }

/* ═══════════ AJUSTES (hoja inferior) ═══════════ */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 4000; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; animation: fadeIn 0.2s ease;
}
.sheet-box {
  background: #fff; width: 100%; border-radius: 18px 18px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom, 0px) + 18px);
  max-height: 85vh; overflow-y: auto;
}
.sheet-title { font-weight: 800; font-size: 16px; color: #1c1c1e; margin-bottom: 4px; }
.sheet-sub { font-size: 13px; color: #888; margin-bottom: 16px; }
.sheet-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid #f0f0f0; font-size: 15px; color: #333;
}
.sheet-row:last-of-type { border-bottom: none; }
.sheet-row small { display: block; font-size: 12px; color: #999; font-weight: 400; }
.sw { width: 50px; height: 30px; border-radius: 15px; border: none; background: #ddd; position: relative; cursor: pointer; flex-shrink: 0; transition: background 0.2s; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.sw.on { background: var(--success); }
.sw.on::after { transform: translateX(20px); }
.btn-sheet { width: 100%; padding: 14px; border-radius: 12px; border: none; font-weight: 800; font-size: 15px; cursor: pointer; margin-top: 14px; font-family: inherit; }
.btn-sheet.pri { background: var(--primary); color: #fff; }
.btn-sheet.sec { background: #fff; border: 2px solid #e0e0e0; color: #666; }
.btn-sheet.dan { background: #fff; border: 2px solid #ffcdd2; color: var(--danger); }

/* ═══════════════════════════════════════════
   VISTA PEDIDOS
   ═══════════════════════════════════════════ */
#view-pedidos { padding-bottom: 180px; }
#view-pedidos .container { padding: 10px; max-width: 600px; margin: 0 auto; }
#view-pedidos .prov-card { background: #fff; border-radius: 12px; margin-bottom: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
#view-pedidos .prov-title {
  background: var(--crema); padding: 10px 15px; font-weight: bold; color: #5a3a1e; font-size: 13px;
  text-transform: uppercase; border-bottom: 1px solid #ddd3c3; border-radius: 12px 12px 0 0;
  position: sticky; top: var(--header-h); z-index: 500; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
#view-pedidos .item-row { padding: 12px 15px; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; justify-content: space-between; }
#view-pedidos .item-row:last-child { border-bottom: none; border-radius: 0 0 12px 12px; }
#view-pedidos .item-info { flex: 1; padding-right: 10px; }
#view-pedidos .item-name { font-weight: 600; font-size: 15px; color: #222; margin-bottom: 2px; line-height: 1.2; }
#view-pedidos .item-unit { font-size: 12px; color: #888; }
#view-pedidos .item-pending { font-size: 11px; color: #e65100; background: #fff3e0; padding: 2px 6px; border-radius: 4px; margin-top: 3px; display: inline-block; }
#view-pedidos .qty-control { display: flex; align-items: center; gap: 8px; background: #f2f2f2; padding: 3px; border-radius: 20px; }
#view-pedidos .btn-qty { width: 32px; height: 32px; border-radius: 50%; border: none; font-weight: bold; font-size: 18px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-family: inherit; }
#view-pedidos .btn-minus { background: #fff; color: #333; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
#view-pedidos .btn-plus { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
#view-pedidos .qty-display { font-weight: bold; font-size: 15px; min-width: 22px; text-align: center; }
#view-pedidos .section-header { padding: 8px 15px; background: #fafafa; font-size: 11px; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #f0f0f0; }

/* Producto fuera de la lista */
#view-pedidos .custom-card { background: #fff; border-radius: 12px; margin: 10px; padding: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 2px dashed #ccc; }
#view-pedidos .custom-card-title { font-weight: 700; font-size: 13px; color: #888; text-transform: uppercase; margin-bottom: 12px; }
#view-pedidos .custom-row { display: flex; gap: 8px; margin-bottom: 8px; }
#view-pedidos .custom-input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; background: #fafafa; font-family: inherit; }
#view-pedidos .custom-input:focus { outline: none; border-color: var(--primary); }
#view-pedidos .custom-input.sm { flex: 0.5; }
#view-pedidos .custom-select {
  flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; background: #fafafa;
  font-family: inherit; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
#view-pedidos .custom-select:focus { outline: none; border-color: var(--primary); }
#view-pedidos .custom-toggle { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
#view-pedidos .custom-toggle input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
#view-pedidos .custom-toggle label { font-size: 13px; color: #555; font-weight: 600; }
#view-pedidos .btn-add-custom { width: 100%; padding: 11px; border: none; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; font-family: inherit; }
#view-pedidos .custom-items { margin-top: 10px; }
#view-pedidos .custom-item-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
#view-pedidos .custom-item-row:last-child { border-bottom: none; }
#view-pedidos .custom-item-prov { font-size: 11px; color: #888; }
#view-pedidos .custom-item-perm { font-size: 10px; color: var(--primary); font-weight: 700; }
#view-pedidos .btn-remove-custom { background: none; border: none; color: #ccc; font-size: 20px; cursor: pointer; padding: 0 4px; }

/* Pie de Pedir */
.footer {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  padding: 10px 15px env(safe-area-inset-bottom, 12px) 15px;
  border-top: 1px solid #ddd; box-shadow: 0 -4px 12px rgba(0,0,0,0.06); z-index: 900;
}
.footer-row { display: flex; gap: 8px; margin-bottom: 8px; }
.footer-quien { flex: 1; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 15px; font-weight: 600; background: #f9f9f9; color: #333; display: flex; align-items: center; gap: 6px; }
.input-nota { flex: 1.5; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; font-size: 14px; background: #f9f9f9; font-family: inherit; }
.input-nota:focus { outline: none; border-color: var(--primary); }
.btn-send { width: 100%; padding: 13px; border: none; border-radius: 8px; background: #ccc; color: #fff; font-weight: bold; font-size: 15px; cursor: not-allowed; transition: all 0.2s; font-family: inherit; }
.btn-send.active { background: var(--success); cursor: pointer; box-shadow: 0 2px 8px rgba(37,211,102,0.35); }

/* Éxito */
.success-screen { animation: fadeIn 0.4s ease; padding: 50px 20px 40px; text-align: center; background: #fff; min-height: 100vh; }
.success-icon { font-size: 72px; display: block; margin-bottom: 16px; }
.success-title { font-size: 26px; font-weight: 800; color: #1a1a1a; margin: 0 0 8px; }
.success-msg { color: #666; font-size: 15px; line-height: 1.5; margin-bottom: 28px; }
.summary-box { background: #f8f9fa; border-radius: 12px; padding: 18px 20px; text-align: left; margin-bottom: 24px; border: 1px solid #eee; }
.summary-item { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed #ddd; font-size: 14px; color: #333; }
.summary-item:last-child { border-bottom: none; }
.summary-nota { margin-top: 12px; font-style: italic; color: #888; font-size: 13px; }
.btn-wa-big { background: var(--success); color: #fff; width: 100%; padding: 16px; border-radius: 12px; font-size: 16px; font-weight: 800; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 4px 15px rgba(37,211,102,0.35); margin-bottom: 12px; font-family: inherit; }
.btn-new { background: transparent; color: #888; border: 2px solid #e5e5e5; width: 100%; padding: 13px; border-radius: 12px; font-weight: bold; font-size: 14px; cursor: pointer; font-family: inherit; }

/* Pestaña Pedidos */
.pedidos-container { padding: 10px; max-width: 600px; margin: 0 auto; padding-bottom: 30px; }
.pedido-card { background: #fff; border-radius: 10px; padding: 12px 15px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); display: flex; align-items: center; justify-content: space-between; }
.pedido-card.comprado { opacity: 0.55; }
.pedido-card.rechazado { opacity: 0.4; }
.pedido-info { flex: 1; }
.pedido-nombre { font-weight: 700; font-size: 15px; color: #222; }
.pedido-meta { font-size: 12px; color: #888; margin-top: 2px; }
.pedido-obs { font-size: 12px; color: #7a6000; margin-top: 4px; background: #fffbe6; padding: 3px 6px; border-radius: 4px; display: inline-block; }
.badge-status { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.badge-pendiente { background: #fff3e0; color: #e65100; }
.badge-comprado { background: #e8f5e9; color: #2e7d32; }
.badge-rechazado { background: #fce4ec; color: #c62828; }
.pedidos-empty { text-align: center; padding: 60px 20px; color: #aaa; font-size: 15px; }
.filters-bar { padding: 8px 10px; background: #fff; border-bottom: 1px solid #eee; position: sticky; top: var(--header-h); z-index: 100; }
.filter-row { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; align-items: center; }
.filter-row:last-child { margin-bottom: 0; }
.filter-label { font-size: 10px; color: #999; font-weight: 700; text-transform: uppercase; width: 60px; flex-shrink: 0; }
.date-input { padding: 5px 8px; border: 1.5px solid #ddd; border-radius: 8px; font-size: 12px; background: #fff; font-family: inherit; color: #444; }
.date-input:focus { outline: none; border-color: var(--primary); }

/* Por recibir (confirmación de entregas) */
.rec-wrap { padding: 10px 10px 0; max-width: 600px; margin: 0 auto; }
.rec-wrap:empty { display: none; }
.rec-msg { background: #e8f5e9; color: #2e7d32; padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.rec-title { font-weight: 800; font-size: 13px; color: #333; margin: 4px 2px 8px; display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.rec-count { background: var(--primary); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 8px; }
.rec-quien { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 8px; }
.rec-quien select { flex: 1; padding: 9px 10px; border: 1px solid #ccc; border-radius: 8px; font-size: 14px; font-weight: 600; background: #fff; font-family: inherit; color: #333; }
.rec-card { background: #fff; border-radius: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.07); border-left: 4px solid var(--primary); overflow: hidden; }
.rec-card.hoy { border-left-color: #2e7d32; }
.rec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid #f0f0f0; }
.rec-prov { font-weight: 800; font-size: 14px; text-transform: uppercase; color: #222; }
.rec-dia { font-size: 12px; color: #888; }
.rec-line { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f4f4f4; cursor: pointer; }
.rec-line.dif { background: #fff6ee; }
.rec-info { flex: 1; min-width: 0; }
.rec-n { font-weight: 600; font-size: 15px; color: #222; line-height: 1.25; }
.rec-sub { font-size: 11px; color: #999; margin-top: 2px; line-height: 1.35; }
.rec-dif { font-size: 12px; font-weight: 700; color: #c62828; margin-top: 3px; }
.rec-dif.mas { color: #8a6d00; }
.rec-q { text-align: right; font-weight: 800; font-size: 17px; white-space: nowrap; color: #222; }
.rec-q small { display: block; font-size: 11px; font-weight: 400; color: #888; }
.rec-tag { font-size: 10px; font-weight: 700; background: #fce4ec; color: #c62828; padding: 1px 6px; border-radius: 5px; vertical-align: 1px; }
.rec-ed { background: #faf7f2; padding: 10px 14px; border-bottom: 1px solid #eee; }
.rec-ed-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; flex-wrap: wrap; color: #333; }
.rec-ed-row input { width: 66px; padding: 7px; border: 1px solid #ccc; border-radius: 8px; font-size: 16px; text-align: center; font-weight: 700; font-family: inherit; }
.rec-ed-row button { width: 34px; height: 34px; border-radius: 50%; border: none; background: #e9e4dc; font-size: 18px; font-weight: 700; cursor: pointer; color: #333; font-family: inherit; }
.rec-mot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rec-mot button { padding: 6px 11px; border-radius: 16px; border: 1.5px solid #ddd; background: #fff; font-size: 12px; font-weight: 600; color: #555; cursor: pointer; font-family: inherit; }
.rec-mot button.on { background: #c62828; border-color: #c62828; color: #fff; }
.rec-ed-acts { display: flex; gap: 8px; margin-top: 10px; }
.rec-ed-acts button { flex: 1; padding: 9px; border-radius: 8px; font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit; }
.rec-bien { background: #fff; border: 1.5px solid #2e7d32; color: #2e7d32; }
.rec-listo { background: #333; border: none; color: #fff; }
.rec-foot { padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.rec-extra-btn { background: none; border: none; color: #888; font-size: 12px; font-weight: 600; text-align: left; padding: 0; text-decoration: underline; cursor: pointer; font-family: inherit; }
.rec-extra { width: 100%; padding: 9px 10px; border: 1.5px dashed #ccc; border-radius: 8px; font-size: 14px; font-family: inherit; background: #fffdf6; }
.rec-ok { width: 100%; padding: 13px; border: none; border-radius: 10px; background: var(--success); color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; font-family: inherit; }
.rec-ok.difs { background: #e65100; }
.rec-ok:disabled { opacity: 0.55; cursor: default; }
.rec-sec { width: 100%; padding: 11px; border-radius: 10px; border: 2px solid #e0e0e0; background: #fff; color: #555; font-weight: 700; font-size: 14px; cursor: pointer; font-family: inherit; }
.rec-row2 { display: flex; gap: 8px; }
.rec-row2 > button { flex: 1; }
details.rec-hoy { margin-bottom: 10px; }
details.rec-hoy summary { font-size: 13px; font-weight: 700; color: #2e7d32; padding: 6px 2px 10px; cursor: pointer; list-style: none; }
details.rec-hoy summary::-webkit-details-marker { display: none; }
.pedido-recep { font-size: 12px; margin-top: 4px; color: #2e7d32; font-weight: 600; }
.pedido-recep.dif { color: #c62828; }

/* ═══════════════════════════════════════════
   VISTA GESTIÓN
   ═══════════════════════════════════════════ */
#view-gestion { padding-bottom: 160px; }
#view-gestion .sticky-tools { position: sticky; top: var(--header-h); z-index: 200; background: var(--bg); }
#view-gestion .toolbar { background: #fff; padding: 10px; display: flex; gap: 8px; border-bottom: 1px solid #ddd; }
#view-gestion .date-row { display: flex; gap: 4px; align-items: center; }
#view-gestion .date-input { padding: 6px 8px; width: 120px; }
#view-gestion .pill-sm { padding: 4px 8px; border-radius: 12px; border: 1px solid #ddd; background: #fff; font-size: 11px; cursor: pointer; color: #999; font-family: inherit; }
#view-gestion .search-wrap { position: relative; flex: 1; display: flex; align-items: center; }
#view-gestion .search-wrap input { width: 100%; -webkit-appearance: none; border: 1px solid #ccc; border-radius: 10px; padding: 10px 34px 10px 12px; font-size: 15px; background: #fff; outline: none; font-family: inherit; }
#view-gestion .search-wrap input:focus { border-color: var(--primary); }
#view-gestion .search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: #ddd; border: none; color: #666; width: 22px; height: 22px; border-radius: 50%;
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0;
}
#view-gestion select { -webkit-appearance: none; border: 1px solid #ccc; border-radius: 10px; padding: 10px 12px; font-size: 15px; background: #fff; outline: none; font-family: inherit; }
#view-gestion .card { background: #fff; margin: 12px; border-radius: 15px; box-shadow: 0 4px 12px rgba(0,0,0,0.07); overflow: visible; }
#view-gestion .card-head {
  padding: 11px 15px; font-weight: bold; font-size: 13px; color: var(--primary);
  text-transform: uppercase; border-bottom: 1px solid #e0e0e0; letter-spacing: 0.5px;
  border-radius: 15px 15px 0 0; display: flex; align-items: center; justify-content: space-between;
}
#view-gestion .sticky-head { position: sticky; z-index: 150; box-shadow: 0 2px 4px rgba(0,0,0,0.06); }
#view-gestion .head-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
#view-gestion .btn-wa-prov {
  background: var(--success); border: none; color: #fff; width: 32px; height: 32px; border-radius: 10px;
  font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(37,211,102,0.3); flex-shrink: 0; transition: transform 0.1s;
}
#view-gestion .btn-wa-prov:active { transform: scale(0.9); }
#view-gestion .btn-checkall { background: #fff; border: 1.5px solid #ccc; color: #666; padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: all 0.15s; font-family: inherit; }
#view-gestion .btn-checkall:active { background: var(--success); border-color: var(--success); color: #fff; }
#view-gestion .row { padding: 13px 15px; border-bottom: 1px solid #ececec; }
#view-gestion .row:last-child { border-bottom: none; }
#view-gestion .row-main { display: flex; justify-content: space-between; align-items: center; }
#view-gestion .nom { font-weight: 700; font-size: 16px; color: #1c1c1e; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#view-gestion .cant { color: var(--primary); font-weight: 800; font-size: 15px; }
#view-gestion .uni { color: #8e8e93; font-weight: 400; font-size: 13px; }
#view-gestion .fecha-meta { font-size: 12px; color: #8e8e93; margin-top: 3px; }
#view-gestion .detalle-personas { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
#view-gestion .detalle-chip { font-size: 11px; background: #f0f0f5; color: #555; padding: 3px 8px; border-radius: 10px; font-weight: 600; }
#view-gestion .state-tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
#view-gestion .tag-comprado { background: #e8f5e9; color: #2e7d32; }
#view-gestion .tag-rechazado { background: #fce4ec; color: #c62828; }
#view-gestion .tag-falta { background: #c62828; color: #fff; }
#view-gestion .entradas-breakdown { margin-top: 4px; }
#view-gestion .entrada-line { font-size: 10px; color: #8e8e93; line-height: 1.5; padding-left: 2px; }
#view-gestion .custom-controls { margin-top: 8px; padding: 8px 10px; background: #f9f7f0; border-radius: 8px; border: 1px dashed #e0d8c0; }
#view-gestion .custom-controls-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
#view-gestion .custom-controls-row:last-child { margin-bottom: 0; }
#view-gestion .custom-select-prov { flex: 1; padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px; background: #fff; font-family: inherit; }
#view-gestion .btn-reclasificar { padding: 6px 10px; border: none; border-radius: 6px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap; font-family: inherit; }
#view-gestion .btn-hacer-perm { padding: 5px 10px; border: 1.5px solid var(--primary); border-radius: 6px; background: #fff; color: var(--primary); font-size: 11px; font-weight: 700; cursor: pointer; font-family: inherit; }
#view-gestion .btn-hacer-perm:active { background: var(--primary); color: #fff; }
#view-gestion .action-btns { display: flex; gap: 6px; flex-shrink: 0; }
#view-gestion .btn-check, #view-gestion .btn-reject {
  width: 38px; height: 38px; border-radius: 10px; border: 2px solid #ddd; background: #fff;
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: #ccc; transition: all 0.15s; font-family: inherit;
}
#view-gestion .btn-check:active, #view-gestion .btn-check.active { background: var(--success); border-color: var(--success); color: #fff; }
#view-gestion .btn-reject:active, #view-gestion .btn-reject.active { background: var(--danger); border-color: var(--danger); color: #fff; }
#view-gestion .comprados-det { border-top: 1px solid #eee; }
#view-gestion .comprados-det summary { padding: 12px 15px; font-size: 14px; color: #8e8e93; font-weight: 600; outline: none; cursor: pointer; list-style: none; }
#view-gestion .comprados-det summary::-webkit-details-marker { display: none; }
#view-gestion .comprados-det summary::before { content: '▸ '; }
#view-gestion .comprados-det[open] summary::before { content: '▾ '; }
#view-gestion .nota-badge { margin-top: 8px; padding: 6px 10px; background: #fffbe6; border-left: 3px solid var(--mostaza); border-radius: 0 6px 6px 0; font-size: 13px; color: #7a6000; line-height: 1.4; word-break: break-word; }
#view-gestion .obs-badge { margin-top: 6px; padding: 6px 10px; background: #e6f2f1; border-left: 3px solid var(--teal); border-radius: 0 6px 6px 0; font-size: 13px; color: #2c5f59; line-height: 1.4; word-break: break-word; }
#view-gestion .nota-input { width: 100%; margin-top: 10px; border: 1.5px dashed #ccc; padding: 9px 11px; border-radius: 8px; font-size: 14px; background: #fffdf0; color: #444; font-family: inherit; }
#view-gestion .nota-input:focus { outline: none; border-color: var(--primary); }
#view-gestion .notas-block, #view-gestion .avisos-block { margin: 12px 12px 0; }
#view-gestion .notas-block:empty, #view-gestion .avisos-block:empty { display: none; }
#view-gestion .nota-pedido { background: #fffbe6; border: 1px solid #f0e2b0; border-left: 4px solid var(--mostaza); border-radius: 0 12px 12px 0; padding: 10px 12px; margin-bottom: 8px; }
#view-gestion .nota-pedido-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; color: #7a6000; }
#view-gestion .nota-pedido-texto { margin-top: 6px; font-size: 14px; color: #3d3200; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
#view-gestion .btn-nota-visto { border: 1.5px solid var(--mostaza); background: #fff; color: #7a6000; font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 8px; cursor: pointer; white-space: nowrap; flex-shrink: 0; font-family: inherit; }
#view-gestion .btn-nota-visto:active { background: var(--mostaza); color: #fff; }
#view-gestion .btn-nota-visto:disabled { opacity: 0.5; }
#view-gestion .badge-ok { background: #e6f9ee; color: #1a7d45; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
#view-gestion .badge-rechazado-hist { background: #fce4ec; color: #c62828; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
#view-gestion .comp-row { margin-top: 6px; font-size: 13px; font-weight: 700; color: #2e7d32; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#view-gestion .comp-input { width: 70px; padding: 6px 8px; border: 1.5px solid #2e7d32; border-radius: 8px; font-size: 15px; font-weight: 700; text-align: center; font-family: inherit; background: #fff; }
#view-gestion .comp-dif { font-size: 11px; font-weight: 700; color: #e65100; background: #fff3e0; padding: 2px 6px; border-radius: 5px; }
#view-gestion .faltas-resumen { background: #fdecea; color: #b71c1c; border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
#view-gestion .aviso-rec { background: #fff8e1; border: 1px solid #f3dfa2; border-left: 4px solid #e6a100; border-radius: 0 12px 12px 0; padding: 10px 12px; margin-bottom: 8px; }
#view-gestion .aviso-rec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; color: #7a5a00; }
#view-gestion .aviso-rec-texto { margin-top: 6px; font-size: 14px; color: #3d3200; line-height: 1.45; word-break: break-word; }
#view-gestion .rec-badge { margin-top: 6px; padding: 5px 10px; background: #e8f5e9; border-left: 3px solid #2e7d32; border-radius: 0 6px 6px 0; font-size: 12px; font-weight: 600; color: #1b5e20; }
#view-gestion .rec-badge.dif { background: #fdecea; border-left-color: #c62828; color: #b71c1c; }
#view-gestion .rec-badge.nada { background: #f2f2f2; border-left-color: #999; color: #666; }

/* Botones fijos de Gestión */
.fab-area {
  position: fixed; bottom: 0; width: 100%; background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px); padding: 12px 16px calc(env(safe-area-inset-bottom, 16px) + 12px);
  display: flex; flex-direction: column; gap: 8px; border-top: 1px solid #ddd; z-index: 900;
}
.fab-row { display: flex; gap: 8px; }
.fab-row > button { flex: 1; }
.btn-wa { background: var(--success); color: #fff; border: none; padding: 15px; border-radius: 12px; font-weight: 800; font-size: 16px; box-shadow: 0 4px 10px rgba(37,211,102,0.3); cursor: pointer; font-family: inherit; }
.btn-equipo { background: var(--primary); color: #fff; border: none; padding: 15px; border-radius: 12px; font-weight: 800; font-size: 15px; cursor: pointer; font-family: inherit; }
.btn-archive { background: #c0c0c0; color: #fff; border: none; padding: 12px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; transition: background 0.2s; font-family: inherit; }
.btn-archive.has-items { background: var(--primary); }

/* Modal WhatsApp / Enviar a la equipa */
.wa-modal-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn 0.2s ease; }
.wa-modal-box { background: #fff; border-radius: 16px; width: 100%; max-width: 400px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
.wa-modal-title { padding: 14px 18px; font-weight: 800; font-size: 15px; color: #1c1c1e; border-bottom: 1px solid #eee; flex-shrink: 0; }
.wa-modal-preview { padding: 14px 18px; font-size: 13px; color: #333; line-height: 1.6; overflow-y: auto; flex: 1; white-space: pre-wrap; word-break: break-word; font-family: inherit; margin: 0; background: #fafafa; }
.wa-modal-send { display: block; margin: 12px 16px 8px; padding: 14px; border-radius: 12px; background: var(--success); color: #fff; text-align: center; font-weight: 800; font-size: 15px; text-decoration: none; box-shadow: 0 3px 10px rgba(37,211,102,0.3); flex-shrink: 0; border: none; cursor: pointer; font-family: inherit; }
.wa-modal-send:active { opacity: 0.85; }
.wa-modal-back { display: block; width: calc(100% - 32px); margin: 0 16px 14px; padding: 12px; border-radius: 12px; border: 2px solid #e0e0e0; background: transparent; color: #666; font-weight: 700; font-size: 14px; cursor: pointer; text-align: center; flex-shrink: 0; font-family: inherit; }
.eq-provs { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 18px; overflow-y: auto; }
.eq-provs button { padding: 9px 14px; border-radius: 20px; border: 1.5px solid #ddd; background: #fff; font-size: 13px; font-weight: 700; color: #555; cursor: pointer; font-family: inherit; }
.eq-provs button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.eq-provs .eq-vacio { font-size: 13px; color: #999; padding: 6px 0; }

/* Orden MAKRO */
.orden-container { padding: 10px 12px; max-width: 600px; margin: 0 auto; padding-bottom: 100px; }
.orden-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; border-radius: 10px; margin-bottom: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); transition: transform 0.1s, box-shadow 0.1s; }
.orden-item.dragging { opacity: 0.5; box-shadow: 0 4px 16px rgba(0,0,0,0.15); transform: scale(1.02); }
.orden-num { font-size: 13px; font-weight: 800; color: var(--primary); min-width: 26px; text-align: center; background: #efe4d8; border-radius: 6px; padding: 4px 2px; cursor: pointer; }
.orden-handle { font-size: 18px; color: #ccc; cursor: grab; padding: 0 4px; flex-shrink: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
.orden-name { flex: 1; font-size: 14px; color: #333; font-weight: 500; line-height: 1.3; }
.orden-arrows { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.btn-arrow { width: 28px; height: 22px; border: 1px solid #ddd; border-radius: 5px; background: #fff; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #888; font-family: inherit; }
.btn-arrow:active { background: var(--primary); color: #fff; border-color: var(--primary); }
.orden-save-area { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); padding: 12px 16px calc(env(safe-area-inset-bottom, 16px) + 12px); border-top: 1px solid #ddd; z-index: 950; }
.btn-save-orden { width: 100%; padding: 14px; border: none; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 800; font-size: 16px; cursor: pointer; font-family: inherit; }
.btn-save-orden:disabled { background: #ccc; cursor: not-allowed; }
.orden-search { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 10px; font-size: 14px; background: #fff; margin-bottom: 10px; font-family: inherit; }
.orden-search:focus { outline: none; border-color: var(--primary); }
