/* =====================================================================
   Pan de Tata · Diseño "Tierra & Horno"
   Sidebar espresso oscuro · contenido crema cálido · acentos terracota/dorado
   ===================================================================== */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f4f4f6;
  --border: #e4e4e9;
  --text: #1a1c1e;
  --muted: #6d7076;
  --accent: #1a1c1e;          /* tinta casi negra */
  --accent-2: #55585e;
  --accent-soft: #ededf0;
  --ring: #ededf0;             /* anillo de foco (box-shadow) */
  --green: #1a7f37; --green-soft: #e9f4ec;
  --amber: #96690f; --amber-soft: #faf1dc;
  --red: #b42318;   --red-soft: #fbeae7;
  --blue: #3661a8;  --blue-soft: #e9eef8;
  --side: #fbfbfc;            /* barra lateral clara */
  --side-2: #f0f0f3;
  --side-text: #55585e;
  --side-strong: #1a1c1e;
  --row-border: #f0f0f2;
  --row-hover: #f7f7f8;
  --radius: 12px;
  --font-display: 'Inter', -apple-system, sans-serif;
  --font-brand: 'Fraunces', Georgia, serif;
  --shadow-sm: 0 1px 2px rgba(18, 19, 22, .05);
  --shadow: 0 1px 3px rgba(18, 19, 22, .06), 0 8px 24px rgba(18, 19, 22, .07);
  --shadow-lift: 0 4px 12px rgba(18, 19, 22, .08), 0 16px 40px rgba(18, 19, 22, .12);
}
/* ---------- Tema oscuro "Espresso" (Ajustes → Apariencia) ---------- */
body.theme-dark {
  --bg: #141517;
  --surface: #1d1e21;
  --surface-2: #26272b;
  --border: #33353a;
  --text: #ececee;
  --muted: #9a9da3;
  --accent: #ececee;
  --accent-2: #b9bcc2;
  --accent-soft: #2c2d31;
  --ring: rgba(236,236,238,.35); /* --accent-soft casi no se distinguía del fondo (1.2:1) */
  --green: #57ab6b; --green-soft: #1d2a20;
  --amber: #d0a04a; --amber-soft: #2e2718;
  --red: #e0705f;   --red-soft: #33211d;
  --blue: #7da2d8;  --blue-soft: #1f2632;
  --side: #18191c;
  --side-2: #202124;
  --side-text: #9a9da3;
  --side-strong: #ececee;
  --row-border: #26272b;
  --row-hover: #202124;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 10px 32px rgba(0, 0, 0, .45);
  --shadow-lift: 0 4px 10px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .55);
}
body.theme-dark .topbar { background: var(--bg); }
/* los documentos imprimibles (notas, recibos, comprobantes) SIEMPRE en claro */
body.theme-dark .factura {
  --surface: #fffdf8; --surface-2: #f7f1e5; --border: #e7dcc9; --text: #2c2118; --muted: #8d7c66;
  background: #fffdf8; color: #2c2118;
}
/* tamaño de letra grande (Ajustes → Apariencia) — para el sol de la calle */
body.letra-grande { zoom: 1.13; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.svg-ic { width: 18px; height: 18px; flex-shrink: 0; display: inline-block; vertical-align: middle; stroke-width: 1.9; }

/* ===== Animaciones base ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes popIn  { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes growX  { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes growY  { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes spin   { to { transform: rotate(360deg); } }

/* ===== Pantalla de carga ===== */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

/* ===== Autenticación ===== */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: var(--bg);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lift); width: 100%; max-width: 880px;
  display: grid; grid-template-columns: 1fr 1.15fr; overflow: hidden;
  animation: popIn .4s cubic-bezier(.2,.8,.3,1) both;
}
.auth-brand {
  background:
    radial-gradient(420px 300px at 85% -10%, rgba(224,150,46,.28), transparent 60%),
    radial-gradient(500px 360px at -15% 110%, rgba(194,87,31,.30), transparent 55%),
    linear-gradient(165deg, #31231a, #20150e);
  /* El fondo es fijo (marrón espresso), así que el texto también va fijo: desde
     el rediseño sobrio --side-strong/--side-text son OSCUROS en tema claro y
     dejaban el subtítulo casi invisible (contraste 2:1). */
  color: #f5e9d4; padding: 48px 36px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 6px;
}
.auth-logo {
  width: 88px; height: 88px; border-radius: 50%; object-fit: contain; background: #fff;
  display: block; margin: 0 auto 18px; box-shadow: 0 0 0 6px rgba(255,255,255,.08), 0 14px 34px rgba(0,0,0,.35);
}
.auth-brand h1 { font-family: var(--font-brand); font-size: 30px; font-weight: 600; letter-spacing: .2px; color: #faf3e7; }
.auth-brand .sub { font-size: 13.5px; color: rgba(245,233,212,.75); }
.auth-tagline { margin-top: 22px; font-size: 12px; letter-spacing: 2.2px; text-transform: uppercase; color: rgba(224,150,46,.85); font-weight: 600; }
.auth-form-side { padding: 40px 38px; }
.auth-form-side h2 { font-family: var(--font-display); font-size: 21px; font-weight: 600; margin-bottom: 2px; }
.auth-form-side .sub2 { font-size: 13px; color: var(--muted); margin-bottom: 22px; }
.auth-tabs { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; margin-bottom: 20px; }
.auth-tabs button { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 8px; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .18s ease; }
.auth-tabs button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.auth-msg { font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }
.auth-msg.err { background: var(--red-soft); color: var(--red); }
.auth-msg.ok { background: var(--green-soft); color: var(--green); }
.auth-hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 18px; line-height: 1.55; }

/* ===== Campos de formulario ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.field textarea { resize: vertical; min-height: 64px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ===== Botones ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-family: inherit; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; transition: all .16s ease; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn-primary { background: var(--accent); color: var(--bg); border-color: transparent; }
.btn-primary:hover { background: var(--accent-2); }
.btn-block { width: 100%; padding: 11px; }
.btn-wa { background: #25D366; color: #fff; border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: #ecc8bf; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn .svg-ic { width: 15px; height: 15px; }

/* ===== Layout app ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; padding: 22px 14px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh;
  background: var(--side);
  border-right: 1px solid var(--border);
  color: var(--side-text);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.brand img { width: 46px; height: 46px; border-radius: 50%; object-fit: contain; background: #fff; border: 1px solid var(--border); }
.brand strong { font-family: var(--font-brand); font-size: 16px; font-weight: 600; display: block; color: var(--side-strong); letter-spacing: .2px; }
.brand span { font-size: 11.5px; color: var(--side-text); }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: rgba(127,127,135,.35) transparent; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(127,127,135,.3); border-radius: 999px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border: none; background: transparent; border-radius: 8px; font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--side-text); cursor: pointer; text-align: left; width: 100%; transition: all .16s ease; }
.nav-item:hover { background: var(--side-2); color: var(--side-strong); }
.nav-item.active { background: var(--accent-soft); color: var(--side-strong); font-weight: 600; }
.nav-item .svg-ic { width: 18px; height: 18px; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; }
.nav-item.active .nav-badge { background: var(--red); }
.nav-sep { font-size: 11px; font-weight: 600; letter-spacing: .01em; color: var(--muted); padding: 16px 12px 6px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.user-av { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--bg); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-chip .un { font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--side-strong); }
.user-chip .ur { font-size: 11px; color: var(--side-text); }
.sidebar .btn { background: var(--surface); border-color: var(--border); color: var(--text); }
.sidebar .btn:hover { background: var(--surface-2); }

.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding: 22px 30px 16px; background: var(--bg); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--border); }
.topbar h1 { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.filters { display: flex; gap: 12px; }
.filters .field { margin: 0; }
.content { padding: 24px 30px 48px; }
.content { animation: fadeUp .18s ease both; }

/* ===== Banner de modo ===== */
.mode-banner { font-size: 12.5px; padding: 10px 16px; text-align: center; font-weight: 500; }
.mode-local { background: var(--amber-soft); color: var(--amber); border-bottom: 1px solid var(--border); }

/* ---------- «Ver como»: la franja del dueño mirando como otro departamento ----------
   Colores fijos (no variables): la franja debe verse idéntica e inconfundible
   en tema claro y oscuro — es la señal de que esta NO es la vista propia. */
.vc-banner { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px; background: #332817; color: #f5e9d4; font-size: 13px; font-weight: 500;
  border-bottom: 2px solid #d97706; }
.vc-banner .vc-eye { width: 15px; height: 15px; flex: none; }
.vc-banner select { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3);
  border-radius: 8px; padding: 4px 8px; font-size: 12.5px; font-weight: 600; max-width: 220px; cursor: pointer; }
.vc-banner select option { color: #1a1c1e; background: #fff; }
.vc-banner .vc-salir { background: #f5e9d4; color: #332817; border: none; border-radius: 8px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.vc-banner .vc-salir:hover { background: #fff; }
.vc-nota { opacity: .75; font-weight: 400; }
@media (max-width: 720px) { .vc-nota { display: none; } }

/* El recuadro para elegir departamento */
.vc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; padding: 4px 0 8px; }
.vc-op { text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text);
  font-family: var(--font-display); }
.vc-op:hover { border-color: var(--accent-2); background: var(--surface-2); }

/* ===== KPIs ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-ico { display: none; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Tarjetas por área física del Almacén (vista Inventario). Son botones:
   tocar una filtra la tabla a esa área; tocarla de nuevo vuelve a "todas". */
.area-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.area-card { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; font-family: inherit; color: var(--text); }
.area-card:hover { border-color: var(--accent-2); }
.area-card.area-sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.area-nombre { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area-card.area-sel .area-nombre { color: var(--text); }
.area-valor { font-size: 17px; font-weight: 700; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.area-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
@media (max-width: 760px) { .area-cards { grid-template-columns: repeat(2, 1fr); } }
.ico-red, .ico-amber, .ico-green, .ico-blue { background: var(--surface-2); color: var(--muted); }

/* ===== Paneles + tablas ===== */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 20px; overflow: hidden; transition: box-shadow .2s ease; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-family: var(--font-display); font-size: 14.5px; font-weight: 650; }
.panel-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
tbody td { padding: 10px 20px; border-bottom: 1px solid var(--row-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--row-hover); }
/* Una solicitud que el empleado reclamó («no me ha llegado») sube al tope de
   la tabla; la franja roja es para que se vea que esa fila está fuera de
   orden a propósito y no se confunda con las de arriba. */
tbody tr.fila-reclamo { background: var(--red-soft); box-shadow: inset 3px 0 0 var(--red); }
tbody tr.fila-reclamo:hover { background: var(--red-soft); filter: brightness(.985); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.act { text-align: right; white-space: nowrap; }
.cell-strong { font-weight: 600; }
.prod-cat { font-size: 11px; color: var(--muted); }
/* Se apilan cuando no caben: una fila con tres acciones (aprobar / despachar /
   rechazar) desbordaba la tabla y cortaba el último botón. */
.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.badge .dot { display: none; width: 6px; height: 6px; border-radius: 50%; }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-bajo { background: var(--amber-soft); color: var(--amber); }
.badge-critico { background: var(--red-soft); color: var(--red); } .badge-critico .dot { display: inline-block; background: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.tag { display: inline-block; font-size: 11px; font-weight: 500; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px; }

/* ===== Toolbar / búsqueda / segmentos ===== */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 13px; transition: border-color .15s ease, box-shadow .15s ease; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.search .svg-ic { width: 16px; height: 16px; color: var(--muted); }
.search input { border: none; outline: none; width: 100%; font-size: 13px; font-family: inherit; background: transparent; color: var(--text); }
.seg { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 7px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; font-family: inherit; transition: all .15s ease; }
.seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ===== Estado vacío / onboarding ===== */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 13px; }
.empty-big { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 44px 28px; text-align: center; }
.empty-big .ic { width: 54px; height: 54px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; }
.empty-big h3 { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.empty-big p { font-size: 13.5px; color: var(--muted); margin: 6px auto 18px; max-width: 440px; line-height: 1.5; }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow: auto; }
.modal.open { display: flex; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 16, 18, .45); }
.modal-card { position: relative; background: var(--surface); border-radius: 12px; box-shadow: 0 24px 70px rgba(10, 11, 12, .3); width: 100%; max-width: 520px; animation: popIn .26s cubic-bezier(.2,.8,.3,1) both; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.modal-x { border: none; background: transparent; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; transition: color .15s ease; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1a1c1e; color: #f4f4f6; padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: 0 12px 34px rgba(10, 11, 12, .35); opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 80; max-width: 90vw; border: 1px solid transparent; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }
/* ===== Móvil: hamburguesa, cajón, solo-lectura ===== */
.hamburger { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; flex-shrink: 0; color: var(--text); }
.hamburger .svg-ic { width: 20px; height: 20px; }
.nav-backdrop { display: none; }
.ro-badge { display: none; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 4px 9px; border-radius: 999px; }
/* tablas anchas → scroll horizontal en lugar de aplastarse */
.panel-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* solo-lectura: ocultar TODOS los controles de edición */
body.ro .js-write,
body.ro td.act > *,
body.ro .so-actions { display: none !important; }

@media (max-width: 760px) {
  .hamburger { display: inline-flex; }
  /* el badge de solo-lectura sigue a body.ro (los roles de campo escriben en móvil) */
  body.ro .ro-badge { display: inline-flex; }
  /* 100dvh: en iOS 100vh es más alto que lo visible y «Cerrar sesión» quedaba bajo la barra del navegador */
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; width: 274px; z-index: 70;
             transform: translateX(-100%); transition: transform .25s ease; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 16, 18, .45); z-index: 65; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; gap: 12px; align-items: center; }
  .topbar h1 { font-size: 20px; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .modal { padding: 16px; }
  .auth-card { grid-template-columns: 1fr; max-width: 440px; }
  .auth-brand { padding: 30px 24px 26px; }
  .auth-logo { width: 64px; height: 64px; margin-bottom: 10px; }
  .auth-brand h1 { font-size: 24px; }
  .auth-tagline { display: none; }
  .auth-form-side { padding: 26px 22px; }
}
@media (max-width: 420px) { .kpi-grid { grid-template-columns: 1fr; } }

/* En el teléfono, el botón del encabezado de un panel se pasa al renglón de
   abajo en vez de salirse: «Solicitar acceso de administrador» al lado de su
   título no cabe en 375px y quedaba cortado contra el borde. */
@media (max-width: 760px) { .panel-head { flex-wrap: wrap; } }

/* Tres cifras en vez de cuatro (el portal del empleado: pendientes / en compra
   / despachadas). Va en una clase y no en un style= dentro del HTML: el estilo
   suelto le ganaba a las medidas de abajo y en el teléfono la tercera tarjeta
   se salía de la pantalla. */
.kpi-3 { grid-template-columns: repeat(3,1fr); max-width: 900px; }
@media (max-width: 760px) { .kpi-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .kpi-3 { grid-template-columns: 1fr; } }
/* Solicitudes tiene cinco: con las cuatro columnas de siempre, la quinta
   caía sola en una segunda fila y dejaba un hueco enorme. */
.kpi-5 { grid-template-columns: repeat(5,1fr); }
@media (max-width: 1500px) { .kpi-5 { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 1100px) { .kpi-5 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 420px) { .kpi-5 { grid-template-columns: 1fr; } }

/* ===== Fase 3: compras por proveedor ===== */
.supplier-order { border: 1px solid var(--border); border-radius: 12px; margin: 0 20px 12px; overflow: hidden; }
.supplier-order:first-child { margin-top: 16px; }
.so-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; background: var(--surface-2); }
.so-head .left { display: flex; align-items: center; gap: 11px; }
.so-avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.so-name { font-weight: 600; font-size: 14px; }
.so-meta { font-size: 12px; color: var(--muted); }
.so-total { font-weight: 700; font-size: 15px; }
.so-items { width: 100%; }
.so-items td { padding: 9px 16px; font-size: 12.5px; }
.so-actions { display: flex; gap: 9px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ===== Fase 3: gráficos ===== */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.bars { display: flex; flex-direction: column; gap: 13px; padding: 18px 20px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 12px; }
.bar-label { font-size: 12.5px; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transform-origin: left; animation: growX .5s ease both; }
.bar-value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }

/* Ranking «quién está usando el sistema» (encabezado de Logs) */
.uso-h { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 10px; }
.uso-row { display: grid; grid-template-columns: 24px 150px 1fr; gap: 12px; align-items: center; padding: 9px 0; }
.uso-row + .uso-row { border-top: 1px solid var(--border); }
.uso-pos { width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.uso-quien { min-width: 0; }
.uso-nombre { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .uso-row { grid-template-columns: 24px 104px 1fr; gap: 8px; } }
.vbars { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 22px 20px 14px; height: 230px; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.vbar-track { width: 100%; max-width: 42px; flex: 1; display: flex; align-items: flex-end; }
.vbar-fill { width: 100%; background: var(--accent); border-radius: 4px 4px 2px 2px; min-height: 3px; transform-origin: bottom; animation: growY .5s ease both; }
.vbar-val { font-size: 11px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.vbar-label { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.donut-wrap { display: flex; align-items: center; gap: 24px; padding: 18px 20px; flex-wrap: wrap; }
.donut-center { font-size: 26px; font-weight: 700; fill: var(--text); font-family: 'Inter', sans-serif; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.lg-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text); min-width: 170px; }
.lg-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ===== Fase 3: registro / respaldo ===== */
.backup-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px 28px; padding: 18px 20px; }
.kv { display: flex; flex-direction: column; gap: 3px; }
.kv .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.kv .v { font-size: 14px; font-weight: 600; }
.kv .v.small { font-size: 13px; font-weight: 500; }
.backup-actions { display: flex; gap: 10px; padding: 0 20px 18px; flex-wrap: wrap; }
.backup-note { font-size: 12px; color: var(--muted); padding: 0 20px 16px; line-height: 1.5; }

/* ===== Fase 3: factura ===== */
.factura { padding: 28px 30px 22px; }
.fac-demo { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 6px 12px; border-radius: 8px; display: inline-block; margin-bottom: 16px; }
.fac-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.fac-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: 0; }
.fac-num { font-size: 13px; color: var(--muted); margin-top: 2px; }
.fac-logo { font-size: 15px; font-weight: 700; }
.fac-parties { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.fac-k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; margin-bottom: 4px; }
.fac-strong { font-size: 13.5px; font-weight: 600; }
.fac-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.fac-totals { margin-top: 14px; margin-left: auto; width: 260px; }
.ft-row { display: flex; justify-content: space-between; padding: 7px 8px; font-size: 13.5px; }
.ft-grand { border-top: 2px solid var(--text); margin-top: 4px; padding-top: 11px; font-size: 16px; font-weight: 700; }
.fac-foot { font-size: 11.5px; color: var(--muted); margin-top: 20px; text-align: center; }

@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } .backup-grid { grid-template-columns: 1fr 1fr; } }
/* Solo se imprime el documento abierto en la ventana (nota de venta, orden de
   compra, recibo, comprobante de retención — todos salen por window.print()
   sobre el modal). El resto se OCULTA, no se vuelve invisible: invisible
   seguía ocupando su espacio y dejaba páginas en blanco. Y la ventana deja de
   ser fija y con scroll: con la altura de una página recortaba lo que sobraba. */
@media print {
  #app, #auth, #splash, #toast { display: none !important; }
  #modal { display: block; position: static; overflow: visible; height: auto; padding: 0; }
  .modal-backdrop, .modal-x, .modal-foot, .fac-demo { display: none !important; }
  .modal-card { position: static; box-shadow: none; max-width: none; width: auto; animation: none; }
}

/* ===== Fase 4: usuarios ===== */
.usel { font-family: inherit; font-size: 12.5px; color: var(--text); padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }

/* ===== Acciones rápidas (Tablero) ===== */
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 20px; }
.qa-btn { display: flex; align-items: center; gap: 14px; text-align: left; padding: 15px 17px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; font-family: inherit; transition: background .15s ease; }
.qa-btn:hover { background: var(--surface-2); }
.qa-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.qa-ico .svg-ic { width: 21px; height: 21px; }
.qa-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.qa-txt b { font-size: 14.5px; color: var(--text); }
.qa-txt small { font-size: 12px; color: var(--muted); }
@media (max-width: 760px) { .qa-grid { grid-template-columns: 1fr; } }

/* ===== Líneas de salida (modal Salidas) ===== */
.sal-sede, .sal-cant { font-family: inherit; font-size: 13.5px; color: var(--text); padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease; }
.sal-sede:focus, .sal-cant:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ===== Tasa BCV: fecha de auto-actualización ===== */
.bcv-fecha { opacity: .65; font-size: .85em; }

/* ===== Accesibilidad: respetar reducción de movimiento ===== */
/* ---------- MI DÍA (lista de trabajo por rol) ---------- */
.md-hero { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.md-saludo { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: .2px; }
.md-fecha { font-size: 13px; color: var(--muted); margin-top: 3px; }
.md-prog { margin-top: 16px; }
.md-prog-bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.md-prog-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.md-prog-txt { font-size: 12.5px; color: var(--muted); margin-top: 7px; display: flex; justify-content: space-between; gap: 10px; }
.md-sec { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 9px; }
.md-task { display: flex; align-items: flex-start; gap: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; margin-bottom: 8px; box-shadow: var(--shadow-sm); }
.md-task.alta { border-left: 4px solid var(--red); }
.md-task .md-ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.md-task.alta .md-ic { background: var(--red-soft); color: var(--red); }
.md-task .md-body { flex: 1; min-width: 0; }
.md-task .md-tit { font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.md-task .md-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.md-task .md-act { flex: none; align-self: center; }
.md-task.hecha { background: transparent; box-shadow: none; border-style: dashed; }
.md-task.hecha .md-ic { background: var(--green-soft); color: var(--green); }
.md-task.hecha .md-tit { color: var(--muted); font-weight: 500; }
.md-nota { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; margin-bottom: 8px; }
.md-nota .svg-ic { width: 15px; height: 15px; flex: none; }
.md-listo { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 34px 24px; text-align: center; }
.md-listo .ic { width: 50px; height: 50px; border-radius: 15px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin: 0 auto 12px; }
.md-listo h3 { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.md-listo p { font-size: 13.5px; color: var(--muted); margin-top: 5px; }
@media (max-width: 560px) {
  .md-task { padding: 13px 14px; gap: 11px; }
  .md-task .md-act { align-self: stretch; }
  .md-task .md-act .btn { width: 100%; }
  .md-task { flex-wrap: wrap; }
  .md-task .md-body { flex-basis: calc(100% - 47px); }
  .md-saludo { font-size: 21px; }
}

/* ---------- MERCADERISTA: reporte con fotos, GPS y códigos ---------- */
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.rp-cod { display: flex; flex-direction: column; gap: 3px; }
.rp-cod label { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; letter-spacing: .03em; }
.rp-cod input { width: 100%; text-align: center; font-family: inherit; font-size: 15px; font-weight: 600; padding: 9px 4px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.rp-cod input:focus { outline: none; border-color: var(--accent); }
.rp-cod input:disabled { background: var(--surface-2); color: var(--muted); }
.rp-check { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; margin-top: 8px; }
.rp-check input { width: auto; }
.rp-acciones { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.rp-acciones .rp-check { margin-top: 0; }
.rp-gps { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; }
.rp-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rp-th { position: relative; width: 68px; height: 68px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); flex: none; display: block; }
.rp-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rp-th-x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: none;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }
.rp-th-err { display: grid; place-items: center; background: var(--red-soft); color: var(--red); font-weight: 700; }
/* Estado de cada foto: sube apenas se toma, y la miniatura lo dice sin leer nada */
.rp-th-est { position: absolute; left: 3px; bottom: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700; line-height: 1; background: rgba(0, 0, 0, .65); color: #fff; }
.rp-th-est.ok { background: var(--green); }
.rp-th-est.pend { background: var(--amber); }
/* Aviso de reporte recuperado: lo primero que ve al reabrir el formulario */
.rp-recup { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin-bottom: 15px;
  background: var(--green-soft); border: 1px solid var(--green); border-radius: 12px; padding: 11px 13px;
  font-size: 13px; line-height: 1.45; }
.rp-recup .svg-ic { color: var(--green); flex: none; margin-top: 1px; }
.rp-recup > div { flex: 1; min-width: 180px; }
.rp-prog { margin-top: 14px; }
.rp-prog-bar { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.rp-prog-bar i { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }
.rp-prog-txt { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.rp-galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 14px; }
.rp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .16s ease, box-shadow .16s ease; }
.rp-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.rp-card-img { position: relative; aspect-ratio: 4/3; background: var(--surface-2); display: grid; place-items: center; }
.rp-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rp-noimg { color: var(--muted); opacity: .5; }
.rp-badge { position: absolute; bottom: 7px; right: 7px; background: rgba(0, 0, 0, .68); color: #fff;
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.rp-card-body { padding: 12px 14px 14px; }
.rp-card-tit { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.rp-card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rp-card-inv { font-size: 12.5px; color: var(--text); margin-top: 7px; font-variant-numeric: tabular-nums; }
.rp-card-pies { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
@media (max-width: 560px) {
  .rp-galeria { grid-template-columns: 1fr 1fr; gap: 10px; }
  .rp-card-body { padding: 10px 11px 12px; }
  .rp-card-tit { font-size: 13px; }
  .rp-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
}

/* ---------- Mi cartera: chips de cliente en el pedido ---------- */
.cart-lbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 10px 0 6px; }
.cart-chips { display: flex; flex-wrap: wrap; gap: 7px; max-height: 132px; overflow-y: auto; padding-bottom: 2px; }
.cart-chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 99px; padding: 7px 13px 7px 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, background .15s; max-width: 100%; }
.cart-chip:hover { border-color: var(--accent); }
.cart-chip.on { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.cart-chip.on .cart-cod { background: rgba(127,127,135,.28); color: var(--bg); }
.cart-cod { background: var(--bg); border-radius: 99px; padding: 2px 8px; font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--muted); flex: none; }
@media (max-width: 560px) { .cart-chips { max-height: 180px; } .cart-chip { padding: 9px 14px 9px 9px; } }

/* Cliente nuevo desde el pedido: el formulario corto vive DENTRO del recuadro
   del pedido, enmarcado para que se lea como un paso aparte del pedido. */
.nc-box { margin-top: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px 2px; background: var(--surface-2); }
.nc-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.nc-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin: 2px 0 12px; }
@media (max-width: 560px) { .nc-foot .btn { flex: 1 1 auto; } }   /* en el teléfono: botones anchos, para el pulgar */
.nc-aviso { border: 1px solid var(--amber); background: var(--amber-soft); border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; font-size: 13px; line-height: 1.5; }
.nc-aviso .ps-res { margin: 8px 0; }
.tag-nuevo { color: var(--green); background: var(--green-soft); border-color: transparent; font-weight: 700; vertical-align: 1px; }
/* Cliente provisional: lo trajo un vendedor y televentas aún no le da de alta. */
.tag-prov { color: var(--amber); background: var(--amber-soft); border-color: transparent; font-weight: 700; vertical-align: 1px; }
/* v84: la lista de clientes viene de Profit. «Sin Profit» = Profit no lo conoce. */
.tag-profit { color: var(--blue); background: var(--blue-soft); border-color: transparent; font-weight: 600; }
.tag-sinprofit { color: var(--red); background: var(--red-soft); border-color: transparent; font-weight: 700; vertical-align: 1px; }
.alta-info { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; font-size: 13px; line-height: 1.5; }
.nc-aviso.alta-bloqueo { border-color: var(--red); background: var(--red-soft); }

/* ---------- Ficha analítica del cliente ---------- */
.fc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.fc-kpi { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.fc-kpi .l { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fc-kpi .v { font-size: 21px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.fc-kpi .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.fc-kpi.rojo { border-color: var(--red); background: var(--red-soft); }
.fc-kpi.rojo .v { color: var(--red); }
.fc-kpi.ambar .v { color: var(--amber); }
.fc-kpi.verde .v { color: var(--green); }
.fc-tend { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; }
.fc-sec { font-family: var(--font-display, Georgia, serif); font-size: 16px; margin: 18px 0 8px; }
.fc-mini td, .fc-mini th { padding: 7px 10px; font-size: 12.5px; }

.lt-wrap { display: flex; flex-direction: column; gap: 2px; }
.lt-fila { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.lt-fila:last-child { border-bottom: none; }
.lt-fecha { flex: none; width: 92px; font-size: 13px; font-weight: 600; line-height: 1.3; }
.lt-fecha span { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.lt-cuerpo { flex: 1; min-width: 0; }
.lt-datos { font-size: 13px; display: flex; flex-wrap: wrap; gap: 7px; align-items: center; font-variant-numeric: tabular-nums; }
.lt-fotos { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 10px; }
.lt-lbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
@media (max-width: 560px) {
  .lt-fila { flex-direction: column; gap: 8px; }
  .lt-fecha { width: auto; display: flex; gap: 8px; align-items: baseline; }
  .lt-fecha span { margin-top: 0; }
  .lt-fotos { gap: 12px; }
}

/* ---------- PREGÚNTALE A TATA ---------- */
.tt-wrap { max-width: 760px; }
.tt-head { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.tt-head h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.tt-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tt-ava { width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.tt-head .tag { margin-left: auto; }
.tt-hilo { min-height: 220px; max-height: 52vh; overflow-y: auto; padding: 4px 2px 8px; display: flex; flex-direction: column; gap: 10px; }
.tt-msg { max-width: 82%; padding: 11px 15px; border-radius: 15px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.tt-yo { align-self: flex-end; background: var(--accent); color: var(--bg); border-bottom-right-radius: 5px; }
.tt-tata { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; box-shadow: var(--shadow-sm); }
.tt-err { border-color: transparent; color: var(--red); background: var(--red-soft); }
.tt-pensando { display: flex; gap: 5px; align-items: center; padding: 15px; }
.tt-pensando span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .4; animation: ttBlink 1.2s infinite; }
.tt-pensando span:nth-child(2) { animation-delay: .2s; } .tt-pensando span:nth-child(3) { animation-delay: .4s; }
@keyframes ttBlink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: .9; transform: translateY(-3px); } }
.tt-vacio { text-align: center; padding: 22px 10px; }
.tt-vacio p { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.tt-sug { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tt-chip { font-family: inherit; font-size: 13px; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 7px 14px; cursor: pointer; transition: all .15s ease; }
.tt-chip:hover { border-color: var(--accent); color: var(--accent); }
.tt-barra { display: flex; gap: 9px; margin-top: 12px; }
.tt-barra input { flex: 1; font-family: inherit; font-size: 14.5px; padding: 12px 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.tt-barra input:focus { outline: none; border-color: var(--accent); }
.tt-barra .btn { white-space: nowrap; }
.tt-nota { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
@media (max-width: 560px) {
  .tt-msg { max-width: 92%; }
  .tt-barra { flex-wrap: wrap; }
  .tt-barra input { flex-basis: 100%; }
  .tt-barra .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Recorrido en calle (mapa de mercaderistas) ===== */
.rec-map { height: 460px; width: 100%; background: var(--surface-2); display: grid; place-items: center; }
.rec-map .leaflet-container { font-family: inherit; }
.rec-pin-wrap { background: none; border: none; }
.rec-pin { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff;
  font-size: 12px; font-weight: 700; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.rec-ruta { margin-bottom: 18px; }
.rec-ruta:last-child { margin-bottom: 0; }
.rec-ruta-head { display: flex; align-items: center; gap: 9px; padding: 0 2px 8px; font-size: 14px; }
.rec-ruta-head .prod-cat { margin-left: auto; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.rec-stop { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font-family: inherit;
  padding: 10px 12px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); cursor: pointer; transition: all .15s ease; }
.rec-stop:hover { background: var(--surface-2); }
.rec-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  color: #fff; font-size: 12px; font-weight: 700; }
.rec-stop-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.rec-stop-txt b { font-size: 13.5px; color: var(--text); }
.rec-stop-txt small { font-size: 11.5px; color: var(--muted); }
.rec-stop-go { font-size: 12px; color: var(--muted); flex-shrink: 0; }
@media (max-width: 760px) { .rec-map { height: 340px; } }

/* =====================================================================
   VISTA DE SOCIO (los dueños)
   ===================================================================== */

/* Modo consulta: se van los botones que escriben, se quedan los que deciden.
   Nota: el selector ataca td.act > *:not(.js-socio) igual que body.ro, pero
   deja pasar el bloque marcado .js-socio (aprobar/rechazar solicitudes). */
body.vista-socio .js-write,
body.vista-socio td.act > *:not(.js-socio),
body.vista-socio .so-actions { display: none !important; }
/* Una celda de acciones que se quedó sin botones no debe dejar hueco. */
body.vista-socio td.act:empty { padding-left: 0; padding-right: 0; }

/* ---------- Pestañas dentro de un grupo del menú ---------- */
.subtabs { display: flex; gap: 4px; margin-bottom: 18px; padding: 4px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); }
.subtab { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--muted); background: transparent;
  padding: 9px 15px; border-radius: 10px; transition: all .15s ease; white-space: nowrap; }
.subtab .svg-ic { width: 15px; height: 15px; }
.subtab:hover { color: var(--text); background: var(--surface-2); }
.subtab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- Portada: los dos números que siempre preguntan ---------- */
.panel-hero { margin-bottom: 26px; }
.hero-titulo h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.hero-titulo .sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 14px; }
.saldo-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.saldo-card { display: flex; flex-direction: column; gap: 8px; text-align: left; font-family: inherit;
  padding: 20px 22px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease; }
button.saldo-card { cursor: pointer; }
button.saldo-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.saldo-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; }
.saldo-top .svg-ic { width: 17px; height: 17px; }
.saldo-val { font-size: 34px; font-weight: 700; letter-spacing: -1px; font-variant-numeric: tabular-nums; color: var(--text); }
.saldo-pie { font-size: 12px; color: var(--muted); }
.saldo-alerta { font-size: 12px; font-weight: 600; color: var(--red); }
/* El degradado tiñe la tarjeta con los mismos tokens del tema, así el claro
   y el oscuro salen bien sin escribir dos paletas. */
.saldo-verde { background: var(--green-soft); }
.saldo-verde .saldo-top { color: var(--green); }
.saldo-rojo { background: var(--red-soft); }
.saldo-rojo .saldo-top { color: var(--red); }
.saldo-neutro-ok .saldo-top { color: var(--blue); }
.saldo-neutro-mal .saldo-top { color: var(--amber); }
.saldo-neutro-mal .saldo-val { color: var(--red); }

/* ---------- Variación contra el periodo anterior ---------- */
.delta { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.delta.bien { color: var(--green); background: var(--green-soft); }
.delta.mal { color: var(--red); background: var(--red-soft); }
.delta.neutro { color: var(--muted); background: var(--surface-2); font-weight: 500; }
.nota-periodo { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: -12px 0 24px; max-width: 720px; }

/* ---------- Lo que necesita un ojo ---------- */
.alerta-lista { display: flex; flex-direction: column; }
.alerta { display: flex; align-items: center; gap: 13px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.alerta:last-child { border-bottom: none; }
.alerta-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0; }
.alerta-ic .svg-ic { width: 17px; height: 17px; }
.alerta-mal .alerta-ic { background: var(--red-soft); color: var(--red); }
.alerta-ojo .alerta-ic { background: var(--amber-soft); color: var(--amber); }
.alerta-ok .alerta-ic { background: var(--green-soft); color: var(--green); }
.alerta-txt { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.alerta-txt b { font-size: 13.5px; }
.alerta-txt small { font-size: 12px; color: var(--muted); }
.alerta .btn { flex-shrink: 0; }

@media (max-width: 1100px) { .saldo-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .saldo-val { font-size: 28px; }
  .alerta { flex-wrap: wrap; }
  .alerta .btn { margin-left: 47px; }
}

/* =====================================================================
   TELÉFONO — revisión de agosto 2026
   El sistema se usa DESDE LA CALLE: vendedores, choferes, mercaderistas,
   despacho, producción y almacén no tienen escritorio. Todo lo de aquí
   abajo solo aplica a pantallas de teléfono; el escritorio no cambia.
   ===================================================================== */

/* ---------- 1. Que iOS no haga zoom al tocar un campo ----------
   Safari en iPhone ACERCA la pantalla cuando el campo tiene menos de 16px,
   y ya no la devuelve: el usuario queda con la página corrida y medio
   formulario fuera de vista. 16px es el mínimo que no dispara el zoom. */
@media (max-width: 760px) {
  .field input, .field select, .field textarea,
  .search input, .tt-barra input, .rp-cod input,
  input[type="text"], input[type="number"], input[type="date"],
  input[type="email"], input[type="password"], input[type="search"],
  select, textarea { font-size: 16px; }
  .rp-cod input { padding: 11px 4px; }
}

/* ---------- 2. La barra de arriba en dos renglones ----------
   Título y filtro peleaban por el mismo renglón: el sello de «solo lectura»
   se partía en dos líneas y la barra se comía 145px de una pantalla de 812. */
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 9px; padding: 12px 16px 11px; }
  .topbar > div:last-child { width: 100%; flex-wrap: wrap; }
  /* El filtro se lleva su propio renglón completo: compartiéndolo con el
     sello de «solo lectura» le quedaban 200px y el nombre de la sede salía
     cortado («Total (Almacé…»). */
  .topbar .filters { flex: 1 0 100%; min-width: 0; flex-wrap: wrap; }
  /* El nombre del filtro va AL LADO, no encima: encima costaba un renglón
     entero y entre el título, el subtítulo y el filtro la barra se comía un
     tercio de la pantalla antes de empezar a trabajar. */
  .topbar .filters .field { flex: 1; min-width: 132px; margin: 0; flex-direction: row; align-items: center; gap: 8px; }
  .topbar .filters .field label { flex: none; }
  .ro-badge { white-space: nowrap; flex: none; }
  .topbar .sub { line-height: 1.35; }
}

/* ---------- 3. Los indicadores, de dos en dos ----------
   Con una sola columna había que pasar cuatro pantallazos de tarjetas
   gigantes antes de llegar al trabajo del día. */
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
  .kpi { padding: 13px 14px; }
  .kpi-top { margin-bottom: 8px; }
  .kpi-label { font-size: 11.5px; line-height: 1.25; }
  .kpi-ico { width: 28px; height: 28px; border-radius: 9px; }
  .kpi-ico .svg-ic { width: 15px; height: 15px; }
  .kpi-value { font-size: 21px; letter-spacing: -.4px; }
  .kpi-sub { font-size: 11px; line-height: 1.3; }
}

/* ---------- 4. Las tablas se leen como fichas ----------
   Una tabla de siete columnas en un teléfono deja fuera de pantalla
   justamente lo que importa: el total, el estado y los botones. Despacho
   no podía marcar «entregado» sin arrastrar la tabla de lado.
   Cada fila pasa a ser una ficha: el primer dato es el título y los demás
   van con el nombre de su columna al lado (lo pone etiquetarTablas). */
@media (max-width: 760px) {
  table.tbl-fichas { min-width: 0; display: block; font-size: 13.5px; }
  table.tbl-fichas thead { display: none; }
  table.tbl-fichas tbody { display: block; }
  table.tbl-fichas tr { display: block; padding: 12px 16px 13px; border-bottom: 1px solid var(--border); }
  table.tbl-fichas tr:last-child { border-bottom: none; }
  table.tbl-fichas tr:hover { background: none; }
  table.tbl-fichas td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
    padding: 3px 0; border: none; text-align: right;
  }
  table.tbl-fichas td::before {
    content: attr(data-l); flex: none; text-align: left;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  }
  table.tbl-fichas td:not([data-l])::before { content: none; }
  /* El primer dato es el nombre de la ficha: solo, a la izquierda y grande. */
  table.tbl-fichas td.ficha-tit { display: block; text-align: left; font-size: 14.5px; padding-bottom: 5px; }
  table.tbl-fichas td.ficha-tit .prod-cat { font-size: 11.5px; }
  /* Los botones de la fila, abajo y a lo ancho: son el dedo, no el ratón. */
  table.tbl-fichas td.act { display: block; text-align: left; padding: 9px 0 0; white-space: normal; }
  table.tbl-fichas td.act .row-actions { justify-content: flex-start; gap: 8px; }
  table.tbl-fichas td.act .btn { padding: 9px 14px; }
  /* Sin permiso de escritura la columna de acciones queda vacía: que no ocupe. */
  body.ro table.tbl-fichas td.act { display: none; }
  /* Al director solo le queda «aprobar» (.js-socio); si no lo tiene, sobra.
     Va en regla aparte: si un navegador viejo no entiende :has() descarta
     ESTA sola, no la de arriba. */
  body.vista-socio table.tbl-fichas td.act:not(:has(.js-socio)) { display: none; }
  /* «No hay nada todavía» ocupa la ficha completa. */
  table.tbl-fichas td[colspan] { display: block; text-align: center; }
  table.tbl-fichas td[colspan]::before { content: none; }

  /* Las dos que NO se vuelven fichas (no tienen encabezado: el pedido por
     proveedor y el estado de resultados) son de concepto + monto y ya caben.
     El min-width de 540px las cortaba: .supplier-order recorta lo que sobra
     en vez de dejar arrastrar, así que el costo quedaba fuera de la vista. */
  table:not(.tbl-fichas) { min-width: 0; }
}

/* ---------- 5. Botones que se puedan tocar con el dedo ----------
   Un botón de 29px de alto se falla con el pulgar, y más en la calle o con
   las manos ocupadas. 40px es el piso cómodo (Apple recomienda 44). */
@media (max-width: 760px) {
  .btn { min-height: 42px; padding: 10px 15px; }
  .btn-sm { min-height: 40px; padding: 9px 13px; font-size: 12.5px; }
  .seg button { min-height: 38px; padding: 9px 14px; }
  .tt-chip { min-height: 38px; padding: 9px 14px; }
  .modal-x { width: 40px; height: 40px; margin: -8px -10px -8px 0; font-size: 24px; }
  .rp-th-x { width: 26px; height: 26px; font-size: 16px; }
  /* La casilla de un «sí/no» también es un objetivo del dedo. */
  .rp-check input[type="checkbox"], .field input[type="checkbox"] { width: 20px; height: 20px; }
  .rp-check { min-height: 34px; }
}

/* ---------- 6. Elegir fotos, en español y con cara de botón ----------
   El control que trae el navegador dice «Choose Files / No file chosen»
   —en inglés— en la pantalla que más usa la mercaderista. */
.file-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 11px 14px;
  border: 1px dashed var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.file-btn:hover { border-color: var(--accent); color: var(--accent); }
.file-btn .svg-ic { width: 17px; height: 17px; }
.file-btn input[type="file"] { display: none; }

/* ---------- 7. La nota de venta, legible en la mano ----------
   Emisor, cliente y fecha en tres columnas dentro de 330px dejaban el nombre
   fiscal partido en cinco renglones. Solo en pantalla: al imprimir manda el
   ancho del papel, que nunca entra en esta media query. */
@media (max-width: 760px) {
  .fac-parties { grid-template-columns: 1fr 1fr; }
  .fac-totals { width: 100%; }
  .fac-head { gap: 12px; }
  .fac-title { font-size: 20px; }
}

/* ---------- 8. Enviar, al final del formulario ----------
   Un formulario que vive dentro de un panel (no de una ventana) no tiene
   pie: su botón se alinea a la derecha en pantalla grande y se estira a lo
   ancho en el teléfono, donde el pulgar agradece el blanco. */
.form-enviar { display: flex; justify-content: flex-end; margin-top: 2px; }
@media (max-width: 760px) { .form-enviar .btn { width: 100%; } }

/* ---------- 9. Portal: buscar productos y armar el pedido ----------
   El empleado pide desde el teléfono, de pie y con prisa. Todo aquí está
   dimensionado para el pulgar: filas altas, botón de quitar grande y la
   cantidad de primera para que se corrija sin buscarla. */
.ps-search { width: 100%; }
.ps-res:not(:empty) { margin-top: 8px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.ps-op { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 11px 13px; border: none; border-bottom: 1px solid var(--border); background: transparent;
  color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; transition: background .12s ease; }
.ps-op:last-child { border-bottom: none; }
.ps-op:hover:not([disabled]) { background: var(--accent-soft); }
.ps-op[disabled] { cursor: default; opacity: .55; }
.ps-op-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-weight: 600; line-height: 1.3; }
.ps-op-txt .prod-cat { font-weight: 500; }
.ps-op-mas { flex: none; font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.ps-op[disabled] .ps-op-mas { color: var(--muted); }
/* El texto libre cierra la lista: es la salida cuando nada del catálogo sirve. */
.ps-op-libre { background: var(--surface-2); }

.ps-lista { display: flex; flex-direction: column; gap: 8px; }
.ps-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
/* Los inputs de aquí no viven dentro de un .field, así que se les da el mismo
   fondo y borde a mano: con los del navegador quedaban blancos en tema oscuro. */
.ps-item-cant, .ps-item-uni { font-family: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; transition: border-color .15s ease, box-shadow .15s ease; }
.ps-item-cant:focus, .ps-item-uni:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.ps-item-cant { flex: none; width: 62px; padding: 9px 6px; font-size: 14px; text-align: center; font-variant-numeric: tabular-nums; }
.ps-item-txt { flex: 1; min-width: 0; }
.ps-item-uni { margin-top: 5px; width: 100%; max-width: 190px; font-size: 12.5px; padding: 6px 9px; }

/* ---------- Portal: pedidos por confirmar ----------
   Agrupados por pedido y no en una tabla: en el teléfono lo que importa es
   qué llegó y qué no, y eso se lee mejor en fichas que en columnas. */
.ps-grupo { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.ps-grupo:last-child { margin-bottom: 0; }
.ps-grupo-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 14px; }
.ps-linea { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--border); }
.ps-linea:last-child { border-bottom: none; }
.ps-linea-txt { flex: 1; min-width: 170px; }
@media (max-width: 560px) {
  .ps-linea .row-actions, .ps-grupo-head .btn { width: 100%; }
  .ps-linea .row-actions .btn { flex: 1; }
}

/* ---------- Trazabilidad de producción ----------
   Las cartas de control se dibujan en SVG con las variables del tema, así
   el modo oscuro funciona solo y no hace falta una librería de gráficas. */
.trz-h3 { font-family: var(--font-display); font-size: 14px; font-weight: 600; margin: 20px 0 8px; display: flex; align-items: center; gap: 8px; }
.trz-h3:first-of-type { margin-top: 4px; }
.trz-bloque { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; background: var(--surface-2); }
.trz-bloque .trz-h3 { margin-top: 0; }
.trz-etapa { display: flex; gap: 9px; align-items: flex-start; padding: 4px 0; }
.trz-etapa-n { flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; display: grid; place-items: center; }

.spc-card { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.spc-card:last-child { border-bottom: none; }
.spc-card h3 { font-family: var(--font-display); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.spc-card h3 .prod-cat { font-weight: 400; margin-left: 6px; }
.spc-stats { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.spc-stats div { flex: 1; min-width: 90px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 10px; }
.spc-stats span { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.spc-stats b { font-size: 15px; font-family: var(--font-display); }
.spc-svg { width: 100%; height: auto; display: block; }
.spc-svg .spc-ax { fill: var(--muted); font-size: 10px; }
.spc-leyenda { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.spc-leyenda li { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.spc-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.spc-dot.ok { background: var(--green); }
.spc-dot.mal { background: var(--red); }

/* Las 4 etapas del proceso: en escritorio caben en fila; en el teléfono se
   apilaban una al lado de otra dentro de la celda y quedaban ilegibles. */
.trz-etapas { display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 760px) {
  .panel-head .usel { width: 100%; margin-top: 8px; }
  .spc-stats div { min-width: 72px; }
  .trz-etapa { padding: 6px 0; }
}

/* ===== MI SEDE — la pantalla del encargado ===== */
/* El aviso de "todavía no hay cobertura": va suelto entre la barra de
   botones y la tabla, así que no puede usar .backup-note (que está pensada
   para ir DENTRO de un panel y trae su propio padding). */
.misede-tip { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 14px; margin-bottom: 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* Conteo desde el teléfono: una ficha por producto, con el número grande.
   La tabla del conteo del admin no sirve caminando por el depósito — hay
   que apuntar a una celda de 90px con el pulgar. */
.cnt-lista { display: flex; flex-direction: column; gap: 8px; }
.cnt-item { display: flex; align-items: center; gap: 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: text; }
.cnt-txt { flex: 1; min-width: 0; }
.cnt-in { flex: none; width: 104px; text-align: right; font-size: 17px; font-weight: 600;
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface); color: var(--text); }
.cnt-in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
@media (max-width: 760px) {
  .cnt-in { width: 92px; font-size: 16px; }  /* 16px: menos de eso, iOS hace zoom al enfocar */
}

/* ===== MI SEDE · Caja y Gastos ===== */
/* El arqueo va en fichas, no en tabla: son dos números por método y en el
   teléfono una tabla de 5 columnas obliga a hacer scroll horizontal justo
   cuando el encargado está contando dinero. */
.cj-lista { display: flex; flex-direction: column; gap: 10px; }
.cj-met { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; }
.cj-met-nom { flex: 1; min-width: 128px; font-weight: 600; font-size: 13.5px; }
.cj-met-campos { display: flex; gap: 8px; }
.cj-campo { display: flex; flex-direction: column; gap: 3px; }
.cj-campo span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.cj-campo input { width: 116px; text-align: right; font-size: 16px; font-weight: 600; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.cj-campo input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.cj-campo input:disabled { opacity: .6; }
.cj-met-dif { flex: none; min-width: 84px; text-align: right; font-weight: 700; font-size: 14px; color: var(--muted); }
.cj-met-dif.ok { color: var(--green); }
.cj-met-dif.mal { color: var(--red); }
.cj-total { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--border); }
.cj-total div { flex: 1; min-width: 116px; }
.cj-total b { display: block; font-size: 19px; font-family: var(--font-display); margin-top: 2px; }
/* La foto del recibo, ya comprimida y todavía sin subir. */
.gs-foto { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.gs-foto img { width: 82px; height: 82px; object-fit: cover; border-radius: 11px; border: 1px solid var(--border); }
@media (max-width: 760px) {
  .cj-met-campos { width: 100%; }
  .cj-campo { flex: 1; }
  .cj-campo input { width: 100%; }
  .cj-met-dif { width: 100%; text-align: left; }
}

/* ===== Rediseno sobrio: banda de cifras del Tablero ===== */
.stat-band { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
.stat { padding: 15px 20px 14px; border-left: 1px solid var(--row-border); min-width: 0; }
.stat:first-child { border-left: none; }
.stat .l { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v { font-size: 23px; font-weight: 700; letter-spacing: -.4px; font-variant-numeric: tabular-nums; margin-top: 3px; line-height: 1.2; }
.stat .v.mal { color: var(--red); }
.stat .v.bien { color: var(--green); }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) {
  .stat-band { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(odd) { border-left: none; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--row-border); }
}

/* =====================================================================
   COMPRAS E INVENTARIO DE PUNTA A PUNTA (órdenes, recepción, sub-almacenes,
   avisos). Requiere migration_ordenes_compra.sql.
   ===================================================================== */

/* ---- Buscador de proveedor: escribir las primeras letras ---- */
.pp { position: relative; }
.pp-in { padding: 8px 10px; }
.pp-in input { font-size: 13.5px; }
.pp-x { border: none; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.pp-x:hover { color: var(--text); }
/* La lista flota sobre el formulario (si empujara los campos de abajo, el
   botón de guardar saltaría con cada letra). */
.pp-res:not(:empty) { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; margin-top: 4px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; }
.pp-res .ps-op { font-size: 13.5px; padding: 9px 12px; }

/* ---- Campana de avisos (barra superior) ---- */
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; color: var(--muted); transition: color .15s, border-color .15s; }
.bell:hover { color: var(--text); border-color: var(--accent-2); }
.bell.tiene { color: var(--text); }
.bell-n { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; line-height: 1; }

/* ---- Bandeja de avisos ---- */
.nt-lista { display: flex; flex-direction: column; }
.nt { display: flex; align-items: flex-start; gap: 13px; padding: 13px 20px; border-bottom: 1px solid var(--border); }
.nt:last-child { border-bottom: none; }
.nt-nueva { background: var(--amber-soft); box-shadow: inset 3px 0 0 var(--amber); }
.nt-ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.nt-nueva .nt-ic { background: var(--surface); }
.nt-body { flex: 1; min-width: 0; }
.nt-tit { font-size: 14px; font-weight: 600; line-height: 1.35; }
.nt-det { font-size: 13px; color: var(--text); margin-top: 2px; line-height: 1.45; }
.nt-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.nt-act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
@media (max-width: 560px) { .nt { flex-wrap: wrap; } .nt-act { width: 100%; justify-content: flex-start; margin-left: 47px; } }

/* ---- Orden de compra: editor de renglones ---- */
.oc-tabla { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; margin-top: 12px; }
.oc-lineas th, .oc-lineas td { padding: 8px 10px; }
.oc-lineas input, .oc-lineas select { font-family: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; }
.oc-lineas input:focus, .oc-lineas select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.oc-desc { width: 100%; min-width: 180px; }
.oc-cat { margin-top: 5px; width: 100%; font-size: 12px !important; }
.oc-uni { width: 96px; }
.oc-cant, .oc-precio, .rc-cant { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
.oc-iva { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.oc-iva input { width: auto; }
.oc-totales { display: flex; justify-content: flex-end; gap: 28px; flex-wrap: wrap; padding: 12px 4px 0; }
.oc-totales .kv .v { font-variant-numeric: tabular-nums; }
.oc-armar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px 4px; }
/* En el teléfono cada renglón de la orden es una ficha y los campos van a lo ancho */
@media (max-width: 760px) {
  .oc-tabla { overflow: visible; border: none; }
  .oc-lineas input, .oc-lineas select { font-size: 16px; }
  .oc-cant, .oc-precio, .rc-cant, .oc-uni { width: 100%; max-width: 160px; }
  .oc-totales { justify-content: flex-start; }
}

/* ---- Ver orden: documento a la izquierda, avance e historia a la derecha ---- */
.oc-ver { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0; }
.oc-lado { padding: 22px 22px 18px; border-left: 1px solid var(--border); background: var(--surface-2); }
.oc-lado .trz-h3:first-child { margin-top: 0; }
.oc-progs { display: flex; flex-direction: column; gap: 8px; }
.oc-prog { display: grid; grid-template-columns: 1fr; gap: 3px; font-size: 12.5px; }
.oc-prog-n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc-prog .bar-track { height: 8px; }
.oc-prog-v { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.oc-hist { display: flex; flex-direction: column; gap: 10px; }
.oc-hist-fila { display: grid; grid-template-columns: 96px 1fr; gap: 10px; font-size: 13px; line-height: 1.4; }
@media (max-width: 900px) { .oc-ver { grid-template-columns: 1fr; } .oc-lado { border-left: none; border-top: 1px solid var(--border); } }
@media print { .oc-lado, .oc-ver .modal-x { display: none !important; } .oc-ver { display: block; } }

/* ---- Sub-almacenes ---- */
.area-card.sub-inactivo { opacity: .55; }

/* ---------- Período + interruptor Cotizado / Facturado (Pedidos Mayor) ----------
   El interruptor va GRANDE a propósito: cotizado y facturado son las dos
   cifras que más se consultan, y un botón chico de los de .seg se pierde. */
.periodo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.periodo-lbl { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.periodo .seg { flex-wrap: wrap; }
.periodo-fechas { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.periodo-fechas label { display: inline-flex; align-items: center; gap: 6px; }
.periodo-fechas.on .usel { border-color: var(--accent); color: var(--text); font-weight: 600; }
.periodo-txt { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.periodo-txt b { color: var(--text); }

.pm-modo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.pm-modo-btn { position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; font-family: inherit; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 18px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: border-color .15s ease, background .15s ease; }
.pm-modo-btn:hover { border-color: var(--accent-2); }
.pm-modo-tit { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--muted); }
.pm-modo-val { font-size: 26px; font-weight: 700; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.pm-modo-sub { font-size: 12.5px; color: var(--muted); }
.pm-modo-cta { position: absolute; top: 12px; right: 14px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); }
.pm-modo-btn.cot.active { border-color: var(--blue); background: var(--blue-soft); }
.pm-modo-btn.cot.active .pm-modo-tit { color: var(--blue); }
.pm-modo-btn.cot.active .pm-modo-cta { background: var(--blue); color: var(--surface); }
.pm-modo-btn.fac.active { border-color: var(--green); background: var(--green-soft); }
.pm-modo-btn.fac.active .pm-modo-tit { color: var(--green); }
.pm-modo-btn.fac.active .pm-modo-cta { background: var(--green); color: var(--surface); }

.pm-pend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; padding: 10px 14px; font-size: 13px;
  color: var(--amber); background: var(--amber-soft); border: 1px solid var(--amber); border-radius: var(--radius); }
.pm-pend .btn { margin-left: auto; }
.pm-pag { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 6px 4px; font-size: 12.5px; color: var(--muted); }
.pm-pag b { color: var(--text); }
.pm-pag-btns { display: inline-flex; align-items: center; gap: 8px; }
.pm-pag-btns .btn[disabled] { opacity: .45; cursor: default; }

@media (max-width: 560px) {
  .pm-modo { gap: 8px; }
  .pm-modo-btn { padding: 12px; }
  .pm-modo-cta { position: static; align-self: flex-start; margin-bottom: 2px; }
  .pm-modo-tit { font-size: 12px; letter-spacing: .4px; }
  .pm-modo-val { font-size: 19px; }
  .pm-pend .btn { margin-left: 0; }
}


/* ---------- Vendedores ---------- */
.vd-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.vd-card { background: var(--panel, var(--card, #fff)); border: 1px solid var(--line, #e5e0d8); border-radius: 14px; padding: 14px 16px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.vd-card:hover, .vd-card:focus-visible { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-1px); outline: none; }
.vd-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.vd-nombre { font-weight: 700; font-size: 1.05rem; }
.vd-card-main { text-align: right; white-space: nowrap; }
.vd-card-val { font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.vd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.vd-grid > div { display: flex; flex-direction: column; }
.vd-grid .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; opacity: .65; }
.vd-grid .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.vd-grid .v small { font-weight: 400; opacity: .7; }
.vd-grid .v.rojo, .rojo { color: var(--red, #c0392b); }
.vd-grid .v.verde { color: var(--green, #2e7d32); }
.vd-meta { margin-top: 10px; }
.vd-meta-txt { font-size: .85rem; margin-bottom: 4px; }
.vd-meta-track { height: 8px; border-radius: 6px; background: var(--line, #e5e0d8); overflow: hidden; }
.vd-meta-fill { height: 100%; background: var(--red, #c0392b); border-radius: 6px; transition: width .3s; }
.vd-meta-fill.mid { background: var(--amber, #d68910); }
.vd-meta-fill.ok { background: var(--green, #2e7d32); }
.vd-inactivos { margin-top: 14px; }
.vd-inactivos summary { cursor: pointer; opacity: .75; margin-bottom: 10px; }
.vd-sinv { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.vd-tabs { margin-top: 14px; }
.vd-2bar { display: grid; grid-template-columns: 64px 1fr 120px; gap: 8px; align-items: center; padding: 3px 0; font-size: .85rem; }
.vd-2bar-l { opacity: .75; white-space: nowrap; }
.vd-2bar-t { display: flex; flex-direction: column; gap: 2px; }
.vd-2bar-a { height: 7px; border-radius: 4px; background: var(--accent, #333); min-width: 2px; }
.vd-2bar-b { height: 7px; border-radius: 4px; background: var(--accent-2, #9aa); opacity: .55; min-width: 2px; }
.vd-2bar-v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vd-2bar-v small { opacity: .65; }
@media (max-width: 760px) {
  .vd-cards { grid-template-columns: 1fr; }
  .vd-2bar { grid-template-columns: 60px 1fr 92px; font-size: .8rem; }
}
