/* muse2api-pro admin console — single stylesheet, no build step. */

/* ---------- tokens ---------- */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --sidebar-w: 224px;
  --header-h: 56px;

  --transition: 140ms ease;
}

:root,
[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e8ebf0;
  --border: #e3e6eb;
  --border-strong: #cbd1da;
  --text: #16191f;
  --text-secondary: #4b5361;
  --text-muted: #737d8c;

  --primary: #3a5ccc;
  --primary-hover: #2f4cb0;
  --primary-soft: #ecf0fd;
  --primary-contrast: #ffffff;

  --ok: #1c7c46;
  --ok-soft: #e5f4ea;
  --warn: #9a5b06;
  --warn-soft: #fbf0dc;
  --danger: #b3261e;
  --danger-soft: #fbe9e8;
  --neutral: #5a6472;
  --neutral-soft: #eceff3;

  --shadow-sm: 0 1px 2px rgba(16, 20, 28, 0.06);
  --shadow: 0 4px 16px rgba(16, 20, 28, 0.09);
  --shadow-lg: 0 18px 48px rgba(16, 20, 28, 0.18);
  --overlay: rgba(17, 21, 28, 0.42);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1015;
  --surface: #151a21;
  --surface-2: #1b212a;
  --surface-3: #232b36;
  --border: #262e3a;
  --border-strong: #38424f;
  --text: #e7ebf1;
  --text-secondary: #b3bcc9;
  --text-muted: #8b95a4;

  --primary: #7f95f5;
  --primary-hover: #97a9f8;
  --primary-soft: #1c2439;
  --primary-contrast: #0d1015;

  --ok: #5bc98c;
  --ok-soft: #162a1f;
  --warn: #e0a75a;
  --warn-soft: #2c2317;
  --danger: #f08a83;
  --danger-soft: #2f1c1b;
  --neutral: #9aa4b2;
  --neutral-soft: #232b36;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 22px 56px rgba(0, 0, 0, 0.6);
  --overlay: rgba(0, 0, 0, 0.6);
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

button {
  font-family: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- boot screen ---------- */

.boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.boot-inner {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  animation: spin 720ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- logo ---------- */

.logo {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--primary);
  position: relative;
  flex: none;
}

.logo::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 3px;
  border: 2px solid var(--primary-contrast);
  border-right-color: transparent;
  border-bottom-color: transparent;
  transform: rotate(45deg);
}

/* ---------- login ---------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 388px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
}

.login-brand-name {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.login-hint {
  margin-top: 6px;
  margin-bottom: 22px;
  font-size: 13px;
}

/* ---------- forms ---------- */

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  min-height: 36px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

textarea {
  min-height: 104px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

input.invalid,
textarea.invalid,
select.invalid {
  border-color: var(--danger);
}

input.invalid:focus,
textarea.invalid:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.check-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-error {
  min-height: 18px;
  margin: 10px 0 4px;
  font-size: 13px;
  color: var(--danger);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    color var(--transition), opacity var(--transition);
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--border-strong);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

[data-theme="dark"] .btn-danger-solid {
  color: #1a0f0e;
}

.btn-danger-solid:hover {
  filter: brightness(0.94);
  background: var(--danger);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn-sm.btn-icon {
  width: 28px;
  padding: 0;
  flex: none;
}

.btn-sm.btn-icon .icon {
  width: 14px;
  height: 14px;
}

.btn-block {
  width: 100%;
}

.btn-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--primary);
  font-size: 12.5px;
  cursor: pointer;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn .icon {
  width: 15px;
  height: 15px;
}

/* ---------- icons ---------- */

.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: -0.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- shell ---------- */

.shell {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand strong {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  overflow-y: auto;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: 0;
  background: none;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-item[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-foot {
  padding: 10px;
  border-top: 1px solid var(--border);
  flex: none;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-h);
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.page-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.view {
  padding: 22px 24px 56px;
  outline: none;
  max-width: 1360px;
  width: 100%;
  min-width: 0;
}

/* ---------- page helpers ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-head .sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar select {
  width: auto;
  min-width: 132px;
  height: 32px;
  min-height: 32px;
  padding: 0 30px 0 10px;
  font-size: 13px;
  background-position: calc(100% - 14px) 13px, calc(100% - 9px) 13px;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 16px 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.card-head h3 {
  font-size: 13.5px;
  font-weight: 600;
}

.card-head .hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 1500px) {
  .stat-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  margin-top: 6px;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.stat-value.sm {
  font-size: 17px;
}

.stat-foot {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.stat-accent .stat-value {
  color: var(--ok);
}

.stat-danger .stat-value {
  color: var(--danger);
}

.stat-warn .stat-value {
  color: var(--warn);
}

.section-gap {
  margin-top: 22px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.045em;
}

/* ---------- tables ---------- */

.table-wrap {
  width: 100%;
  max-width: 100%;
  /* Containing block for absolutely positioned children (e.g. .sr-only), so
     they are clipped by this scroll container instead of the page. */
  position: relative;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

td.actions {
  text-align: right;
  white-space: nowrap;
}

td.actions .btn + .btn {
  margin-left: 4px;
}

.cell-title {
  font-weight: 500;
  color: var(--text);
  overflow-wrap: anywhere;
}

.cell-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.cell-ellipsis {
  display: block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* One-line text with an ellipsis; the full value goes in `title`. */
.truncate {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Accounts table: hold every column on one line at desktop widths so rows
   stay a single line tall. Column widths are fixed (px) because the headers
   are nowrap: with percentage widths the English headers were clipped.
   Narrow screens keep scrolling inside .table-wrap. */
.table-accounts {
  table-layout: fixed;
  width: 100%;
  /* Sum of the column widths below, so a narrow screen scrolls instead of
     squeezing every cell into a one-character column. */
  min-width: 1140px;
}

.table-accounts th,
.table-accounts td {
  padding: 10px 12px;
  vertical-align: middle;
}

.table-accounts th {
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-accounts .col-name {
  width: 165px;
}

.table-accounts .col-status {
  width: 98px;
}

.table-accounts .col-priority {
  width: 78px;
}

.table-accounts .col-concurrency {
  width: 106px;
}

.table-accounts .col-proxy {
  width: 128px;
}

.table-accounts .col-quota {
  width: 148px;
}

.table-accounts .col-error {
  width: 172px;
}

.table-accounts .col-checked {
  width: 104px;
}

.table-accounts th.actions,
.table-accounts td.actions {
  /* 4 icon buttons (28px) + 3 gaps (2px) + 2x12px padding */
  width: 140px;
  padding-left: 4px;
  padding-right: 12px;
  white-space: nowrap;
}

.table-accounts td.actions .btn + .btn {
  margin-left: 2px;
}

.cell-error {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--danger);
}

.cell-error .error-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  line-height: 1.5;
}

.cell-error:hover .error-text {
  text-decoration: underline;
}

.long-text {
  margin: 0 0 8px;
  padding: 12px;
  max-height: 50vh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}

.spinner-xs {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
  vertical-align: middle;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--neutral);
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge-plain::before {
  display: none;
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- quota ---------- */

.quota {
  min-width: 0;
}

.quota-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width var(--transition);
}

.quota-fill.warn {
  background: var(--warn);
}

.quota-fill.danger {
  background: var(--danger);
}

.quota-text {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- inline alert / states ---------- */

.state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 52px 20px;
  text-align: center;
  color: var(--text-muted);
}

.state-icon {
  width: 36px;
  height: 36px;
  color: var(--border-strong);
  stroke-width: 1.4;
}

.state-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.state-text {
  font-size: 12.5px;
  max-width: 380px;
}

.state-error .state-icon,
.state-error .state-title {
  color: var(--danger);
}

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.alert .icon {
  margin-top: 1px;
  color: var(--text-muted);
}

.alert-error {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}

.alert-error .icon {
  color: var(--danger);
}

.alert-warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 28%, transparent);
  color: var(--warn);
}

.alert-warn .icon {
  color: var(--warn);
}

.alert-info .icon {
  color: var(--primary);
}

.skeleton {
  display: block;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* ---------- jobs ---------- */

.result-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-3);
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
}

.result-thumb.loading {
  background-image: none;
}

.result-thumb.placeholder {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  cursor: default;
}

.result-thumb.placeholder .icon {
  width: 18px;
  height: 18px;
}

.prompt-cell {
  max-width: 100%;
  line-height: 1.35;
  color: var(--text-secondary);
}

/* Jobs rows stay one line tall: fixed columns, ellipsised text, and a compact
   thumbnail. Long prompts and errors never widen the row. */
.table-jobs {
  table-layout: fixed;
  width: 100%;
  min-width: 1064px;
}

.table-jobs th {
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-jobs td {
  padding: 8px 12px;
}

.table-jobs .col-preview {
  width: 64px;
}

.table-jobs .col-id {
  width: 150px;
}

.table-jobs .col-kind {
  width: 90px;
}

.table-jobs .col-status {
  width: 100px;
}

.table-jobs .col-prompt {
  width: 340px;
}

.table-jobs .col-account {
  width: 120px;
}

.table-jobs .col-duration {
  width: 90px;
}

.table-jobs .col-created {
  width: 110px;
}

.table-jobs .cell-error .error-text {
  line-height: 1.3;
}

img.zoomable {
  cursor: zoom-in;
}

/* ---------- keys ---------- */

.key-shown {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-bottom: 14px;
}

.key-shown code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--text);
}

/* ---------- tabs ---------- */

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  max-width: 100%;
  overflow-x: auto;
}

.tab {
  border: 0;
  background: none;
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------- playground ---------- */

.pg-grid {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.pg-output {
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.pg-output-body {
  flex: 1;
  padding: 14px 16px;
  overflow-wrap: anywhere;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 16px;
}

.msg {
  display: flex;
  gap: 10px;
}

.msg-role {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-secondary);
}

.msg-assistant .msg-role {
  background: var(--primary-soft);
  color: var(--primary);
}

.msg-body {
  min-width: 0;
  flex: 1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  padding-top: 3px;
}

.msg-user .msg-body {
  color: var(--text-secondary);
}

.msg-body.streaming::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 14px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--primary);
  animation: caret 1s steps(2) infinite;
}

@keyframes caret {
  50% {
    opacity: 0;
  }
}

/* ---------- modal ---------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--overlay);
  animation: fade-in 120ms ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop-in 140ms ease;
}

.modal-sm {
  max-width: 420px;
}

.modal-lg {
  max-width: 640px;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  flex: none;
}

.modal-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-head .sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.modal-body {
  padding: 4px 20px 8px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  flex: none;
}

.modal-close {
  margin: -4px -6px 0 0;
}

/* ---------- toast ---------- */

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
  max-width: calc(100vw - 36px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 160ms ease;
  max-width: 420px;
  pointer-events: auto;
}

.toast-error {
  background: var(--danger);
  color: #fff;
}

[data-theme="dark"] .toast {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

[data-theme="dark"] .toast-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.toast .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- responsive ---------- */

@media (max-width: 1024px) {
  .pg-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 767px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-head {
    height: 50px;
    border-bottom: 0;
    padding: 0 16px;
  }

  .nav {
    flex-direction: row;
    gap: 4px;
    padding: 0 12px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    padding: 7px 11px;
    background: var(--surface-2);
    font-size: 13px;
    flex: none;
  }

  .nav-item .icon {
    display: none;
  }

  .sidebar-foot {
    display: flex;
    justify-content: flex-end;
    padding: 0 12px 10px;
    border-top: 0;
    margin-top: -46px;
    position: relative;
    pointer-events: none;
  }

  .sidebar-foot .btn {
    width: auto;
    pointer-events: auto;
    height: 32px;
    font-size: 12.5px;
    padding: 0 10px;
  }

  .topbar {
    padding: 0 16px;
    height: 50px;
  }

  .view {
    padding: 16px 16px 48px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    padding: 12px 14px;
  }

  .stat-value {
    font-size: 20px;
  }

  .page-head {
    margin-bottom: 12px;
  }

  .page-head .toolbar {
    width: 100%;
  }

  .toolbar select,
  .toolbar .btn {
    flex: 1 1 auto;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal {
    max-height: calc(100dvh - 24px);
  }

  .modal-root {
    padding: 12px;
    place-items: end center;
  }

  .modal {
    max-width: 100%;
  }

  .toast-root {
    right: 12px;
    left: 12px;
    bottom: 12px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }

  .pg-output {
    min-height: 260px;
  }

  .chat-log {
    max-height: 50vh;
  }
}

@media (max-width: 420px) {
  .sidebar-foot {
    margin-top: -46px;
  }

  .brand-sub {
    display: none;
  }
}

/* ---------- pieces added with the views ---------- */

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 20px;
}

.health-row {
  min-width: 0;
}

.health-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.health-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.table-slot {
  min-width: 0;
  max-width: 100%;
}

.modal-foot-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.confirm-text {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-bottom: 6px;
}

/* playground */

.pg-panel {
  min-width: 0;
}

.pg-form {
  display: flex;
  flex-direction: column;
}

.pg-form .field:last-of-type {
  margin-bottom: 6px;
}

.pg-form-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.pg-output-body {
  padding: 14px 16px;
}

.pg-output-body.no-pad {
  padding: 0;
}

.pg-output-body .state {
  padding: 40px 16px;
}

.pg-ref {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.pg-ref-img {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-3);
  flex: none;
}

.pg-figure {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pg-image,
.pg-video {
  width: 100%;
  max-height: 62vh;
  border-radius: var(--radius);
  background: var(--surface-3);
  display: block;
}

.pg-image {
  object-fit: contain;
}

.pg-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-full {
  width: 100%;
  max-height: 62vh;
  border-radius: var(--radius);
  background: var(--surface-3);
  display: block;
  object-fit: contain;
}

.msg-error .msg-body {
  color: var(--danger);
}

.pg-prompt {
  min-height: 96px;
}

@media (max-width: 767px) {
  .health-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .card-head {
    padding: 11px 14px;
  }

  .card-pad {
    padding: 14px;
  }

  .modal-foot-inner {
    width: 100%;
  }

  .modal-foot-inner .btn {
    flex: 1 1 auto;
  }

  .pg-output-body {
    padding: 12px;
  }

  .chat-log {
    padding: 12px;
  }

  .pg-image,
  .pg-video,
  .preview-full {
    max-height: 48vh;
  }
}

/* ---------- ops tools (keep-alive, batch import, proxy test, results, version) ---------- */

/* One-line keep-alive summary above the accounts table. */
.keepalive-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  box-shadow: var(--shadow-sm);
}

.keepalive-bar .icon {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex: none;
}

.keepalive-bar .keepalive-every::before {
  content: "· ";
}

.keepalive-bar.is-running .icon {
  color: var(--primary);
  animation: spin 1.4s linear infinite;
}

/* Input with a button on its right (proxy test). */
.field-inline {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}

.field-inline input {
  flex: 1 1 auto;
  min-width: 0;
}

.field-inline .btn {
  flex: none;
  white-space: nowrap;
}

.proxy-result {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.proxy-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.proxy-summary.ok {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
  color: var(--ok);
}

.proxy-summary.warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--warn);
}

.proxy-summary .muted,
.proxy-detail {
  font-size: 11.5px;
  color: var(--text-muted);
}

.proxy-detail {
  overflow-wrap: anywhere;
}

/* Batch import: monospace lines, one per account. */
.batch-input {
  min-height: 150px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre;
  overflow-x: auto;
}

.batch-results {
  margin-top: 12px;
}

.batch-wrap {
  max-height: 240px;
  overflow-y: auto;
}

.table-batch {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

.table-batch th,
.table-batch td {
  padding: 7px 10px;
  font-size: 12.5px;
}

.table-batch .col-line {
  width: 56px;
}

.table-batch .col-label {
  width: 150px;
}

.table-batch .col-status {
  width: 92px;
}

.table-batch .col-error .error-text {
  display: block;
  overflow-wrap: anywhere;
}

/* Job selection column. */
.col-select {
  width: 40px;
  text-align: center;
  padding-left: 12px;
  padding-right: 4px;
}

.row-check {
  width: 15px;
  height: 15px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--primary);
  cursor: pointer;
}

.table-jobs {
  min-width: 1120px;
}

.table-jobs th.col-select {
  width: 40px;
}

/* Results (media library) table. */
.table-results {
  table-layout: fixed;
  width: 100%;
  min-width: 1060px;
}

.table-results th {
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-results td {
  padding: 8px 12px;
}

.table-results .col-preview {
  width: 72px;
}

.table-results .col-id {
  width: 150px;
}

.table-results .col-kind {
  width: 86px;
}

.table-results .col-model {
  width: 120px;
}

.table-results .col-size {
  width: 84px;
}

.table-results .col-dims {
  width: 100px;
}

.table-results .col-duration {
  width: 78px;
}

.table-results .col-key {
  width: 116px;
}

.table-results .col-created {
  width: 108px;
}

.table-results th.actions,
.table-results td.actions {
  width: 60px;
  padding-left: 4px;
  padding-right: 10px;
}

.table-results td.col-id a {
  color: var(--text-secondary);
  text-decoration: none;
}

.table-results td.col-id a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Version notice in the sidebar footer. */
.version-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 8px;
  min-width: 0;
}

.version-current {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-new {
  border: 0;
  cursor: pointer;
  flex: none;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Key/value list used by the version dialog. */
.kv-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 14px;
  margin: 0 0 14px;
  font-size: 13px;
}

.kv-list dt {
  color: var(--text-muted);
}

.kv-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.code-block {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .keepalive-bar {
    font-size: 12px;
  }

  .field-inline {
    flex-wrap: wrap;
  }

  .field-inline .btn {
    width: 100%;
  }

  .kv-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px 0;
  }
}
