:root {
  --bg: #0f1419;
  --bg-2: #171d25;
  --panel: #1c2430;
  --line: #2b3645;
  --text: #e7eef7;
  --muted: #93a4b8;
  --accent: #3d8bfd;
  --good: #3dd68c;
  --warn: #f0b429;
  --crit: #f07178;
  --font: "Segoe UI", "IBM Plex Sans", "Source Sans 3", system-ui, sans-serif;
  --mono: "Cascadia Mono", "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2740 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #13251f 0%, transparent 45%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #121820, #0e1319);
  border-right: 1px solid var(--line);
  padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1rem;
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; gap: .75rem; align-items: center; margin-bottom: .5rem; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2f6fed, #1f9d6e);
  font-weight: 700;
}
.brand strong { display: block; letter-spacing: .04em; font-size: .95rem; }
.brand small { color: var(--muted); }
.sidebar nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.sidebar nav .nav-group {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: .85rem .65rem .25rem;
  opacity: .85;
}
.sidebar nav .nav-group:first-child { margin-top: .15rem; }
.sidebar nav a {
  color: var(--muted); padding: .45rem .65rem; border-radius: 8px; text-decoration: none;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: var(--panel); color: var(--text);
}
.logout button, button, .btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .9rem; cursor: pointer; font: inherit;
}
.btn-primary { background: #234987; border-color: #3d8bfd; }
.btn-danger { background: #4a2328; border-color: var(--crit); }
.btn-sm { padding: .3rem .55rem; font-size: .8rem; }
.threat-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .35rem; }
.filter-tabs .btn.active { background: #234987; border-color: #3d8bfd; color: var(--text); }
.content { padding: 1.5rem 1.75rem 2.5rem; }
h1 { margin: 0 0 .35rem; font-size: 1.55rem; letter-spacing: .02em; }
h2 { margin: 1.5rem 0 .75rem; font-size: 1.1rem; color: #d7e3f2; }
.sub { color: var(--muted); margin-bottom: 1.25rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .85rem; }
.cards-equipo { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: .9rem 1rem; min-height: 96px;
}
.card.wide { grid-column: span 2; }
.card .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.card .value { font-size: 1.35rem; margin-top: .35rem; font-family: var(--mono); }
.card .value.text { font-size: .98rem; font-family: var(--font); line-height: 1.35; word-break: break-word; }
.card .hint { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.dash-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  align-items: flex-start; margin-bottom: .5rem;
}
.dash-head h1 { margin-bottom: .25rem; }
.dash-id { margin-top: -.5rem !important; margin-bottom: .5rem !important; font-size: .85rem; }
.dash-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
tr.row-crit td { background: rgba(240,113,120,.08); }

.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; letter-spacing: .04em;
}
.badge.good, .status-GOOD, .status-ONLINE, .status-OK, .status-SECURE { color: var(--good); background: rgba(61,214,140,.12); }
.badge.warn, .status-WARNING { color: var(--warn); background: rgba(240,180,41,.12); }
.badge.crit, .status-CRITICAL, .status-OFFLINE, .status-FAILED { color: var(--crit); background: rgba(240,113,120,.12); }
.badge.unk, .status-UNKNOWN { color: var(--muted); background: rgba(147,164,184,.12); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .65rem .8rem; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
code, .mono { font-family: var(--mono); font-size: .88rem; }

.flash { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.flash.ok { background: rgba(61,214,140,.12); border: 1px solid rgba(61,214,140,.35); }
.flash.err { background: rgba(240,113,120,.12); border: 1px solid rgba(240,113,120,.35); }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card {
  width: min(420px, 100%); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 1.75rem; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-card h1 { font-size: 1.4rem; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field label { color: var(--muted); font-size: .85rem; }
.field input, .field select, .field textarea {
  background: #0f1419; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: .65rem .75rem; font: inherit;
}
.validation { color: var(--crit); margin-bottom: .75rem; }
.hero-status { display: flex; align-items: center; gap: .75rem; margin: 1rem 0 1.25rem; }
.hero-status .level { font-size: 1.4rem; font-weight: 700; }

.attention-panel {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}
.attention-panel.status-CRITICAL { border-color: color-mix(in srgb, var(--crit) 55%, var(--line)); }
.attention-panel.status-WARNING { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.attention-panel.status-GOOD { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.attention-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .75rem;
  margin-bottom: .5rem;
}
.attention-head h2 { margin: 0; font-size: 1.15rem; }
.attention-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.attention-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .2rem .75rem;
  padding: .55rem .65rem;
  border-radius: 8px;
  background: rgba(0,0,0,.18);
}
.attention-list li strong { grid-column: 1; }
.attention-list li .muted { grid-column: 1; font-size: .9rem; }
.attention-list li a { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.attention-list li.status-CRITICAL { box-shadow: inset 3px 0 0 var(--crit); }
.attention-list li.status-WARNING { box-shadow: inset 3px 0 0 var(--warn); }

.timeline { display: grid; gap: .75rem; margin: 1rem 0 2rem; }
.timeline-item {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: .75rem 1rem;
  padding: .75rem .9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0,0,0,.16);
}
.timeline-item time { color: var(--muted); font-size: .85rem; }
.timeline-item.status-Critical { box-shadow: inset 3px 0 0 var(--crit); }
.timeline-item.status-Warning { box-shadow: inset 3px 0 0 var(--warn); }
.timeline-item.status-Info { box-shadow: inset 3px 0 0 var(--good); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.panel-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.check { display: flex; align-items: center; gap: .55rem; color: var(--text); margin: .35rem 0 .6rem; }
.check input { width: 1rem; height: 1rem; }

.help-list { margin: .75rem 0 0; padding-left: 1.2rem; line-height: 1.55; }
details.panel-box > summary { cursor: pointer; list-style-position: outside; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 .75rem; }
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: rgba(6, 10, 16, .72); align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  width: min(640px, 100%); max-height: min(90vh, 900px); overflow: auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.25rem 1.35rem; box-shadow: 0 24px 80px rgba(0,0,0,.45);
}
.modal-card h3 { margin: 0 0 .75rem; font-size: 1.15rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.table-actions { display: flex; flex-wrap: wrap; gap: .35rem; }

/* Utility / CSP-friendly replacements for former inline styles */
.mt-0 { margin-top: 0; }
.mt-neg-5 { margin-top: -.5rem; }
.mt-25 { margin-top: .25rem; }
.mt-35 { margin-top: .35rem; }
.mt-65 { margin-top: .65rem; }
.mt-75 { margin-top: .75rem; }
.mt-85 { margin-top: .85rem; }
.mt-1 { margin-top: 1rem; }
.mt-125 { margin-top: 1.25rem; }
.mt-15 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 1rem; }
.mb-125 { margin-bottom: 1.25rem; }
.my-35-75 { margin: .35rem 0 .75rem; }
.my-75 { margin: .75rem 0; }
.fs-75 { font-size: .75rem; }
.fs-78 { font-size: .78rem; }
.fs-8 { font-size: .8rem; }
.fs-85 { font-size: .85rem; }
.fs-105 { font-size: 1.05rem; }
.fs-1 { font-size: 1rem; }
.inline-form { display: inline; }
.btn-block { width: 100%; }
.is-hidden { display: none; }
.pre-scroll { overflow: auto; white-space: pre-wrap; }
.investigate-box {
  display: none;
  margin-top: 1rem;
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
}
.investigate-box.is-visible { display: block; }
.eyebrow {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.id-line { font-size: 1.05rem; margin: .35rem 0; }
.guide-line { font-size: .8rem; margin-top: .25rem; }
.hint-sm { margin: .35rem 0 0; font-size: .85rem; }
.row-hot { background: rgba(61, 139, 253, .08); }
.flex-between {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: space-between;
  align-items: flex-start;
}
.text-good { color: var(--good); }
.text-crit { color: var(--crit); }
.word-break-all { word-break: break-all; }
.checklist { margin: .65rem 0 0; padding-left: 1.2rem; line-height: 1.55; }

@media (max-width: 1100px) {
  .cards-equipo { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.settings-toc {
  display: flex; flex-wrap: wrap; gap: .4rem;
  position: sticky; top: .5rem; z-index: 4;
  padding: .55rem .65rem; margin: 0 0 1rem;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(6px);
}
.settings-toc a {
  color: var(--muted); text-decoration: none;
  padding: .35rem .65rem; border-radius: 999px;
  border: 1px solid transparent; font-size: .85rem;
}
.settings-toc a:hover { color: var(--text); background: var(--panel); }
.settings-toc a.active {
  color: var(--text); background: #234987; border-color: #3d8bfd;
}
.settings-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.settings-section { margin-bottom: 1.25rem; scroll-margin-top: 4rem; }
.settings-section > h2 { margin-top: .35rem; }
.settings-help { margin: 0 0 .85rem; }
.settings-help summary { cursor: pointer; }
.settings-instance .id-line { font-size: 1rem; }
body.settings-focus .settings-section { display: none; }
body.settings-focus .settings-section.is-active { display: block; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav .nav-group { width: 100%; margin: .5rem .35rem .1rem; }
  .card.wide { grid-column: span 1; }
  .cards-equipo { grid-template-columns: 1fr 1fr; }
}