:root {
  --bg: #0a0f15;
  --bg-soft: #0f1722;
  --panel: #111b27;
  --panel-2: #162231;
  --border: #223247;
  --border-soft: #1a2839;
  --text: #e8eef7;
  --muted: #8fa5bd;
  --accent: #3ddc97;
  --accent-2: #5aa9ff;
  --danger: #ff6b6b;
  --warning: #ffc857;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(61, 220, 151, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(90, 169, 255, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

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

code, .mono {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
}

code {
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
}

h1, h2, h3 { margin: 0 0 6px; line-height: 1.2; }
h1 { font-size: 26px; letter-spacing: -0.3px; }
h2 { font-size: 16px; font-weight: 600; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.break { word-break: break-all; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.right { text-align: right; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  background: rgba(10, 15, 21, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand:hover { text-decoration: none; }
.brand small {
  color: var(--muted);
  font-weight: 500;
  font-size: 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(61, 220, 151, 0.12), 0 0 18px rgba(61, 220, 151, 0.6);
}

.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 9px;
  font-weight: 500;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--panel-2); }

.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-user form { margin: 0; }
.dot-live {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(143, 165, 189, 0.12);
}
.dot-live.ok { background: var(--accent); box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.15); }
.dot-live.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.15); }

/* Layout */
.container { max-width: 1180px; margin: 0 auto; padding: 28px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.page-head p { margin: 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Cards */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent), var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.grid-client {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

/* Health */
.health-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  margin-bottom: 18px;
}
.health-banner.ok { border-color: rgba(61, 220, 151, 0.35); background: rgba(61, 220, 151, 0.05); }
.health-banner.bad { border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.05); }
.health-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 5px rgba(255, 200, 87, 0.1);
}
.health-banner.ok .health-dot { background: var(--accent); box-shadow: 0 0 0 5px rgba(61, 220, 151, 0.1); }
.health-banner.bad .health-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(255, 107, 107, 0.1); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(255, 255, 255, 0.015); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.on { color: var(--accent); background: rgba(61, 220, 151, 0.1); }
.status.off { color: var(--muted); background: rgba(143, 165, 189, 0.1); }

.badge {
  display: inline-block;
  font-size: 11px;
  color: var(--warning);
  border: 1px solid rgba(255, 200, 87, 0.35);
  background: rgba(255, 200, 87, 0.08);
  border-radius: 20px;
  padding: 1px 7px;
  vertical-align: middle;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 13px;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.btn:hover { border-color: #334b68; background: #1a293b; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04120b; }
.btn-primary:hover { background: #55e8a8; border-color: #55e8a8; }
.btn-danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.07); }
.btn-danger:hover { background: rgba(255, 107, 107, 0.14); border-color: rgba(255, 107, 107, 0.55); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { color: var(--text); }
.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; flex-wrap: wrap; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label > span { font-weight: 600; color: var(--text); }
input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
}
input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(90, 169, 255, 0.12); }
label small { line-height: 1.35; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.login-logo { margin-bottom: 14px; }
.login-card h1 { font-size: 24px; }
.login-card p { margin: 0 0 18px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }

/* Flash */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 10px 13px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 13.5px;
}
.flash.ok { border-color: rgba(61, 220, 151, 0.35); background: rgba(61, 220, 151, 0.07); }
.flash.error { border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.07); }

/* QR / config */
.qr-card { text-align: center; }
.qr {
  width: 100%;
  max-width: 320px;
  height: auto;
  margin: 8px auto 4px;
  border-radius: 10px;
  background: #fff;
  padding: 10px;
  image-rendering: pixelated;
}
.config {
  background: #060a0f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 15px;
  overflow: auto;
  max-height: 460px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre;
}

/* Meta / lists */
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 0; }
.meta > div { min-width: 0; }
.meta dt { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; }
.meta dd { margin: 2px 0 0; }

.services { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.services li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); }
.services li:last-child { border-bottom: 0; }

.audit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.audit li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.audit li:last-child { border-bottom: 0; }
.audit-action { color: var(--accent-2); font-weight: 600; white-space: nowrap; }
.audit time { margin-left: auto; white-space: nowrap; }

.list { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.list li { margin-bottom: 8px; }
.list strong { color: var(--text); }
.info-card h2 { margin-bottom: 10px; }

.empty { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; }

.error-page { text-align: center; padding: 80px 20px; }
.error-code { font-size: 72px; font-weight: 800; color: var(--accent-2); letter-spacing: -4px; }

/* Responsive */
@media (max-width: 900px) {
  .grid-2, .grid-client { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .container { padding: 18px; }
  .page-head { flex-direction: column; }
  .meta { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  h1 { font-size: 22px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 18px; }
  .topbar-user .muted { display: none; }
}
