/* ==========================================================================
   Sumaq Tecnologia - back office y punto de venta
   ========================================================================== */

:root {
  --ink: #0b1220;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #be123c;
  --danger-soft: #fff1f2;
  --sidebar: #0f172a;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow: 0 4px 12px rgba(15,23,42,.07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink-2); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { color: var(--ink); margin: 0 0 .4em; letter-spacing: -.02em; line-height: 1.25; }
h1 { font-size: 1.55rem; font-weight: 750; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0 0 .9rem; }
svg { display: block; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar { background: var(--sidebar); color: #94a3b8; padding: 1.15rem 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar__logo { display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem 1.25rem; color: #fff; font-weight: 750; letter-spacing: -.02em; }
.sidebar__mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #4f46e5, #06b6d4); display: grid; place-items: center; font-size: .85rem; font-weight: 800; color: #fff; flex: none; }
.sidebar__sub { display: block; font-size: .65rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: #64748b; margin-top: -3px; }
.sidebar__group { padding: 1rem 1.25rem .4rem; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #475569; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem 1.25rem; font-size: .93rem; font-weight: 550; color: #cbd5e1; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar nav a.is-active { background: rgba(79,70,229,.18); color: #fff; border-left-color: #6366f1; }
.sidebar nav a svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.sidebar__foot { margin-top: auto; padding: 1rem 1.25rem 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar__user { font-size: .85rem; color: #e2e8f0; font-weight: 600; }
.sidebar__role { font-size: .75rem; color: #64748b; }
.sidebar__foot form { margin-top: .6rem; }
.sidebar__foot button { width: 100%; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); color: #cbd5e1; padding: .45rem; border-radius: 8px; font: inherit; font-size: .85rem; cursor: pointer; }
.sidebar__foot button:hover { background: rgba(255,255,255,.12); color: #fff; }

.main { min-width: 0; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 1rem 1.75rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; position: sticky; top: 0; z-index: 20; }
.topbar__title { font-size: 1.25rem; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.topbar__sub { font-size: .85rem; color: var(--muted); }
.content { padding: 1.75rem; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem 1rem; border-radius: 9px; font: inherit; font-size: .9rem; font-weight: 600; border: 1px solid transparent; cursor: pointer; transition: background .15s ease, border-color .15s ease; white-space: nowrap; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: var(--panel); color: var(--ink-2); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--muted-2); }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: #fecdd3; }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { padding: .32rem .65rem; font-size: .82rem; border-radius: 7px; }
.btn--block { width: 100%; justify-content: center; }
.btn svg { width: 15px; height: 15px; }

/* ---------- Tarjetas y paneles ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel__head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.panel__head h2 { margin: 0; }
.panel__head p { margin: 0; font-size: .85rem; color: var(--muted); }
.panel__body { padding: 1.25rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); }
.kpi__label { font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.kpi__label svg { width: 15px; height: 15px; }
.kpi__value { font-size: 1.75rem; font-weight: 780; color: var(--ink); letter-spacing: -.03em; margin-top: .35rem; line-height: 1.1; }
.kpi__value small { font-size: .95rem; font-weight: 600; color: var(--muted); }
.kpi__note { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.kpi--warn .kpi__value { color: var(--warn); }
.kpi--danger .kpi__value { color: var(--danger); }

.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.25rem; align-items: start; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: .65rem 1.25rem; border-bottom: 1px solid var(--line); background: #fbfcfe; white-space: nowrap; }
table.data td { padding: .7rem 1.25rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fbfcfe; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: .8rem; color: var(--muted-2); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; color: var(--muted); }

/* ---------- Etiquetas ---------- */
.tag { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 650; padding: .2rem .55rem; border-radius: 999px; white-space: nowrap; }
.tag.is-ok { background: var(--ok-soft); color: var(--ok); }
.tag.is-low { background: var(--warn-soft); color: var(--warn); }
.tag.is-out { background: var(--danger-soft); color: var(--danger); }
.tag.is-off { background: #f1f5f9; color: var(--muted); }
.tag.is-in { background: var(--ok-soft); color: var(--ok); }
.tag.is-brand { background: var(--brand-soft); color: var(--brand-dark); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .82rem; font-weight: 650; color: var(--ink-2); margin-bottom: .3rem; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: .92rem; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
input[type=color] { width: 100%; height: 38px; padding: .2rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
textarea { resize: vertical; min-height: 90px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.check { display: flex; align-items: center; gap: .55rem; font-size: .9rem; padding: .5rem 0; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.error { color: var(--danger); font-size: .8rem; margin-top: .25rem; }
input.has-error, select.has-error { border-color: var(--danger); }
.form-actions { display: flex; gap: .6rem; padding-top: .5rem; flex-wrap: wrap; }

/* ---------- Avisos ---------- */
.alert { display: flex; gap: .7rem; align-items: flex-start; border-radius: 10px; padding: .8rem 1rem; font-size: .9rem; margin-bottom: 1.25rem; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: .1rem; }
.alert--ok { background: var(--ok-soft); color: #065f46; border: 1px solid #a7f3d0; }
.alert--error { background: var(--danger-soft); color: #9f1239; border: 1px solid #fecdd3; }
.alert--info { background: var(--brand-soft); color: #3730a3; border: 1px solid #c7d2fe; }

/* ---------- Filtros ---------- */
.filters-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.filters-bar input[type=search] { min-width: 220px; width: auto; }
.filters-bar select { width: auto; min-width: 150px; }

/* ---------- Paginacion ---------- */
.pagination { display: flex; gap: .25rem; justify-content: center; margin: 1.5rem 0 0; list-style: none; padding: 0; flex-wrap: wrap; }
.pagination li span, .pagination li a { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 .55rem; border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; background: #fff; color: var(--ink-2); }
.pagination li a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .active span { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 650; }
.pagination .disabled span { color: var(--muted-2); background: var(--bg); }

/* ---------- Vacio ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: .3rem; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--sidebar); padding: 1.5rem; }
.login__card { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 2rem; box-shadow: 0 25px 50px -12px rgba(0,0,0,.4); }
.login__logo { display: flex; align-items: center; gap: .65rem; justify-content: center; font-weight: 800; font-size: 1.1rem; color: var(--ink); margin-bottom: .35rem; }
.login__intro { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cols, .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .75rem 1rem; gap: .5rem; }
  .sidebar__logo { padding: 0; margin-right: auto; }
  .sidebar__group { display: none; }
  .sidebar nav { display: flex; overflow-x: auto; width: 100%; gap: .25rem; }
  .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; padding: .5rem .7rem; white-space: nowrap; }
  .sidebar nav a.is-active { border-left: 0; border-bottom-color: #6366f1; }
  .sidebar__foot { margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: .75rem; }
  .sidebar__foot form { margin: 0; }
  .content { padding: 1rem; }
  .topbar { padding: .9rem 1rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
}
