/* Centinela console — no external resources */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --muted-soft: #e2e8f0;
  --side-bg: #0b1220;
  --side-bg-2: #111a2e;
  --side-text: #cbd5e1;
  --side-text-2: #64748b;
  --side-active: #1e293b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --mod-ssh: #6366f1;
  --mod-mail: #0ea5e9;
  --mod-ftp: #14b8a6;
  --mod-panel: #a855f7;
  --mod-web: #f59e0b;
  --mod-waf: #ef4444;
  --mod-captcha: #22c55e;
  --mod-honeypot: #d946ef;
  --mod-dos: #f97316;
  --mod-other: #64748b;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; }
.break { word-break: break-all; }

/* ------------------------------------------------------------ layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .01em;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; flex: 0 0 auto; }
.nav { display: flex; flex-direction: column; padding: 10px 10px; gap: 2px; overflow-y: auto; flex: 1; }
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--side-text-2);
  padding: 14px 10px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--side-text);
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .05); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.nav svg { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.sidebar-foot { padding: 12px 18px; font-size: 11px; color: var(--side-text-2); border-top: 1px solid rgba(255, 255, 255, .06); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title { font-size: 19px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.tenant-switch { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.tenant-switch select { min-width: 180px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
}
.user-chip:hover { text-decoration: none; border-color: var(--border-strong); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; text-transform: uppercase;
}
.tenant-banner {
  background: var(--warning-soft);
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
  padding: 8px 28px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.view { padding: 24px 28px 48px; outline: none; max-width: 1500px; width: 100%; }

/* ------------------------------------------------------------ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 10px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.stat.s-danger::before { background: var(--danger); }
.stat.s-warning::before { background: var(--warning); }
.stat.s-success::before { background: var(--success); }
.stat.s-muted::before { background: var(--text-3); }
.stat-label { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.stat-value small { font-size: 15px; color: var(--text-3); font-weight: 600; }
.stat-hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); background: var(--surface-2); font-weight: 650; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f8fafc; }
.table tr.clickable { cursor: pointer; }
.table td.actions { white-space: nowrap; text-align: right; }
.table .empty { text-align: center; color: var(--text-3); padding: 28px 14px; }
.detail-cell { max-width: 520px; color: var(--text-2); word-break: break-word; }
.detail-cell .expand { margin-left: 6px; font-size: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; }
.kv dt { color: var(--text-2); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

/* ------------------------------------------------------------ badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 18px;
  white-space: nowrap;
  background: var(--muted-soft);
  color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.b-success { background: var(--success-soft); color: #15803d; }
.b-danger { background: var(--danger-soft); color: #b91c1c; }
.b-warning { background: var(--warning-soft); color: #b45309; }
.b-info { background: var(--primary-soft); color: #1d4ed8; }
.b-muted { background: var(--muted-soft); color: #475569; }
.b-black { background: var(--danger-soft); color: #b91c1c; }
.b-grey { background: var(--warning-soft); color: #b45309; }
.b-white { background: var(--success-soft); color: #15803d; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--mod-other); flex: 0 0 auto; }
.mod-ssh { background: var(--mod-ssh); }
.mod-mail { background: var(--mod-mail); }
.mod-ftp { background: var(--mod-ftp); }
.mod-panel { background: var(--mod-panel); }
.mod-web { background: var(--mod-web); }
.mod-waf { background: var(--mod-waf); }
.mod-captcha { background: var(--mod-captcha); }
.mod-honeypot { background: var(--mod-honeypot); }
.mod-dos { background: var(--mod-dos); }
.mod-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 550; }

/* ------------------------------------------------------------ chart */
.chart { width: 100%; height: 220px; display: block; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 3; }
.chart text { fill: var(--text-3); font-size: 10px; font-family: var(--font); }
.chart rect.bar:hover { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 90px 1fr 50px; align-items: center; gap: 10px; font-size: 13px; }
.hbar-track { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; background: var(--mod-other); }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span, .field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-height: 34px;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
textarea.tall { min-height: 260px; }
textarea.prose { font-family: var(--font); font-size: 14px; min-height: 70px; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
details summary { cursor: pointer; margin-bottom: 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-2); }
input[type=number] { max-width: 140px; }
.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--primary); flex: 0 0 auto; }
.check b { font-weight: 600; }
.check .hint { display: block; font-size: 12px; color: var(--text-3); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > .field { flex: 1 1 180px; margin-bottom: 0; }
.form-row > .field.narrow { flex: 0 0 160px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 18px; }
.form-error { background: var(--danger-soft); color: #991b1b; border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; margin-bottom: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .field.wide { min-width: 220px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 18px 0 10px; font-weight: 700; }
.section-title:first-child { margin-top: 0; }
.rule-input { max-width: 100px !important; }

/* ------------------------------------------------------------ buttons */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  min-height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--surface); border-color: #fca5a5; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-sm { padding: 4px 10px; min-height: 28px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-link { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 0; font: inherit; font-size: inherit; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 9px 14px;
  color: var(--text-2);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented a { padding: 5px 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); background: var(--surface); }
.segmented a + a { border-left: 1px solid var(--border-strong); }
.segmented a.active { background: var(--primary); color: #fff; }
.segmented a:hover { text-decoration: none; }

.pager { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }

.copy-box {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
}
.copy-box code { flex: 1; color: inherit; align-self: center; }
.copy-box .btn { background: #1e293b; color: #e2e8f0; border-color: #334155; }
.copy-box .btn:hover { background: #334155; }

pre.json {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: auto;
  max-height: 360px;
  font-family: var(--mono);
  font-size: 12px;
  margin: 0;
}

.notice { border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.notice.info { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.notice.warn { background: var(--warning-soft); border-color: #fcd34d; color: #92400e; }

.loading { padding: 40px; text-align: center; color: var(--text-3); }
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ login */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 20% 10%, #1e3a8a 0%, transparent 60%), linear-gradient(160deg, #0b1220 0%, #111a2e 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 14px;
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand .logo { width: 42px; height: 42px; }
.login-title { font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.login-sub { color: var(--text-2); font-size: 13px; }

/* ------------------------------------------------------------ toasts & modal */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 11px 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #f1f5f9;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  border-left: 4px solid var(--primary);
  animation: toast-in .18s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 90;
}
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ------------------------------------------------------------ IP page */
.ip-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ip-head .ip { font-family: var(--mono); font-size: 22px; font-weight: 700; }
.verdict { font-size: 13px; font-weight: 650; padding: 4px 12px; border-radius: 999px; }
.verdict.v-black { background: var(--danger-soft); color: #b91c1c; }
.verdict.v-grey { background: var(--warning-soft); color: #b45309; }
.verdict.v-white { background: var(--success-soft); color: #15803d; }
.verdict.v-clean { background: var(--muted-soft); color: var(--text-2); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .grid-2-1, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: 0 0 auto; height: auto; position: static; }
  .brand { padding: 12px 16px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 6px 8px; }
  .nav-section, .sidebar-foot { display: none; }
  .nav a { white-space: nowrap; }
  .topbar { padding: 12px 16px; position: static; flex-wrap: wrap; }
  .view { padding: 16px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .tenant-banner { padding: 8px 16px; }
}

/* Phase 2 */
a.stat { display: block; color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.card-head .field.inline { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 0; }
td.path-cell { min-width: 340px; max-width: 560px; overflow-wrap: anywhere; }

/* Server activity: one small chart per measure */
.act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.act-tile { position: relative; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px 10px; background: var(--surface); }
.act-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.act-swatch { width: 10px; height: 10px; flex: 0 0 auto; }
.act-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; color: var(--text); }
.act-hint { font-size: 11.5px; color: var(--text-3); min-height: 16px; }
.act-plot { margin-top: 8px; cursor: crosshair; }
.act-chart { display: block; width: 100%; height: 64px; overflow: visible; }
.act-chart .gridline { stroke: var(--border); stroke-dasharray: 3 3; }
.act-chart .baseline { stroke: var(--border-strong); }
.act-chart .hover-band { fill: var(--text); opacity: .07; }
.act-axis { display: flex; justify-content: space-between; margin-top: 3px; font-size: 10.5px; color: var(--text-3); }
.act-tip { position: absolute; z-index: 5; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  background: var(--text); color: #fff; font-size: 11.5px; padding: 4px 8px; border-radius: 5px; box-shadow: var(--shadow-lg); }
.act-tip.tip-left { transform: translate(-100%, -100%); }
.act-tip.tip-right { transform: translate(0, -100%); }
.act-note { margin: 12px 0 6px; }
#activity details .act-table { margin-top: 10px; max-height: 360px; overflow: auto; }
