/* =====================================================================
   Núcleo — interfaz v1.1
   Identidad: negro del logo en la barra superior, rojo de franja como acento,
   plata en la marca. Superficies grafito suaves (noche) o claras (día),
   esquinas redondeadas, sombras ligeras y tipografía Plus Jakarta Sans.
   ===================================================================== */
@font-face { font-family: "Jakarta"; src: url("../fonts/jakarta-latin.woff2") format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Jakarta"; src: url("../fonts/jakarta-latin-ext.woff2") format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Barlow Condensed"; src: url("../fonts/barlow-cond-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Condensed"; src: url("../fonts/barlow-cond-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --red: #e31f1d;
  --red-hover: #f0342f;
  --red-press: #bf1614;
  --red-soft: rgba(227, 31, 29, .12);
  --red-glow: 0 6px 18px rgba(227, 31, 29, .28);
  --silver: linear-gradient(180deg, #ffffff 0%, #dcdee2 48%, #a9adb4 100%);
  --brand-black: #0a0a0c;

  --font: "Jakarta", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;

  --topbar-h: 60px;
  --sidebar-w: 248px;
  --r-xl: 20px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 10px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Noche */
  --bg: #0d0e11;
  --bg-glow: radial-gradient(1200px 500px at 85% -10%, rgba(227, 31, 29, .07), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(120, 130, 160, .06), transparent 60%);
  --surface: #15161a;
  --surface-2: #1b1c21;
  --surface-3: #24252b;
  --surface-hover: #1f2026;
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .13);
  --text: #eceef1;
  --text-2: #a5a8b1;
  --text-3: #747884;
  --ok: #3ecf8e;
  --warn: #f5b947;
  --danger: #ff6159;
  --info: #7aa7ff;
  --shadow-card: inset 0 1px 0 rgba(255, 255, 255, .03), 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .18);
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .3);
  --focus: 0 0 0 3px rgba(227, 31, 29, .35);
  --topbar-bg: rgba(10, 10, 12, .82);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-glow: radial-gradient(1200px 500px at 85% -10%, rgba(227, 31, 29, .05), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef2;
  --surface-hover: #f3f4f7;
  --border: #e5e7eb;
  --border-strong: #d3d6dc;
  --text: #121418;
  --text-2: #50555f;
  --text-3: #868b95;
  --ok: #0f9960;
  --warn: #b7791f;
  --danger: #d4271f;
  --info: #2563eb;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 18px rgba(16, 24, 40, .05);
  --shadow-pop: 0 24px 60px rgba(16, 24, 40, .18), 0 2px 8px rgba(16, 24, 40, .08);
  --topbar-bg: rgba(10, 10, 12, .94);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg-glow), var(--bg); background-attachment: fixed;
  color: var(--text); font: 400 14.5px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
::selection { background: rgba(227, 31, 29, .3); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15.5px; letter-spacing: -.01em; }
p { margin: 0 0 .75em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.hidden { display: none !important; }
.num-font { font-family: var(--font-num); }
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

/* Arranque */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { width: 54px; animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.enter { animation: rise .28s var(--ease) both; }

/* ---------- Barra superior ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 50;
  display: flex; align-items: center; gap: 6px; padding: 0 14px 0 12px;
  background: var(--topbar-bg); color: #fff;
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.topbar::after { /* franja fina del logo */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(227, 31, 29, .7) 18%, rgba(255, 255, 255, .25) 50%, rgba(227, 31, 29, .7) 82%, transparent);
  opacity: .55;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 4px; margin-right: 6px; text-decoration: none; border-radius: 12px; }
.brand img { height: 34px; width: auto; display: block; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5)); }
.brand-name { font: 700 20px/1 var(--font-num); letter-spacing: .02em; background: var(--silver); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; }
.nav-sections { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav-sections::-webkit-scrollbar { display: none; }
.nav-item { position: relative; display: flex; }
.nav-btn {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px; border: 0; border-radius: 10px;
  background: none; cursor: pointer; color: #b9bbc2; font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-btn:hover, .nav-item.open > .nav-btn { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-btn[aria-current="true"] { color: #fff; background: rgba(255, 255, 255, .06); }
.nav-btn[aria-current="true"]::after { content: ""; position: absolute; left: 13px; right: 13px; bottom: -11px; height: 2px; border-radius: 2px; background: var(--red); box-shadow: 0 0 10px rgba(227, 31, 29, .8); }
.nav-btn svg { width: 16px; height: 16px; opacity: .8; }
.caret { width: 7px; height: 7px; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: translateY(-2px) rotate(45deg); opacity: .6; transition: transform .2s; }
.nav-item.open .caret { transform: translateY(1px) rotate(225deg); }
.dropdown {
  position: fixed; top: calc(var(--topbar-h) + 6px); min-width: 300px; max-width: 380px; z-index: 60;
  background: rgba(22, 23, 27, .97); color: #eceef1; border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 16px; box-shadow: var(--shadow-pop); padding: 8px; animation: rise .18s var(--ease) both;
  backdrop-filter: blur(16px);
}
.dropdown .dd-title { font-size: 12px; color: #80838d; font-weight: 600; padding: 8px 10px 6px; }
.dropdown a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; text-decoration: none; color: #dfe1e5; }
.dropdown a:hover, .dropdown a:focus-visible, .dropdown a[aria-current="page"] { background: rgba(255, 255, 255, .07); color: #fff; }
.dropdown a .t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.dropdown a .t b { font-weight: 600; font-size: 14px; }
.dropdown a .t span { font-size: 12px; color: #8a8d97; }
.topbar-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.search-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .04); color: #a7aab3; font-size: 13px; margin-right: 6px;
}
.search-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.search-btn svg { width: 15px; height: 15px; }
kbd { font: 600 11px/1 var(--font); padding: 4px 6px; border-radius: 6px; border: 1px solid currentColor; opacity: .55; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 0; background: none; color: #b9bbc2; cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.icon-btn svg { width: 19px; height: 19px; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 3px 10px 3px 3px; border: 0; background: none; border-radius: 999px; cursor: pointer; color: #fff; margin-left: 4px; }
.user-btn:hover { background: rgba(255, 255, 255, .08); }
.user-btn .who { text-align: left; line-height: 1.2; }
.user-btn .who b { display: block; font-weight: 600; font-size: 13.5px; }
.user-btn .who span { font-size: 11.5px; color: #8f929b; }
.avatar { --h: 0; width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; letter-spacing: .02em;
  color: hsl(var(--h) 70% 92%); background: linear-gradient(135deg, hsl(var(--h) 55% 42%), hsl(calc(var(--h) + 30) 55% 30%)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.avatar.lg { width: 52px; height: 52px; font-size: 17px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.tile { --h: 0; width: 36px; height: 36px; flex: none; border-radius: 11px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
  background: linear-gradient(140deg, hsl(var(--h) 65% 52%), hsl(calc(var(--h) + 25) 60% 36%)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 4px 10px hsl(var(--h) 60% 20% / .35); }
.tile.lg { width: 44px; height: 44px; border-radius: 13px; font-size: 15px; }
.menu-pop {
  position: fixed; top: calc(var(--topbar-h) + 6px); right: 12px; width: 260px; z-index: 60; padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-pop); animation: rise .18s var(--ease) both;
}
.menu-pop .head { display: flex; gap: 10px; align-items: center; padding: 10px; }
.menu-pop .head b { display: block; font-size: 14px; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none; border-radius: 10px; text-decoration: none; cursor: pointer; font-size: 14px; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop svg { width: 17px; height: 17px; color: var(--text-2); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.seg svg { width: 14px; height: 14px; }

/* Aviso global */
.announce { display: flex; align-items: center; gap: 12px; padding: 10px 18px; font-size: 13.5px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--info) 12%, var(--surface)); }
.announce.warning { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); }
.announce.critical { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); }
.announce svg { width: 18px; height: 18px; flex: none; }
.announce button { margin-left: auto; }

/* ---------- Estructura ---------- */
.shell { padding-top: var(--topbar-h); min-height: 100vh; }
.with-sidebar { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); transition: grid-template-columns .22s var(--ease); }
html.sb-collapsed .with-sidebar:not(.no-sidebar) { grid-template-columns: 72px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; overflow-x: hidden;
  padding: 18px 12px 18px; border-right: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 55%, transparent);
  display: flex; flex-direction: column;
}
.sidebar-title { display: flex; align-items: center; gap: 12px; padding: 2px 8px 16px; min-width: 0; }
.sidebar-title > div { min-width: 0; }
.sidebar-title h2 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-title .small { margin-top: 2px; color: var(--text-3); white-space: nowrap; }
.side-group { font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 18px 12px 6px; letter-spacing: .02em; white-space: nowrap; }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.side-link svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side-link:hover { background: var(--surface-hover); color: var(--text); }
.side-link[aria-current="page"] { background: var(--red-soft); color: var(--text); font-weight: 650; }
.side-link[aria-current="page"] svg { color: var(--red); opacity: 1; }
.side-link[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--red); }
.side-link .count { margin-left: auto; font-size: 11.5px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: var(--red); color: #fff; }
.side-foot { margin-top: auto; padding-top: 12px; }
.collapse-btn { color: var(--text-3); }
html.sb-collapsed .sidebar .lbl, html.sb-collapsed .sidebar .side-group, html.sb-collapsed .sidebar-title > div, html.sb-collapsed .side-link .count { display: none; }
html.sb-collapsed .side-link { justify-content: center; padding: 0; }
html.sb-collapsed .sidebar-title { justify-content: center; padding-left: 0; padding-right: 0; }
.main { padding: 30px 36px 56px; min-width: 0; }
.main > * { animation: rise .26s var(--ease) both; }
.main-narrow { max-width: 1180px; margin: 0 auto; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--text-2); }
.crumb { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.crumb a { text-decoration: none; } .crumb a:hover { color: var(--text); }

/* ---------- Vista de módulo ---------- */
.module-frame-wrap { position: relative; min-width: 0; padding: 12px 12px 12px 0; }
.no-sidebar .module-frame-wrap { padding-left: 12px; }
.module-frame { display: block; width: 100%; height: calc(100vh - var(--topbar-h) - 24px); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.module-banner { display: flex; align-items: center; gap: 10px; padding: 9px 14px; margin-bottom: 10px; font-size: 13.5px; border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--border)); }
.module-banner + .module-frame { height: calc(100vh - var(--topbar-h) - 24px - 50px); }
.no-sidebar { grid-template-columns: 1fr !important; }

/* ---------- Componentes ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-card); min-width: 0; }
.panel-pad { padding: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-head h3 { display: flex; align-items: center; gap: 8px; }
.panel-head .sub { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(180deg, #ef2d2a, #d41a18); border-color: transparent; color: #fff; box-shadow: var(--red-glow), inset 0 1px 0 rgba(255, 255, 255, .2); }
.btn-primary:hover { background: linear-gradient(180deg, #f73b37, #dc201d); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }
.input, select.input, textarea.input {
  height: 40px; padding: 0 13px; border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s, background .15s;
}
html[data-theme="light"] .input { background: #fff; }
textarea.input { height: auto; min-height: 92px; padding: 10px 13px; resize: vertical; }
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: color-mix(in srgb, var(--text-3) 60%, var(--border-strong)); }
.input:focus { border-color: var(--red); outline: none; box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--red); margin-top: 1px; flex: none; }
.switch { position: relative; width: 38px; height: 22px; flex: none; appearance: none; -webkit-appearance: none; margin: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--ease); }
.switch:checked { background: var(--red); border-color: var(--red); }
.switch:checked::after { transform: translateX(16px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.error-text { color: var(--danger); font-size: 13.5px; }
.error-text:empty { display: none; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: color-mix(in srgb, var(--surface-2) 60%, transparent); position: sticky; top: 0; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td, .table tbody tr:hover td { background: var(--surface-hover); }
.cell-user { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cell-user b { display: block; font-weight: 600; }
.cell-user span { font-size: 12px; color: var(--text-3); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap;
  color: var(--text-2); background: var(--surface-3); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.badge.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.badge.info { color: var(--info); background: color-mix(in srgb, var(--info) 13%, transparent); }
.badge.plain::before { display: none; }

.tabs { display: inline-flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; max-width: 100%; }
.tab { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--text-2); cursor: pointer; font-weight: 600; font-size: 13.5px; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.tab svg { width: 15px; height: 15px; }

.empty { text-align: center; padding: 52px 24px; color: var(--text-2); }
.empty .ico { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.empty .ico svg { width: 24px; height: 24px; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 16px; }
.empty p { max-width: 460px; margin: 0 auto 14px; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 11px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.log-box { background: #0a0b0d; color: #d6d8dc; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; max-height: 480px; overflow: auto; white-space: pre-wrap; font: 12px/1.6 var(--font-mono); margin: 0; }

/* Métricas */
.kpi { padding: 18px 20px 14px; display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.kpi .top { display: flex; align-items: center; gap: 9px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.kpi .chip { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.kpi .chip svg { width: 15px; height: 15px; }
.kpi .chip.red { background: var(--red-soft); color: var(--red); }
.kpi .value { font: 700 34px/1.05 var(--font-num); letter-spacing: .01em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 17px; color: var(--text-3); font-weight: 600; margin-left: 3px; }
.kpi .sub { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi .spark { height: 38px; margin: 6px -20px -14px; }
.delta { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.delta.up { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.delta.down { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.delta.flat { color: var(--text-3); background: var(--surface-2); }
.metric { padding: 18px 20px; }
.metric .label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.metric .value { font: 700 32px/1.1 var(--font-num); margin-top: 6px; font-variant-numeric: tabular-nums; }
.metric .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #8a8f99, #c4c7cd); transition: width .6s var(--ease); }
html[data-theme="light"] .bar > i { background: linear-gradient(90deg, #6b7280, #9ca3af); }
.bar.hot > i { background: linear-gradient(90deg, #ff6b4a, var(--red)); }
.bar.ok > i { background: linear-gradient(90deg, #2bb673, var(--ok)); }
.gauge { width: 112px; height: 112px; position: relative; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge .lbl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge .lbl b { display: block; font: 700 24px/1 var(--font-num); }
.gauge .lbl span { font-size: 11px; color: var(--text-3); }
.chart-wrap { position: relative; }
.chart { width: 100%; height: 190px; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.chart .axis-text { fill: var(--text-3); font: 11px var(--font); }
.chart .line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .cursor { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.chart .bar-rect { rx: 3; }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; padding: 8px 10px; border-radius: 10px; font-size: 12px; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); transform: translate(-50%, calc(-100% - 10px)); }
.chart-tip b { display: block; font-size: 11.5px; color: var(--text-3); font-weight: 600; margin-bottom: 3px; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.rank { display: flex; flex-direction: column; gap: 12px; }
.rank-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.rank-item .meta b { display: block; font-weight: 600; font-size: 13.5px; }
.rank-item .meta span { font-size: 12px; color: var(--text-3); }
.rank-item .bar { margin-top: 6px; height: 5px; }
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.feed-item:last-child { border-bottom: 0; }
.feed-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--text-3); }
.feed-item .dot.high { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent); }
.feed-item .dot.warning { background: var(--warn); }
.feed-item .dot.info { background: var(--info); }
.feed-item .body { flex: 1; min-width: 0; font-size: 13.5px; }
.feed-item .body .t { color: var(--text-3); font-size: 12px; }

/* Modal y avisos */
.modal-backdrop { position: fixed; inset: 0; background: rgba(5, 6, 8, .55); backdrop-filter: blur(6px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade .18s both; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); animation: rise .22s var(--ease) both; }
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 22px 24px 0; }
.modal-body { padding: 14px 24px 24px; }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { display: flex; gap: 10px; align-items: flex-start; min-width: 280px; max-width: 420px; padding: 12px 14px; border-radius: 14px; font-size: 13.5px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); animation: rise .22s var(--ease) both; }
.toast svg { width: 18px; height: 18px; flex: none; color: var(--ok); margin-top: 1px; }
.toast.error svg { color: var(--danger); }
.session-warn { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 150; display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 18px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); animation: rise .25s var(--ease) both; font-size: 13.5px; }
.session-warn svg { width: 18px; height: 18px; color: var(--warn); }

/* Paleta de comandos */
.palette-back { position: fixed; inset: 0; z-index: 120; background: rgba(5, 6, 8, .5); backdrop-filter: blur(5px); display: flex; justify-content: center; padding-top: 12vh; animation: fade .15s both; }
.palette { width: min(620px, calc(100% - 32px)); max-height: 64vh; display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); animation: rise .2s var(--ease) both; }
.palette .q { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette .q svg { width: 18px; height: 18px; color: var(--text-3); }
.palette .q input { flex: 1; height: 56px; border: 0; background: none; outline: none; font-size: 16px; color: var(--text); }
.palette .res { overflow-y: auto; padding: 8px; }
.palette .grp { font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 10px 10px 4px; }
.palette .opt { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 11px; cursor: pointer; }
.palette .opt[aria-selected="true"] { background: var(--surface-2); }
.palette .opt .t b { display: block; font-weight: 600; font-size: 14px; }
.palette .opt .t span { font-size: 12px; color: var(--text-3); }
.palette .opt > svg { width: 18px; height: 18px; color: var(--text-2); margin: 0 9px; }
.palette .hint { display: flex; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }

/* ---------- Inicio de sesión ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 46%) 1fr; }
.auth-brand { position: relative; color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 44px 52px; overflow: hidden;
  background: radial-gradient(700px 420px at 20% 15%, rgba(227, 31, 29, .22), transparent 60%), radial-gradient(600px 500px at 90% 100%, rgba(140, 150, 170, .14), transparent 60%), linear-gradient(160deg, #141519, #08080a 70%); }
.auth-brand::before { content: ""; position: absolute; top: -10%; bottom: -10%; right: 70px; width: 70px; transform: skewX(-8deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, .9) 0 14px, transparent 14px 26px, var(--red) 26px 70px); opacity: .9; box-shadow: 0 0 60px rgba(227, 31, 29, .35); }
.auth-brand > * { position: relative; max-width: calc(100% - 180px); }
.auth-brand img { width: 92px; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .6)); }
.auth-brand .tagline { font: 700 46px/1.02 var(--font-num); letter-spacing: .005em; max-width: 12ch; background: var(--silver); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand .foot { color: #8b8e97; font-size: 12.5px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: min(410px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-card); padding: 34px 32px; }
.auth-card h1 { margin-bottom: 6px; font-size: 24px; }
.auth-card .lead { color: var(--text-2); margin-bottom: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .btn-primary { height: 44px; font-size: 14.5px; }
.auth-links { margin-top: 18px; font-size: 13.5px; text-align: center; }
.auth-links a { color: var(--text-2); }
.qr { background: #fff; padding: 10px; border-radius: 14px; width: 210px; display: block; margin: 0 auto; }
.secret { letter-spacing: .12em; font-size: 13px; word-break: break-all; }

/* ---------- Inicio ---------- */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 26px 28px; margin-bottom: 26px; border-radius: var(--r-xl); position: relative; overflow: hidden;
  background: radial-gradient(500px 220px at 100% 0%, rgba(227, 31, 29, .18), transparent 70%), linear-gradient(135deg, var(--surface), var(--surface-2)); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.hero h1 { font-size: 28px; }
.hero p { margin: 6px 0 0; color: var(--text-2); }
.hero .clock { text-align: right; }
.hero .clock b { font: 700 40px/1 var(--font-num); display: block; }
.hero .clock span { color: var(--text-3); font-size: 13px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.module-card { display: flex; gap: 14px; align-items: center; padding: 16px; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card); transition: transform .18s var(--ease), border-color .18s, box-shadow .18s; }
.module-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.module-card .t { min-width: 0; flex: 1; }
.module-card b { display: block; font-weight: 650; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.module-card span { font-size: 12.5px; color: var(--text-3); }
.module-card .go { width: 16px; height: 16px; color: var(--text-3); transition: transform .18s, color .18s; }
.module-card:hover .go { transform: translateX(3px); color: var(--red); }
.section-title { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--text-2); margin: 28px 0 12px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Permisos */
.perm-module { border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 10px; background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; }
.perm-module > header { display: flex; align-items: center; gap: 12px; padding: 13px 18px; }
.perm-module > .perm-list { border-top: 1px solid var(--border); padding: 14px 18px 16px 48px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 20px; background: var(--surface-2); }
.perm-module.off > .perm-list { display: none; }
.dropzone { display: block; border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); padding: 38px 24px; text-align: center; color: var(--text-2); cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone:hover { border-color: var(--text-3); }
.dropzone.over { border-color: var(--red); background: var(--red-soft); }
.dropzone .ico { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--surface); color: var(--red); box-shadow: var(--shadow-card); }
.dropzone .ico svg { width: 22px; height: 22px; }
.check-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; }
.check-list .mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; background: var(--ok); }
.check-list .mark.bad { background: var(--danger); }
.check-list .mark.warn { background: var(--warn); }

@media (max-width: 1200px) { .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span-2 { grid-column: auto; } }
@media (max-width: 900px) {
  .with-sidebar, html.sb-collapsed .with-sidebar:not(.no-sidebar) { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px; background: var(--surface); }
  .sidebar .side-links { flex-direction: row; overflow-x: auto; }
  .sidebar .side-group, .sidebar-title, .side-foot { display: none; }
  .side-link { width: auto; }
  .side-link[aria-current="page"]::before { display: none; }
  .grid-2, .grid-3, .grid-4, .grid-5, .form-grid { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 44px; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { min-height: 190px; padding: 24px; }
  .auth-brand img { width: 58px; }
  .auth-brand .tagline { font-size: 30px; }
  .auth-brand::before { right: 20px; width: 46px; background: linear-gradient(90deg, rgba(255, 255, 255, .9) 0 9px, transparent 9px 17px, var(--red) 17px 46px); }
  .auth-brand > * { max-width: calc(100% - 80px); }
  .user-btn .who, .brand-name, .search-btn span, .search-btn kbd, .topbar-right > .nav-btn span { display: none; }
  .module-frame-wrap { padding: 8px; }
  .module-frame { height: calc(100vh - var(--topbar-h) - 70px); }
  .hero { flex-direction: column; align-items: flex-start; }
  .hero .clock { text-align: left; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.tile svg { width: 18px; height: 18px; }
.tile.lg svg { width: 21px; height: 21px; }
.page-head p svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--ok); }
.panel-head h3 svg, section > h3 svg { width: 17px; height: 17px; color: var(--text-3); }
.spark svg, svg.spark { width: 100%; height: 100%; display: block; }
a.panel.kpi:hover { border-color: var(--border-strong); }
.chart-wrap .ax { position: absolute; font-size: 11px; color: var(--text-3); pointer-events: none; white-space: nowrap; line-height: 1; font-variant-numeric: tabular-nums; }
.chart-wrap .ay { left: 4px; background: color-mix(in srgb, var(--surface) 70%, transparent); padding: 1px 3px; border-radius: 4px; }
.chart-wrap .ax0, .chart-wrap .axm, .chart-wrap .ax1 { bottom: 4px; }
.chart-wrap .ax0 { left: 4px; } .chart-wrap .axm { left: 50%; transform: translateX(-50%); } .chart-wrap .ax1 { right: 4px; }
/* Tamaño base de todos los iconos (cada contexto puede ajustarlo con un selector más específico) */
.ico-svg { width: 18px; height: 18px; flex: none; }
.module-banner .ico-svg { width: 18px; height: 18px; color: var(--warn); }
h2 > .ico-svg, h3 > .ico-svg { width: 17px; height: 17px; vertical-align: -3px; margin-right: 4px; color: var(--text-3); }
/* Vista de módulo de borde a borde: sin marco, margen ni esquinas, para que el módulo se vea integrado */
.module-frame-wrap, .no-sidebar .module-frame-wrap { padding: 0; }
.module-frame { height: calc(100vh - var(--topbar-h)); border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.module-banner { margin: 0; border-radius: 0; border-width: 0 0 1px; }
.module-banner + .module-frame { height: calc(100vh - var(--topbar-h) - 40px); }
@media (max-width: 900px) { .module-frame-wrap { padding: 0; } .module-frame { height: calc(100vh - var(--topbar-h) - 52px); } }
.auth-brand .brand-sub { margin-top: 10px; color: #a3a6ae; font-size: 15px; font-weight: 500; letter-spacing: .02em; }
/* Barra indeterminada mientras el servidor procesa */
.bar.busy > i { width: 35% !important; animation: barbusy 1.2s ease-in-out infinite; background: linear-gradient(90deg, #ff6b4a, var(--red)); }
@keyframes barbusy { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
