:root {
  --bg-main: #eef1f6;
  --bg-sidebar: #0c1424;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-card: #e5e9f0;
  --border-focus: #93c5fd;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-glow: rgba(37, 99, 235, 0.15);
  --accent: #2563eb;
  --success: #16a34a;
  --success-light: #dcfce7;
  --success-glow: rgba(22, 163, 74, 0.25);
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --danger-glow: rgba(220, 38, 38, 0.2);
  --purple: #7c3aed;
  --purple-light: #ede9fe;

  --text-main: #111827;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;

  --font-sans: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: all 0.2s ease;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
}

/* App Layout */
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 22px 14px;
  position: relative;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 20px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #ffffff;
}

.badge-phase {
  font-size: 10px;
  font-family: var(--font-sans);
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  padding-top: 6px;
  overflow-y: auto;
  min-height: 0;
}

.nav-item {
  display: block;
  padding: 13px 10px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  color: #ffffff;
}

.nav-item:disabled {
  color: #37445a;
  cursor: not-allowed;
}

.nav-item:disabled:hover {
  color: #37445a;
}

.nav-section-label {
  padding: 10px 10px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #4b5a73;
}

.nav-section-label:not(:first-child) {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 14px;
}

.nav-item.active {
  color: #ffffff;
}

/* Item counters are kept in the DOM (app.js writes to them directly) but
   not shown — the reference menu is a plain flat list with no badges. */
.nav-count {
  display: none;
}

.sidebar-footer {
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.server-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.pulse-indicator {
  width: 9px;
  height: 9px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(22, 163, 74, 0.5);
  animation: pulse-ring 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.status-label {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.status-sub {
  font-size: 11px;
  color: #64748b;
  font-family: var(--font-mono);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 32px;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.topbar-title h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-main);
}

.topbar-title p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-token-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-card);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: var(--shadow-card);
}

.token-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.quick-token-badge code {
  color: var(--primary-dark);
  font-family: var(--font-mono);
  font-size: 11px;
}

.copy-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.copy-btn:hover {
  opacity: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline {
  background: #ffffff;
  border: 1px solid var(--border-card);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.btn-danger {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fecaca;
}

.btn-warning {
  background: var(--warning-light);
  border: 1px solid #fde68a;
  color: #92400e;
}

.btn-warning:hover {
  background: #fde68a;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Tab Management */
.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: #d1d5db;
}

.kpi-header {
  margin-bottom: 10px;
}

.kpi-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-sans);
  color: var(--text-main);
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-dim);
}

/* Only the two states that genuinely need to stand out — everything else
   stays neutral ink, per the "2-3 colors max" rule. */
.highlight-red .kpi-value { color: var(--danger); }
.highlight-yellow .kpi-value { color: var(--warning); }

/* Panel Card */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.panel-counter {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.table-search-box input {
  background: #f9fafb;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  width: 280px;
  outline: none;
  transition: var(--transition);
}

.table-search-box input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Data Table */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--border-card);
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #f1f2f4;
  vertical-align: middle;
  color: var(--text-main);
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: #f9fafb;
}

/* Status Badges */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.status-tag.online {
  background: var(--success-light);
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.status-tag.offline {
  background: #f3f4f6;
  color: var(--text-muted);
  border: 1px solid var(--border-card);
}

.status-tag.isolated {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.status-tag.warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid #fde68a;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Deployment Tab */
.deployment-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.command-box {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 16px;
}

.command-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  font-weight: 700;
}

.command-box code {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #7dd3fc;
  word-break: break-all;
  line-height: 1.5;
}

.steps-list {
  padding-left: 20px;
  display: grid;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.steps-list strong {
  color: var(--text-main);
}

.tokens-list {
  display: grid;
  gap: 10px;
}

.token-item {
  background: #f9fafb;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.token-code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--primary-dark);
}

.token-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Agent Detail Page (device page, clean sidebar + tabs layout) */
.data-table-clickable tbody tr {
  cursor: pointer;
}

.data-table-clickable tbody tr:hover {
  background: #f0f6ff;
}

.breadcrumb-link {
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.device-detail-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.device-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 16px;
}

.device-id-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.device-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.device-sidebar h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 5px;
  word-break: break-word;
  line-height: 1.3;
}

/* Real differentiator from a stock device page: an actual computed risk
   score for the endpoint (agent.risk_score), not just an online/offline
   badge. */
.device-risk-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: #f9fafb;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 14px;
}

.device-risk-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  font-weight: 700;
}

.device-risk-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

.device-meta-list {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-card);
}

.device-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.device-actions {
  display: grid;
  gap: 6px;
}

.device-actions .btn {
  width: 100%;
  justify-content: center;
}

.device-main {
  flex: 1;
  min-width: 0;
}

.device-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-card);
  margin-bottom: 20px;
}

.device-tab-btn {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.device-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.device-tab-pane {
  display: none;
}

.device-tab-pane.active {
  display: block;
}

.clean-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.clean-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-card);
}

.clean-table td {
  padding: 10px;
  border-bottom: 1px solid #f1f3f7;
  vertical-align: middle;
  color: var(--text-main);
}

.clean-table tr:last-child td {
  border-bottom: none;
}

.event-type-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.module-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-right: 8px;
  background: #f3f4f6;
  color: var(--text-muted);
}

.rule-row {
  cursor: pointer;
}

.rule-row:hover td,
.rule-row.open td {
  background: var(--bg-card-hover);
}

.mode-select {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
}

.mode-select.mode-alert {
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

.mode-select.mode-off {
  color: var(--text-dim);
}

.rule-reset {
  color: var(--primary);
}

.rule-samples {
  padding: 10px 4px 10px;
  font-size: 12px;
}

.rule-sample-line {
  padding: 2px 0;
  color: var(--text-main);
  word-break: break-all;
}

.rule-sample-count {
  font-family: var(--font-mono);
  color: var(--text-muted);
  display: inline-block;
  min-width: 46px;
}

.rule-source-row td {
  padding: 0 10px 12px;
  background: var(--bg-card-hover);
}

.rule-source {
  margin: 0;
  padding: 12px 14px;
  max-height: 360px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-main);
  white-space: pre;
}

.clean-table .event-time {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

.clean-table .event-desc-link {
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  white-space: nowrap;
}

.event-detail-row td {
  background: #f9fafb;
}

.event-detail-row pre {
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
  margin: 0;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f1f3f7;
  font-size: 12px;
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-row .kv-label {
  color: var(--text-muted);
}

.kv-row .kv-value {
  color: var(--text-main);
  font-weight: 600;
}

.panel-subsection-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  margin: 18px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-card);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: 16px;
  width: 760px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  animation: modalScale 0.2s ease;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-card);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Helpers */
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 13px;
}

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-6 { margin-top: 24px; }
.flex { display: flex; }
.gap-3 { gap: 12px; }

/* ========================================================
   TIMELINE & SUB-TABS
   ======================================================== */
.timeline-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  background: #ffffff;
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Full timeline list (Línea Temporal Completa tab) — a dense row list with
   a thin color-coded left border per event type, not a stack of individual
   icon-and-card items; keeps a long event history scannable instead of
   reading as a pile of identical boxes. */
.full-timeline-list {
  max-height: 650px;
  overflow-y: auto;
}

.full-timeline-row {
  display: flex;
  gap: 12px;
  padding: 9px 10px;
  border-bottom: 1px solid #f1f3f7;
  border-left: 3px solid transparent;
}

.full-timeline-row:last-child {
  border-bottom: none;
}

.full-timeline-time {
  width: 72px;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  padding-top: 1px;
}

.full-timeline-body {
  flex: 1;
  min-width: 0;
}

.full-timeline-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.full-timeline-summary {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.full-timeline-toggle {
  font-size: 11px;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin-top: 4px;
  font-weight: 600;
}

.timeline-details {
  margin-top: 8px;
  background: #f8fafc;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary-dark);
  word-break: break-all;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 24px 0;
  border-bottom: 1px solid var(--border-card);
  background: #fafbfc;
}

.modal-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition);
}

.modal-tab-btn:hover {
  color: var(--text-main);
}

.modal-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ========================================================
   ALERTS & INCIDENTS
   ======================================================== */
.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 18px 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.alert-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
}

.alert-card.critical::before { background: var(--danger); }
.alert-card.high::before { background: var(--warning); }
.alert-card.medium::before { background: var(--primary); }

.alert-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.alert-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.alert-title-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.alert-badge {
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.alert-badge.critical { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-badge.high { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-badge.medium { background: #dbeafe; color: var(--primary-dark); border: 1px solid #bfdbfe; }
.alert-badge.low { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }
.alert-badge.info { background: #f3f4f6; color: var(--text-muted); border: 1px solid var(--border-card); }

.mitre-tag {
  background: var(--purple-light);
  color: var(--purple);
  border: 1px solid #ddd6fe;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
}

.alert-summary-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.alert-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-card);
  flex-wrap: wrap;
  gap: 8px;
}

.alert-host-info {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ==========================================
   INCIDENTES XDR & BÓVEDA CUARENTENA
   ========================================== */
.incidents-container {
  display: grid;
  gap: 16px;
}

.incident-card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.incident-card:hover {
  border-color: #d1d5db;
}

.incident-card.critical {
  border-left: 4px solid var(--danger);
}

.incident-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.incident-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.incident-badge.critical { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.incident-badge.high { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }

.incident-type-tag {
  background: var(--purple-light);
  color: var(--purple);
  border: 1px solid #ddd6fe;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
}

.incident-title-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-left: 8px;
}

.affected-hosts-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.host-chip {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #bfdbfe;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
}

.ai-narrative-box {
  background: #faf5ff;
  border: 1px solid var(--purple-light);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 14px;
  color: var(--text-main);
  font-size: 13px;
  line-height: 1.6;
}

.ai-narrative-box h3, .ai-narrative-box h4 {
  color: var(--purple);
  font-size: 13px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-narrative-box ul {
  padding-left: 20px;
  margin-bottom: 8px;
}

.incident-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border-card);
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================
   SIEM SEARCH BAR (Timeline tab)
   ========================================== */
.siem-field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 4px;
}

.siem-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: var(--transition);
}

.siem-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* One neutral style for every event type — the label text already says
   what it is; color is reserved for severity, not category. */
.event-type-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-block;
  background: #f3f4f6;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sev-text {
  font-weight: 700;
  font-size: 12px;
}
.sev-text.CRITICAL { color: var(--danger); }
.sev-text.HIGH { color: #b45309; }
.sev-text.MEDIUM { color: var(--primary-dark); }
.sev-text.LOW { color: #15803d; }
.sev-text.INFO { color: var(--text-muted); }

/* ==========================================
   SIEM LOG EXPLORER (field picker + compact table)
   ========================================== */
.siem-explorer {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-width: 0;
}

.field-picker {
  flex: 0 0 190px;
  background: #fafbfc;
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 14px;
}

.field-picker-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.field-picker-hint {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
  line-height: 1.3;
}

.field-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  border-radius: 6px;
}

.field-picker-item:hover {
  background: #eef1f6;
}

.field-picker-item input {
  cursor: pointer;
  accent-color: var(--primary);
}

/* The table area owns the remaining width and never scrolls sideways by
   default — the minimal column set (chevron/hora/equipo/tipo/info) is sized
   to always fit; adding many extra fields can still wrap or scroll, which
   is expected since you explicitly asked for more columns. */
.siem-table-wrap {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.siem-table {
  table-layout: fixed;
  width: 100%;
}

.siem-table th, .siem-table td {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.siem-table td.siem-cell-info {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0; /* forces the flexible column to actually respect ellipsis in a fixed-layout table */
  cursor: pointer;
}

.siem-expand-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  width: 22px;
  padding: 0;
  transition: transform 0.15s ease;
}

.siem-expand-btn.open {
  transform: rotate(90deg);
  color: var(--primary);
}

tr.siem-row {
  cursor: pointer;
}

tr.siem-detail-row td {
  background: #f8fafc;
  padding: 16px 20px;
  white-space: normal;
  border-bottom: 1px solid var(--border-card);
}

.detail-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-field-box {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 8px 12px;
}

.detail-field-box .lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

.detail-field-box .val {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  font-family: var(--font-mono);
  word-break: break-all;
  margin-top: 2px;
}

.detail-summary-full {
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 14px;
  line-height: 1.5;
}

.raw-json-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.raw-json-box {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #7dd3fc;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
}

/* ===================================================================
   Sign-in page
   =================================================================== */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  font-family: var(--font-sans);
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  padding: 28px 28px 24px;
}

.login-brand {
  margin-bottom: 22px;
}

.login-brand-name {
  font-weight: 800;
  letter-spacing: 1.5px;
  font-size: 15px;
  color: var(--text-main);
}

.login-brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.login-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 14px;
}

.login-help {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.5;
}

.login-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 10px 0 4px;
}

.login-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  font-size: 14px;
  font-family: var(--font-sans);
  border: 1px solid var(--border-card);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
}

.login-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.login-code {
  font-family: var(--font-mono);
  font-size: 20px;
  letter-spacing: 6px;
  text-align: center;
  margin-top: 8px;
}

.login-submit {
  width: 100%;
  margin-top: 16px;
  justify-content: center;
}

.login-qr {
  display: flex;
  justify-content: center;
  margin: 4px 0 10px;
}

.login-qr svg {
  width: 200px;
  height: 200px;
}

.login-secret {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  word-break: break-all;
  margin-bottom: 8px;
}

.login-error {
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-light);
  border-radius: 6px;
  padding: 8px 10px;
}

/* ===================================================================
   Session bar (customer selector + user)
   =================================================================== */
.session-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.org-select {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  max-width: 240px;
}

.org-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.user-chip {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: right;
}

.user-chip-email {
  font-size: 12px;
  color: var(--text-main);
}

.user-chip-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===================================================================
   Users and customers pages
   =================================================================== */
.admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 4px 0 14px;
}

.admin-form label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.admin-form input,
.admin-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  font-size: 13px;
  font-family: var(--font-sans);
  border: 1px solid var(--border-card);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
}

.access-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f3f4f6;
  color: var(--text-muted);
  margin: 1px 4px 1px 0;
  white-space: nowrap;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  margin-right: 10px;
}

.link-btn.danger {
  color: var(--danger);
}

/* One-time credentials of a new account */
.credential-box {
  border: 1px solid var(--border-focus);
  background: var(--primary-light);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
}

.credential-text {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: #fff;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Session about to end for inactivity (session-guard.js) */
.idle-warning {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 200;
  max-width: 560px;
  background: var(--warning-light);
  color: #78350f;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

/* Sign-in page: why the person is back here */
.login-info {
  font-size: 13px;
  color: #78350f;
  background: var(--warning-light);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 14px;
}

/* Event of the Windows Security log (SIEM detail row) */
.winevent-panel {
  margin: 10px 0 14px;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.winevent-head {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border-card);
}

.winevent-message {
  margin: 0;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
  border-bottom: 1px solid var(--border-card);
}

.winevent-fields {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.winevent-fields th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-card);
}

.winevent-fields td {
  padding: 4px 12px;
  border-bottom: 1px solid #f1f3f7;
  vertical-align: top;
  word-break: break-word;
}

.winevent-name {
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
}

.winevent-value {
  font-family: var(--font-mono);
}

.winevent-resolved {
  color: var(--text-main);
}

/* Shown to provider staff inside a paused customer's console */
.paused-banner {
  background: var(--warning-light);
  color: #78350f;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
}

[data-min-role][hidden] {
  display: none !important;
}

/* The hidden attribute always wins over a component's display style. */
[hidden] {
  display: none !important;
}
