:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #16181d; --text-2: #5b616e; --line: #e3e6eb; --hover: #eef0f4;
  --accent: #4f6bed; --accent-ink: #3550d4; --danger: #c62f2f; --ok: #1b7f4b; --warn: #a15c00;
  --r: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --card: #1a1d23; --text: #e8eaee; --text-2: #9aa1ad; --line: #2a2e36; --hover: #232731;
    --accent: #6b83f2; --accent-ink: #8ea0f5; --danger: #f07272; --ok: #4cc488; --warn: #e0a24a;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 18px; }
h2 { font-size: 15px; font-weight: 650; margin: 22px 0 10px; display: flex; align-items: center; gap: 10px; }
.card h2 { margin-top: 0; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.wrap { overflow-wrap: anywhere; max-width: 360px; }
.bad { color: var(--danger); }
.error { color: var(--danger); margin: 8px 0 0; min-height: 1em; }
.pad { padding: 14px 16px; margin: 0; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; }
.btn:hover { background: var(--hover); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.signin { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.signin-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 32px; display: grid; gap: 12px; justify-items: start; box-shadow: var(--shadow); }
.signin-card h1 { margin: 6px 0 0; }
.signin-card p { margin: 0 0 8px; color: var(--text-2); }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.nav { background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; padding: 4px 8px 18px; }
.brand em { font-style: normal; font-weight: 500; color: var(--text-2); }
#nav { display: grid; gap: 2px; }
#nav a { padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 550; }
#nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
#nav a[aria-current="page"] { background: var(--hover); color: var(--text); }
.me { margin-top: auto; display: grid; gap: 6px; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
main { min-width: 0; }
.env { padding: 6px 28px; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.env.local { color: var(--text-2); }
.env.staging { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.env.prod { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.view { padding: 24px 28px 64px; max-width: 1240px; outline: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow-x: auto; }
.card.error { color: var(--danger); }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-bottom: 12px; align-items: start; }
.stat { display: grid; gap: 4px; }
.stat span { color: var(--text-2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat b { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat em { font-style: normal; color: var(--text-2); font-size: 12px; }
.bar { display: block; width: 100%; height: 8px; margin: -4px 0 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.card:not(.flush) table th:first-child, .card:not(.flush) table td:first-child { padding-left: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
table.click tbody tr { cursor: pointer; }
table.click tbody tr:hover { background: var(--hover); }
td.actions { white-space: nowrap; display: flex; gap: 6px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 420px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 99px; background: var(--hover); white-space: nowrap; }
.pill.none { color: var(--ok); }
.pill.network { color: var(--warn); }
.pill.suspended, .pill.full, .pill.revoked { color: var(--danger); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 16px; margin: 0 0 12px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.form { display: grid; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row.end { justify-content: flex-end; }
label { display: grid; gap: 5px; font-size: 13px; font-weight: 550; flex: 1; min-width: 160px; }
label.check { display: flex; align-items: center; gap: 8px; }
label.inline { grid-template-columns: 1fr 110px; align-items: center; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-height: 34px; }
textarea { resize: vertical; }
input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; }
.filters input { min-width: 260px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 22px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(10, 12, 16, .45); }
dialog form { display: grid; gap: 12px; }
dialog h2 { margin: 0; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 550; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: 420px; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  #nav { display: flex; flex-wrap: wrap; }
  .me { margin: 0; border: 0; }
  .view { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
