@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500;600;700&family=Inter:wght@400;500;600;700;800&family=Spline+Sans:wght@500;600;700&display=swap");

:root {
  --font-sans: "Inter", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --bg: #d8dfdb;
  --card: #f9faf9;
  --text: #1f2e3b;
  --muted: #57677a;
  --border: #b8c1cf;
  --primary: #355f93;
  --surface: #eef2ef;
  --menu-shadow: 0 12px 28px rgba(31, 46, 59, 0.16);
  --tooltip-bg: #3b82f6;
  --tooltip-text: #f5f8fb;
  --tooltip-border: #2563eb;
  --trend-fps: #2563eb;
  --trend-pt: #dc2626;
  --trend-faces: #16a34a;
  --trend-fds: #d97706;
  --trend-gpu-util: #0ea5e9;
  --trend-vram-used: #8b5cf6;
  --trend-vram-total: #64748b;
  --trend-vram-util: #f59e0b;
  --trend-enc-util: #22c55e;
  --trend-dec-util: #eab308;
  --trend-gpu-temp: #ef4444;
  --trend-power: #f97316;
  --trend-surface: #f8fbff;
  --trend-border: #d2dae6;
  --trend-muted: #73859a;
}

[data-theme="dark"] {
  --bg: #132129;
  --card: #182c37;
  --text: #dbe5ed;
  --muted: #a8b8c6;
  --border: #3b5567;
  --primary: #77b5ff;
  --surface: #11212b;
  --menu-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
  --tooltip-bg: #3b82f6;
  --tooltip-text: #f5f8fb;
  --tooltip-border: #2563eb;
  --trend-fps: #7cb3ff;
  --trend-pt: #f58e8e;
  --trend-faces: #6fe68f;
  --trend-fds: #fbbf24;
  --trend-gpu-util: #38bdf8;
  --trend-vram-used: #a78bfa;
  --trend-vram-total: #94a3b8;
  --trend-vram-util: #fbbf24;
  --trend-enc-util: #4ade80;
  --trend-dec-util: #fde047;
  --trend-gpu-temp: #f87171;
  --trend-power: #fb923c;
  --trend-surface: #0f1d27;
  --trend-border: #30485b;
  --trend-muted: #98adbf;
}

html {
  font-size: 17px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at -20% 0%, rgba(255, 255, 255, 0.55), transparent 50%),
    linear-gradient(180deg, #d6ddd8 0%, var(--bg) 45%);
  color: var(--text);
}

[data-theme="dark"] body {
  background: var(--bg);
}

.page {
  width: calc(100% - 1.5rem);
  margin: 0 auto;
  padding: 2rem 1rem;
}

.page-center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding-top: 0;
  padding-bottom: 0;
}

.page-admin {
  padding-top: 1.0rem;
  padding-bottom: 1.0rem;
}

.signin-card {
  width: min(560px, 100%);
  text-align: center;
}

.signin-card h1 {
  margin: 0 0 0.41rem;
  line-height: 1.2;
}

.signin-auth-row {
  display: flex;
  justify-content: center;
  margin-top: 0.19rem;
}

.signin-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

#create-session-btn {
  background: #4285f4;
  border-color: #4285f4;
  color: #ffffff;
}

#create-session-btn:hover {
  background: #3367d6;
  border-color: #3367d6;
  filter: none;
}

.signin-gmark {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  flex: 0 0 auto;
}

.signin-note {
  margin-top: 0.45rem;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.signin-note + .signin-note {
  margin-top: 0.15rem;
}

.signin-note-spacer {
  visibility: hidden;
  pointer-events: none;
}

.signin-note-spacer-top {
  margin-top: 0;
  margin-bottom: 0.15rem;
}

.signin-title-line {
  display: block;
}

.signin-theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 70;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.62rem;
  gap: 1rem;
}

.page-admin .topbar {
  margin-bottom: 0.45rem;
}

.page-admin .card {
  padding-top: 0.92rem;
  padding-bottom: 0.92rem;
  margin-bottom: 0.56rem;
}

.page-admin .card h2 {
  margin-bottom: 0.44rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.05rem 1.25rem;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
  margin-bottom: 0.64rem;
}

.card h2 {
  margin: 0 0 0.53rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-header h2 {
  margin: 0;
}

.section-content {
  margin-top: 0.44rem;
}

.section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.section-toggle:hover {
  color: var(--text);
  border-color: var(--primary);
}

.section-toggle[aria-expanded="false"] {
  color: var(--primary);
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn.signin-google-btn {
  background: #4285f4;
  border-color: #4285f4;
  color: #ffffff;
}

.btn.signin-google-btn:hover {
  background: #3367d6;
  border-color: #3367d6;
  filter: none;
}

[data-theme="dark"] .btn.signin-google-btn {
  background: #4285f4;
  border-color: #4285f4;
  color: #ffffff;
}

[data-theme="dark"] .btn.signin-google-btn:hover {
  background: #3367d6;
  border-color: #3367d6;
  filter: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.18rem 0.56rem;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  user-select: none;
}

button.badge {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
}

.text-bg-secondary {
  background: #6c757d;
  border-color: #6c757d;
  color: #ffffff;
}

.text-bg-success {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.text-bg-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.text-bg-warning {
  background: #d97706;
  border-color: #d97706;
  color: #ffffff;
}

.health-badge {
  letter-spacing: 0.02em;
}

.badge-outline-success {
  background: transparent;
  border-color: #16a34a;
  color: #16a34a;
}

.badge-outline-danger {
  background: transparent;
  border-color: #dc2626;
  color: #dc2626;
}

.badge-outline-warning {
  background: transparent;
  border-color: #d97706;
  color: #d97706;
}

.badge-outline-secondary {
  background: transparent;
  border-color: #6c757d;
  color: #6c757d;
}

.badge-white {
  background: #ffffff;
  border-color: #ffffff;
  color: #0f172a;
}

.action-badge {
  margin-right: 0;
}

.action-badge:last-child {
  margin-right: 0;
}

.action-badge-test:hover {
  background: #0d6efd;
  border-color: #0d6efd;
  color: #ffffff;
}

.action-badge-terminate:hover {
  background: #dc3545;
  border-color: #dc3545;
  color: #ffffff;
}

.action-badge-player:hover {
  background: #198754;
  border-color: #198754;
  color: #ffffff;
}

.action-badge-logs:hover {
  background: #0ea5e9;
  border-color: #0ea5e9;
  color: #ffffff;
}

.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  min-height: 32px;
  padding: 0.2rem 0.7rem 0.2rem 0.2rem;
  cursor: pointer;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.user-trigger-name {
  font-size: 0.85rem;
  line-height: 1.1;
  font-weight: 500;
}

.user-trigger-caret {
  display: none;
}

.icon-btn {
  width: 40px;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: #f4c73a;
  font-size: 1rem;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover,
.topbar-logout:hover,
.user-trigger:hover {
  filter: brightness(1.03);
}

.topbar-logout {
  min-height: 32px;
  min-width: 68px;
  font-size: 0.85rem;
  border-radius: 10px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 400;
}

.leader-indicator {
  margin-left: 0.2rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  min-width: 72px;
  text-align: center;
}

.server-indicator {
  min-width: 128px;
  text-transform: none;
}

.signin-card h1 {
  font-family: "Spline Sans", var(--font-sans);
  font-size: 22pt;
  font-weight: 600;
}

.page-admin .topbar h1 {
  font-family: "Spline Sans", var(--font-sans);
  font-size: 22pt;
  font-weight: 600;
}

#create-card .card-header h2,
#instances-card .card-header h2,
#sessions-card .card-header h2 {
  font-family: "Spline Sans", var(--font-sans);
  font-size: 20pt;
  font-weight: 700;
  line-height: 1.1;
}

.user-menu {
  position: absolute;
  right: 194px;
  top: calc(100% + 0.35rem);
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--menu-shadow);
  padding: 0.35rem;
  z-index: 40;
}

.user-menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}

.user-menu-item:hover {
  background: rgba(29, 78, 216, 0.08);
}

.btn-danger {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #ffffff;
}

.btn-small {
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
  margin-right: 0.26rem;
}

.user-name {
  color: var(--muted);
  font-size: 0.95rem;
}

.status-time {
  display: inline-block;
  width: 11ch;
  font-variant-numeric: tabular-nums;
}

.status-time-bold {
  font-weight: 700;
}

.status-flash-green {
  border-radius: 2px;
  animation: status-flash-green 1s ease-out;
}

@keyframes status-flash-green {
  0% {
    background: rgba(34, 197, 94, 0.45);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.3);
    color: var(--text);
  }
  100% {
    background: transparent;
    box-shadow: none;
    color: var(--muted);
  }
}

.placeholder {
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 60;
  overflow-y: auto;
}

.modal-card {
  width: min(680px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.modal-card-logs {
  width: min(1024px, 100%);
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.6rem 0.6rem;
}

.modal-card label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.49rem;
}

.modal-card input,
.modal-card textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: transparent;
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.26rem;
  flex-wrap: wrap;
}

.modal-card-logs #logs-status {
  margin-right: 2.2rem;
}

.modal-card-logs .json-popup-close {
  z-index: 2;
}

.modal-card-logs .logs-detail.detail-json {
  flex: 1 1 auto;
  min-height: 240px;
  max-height: none;
}

.modal-card-logs .modal-actions {
  position: sticky;
  bottom: 0;
  background: var(--card);
  padding-top: 0.5rem;
  margin-top: 0.4rem;
}

.modal-card-stats #stats-status {
  margin-right: 2.2rem;
}

.modal-card-stats .stats-detail {
  flex: 1 1 auto;
  min-height: 260px;
  max-height: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  background: rgba(31, 46, 59, 0.04);
  overflow: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.5rem;
}

.stats-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.45rem 0.5rem;
}

.stats-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.45rem;
  margin: 0 0 0.36rem;
}

.stats-section h4 {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.stats-section-meta {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stats-kv {
  display: grid;
  grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
  gap: 0.24rem 0.45rem;
}

.stats-k {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.stats-v {
  color: var(--text);
  font-size: 0.77rem;
  word-break: break-word;
}

.stats-v-flash-target {
  display: inline;
}

.stats-v-mono {
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.stats-placeholder {
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-trends {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem;
  background: rgba(31, 46, 59, 0.04);
}

.stats-trends-section + .stats-trends-section {
  margin-top: 0.55rem;
}

.stats-trends-head {
  margin: 0 0 0.35rem;
}

.stats-trends-head h4 {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.stats-trends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
}

.stats-trend-card {
  border: 1px solid var(--trend-border);
  border-radius: 8px;
  background: var(--trend-surface);
  padding: 0.4rem 0.45rem 0.35rem;
}

.stats-trend-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.45rem;
  margin: 0 0 0.25rem;
}

.stats-trend-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.stats-trend-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.stats-trend-meta {
  color: var(--trend-muted);
  font-size: 0.66rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stats-trend-expand-btn {
  border: 1px solid var(--trend-border);
  background: transparent;
  color: var(--trend-muted);
  border-radius: 999px;
  font-size: 0.62rem;
  padding: 0.08rem 0.42rem;
  line-height: 1.2;
  cursor: pointer;
}

.stats-trend-expand-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

.stats-trend-plot {
  height: 88px;
  min-height: 88px;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.stats-trend-plot .u-wrap {
  background: #f3f6fb;
  border-radius: 6px;
}

[data-theme="dark"] .stats-trend-plot .u-wrap {
  background: transparent;
}

.stats-trend-tooltip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border-radius: 6px;
  border: 1px solid var(--trend-border);
  background: var(--card);
  color: var(--text);
  padding: 0.22rem 0.34rem;
  font-size: 0.66rem;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.2);
  min-width: 120px;
}

.stats-trend-tooltip-floating {
  position: fixed;
  z-index: 90;
}

.stats-trend-tooltip-ts {
  color: var(--muted);
  font-size: 0.62rem;
}

.stats-trend-tooltip-values {
  display: grid;
  gap: 0.08rem;
  margin-top: 0.12rem;
}

.stats-trend-tooltip-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.24rem;
}

.stats-trend-tooltip-dot {
  width: 0.44rem;
  height: 0.44rem;
  border-radius: 999px;
}

.stats-trend-tooltip-label {
  color: var(--muted);
  font-size: 0.62rem;
}

.stats-trend-tooltip-value-inline {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  justify-self: end;
}

.stats-trend-expanded-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(31, 46, 59, 0.04);
  padding: 0.45rem;
  min-height: 360px;
}

.stats-trend-expanded-plot {
  width: 100%;
  min-height: 340px;
  height: 340px;
  position: relative;
  overflow: hidden;
}

.stats-trend-expanded-hint {
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 0.35rem;
}

.modal-card-trend {
  width: min(1180px, 100%);
}

.stats-trend-placeholder {
  height: 88px;
  border: 1px dashed var(--trend-border);
  border-radius: 6px;
  color: var(--trend-muted);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
}

.instances-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.instance-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  font-size: 0.85rem;
  min-width: 260px;
}

.instance-chip-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.instance-chip-meta {
  color: var(--muted);
  font-size: 0.78rem;
  flex: 1;
}

.instance-slots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.instance-slot {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.instance-slot.used {
  background: #16a34a;
  border-color: #16a34a;
}

.instance-slot.progress {
  background: #f59e0b;
  border-color: #f59e0b;
}

.tippy-box[data-theme~="gpuctl"] {
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border: 1px solid var(--tooltip-border);
  font-size: 0.74rem;
  line-height: 1.3;
  max-width: min(460px, calc(100vw - 24px));
  border-radius: 8px;
  box-shadow: 0 10px 24px var(--shadow);
}

.tippy-box[data-theme~="gpuctl"] .tippy-content {
  padding: 0.38rem 0.5rem;
  white-space: pre-line;
}

.tippy-box[data-theme~="gpuctl"] > .tippy-arrow::before {
  color: var(--tooltip-bg);
}

.tippy-box[data-theme~="gpuctl"][data-placement^="top"] > .tippy-arrow::before {
  border-top-color: var(--tooltip-bg);
}

.tippy-box[data-theme~="gpuctl"][data-placement^="bottom"] > .tippy-arrow::before {
  border-bottom-color: var(--tooltip-bg);
}

.tippy-box[data-theme~="gpuctl"][data-placement^="left"] > .tippy-arrow::before {
  border-left-color: var(--tooltip-bg);
}

.tippy-box[data-theme~="gpuctl"][data-placement^="right"] > .tippy-arrow::before {
  border-right-color: var(--tooltip-bg);
}

.lightbox-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-height: 85vh;
  max-width: 90vw;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.json-popup-inner {
  position: relative;
  width: fit-content;
  max-width: min(92vw, 1200px);
  max-height: calc(100vh - 2rem);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.6rem 0.6rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}

.json-popup-status {
  margin: 0 1.6rem 0.35rem 0.2rem;
  font-size: 0.82rem;
}

.json-popup-detail {
  margin: 0;
  min-height: auto;
  max-height: calc(100vh - 4.6rem);
  width: max-content;
  min-width: min(56ch, 86vw);
  max-width: min(88vw, 1120px);
}

.json-popup-close {
  top: 8px;
  right: 8px;
}

#json-modal {
  overflow-y: auto;
  place-items: center;
}

.session-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.48rem;
}

.session-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.session-filter-sep {
  color: var(--muted);
  font-size: 0.88rem;
}

.session-toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.session-toolbar-right select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem 0.35rem;
  background: var(--surface);
  color: var(--text);
}

.session-toolbar .toggle,
.session-toolbar .session-filter-sep,
.session-toolbar-right select,
.session-toolbar-right .btn-small,
.session-toolbar-right .user-name {
  font-size: 0.82rem;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pager .btn-small {
  margin-right: 0;
}

.create-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr)) auto;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.42rem;
}

.create-grid label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.create-grid input,
.create-grid select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  background: transparent;
  color: var(--text);
}

.create-grow {
  grid-column: span 2;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.table-wrap {
  overflow-x: auto;
}

.sessions-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.session-thumb-cell {
  width: 48px;
  padding: 0.15rem 0.2rem;
  vertical-align: middle;
}

.session-thumb {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.session-thumb-empty {
  display: block;
  width: 40px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
}

.sessions-table th,
.sessions-table td {
  text-align: left;
  padding: 0.26rem 0.22rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
  vertical-align: top;
}

.sessions-table th.state-col,
.sessions-table td.state-col {
  text-align: right;
}

.session-id-cell,
.session-instance-cell {
  font-family: var(--font-mono);
  font-size: 0.79rem;
}

.session-ip-cell {
  font-family: var(--font-mono);
  font-size: 0.79rem;
}

.copyable-value {
  position: relative;
  cursor: pointer;
}

.copy-truncate {
  display: inline-block;
  max-width: 13.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}

.session-id-cell .copy-truncate {
  max-width: 8.5rem;
}

.session-instance-cell .copy-truncate {
  max-width: 10.5rem;
}

.copyable-value.is-copied {
  outline: 1px dashed #16a34a;
  outline-offset: 1px;
}

.copyable-value.is-copied::after {
  content: "Copied!";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translate(-50%, 2px);
  opacity: 0;
  pointer-events: none;
  font-size: 0.68rem;
  line-height: 1;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 6px;
  padding: 0.2rem 0.32rem;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  animation: copy-toast 0.55s ease-out;
}

@keyframes copy-toast {
  0% {
    opacity: 0;
    transform: translate(-50%, 2px);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -2px);
  }
}

.session-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.2rem;
  min-height: 26px;
}

.sessions-table td.action-col {
  width: 30px;
  min-width: 30px;
  max-width: 30px;
  text-align: center;
  padding-left: 0.12rem;
  padding-right: 0.12rem;
}

.sessions-table th.action-group-head {
  font-size: 0.7rem;
  text-align: center;
}

.action-icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 120ms ease,
    filter 120ms ease;
}

.action-icon-btn:hover {
  transform: scale(1.05);
  filter: brightness(1.04);
}

.action-icon-btn:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

.action-icon-img {
  width: 26px;
  height: 26px;
  display: block;
}

.sessions-table tr.is-selected td {
  background: rgba(53, 95, 147, 0.12);
}

.sessions-table tr.session-row {
  cursor: pointer;
}

.sessions-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.relative-date {
  white-space: nowrap;
}

.session-time-cell {
  font-weight: 400;
}

.session-time-live {
  color: #166534;
}

.session-time-dead {
  color: #7f1d1d;
}

[data-theme="dark"] .session-time-live {
  color: #4ade80;
}

[data-theme="dark"] .session-time-dead {
  color: #f87171;
}

.state-pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 400;
}

.sessions-table td .badge {
  font-size: 0.68rem;
  font-weight: 400;
}

.fd-col-title {
  display: inline-block;
  line-height: 1.05;
  text-align: center;
}

.state-running {
  border-color: #16a34a;
  color: #16a34a;
}

.state-failed {
  border-color: #dc2626;
  color: #dc2626;
}

.state-terminated {
  border-color: #64748b;
  color: #64748b;
}

.state-progress {
  border-color: #f59e0b;
  color: #f59e0b;
}

.state-pill.state-live.state-running {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.state-pill.state-live.state-progress {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #ffffff;
}

.stream-pill-connected {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.stream-pill-idle {
  border-color: #f59e0b;
  color: #b45309;
}

.stream-pill-unknown {
  border-color: #64748b;
  color: #64748b;
}

.stream-reason {
  margin-top: 0.1rem;
  font-size: 0.62rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.detail-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.detail-color-toggle,
.detail-pretty-toggle {
  white-space: nowrap;
}

.detail-json {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.4;
  background: rgba(31, 46, 59, 0.04);
}

.json-popup-detail.detail-json {
  min-height: min(76vh, 860px);
  max-height: calc(100vh - 4.6rem);
}

.logs-detail.detail-json {
  min-height: 360px;
  max-height: min(70vh, 780px);
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-json-colored .json-key {
  color: #0f766e;
}

.detail-json-colored .json-string {
  color: #2563eb;
}

.detail-json-colored .json-number {
  color: #b45309;
}

.detail-json-colored .json-boolean {
  color: #7c3aed;
}

.detail-json-colored .json-null {
  color: #dc2626;
}

[data-theme="dark"] .detail-json-colored .json-key {
  color: #5eead4;
}

[data-theme="dark"] .detail-json-colored .json-string {
  color: #93c5fd;
}

[data-theme="dark"] .detail-json-colored .json-number {
  color: #fbbf24;
}

[data-theme="dark"] .detail-json-colored .json-boolean {
  color: #c4b5fd;
}

[data-theme="dark"] .detail-json-colored .json-null {
  color: #fca5a5;
}

.player-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.player-state-badge {
  font-size: 0.78rem;
}

.player-source-thumb-wrap {
  display: flex;
  align-items: center;
  min-height: 40px;
}

.player-preview-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.player-preview-title {
  margin: 0 0 0.35rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.player-preview-pane {
  position: relative;
}

.player-preview-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: none;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: #000;
  object-fit: cover;
  object-position: center center;
}

.player-screen-card {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: #000;
  object-fit: cover;
  object-position: center center;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: opacity 140ms ease-in-out;
}

.player-screen-card.hidden {
  opacity: 0;
  visibility: hidden;
}

@media (max-width: 1400px) {
  .create-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .create-grow {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .modal {
    padding: 0.55rem;
  }

  .modal-card {
    padding: 0.75rem;
    border-radius: 10px;
    max-height: calc(100vh - 1.1rem);
  }

  .modal-card-logs .modal-actions .btn {
    min-height: 2.2rem;
  }

  .page-admin {
    padding-top: 0.8rem;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .user-menu {
    right: 0;
    top: calc(100% + 0.45rem);
  }

  .icon-btn {
    width: 36px;
    min-height: 28px;
  }

  .signin-theme-toggle {
    top: 0.7rem;
    right: 0.7rem;
  }

  .topbar-logout {
    min-height: 28px;
    min-width: 60px;
  }

  .create-grid {
    grid-template-columns: 1fr;
  }

  .create-grow {
    grid-column: span 1;
  }

  .session-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-toolbar-right {
    justify-content: flex-start;
    width: 100%;
  }

  .detail-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-toggle-group {
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .player-preview-grid {
    grid-template-columns: 1fr;
  }

  .player-preview-video {
    aspect-ratio: 16 / 9;
    height: auto;
    max-height: none;
  }
}
