:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-subtle: #fafafa;
  --surface-hover: #f5f3ff;
  --border: #e5e5e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --accent: #635bdb;
  --accent-hover: #554ec4;
  --accent-soft: #eeedff;
  --ok: #16804a;
  --ok-soft: #e8f7ef;
  --warning: #9a5b12;
  --warning-soft: #fff5e5;
  --danger: #c43b45;
  --danger-soft: #fff0f1;
  --radius: 12px;
  --radius-control: 7px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html.dark {
    --bg: #0f1012;
    --surface: #151619;
    --surface-subtle: #191a1e;
    --surface-hover: #201f32;
    --border: #292a2f;
    --border-strong: #3a3b42;
    --text: #f1f1f3;
    --muted: #a1a1aa;
    --faint: #71717a;
    --accent: #8b84f8;
    --accent-hover: #9b95ff;
    --accent-soft: #292744;
    --ok: #59c98a;
    --ok-soft: #162a20;
    --warning: #edb45d;
    --warning-soft: #2d2418;
    --danger: #f08087;
    --danger-soft: #321b1e;
}

* { box-sizing: border-box; }

html { scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.dialog-open { overflow: hidden; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap { width: 100%; max-width: 1088px; margin: 0 auto; padding-inline: 24px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-160%); padding: 8px 12px; border-radius: var(--radius-control); background: var(--text); color: var(--surface); }
.skip-link:focus { transform: translateY(0); }

.topbar { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border); background: var(--bg); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 650; letter-spacing: -.01em; text-decoration: none; }
.brand-mark { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-linejoin: round; stroke-width: 1.5; }
.brand-mark path:last-child { fill: var(--accent); stroke: none; }
.nav { display: flex; align-items: center; gap: 16px; }
.nav-hint, .nav-user { color: var(--muted); font-size: 12px; }
.nav-link, .nav-action { color: var(--muted); font-size: 13px; text-decoration: none; transition: color 140ms ease; }
.nav-link:hover, .nav-action:hover { color: var(--text); }
.inline-form { margin: 0; }
.nav-action { border: 0; background: transparent; cursor: pointer; padding: 6px 0; }

.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 44px 0 24px; }
.page-intro h1, .page-head h1, .auth-copy h1 { margin: 10px 0 4px; font-size: clamp(25px, 4vw, 32px); line-height: 1.15; letter-spacing: -.035em; }
.page-intro p, .page-head p, .auth-copy p { margin: 0; color: var(--muted); }
.system-state { display: inline-flex; align-items: center; gap: 7px; color: var(--ok); font-size: 12px; font-weight: 600; }
.system-state span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.context-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.context-meta span { padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; }

.panel, .form-card, .panel-form { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel { overflow: hidden; margin-bottom: 28px; }
.panel-head, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-head h2, .card-head h2 { margin: 0; font-size: 14px; line-height: 1.3; }
.panel-head p, .card-kicker { margin: 2px 0 0; color: var(--muted); font-size: 11px; }

.btn { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--accent); border-radius: var(--radius-control); background: var(--accent); color: #fff; cursor: pointer; font-size: 13px; font-weight: 600; line-height: 1; text-decoration: none; transition: background 140ms ease, border-color 140ms ease; }
.btn:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }
.btn.secondary { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.btn.secondary:hover { background: var(--surface-subtle); }
.btn-wide { width: 100%; min-height: 38px; }

.server-list { display: flex; flex-direction: column; }
.server-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 64px; padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; transition: background 140ms ease; }
.server-row:last-child { border-bottom: 0; }
.server-row:hover { background: var(--surface-hover); }
.server-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.server-icon { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-subtle); color: var(--muted); }
.server-icon svg, .empty-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.5; }
.server-copy { min-width: 0; }
.server-copy strong, .server-copy span { display: block; }
.server-copy strong { font-size: 13px; font-weight: 620; }
.server-copy span { overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.server-signals { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.row-arrow { width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-size: 11px; font-weight: 600; text-transform: capitalize; }
.badge.supported, .badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.unsupported_raw { background: var(--danger-soft); color: var(--danger); }
.check-state { color: var(--muted); font-size: 11px; }
.check-state.enabled { color: var(--ok); }

.empty { display: grid; justify-items: center; padding: 54px 24px 58px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-subtle); color: var(--muted); }
.empty-title { margin: 0 0 5px; font-weight: 620; }
.empty-sub { max-width: 48ch; margin: 0; color: var(--muted); font-size: 13px; }

.auth-shell { display: grid; grid-template-columns: 1fr minmax(320px, 400px); gap: 64px; align-items: center; min-height: calc(100vh - 160px); padding: 56px 0; }
.auth-shell.compact { max-width: 800px; margin: 0 auto; }
.auth-copy h1 { margin-top: 0; }
.form-card, .server-form { display: flex; flex-direction: column; gap: 16px; padding: 22px; }
.form-card { box-shadow: none; }
.form-wide { max-width: 720px; margin-bottom: 36px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-card label, .server-form > label, .form-grid label { display: flex; flex-direction: column; gap: 6px; color: var(--text); font-size: 12px; font-weight: 600; }
.field-label { display: flex; justify-content: space-between; align-items: center; }
.form-card input:not([type="checkbox"]), .server-form input:not([type="checkbox"]), .form-card select { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-control); outline: 0; background: var(--surface); color: var(--text); }
.form-card input:focus, .server-form input:focus, .form-card select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-card small, .server-form small { color: var(--muted); font-weight: 400; }
.form-error { padding: 9px 11px; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border)); border-radius: var(--radius-control); background: var(--danger-soft); color: var(--danger); font-size: 12px; }
.form-help { margin: 4px 0 0; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.optional { color: var(--muted); font-size: 11px; font-weight: 400; }
.toggle-row { flex-direction: row !important; align-items: flex-start; gap: 10px !important; padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-subtle); }
.toggle-row input { margin: 3px 0 0; accent-color: var(--accent); }
.toggle-row strong, .toggle-row small { display: block; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 2px; }

.dialog { width: min(600px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); padding: 0; overflow: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .24); }
.dialog::backdrop { background: rgba(12, 12, 14, .52); }
.dialog[open] { animation: dialog-enter 180ms ease-out; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 22px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0 0 3px; font-size: 17px; letter-spacing: -.015em; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 12px; }
.icon-btn { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { border-color: var(--border); background: var(--surface-subtle); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.6; }
@keyframes dialog-enter { from { opacity: 0; transform: translateY(6px) scale(.99); } }

.page-head { padding: 38px 0 22px; }
.back-link { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 12px; text-decoration: none; }
.back-link:hover { color: var(--text); }
.back-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.title-line { display: flex; align-items: center; gap: 12px; }
.notice-card { margin: 0 0 20px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--warning) 55%, var(--border)); border-radius: var(--radius); background: var(--warning-soft); }
.notice-card p { margin: 4px 0 10px; color: var(--muted); font-size: 12px; }
.notice-card code { display: block; overflow-wrap: anywhere; font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.card { overflow: hidden; margin: 0 0 28px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.facts { margin: 0; }
.facts > div { display: flex; justify-content: space-between; gap: 20px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-size: 12px; text-align: right; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 16px; }
.setting-row p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: relative; display: block; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); cursor: pointer; transition: background 160ms ease; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform 160ms ease; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }

.users-grid { display: grid; grid-template-columns: 1.25fr .9fr; gap: 18px; align-items: start; }
.user-list { display: flex; flex-direction: column; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: 0; }
.user-row strong, .user-row span { display: block; }
.user-row div span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.footer { display: flex; gap: 7px; padding-block: 22px 36px; color: var(--muted); font-size: 11px; }

@media (max-width: 720px) {
  .wrap { padding-inline: 16px; }
  .nav-hint, .nav-user { display: none; }
  .page-intro { display: block; padding-top: 32px; }
  .context-meta { justify-content: flex-start; margin-top: 16px; }
  .auth-shell, .detail-grid, .users-grid { grid-template-columns: 1fr; gap: 24px; }
  .auth-shell { min-height: auto; padding: 40px 0; }
  .form-grid { grid-template-columns: 1fr; }
  .server-row { align-items: flex-start; flex-direction: column; gap: 8px; padding-block: 13px; }
  .server-signals { width: 100%; padding-left: 45px; }
  .row-arrow { margin-left: auto; }
  .dialog { width: 100%; max-width: none; max-height: calc(100vh - 32px); margin: auto 0 0; border-radius: 16px 16px 0 0; border-width: 1px 0 0; }
  .dialog-head, .server-form { padding-inline: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

a { text-decoration: none; }
button { outline: none; border: none; background: transparent; cursor: pointer; }
html.dark { color-scheme: dark; }

/* Fix borders since preflight is disabled */
input, button, select, textarea {
  font-family: inherit;
  font-size: 100%;
  margin: 0;
  box-sizing: border-box;
}
input {
  color: inherit;
}

input:focus, button:focus, select:focus, textarea:focus {
  outline: none;
}

/* Make sure elements with Tailwind border classes actually show a solid border instead of browser defaults */
