:root {
  --bg: #0a0f1d;
  --bg-soft: #0e1526;
  --panel: #121b2f;
  --panel-2: #17223a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eefb;
  --muted: #8ea0bd;
  --accent: #35d0a5;
  --accent-2: #6aa9ff;
  --danger: #ff6b7a;
  --warn: #ffc857;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family:
    ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans', sans-serif;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(53, 208, 165, 0.12), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(106, 169, 255, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.tiny {
  font-size: 12px;
}
.error-text {
  color: var(--danger);
  min-height: 20px;
  margin: 10px 0 0;
  font-size: 13px;
}
.fineprint {
  color: var(--muted);
  font-size: 11px;
  margin-top: 18px;
}

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent), var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 21px;
  margin: 14px 0 4px;
}
.login-card p {
  margin: 0 0 22px;
}
.login-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #05261d;
  background: linear-gradient(135deg, var(--accent), #7ff0c9);
  box-shadow: 0 8px 20px rgba(53, 208, 165, 0.3);
}
.brand-mark.small {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 13px;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: rgba(9, 14, 26, 0.75);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(12px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
}
.brand strong {
  display: block;
  font-size: 15px;
}
.brand .muted {
  display: block;
}
nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: 0.16s ease;
}
.nav-item span {
  width: 18px;
  text-align: center;
  opacity: 0.85;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(53, 208, 165, 0.16), rgba(53, 208, 165, 0.03));
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar-foot {
  margin-top: auto;
  padding: 16px 10px 4px;
}
.main {
  min-width: 0;
  padding: 26px 32px 60px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}
.topbar h2 {
  margin: 0;
  font-size: 19px;
}
.topbar p {
  margin: 3px 0 0;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: var(--muted);
}
.dot.ok {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(53, 208, 165, 0.15);
}
.dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 107, 122, 0.15);
}
.dot.unknown {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(255, 200, 87, 0.14);
}

/* ---------- Buttons & inputs ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.16s ease;
  white-space: nowrap;
}
.btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn.primary {
  background: linear-gradient(135deg, #2fc59b, #48dbb2);
  border-color: transparent;
  color: #04241b;
  font-weight: 700;
}
.btn.danger {
  background: rgba(255, 107, 122, 0.12);
  border-color: rgba(255, 107, 122, 0.35);
  color: #ffb3bb;
}
.btn.ghost {
  background: transparent;
}
.btn.wide {
  width: 100%;
  margin-top: 14px;
  padding: 11px;
}
input,
select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: 0.16s ease;
}
input:focus,
select:focus {
  border-color: rgba(53, 208, 165, 0.55);
  box-shadow: 0 0 0 3px rgba(53, 208, 165, 0.12);
}
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 7px;
}
.field .help {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

/* ---------- Cards / grid ---------- */
.content {
  animation: fade 0.25s ease;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.grid {
  display: grid;
  gap: 16px;
}
.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}
.card h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.stat .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.stat .value {
  font-size: 28px;
  font-weight: 750;
  margin: 8px 0 4px;
  letter-spacing: -0.5px;
}
.stat .sub {
  color: var(--muted);
  font-size: 12px;
}
.stat.accent .value {
  color: var(--accent);
}
.stat.blue .value {
  color: var(--accent-2);
}
.section-gap {
  margin-top: 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h3 {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok {
  color: #8ff0d2;
  border-color: rgba(53, 208, 165, 0.35);
  background: rgba(53, 208, 165, 0.1);
}
.badge.bad {
  color: #ffb3bb;
  border-color: rgba(255, 107, 122, 0.35);
  background: rgba(255, 107, 122, 0.1);
}
.badge.warn {
  color: #ffe0a3;
  border-color: rgba(255, 200, 87, 0.35);
  background: rgba(255, 200, 87, 0.1);
}

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  word-break: break-word;
}
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  word-break: break-all;
}

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 620px;
}
th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: rgba(255, 255, 255, 0.02);
}
tr:last-child td {
  border-bottom: 0;
}
td .name {
  font-weight: 600;
}
td .desc {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Toggle ---------- */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: 0.18s ease;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cfd8e8;
  transition: 0.18s ease;
}
.toggle.on {
  background: rgba(53, 208, 165, 0.35);
  border-color: rgba(53, 208, 165, 0.5);
}
.toggle.on::after {
  left: 23px;
  background: var(--accent);
}
.toggle:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ---------- Logs ---------- */
.log {
  background: #070c16;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow: auto;
}
.log-line {
  display: block;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.04);
  padding: 3px 0;
}
.log-line .lv {
  display: inline-block;
  min-width: 52px;
  font-weight: 700;
}
.lv.info {
  color: #7fd7ff;
}
.lv.warn {
  color: var(--warn);
}
.lv.error {
  color: var(--danger);
}
.lv.debug {
  color: var(--muted);
}
.log-line .ts {
  color: #61708a;
  margin-right: 8px;
}

/* ---------- Checks ---------- */
.check-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.check-item:last-child {
  border-bottom: 0;
}
.check-item .check-name {
  font-weight: 600;
  font-size: 14px;
}
.check-item .check-detail {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  word-break: break-word;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.loading {
  color: var(--muted);
  padding: 30px;
}

/* ---------- Toast / modal ---------- */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 13px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-width: 380px;
  font-size: 13px;
  z-index: 80;
  animation: fade 0.2s ease;
}
.toast.error {
  border-left-color: var(--danger);
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.7);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 90;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal-card h3 {
  margin: 0 0 14px;
  font-size: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.key-reveal {
  background: rgba(53, 208, 165, 0.08);
  border: 1px solid rgba(53, 208, 165, 0.35);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  margin: 10px 0;
}
.empty {
  color: var(--muted);
  text-align: center;
  padding: 34px 12px;
  font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand {
    padding-bottom: 12px;
  }
  nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
  }
  .nav-item {
    width: auto;
    white-space: nowrap;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
  }
  .sidebar-foot {
    display: none;
  }
  .main {
    padding: 18px 16px 50px;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }
  .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .kv dd {
    margin-bottom: 10px;
  }
}
@media (max-width: 520px) {
  .grid.cols-4 {
    grid-template-columns: 1fr;
  }
  .topbar-actions .tiny,
  #live-text {
    display: none;
  }
}
