* { box-sizing: border-box; }

:root{
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --text: #101828;
  --muted: #667085;
  --border: rgba(16, 24, 40, .12);
  --shadow: 0 10px 30px rgba(16, 24, 40, .10);
  --shadow-sm: 0 6px 16px rgba(16, 24, 40, .08);

  /* Brand (del logo): rojo principal + acento azul */
  --brand: #c30000;     /* rojo base */
  --brand-2: #a40000;   /* hover / presión */
  --accent: #1b49c6;    /* azul del isotipo */

  /* UI */
  --primary: var(--brand);
  --primary-2: var(--brand-2);
  --danger: #b42318;

  --radius: 14px;
  --radius-sm: 10px;
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;

  --max: 1120px;
}

html, body { height: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
h1, h2, h3 { letter-spacing: -.01em; }
h1 { margin: 0 0 .25rem; }

.muted { color: var(--muted); }

/* Topbar + drawer (mobile-first) */
.construccion-banner {
  background: #fff7ed;
  color: #9a3412;
  font-size: .82rem;
  font-weight: 700;
  text-align: center;
  padding: .4rem 1rem;
  border-bottom: 1px solid #fed7aa;
}
.construccion-banner a { color: #9a3412; text-decoration: underline; text-underline-offset: 2px; }
.topbar { position: sticky; top: 0; z-index: 50; background: #fff; border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: var(--max); margin: 0 auto; padding: .75rem 1rem; display: flex; gap: .75rem; align-items: center; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: radial-gradient(circle at 20% 20%, #ff4d4d, var(--brand)); box-shadow: var(--shadow-sm); }
.brand-name { font-weight: 800; }
.brand-logo { height: 34px; width: auto; display: block; }
.topbar-right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.user-pill { display: none; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .85rem; background: #fff; }
.nav-links { display: none; gap: .5rem; }
.nav-links a { text-decoration: none; padding: .45rem .6rem; border-radius: 10px; color: var(--muted); }
.nav-links a.is-active { background: rgba(195,0,0,.10); color: var(--text); }
.icon-btn { border: 1px solid var(--border); background: #fff; border-radius: 12px; padding: .45rem .6rem; cursor: pointer; }

.drawer { position: fixed; inset: 0; background: rgba(16,24,40,.45); }
.drawer-inner { position: absolute; top: 0; right: 0; height: 100%; width: min(340px, 92vw); background: #fff; padding: 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .25rem; }
.drawer-inner a { text-decoration: none; padding: .65rem .8rem; border-radius: 12px; color: var(--text); }
.drawer-inner a.is-active { background: rgba(195,0,0,.10); }
.has-drawer { overflow: hidden; }

@media (min-width: 900px) {
  .topbar-menu { display: none; }
  .nav-links { display: flex; }
  .user-pill { display: inline-flex; }
  .brand-logo { height: 39px; }
}

/* Layout containers */
.container { max-width: var(--max); width: 100%; margin: 0 auto; padding: 1.25rem 1rem 5rem; flex: 1 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-title { font-size: 1.55rem; }
.page-subtitle { margin: 0; color: var(--muted); }
.page-actions { display: flex; gap: .5rem; align-items: center; }

.section { margin-top: 1rem; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; align-items: center; margin: .5rem 0; }
.section-title { margin: 0; font-size: 1.05rem; }
.section-subtitle { margin: 0; color: var(--muted); font-size: .92rem; }
.section-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1rem; }
.table-wrap { width: 100%; overflow: auto; border-radius: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .65rem 1rem; background: var(--primary); color: #fff; text-decoration: none; border-radius: 12px; border: 0; cursor: pointer; font-weight: 700; }
.btn:hover { background: var(--primary-2); }
.btn:disabled { opacity: .65; cursor: not-allowed; }
.btn-sm { padding: .45rem .7rem; border-radius: 10px; font-weight: 700; }
.btn-ghost { background: rgba(195,0,0,.06); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(195,0,0,.10); }
.btn-danger-ghost { background: rgba(180,35,24,.08); color: var(--danger); border: 1px solid rgba(180,35,24,.22); }
.btn-danger-ghost:hover { background: rgba(180,35,24,.14); }
.btn-link { background: none; border: none; color: var(--danger); cursor: pointer; text-decoration: underline; padding: 0; font-size: inherit; }

/* Forms */
.field { display: grid; gap: .35rem; }
.label { font-size: .82rem; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(26,26,46,.20); border-color: rgba(26,26,46,.30); }

.searchbar { display: grid; grid-template-columns: 1fr; gap: .75rem; align-items: end; }
@media (min-width: 640px){ .searchbar { grid-template-columns: 1fr auto; } }

/* Tables (desktop) */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .85rem; color: var(--muted); background: #fff; position: sticky; top: 0; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

/* Tables -> cards (mobile) */
@media (max-width: 720px) {
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) thead { display: none; }
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile),
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) tbody,
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) tr,
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) td { display: block; width: 100%; }
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) tr { border: 1px solid var(--border); border-radius: 14px; padding: .75rem; margin: .75rem 0; background: #fff; box-shadow: var(--shadow-sm); }
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) td { border: 0; padding: .35rem 0; display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) td::before { content: attr(data-label); color: var(--muted); font-weight: 700; font-size: .82rem; flex: 0 0 7.5rem; }
  .table-responsive td[data-label=""]::before { display: none; }
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) td.cell-acciones { display: block; padding-top: .55rem; }
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) td.cell-acciones::before { display: none; }
  .table-responsive:not(#tablaComparativa):not(.table-scroll-mobile) td.cell-acciones .btn { width: 100%; }
  .row-actions { justify-content: flex-start; }
  .stickybar-inner { flex-wrap: wrap; }
  .stickybar-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
  .stickybar-actions .btn { min-height: 2.5rem; }
  .table-wrap:has(.table-scroll-mobile) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-scroll-mobile { min-width: 960px; }
}

/* Pills + lists */
.pill { display: inline-flex; align-items: center; padding: .25rem .5rem; border-radius: 999px; background: rgba(195,0,0,.06); border: 1px solid var(--border); color: var(--muted); font-size: .82rem; }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.list-compact { list-style: none; padding: .5rem 0 0; margin: 0; display: grid; gap: .35rem; }
.list-compact-item { display: flex; justify-content: space-between; gap: .75rem; }
.list-compact-main { color: var(--text); }
.list-compact-right { color: var(--muted); white-space: nowrap; }

/* Sticky bar (cotizador) */
.stickybar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
.stickybar-inner { max-width: var(--max); margin: 0 auto; padding: .75rem 1rem; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.stickybar-title { font-weight: 900; }
.stickybar-meta { color: var(--muted); font-size: .9rem; }
.stickybar-list { max-width: var(--max); margin: 0 auto; padding: 0 1rem .75rem; }
@media (max-width: 720px) {
  .stickybar-inner { flex-direction: column; align-items: stretch; }
  .stickybar-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
  .stickybar-actions .btn { width: 100%; text-align: center; }
}

/* Toasts */
.toast-stack { position: fixed; right: 12px; bottom: 90px; display: grid; gap: .5rem; z-index: 100; }
.toast { background: #111827; color: #fff; padding: .75rem .95rem; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: .2s ease; max-width: min(380px, 92vw); font-weight: 600; font-size: .92rem; line-height: 1.35; }
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast-ok { background: #065f46; border-left: 4px solid #34d399; }
.toast-warn { background: #7a2e00; border-left: 4px solid #fb923c; }
.toast-error { background: #7f1d1d; border-left: 4px solid #f87171; }

/* Footer (simple, marca) */
.app-footer { margin-top: auto; padding: 1.5rem 1rem; border-top: 1px solid rgba(255,255,255,.10); background: #0b0b0d; color: rgba(255,255,255,.92); }
.app-footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.app-footer-brand { display: inline-flex; gap: .5rem; align-items: center; justify-content: center; font-weight: 800; }
.app-footer-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--brand); box-shadow: 0 0 0 4px rgba(195,0,0,.10); }
.app-footer-meta { color: rgba(255,255,255,.70); font-size: .9rem; text-align: center; }
.footer-logo { height: 56px; width: auto; display: block; margin: 0 auto; }

/* Legacy compat (keep existing class names working) */
.main { max-width: 960px; width: 100%; margin: 0 auto; padding: 1.5rem; background: #fff; min-height: 80vh; flex: 1 0 auto; }
.form label { display: block; margin: 0.75rem 0; }
.form input, .form select, .form textarea { max-width: 520px; }
.form-inline { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.form-inline input { min-width: 200px; }
.tabla { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.tabla th, .tabla td { padding: 0.5rem; text-align: left; border-bottom: 1px solid #ddd; }
.tabla th { background: #f0f0f0; }
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: #1a1a2e; padding: 1rem; }
.login-page .app-footer { width: 100%; margin-top: auto; }
.login-page .app-footer-inner { justify-content: center; }
.login-box { background: #fff; padding: 2rem; border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,0.26); width: 100%; max-width: 360px; }
.login-logo { display: block; height: 54px; width: auto; margin: 0 auto .75rem; }
.login-box h1 { font-size: 1.9rem; text-align: center; margin-bottom: .25rem; }
.login-box input { width: 100%; padding: 0.5rem; margin: 0.5rem 0; border: 1px solid #ccc; border-radius: 4px; }
.login-box button { width: 100%; padding: 0.6rem; margin-top: 0.5rem; background: #1a1a2e; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.login-box .error { color: #c00; font-size: 0.9rem; }
.login-box a { color: #36c; }
.promos { background: #f9f9e0; padding: 1rem; border-radius: 4px; margin-bottom: 1rem; }
.competencia-cell .cache-list { font-size: 0.9rem; margin-bottom: 0.25rem; }
.competencia-cell .cache-item { margin: 0.2rem 0; }
.competencia-cell .sin-cache { color: #888; }
.competencia-cell .competencia-actions { margin-top: 0.35rem; }
.competencia-cell .competencia-actions .btn-sm { margin-right: 0.25rem; }
.ref-select { min-width: 180px; padding: 0.35rem; }
.lista-competencia { list-style: none; padding: 0; margin: 0; }
.lista-competencia li { padding: 0.4rem 0.5rem; margin: 0.25rem 0; background: #fff; border-radius: 4px; }
.btn-ref.ref-activo { outline: 2px solid #1a1a2e; outline-offset: 2px; }

/* Checkboxes unificados (tienda + admin + auth) */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  flex: 0 0 auto;
  border: 2px solid #c5cad3;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
input[type="checkbox"]:hover { border-color: #9aa3b2; }
input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(195, 0, 0, .22);
}
input[type="checkbox"]:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.check-label,
label.check-label,
label:has(> input[type="checkbox"]:first-child) {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  cursor: pointer;
  line-height: 1.4;
  margin: .35rem 0;
  text-align: left;
  max-width: 100%;
}
.check-label > input[type="checkbox"],
label.check-label > input[type="checkbox"],
label:has(> input[type="checkbox"]:first-child) > input[type="checkbox"] {
  margin-top: .12rem;
}
.check-label > span,
label.check-label > span,
label:has(> input[type="checkbox"]:first-child) > span {
  flex: 1 1 auto;
  min-width: 0;
}

