/* Omega Web — estilos base (Fase 0). Claro/oscuro simple. */
:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #eef2f9; --line: #dde5f0;
  --text: #142033; --muted: #6b7a90; --primary: #1e6bff; --primary-700: #1146ad;
  --danger: #e5484d; --ok: #2fa96b; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0e1420; --surface:#161d2b; --surface-2:#1e2838; --line:#2a3547; --text:#e7edf6; --muted:#93a1b5; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login__card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 26px; box-shadow: 0 12px 40px rgba(0,0,0,.08); }
.login__logo { text-align: center; font-size: 26px; font-weight: 800; color: var(--primary-700); margin-bottom: 4px; letter-spacing: .5px; }
.login__sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; background: var(--surface-2); color: var(--text); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; border-color: var(--line); }

/* Layout app */
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .brand { font-weight: 800; color: var(--primary-700); letter-spacing: .4px; }
.top .who { font-size: 13px; color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px; }

.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.mod { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mod__h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--surface-2); font-weight: 800; }
.mod__h .count { font-size: 11px; color: var(--muted); font-weight: 700; background: var(--bg); border-radius: 20px; padding: 2px 9px; }
.mod__body { max-height: 320px; overflow: auto; }
.opt { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.opt:hover { background: var(--surface-2); }
.opt--link { cursor: pointer; }
.opt--link:hover { background: var(--primary); color: #fff; }
.opt--link:hover .lvl { color: var(--text); }
.opt .lvl { font-size: 10px; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 1px 6px; }
.opt .flags { margin-left: auto; font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 4px 0 10px; }

/* Barra de vista (título + volver + acciones) */
.viewbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 0 16px; }
.viewbar h2 { margin: 0; font-size: 20px; }
.viewbar .spacer { flex: 1; }
.viewbar .count { font-size: 12px; color: var(--muted); font-weight: 700; }
.search { flex: 1; min-width: 200px; max-width: 420px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.search:focus { outline: none; border-color: var(--primary); }

/* Tabla de datos */
.tablecard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 10px 12px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
table.data th.th-sort:hover { color: var(--text); background: var(--bg); }
table.data th.th-sort--on { color: var(--primary); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 20px; background: var(--surface-2); color: var(--muted); }
.badge--on { background: rgba(47,169,107,.15); color: var(--ok); }
.badge--off { background: rgba(229,72,77,.15); color: var(--danger); }
.badge--ice { background: rgba(30,107,255,.15); color: var(--primary); }
.badge--warn { background: rgba(214,158,20,.16); color: #a9761a; }
tr.row--link { cursor: pointer; }

/* Formularios */
.form { max-width: 980px; }
.fieldset { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.fieldset > h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.grid--5 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.f label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.f input, .f select, .f textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--text); }
.f input:focus, .f select:focus, .f textarea:focus { outline: none; border-color: var(--primary); }
.f textarea { resize: vertical; min-height: 60px; }
.f--req label::after { content: ' *'; color: var(--danger); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; padding-top: 22px; }
.check input { width: 18px; height: 18px; }
.check--top { padding-top: 0; }
.ta { position: relative; }
.ta__list { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.15); max-height: 240px; overflow: auto; }
.ta__item { padding: 9px 11px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ta__item:hover { background: var(--primary); color: #fff; }
.ta__item small { color: var(--muted); }
.ta__item:hover small { color: #dfe8ff; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.actions .spacer { flex: 1; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--ok { background: #128a3e; color: #fff; }

/* Paginador */
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 4px 2px; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.pager button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.pager button:disabled { opacity: .45; cursor: default; }

/* Subir imagen */
.imgup { display: flex; align-items: center; gap: 12px; }
.imgup__prev { width: 84px; height: 84px; border: 1px solid var(--line); border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.imgup__ph { width: 84px; height: 84px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }
.thumbgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.thumb { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 120px; object-fit: cover; display: block; }
.thumb__x { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%; width: 26px; height: 26px; cursor: pointer; font-size: 14px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,16,26,.55); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.modal__h { padding: 14px 18px; font-weight: 800; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.modal__b { padding: 16px 18px; display: grid; gap: 12px; }
.modal__f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.modal__f .spacer { flex: 1; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #142033; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 50; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }
.toast--error { background: var(--danger); }
.toast--ok { background: var(--ok); }

/* ======================= SHELL (sidebar + topbar) ======================= */
.shell { display: flex; min-height: 100vh; }
.maincol { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side { flex: 0 0 264px; width: 264px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-ov { display: none; }

.side-top { display: flex; align-items: center; gap: 8px; padding: 13px 12px; border-bottom: 1px solid var(--line); }
.side-brand { flex: 1; display: flex; align-items: center; gap: 10px; border: none; background: transparent; color: var(--primary-700); font-weight: 800; letter-spacing: .6px; font-size: 17px; padding: 2px; overflow: hidden; }
.side-brand__mk { display: inline-flex; color: var(--primary); flex: 0 0 auto; }
.side-rail { border: none; background: transparent; color: var(--muted); border-radius: 8px; padding: 6px; display: inline-flex; transition: transform .2s; }
.side-rail:hover { background: var(--surface-2); color: var(--text); }
.shell--rail .side-rail { transform: rotate(180deg); }

.nav { flex: 1; overflow: auto; padding: 8px 8px 16px; }
.nav-load { padding: 14px; color: var(--muted); font-size: 13px; }
.nav-block { margin-bottom: 2px; }
.nav-mod { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: none; background: transparent; color: var(--text); font-weight: 700; border-radius: 9px; text-align: left; }
.nav-mod:hover { background: var(--surface-2); }
.nav-mod.has-active { color: var(--primary); }
.nav-ico { width: 22px; height: 20px; display: inline-flex; align-items: center; color: var(--muted); flex: 0 0 auto; }
.nav-mod.has-active .nav-ico { color: var(--primary); }
.nav-mod__t { flex: 1; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count { font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 20px; padding: 1px 7px; }
.nav-soon { color: var(--muted); font-weight: 800; }
.nav-chev { display: inline-flex; color: var(--muted); transition: transform .18s; flex: 0 0 auto; }
.nav-mod.is-open .nav-chev { transform: rotate(90deg); }
.nav-sub { padding: 2px 0 8px 10px; margin: 2px 0 4px 20px; border-left: 1px solid var(--line); }
.nav-sa { width: 100%; display: flex; align-items: center; gap: 6px; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 6px 8px 4px; font-weight: 800; border: none; background: transparent; cursor: pointer; text-align: left; }
.nav-sa:hover { color: var(--text); }
.nav-sa__t { flex: 1; }
.nav-sa-count { font-size: 9.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 20px; padding: 0 6px; }
.nav-sa-chev { display: inline-flex; color: var(--muted); transition: transform .18s; }
.nav-sa-chev svg { width: 13px; height: 13px; }
.nav-sa.is-open .nav-sa-chev { transform: rotate(90deg); }
.nav-sa-body { padding-left: 2px; }
.nav-opt { width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 10px; border: none; background: transparent; color: var(--text); font-size: 13px; border-radius: 8px; text-align: left; }
.nav-opt:hover { background: var(--surface-2); }
.nav-opt.is-active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(30,107,255,.28); }
.nav-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.nav-opt.is-active .nav-dot { background: #fff; }
.nav-opt.is-off { opacity: .42; cursor: default; }
.nav-opt.is-off:hover { background: transparent; }
.nav-empty { font-size: 12px; color: var(--muted); padding: 4px 10px 6px; }

.side-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.side-user { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; }
.side-user__av { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: 0 0 auto; }
.side-user__i { min-width: 0; }
.side-user__n { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user__r { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-out { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.side-out:hover { border-color: var(--danger); color: var(--danger); }

/* Riel (escritorio colapsado) */
.shell--rail .side { flex-basis: 66px; width: 66px; }
.shell--rail .side-brand__t, .shell--rail .nav-mod__t, .shell--rail .nav-count, .shell--rail .nav-soon,
.shell--rail .nav-chev, .shell--rail .nav-sub, .shell--rail .side-user__i, .shell--rail .side-out { display: none; }
.shell--rail .nav-mod, .shell--rail .side-brand { justify-content: center; }
.shell--rail .side-foot { justify-content: center; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.tb-burger { display: none; border: none; background: transparent; color: var(--text); padding: 6px; border-radius: 8px; }
.tb-burger:hover { background: var(--surface-2); }
.tb-ctx { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.tb-emp { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-meta { font-size: 11.5px; color: var(--muted); }
.tb-spacer { flex: 1; }
.tb-home { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 8px; padding: 7px 13px; font-size: 12.5px; font-weight: 700; }
.tb-home:hover { border-color: var(--primary); color: var(--primary); }

/* Home dashboard */
.hero { padding: 6px 2px 14px; }
.hero__t { margin: 0; font-size: 26px; font-weight: 800; }
.hero__s { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; }
.sec-h { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 16px 2px 10px; }
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.qa { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.qa:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(30,107,255,.14); }
.qa__k { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 800; }
.qa__t { font-size: 15px; font-weight: 700; }
.qa__m { font-size: 12px; color: var(--muted); }
.ms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 22px; }
.ms { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 13px; }
.ms__t { font-weight: 700; font-size: 14px; }
.ms__b { font-size: 12px; color: var(--ok); margin-top: 2px; font-weight: 600; }
.ms--soon .ms__b { color: var(--muted); }

.wrap--tight { padding-top: 14px; padding-bottom: 0; }
.backlink { border: none; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; padding: 2px 0; cursor: pointer; }
.backlink:hover { color: var(--primary); }

/* ---- Móvil / PWA: sidebar off-canvas ---- */
@media (max-width: 900px) {
  .side { position: fixed; left: 0; top: 0; z-index: 40; height: 100vh; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
  .shell.is-mobopen .side { transform: none; }
  .shell--rail .side { flex-basis: 264px; width: 264px; }
  .shell--rail .side-brand__t, .shell--rail .nav-mod__t, .shell--rail .nav-count,
  .shell--rail .nav-chev, .shell--rail .nav-sub, .shell--rail .side-user__i, .shell--rail .side-out { display: revert; }
  .side-rail { display: none; }
  .side-ov { display: block; position: fixed; inset: 0; background: rgba(8,12,20,.5); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 35; }
  .shell.is-mobopen .side-ov { opacity: 1; pointer-events: auto; }
  .tb-burger { display: inline-flex; }
  .wrap { padding: 14px; }
  .hero__t { font-size: 22px; }
}
