:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #101827;
  --muted: #64748b;
  --line: #dbe3ef;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --danger: #dc2626;
  --soft: #edf4ff;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { border: 0; border-radius: 10px; background: var(--blue); color: #fff; padding: 11px 16px; cursor: pointer; font-weight: 700; }
button:hover { background: var(--blue-dark); }
button.secondary { background: #e8eef9; color: #1f2937; }
button.secondary:hover { background: #dce7f7; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); width: 100%; }
button.danger { background: #fee2e2; color: var(--danger); padding: 8px 10px; }
button.danger:hover { background: #fecaca; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff; color: var(--text); outline: none; }
textarea { resize: vertical; min-height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
label { font-size: 13px; color: #334155; font-weight: 700; margin: 12px 0 6px; display: block; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 32px; border-radius: 22px; background: var(--card); box-shadow: 0 18px 60px rgba(15,23,42,.08); border: 1px solid var(--line); }
.brand-dot { width: 46px; height: 46px; border-radius: 15px; background: linear-gradient(135deg, var(--blue), #60a5fa); margin-bottom: 18px; }
.login-card h1 { margin: 0 0 8px; font-size: 30px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.login-form { display: grid; gap: 12px; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 24px; }
.logo { font-size: 24px; font-weight: 900; letter-spacing: -0.04em; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a { padding: 13px 14px; border-radius: 12px; color: #1f2937; font-weight: 800; }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--soft); color: var(--blue); }
.sidebar form { margin-top: auto; }
.content { padding: 28px; max-width: 1220px; width: 100%; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 22px; }
.topbar h1 { margin: 0 0 6px; font-size: 34px; letter-spacing: -0.04em; }
.topbar p { margin: 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.stat strong { display: block; font-size: 24px; margin-bottom: 4px; }
.stat span { color: var(--muted); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px; margin-bottom: 20px; box-shadow: 0 12px 36px rgba(15,23,42,.04); }
.card-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 18px; }
.card h2 { margin: 0 0 6px; font-size: 24px; }
.card p { margin: 0; color: var(--muted); }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.box { background: #f8fafc; border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.box.full { max-width: 760px; }
.box h3 { margin: 0 0 10px; }
.inline-form { display: grid; grid-template-columns: 1.2fr .8fr 1.2fr .7fr 1fr 1fr auto; gap: 10px; align-items: end; }
.table-wrap { overflow-x: auto; margin-top: 18px; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 760px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { background: #f8fafc; color: #334155; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; background: #e0f2fe; color: #075985; font-size: 12px; font-weight: 800; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.check-item { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.check-item input { width: auto; }
.chain-list { display: grid; gap: 12px; }
.chain-card { border: 1px solid var(--line); background: #f8fafc; border-radius: 16px; padding: 16px; }
.chain-card h3 { margin: 0; }
.chain-meta { color: var(--muted); font-size: 13px; font-weight: 800; margin: 0 0 10px 30px; line-height: 1.5; }
.chain-url { display: flex; gap: 10px; align-items: center; }
.chain-url code { flex: 1; white-space: nowrap; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; background: #111827; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); max-width: 420px; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow: auto; }
  .sidebar nav { display: flex; }
  .sidebar form { margin-left: auto; margin-top: 0; }
  .content { padding: 18px; }
  .stats, .grid.two { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}

.list-toolbar,
.select-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0 0;
}
.list-toolbar input,
.select-tools input { max-width: 360px; }
.muted-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}
.compact-table {
  max-height: 360px;
  overflow: auto;
}
.small-table { max-height: 240px; }
.compact-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.quick-exit { margin-bottom: 12px; }
.quick-exit h3 { margin-bottom: 12px; }
.quick-exit textarea { min-height: 92px; }
.manual-panel {
  margin: 12px 0 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f8fafc;
  padding: 0;
}
.manual-panel summary {
  cursor: pointer;
  font-weight: 900;
  color: #1f2937;
  padding: 14px 16px;
}
.manual-panel .inline-form {
  padding: 0 16px 16px;
}
.compact-checks {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  background: #fff;
}
.check-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-tools button {
  padding: 10px 12px;
}
.button-link { display: inline-flex; }
@media (max-width: 960px) {
  .list-toolbar input,
  .select-tools input { max-width: none; }
  .select-tools > * { width: 100%; }
}
.latency {
  display: inline-flex;
  align-items: center;
  min-width: 72px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.latency.good { background: #dcfce7; color: #166534; }
.latency.mid { background: #fef3c7; color: #92400e; }
.latency.bad { background: #fee2e2; color: #991b1b; }
.muted-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.slim-toolbar { margin-top: 0; margin-bottom: 12px; }
.check-item small { color: var(--muted); font-weight: 800; }
.quick-exit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 720px) {
  .quick-exit-row { grid-template-columns: 1fr; }
}
button:disabled { opacity: .45; cursor: not-allowed; }
button:disabled:hover { background: inherit; }
.check-col { width: 42px; }
td input[type="checkbox"], th input[type="checkbox"] { width: auto; }
.chain-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chain-title-row h3 { margin: 0; }
.chain-check { margin: 0; display: inline-flex; align-items: center; }
.chain-check input { width: auto; }
#exitFilter { max-width: 320px; }
@media (max-width: 960px) {
  #exitFilter { max-width: none; }
}
