/* =========================================================
   SHOPPING — Área de Gestión
   ========================================================= */
:root {
  --brand: #e2466f;
  --brand-dark: #c1305a;
  --navy: #1d1f3d;
  --navy-2: #282b52;
  --ink: #2b2d42;
  --muted: #6b6f85;
  --bg: #f4f3f8;
  --surface: #ffffff;
  --line: #e8e6f0;
  --danger: #d63c3c;
  --ok: #1a9b62;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(29, 31, 61, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Poppins', sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: .9rem; color: var(--ink); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }

/* ========== BOTONES ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 18px; border-radius: 10px;
  border: 1px solid transparent; font-weight: 600; font-size: .86rem; white-space: nowrap; transition: background .2s, border-color .2s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger-ghost { background: transparent; border-color: #f2c9c9; color: var(--danger); }
.btn-danger-ghost:hover { background: #fdf0f0; }
.btn-block { width: 100%; padding: 12px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); display: inline-grid; place-items: center; transition: background .2s, color .2s; }
.icon-btn:hover { background: #f0eff6; color: var(--navy); }
.icon-btn.danger:hover { background: #fdf0f0; color: var(--danger); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* ========== LOGIN ========== */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--navy) 0%, #5b2a86 55%, var(--brand) 100%); }
.login-card { background: var(--surface); width: 100%; max-width: 380px; border-radius: 20px; padding: 36px 30px; box-shadow: 0 30px 60px rgba(0, 0, 0, .25); display: grid; gap: 14px; }
.login-logo { width: 60px; height: 60px; border-radius: 16px; background: #fde8ee; color: var(--brand); display: grid; place-items: center; font-size: 1.6rem; margin: 0 auto; }
.login-card h1 { text-align: center; font-size: 1.4rem; color: var(--navy); }
.login-card > p { text-align: center; margin-top: -10px; }
.login-card label { display: grid; gap: 6px; font-weight: 500; font-size: .85rem; }
.login-card input { padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.login-card input:focus { border-color: var(--brand); }
.login-error { color: var(--danger); font-size: .85rem; text-align: center; }
.login-back { text-align: center; font-size: .82rem; color: var(--muted); }
.login-back:hover { color: var(--brand); }

/* ========== LAYOUT ========== */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 250px; flex-shrink: 0; background: var(--navy); color: rgba(255, 255, 255, .75); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 14px; }
.sidebar-logo { font-size: 1.3rem; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.sidebar-logo i { color: var(--brand); }
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-nav a, .sidebar-link { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; font-size: .88rem; transition: background .2s, color .2s; }
.sidebar-nav a i, .sidebar-link i { width: 18px; text-align: center; }
.sidebar-nav a:hover, .sidebar-link:hover { background: var(--navy-2); color: #fff; }
.sidebar-nav a.active { background: var(--brand); color: #fff; }
.sidebar-link { margin-top: auto; border: 1px solid rgba(255, 255, 255, .12); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 1.2rem; color: var(--navy); flex: 1; }
.menu-btn { display: none; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: .85rem; }
.user-chip i { font-size: 1.3rem; color: var(--brand); }
.user-chip small { background: #f0eff6; color: var(--muted); padding: 2px 8px; border-radius: 999px; font-size: .72rem; }
.content { padding: 24px 28px 50px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }

/* ========== FILTROS / TOOLBAR ========== */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h3 { color: var(--navy); font-size: 1rem; }
.toolbar-actions { display: flex; gap: 8px; }
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 0; }
.sec > .filterbar { margin-bottom: 18px; }
.filterbar label { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.filterbar input, .filterbar select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); outline: none; }
.filterbar input[type=search] { min-width: 220px; }
.filterbar input:focus, .filterbar select:focus { border-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: none; background: transparent; padding: 8px 14px; font-size: .82rem; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--navy); color: #fff; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: none; background: none; padding: 11px 16px; font-size: .86rem; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.tabs button:hover { color: var(--navy); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ========== KPIs ========== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.kpi i { width: 42px; height: 42px; border-radius: 11px; background: #fde8ee; color: var(--brand); display: grid; place-items: center; font-size: 1.05rem; flex-shrink: 0; }
.kpi small { display: block; color: var(--muted); font-size: .76rem; }
.kpi strong { font-size: 1.18rem; color: var(--navy); }
.kpis-sm .kpi { padding: 12px 16px; }
.kpis-sm .kpi strong { font-size: 1.05rem; }

/* ========== CHARTS ========== */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-card { padding: 18px 20px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { font-size: .95rem; color: var(--navy); margin-bottom: 12px; }
.chart-card h3 small { color: var(--muted); font-weight: 400; font-size: .78rem; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 300px; }

/* ========== TABLAS ========== */
.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: .85rem; }
.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; padding: 12px 14px; background: #faf9fc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 10px 14px; border-bottom: 1px solid #f0eff5; vertical-align: middle; }
.grid tbody tr:hover { background: #fbfaff; }
.grid tfoot td { font-weight: 700; color: var(--navy); background: #faf9fc; border-bottom: none; }
.grid .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid .acciones { text-align: right; white-space: nowrap; width: 1%; }
.grid .vacio { text-align: center; color: var(--muted); padding: 30px; }
.grid .clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.neg { color: var(--danger); }
.table-foot { color: var(--muted); font-size: .8rem; margin-top: 10px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 8px; }
.thumb { width: 48px; height: 48px; border-radius: 9px; object-fit: cover; display: block; }
.thumb-ph { display: grid; place-items: center; background: var(--c); color: #fff; font-size: 1.1rem; }
.bar-col { width: 22%; min-width: 140px; }
.hbar { height: 10px; background: #f0eff5; border-radius: 4px; overflow: hidden; }
.hbar span { display: block; height: 100%; background: var(--c); border-radius: 0 4px 4px 0; }
.stock { display: inline-block; min-width: 34px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; text-align: center; }
.stock-ok { background: #e5f6ef; color: #12734a; }
.stock-bajo { background: #fff3d6; color: #8a5a00; }
.stock-cero { background: #fdecec; color: var(--danger); }
.rol { padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.rol-admin { background: #fde8ee; color: var(--brand-dark); }
.rol-ven { background: #e6f1fc; color: #1f62b3; }
.rol-alm { background: #e5f6ef; color: #12734a; }
.icon-cell { width: 36px; height: 36px; border-radius: 50%; background: #fde8ee; color: var(--brand); display: inline-grid; place-items: center; }

/* ========== SWITCH ========== */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d5d4de; border-radius: 999px; transition: background .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: .88rem; margin: 6px 0 14px; cursor: pointer; }

/* ========== FORMULARIOS ========== */
.form-card { padding: 22px; margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin-bottom: 14px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-grid label { display: grid; gap: 6px; font-weight: 500; font-size: .82rem; align-content: start; }
.form-grid label small { color: var(--muted); font-weight: 400; }
.form-grid input, .form-grid select, .form-grid textarea { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: var(--surface); width: 100%; }
.form-grid textarea { resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--brand); }
.form-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.form-actions :only-child { margin-left: auto; }

.img-label { display: block; font-weight: 500; font-size: .82rem; margin-bottom: 8px; }
.img-field { margin-bottom: 10px; }
.img-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.img-preview { width: 160px; height: 110px; border-radius: 10px; border: 1px dashed #cfcde0; background: #faf9fc; display: grid; place-items: center; color: #b4b2c8; font-size: 1.8rem; overflow: hidden; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-btns { display: grid; gap: 8px; justify-items: start; }
.img-btns label.btn { cursor: pointer; }

.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-picker input { position: absolute; opacity: 0; }
.icon-picker span { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); cursor: pointer; transition: all .15s; }
.icon-picker input:checked + span { border-color: var(--brand); background: #fde8ee; color: var(--brand); }
.icon-picker input:focus-visible + span { outline: 2px solid var(--brand); }

.venta-total { text-align: right; font-size: 1rem; color: var(--muted); }
.venta-total strong { color: var(--navy); font-size: 1.25rem; }

/* ========== BANNERS ========== */
.banner-list { display: grid; gap: 12px; }
.banner-item { display: flex; align-items: center; gap: 18px; padding: 12px; }
.banner-item.off { opacity: .55; }
.banner-thumb { width: 220px; height: 84px; border-radius: 9px; flex-shrink: 0; background: linear-gradient(120deg, #1d1f3d, #5b2a86, #e2466f); background-size: cover; background-position: center; display: grid; place-items: center; align-content: center; color: rgba(255, 255, 255, .8); font-size: 1.2rem; gap: 2px; }
.banner-thumb small { font-size: .68rem; }
.banner-info { flex: 1; min-width: 0; }
.banner-info strong { color: var(--navy); }
.banner-info p { font-size: .84rem; }
.banner-actions { display: flex; align-items: center; gap: 4px; }

/* ========== MODAL ========== */
.modal { position: fixed; inset: 0; background: rgba(20, 20, 45, .5); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal-card { background: var(--surface); width: 100%; max-width: 640px; max-height: calc(100vh - 40px); border-radius: 16px; display: flex; flex-direction: column; box-shadow: 0 30px 60px rgba(0, 0, 0, .25); }
.modal-card form { display: flex; flex-direction: column; min-height: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.1rem; color: var(--navy); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); }

/* ========== TOAST ========== */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 10px; font-size: .88rem; z-index: 200; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.error { border-left: 4px solid var(--danger); }

/* ========== RESPONSIVE ========== */
@media (max-width: 991px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .menu-btn { display: inline-grid; }
  .charts { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 576px) {
  .user-chip span, .user-chip small { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .filterbar input[type=search] { min-width: 0; width: 100%; }
  .filterbar, .filterbar label { width: 100%; }
  .filterbar label input { flex: 1; }
  .toolbar > .btn { width: 100%; }
  .banner-item { flex-direction: column; align-items: stretch; }
  .banner-thumb { width: 100%; }
  .chart-box { height: 300px; }
}
