:root {
  color-scheme: dark;
  --bg: #090d14;
  --surface: #111722;
  --raised: #171f2c;
  --hover: #202a39;
  --border: #2a3546;
  --text: #f4f7fb;
  --muted: #aab6c7;
  --accent: #5ba7ff;
  --accent-strong: #2c8cf4;
  --success: #55d69e;
  --danger: #ff7b89;
  --warning: #f3c66d;
  --radius: 8px;
  --sidebar: 236px;
  --topbar: 56px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: #91c5ff; }
button, input, textarea, select { font: inherit; }
button, .button { min-height: 2.25rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 100; top: .5rem; left: .5rem; padding: .55rem .8rem; border-radius: 6px; background: var(--text); color: var(--bg); transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.topbar { position: fixed; z-index: 20; inset: 0 0 auto; height: var(--topbar); display: flex; align-items: center; gap: 1rem; padding: 0 1.1rem; border-bottom: 1px solid var(--border); background: #0c121b; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--text); font-size: .98rem; font-weight: 750; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 6px; background: var(--accent-strong); color: white; font-size: .85rem; }
.topbar-context { color: var(--muted); font-size: .8rem; }
.nav-toggle { display: none; margin-left: auto; }

.sidebar { position: fixed; z-index: 10; inset: var(--topbar) auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; overflow-y: auto; padding: .7rem .55rem 1rem; border-right: 1px solid var(--border); background: #0c121b; }
.sidebar nav { display: grid; gap: .12rem; }
.sidebar a { position: relative; padding: .42rem .7rem; border-radius: 6px; color: #c9d4e4; font-size: .86rem; text-decoration: none; }
.sidebar a:hover { background: var(--hover); color: white; }
.sidebar a.is-active { background: rgb(91 167 255 / 14%); color: #fff; font-weight: 650; }
.sidebar a.is-active::before { content: ""; position: absolute; inset: .38rem auto .38rem 0; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent); }
.sidebar a.is-active:hover { background: rgb(91 167 255 / 20%); color: #fff; }
.nav-label { margin: 1rem .7rem .28rem; color: #7f8ca0; font-size: .68rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.nav-label:first-child { margin-top: .15rem; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; }
.sidebar-footer button { width: 100%; margin-top: 0; }

.content { max-width: 1440px; margin-left: var(--sidebar); padding: calc(var(--topbar) + 1.35rem) 1.75rem 2.5rem; }
.auth-page .content { max-width: 420px; margin: 0 auto; padding-top: 16vh; }
.auth-page:has(.onboard) .content { max-width: 36rem; padding-top: 8vh; }
.auth-page .topbar { justify-content: center; }
.button-large { min-height: 3rem; padding: .75rem 1.15rem; font-size: 1rem; }
.onboard-code { max-width: 12rem; letter-spacing: .28em; font-size: 1.35rem; font-weight: 700; text-align: center; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -.018em; }
h1 { margin: 0 0 .45rem; font-size: clamp(1.35rem, 2.2vw, 1.7rem); font-weight: 750; }
h2 { margin: 0 0 .65rem; font-size: 1.02rem; }
h3 { margin: 0 0 .4rem; font-size: .95rem; }
p { margin: .45rem 0 .8rem; color: #d3dbe7; }
.muted { color: var(--muted); }
h1 + p, h1 + .muted { margin-top: 0; max-width: 52rem; }
ul { margin: .35rem 0 0; padding-left: 1.15rem; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .7rem 1.2rem; margin-bottom: 1.05rem; }
.page-header h1 { margin: 0; }
.page-header .muted, .page-header p { margin: .28rem 0 0; max-width: 46rem; color: var(--muted); }
.page-header .actions, .page-header-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-left: auto; }
.page-header .actions button, .page-header .actions .button,
.page-header-actions button, .page-header-actions .button { margin-top: 0; }

.card { margin-bottom: .9rem; padding: 1.05rem 1.15rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 22px rgb(0 0 0 / 16%); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .85rem; }
.card-grid .card { margin: 0; }
.card > article { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.card > article:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.download-card { display: flex; min-height: 138px; flex-direction: column; }
.download-card .button { align-self: flex-start; margin-top: auto; }
.notice { border-left: 3px solid var(--warning); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: .75rem; margin: 0 0 1.05rem; }
.stat-card { margin: 0; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stat-card .label, .stat-card dt { color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.stat-card .value, .stat-card dd { margin: .3rem 0 0; color: var(--text); font-size: 1.45rem; font-weight: 750; letter-spacing: -.03em; line-height: 1.15; }
.stat-card .muted, .stat-card p { margin: .3rem 0 0; font-size: .8rem; }

.pill { display: inline-flex; align-items: center; gap: .25rem; max-width: 100%; padding: .12rem .5rem; border: 1px solid var(--border); border-radius: 999px; background: var(--raised); color: var(--muted); font-size: .72rem; font-weight: 650; line-height: 1.3; vertical-align: middle; }
.pill-ok { border-color: rgb(85 214 158 / 30%); background: rgb(85 214 158 / 14%); color: var(--success); }
.pill-muted { border-color: var(--border); background: var(--hover); color: var(--muted); }
.pill-bad { border-color: rgb(255 123 137 / 30%); background: rgb(255 123 137 / 14%); color: var(--danger); }
.card-danger { border-color: rgb(255 123 137 / 42%); }
.button-danger { border-color: #b54756; background: #b54756; }
.button-danger:hover { border-color: var(--danger); background: #d45d6c; color: white; }

.tabs { display: flex; flex-wrap: wrap; gap: .15rem; margin: 0 0 .9rem; padding: 0; border-bottom: 1px solid var(--border); list-style: none; }
.tabs a, .tabs button { min-height: 0; margin: 0 0 -1px; padding: .5rem .8rem; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); font-weight: 650; text-decoration: none; }
.tabs a:hover, .tabs button:hover { background: transparent; color: var(--text); border-color: transparent; }
.tabs a.is-active, .tabs a[aria-current="page"], .tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.empty-state { padding: 2.1rem 1.15rem; text-align: center; }
.empty-state h2, .empty-state h3 { margin: 0 0 .35rem; color: var(--text); }
.empty-state p { margin: 0 auto; max-width: 34rem; color: var(--muted); }
.empty-state .button, .empty-state button { margin-top: .9rem; }

.flash, .flash-success, p.success { margin: 0 0 .85rem; padding: .65rem .85rem; border: 1px solid rgb(85 214 158 / 28%); border-left-width: 3px; border-radius: 6px; background: rgb(85 214 158 / 10%); color: var(--success); }
.flash-error, p.error { margin: 0 0 .85rem; padding: .65rem .85rem; border: 1px solid rgb(255 123 137 / 28%); border-left-width: 3px; border-radius: 6px; background: rgb(255 123 137 / 10%); color: var(--danger); }
.success { color: var(--success); }
.error { color: var(--danger); }

.table-scroll, .card:has(> table) { overflow-x: auto; }
.table-scroll { max-height: min(72vh, 44rem); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: .55rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .68rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.table-scroll th { position: sticky; top: 0; z-index: 1; background: var(--surface); box-shadow: 0 1px 0 var(--border); }
tbody tr:hover { background: rgb(91 167 255 / 5%); }
table button, table .button { margin-top: 0; }
.rustdesk-id-cell { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; white-space: normal; }

label { display: block; margin: .75rem 0 .28rem; color: #dce4ef; font-size: .82rem; font-weight: 650; }
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { display: flex; align-items: center; gap: .5rem; margin: .35rem 0; font-weight: 500; }
input, textarea, select { width: min(100%, 40rem); padding: .5rem .7rem; border: 1px solid #3a4658; border-radius: 6px; background: #0b1018; color: var(--text); }
textarea { min-height: 6.5rem; resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: #58677c; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent-strong); }
fieldset { margin: .85rem 0 0; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 6px; }
legend { padding: 0 .3rem; color: var(--muted); font-size: .75rem; font-weight: 650; }

button, .button { display: inline-flex; align-items: center; justify-content: center; margin-top: .75rem; padding: .4rem .8rem; border: 1px solid var(--accent-strong); border-radius: 6px; background: var(--accent-strong); color: white; font-size: .86rem; font-weight: 650; cursor: pointer; text-decoration: none; }
button:hover, .button:hover { border-color: var(--accent); background: #3c99fa; color: white; }
.button-secondary, .copy-button { border-color: var(--border); background: var(--raised); color: #e5ebf3; }
.button-secondary:hover, .copy-button:hover { background: var(--hover); }
.copy-button { min-height: 1.85rem; margin: .15rem; padding: .18rem .5rem; font-size: .74rem; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .95rem; }
.form-actions button, .form-actions .button { margin-top: 0; }
form > button + button, form > button + .button, form > .button + .button, form > .button + button { margin-left: .15rem; }
form[action$="/archive"] button { border-color: #7a3842; background: #5c2a33; }
form[action$="/archive"] button:hover { border-color: var(--danger); background: #74343e; }
form[action$="/unarchive"] button { border-color: var(--border); background: var(--raised); color: #e5ebf3; }
form:has(> #term) { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem .6rem; }
form:has(> #term) label { flex: 1 1 100%; margin-bottom: 0; }
form:has(> #term) input { flex: 1 1 16rem; width: auto; max-width: 28rem; }
form:has(> #term) button, form:has(> #term) .button { margin-top: 0; }

.inline-form { display: inline; }
.inline-form button { margin-top: 0; }
.checkbox-row, .input-with-copy { display: flex; align-items: center; gap: .5rem; }
.checkbox-row label { margin: 0; }
.input-with-copy input { flex: 1; }

pre, code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
pre { overflow: auto; padding: .85rem; border: 1px solid var(--border); border-radius: 6px; background: #080c12; color: #dce8f8; font-size: .78rem; white-space: pre-wrap; word-break: break-word; }
code { font-size: .84em; }
.config-list { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; }
.config-list dt { color: var(--muted); font-weight: 650; }
.config-list dd { margin: 0; overflow-wrap: anywhere; }
.qr-code { display: inline-block; padding: .7rem; border-radius: 8px; background: white; }
.qr-code svg { display: block; width: min(240px, 65vw); height: auto; }
.status-summary dt { margin-top: .4rem; font-weight: 650; }
.status-summary dd { margin: .1rem 0 .4rem; }

@media (max-width: 820px) {
  .topbar-context { display: none; }
  .nav-toggle { display: inline-flex; }
  .sidebar { display: none; width: min(86vw, 300px); box-shadow: 12px 0 40px rgb(0 0 0 / 45%); }
  .sidebar.is-open { display: flex; }
  .content { margin-left: 0; padding: calc(var(--topbar) + 1rem) 1rem 2rem; }
  .auth-page .content { padding: 22vh 1rem 2rem; }
  .card { padding: .9rem; }
  .config-list { grid-template-columns: 1fr; gap: .12rem; }
  .config-list dd { margin-bottom: .55rem; }
  .page-header .actions, .page-header-actions { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
