:root {
  --brand: #006aff;
  --brand-hover: #0052cc;
  --ink: #1e293b;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --surface: #ffffff;
  --bg: #f8fafc;
  --line: #e2e8f0;
  --error: #ad4433;
  --error-bg: #fee2e2;
  --ok: #059669;
  --ok-bg: #d1fae5;
  --warn: #92400e;
  --warn-bg: #fef3c7;

  --font-body: "DM Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Outfit", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink-soft);
  font-family: var(--font-body);
  overflow-x: hidden;
}

a { color: var(--brand); }
img { max-width: 100%; }

/* ---------- Login (pantalla sola, centrada) ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }

.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 32px 28px; margin: 20px;
}
.login-card h1 { margin: 0 0 4px; font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--ink); }
.login-sub { margin: 0 0 22px; font-size: 14px; }
.login-error { background: var(--error-bg); color: var(--error); padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 12.5px; margin-top: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; color: var(--ink); }
.login-form input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 16px; font-family: inherit; background: var(--bg); }
.login-form input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------- Botones ---------- */
.btn { display: inline-block; padding: 0.6rem 1.1rem; border-radius: 6px; border: none; font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; cursor: pointer; text-decoration: none; text-align: center; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-outline { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--surface); color: var(--error); border: 1px solid var(--error-bg); }
.btn-danger:hover { background: var(--error-bg); }
.btn-full { width: 100%; padding: 0.85rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.78rem; }

/* ---------- Navbar (con menu hamburguesa por debajo de 860px) ---------- */
.navbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; position: relative;
}
.navbar .logo { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.navbar .logo span { color: var(--brand); }
.navbar .nav-links { display: flex; align-items: center; gap: 1.4rem; font-size: 0.88rem; flex-wrap: wrap; }
.navbar .nav-links a { color: var(--ink-soft); text-decoration: none; }
.navbar .nav-links a:hover, .navbar .nav-links a.activo { color: var(--brand); }
.navbar form { display: inline; }
.navbar .nav-links button { background: none; border: none; color: var(--ink-soft); font-size: 0.88rem; cursor: pointer; font-family: inherit; padding: 0; }
.navbar .nav-links button:hover { color: var(--error); }

.nav-toggle { display: none; }
.nav-burger { display: none; }

@media (max-width: 860px) {
  .nav-burger {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 6px;
    font-size: 1.1rem; cursor: pointer; color: var(--ink); background: var(--surface);
  }
  .navbar .nav-links {
    display: none;
    flex-direction: column; align-items: flex-start; gap: 0.9rem;
    width: 100%; order: 3;
    padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--line);
  }
  .nav-toggle:checked ~ .nav-links { display: flex; }
  .navbar .nav-links form { width: 100%; }
  .navbar .nav-links button { font-size: 0.95rem; }
}

/* ---------- Layout ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 2.2rem 1.25rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-size: 1.5rem; color: var(--ink); margin: 0; }
.page-sub { color: var(--ink-faint); font-size: 0.85rem; margin: 4px 0 0; }

@media (max-width: 480px) {
  .page { padding: 1.5rem 1rem 3rem; }
  .page-head h1 { font-size: 1.25rem; }
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.6rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.card-mini { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1.4rem; }
.card-mini h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 1rem; color: var(--ink); }
.card-mini p { margin: 0; font-size: 0.8rem; color: var(--ink-faint); }
.form-panel { max-width: 520px; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.1rem; }
.form-group label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; color: var(--ink); }
.form-group input, .form-group select, .form-group textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0.75rem 1rem; font-size: 16px; font-family: inherit; width: 100%; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 480px) { .form-grid-2 { grid-template-columns: 1fr; } }

@media (max-width: 480px) {
  .card { padding: 1.2rem; }
}

/* Dos columnas lado a lado que se apilan en pantallas chicas — para
   reemplazar cualquier "grid-template-columns" fijo puesto inline. */
.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
.split-2--wide-right { grid-template-columns: 1fr 1.4fr; }
.split-2--wide-left { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 760px) {
  .split-2, .split-2--wide-right, .split-2--wide-left { grid-template-columns: 1fr; }
}

/* ---------- Tablas (se convierten en tarjetas apiladas en movil) ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; background: var(--surface); border-collapse: collapse; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
th, td { padding: 0.85rem 1.1rem; text-align: left; font-size: 0.85rem; border-bottom: 1px solid var(--line); }
th { background: var(--bg); color: var(--ink); font-weight: 700; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
.empty-state { text-align: center; padding: 3rem; color: var(--ink-faint); }

@media (max-width: 640px) {
  .table-wrap table thead { display: none; }
  .table-wrap table, .table-wrap table tbody, .table-wrap table tr, .table-wrap table td { display: block; width: 100%; }
  .table-wrap table tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 0.9rem; overflow: hidden; }
  .table-wrap table tr:last-child { margin-bottom: 0; }
  .table-wrap table td {
    border-bottom: 1px solid var(--line); padding-left: 42%;
    position: relative; text-align: right; min-height: 2.4rem; display: flex; align-items: center; justify-content: flex-end;
  }
  .table-wrap table td:last-child { border-bottom: none; }
  .table-wrap table td::before {
    content: attr(data-label);
    position: absolute; left: 1rem; top: 0.85rem;
    width: 38%; text-align: left; font-weight: 700; text-transform: uppercase;
    font-size: 0.68rem; letter-spacing: 0.4px; color: var(--ink-faint);
  }
  .table-wrap table td:empty::before { content: none; }
}

.badge { display: inline-block; padding: 0.25rem 0.7rem; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: var(--error-bg); color: var(--error); }

.alert { padding: 0.8rem 1rem; border-radius: 6px; font-size: 0.85rem; margin-bottom: 1.2rem; }
.alert-error { background: var(--error-bg); color: var(--error); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.back-link { display: inline-block; margin-bottom: 1rem; font-size: 0.85rem; color: var(--ink-faint); text-decoration: none; }
.back-link:hover { color: var(--brand); }
code { background: var(--bg); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.85em; word-break: break-word; }
pre { overflow-x: auto; max-width: 100%; }

/* ---------- Tarjetas de estadisticas (KPI) ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.kpi-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem 1.3rem; }
.kpi-tile .kpi-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-faint); font-weight: 600; }
.kpi-tile .kpi-valor { font-family: var(--font-display); font-size: 1.6rem; color: var(--ink); margin-top: 0.3rem; font-variant-numeric: tabular-nums; }

.barra-horizontal { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.7rem; }
.barra-horizontal .barra-etiqueta { width: 40%; font-size: 0.8rem; color: var(--ink); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-horizontal .barra-track { flex: 1; background: var(--bg); border-radius: 4px; height: 10px; overflow: hidden; }
.barra-horizontal .barra-fill { background: var(--brand); height: 100%; border-radius: 4px; min-width: 4px; }
.barra-horizontal .barra-valor { font-size: 0.78rem; color: var(--ink-soft); width: 3.4rem; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

.barras-dias { display: flex; align-items: flex-end; gap: 0.6rem; height: 140px; padding-top: 1.5rem; }
.barras-dias .dia-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 0.4rem; }
.barras-dias .dia-monto { font-size: 0.68rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.barras-dias .dia-barra { width: 100%; max-width: 34px; background: var(--brand); border-radius: 4px 4px 2px 2px; min-height: 3px; }
.barras-dias .dia-etiqueta { font-size: 0.66rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.3px; }

/* ---------- Catálogo público ---------- */
.hero-tienda {
  background: linear-gradient(180deg, var(--bg) 0%, var(--surface) 100%);
  padding: 3rem 1.5rem; text-align: center; border-bottom: 1px solid var(--line);
}
.hero-tienda h1 { font-family: var(--font-display); font-size: clamp(1.6rem, 6vw, 2.4rem); color: var(--ink); margin: 0 0 0.5rem; text-wrap: balance; }
.hero-tienda p { max-width: 520px; margin: 0 auto; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.product-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; display: block; transition: transform 0.15s, border-color 0.15s; }
.product-card:hover { transform: translateY(-3px); border-color: var(--brand); }
.product-card .imagen { aspect-ratio: 1 / 1; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--ink-faint); font-size: 0.8rem; overflow: hidden; }
.product-card .imagen img { width: 100%; height: 100%; object-fit: cover; }
.product-card .info { padding: 0.85rem; }
.product-card h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 0.9rem; color: var(--ink); }
.product-card .precio { font-weight: 700; color: var(--brand); }

@media (max-width: 480px) {
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.7rem; }
}

.detalle-producto { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.detalle-producto .imagen { aspect-ratio: 1 / 1; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--ink-faint); }
.detalle-producto .imagen img { width: 100%; height: 100%; object-fit: cover; }
.detalle-producto h1 { font-family: var(--font-display); color: var(--ink); font-size: 1.6rem; margin: 0 0 0.5rem; text-wrap: balance; }
.detalle-producto .precio { font-family: var(--font-display); font-size: 1.4rem; color: var(--brand); font-weight: 700; margin-bottom: 1rem; }
@media (max-width: 640px) { .detalle-producto { grid-template-columns: 1fr; gap: 1.5rem; } }
