:root, html[data-theme="dark"], body.theme-dark {
  --bg: #07080c;
  --bg-2: #0c0e14;
  --elev: #12151d;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #eef2f8;
  --muted: #9aa3b5;
  --faint: #6b7384;
  --a: #7aa8ff;
  --a-dim: rgba(122, 168, 255, 0.14);
  --b: #3ee0b0;
  --b-dim: rgba(62, 224, 176, 0.14);
  --bad: #ff6678;
  --bad-dim: rgba(255, 102, 120, 0.14);
  --warn: #ffc857;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --field-bg: #1a1e28;
  --field-text: #eef2f8;
  --radius: 16px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

body.theme-light, html[data-theme="light"] {
  --bg: #eef2f8;
  --bg-2: #ffffff;
  --elev: #ffffff;
  --line: rgba(28, 35, 48, 0.1);
  --line-2: rgba(28, 35, 48, 0.16);
  --text: #1c2330;
  --muted: #4b5568;
  --faint: #6b7287;
  --a: #2563eb;
  --a-dim: rgba(37, 99, 235, 0.1);
  --b: #0f9f73;
  --b-dim: rgba(15, 159, 115, 0.12);
  --bad: #dc3d4e;
  --bad-dim: rgba(220, 61, 78, 0.12);
  --warn: #c98400;
  --shadow: 0 12px 32px rgba(28, 35, 48, 0.08);
  --field-bg: #ffffff;
  --field-text: #1c2330;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.01em;
}

.bg-glow {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 8% -10%, rgba(122, 168, 255, 0.16), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(62, 224, 176, 0.1), transparent 50%);
}
.bg-grid {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 50% 20%, black, transparent 78%);
}
body.theme-dark .bg-glow,
body.theme-dark .bg-grid { display: block; }
.wrap { position: relative; z-index: 1; }
a { color: var(--a); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
.mono { font-family: var(--mono); }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: min(440px, 100%);
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
}
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  margin-bottom: 16px;
}
.login-card .brand-logo { width: 56px; height: 56px; border-radius: 16px; }
.side .logo .brand-logo { margin-bottom: 0; width: 40px; height: 40px; }
.captcha-row { display: flex; gap: 8px; align-items: stretch; }
.captcha-row input { flex: 1; min-width: 0; }
.captcha-img {
  width: 130px;
  height: 44px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #f4f6fb center / contain no-repeat;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.login-card h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -0.04em; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.6; }
label.field {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  background: var(--field-bg) !important;
  color: var(--field-text) !important;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}
select option {
  background: var(--field-bg);
  color: var(--field-text);
}
input:focus, select:focus, textarea:focus {
  border-color: #2f6bff;
  box-shadow: 0 0 0 4px rgba(47, 107, 255, 0.18);
}

.stack { display: grid; gap: 14px; margin-bottom: 18px; }
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
}
.btn-primary { background: #2f6bff; color: #fff; width: 100%; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-2);
}
.btn-mint { background: #12b981; color: #fff; }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn-sm { padding: 8px 12px; font-size: 12px; border-radius: 10px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 0 0 10px; }
.hint { color: var(--faint); font-size: 12px; margin-top: 16px; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.side {
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  background: var(--elev);
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.side .logo .brand-logo { margin-bottom: 0; }
.side .logo strong { font-size: 16px; letter-spacing: -0.04em; }
.side .logo span { display: block; color: var(--faint); font-size: 11px; font-weight: 600; }
.nav-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.nav-btn.active, .nav-btn:hover {
  background: var(--a-dim);
  color: var(--text);
}
.side-foot {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 16px;
  color: var(--faint);
  font-size: 12px;
}
.main { padding: 24px 28px 56px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 22px;
}
.topbar h2 { margin: 0; font-size: 26px; letter-spacing: -0.05em; }
.topbar .desc { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
}
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 750; }
.kpi .num {
  font-family: var(--mono);
  font-size: 30px;
  letter-spacing: -0.06em;
  margin-top: 8px;
  line-height: 1.1;
}
.kpi.a .num { color: var(--a); }
.kpi.b .num { color: var(--b); }
.kpi .delta { margin-top: 8px; color: var(--faint); font-size: 12px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 12px;
}
.section-head h3 { margin: 0; font-size: 16px; }
.section-head span { color: var(--muted); font-size: 12px; }

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.site-card {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  cursor: pointer;
}
.site-card:hover { border-color: var(--line-2); }
.site-card .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.site-card h4 { margin: 0; font-size: 16px; }
.site-card .dom { color: var(--muted); font-size: 12px; margin-top: 4px; font-family: var(--mono); word-break: break-all; }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 64px;
  height: 24px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  border-radius: 999px;
  background: var(--b-dim);
  color: var(--b);
}
.pill.off { background: var(--bad-dim); color: var(--bad); }
.metrics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.metrics div { background: var(--a-dim); border-radius: 12px; padding: 10px; }
.metrics b { display: block; font-family: var(--mono); font-size: 18px; }
.metrics span { color: var(--muted); font-size: 11px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.table-wrap {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 750; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.status-ok { color: var(--b); font-weight: 800; white-space: nowrap; }
.status-no { color: var(--bad); font-weight: 800; white-space: nowrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 150px; }

.flag {
  display: inline-block;
  vertical-align: middle;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.12);
  margin-right: 8px;
}
.flag-fallback { margin-right: 6px; }
.dev-cell { display: flex; align-items: center; gap: 2px; line-height: 1.45; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 36, 0.45);
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal {
  width: min(560px, 100%);
  background: #ffffff;
  color: #1c2330;
  border: 1px solid #d5dbe6;
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal input, .modal select, .modal textarea {
  background: #ffffff !important;
  color: #1c2330 !important;
  border-color: #c9d0dc;
  color-scheme: light;
}
.modal select option {
  background: #ffffff;
  color: #1c2330;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal .btn-ghost { color: #1c2330; border-color: #c9d0dc; }

.snippet {
  background: #1c2330;
  border-radius: 14px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  color: #e8edf7;
  line-height: 1.55;
  overflow-x: auto;
}
.share-box {
  background: var(--elev);
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 16px;
}

.six {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0 22px;
}
.empty-box {
  background: var(--elev);
  border: 1px dashed var(--line-2);
  border-radius: 16px;
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
}
.hidden { display: none !important; }
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #1c2330;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 40;
  font-size: 13px;
}

.board {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 14px 56px;
}
.board-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.board h1 { margin: 6px 0 0; font-size: 24px; letter-spacing: -0.04em; word-break: break-all; }
.board .meta { color: var(--muted); margin-top: 6px; font-size: 13px; }
.toggle {
  border: 1px solid var(--line-2);
  background: var(--elev);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: sticky;
    top: 0;
    z-index: 8;
    height: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .side .logo { padding: 0 8px 0 0; }
  .nav-btn { width: auto; margin: 0; }
  .side-foot {
    position: static;
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
  }
  .kpis, .cards, .six { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px 12px 48px; }
}
@media (max-width: 640px) {
  .kpis, .cards, .six { grid-template-columns: 1fr; }
  .topbar, .board-top { flex-direction: column; }
  .metrics { grid-template-columns: 1fr 1fr; }
  table { min-width: 520px; }
  .login-card { padding: 24px 18px; }
  .board h1 { font-size: 20px; }
}
