/* SIGESCEP - hoja de estilos. Sin dependencias externas (CSP: style-src 'self'). */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #14213d;
  --muted: #5b6785;
  --border: #e1e6f0;
  --primary: #12408a;
  --primary-600: #0e3370;
  --primary-ink: #ffffff;
  --accent: #f2b705;
  --ok: #0f7a4d;       --ok-bg: #e3f5ec;
  --bad: #b3261e;      --bad-bg: #fde8e6;
  --info: #17509e;     --info-bg: #e5eefb;
  --warn: #8a5a00;     --warn-bg: #fff3d6;
  --side: #0c2a5c;     --side-ink: #dfe7f7; --side-muted: #8fa3cc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,32,64,.06), 0 6px 20px rgba(16,32,64,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #121b2e; --surface-2: #162238; --text: #e8edf8; --muted: #9aa8c7; --border: #24324f;
  --primary: #5b9bff; --primary-600: #7db0ff; --primary-ink: #06122a;
  --ok: #5fd39a; --ok-bg: #123325; --bad: #ff8a80; --bad-bg: #3a1613; --info: #8ab8ff; --info-bg: #14264a; --warn: #ffd166; --warn-bg: #3a2c0b;
  --side: #08101f; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #121b2e; --surface-2: #162238; --text: #e8edf8; --muted: #9aa8c7; --border: #24324f;
    --primary: #5b9bff; --primary-600: #7db0ff; --primary-ink: #06122a;
    --ok: #5fd39a; --ok-bg: #123325; --bad: #ff8a80; --bad-bg: #3a1613; --info: #8ab8ff; --info-bg: #14264a; --warn: #ffd166; --warn-bg: #3a2c0b;
    --side: #08101f; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); min-height: 100vh; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--primary); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.ico { width: 20px; height: 20px; flex: none; } .ico-lg { width: 30px; height: 30px; color: var(--primary); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- Estructura ---- */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem;
  background: linear-gradient(135deg, var(--accent), #ffd95a); color: #1b2a4a; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { letter-spacing: .06em; } .brand-text small { color: var(--side-muted); font-size: .72rem; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-title { margin: 18px 10px 6px; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--side-muted); }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-ink);
  text-decoration: none; font-weight: 500; }
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.is-active { background: rgba(255,255,255,.14); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.is-disabled { opacity: .4; cursor: not-allowed; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.page-title { font-size: 1.2rem; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user { display: flex; align-items: center; gap: 10px; padding-left: 8px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--info-bg); color: var(--primary); }
.user-text { display: flex; flex-direction: column; line-height: 1.2; }
.user-text small { color: var(--muted); }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text); width: 40px; height: 40px;
  border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.only-mobile { display: none; }
.ico-sun { display: none; }
:root[data-theme="dark"] .ico-sun { display: block; } :root[data-theme="dark"] .ico-moon { display: none; }
.content { padding: 24px; display: grid; gap: 20px; align-content: start; max-width: 1400px; width: 100%; }
.scrim { display: none; }

/* ---- Componentes ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-narrow { max-width: 520px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.link { font-weight: 600; text-decoration: none; } .link:hover { text-decoration: underline; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--primary), #1e6ad8); color: #fff; border: 0; }
.hero h2 { font-size: 1.4rem; } .hero .muted { color: rgba(255,255,255,.85); }
.chips { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.chip-ok { background: var(--ok-bg); color: var(--ok); } .chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-info { background: var(--info-bg); color: var(--info); } .chip-off { background: var(--surface-2); color: var(--muted); }
.hero .chip .ico { width: 16px; height: 16px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-value { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.kpi-warn .kpi-value { color: var(--bad); }
.modules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.module { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; position: relative; }
.module.is-off { opacity: .6; }
.module .soon { position: absolute; top: 16px; right: 16px; font-size: .72rem; color: var(--muted); border: 1px dashed var(--border); padding: 2px 8px; border-radius: 999px; }

.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid transparent; font-weight: 500; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-info { background: var(--info-bg); color: var(--info); }

.form { display: grid; gap: 14px; margin-top: 12px; }
.field { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.field input, .field select { font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); width: 100%; min-height: 44px; }
.field input:focus, .field select:focus { border-color: var(--primary); outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent); }
.field .code-input, .code-input { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; min-height: 44px;
  padding: 0 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); } .btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); } .btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.rules { color: var(--muted); padding-left: 18px; margin: 8px 0; }
.qr { width: 224px; max-width: 100%; margin: 12px 0; background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--border); }
.qr svg { display: block; width: 100%; height: auto; }
.secret { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 12px; align-items: end; margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:hover { background: var(--surface-2); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }

/* ---- Acceso ---- */
.auth { display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent), var(--bg); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 12px; } .auth-card .brand-text small { color: var(--muted); }
.brand-lg .brand-mark { width: 48px; height: 48px; }
.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 16px; }

/* ---- Movil / tableta ---- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modules { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .only-mobile { display: grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30; transform: translateX(-102%); transition: transform .2s ease; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(5,12,28,.55); z-index: 20; }
  .topbar { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .user-text { display: none; }
  .content { padding: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .filters { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 1.6rem; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: var(--surface); }
  .table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-weight: 600; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- Gestion de usuarios ---- */
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: grid; gap: 12px; margin: 0; }
.fieldset legend { padding: 0 6px; font-weight: 700; color: var(--muted); font-size: .85rem; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { width: 20px; height: 20px; margin-top: 2px; }
.checks { display: grid; gap: 14px; padding: 6px 0 10px; }
.grid-ficha { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-ficha .span-all { grid-column: 1 / -1; }
@media (max-width: 900px) { .grid-ficha { grid-template-columns: 1fr; } }
.btn-danger { background: var(--bad); color: #fff; } .btn-danger:hover { filter: brightness(.92); }
.filters-4 { grid-template-columns: 2fr 1fr 1fr 1.4fr auto; }
.temp-pass { margin: 14px 0; }
.temp-pass code { display: block; font-size: 1.4rem; letter-spacing: .04em; padding: 14px; text-align: center; background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: 12px; user-select: all; word-break: break-all; }
.card-alert { border-left: 5px solid var(--accent); }
.aviso { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); }
.aviso:first-of-type { border-top: 0; }
[hidden] { display: none !important; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } .filters-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .filters-4 { grid-template-columns: 1fr; } .aviso { flex-direction: column; align-items: flex-start; } }

/* ---- Eliminar usuario ---- */
.row-actions { white-space: nowrap; }
.row-actions .link + .link, .row-actions .link + .link-off { margin-left: 14px; }
.link-danger { color: var(--bad); }
.link-off { color: var(--muted); opacity: .5; cursor: not-allowed; font-weight: 600; }
.card-danger { border-left: 5px solid var(--bad); }

/* ---- Menu de afiliados y edicion ---- */
.menu-block { padding: 18px 20px; }
.menu-title { display: flex; align-items: center; gap: 10px; font-size: .95rem; letter-spacing: .14em; text-transform: uppercase; color: var(--primary); margin: 0 0 14px; }
.menu-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.menu-item { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); text-decoration: none; color: var(--text); min-height: 76px; }
.menu-item strong { font-size: 1rem; } .menu-item span { color: var(--muted); font-size: .85rem; }
a.menu-item:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.menu-item.is-off { opacity: .55; cursor: not-allowed; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.locked { padding: 11px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); min-height: 44px; border: 1px dashed var(--border); }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.field-inline { min-width: 11rem; }
.filters-simple { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 900px) { .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .menu-grid, .cols-2 { grid-template-columns: 1fr; } .filters-simple { grid-template-columns: 1fr; } }
