/* CESCAC INVENTARIO — Mobile-First, catálogo + pedidos por WhatsApp */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --brand: #025338;
  --brand-light: #037a4f;
  --brand-soft: #e3f3ec;
  --accent: #025338;
  --accent-soft: #d1fae5;
  --whatsapp: #25D366;
  --whatsapp-dark: #128C7E;
  --negative: #b91c1c;
  --negative-soft: #fee2e2;
  --positive: #047857;
  --positive-soft: #d1fae5;
  --warning: #92400e;
  --warning-soft: #fef3c7;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(2, 83, 56, 0.06);
  --shadow: 0 4px 12px rgba(2, 83, 56, 0.08);
  --shadow-lg: 0 10px 28px rgba(2, 83, 56, 0.10);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-full: 9999px;
  --touch: 44px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute; top: -3rem; left: 0.75rem; z-index: 100;
  padding: 0.5rem 0.75rem; background: var(--brand); color: #fff; font-weight: 600;
  border-radius: var(--radius-sm); text-decoration: none; transition: top 0.2s;
}
.skip-link:focus { top: 0.5rem; outline: 2px solid #fff; outline-offset: 2px; }

body.inv-app {
  font-family: 'Century Gothic', CenturyGothic, 'DM Sans', Arial, sans-serif;
  margin: 0; padding: 0; background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-tap-highlight-color: transparent; min-height: 100vh;
}

.app-header {
  position: relative;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff; padding: 0.75rem 1rem; display: flex; align-items: center; gap: 0.75rem;
  flex-wrap: wrap; box-shadow: var(--shadow);
}
.app-header a {
  color: rgba(255,255,255,0.95); text-decoration: none; min-height: var(--touch); min-width: var(--touch);
  display: inline-flex; align-items: center; justify-content: center; padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm); font-weight: 500; transition: background 0.2s, color 0.2s;
}
.app-header a:hover { background: rgba(255,255,255,0.14); color: #fff; }
.app-header .logo-link { display: flex; align-items: center; }
.app-header .logo-img { height: 32px; width: auto; filter: brightness(0) invert(1); }
.login-page .login-main .logo-img { filter: none; }
.app-header .brand-text { white-space: nowrap; font-weight: 700; letter-spacing: 0.02em; }
.app-header .user { margin-left: auto; font-size: 0.9rem; opacity: 0.95; display: flex; align-items: center; gap: 0.4rem; }
.badge-pro { background: #fbbf24; color: #78350f; font-size: 0.65rem; font-weight: 800; padding: 0.15rem 0.5rem; border-radius: var(--radius-full); letter-spacing: 0.03em; }

.nav-toggle { display: none; }
.nav-toggle-label {
  display: none; padding: 0.5rem 0.75rem; min-height: var(--touch); align-items: center; justify-content: center;
  cursor: pointer; font-weight: 600; border-radius: var(--radius-sm); background: rgba(255,255,255,0.15);
}
.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
@media (max-width: 768px) {
  .nav-toggle-label { display: inline-flex; margin-left: auto; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--brand-light);
    flex-direction: column; padding: 0.75rem; gap: 0.25rem; box-shadow: var(--shadow-lg); z-index: 20;
  }
  .nav-toggle:checked ~ .nav-links { display: flex; }
  .app-header .user { margin-left: 0; width: 100%; text-align: center; order: -1; padding-bottom: 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.2); justify-content: center; }
}

main { max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem; min-height: calc(100vh - 140px); }
@media (min-width: 768px) { main { padding: 1.75rem 1.5rem; } }

main > h1:first-of-type { font-size: 1.75rem; font-weight: 700; color: var(--text); margin: 0 0 0.35rem 0; letter-spacing: -0.02em; }
.page-subtitle { font-size: 1rem; color: var(--text-muted); margin: 0 0 1.25rem 0; font-weight: 400; }

.app-footer { text-align: center; padding: 1rem; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); background: var(--surface); }
.app-footer a { color: var(--brand); font-weight: 600; text-decoration: none; }

.error { color: var(--negative); background: var(--negative-soft); padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.positive { color: var(--positive); background: var(--positive-soft); padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); margin-bottom: 1rem; }

.login-page .login-main {
  margin: 2.5rem auto; max-width: 380px; background: var(--surface); padding: 2rem;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.login-page .login-main h1 { margin-top: 0; margin-bottom: 0.35rem; font-size: 1.5rem; font-weight: 700; }
.login-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 1rem; line-height: 1.5; }
.login-main a { color: var(--brand); font-weight: 600; min-height: var(--touch); display: inline-flex; align-items: center; }
.login-main a:hover { text-decoration: underline; }
.login-main form label { display: block; margin-bottom: 0.6rem; font-weight: 500; color: var(--text); }
.login-main input, main input[type=text], main input[type=tel], main input[type=password], main input[type=number], main textarea, main select {
  width: 100%; padding: 0.65rem 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; min-height: var(--touch); transition: border-color 0.2s, box-shadow 0.2s; font-family: inherit;
}
.login-main input:focus, main input:focus, main textarea:focus, main select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(2, 83, 56, 0.14);
}
.login-main button, main button[type=submit] {
  margin-top: 0.75rem; padding: 0.65rem 1.25rem; min-height: var(--touch); width: 100%; font-weight: 700;
  font-size: 1rem; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%); color: #fff;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; font-family: inherit;
}
.login-main button:hover, main button[type=submit]:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.dashboard-cards { display: grid; grid-template-columns: 1fr; gap: 1rem; margin: 1.25rem 0; }
@media (min-width: 480px) { .dashboard-cards { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--surface); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card h2 { margin: 0 0 0.5rem 0; font-size: 0.85rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.card .amount { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.card .amount.negative { color: var(--negative); }
.card .amount.positive { color: var(--positive); }
.card-note { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0 0 0; line-height: 1.4; }

.btn-primary, .btn-secondary, .btn-wa, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  margin-top: 0.5rem; margin-right: 0.5rem; margin-bottom: 0.25rem; padding: 0.65rem 1.2rem;
  min-height: var(--touch); border-radius: var(--radius-full); font-size: 0.9rem; font-weight: 700;
  text-decoration: none; transition: transform 0.15s, box-shadow 0.15s; border: none; cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); color: var(--brand); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--brand-soft); border-color: var(--brand); }
.btn-wa { background: var(--whatsapp); color: #fff; box-shadow: var(--shadow-sm); }
.btn-wa:hover { background: var(--whatsapp-dark); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn-danger { background: var(--negative-soft); color: var(--negative); }
*:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.cliente-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.cliente-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); display: flex; flex-wrap: wrap;
  align-items: center; justify-content: space-between; gap: 0.6rem;
}
.cliente-item.inactivo { opacity: 0.6; }
.cliente-item .nombre { font-weight: 700; font-size: 1.02rem; }
.cliente-item .tel { color: var(--text-muted); font-size: 0.82rem; }
.cliente-item .saldo { font-weight: 800; font-size: 1.1rem; color: var(--negative); }
.cliente-item .saldo.al-dia { color: var(--positive); }
.cliente-item .saldo.positive { color: var(--positive); }
.cliente-item .saldo.negative { color: var(--negative); }
.cliente-item .acciones { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.cliente-item .acciones a, .cliente-item .acciones button { margin: 0; padding: 0.45rem 0.9rem; font-size: 0.82rem; min-height: 38px; }

.thumb-mini { width: 42px; height: 42px; border-radius: var(--radius-sm); object-fit: cover; background: var(--brand-soft); }
.thumb-mini-empty { display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.thumb-detalle { width: 96px; height: 96px; border-radius: var(--radius); object-fit: cover; box-shadow: var(--shadow-sm); }

.quick-add { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.quick-add h2 { margin-top: 0; font-size: 1.1rem; }
.quick-add .row { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) { .quick-add .row { grid-template-columns: repeat(4, 1fr); align-items: end; } }
.quick-add label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.25rem; display: block; }
@media (min-width: 640px) { .row--movimiento { grid-template-columns: 1fr 1fr 2fr auto; } }

table.tabla-mov { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table.tabla-mov th, table.tabla-mov td { padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
table.tabla-mov th { background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
table.tabla-mov tr:last-child td { border-bottom: none; }
.tipo-cargo { color: var(--negative); font-weight: 700; }
.tipo-abono { color: var(--positive); font-weight: 700; }

.pill-limit { display: inline-block; background: #fef3c7; color: #92400e; font-size: 0.78rem; font-weight: 700; padding: 0.3rem 0.85rem; border-radius: var(--radius-full); margin-bottom: 1rem; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.opt-toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--text-muted); }

.catalogo-link-box {
  background: var(--brand-soft); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; font-size: 0.9rem;
}
.catalogo-link-box a { color: var(--brand); font-weight: 700; word-break: break-all; }

.tabs { display: flex; gap: 0.4rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab {
  padding: 0.5rem 1rem; border-radius: var(--radius-full); background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); font-weight: 700; font-size: 0.85rem; text-decoration: none; min-height: 38px; display: inline-flex; align-items: center;
}
.tab-activo { background: var(--brand); color: #fff; border-color: var(--brand); }

.estado-pill { display: inline-block; padding: 0.15rem 0.6rem; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em; }
.estado-pendiente { background: var(--warning-soft); color: var(--warning); }
.estado-confirmado { background: var(--positive-soft); color: var(--positive); }
.estado-cancelado { background: var(--negative-soft); color: var(--negative); }

/* ===== Catálogo público ===== */
body.catalogo-body { padding-bottom: 5.5rem; }
.catalogo-header .brand-text { font-size: 1.05rem; }
main.catalogo-main { max-width: 1080px; }
.catalogo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
@media (min-width: 640px) { .catalogo-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; } }
@media (min-width: 960px) { .catalogo-grid { grid-template-columns: repeat(4, 1fr); } }

.prod-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.prod-img { position: relative; aspect-ratio: 1 / 1; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prod-img img { width: 100%; height: 100%; object-fit: cover; }
.prod-img-empty { font-size: 2.2rem; opacity: 0.6; }
.badge-agotado, .badge-poco { position: absolute; top: 0.4rem; left: 0.4rem; font-size: 0.65rem; font-weight: 800; padding: 0.2rem 0.5rem; border-radius: var(--radius-full); }
.badge-agotado { background: var(--negative-soft); color: var(--negative); }
.badge-poco { background: var(--warning-soft); color: var(--warning); }
.prod-body { padding: 0.7rem 0.75rem 0.85rem; display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }
.prod-nombre { font-weight: 700; font-size: 0.88rem; line-height: 1.3; min-height: 2.3em; }
.prod-precio { font-weight: 800; font-size: 1.05rem; color: var(--brand); }
.prod-qty { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 0.3rem; }
.prod-qty-disabled { color: var(--text-muted); font-size: 0.78rem; font-weight: 600; text-align: center; padding: 0.4rem 0; }
.qty-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface);
  font-size: 1.1rem; font-weight: 700; color: var(--brand); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { background: var(--brand-soft); border-color: var(--brand); }
.qty-input { width: 42px; text-align: center; border: none; background: transparent; font-weight: 700; font-size: 0.95rem; min-height: auto; padding: 0; }

.cart-bar {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08); padding: 0.75rem 1rem; display: flex; align-items: center;
  justify-content: space-between; gap: 0.75rem; z-index: 30;
}
.cart-bar-info { font-size: 0.9rem; font-weight: 600; }
.cart-bar .btn-wa { margin: 0; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: flex; align-items: flex-end;
  justify-content: center; z-index: 50;
}
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal-box {
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; padding: 1.5rem; width: 100%;
  max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
@media (min-width: 640px) { .modal-box { border-radius: var(--radius); } }
.modal-box h2 { margin-top: 0; font-size: 1.2rem; }
.resumen-items { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0.5rem 0; margin-bottom: 0.75rem; }
.resumen-row { font-size: 0.88rem; padding: 0.3rem 0; }
.resumen-total { font-size: 1.05rem; margin: 0 0 1rem; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.modal-actions button { flex: 1; min-width: 140px; margin: 0; }
