:root {
  color-scheme: dark;
  --bg: #080b11;
  --bg-soft: #0d111a;
  --panel: rgba(18, 23, 34, 0.92);
  --panel-2: #151b27;
  --panel-3: #1b2331;
  --line: #273244;
  --line-soft: #1e2735;
  --text: #f1f5fb;
  --muted: #8d9aaf;
  --muted-2: #637086;
  --primary: #6ea8ff;
  --primary-strong: #4d8fff;
  --cyan: #55d9e6;
  --green: #58d68d;
  --yellow: #f6c95f;
  --orange: #ff9f5b;
  --red: #ff6d7a;
  --purple: #b893ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, .35);
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(78, 143, 255, .13), transparent 33%),
    radial-gradient(circle at 90% 5%, rgba(85, 217, 230, .08), transparent 28%),
    var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button { color: inherit; }
a { color: var(--primary); }
code, pre { font-family: var(--mono); }
code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #0b0f17;
  color: #d8e6ff;
}
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(39, 50, 68, .82);
  background: rgba(8, 11, 17, .88);
  backdrop-filter: blur(18px);
}
.brand-block, .brand-line, .status-line, .top-actions, .toolbar, .metric-heading, .panel-header, .chart-legend, .modal-actions, .diagnostic-actions { display: flex; align-items: center; }
.brand-block { gap: 12px; min-width: 260px; }
.brand-line { gap: 9px; font-size: 16px; }
.status-line { gap: 6px; margin-top: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.separator { color: var(--muted-2); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(110, 168, 255, .55);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(110, 168, 255, .28), rgba(85, 217, 230, .1));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09), 0 12px 40px rgba(55, 112, 211, .2);
  color: #dce9ff;
  font-weight: 800;
  letter-spacing: -.04em;
}
.brand-mark.small { width: 42px; height: 42px; border-radius: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 999px; box-shadow: 0 0 10px currentColor; }
.status-dot.online { color: var(--green); background: var(--green); }
.status-dot.offline { color: var(--red); background: var(--red); }
.status-dot.paused { color: var(--yellow); background: var(--yellow); }
.top-actions { justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.compact-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }

.tabs {
  position: sticky;
  top: 72px;
  z-index: 25;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 9px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 14, 21, .92);
  backdrop-filter: blur(14px);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .035); }
.tab.active { border-color: var(--line); background: var(--panel-2); color: var(--text); }
.count-pill {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #222c3c;
  color: #b9c7da;
  font-size: 11px;
  text-align: center;
}

.content { max-width: 1840px; margin: 0 auto; padding: 18px 22px 44px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.capability-banner {
  display: none;
  margin-bottom: 14px;
  padding: 10px 13px;
  border: 1px solid rgba(246, 201, 95, .25);
  border-radius: var(--radius-sm);
  background: rgba(246, 201, 95, .07);
  color: #eddba7;
  font-size: 12px;
}
.capability-banner.visible { display: block; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(170px, 1fr));
  gap: 10px;
}
.metric-card, .panel {
  border: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(20, 26, 38, .96), rgba(14, 19, 29, .96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025);
}
.metric-card { min-height: 138px; padding: 14px; border-radius: var(--radius); }
.metric-heading { justify-content: space-between; color: #c9d3e3; font-size: 12px; font-weight: 650; }
.metric-sub { color: var(--muted); font-weight: 500; }
.metric-value { margin-top: 8px; font-size: 29px; font-weight: 760; letter-spacing: -.04em; }
.metric-value.compact { font-size: 20px; letter-spacing: -.02em; margin-top: 13px; }
.metric-meta { margin-top: 8px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { height: 5px; margin-top: 11px; overflow: hidden; border-radius: 99px; background: #222b39; }
.meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--cyan)); transition: width .25s ease; }
.meter span.warning { background: linear-gradient(90deg, var(--yellow), var(--orange)); }
.meter span.critical { background: linear-gradient(90deg, var(--orange), var(--red)); }

.panel { margin-top: 12px; padding: 15px; border-radius: var(--radius); }
.panel-header { justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.panel-header h2, .diagnostic-actions h2, .drawer-header h2, .modal h2 { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.eyebrow { margin: 0 0 2px; color: var(--muted-2); font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart-panel { min-width: 0; }
.chart-panel canvas { display: block; width: 100%; height: 220px; }
.chart-legend { justify-content: flex-end; gap: 16px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; }
.legend-dot.cpu { background: var(--primary); }
.legend-dot.ram { background: var(--cyan); }
.legend-dot.iowait { background: var(--yellow); }
.legend-dot.disk-read { background: var(--primary); }
.legend-dot.disk-write { background: var(--purple); }
.legend-dot.net-in { background: var(--cyan); }
.legend-dot.net-out { background: var(--green); }

.warning-list { display: grid; gap: 8px; }
.warning-item {
  display: grid;
  grid-template-columns: 9px minmax(180px, .7fr) minmax(240px, 1.2fr) minmax(240px, 1fr);
  align-items: start;
  gap: 11px;
  padding: 10px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, .018);
}
.warning-marker { width: 8px; height: 8px; margin-top: 5px; border-radius: 99px; }
.warning-item.critical .warning-marker { background: var(--red); box-shadow: 0 0 12px rgba(255, 109, 122, .6); }
.warning-item.warning .warning-marker { background: var(--yellow); box-shadow: 0 0 12px rgba(246, 201, 95, .5); }
.warning-item.ok .warning-marker { background: var(--green); box-shadow: 0 0 12px rgba(88, 214, 141, .5); }
.warning-title { font-weight: 700; }
.warning-evidence, .warning-recommendation { color: var(--muted); font-size: 12px; }

.detail-grid { display: grid; gap: 12px; }
.detail-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.detail-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat-tile { padding: 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgba(255,255,255,.015); }
.stat-tile span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.stat-tile strong { display: block; margin-top: 3px; font-size: 16px; }
.stack-list { display: grid; gap: 8px; max-height: 300px; overflow: auto; }
.stack-item { padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgba(255,255,255,.014); }
.stack-item-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.stack-item-meta { margin-top: 4px; color: var(--muted); font-size: 11px; }
.mini-meter { height: 3px; margin-top: 7px; border-radius: 99px; overflow: hidden; background: #222b39; }
.mini-meter span { display: block; height: 100%; background: var(--primary); }

.button, .icon-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .12s ease, opacity .15s ease;
}
.button { min-height: 34px; padding: 7px 11px; border-radius: 8px; font-size: 12px; font-weight: 650; }
.button:hover:not(:disabled) { border-color: #3b4a62; background: #1b2433; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button.primary { border-color: rgba(110, 168, 255, .6); background: linear-gradient(180deg, #397fe7, #2868c7); color: white; }
.button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #4a8df2, #2c70d4); }
.button.subtle { background: #151b27; }
.button.ghost { background: transparent; color: var(--muted); }
.button.danger { border-color: rgba(255, 109, 122, .55); background: rgba(255, 109, 122, .12); color: #ffc6cc; }
.button.warning { border-color: rgba(246, 201, 95, .45); background: rgba(246, 201, 95, .09); color: #f7e0a6; }
.button.wide { width: 100%; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); font-size: 23px; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.neutral { border-color: var(--line); background: #151c28; color: #aebbd0; }
.badge.good { border-color: rgba(88, 214, 141, .25); background: rgba(88, 214, 141, .08); color: #9be6b9; }
.badge.warn { border-color: rgba(246, 201, 95, .25); background: rgba(246, 201, 95, .08); color: #f0d994; }
.badge.bad { border-color: rgba(255, 109, 122, .25); background: rgba(255, 109, 122, .08); color: #ffabb3; }

input, select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #0f141e;
  color: var(--text);
}
input { padding: 7px 10px; }
select { padding: 6px 28px 6px 9px; }
input:focus, select:focus { border-color: var(--primary-strong); box-shadow: 0 0 0 3px rgba(77, 143, 255, .1); }
.search-input { width: min(360px, 32vw); }
.toolbar-header { align-items: flex-end; }
.toolbar { justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.full-height-panel { min-height: calc(100vh - 175px); }

.table-wrap { overflow: auto; border: 1px solid var(--line-soft); border-radius: 10px; }
.tall-table { max-height: calc(100vh - 245px); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th, .data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; white-space: nowrap; }
.data-table th { position: sticky; top: 0; z-index: 3; background: #151b26; color: #8f9cb0; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.data-table tbody tr { background: rgba(255,255,255,.006); }
.data-table tbody tr:nth-child(even) { background: rgba(255,255,255,.013); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: rgba(110, 168, 255, .065); }
.data-table td.path-cell { max-width: 330px; overflow: hidden; text-overflow: ellipsis; color: #9badc4; font-family: var(--mono); font-size: 11px; }
.data-table td.command-cell { max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.compact-table td { padding-top: 7px; padding-bottom: 7px; }
.empty-cell, .empty-state { padding: 22px !important; color: var(--muted); text-align: center !important; }
.primary-cell { font-weight: 680; }
.secondary-line { display: block; max-width: 320px; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; }
.mono { font-family: var(--mono); }
.metric-inline { display: flex; align-items: center; gap: 7px; min-width: 90px; }
.tiny-bar { width: 44px; height: 4px; overflow: hidden; border-radius: 99px; background: #222b39; }
.tiny-bar span { display: block; height: 100%; background: var(--primary); }
.state-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 99px; background: var(--muted-2); }
.state-dot.active, .state-dot.running, .state-dot.LISTEN { background: var(--green); }
.state-dot.failed, .state-dot.zombie { background: var(--red); }
.state-dot.activating, .state-dot.deactivating { background: var(--yellow); }

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 70;
  width: min(760px, 94vw);
  height: 100vh;
  transform: translateX(102%);
  border-left: 1px solid var(--line);
  background: #0d121b;
  box-shadow: -30px 0 80px rgba(0,0,0,.5);
  transition: transform .2s ease;
}
.detail-drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 72px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-body { height: calc(100vh - 72px); padding: 15px 18px 36px; overflow-y: auto; }
.detail-section { margin-bottom: 14px; padding: 13px; border: 1px solid var(--line-soft); border-radius: 11px; background: rgba(255,255,255,.012); }
.detail-section h3 { margin: 0 0 10px; font-size: 13px; }
.kv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kv { min-width: 0; padding: 8px; border: 1px solid var(--line-soft); border-radius: 8px; background: #0c1119; }
.kv span { display: block; color: var(--muted-2); font-size: 9px; letter-spacing: .07em; text-transform: uppercase; }
.kv strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font-size: 12px; font-weight: 620; }
.code-block, .log-box { margin: 0; overflow: auto; border: 1px solid var(--line-soft); border-radius: 9px; background: #090d14; color: #b9c8dc; font-family: var(--mono); font-size: 11px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.code-block { padding: 10px; }
.log-box { min-height: 260px; max-height: 520px; padding: 12px; white-space: pre; }
.action-bar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px; border: 1px solid rgba(246,201,95,.18); border-radius: 10px; background: rgba(246,201,95,.035); }
.action-note { width: 100%; color: var(--muted); font-size: 10px; }
details { border-top: 1px solid var(--line-soft); padding-top: 10px; }
details summary { color: #c5d1e2; cursor: pointer; font-size: 12px; font-weight: 650; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
.modal { width: min(460px, 96vw); padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: #111722; box-shadow: var(--shadow); }
.modal label { display: block; margin: 15px 0 6px; color: #c3cede; font-size: 12px; }
.modal input { width: 100%; }
.modal-actions { justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 130; display: grid; gap: 8px; width: min(390px, calc(100vw - 36px)); }
.toast { padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: #151c28; box-shadow: var(--shadow); color: #dce4f1; font-size: 12px; animation: toast-in .18s ease; }
.toast.error { border-color: rgba(255,109,122,.38); background: #25161c; }
.toast.success { border-color: rgba(88,214,141,.28); background: #12221a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.diagnostic-actions { justify-content: space-between; gap: 20px; margin-bottom: 12px; padding: 8px 2px; }
.diagnostic-actions p { margin-top: 4px; margin-bottom: 0; }
.audit-list { display: grid; gap: 7px; }
.audit-item { display: grid; grid-template-columns: 170px 100px 1fr 90px; gap: 10px; padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgba(255,255,255,.012); font-size: 11px; }
.audit-item .ok { color: var(--green); }
.audit-item .failed { color: var(--red); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 22px; }
.login-shell { width: 100%; max-width: 430px; }
.login-card { padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(180deg, rgba(20,26,38,.98), rgba(12,17,26,.98)); box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 20px; }
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.login-card form { margin-top: 22px; }
.login-card label { display: block; margin-bottom: 7px; color: #c7d2e2; font-size: 12px; font-weight: 650; }
.login-card input { width: 100%; height: 42px; margin-bottom: 10px; }
.form-error { min-height: 20px; margin: 8px 0 0; color: #ff9ca7; font-size: 12px; text-align: center; }
.login-note { margin-top: 18px; padding: 10px 11px; border: 1px solid var(--line-soft); border-radius: 9px; background: rgba(255,255,255,.018); color: var(--muted); font-size: 11px; }

@media (max-width: 1320px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(170px, 1fr)); }
  .detail-grid.three { grid-template-columns: 1fr 1fr; }
  .detail-grid.three > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .tabs { top: 0; }
  .content { padding-left: 12px; padding-right: 12px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .chart-grid, .detail-grid.two, .detail-grid.three { grid-template-columns: 1fr; }
  .detail-grid.three > :first-child { grid-column: auto; }
  .warning-item { grid-template-columns: 9px 1fr; }
  .warning-evidence, .warning-recommendation { grid-column: 2; }
  .toolbar-header, .diagnostic-actions { align-items: flex-start; flex-direction: column; }
  .toolbar { width: 100%; justify-content: flex-start; }
  .search-input { width: 100%; }
  .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-item { grid-template-columns: 1fr 80px; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 124px; }
  .brand-block { min-width: 0; }
  .status-line { flex-wrap: wrap; white-space: normal; }
  .tabs { padding-left: 10px; padding-right: 10px; }
  .top-actions .compact-control { width: 100%; }
  .kv-grid, .stat-list { grid-template-columns: 1fr; }
  .drawer-body { padding-left: 11px; padding-right: 11px; }
  .chart-legend { flex-wrap: wrap; justify-content: flex-start; }
}
