/* Droguería Zami — Identidad visual */
:root {
  --navy: #2E3A59; --blue: #3D5A99; --blue-soft: #4A6FA5;
  --green: #8DC63F; --green-dark: #6FA82B;
  --bg: #F4F6FA; --card: #FFFFFF; --line: #E2E7F0;
  --rojo: #D9534F; --ambar: #F0AD4E;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--navy); min-height: 100vh; }
h1,h2,h3 { color: var(--navy); }
a { color: var(--blue); }

.btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; border: none; cursor: pointer;
  border-radius: 10px; padding: 10px 18px; font-size: 15px; font-weight: 600; transition: .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--navy); }
.btn-ghost { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-danger { background: var(--rojo); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 15px; color: var(--navy); background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); }
label { font-size: 13px; font-weight: 600; display: block; margin: 10px 0 4px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 8px 10px; background: var(--navy); color: #fff; font-weight: 600; }
th:first-child { border-radius: 8px 0 0 8px; } th:last-child { border-radius: 0 8px 8px 0; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
tr:hover td { background: #F0F5EA; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.chip-verde { background: #E5F3D2; color: var(--green-dark); }
.chip-rojo { background: #FBE3E2; color: var(--rojo); }
.chip-ambar { background: #FCF0DB; color: #B27B16; }
.chip-azul { background: #E1E9F7; color: var(--blue); }

.modal-fondo { position: fixed; inset: 0; background: rgba(46,58,89,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 14px; }
.modal { background: #fff; border-radius: var(--radius); padding: 22px; width: 100%; max-width: 520px;
  max-height: 92vh; max-height: calc(100dvh - 28px); overflow-y: auto; position: relative;
  overscroll-behavior: contain; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
.modal-x { position: sticky; top: -6px; float: right; margin: -8px -8px 0 8px; z-index: 5;
  width: 34px; height: 34px; border: none; border-radius: 50%; background: var(--bg, #eef2f8); color: var(--navy);
  font-size: 18px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.modal-x:hover { background: var(--rojo); color: #fff; }
/* Modales: nada de esquinas en punta — todos los campos y botones van redondeados (menos la X circular) */
.modal input, .modal select, .modal textarea { border-radius: 10px !important; }
.modal button:not(.modal-x) { border-radius: 10px !important; }
.modal .dropzone { border-radius: 12px !important; }
.oculto { display: none !important; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy);
  color: #fff; padding: 12px 22px; border-radius: 12px; z-index: 99; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.toast.error { background: var(--rojo); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  /* Móvil: el modal se pega arriba para que el teclado no tape los botones (ej: Confirmar venta) */
  .modal-fondo { align-items: flex-start; padding-top: 10px; }
  /* dvh = alto REAL visible (sin la barra del navegador): así el botón Guardar nunca queda escondido */
  .modal { max-height: 94vh; max-height: calc(100dvh - 20px); padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }
  /* Móvil: tablas, tarjetas y botones más compactos para que quepan mejor en las tres páginas */
  .card { padding: 12px; }
  table { font-size: 12.5px; }
  th, td { padding: 6px 7px; }
  .btn { padding: 9px 14px; font-size: 14px; }
  .btn-sm { padding: 5px 9px; font-size: 12px; }
  .modal { padding: 16px; }
  h1 { font-size: 19px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
}

/* ===== Textos largos (nombres de productos, correos, códigos, direcciones) =====
   Cualquier texto que se registre, por largo que sea o aunque no tenga espacios,
   parte la línea DENTRO de su tarjeta o fila y nunca se sale del borde. */
body { overflow-wrap: break-word; }
.prod, .grid-prod > *, .grid2 > *, .kpis > *, .config-grid > *, .layout > *,
.item .nom, .item-car .nom { min-width: 0; }
.nom, .prod, .item, .item-car, .modal, .toast { overflow-wrap: break-word; word-break: break-word; }
/* En tablas (inventario, pedidos, ventas): el nombre largo se parte dentro de su celda en vez de ensanchar la tabla */
td strong, td small, td .nom { overflow-wrap: anywhere; }
