:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --border: #dde3ea;
  --text: #1c2430;
  --muted: #667085;
  --accent: #1a73e8;
  --accent-text: #ffffff;
  --ok: #138a4c;
  --ok-bg: #e3f5eb;
  --warn: #9a6200;
  --warn-bg: #fdf1d8;
  --bad: #c62828;
  --bad-bg: #fde7e7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #171d24;
    --surface-2: #1f2730;
    --border: #2b3540;
    --text: #e6edf3;
    --muted: #8b98a5;
    --accent: #4c9aff;
    --accent-text: #0b1220;
    --ok: #4cc38a;
    --ok-bg: #12301f;
    --warn: #f0b44c;
    --warn-bg: #33270f;
    --bad: #ff7b7b;
    --bad-bg: #3a1717;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
h2, h3, h4 { margin: 0; }
h2 { font-size: 16px; }
h3 { font-size: 18px; margin-bottom: 12px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 16px; }
.logo { color: var(--accent); font-size: 20px; }
.muted { color: var(--muted); }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 2px 10px; font-size: 12.5px; font-family: ui-monospace, monospace; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-value.small { font-size: 15px; padding-top: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--surface-2); }
td.actions { text-align: right; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
td.agent { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px 0 8px; margin: 0; }

.badge { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 600; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.off { color: var(--muted); background: var(--surface-2); }

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 14px; font: inherit; font-weight: 550; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }

input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=search] { width: 200px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 550; font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 22px; }
label.check input { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.suffix-input { display: flex; align-items: stretch; }
.suffix-input input { border-radius: 8px 0 0 8px; }
.suffix { background: var(--surface-2); border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; padding: 7px 10px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 12.5px; white-space: nowrap; display: flex; align-items: center; }
.error { color: var(--bad); margin: 0; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 12px; margin: 0 0 4px; font-weight: 550; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login-card p { margin: 0; }

dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); }
dialog:has(.wide) { width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 15, 20, .5); }
.dialog-body { padding: 22px; display: grid; gap: 12px; }
.dialog-body.wide { display: block; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; align-items: center; }
.kv > span { color: var(--muted); font-size: 13px; }
.copy-field { display: flex; align-items: center; gap: 8px; min-width: 0; }
.copy-field code { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; overflow-x: auto; white-space: nowrap; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.steps .copy-field { margin-top: 6px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-weight: 550; z-index: 50; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .container { padding: 16px; }
  .grid2, .kv { grid-template-columns: 1fr; }
  input[type=search] { width: 120px; }
  .kv > span { margin-top: 6px; }
}
