:root {
  --bg: #0D0B14;
  --bg-soft: #100D1A;
  --panel: #161224;
  --panel-2: #1B1630;
  --line: rgba(142, 138, 159, 0.22);
  --line-soft: rgba(255, 255, 255, 0.045);
  --text: #FFFFFF;
  --muted: #8E8A9F;
  --dim: #6E6980;
  --accent: #99FF00;
  --blue: #FFFFFF;
  --warn: #f5b942;
  --danger: #ff6b6b;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 82% -10%, rgba(153, 255, 0, 0.09), transparent 60%),
    radial-gradient(900px 500px at 10% 0%, rgba(142, 138, 159, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
p { margin: 0; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.empty { color: var(--dim); font-style: normal; padding: 10px 0; }
.small-text { font-size: 12px; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.hint { color: var(--dim); font-size: 12px; margin-top: 14px; }

/* ------------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 12, 24, 0.95), rgba(10, 8, 17, 0.98));
  backdrop-filter: blur(6px);
}

.main { padding: 26px 30px 44px; min-width: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(153, 255, 0, 0.22), rgba(142, 138, 159, 0.25));
  border: 1px solid rgba(153, 255, 0, 0.35);
}
.brand-mark .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(153, 255, 0, 0.6);
  animation: pulse 2.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(153, 255, 0, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(153, 255, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(153, 255, 0, 0); }
}

.brand-text { font-weight: 650; letter-spacing: 0.01em; }
.brand-text small { display: block; font-size: 10.5px; font-weight: 500; color: var(--dim); letter-spacing: 0.06em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: rgba(255, 255, 255, 0.035); color: var(--text); text-decoration: none; }
.nav a.active {
  background: linear-gradient(90deg, rgba(153, 255, 0, 0.12), rgba(153, 255, 0, 0.02));
  color: var(--accent);
  border-color: rgba(153, 255, 0, 0.22);
}
.nav svg { width: 17px; height: 17px; fill: currentColor; opacity: 0.9; flex: none; }
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 107, 107, 0.18);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #ffb3b3;
  font-size: 11px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.who { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.linkbtn:hover { color: var(--danger); }

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.topmeta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  font-size: 11.5px;
  color: var(--muted);
}
.pill.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px rgba(153, 255, 0, 0.8); }
.pill.offline i { background: var(--danger); box-shadow: none; }

/* ------------------------------------------------------------------- grids */

.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ------------------------------------------------------------------- cards */

.card {
  background: linear-gradient(180deg, #1C1731 0%, #161224 58%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-width: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}
.card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 12px;
}
.card > header.inner { margin-top: 18px; }
.card > header a { text-transform: none; letter-spacing: 0; font-size: 12px; }

.stat .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.stat .value.small { font-size: 20px; padding-top: 6px; }
.stat .value small { font-size: 14px; color: var(--muted); margin-left: 3px; font-weight: 500; }
.stat .sub { font-size: 12px; margin-top: 8px; }
.stat .sub, .card .sub { color: var(--muted); }

.meter {
  position: relative;
  height: 6px;
  margin-top: 12px;
  border-radius: 999px;
  background: #251E3A;
  overflow: hidden;
}
.meter.big { height: 10px; margin: 4px 0 14px; }
.meter.inline { display: inline-block; width: 90px; vertical-align: middle; margin: 0 6px 0 0; }
.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7ACC00, var(--accent));
  transition: width 0.5s ease;
}
.meter i.warn { background: linear-gradient(90deg, #d99a20, var(--warn)); }
.meter i.bad { background: linear-gradient(90deg, #d94c4c, var(--danger)); }

/* ------------------------------------------------------------------ charts */

.chart-card canvas.chart { height: 168px; }
.chart-card canvas.chart.tall { height: 220px; }
canvas.chart { display: block; width: 100%; height: 160px; }
canvas.spark { display: block; width: 140px; height: 28px; }
.legend { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); margin: 6px 0 4px; }
.legend .key { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend .key.accent { background: var(--accent); }
.legend .key.blue { background: var(--blue); }

.core { display: grid; grid-template-columns: 70px 1fr 46px; align-items: center; gap: 10px; font-size: 12px; margin-top: 6px; }
.cores { margin-top: 14px; }

.range-bar { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.range-bar .btn { padding: 3px 8px; font-size: 11px; text-transform: none; letter-spacing: 0; }
.range-bar .btn.active {
  color: #0D0B14;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 650;
}

/* ------------------------------------------------------------------- lists */

.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 13px;
}
.status-list li:last-child { border-bottom: 0; }
.status-list li.col { display: block; }
.status-list .row { display: flex; gap: 10px; align-items: center; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--dim);
  display: inline-block;
  margin-right: 7px;
  vertical-align: middle;
}
.dot.ok { background: var(--accent); box-shadow: 0 0 7px rgba(153, 255, 0, 0.55); }
.dot.warn { background: var(--warn); box-shadow: 0 0 7px rgba(245, 185, 66, 0.5); }
.dot.bad { background: var(--danger); box-shadow: 0 0 7px rgba(255, 107, 107, 0.55); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; }
.chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(142, 138, 159, 0.06);
  font-size: 12px;
  color: var(--muted);
}
.chip strong { color: var(--text); font-weight: 600; }

.tag { padding: 2px 8px; border-radius: 999px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); }
.tag.warn { color: #ffd280; border-color: rgba(245, 185, 66, 0.35); background: rgba(245, 185, 66, 0.08); }

/* ------------------------------------------------------------------ tables */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--dim);
  font-weight: 600;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:hover { background: rgba(153, 255, 0, 0.035); }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 6px 10px; font-size: 12.5px; }
.table th.right, .table td.right { text-align: right; }

/* -------------------------------------------------------------------- misc */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
}
.banner.danger {
  border-color: rgba(255, 107, 107, 0.35);
  background: linear-gradient(90deg, rgba(255, 107, 107, 0.12), rgba(255, 107, 107, 0.03));
}
.banner[hidden] { display: none; }

.alert-list { display: flex; flex-direction: column; gap: 2px; }
.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px dashed var(--line-soft);
}
.alert-row:last-child { border-bottom: 0; }
.alert-row .sub { font-size: 12px; }
.alert-row.sev-critical { border-left: 2px solid var(--danger); padding-left: 12px; }
.alert-row.sev-warning { border-left: 2px solid var(--warn); padding-left: 12px; }
.alert-row.sev-info { border-left: 2px solid var(--blue); padding-left: 12px; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.rules { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.rules li { padding: 3px 0; }

.empty-state { text-align: center; padding: 48px 20px; }
.empty-state h2 { margin-bottom: 8px; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--dim);
}

.bad-text { color: var(--danger); }
.warn-text { color: var(--warn); }
.ok-text { color: var(--accent); }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.08); border-color: #3A3157; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn.primary {
  background: linear-gradient(180deg, #99FF00, #7ACC00);
  border-color: #7ACC00;
  color: #0D0B14;
  font-weight: 650;
}
.btn.primary:hover { background: linear-gradient(180deg, #B2FF40, #8AE600); }
.btn.danger { color: #ffb0b0; border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.08); }
.btn.danger:hover { background: rgba(255, 107, 107, 0.16); }
.btn.wide { width: 100%; justify-content: center; padding: 10px 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ------------------------------------------------------------------ forms */

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.field.check { flex-direction: row; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 12px; }
.field.check input { width: 16px; height: 16px; accent-color: var(--accent); }
select, input[type="text"], input[type="email"], input[type="password"], input[type="search"] {
  background: #120F1D;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
}
select:focus, input:focus { outline: 2px solid rgba(153, 255, 0, 0.35); outline-offset: 1px; border-color: rgba(153, 255, 0, 0.5); }

.logbox {
  margin: 0;
  height: 58vh;
  min-height: 280px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0B0912;
  color: #D9D6E3;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}

/* ------------------------------------------------------------------ login */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(700px 380px at 50% 0%, rgba(153, 255, 0, 0.12), transparent 65%),
    radial-gradient(600px 340px at 80% 100%, rgba(142, 138, 159, 0.08), transparent 60%),
    var(--bg);
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: linear-gradient(180deg, rgba(22, 18, 36, 0.97), rgba(14, 11, 24, 0.98));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 26px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.login-brand { padding: 0 0 18px; }
.login-brand .brand-text small { display: inline; margin-left: 4px; font-size: 11px; }
.login-lead { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.login-card input { padding: 11px 12px; font-size: 14px; }
.login-foot { margin-top: 16px; text-align: center; color: var(--dim); font-size: 11.5px; }
.alert.error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.1);
  color: #ffc0c0;
  font-size: 12.5px;
}

.chart-tip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(9, 14, 20, 0.96);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}
.chart-tip[hidden] { display: none; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #161224;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.toast.ok { border-color: rgba(153, 255, 0, 0.45); }
.toast.err { border-color: rgba(255, 107, 107, 0.55); }

/* --------------------------------------------------------------- responsive */

@media (max-width: 700px) {
  .kv { grid-template-columns: 96px minmax(0, 1fr); }
  .kv dd { overflow-wrap: anywhere; }
  .card { overflow-x: auto; }
  .table { min-width: 460px; }
  .toolbar { gap: 10px; }
  .field { flex: 1 1 150px; }
  .field.grow { flex-basis: 100%; }
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 7px 10px; white-space: nowrap; }
  .nav a span:not(.nav-badge) { display: none; }
  .nav svg { width: 18px; height: 18px; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 16px 32px; }
  .topbar { margin-bottom: 16px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .logbox { height: 50vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
