:root {
  --bg: #050910;
  --bg-soft: #08111f;
  --panel: rgba(10, 21, 38, 0.82);
  --panel-strong: #0b1728;
  --line: rgba(137, 173, 220, 0.13);
  --line-bright: rgba(70, 153, 255, 0.34);
  --text: #e8f2ff;
  --muted: #7890ad;
  --blue: #2c74ff;
  --cyan: #46defa;
  --amber: #ffb74a;
  --red: #ff496a;
  --green: #42e5a3;
  --sidebar: 242px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 75% -10%, rgba(33, 112, 255, .17), transparent 35%), var(--bg); }
button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.noise { position: fixed; inset: 0; pointer-events: none; opacity: .16; z-index: 10; background-image: linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.012) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(to bottom, #000, transparent 80%); }

.access-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; overflow: hidden; background: #03070d; }
.gate-glow { position: absolute; width: 560px; height: 560px; border-radius: 50%; background: radial-gradient(circle, rgba(34, 119, 255, .24), transparent 66%); filter: blur(15px); animation: pulse 4s ease-in-out infinite; }
.gate-card { position: relative; width: min(420px, 100%); padding: 42px; border: 1px solid rgba(75, 150, 255, .28); border-radius: 18px; text-align: center; background: linear-gradient(145deg, rgba(12, 26, 47, .96), rgba(5, 12, 23, .96)); box-shadow: 0 35px 100px rgba(0,0,0,.65), inset 0 1px rgba(255,255,255,.04); }
.gate-card::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; background: linear-gradient(120deg, transparent 20%, rgba(78, 225, 255, .28), transparent 70%); mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude; padding: 1px; }
.gate-mark { width: 76px; filter: drop-shadow(0 0 20px rgba(51, 154, 255, .35)); }
.eyebrow { margin: 0 0 7px; color: #6f9fdc; font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.gate-card h1 { margin: 10px 0 2px; font-size: clamp(37px, 10vw, 54px); letter-spacing: .18em; background: linear-gradient(90deg, #f1f8ff, #57dfff); color: transparent; background-clip: text; }
.gate-copy { margin: 0 0 35px; color: #7f96b2; font-size: 13px; letter-spacing: .12em; }
.gate-card label { display: block; margin-bottom: 8px; text-align: left; color: #9bb0c9; font-size: 12px; }
.key-field { display: flex; border: 1px solid rgba(125, 165, 215, .2); border-radius: 9px; background: rgba(1, 7, 14, .8); transition: .2s ease; }
.key-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44, 116, 255, .15); }
.key-field input { width: 100%; min-width: 0; padding: 13px 14px; color: var(--text); border: 0; outline: 0; background: transparent; }
.reveal-key { padding: 0 13px; border: 0; color: #5f86b5; background: transparent; font-size: 10px; font-weight: 800; letter-spacing: .08em; cursor: pointer; }
.primary-button { width: 100%; margin-top: 15px; padding: 13px; border: 1px solid #4a94ff; border-radius: 9px; color: #fff; background: linear-gradient(110deg, #1558d8, #2686ff); box-shadow: 0 10px 25px rgba(28, 104, 255, .24); font-size: 11px; font-weight: 900; letter-spacing: .14em; cursor: pointer; transition: .2s ease; }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.12); }
.gate-error { min-height: 18px; margin: 12px 0 0; color: #ff6f87; font-size: 12px; }
.gate-note { margin: 5px 0 0; color: #50647c; font-size: 10px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; width: var(--sidebar); padding: 23px 15px; border-right: 1px solid var(--line); background: rgba(5, 11, 20, .94); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 28px; }
.brand img { width: 39px; }
.brand strong { display: block; font-size: 16px; letter-spacing: .17em; }
.brand span { display: block; margin-top: 3px; color: #536c8c; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; letter-spacing: .11em; }
nav { display: grid; gap: 5px; }
.nav-item { position: relative; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; width: 100%; padding: 11px 12px; border: 1px solid transparent; border-radius: 8px; color: #7389a5; background: transparent; text-align: left; cursor: pointer; transition: .18s ease; }
.nav-item:hover:not(:disabled) { color: #d7e7fa; background: rgba(32, 84, 150, .1); }
.nav-item.active { color: #dcecff; border-color: rgba(55, 127, 226, .22); background: linear-gradient(90deg, rgba(35, 101, 197, .2), rgba(35, 101, 197, .04)); }
.nav-item.active::before { content: ""; position: absolute; left: -16px; width: 3px; height: 24px; border-radius: 0 4px 4px 0; background: #3da4ff; box-shadow: 0 0 13px #2d7cff; }
.nav-icon { color: #4d9fff; font-size: 18px; }
.nav-item small { padding: 3px 5px; border-radius: 4px; color: #4e6684; background: #0b192a; font-size: 7px; font-weight: 800; letter-spacing: .08em; }
.nav-item.disabled { opacity: .56; cursor: default; }
.sidebar-footer { margin-top: auto; padding: 0 9px; }
.core-status { display: flex; align-items: center; gap: 8px; padding: 12px; border: 1px solid rgba(66, 229, 163, .12); border-radius: 8px; color: #6dc5a0; background: rgba(20, 91, 63, .08); font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.core-status i, .live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.text-button { padding: 0; border: 0; color: #5fa8ff; background: none; font-size: 11px; cursor: pointer; }
.sidebar-footer .text-button { margin: 16px 11px 0; color: #607793; }

main { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; min-height: 83px; padding: 15px 30px; border-bottom: 1px solid var(--line); background: rgba(5, 10, 18, .84); backdrop-filter: blur(18px); }
.breadcrumb { margin: 0 0 4px; color: #4e6989; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; letter-spacing: .12em; }
.breadcrumb span { color: #4baeff; }
.topbar h2 { margin: 0; font-size: 17px; font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.live-pill { display: flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid rgba(66, 229, 163, .16); border-radius: 30px; color: #71d6ad; background: rgba(30, 136, 91, .08); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.live-pill i { width: 5px; height: 5px; }
.clock { color: #8da4bf; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.icon-button { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: #8ba3bf; background: #091322; cursor: pointer; }
.icon-button.loading { animation: spin 1s linear infinite; }
.content { width: min(1500px, 100%); margin: auto; padding: 30px; }
.view { display: none; }
.view.active { display: block; animation: reveal .25s ease; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 19px; }
.section-heading h3 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.last-update { margin: 0; color: #59718d; font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.metric-card, .panel { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(145deg, rgba(13, 27, 47, .83), rgba(7, 15, 27, .9)); box-shadow: 0 15px 45px rgba(0,0,0,.14); }
.metric-card { min-height: 142px; padding: 18px 19px; }
.metric-card::after { content: ""; position: absolute; top: -50px; right: -30px; width: 130px; height: 130px; border-radius: 50%; background: var(--accent); filter: blur(65px); opacity: .22; }
.metric-card.blue { --accent: var(--blue); }
.metric-card.cyan { --accent: var(--cyan); }
.metric-card.amber { --accent: var(--amber); }
.metric-card.red { --accent: var(--red); }
.metric-head { display: flex; align-items: center; justify-content: space-between; color: #7c93ae; font-size: 9px; font-weight: 850; letter-spacing: .14em; }
.metric-symbol { display: grid; width: 25px; height: 25px; place-items: center; border: 1px solid color-mix(in srgb, var(--accent), transparent 72%); border-radius: 6px; color: var(--accent); background: color-mix(in srgb, var(--accent), transparent 91%); font-style: normal; font-size: 14px; }
.metric-card strong { display: block; margin: 14px 0 6px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 30px; font-weight: 600; }
.metric-card p { margin: 0; color: #58708b; font-size: 10px; }
.metric-card p b { color: var(--accent); }

.overview-grid { display: grid; grid-template-columns: 1fr 1.45fr; gap: 13px; margin-top: 13px; }
.panel { min-height: 260px; padding: 19px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 18px; }
.panel-heading h4 { margin: 0; font-size: 14px; }
.panel-tag { padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; color: #657c98; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; }
.threat-content { display: flex; align-items: center; justify-content: space-around; gap: 20px; min-height: 175px; }
.threat-ring { display: grid; flex: 0 0 143px; width: 143px; height: 143px; place-items: center; border-radius: 50%; background: conic-gradient(#20314a 0 100%); box-shadow: inset 0 0 20px rgba(0,0,0,.35); }
.threat-ring::before { content: ""; grid-area: 1/1; width: 103px; height: 103px; border: 1px solid rgba(116, 153, 201, .12); border-radius: 50%; background: #091321; }
.threat-ring div { z-index: 1; grid-area: 1/1; text-align: center; }
.threat-ring strong { display: block; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 24px; }
.threat-ring span { color: #637995; font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.legend { display: grid; gap: 10px; min-width: 145px; }
.legend-row { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; color: #7890ad; font-size: 9px; }
.legend-row i { width: 7px; height: 7px; border-radius: 2px; background: var(--legend); box-shadow: 0 0 8px color-mix(in srgb, var(--legend), transparent 30%); }
.legend-row b { color: #cbd9e9; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.bar-list { display: grid; gap: 14px; padding-top: 2px; }
.bar-item { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; }
.bar-item label { overflow: hidden; color: #7890ad; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 5px; overflow: hidden; border-radius: 5px; background: #101d2e; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2869e8, #42c8f4); box-shadow: 0 0 10px rgba(49, 151, 255, .38); }
.bar-item b { color: #9fb4cd; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; text-align: right; }
.events-panel { grid-column: 1 / 3; }
.event-stream { display: grid; }
.stream-row { display: grid; grid-template-columns: 84px 100px minmax(130px, .8fr) 76px 1.4fr 100px; align-items: center; gap: 13px; min-height: 46px; border-top: 1px solid rgba(130, 160, 200, .08); color: #7890ad; font-size: 10px; cursor: pointer; }
.stream-row:hover { background: rgba(45, 103, 173, .06); }
.stream-row time { color: #536b88; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.stream-row .host { color: #c2d2e4; font-weight: 700; }
.stream-row .event-id { color: #61b2ff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.stream-row .message { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.endpoint-panel { grid-column: 1 / 3; min-height: 190px; }
.endpoint-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.endpoint-chip { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 9px; padding: 11px; border: 1px solid rgba(121, 158, 205, .1); border-radius: 8px; background: rgba(4, 11, 21, .45); }
.endpoint-chip .device-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 6px; color: #5fa8ff; background: rgba(41, 118, 225, .1); }
.endpoint-chip strong { display: block; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.endpoint-chip span { color: #5c738e; font-size: 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #485b72; }
.status-dot.online { background: var(--green); box-shadow: 0 0 9px rgba(66,229,163,.8); }

.severity-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 67px; padding: 4px 7px; border: 1px solid color-mix(in srgb, var(--sev), transparent 62%); border-radius: 4px; color: var(--sev); background: color-mix(in srgb, var(--sev), transparent 91%); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.severity-badge.CRITICAL { --sev: var(--red); }
.severity-badge.HIGH { --sev: #ff855c; }
.severity-badge.MEDIUM { --sev: var(--amber); }
.severity-badge.LOW { --sev: #66a8ff; }
.severity-badge.INFO { --sev: #52d8d0; }

.toolbar { display: flex; align-items: end; gap: 14px; min-height: auto; margin-bottom: 13px; padding: 13px; overflow: visible; }
.search-box { display: flex; flex: 1; align-items: center; gap: 9px; min-width: 240px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; color: #537191; background: rgba(3, 10, 18, .7); }
.search-box input { width: 100%; border: 0; outline: 0; color: #cfe0f3; background: transparent; font-size: 11px; }
.select-box { display: grid; gap: 4px; color: #5e7692; font-size: 8px; font-weight: 800; letter-spacing: .08em; }
.select-box select { min-width: 130px; padding: 8px 28px 8px 9px; border: 1px solid var(--line); border-radius: 7px; outline: 0; color: #adc0d7; background: #081321; font-size: 10px; }
.result-count { margin: 0 2px 8px auto; color: #5b728f; font-size: 10px; }
.table-wrap { min-height: 340px; padding: 0; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 14px; color: #536d8c; background: rgba(6, 14, 25, .82); font-size: 8px; font-weight: 800; letter-spacing: .1em; text-align: left; white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid rgba(127, 163, 208, .08); color: #788faa; font-size: 10px; white-space: nowrap; }
tbody tr { cursor: pointer; transition: .15s ease; }
tbody tr:hover { background: rgba(43, 102, 178, .07); }
td.host-cell { color: #c5d6e9; font-weight: 700; }
td.code-cell { color: #65b1ff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.row-action { border: 0; color: #4e91df; background: transparent; cursor: pointer; }

.endpoint-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.endpoint-card { padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(145deg, rgba(13, 27, 47, .83), rgba(7, 15, 27, .9)); }
.endpoint-card-head { display: flex; align-items: center; justify-content: space-between; }
.endpoint-card-title { display: flex; align-items: center; gap: 10px; }
.endpoint-card-title .device-icon { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(54, 143, 255, .16); border-radius: 8px; color: #56a9ff; background: rgba(37, 119, 228, .09); }
.endpoint-card h4 { margin: 0 0 3px; font-size: 12px; }
.endpoint-card .agent-code { color: #4e6683; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 7px; }
.endpoint-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 18px; padding-top: 15px; border-top: 1px solid rgba(130,160,200,.08); }
.endpoint-meta div { min-width: 0; }
.endpoint-meta label { display: block; color: #4e6785; font-size: 7px; font-weight: 800; letter-spacing: .08em; }
.endpoint-meta span { display: block; margin-top: 4px; overflow: hidden; color: #8da4bf; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.event-dialog { width: min(760px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 27px; overflow: auto; border: 1px solid rgba(66, 145, 248, .3); border-radius: 13px; color: var(--text); background: #091321; box-shadow: 0 40px 120px #000; }
.event-dialog::backdrop { background: rgba(0, 4, 10, .78); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 16px; right: 17px; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; color: #7d93ad; background: #0c192a; cursor: pointer; }
.dialog-title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.dialog-title-row h3 { margin: 0; font-size: 20px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 22px; }
.detail-item { padding: 10px; border: 1px solid rgba(122, 159, 204, .1); border-radius: 7px; background: rgba(2,8,15,.48); }
.detail-item label { display: block; margin-bottom: 5px; color: #526c8b; font-size: 7px; font-weight: 800; letter-spacing: .09em; }
.detail-item span { color: #a8bdd4; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 9px; overflow-wrap: anywhere; }
.event-dialog h4 { margin: 16px 0 8px; color: #7391b4; font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.event-dialog pre { max-height: 210px; margin: 0; padding: 13px; overflow: auto; border: 1px solid rgba(117,154,200,.1); border-radius: 7px; color: #92abc6; background: #050d18; font: 10px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.event-dialog summary { margin: 16px 0 8px; color: #6595ca; font-size: 9px; cursor: pointer; }
.empty-state { display: grid; min-height: 150px; place-items: center; color: #4e6784; font-size: 10px; }
.empty-state.compact { min-height: 100px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 200; max-width: 360px; padding: 11px 15px; border: 1px solid rgba(255, 82, 111, .28); border-radius: 8px; color: #ff9cad; background: rgba(55, 12, 24, .96); box-shadow: 0 20px 40px rgba(0,0,0,.4); font-size: 10px; transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.mobile-nav { display: none; }

@keyframes pulse { 50% { transform: scale(1.08); opacity: .75; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 1100px) {
  :root { --sidebar: 78px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand div, .nav-item span:not(.nav-icon), .nav-item small, .sidebar-footer span, .sidebar-footer .text-button { display: none; }
  .nav-item { grid-template-columns: 1fr; place-items: center; }
  .nav-item.active::before { left: -16px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .endpoint-list { grid-template-columns: 1fr 1fr; }
  .endpoint-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  main { grid-column: 1; }
  .topbar { padding: 13px 17px; }
  .topbar h2 { font-size: 14px; }
  .live-pill, .clock { display: none; }
  .content { padding: 19px 14px 70px; }
  .section-heading h3 { font-size: 20px; }
  .last-update { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 126px; padding: 15px; }
  .metric-card strong { font-size: 25px; }
  .overview-grid { grid-template-columns: 1fr; }
  .events-panel, .endpoint-panel { grid-column: 1; }
  .threat-content { flex-wrap: wrap; }
  .stream-row { grid-template-columns: 72px 80px 1fr 50px; }
  .stream-row .message, .stream-row .category { display: none; }
  .endpoint-list, .endpoint-cards { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; align-items: stretch; }
  .search-box { flex-basis: 100%; }
  .result-count { margin-left: auto; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .gate-card { padding: 32px 24px; }
  .mobile-nav { position: fixed; inset: auto 10px 10px; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 5px; border: 1px solid rgba(95,145,205,.2); border-radius: 12px; background: rgba(6,14,25,.94); box-shadow: 0 18px 45px rgba(0,0,0,.55); backdrop-filter: blur(16px); }
  .mobile-nav button { display: grid; gap: 2px; place-items: center; padding: 7px 3px; border: 0; border-radius: 8px; color: #5f7590; background: transparent; font-size: 8px; }
  .mobile-nav button span { color: #4d9fff; font-size: 15px; }
  .mobile-nav button.active { color: #cfe2f7; background: rgba(36,101,191,.18); }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
