:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18201c;
  background: #f4f6f4;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.brand {
  color: #126149;
  font-size: 20px;
  font-weight: 750;
}

.login-page {
  color-scheme: dark;
  background: #000;
  color: #fafafa;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 400px);
  border: 1px solid #303030;
  border-radius: 8px;
  padding: 30px;
  background: #0a0a0a;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .6);
}

.login-panel .brand {
  color: #fafafa;
  font-size: 14px;
  font-weight: 600;
}

h1 { margin: 20px 0; font-size: 26px; }
label { display: grid; gap: 7px; margin: 14px 0; color: #49544e; font-size: 13px; font-weight: 650; }
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c9d1cc;
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: #18201c;
  outline: none;
}
input:focus { border-color: #19765a; box-shadow: 0 0 0 3px rgba(25, 118, 90, .14); }

.login-panel h1 {
  margin: 22px 0 24px;
  color: #fafafa;
  font-size: 24px;
  font-weight: 600;
}

.login-panel label {
  gap: 8px;
  margin: 0 0 16px;
  color: #a0a0a0;
  font-size: 12px;
  font-weight: 500;
}

.login-panel input {
  min-height: 40px;
  border-color: #303030;
  background: #151515;
  color: #fafafa;
  caret-color: #fafafa;
}

.login-panel input:hover {
  border-color: #404040;
}

.login-panel input:focus,
.login-panel input:focus-visible {
  border-color: #626262;
  outline: none;
  box-shadow: none;
}

button {
  min-height: 38px;
  border: 1px solid #126149;
  border-radius: 6px;
  padding: 8px 14px;
  background: #126149;
  color: #fff;
  font-weight: 700;
}
button:hover { background: #0c513d; }
button:disabled { cursor: wait; opacity: .65; }
.login-panel button {
  width: 100%;
  min-height: 40px;
  margin-top: 4px;
  border-color: #f0f0f0;
  background: #f0f0f0;
  color: #0a0a0a;
  font-size: 12px;
  font-weight: 600;
}
.login-panel button:hover {
  border-color: #fff;
  background: #fff;
}
.login-panel button:focus-visible {
  border-color: #626262;
  outline: 1px solid #626262;
  outline-offset: 2px;
  box-shadow: none;
}
.login-panel button:disabled {
  border-color: #626262;
  background: #626262;
}
.login-panel .error {
  margin: -2px 0 10px;
  color: #f17a7a;
}
.error, .page-error { min-height: 20px; color: #a52b2b; font-size: 13px; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid #dce2de;
  background: #fff;
}
.summary { margin-top: 4px; color: #68736d; font-size: 13px; }
.quiet {
  border-color: #cbd3ce;
  background: #fff;
  color: #344039;
}
.quiet:hover { background: #f0f3f1; }

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 18px clamp(18px, 4vw, 56px);
  background: #fff;
  border-bottom: 1px solid #e2e6e3;
}
.search { position: relative; display: block; margin: 0; }
.search span { position: absolute; left: 12px; top: 8px; color: #68736d; font-size: 20px; }
.search input { padding-left: 38px; }
.filters { display: flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid #d5dcd7; border-radius: 7px; }
.filters button {
  min-height: 32px;
  border: 0;
  padding: 6px 10px;
  background: transparent;
  color: #59645e;
}
.filters button:hover, .filters button.active { background: #e8f1ed; color: #0d5b42; }

.page-error { margin: 16px clamp(18px, 4vw, 56px) 0; }
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 20px clamp(18px, 4vw, 56px) 48px;
}
.profile-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid #d9dfdb;
  border-radius: 8px;
  background: #fff;
}
.profile-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.profile-name { min-width: 0; font-size: 16px; font-weight: 750; overflow-wrap: anywhere; }
.status {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e9ecea;
  color: #55605a;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}
.status.running { background: #dff3e9; color: #126149; }
.status.waking { background: #fff0c9; color: #825c00; }
.status.draining { background: #e5ebf6; color: #31558d; }
.status.failed { background: #f9dddd; color: #9a2929; }
.profile-user { margin: 11px 0 4px; color: #344039; overflow-wrap: anywhere; }
.profile-meta { min-height: 20px; color: #758079; font-size: 12px; }
.profile-actions { display: flex; gap: 8px; margin-top: 17px; }
.profile-actions .open { flex: 1; }
.profile-actions .sleep { border-color: #d7b3b3; color: #8b2929; background: #fff; }
.profile-actions .sleep:hover { background: #fff0f0; }
.empty { padding: 80px 24px; text-align: center; color: #6c7771; }

.viewer-page {
  --viewer-tabbar-height: 38px;
  --viewer-meta-height: 24px;
  --viewer-bg: #000;
  --viewer-surface: #0a0a0a;
  --viewer-surface-2: #151515;
  --viewer-surface-3: #1e1e1e;
  --viewer-border: #1c1c1c;
  --viewer-border-strong: #303030;
  --viewer-fg: #fafafa;
  --viewer-muted: #828282;
  --viewer-subtle: #626262;
  --viewer-accent: #ea4b71;
  --viewer-accent-hover: #d43c62;
  --viewer-danger: #dc4646;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--viewer-tabbar-height) minmax(0, 1fr) var(--viewer-meta-height);
  overflow: hidden;
  background: var(--viewer-bg);
  color: var(--viewer-fg);
  color-scheme: dark;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.viewer-page.viewer-empty {
  grid-template-rows: var(--viewer-tabbar-height) minmax(0, 1fr);
}
.viewer-page.viewer-empty .viewer-meta {
  display: none;
}
.sr-only {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.viewer-chrome {
  height: var(--viewer-tabbar-height);
  overflow: hidden;
  border-bottom: 1px solid var(--viewer-border);
  background: var(--viewer-bg);
}
.viewer-tabbar {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
}
.viewer-page .viewer-icon.mobile-tabs-button,
.viewer-page .viewer-icon.mobile-status-button,
.mobile-tabs-menu {
  display: none;
}
.viewer-page .viewer-icon {
  flex: none;
  width: 28px;
  min-height: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--viewer-border);
  border-radius: 6px;
  padding: 0;
  background: var(--viewer-surface);
  color: var(--viewer-muted);
  line-height: 1;
  text-decoration: none;
}
.viewer-page .viewer-icon svg {
  width: 14px;
  height: 14px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.viewer-page .viewer-icon svg circle {
  fill: currentColor;
  stroke: none;
}
.viewer-page .viewer-icon:hover,
.viewer-page .viewer-icon[aria-expanded="true"] {
  border-color: var(--viewer-border-strong);
  background: var(--viewer-surface-2);
  color: var(--viewer-fg);
}
.viewer-page button:focus-visible {
  outline: 1px solid var(--viewer-border-strong);
  outline-offset: -1px;
  box-shadow: none;
}
.viewer-page input:focus-visible {
  outline: 1px solid var(--viewer-border-strong);
  outline-offset: -1px;
  box-shadow: none;
}
.viewer-tabs {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.viewer-tabs::-webkit-scrollbar { display: none; }
.viewer-tab-wrap {
  flex: 0 1 210px;
  min-width: 120px;
  max-width: 240px;
  height: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  align-items: center;
  border: 1px solid var(--viewer-border);
  border-radius: 6px;
  background: var(--viewer-surface);
  transition: border-color 100ms ease, background 100ms ease;
}
.viewer-tab-wrap:hover {
  border-color: var(--viewer-border-strong);
  background: var(--viewer-surface-2);
}
.viewer-tab-wrap.active {
  border-color: var(--viewer-border-strong);
  background: var(--viewer-surface-2);
}
.viewer-tab {
  min-width: 0;
  min-height: 26px;
  height: 26px;
  overflow: hidden;
  border: 0;
  border-radius: 5px 0 0 5px;
  padding: 0 5px 1px 9px;
  background: transparent;
  color: var(--viewer-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 26px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-tab:hover { background: transparent; color: var(--viewer-fg); }
.viewer-tab-wrap.active .viewer-tab { background: transparent; color: var(--viewer-fg); font-weight: 600; }
.viewer-tab-close {
  position: relative;
  width: 22px;
  min-height: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  padding: 0;
  background: transparent;
  color: var(--viewer-subtle);
  opacity: 0;
  pointer-events: none;
}
.viewer-tab-close svg {
  width: 12px;
  height: 12px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.viewer-tab-wrap:hover .viewer-tab-close,
.viewer-tab-close:focus-visible {
  opacity: 1;
  pointer-events: auto;
}
.viewer-tab-wrap.active .viewer-tab-close {
  opacity: 1;
}
.viewer-tab-wrap.active .viewer-tab-close::before {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #84c480;
  content: "";
}
.viewer-tab-wrap.active .viewer-tab-close svg {
  opacity: 0;
}
.viewer-tab-wrap.active:hover .viewer-tab-close::before,
.viewer-tab-wrap.active .viewer-tab-close:focus-visible::before {
  opacity: 0;
}
.viewer-tab-wrap.active:hover .viewer-tab-close svg,
.viewer-tab-wrap.active .viewer-tab-close:focus-visible svg {
  opacity: 1;
}
.viewer-tab-close:hover {
  background: transparent;
  color: var(--viewer-danger);
}
.viewer-menu {
  position: fixed;
  top: calc(var(--viewer-tabbar-height) + 4px);
  right: 8px;
  z-index: 30;
  width: 180px;
  max-width: calc(100vw - 16px);
  border: 1px solid var(--viewer-border-strong);
  border-radius: 8px;
  padding: 4px;
  background: var(--viewer-surface);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .55);
}
.viewer-menu-item {
  width: 100%;
  min-height: 30px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 5px;
  padding: 0 10px;
  background: transparent;
  color: var(--viewer-fg);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}
.viewer-menu-item:hover { background: var(--viewer-surface-2); }
.viewer-menu-item.danger:hover { background: rgba(220, 70, 70, .14); color: #f17a7a; }
.viewer-menu-separator {
  height: 1px;
  margin: 4px 6px;
  background: var(--viewer-border);
}
.viewer-operation {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  background: rgba(8, 8, 8, .28);
  color: var(--viewer-fg);
  cursor: progress;
}
.viewer-operation[open] {
  display: grid;
  place-items: center;
}
.viewer-operation::backdrop {
  background: rgba(0, 0, 0, .54);
}
.viewer-operation-panel {
  width: min(360px, calc(100vw - 32px));
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--viewer-border-strong);
  border-radius: 7px;
  padding: 13px 15px;
  background: var(--viewer-surface);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .62);
}
.viewer-operation-panel .viewer-spinner {
  width: 17px;
  height: 17px;
  flex: none;
}
.viewer-operation-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.viewer-operation-copy strong,
.viewer-operation-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-operation-copy strong {
  color: var(--viewer-fg);
  font-size: 12px;
  font-weight: 600;
}
.viewer-operation-copy span {
  color: var(--viewer-muted);
  font-size: 11px;
}
.viewer-notice {
  position: fixed;
  top: calc(var(--viewer-tabbar-height) + 8px);
  right: 8px;
  z-index: 40;
  width: min(420px, calc(100vw - 16px));
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(241, 122, 122, .5);
  border-radius: 7px;
  padding: 8px 8px 8px 12px;
  background: #211213;
  color: #f6c4c4;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .55);
  font-size: 11px;
}
.viewer-notice[hidden] { display: none; }
.viewer-page .viewer-notice button {
  width: 26px;
  min-height: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: currentColor;
}
.viewer-notice svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.viewer-meta {
  height: var(--viewer-meta-height);
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 0 7px;
  border-top: 1px solid var(--viewer-border);
  background: var(--viewer-bg);
  color: var(--viewer-muted);
  font-size: 11px;
  white-space: nowrap;
  scrollbar-width: none;
}
.viewer-meta::-webkit-scrollbar { display: none; }
.viewer-meta > * { transform: translateY(-1px); }
.viewer-meta > time {
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--viewer-border);
  padding: 0 9px;
  text-overflow: ellipsis;
}
.viewer-meta .meta-primary { max-width: 300px; color: var(--viewer-fg); font-weight: 600; }
#meta-clock { font-variant-numeric: tabular-nums; }
.viewer-page .meta-item {
  min-width: 0;
  min-height: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--viewer-border);
  border-radius: 0;
  padding: 0 9px;
  background: transparent;
  color: var(--viewer-muted);
  font-size: 11px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-page .meta-item:hover { background: var(--viewer-surface-2); color: var(--viewer-fg); }
.viewer-page .meta-item svg {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.meta-state {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--viewer-subtle);
}
.meta-state[data-state="connected"] { background: #84c480; }
.meta-state[data-state="failed"],
.meta-state[data-state="offline"],
.meta-state[data-state="disconnected"] { background: #dc4646; }
.meta-state[data-state="connecting"],
.meta-state[data-state="starting"] { background: #dc963c; }
.meta-state[data-state="disabled"] { background: var(--viewer-subtle); }
.meta-spinner {
  width: 9px;
  height: 9px;
  flex: none;
  border: 1px solid var(--viewer-border-strong);
  border-top-color: #dc963c;
  border-radius: 50%;
  animation: viewer-spin .7s linear infinite;
}
.meta-spinner[hidden] { display: none; }
.meta-captcha { cursor: pointer; }
.viewer-meta-spacer { flex: 1 0 8px; }
.viewer-page .meta-action {
  width: 20px;
  height: 20px;
  min-height: 20px;
  border-color: transparent;
  background: transparent;
}
.viewer-page .meta-action svg { width: 12px; height: 12px; }
.viewer-page #profile-settings {
  width: 24px;
}
.viewer-page #profile-settings svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  stroke: none;
}
.viewer-page .meta-command {
  min-height: 20px;
  height: 20px;
  border-color: transparent;
  border-radius: 5px;
  padding: 0 7px;
  background: transparent;
  color: var(--viewer-muted);
  font-size: 11px;
  font-weight: 500;
}
.viewer-page .meta-command:hover { background: var(--viewer-surface-2); color: var(--viewer-fg); }
.viewer-page .meta-command.danger:hover { color: #f17a7a; background: rgba(220, 70, 70, .14); }
.viewer-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--viewer-bg);
}
.viewer-frame {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  border: 0;
  background: var(--viewer-bg);
  transform-origin: top left;
}
.viewer-stage-state {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--viewer-muted);
  font-size: 13px;
}
.viewer-page .viewer-stage-state button {
  min-height: 30px;
  border-color: var(--viewer-accent);
  padding: 5px 12px;
  background: var(--viewer-accent);
  color: #fff;
}
.viewer-page .viewer-stage-state button:hover { border-color: var(--viewer-accent-hover); background: var(--viewer-accent-hover); }
.viewer-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--viewer-border-strong);
  border-top-color: var(--viewer-accent);
  border-radius: 50%;
  animation: viewer-spin .8s linear infinite;
}
@keyframes viewer-spin { to { transform: rotate(360deg); } }

.profile-picker {
  position: fixed;
  inset: 52px 0 auto;
  width: min(480px, calc(100vw - 24px));
  height: min(620px, calc(100dvh - 68px));
  max-height: calc(100vh - 68px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--viewer-border-strong);
  border-radius: 8px;
  padding: 0;
  background: var(--viewer-surface);
  color: var(--viewer-fg);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .6);
}
.profile-picker[open] { display: grid; grid-template-rows: 44px auto auto minmax(0, 1fr); }
.profile-picker::backdrop { background: rgba(0, 0, 0, .62); }
.viewer-dialog {
  position: fixed;
  inset: 72px 0 auto;
  width: min(520px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 96px));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--viewer-border-strong);
  border-radius: 8px;
  padding: 0;
  background: var(--viewer-surface);
  color: var(--viewer-fg);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .6);
}
.viewer-dialog[open] { display: grid; grid-template-rows: 44px minmax(0, 1fr); }
.viewer-dialog.connection-details-dialog.has-actions[open] {
  grid-template-rows: 44px minmax(0, 1fr) 52px;
}
.viewer-dialog::backdrop { background: rgba(0, 0, 0, .62); }
.viewer-dialog.form-dialog[open] { display: block; height: auto; max-height: calc(100dvh - 96px); }
.viewer-dialog.profile-settings-dialog[open] {
  height: min(680px, calc(100dvh - 96px));
  max-height: calc(100dvh - 96px);
}
.profile-settings-dialog .dialog-form { height: 100%; }
.viewer-dialog.takeover-dialog { width: min(440px, calc(100vw - 24px)); }
.viewer-dialog.wide-dialog {
  width: min(900px, calc(100vw - 24px));
  height: min(680px, calc(100dvh - 96px));
}
.picker-head {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--viewer-border);
}
.picker-head-actions { display: inline-flex; align-items: center; gap: 6px; }
.picker-search { position: relative; display: block; margin: 10px; }
.picker-search span { position: absolute; left: 11px; top: 7px; color: var(--viewer-muted); font-size: 19px; }
.viewer-page .picker-search input {
  min-height: 36px;
  border-color: var(--viewer-border-strong);
  padding-left: 36px;
  background: var(--viewer-surface-2);
  color: var(--viewer-fg);
}
.picker-filters {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding: 0 10px 10px;
  scrollbar-width: none;
}
.picker-filters::-webkit-scrollbar { display: none; }
.picker-filters button {
  flex: none;
  min-height: 27px;
  border-color: var(--viewer-border);
  padding: 3px 8px;
  background: var(--viewer-surface-2);
  color: var(--viewer-muted);
  font-size: 10px;
  font-weight: 500;
}
.picker-filters button:hover, .picker-filters button.active {
  border-color: var(--viewer-border-strong);
  background: var(--viewer-surface-3);
  color: var(--viewer-fg);
}
.profile-picker-list { min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
.profile-picker-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  border-radius: 5px;
}
.profile-picker-row:hover { background: var(--viewer-surface-2); }
.profile-picker-item {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 5px;
  padding: 6px 8px;
  background: transparent;
  color: var(--viewer-fg);
  text-align: left;
}
.profile-picker-item:hover { background: transparent; }
.viewer-page .row-delete {
  width: 28px;
  min-height: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--viewer-subtle);
  opacity: 0;
}
.viewer-page .profile-picker-row:hover .row-delete,
.viewer-page .user-switcher-item:hover .row-delete,
.viewer-page .row-delete:focus-visible { opacity: 1; }
.viewer-page .row-delete:hover { background: transparent; color: var(--viewer-danger); }
.viewer-page .row-delete svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.picker-identity { min-width: 0; display: grid; gap: 2px; }
.picker-identity strong, .picker-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-identity small { color: var(--viewer-muted); font-size: 11px; }
.details-list {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(120px, 34%) minmax(0, 1fr);
  align-content: start;
  overflow-y: auto;
  margin: 0;
  padding: 8px 14px 16px;
}
.details-list dt,
.details-list dd {
  min-width: 0;
  margin: 0;
  border-bottom: 1px solid var(--viewer-border);
  padding: 9px 0;
  overflow-wrap: anywhere;
}
.details-list dt { padding-right: 14px; color: var(--viewer-muted); }
.details-list dd { color: var(--viewer-fg); }
.dialog-timestamp {
  color: var(--viewer-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.system-content {
  min-height: 0;
  overflow-y: auto;
  padding: 0 14px 16px;
}
.dialog-loading {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--viewer-muted);
  font-size: 11px;
}
.system-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--viewer-border);
}
.system-summary > div {
  min-width: 0;
  padding: 14px 12px 14px 0;
}
.system-summary dt {
  color: var(--viewer-muted);
  font-size: 10px;
}
.system-summary dd {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--viewer-fg);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.system-section { margin-top: 16px; }
.system-section h2 {
  margin: 0 0 8px;
  color: var(--viewer-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.system-table-scroll { overflow-x: auto; }
.system-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--viewer-fg);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.system-table th,
.system-table td {
  height: 34px;
  border-bottom: 1px solid var(--viewer-border);
  padding: 0 12px 0 0;
  text-align: left;
}
.system-table th {
  color: var(--viewer-muted);
  font-size: 10px;
  font-weight: 500;
}
.system-table td:first-child {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.system-table .state-running { color: #84c480; }
.system-table .state-cold { color: var(--viewer-subtle); }
.system-table .state-failed { color: #f17a7a; }
.captcha-log-dialog { width: min(820px, calc(100vw - 24px)); }
.captcha-log-content {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  overflow: hidden;
  padding: 0 14px 14px;
}
.captcha-log-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--viewer-border);
}
.captcha-log-summary > div { min-width: 0; padding: 13px 12px 13px 0; }
.captcha-log-summary dt { color: var(--viewer-muted); font-size: 10px; }
.captcha-log-summary dd {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--viewer-fg);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.captcha-scope-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--viewer-border);
}
.captcha-scope-row > div { min-width: 0; display: grid; gap: 3px; }
.captcha-scope-row strong,
.captcha-scope-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.captcha-scope-row strong { font-size: 11px; }
.captcha-scope-row small { color: var(--viewer-muted); font-size: 10px; }
.viewer-page .captcha-scope-row button {
  min-height: 30px;
  flex: none;
  border-color: #d96363;
  padding: 4px 10px;
  background: transparent;
  color: #f17a7a;
  font-size: 10px;
  font-weight: 600;
}
.viewer-page .captcha-scope-row button:hover:not(:disabled) {
  background: rgba(220, 70, 70, .14);
}
.captcha-log-content > .dialog-error { padding-top: 8px; }
.captcha-history-scroll { min-height: 0; overflow: auto; }
.captcha-history td { vertical-align: top; }
.captcha-history td:last-child {
  min-width: 240px;
  max-width: 360px;
  white-space: normal;
  line-height: 1.4;
}
.captcha-history .captcha-state-solved,
.captcha-history .captcha-state-site_accepted { color: #84c480; }
.captcha-history .captcha-state-failed,
.captcha-history .captcha-state-site_rejected { color: #f17a7a; }
.captcha-history .captcha-state-solving,
.captcha-history .captcha-state-retrying,
.captcha-history .captcha-state-detected,
.captcha-history .captcha-state-provider_solved,
.captcha-history .captcha-state-injected { color: #dc963c; }
.captcha-history-empty {
  height: 96px;
  color: var(--viewer-muted);
  text-align: center !important;
}
.user-switcher-list { min-height: 0; overflow-y: auto; padding: 8px; }
.user-switcher-item {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 5px;
  padding: 6px 8px;
}
.user-switcher-item:hover,
.user-switcher-item.active { background: var(--viewer-surface-2); }
.viewer-page .user-switch-action {
  min-width: 66px;
  min-height: 28px;
  border-color: var(--viewer-border-strong);
  padding: 3px 9px;
  background: transparent;
  color: var(--viewer-fg);
  font-size: 11px;
}
.viewer-page .user-switch-action:hover:not(:disabled) {
  border-color: var(--viewer-border-strong);
  background: var(--viewer-surface-3);
}
.viewer-page .user-switch-action:disabled {
  border-color: transparent;
  color: #84c480;
  opacity: 1;
}
.user-switcher-actions { display: flex; align-items: center; gap: 4px; }
.viewer-page .user-switch-action.location-action {
  min-width: 86px;
  color: #dc963c;
}
.egress-decision-dialog { width: min(480px, calc(100vw - 24px)); }
.egress-decision-dialog .dialog-form { min-height: 280px; }
.egress-decision-dialog .details-list { align-content: start; }
.egress-decision-dialog .dialog-error:empty { display: none; }

.dialog-form {
  min-height: 0;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 52px;
}
.dialog-fields {
  min-height: 0;
  display: grid;
  gap: 12px;
  overflow-y: auto;
  padding: 14px;
}
.settings-dialog { width: min(620px, calc(100vw - 24px)); }
.viewer-dialog.settings-dialog[open] {
  height: min(620px, calc(100dvh - 96px));
  max-height: calc(100dvh - 96px);
}
.settings-dialog .dialog-form { height: 100%; }
.settings-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.access-dialog[open] { grid-template-rows: 44px minmax(0, 1fr); }
.access-content {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
}
.access-table td { vertical-align: top; }
.access-table .row-delete {
  min-width: 72px;
  min-height: 28px;
  color: #f17a7a;
}
.access-key-prefix,
#created-access-key {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.access-profile-list {
  max-height: 180px;
  display: grid;
  gap: 4px;
  overflow-y: auto;
}
.access-key-warning {
  margin: 0;
  color: #dc963c;
  font-size: 11px;
}
.settings-fields > fieldset,
.settings-fields > .dialog-error {
  grid-column: 1 / -1;
}
.settings-fields fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--viewer-border);
  border-radius: 6px;
  padding: 12px;
}
.dialog-fields > fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--viewer-border);
  border-radius: 6px;
  padding: 12px;
}
.dialog-fields > fieldset legend {
  padding: 0 6px;
  color: var(--viewer-muted);
  font-size: 10px;
}
.captcha-route-grid {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.site-data-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  align-items: end;
  gap: 8px;
}
.viewer-page .site-data-controls button {
  min-height: 36px;
  border-color: #d96363;
  background: #d96363;
  color: #090909;
}
.site-data-result {
  display: block;
  min-height: 16px;
  margin-top: 8px;
  color: var(--viewer-muted);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.viewer-page .dialog-fields .captcha-route {
  display: grid;
  grid-template-columns: 14px minmax(96px, 1fr) minmax(118px, 0.9fr);
  align-items: center;
  gap: 8px;
  color: var(--viewer-fg);
}
.viewer-page .dialog-fields .captcha-route input {
  width: 14px;
  min-height: 14px;
  height: 14px;
  margin: 0;
}
.viewer-page .dialog-fields .captcha-route select {
  min-height: 32px;
  padding-block: 5px;
}
.settings-fields legend {
  padding: 0 6px;
  color: var(--viewer-muted);
  font-size: 10px;
}
.retention-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.dialog-action-spacer { flex: 1; }
.viewer-page .dialog-fields label {
  gap: 6px;
  margin: 0;
  color: var(--viewer-muted);
  font-size: 11px;
  font-weight: 500;
}
.viewer-page .dialog-fields input,
.viewer-page .dialog-fields select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--viewer-border-strong);
  border-radius: 5px;
  padding: 7px 9px;
  outline: none;
  background: var(--viewer-surface-2);
  color: var(--viewer-fg);
}
.viewer-page .dialog-fields input[type="number"] {
  font-variant-numeric: tabular-nums;
}
.viewer-page .dialog-fields input:focus,
.viewer-page .dialog-fields select:focus {
  border-color: var(--viewer-subtle);
  box-shadow: none;
}
.viewer-page .dialog-fields .check-field {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--viewer-fg);
}
.viewer-page .dialog-fields .check-field input {
  width: 14px;
  min-height: 14px;
  height: 14px;
  margin: 0;
}
.dialog-error {
  min-height: 16px;
  margin: 0;
  color: #f17a7a;
  font-size: 11px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--viewer-border);
}
.viewer-page .dialog-actions button {
  min-height: 32px;
  border-color: var(--viewer-border-strong);
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
}
.viewer-page .dialog-actions button[type="submit"] {
  border-color: var(--viewer-fg);
  background: var(--viewer-fg);
  color: var(--viewer-bg);
}
.viewer-page .dialog-actions button[type="submit"]:disabled {
  border-color: var(--viewer-border-strong);
  background: var(--viewer-surface-2);
  color: var(--viewer-subtle);
}
.viewer-page .dialog-actions .quiet-command {
  background: transparent;
  color: var(--viewer-muted);
}
.viewer-page .dialog-actions .danger-command {
  border-color: #d96363;
  background: #d96363;
  color: #090909;
}
.viewer-page .connection-actions .location-command {
  border-color: #dc963c;
  background: transparent;
  color: #dc963c;
}
.takeover-copy { gap: 9px; }
.takeover-copy p {
  margin: 0;
  color: var(--viewer-muted);
  line-height: 1.5;
}
.takeover-copy p:first-child { color: var(--viewer-fg); }

.viewer-page .status {
  background: var(--viewer-surface-3);
  color: var(--viewer-muted);
}
.viewer-page .status.running { background: rgba(132, 196, 128, .12); color: #84c480; }
.viewer-page .status.waking { background: rgba(220, 150, 60, .12); color: #dc963c; }
.viewer-page .status.draining { background: rgba(90, 150, 230, .12); color: #5a96e6; }
.viewer-page .status.failed { background: rgba(220, 70, 70, .12); color: #dc4646; }

@media (max-width: 720px), (max-height: 500px) {
  .controls { grid-template-columns: 1fr auto; }
  .filters { grid-column: 1 / -1; overflow-x: auto; }
  .profile-grid { grid-template-columns: 1fr; }
  .viewer-page {
    --viewer-tabbar-height: 42px;
    grid-template-rows: var(--viewer-tabbar-height) minmax(0, 1fr);
  }
  .viewer-tabbar {
    gap: 6px;
    padding: 6px max(6px, env(safe-area-inset-right)) 6px max(6px, env(safe-area-inset-left));
  }
  .viewer-tabs { display: none; }
  .viewer-page .viewer-icon.mobile-tabs-button {
    display: inline-flex;
    margin-right: auto;
  }
  .mobile-tabs-menu {
    position: fixed;
    top: calc(var(--viewer-tabbar-height) + 4px);
    left: max(6px, env(safe-area-inset-left));
    z-index: 35;
    width: min(340px, calc(100vw - 12px));
    max-height: calc(100dvh - var(--viewer-tabbar-height) - 12px);
    overflow-y: auto;
    border: 1px solid var(--viewer-border-strong);
    border-radius: 8px;
    padding: 6px;
    background: var(--viewer-surface);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .55);
  }
  .mobile-tabs-menu:not([hidden]) { display: block; }
  .mobile-viewer-tabs {
    display: grid;
    gap: 4px;
  }
  .mobile-viewer-tabs .viewer-tab-wrap {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 44px;
    grid-template-columns: minmax(0, 1fr) 42px;
  }
  .mobile-viewer-tabs .viewer-tab {
    height: 42px;
    min-height: 42px;
    line-height: 42px;
  }
  .mobile-viewer-tabs .viewer-tab-close {
    width: 38px;
    height: 38px;
    min-height: 38px;
    opacity: 1;
    pointer-events: auto;
  }
  .viewer-meta {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(52px + env(safe-area-inset-bottom));
    z-index: 34;
    width: min(360px, calc(100vw - 16px));
    height: auto;
    max-height: calc(100dvh - var(--viewer-tabbar-height) - 68px);
    display: none;
    grid-template-columns: 1fr auto auto;
    align-content: start;
    overflow: auto;
    border: 1px solid var(--viewer-border-strong);
    border-radius: 8px;
    padding: 6px;
    background: var(--viewer-surface);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .55);
    white-space: normal;
  }
  .viewer-page.mobile-status-open .viewer-meta { display: grid; }
  .viewer-meta > * { transform: none; }
  .viewer-meta > time,
  .viewer-page .meta-item {
    min-height: 42px;
    height: 42px;
    border: 0;
    border-bottom: 1px solid var(--viewer-border);
    padding: 0 10px;
  }
  .viewer-meta > time,
  .viewer-page .meta-item,
  .viewer-meta-spacer {
    grid-column: 1 / -1;
  }
  .viewer-meta-spacer { display: none; }
  .viewer-page .meta-action {
    width: 42px;
    height: 42px;
    min-height: 42px;
    border-color: transparent;
  }
  .viewer-page #profile-settings { width: 42px; }
  .viewer-page .meta-command {
    min-height: 42px;
    height: 42px;
    padding-inline: 12px;
  }
  .viewer-page .viewer-icon.mobile-status-button {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 33;
    width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    display: inline-flex;
    border-color: var(--viewer-border-strong) !important;
    background: var(--viewer-surface-2) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .5);
  }
  .viewer-page.viewer-empty .mobile-status-button { display: none; }
  .viewer-menu {
    top: calc(var(--viewer-tabbar-height) + 4px);
    right: max(6px, env(safe-area-inset-right));
  }
  .viewer-notice {
    top: calc(var(--viewer-tabbar-height) + 8px);
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
  }
  .profile-picker,
  .viewer-dialog,
  .viewer-dialog.wide-dialog,
  .viewer-dialog.settings-dialog[open] {
    inset: calc(var(--viewer-tabbar-height) + 6px) 6px auto;
    width: auto;
    height: calc(100dvh - var(--viewer-tabbar-height) - 12px);
    max-height: calc(100dvh - var(--viewer-tabbar-height) - 12px);
  }
  .viewer-dialog.profile-settings-dialog[open] {
    height: calc(100dvh - var(--viewer-tabbar-height) - 12px);
    max-height: calc(100dvh - var(--viewer-tabbar-height) - 12px);
  }
  .captcha-log-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .captcha-scope-row { align-items: stretch; flex-direction: column; padding: 10px 0; }
  .viewer-page .captcha-scope-row button { width: 100%; }
  .viewer-page .meta-item { padding-inline: 7px; }
  .details-list { grid-template-columns: 110px minmax(0, 1fr); }
  .system-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-fields,
  .retention-grid { grid-template-columns: 1fr; }
  .site-data-controls { grid-template-columns: 1fr; }
  .viewer-page .site-data-controls button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .viewer-spinner { animation-duration: 1.6s; }
}
