:root {
  color-scheme: light dark;
  font: 13px/20px -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --background: #f5f7f9;
  --wave: url("wave-light.svg");
  --panel: rgba(255,255,255,.62);
  --raised: rgba(255,255,255,.88);
  --solid: #fff;
  --text: #202b36;
  --muted: #4f5e70;
  --border: rgba(40,62,82,.16);
  --field: rgba(255,255,255,.62);
  --login-field: rgba(255,255,255,.55);
  --login-field-hover: rgba(255,255,255,.80);
  --login-field-border: rgba(40,62,82,.15);
  --control-border: rgba(40,62,82,.25);
  --hover: rgba(87,113,140,.11);
  --neutral: rgba(94,114,132,.10);
  --primary: #007aff;
  --primary-text: #005dc5;
  --primary-soft: rgba(0,122,255,.10);
  --primary-hover: rgba(0,122,255,.17);
  --primary-active: rgba(0,122,255,.23);
  --primary-border: rgba(0,122,255,.50);
  --danger: #ad2b38;
  --danger-soft: rgba(192,44,59,.10);
  --danger-border: rgba(192,44,59,.34);
  --success: #196344;
  --success-soft: rgba(32,133,87,.12);
  --warning: #825218;
  --warning-soft: rgba(174,112,24,.12);
  --shadow: 0 3px 14px rgba(34,52,72,.06);
  --input-height: 32px;
  --button-height: 28px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #14191e;
    --wave: url("wave-dark.svg");
    --panel: rgba(35,41,47,.62);
    --raised: rgba(33,40,47,.90);
    --solid: #21282f;
    --text: #edf3fa;
    --muted: #b5c4d4;
    --border: rgba(183,205,229,.20);
    --field: rgba(12,24,36,.38);
    --login-field: var(--field);
    --login-field-hover: rgba(80,101,123,.27);
    --login-field-border: rgba(183,205,229,.18);
    --control-border: rgba(183,205,229,.33);
    --hover: rgba(183,205,229,.12);
    --neutral: rgba(183,205,229,.09);
    --primary: #63adff;
    --primary-text: #91c6ff;
    --primary-soft: rgba(73,156,255,.17);
    --primary-hover: rgba(73,156,255,.27);
    --primary-active: rgba(73,156,255,.34);
    --primary-border: rgba(110,181,255,.55);
    --danger: #ffadb5;
    --danger-soft: rgba(233,98,112,.16);
    --danger-border: rgba(233,98,112,.42);
    --success: #89dbb2;
    --success-soft: rgba(80,174,126,.16);
    --warning: #f0c786;
    --warning-soft: rgba(190,133,64,.16);
    --shadow: 0 3px 14px rgba(0,0,0,.17);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background: var(--background) var(--wave) center / cover no-repeat fixed;
}
.admin-page { height: 100dvh; display: grid; grid-template-rows: auto minmax(0,1fr); }
.admin-page main { display: flex; min-width: 0; padding: 12px var(--gutter); }
.account-list { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.topbar {
  min-height: 40px;
  padding: 5px var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.panel, .topbar, dialog, .row-menu { background: var(--solid); }
@supports (backdrop-filter: blur(20px)) {
  .panel, .topbar { background: var(--panel); }
  dialog, .row-menu { background: var(--raised); }
  .panel, .topbar, dialog, .row-menu { backdrop-filter: blur(20px) saturate(115%); }
}
.panel { padding: 12px; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
h1, h2, p { margin: 0; }
h1 { font-size: 17px; line-height: 24px; font-weight: 600; }
h2 { font-size: 15px; line-height: 20px; font-weight: 600; }
input, button { font: inherit; color: inherit; }
input {
  min-width: 0;
  width: 100%;
  height: var(--input-height);
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--field);
}
input::placeholder { color: var(--muted); }
input:hover:not(:disabled) { background: var(--hover); border-color: var(--border); }
input:focus { border-color: var(--primary-border); outline: none; }
.keyboard input:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input[aria-invalid="true"] { border-color: var(--danger); }
button {
  min-width: var(--button-height);
  height: var(--button-height);
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--neutral);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--hover); }
button.primary { color: var(--primary-text); background: var(--primary-soft); }
button.primary:hover:not(:disabled) { background: var(--primary-hover); }
button.primary:active:not(:disabled) { background: var(--primary-active); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--neutral); }
button.danger { color: var(--danger); background: var(--danger-soft); }
button.danger:hover:not(:disabled) { border-color: var(--danger-border); background: var(--danger-soft); }
button:disabled, input:disabled { opacity: .56; cursor: default; }
button.icon { width: var(--button-height); padding: 0; }
button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.actions, .toolbar-search { display: flex; align-items: center; gap: 6px; }
.toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.toolbar-search { gap: 8px; }
.toolbar-search label { white-space: nowrap; }
.toolbar-search input { width: clamp(180px, 31vw, 240px); max-width: 100%; }
label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); }
.muted, .field-note { color: var(--muted); }
.field-note { margin-bottom: 8px; }
.error { color: var(--danger); font-size: 12px; line-height: 18px; }
.table-wrap { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.table-wrap:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
table { width: 100%; min-width: 480px; border-spacing: 0; text-align: left; background: var(--solid); }
th, td { padding: 4px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 36px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--table-heading);
  border-block-color: var(--rule);
  border-top: 1px solid var(--rule);
}
td { height: 40px; overflow-wrap: anywhere; }
td:first-child { padding-block: 8px; }
tbody tr:hover { background: var(--neutral); }
.center { text-align: center; }
td .actions { justify-content: center; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; justify-content: center; min-height: 22px; padding: 0 8px; border-radius: 6px; background: var(--neutral); color: var(--muted); font-size: 12px; }
.pill[data-state="running"] { color: var(--success); background: var(--success-soft); }
.pill[data-state="working"], .pill[data-state="queued"], .pill[data-state="provisioning"] { color: var(--primary-text); background: var(--primary-soft); }
.pill[data-state="degraded"], .pill[data-state="offline"] { color: var(--warning); background: var(--warning-soft); }
.pill[data-state="failed"], .pill[data-state="operation_failed"] { color: var(--danger); background: var(--danger-soft); }
.uptime-anchor { display: inline-block; white-space: nowrap; }
.uptime-button { text-decoration: underline dotted; text-underline-offset: 3px; }
.uptime-tooltip {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 6px 8px;
  max-width: calc(100vw - 16px);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--solid);
  color: var(--text);
  box-shadow: var(--shadow);
}
.row-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 128px;
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 4px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.row-menu:popover-open { display: grid; gap: 2px; }
.row-menu button { justify-content: flex-start; }
dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog::backdrop { background: rgba(15,23,34,.28); }
dialog form { margin: 0; display: flex; flex-direction: column; gap: 12px; max-height: calc(100dvh - 66px); }
.dialog-body { overflow: auto; overscroll-behavior: contain; display: grid; gap: 12px; padding: 2px; }
.dialog-actions { justify-content: flex-end; }
form label { display: grid; gap: 4px; }
#initial-password { padding: 8px 10px; border-radius: 6px; background: var(--field); font: 13px/20px ui-monospace, monospace; user-select: all; overflow-wrap: anywhere; }
#runtime-details dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; }
#runtime-details dt { color: var(--muted); }
#runtime-details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.login-page { padding: 12px; display: grid; place-items: center; }
.login-panel { width: min(100%, 384px); padding: 16px; }
.login-panel form { display: grid; gap: 12px; margin-top: 12px; }
.login-panel .actions { justify-content: flex-end; }
.bot-login { display: grid; gap: 12px; }
.bot-login h1 { font-size: 15px; line-height: 20px; }
.bot-login form { margin: 0; }
.login-fields { display: grid; gap: 4px; }
.login-fields-group { display: grid; gap: 12px; }
.bot-login input {
  font-size: 13px;
  line-height: 20px;
  background: var(--login-field);
  border-color: var(--login-field-border);
}
.bot-login input:hover:not(:disabled):not(:focus):not([aria-invalid="true"]) {
  background: var(--login-field-hover);
  border-color: var(--control-border);
}
.bot-login input:disabled { background: var(--neutral); }
.bot-login input:focus { border-color: var(--primary-border); }
.bot-login input[aria-invalid="true"] { border-color: var(--danger); }
.bot-login button[type="submit"] { display: inline-grid; }
.login-button-label, .login-button-loading { grid-area: 1 / 1; }
.login-button-loading, .bot-login button[aria-busy="true"] .login-button-label { visibility: hidden; }
.bot-login button[aria-busy="true"] .login-button-loading { visibility: visible; }
.login-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 6px;
  background: var(--neutral);
}
.login-methods > :is(button, .login-redirect) {
  flex: 1 1 96px;
  justify-content: center;
  background: transparent;
  color: var(--muted);
}
.login-methods .login-redirect:hover { color: var(--primary-text); background: var(--hover); }
.login-methods .login-redirect[aria-disabled="true"] { opacity: .56; cursor: default; }
.login-methods button[aria-pressed="true"] { color: var(--primary-text); background: var(--primary-soft); }
.login-methods button[aria-pressed="true"]:hover:not(:disabled) { background: var(--primary-hover); }
.login-methods button[aria-pressed="true"]:active:not(:disabled) { background: var(--primary-active); }
.login-feedback { color: var(--muted); font-size: 12px; line-height: 18px; }
.login-feedback:empty { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.login-feedback[data-error] { color: var(--danger); }
.login-redirect {
  min-height: var(--button-height);
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--text);
  background: var(--neutral);
  font-weight: 500;
  text-decoration: none;
}
.login-redirect:hover { background: var(--hover); }
.login-redirect:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 760px), (pointer: coarse) {
  :root { --input-height: 44px; --button-height: 44px; }
  button { font-size: 14px; }
  button svg { width: 18px; height: 18px; }
  input { font-size: 16px; line-height: 22px; padding-inline: 12px; }
  label { font-size: 13px; line-height: 18px; }
  .bot-login { padding: 12px; }
  .bot-login input { font-size: 16px; line-height: 22px; }
  .login-redirect { font-size: 14px; }
  td { height: 52px; }
  .pill { min-height: 24px; }
  dialog { width: calc(100vw - 24px); padding: 12px; max-height: calc(100dvh - 24px); }
  dialog form { max-height: calc(100dvh - 50px); }
}
@media (max-width: 520px) {
  .toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .toolbar-search { grid-column: 1 / -1; }
  .toolbar-search input { flex: 1; width: auto; }
}

:root.admin-theme {
  color-scheme: light;
  --gutter: 24px;
  --background: #edf4fa;
  --solid: #f9fcff;
  --table-heading: #e2eef9;
  --text: #102d4d;
  --muted: #41607f;
  --border: #ccdbeb;
  --rule: #8caac8;
  --grid-line: #cbdff0;
  --field: #f9fcff;
  --hover: #dfecf8;
  --neutral: #e8f1fa;
  --primary: #195c9d;
  --primary-text: #154f88;
  --primary-soft: #dcecfb;
  --primary-hover: #cde4f9;
  --primary-active: #bddaf4;
  --primary-border: #4780b4;
  --danger: #a52b3d;
  --danger-soft: #fae8ee;
  --danger-border: #c16f7e;
  --success: #17654d;
  --success-soft: #e1f2eb;
  --warning: #795014;
  --warning-soft: #f7efd9;
  --scrollbar-thumb: #6389ac;
  --shadow: none;
}
:root.admin-theme[data-color-scheme="dark"] {
  color-scheme: dark;
  --background: #131f37;
  --solid: #192740;
  --table-heading: #20334f;
  --text: #e0edfd;
  --muted: #adc4df;
  --border: #314a68;
  --rule: #597ba3;
  --grid-line: #263e5d;
  --field: #192740;
  --hover: #253c58;
  --neutral: #233552;
  --primary: #9acaff;
  --primary-text: #c1deff;
  --primary-soft: #25456b;
  --primary-hover: #2d5280;
  --primary-active: #365f91;
  --primary-border: #78a9da;
  --danger: #ffbac6;
  --danger-soft: #492838;
  --danger-border: #c77a89;
  --success: #a4e2cd;
  --success-soft: #1d3e40;
  --warning: #f2d397;
  --warning-soft: #413629;
  --scrollbar-thumb: #769bc2;
}
.admin-theme body {
  background:
    linear-gradient(var(--background), var(--background)) center / calc(100% - 2 * var(--gutter)) 100% no-repeat,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) center / 12px 12px,
    linear-gradient(var(--grid-line) 1px, transparent 1px) center / 12px 12px var(--background);
}
.admin-theme :is(.topbar, .login-panel, dialog, .row-menu) {
  background: var(--solid);
  backdrop-filter: none;
}
.admin-theme input { border-color: var(--rule); }
.admin-theme input:focus { border-color: var(--primary-border); }
.admin-theme input[aria-invalid="true"] { border-color: var(--danger); }
.admin-theme button.primary { border-color: var(--primary-border); }
#color-scheme[aria-pressed="true"] {
  color: var(--primary-text);
  background: var(--primary-soft);
}
.admin-theme #count { font-variant-numeric: tabular-nums; }
.admin-page th:last-child { text-align: right; }
.admin-page td .actions { justify-content: flex-end; }

.admin-theme, .admin-theme [data-scroll-area] {
  --scroll-thumb: transparent;
}
.admin-theme [data-scroll-area] { scrollbar-gutter: stable; }
.admin-theme.show-scrollbar, .admin-theme [data-scroll-area].show-scrollbar {
  --scroll-thumb: var(--scrollbar-thumb);
}
.admin-theme::-webkit-scrollbar, .admin-theme [data-scroll-area]::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
.admin-theme::-webkit-scrollbar-thumb, .admin-theme [data-scroll-area]::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: var(--scroll-thumb);
}
.admin-theme::-webkit-scrollbar-track, .admin-theme [data-scroll-area]::-webkit-scrollbar-track,
.admin-theme::-webkit-scrollbar-corner, .admin-theme [data-scroll-area]::-webkit-scrollbar-corner {
  background: transparent;
}
@supports not selector(::-webkit-scrollbar) {
  .admin-theme, .admin-theme [data-scroll-area] {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) transparent;
  }
}
@media (max-width: 760px), (pointer: coarse) {
  :root.admin-theme { --gutter: 12px; }
}
