:root {
  --bg: #0c141f;
  --card: rgba(13, 25, 38, 0.72);
  --card-border: rgba(142, 181, 221, 0.22);
  --text: #e7f1fd;
  --muted: #a8bfd8;
  --brand: #2cc7aa;
  --brand-hover: #1db397;
  --danger: #e16068;
  --danger-hover: #c94c53;
  --border: rgba(165, 197, 230, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  background: radial-gradient(circle at 15% 20%, #163252 0%, #0c141f 45%, #070c14 100%);
  color: var(--text);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.25;
  pointer-events: none;
  z-index: -1;
}
.bg-orb-a {
  width: 400px;
  height: 400px;
  background: #2cc7aa;
  top: -150px;
  right: -100px;
}
.bg-orb-b {
  width: 500px;
  height: 500px;
  background: #1d79d1;
  left: -200px;
  bottom: -200px;
}

.shell {
  max-width: 1000px;
  margin: 40px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  padding: 24px;
}

.header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}
h1 {
  margin: 0;
  font-size: 28px;
}
h2 {
  margin: 0 0 16px;
  font-size: 18px;
}
.muted {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: rgba(44, 199, 170, 0.15);
  color: var(--brand);
}

.queue-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: #a8bfd8;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.queue-tab-badge.active {
  background: rgba(48, 170, 255, 0.2);
  color: #7bd5ff;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 24px;
}

.tab-pane.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Forms */
.add-form, .config-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.config-category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.config-cat-btn {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: #cce0f5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.config-cat-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.config-cat-btn.active {
  background: rgba(44, 199, 170, 0.16);
  color: #6ff2d7;
  border-color: rgba(77, 226, 196, 0.4);
}

.config-cat-pane {
  display: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  gap: 12px;
  flex-direction: column;
}

.config-cat-pane.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-inline-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.config-inline-row .inline-item {
  min-width: 0;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #cce0f5;
}

.help {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.input-text {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.input-text:focus {
  outline: none;
  border-color: var(--brand);
}

textarea#tokenInput {
  width: 100%;
  height: 80px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  resize: vertical;
}

textarea#refreshBundleInput {
  width: 100%;
  min-height: 140px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  resize: vertical;
}

#refreshBundleFile {
  color: var(--muted);
}

.refresh-status {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: #a8bfd8;
  font-size: 12px;
  line-height: 1.5;
}

.refresh-status .table-wrapper {
  margin-top: 6px;
}

.refresh-profiles-table {
  font-size: 12px;
}

.refresh-profiles-table th,
.refresh-profiles-table td {
  padding: 8px;
}

.dialog-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 16, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 950;
  padding: 20px;
}

.dialog-modal.open {
  display: flex;
}

.dialog-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #0d1926;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* Actions */
.actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

button {
  background: var(--brand);
  color: #051410;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
button:hover {
  background: var(--brand-hover);
}

button.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
button.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 6px 12px;
  font-size: 12px;
}
button.danger:hover {
  background: var(--danger);
  color: #fff;
}

button.small {
  padding: 6px 12px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
button.small:hover {
  background: rgba(255, 255, 255, 0.2);
}

.msg {
  font-size: 14px;
}

/* Table */
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.list-head h2 {
  margin: 0;
}

.token-list-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.token-credits-summary {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.token-credits-summary strong {
  color: #e7f1fd;
  font-size: 15px;
}

.input-select {
  min-width: 120px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.input-select:focus {
  outline: none;
  border-color: var(--brand);
}

.log-query-bar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto minmax(110px, auto);
  align-items: end;
  gap: 18px;
  margin: 2px 0 16px;
  padding: 14px 0;
  border-top: 1px solid rgba(111, 151, 188, 0.22);
  border-bottom: 1px solid rgba(111, 151, 188, 0.22);
}

.log-query-search,
.log-query-status {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.log-query-label {
  color: #8fa8c0;
  font-size: 11px;
  font-weight: 700;
}

.log-search-control {
  position: relative;
}

.log-search-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 36px 10px 12px;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.log-search-input:focus {
  outline: none;
  border-color: var(--brand);
}

.log-search-input::placeholder {
  color: var(--muted);
}

.log-search-clear {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 26px;
  height: 26px;
  padding: 0;
  transform: translateY(-50%);
  border-radius: 6px;
  background: transparent;
  color: #7890a8;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
}

.log-search-clear.visible {
  opacity: 1;
  pointer-events: auto;
}

.log-search-clear:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #d7e5f3;
}

.log-search-clear:disabled {
  opacity: 0;
}

.log-filter-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 170px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
}

.log-filter-segment button {
  min-width: 78px;
  padding: 7px 11px;
  border-radius: 6px;
  background: transparent;
  color: #8fa8c0;
  font-size: 12px;
  font-weight: 700;
}

.log-filter-segment button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #d9e6f2;
}

.log-filter-segment #logFilterAll.active {
  background: rgba(77, 226, 196, 0.16);
  color: #63e7ce;
}

.log-filter-segment #logFilterErrors.active {
  background: rgba(255, 107, 120, 0.17);
  color: #ffb4bc;
}

.log-filter-summary {
  align-self: center;
  justify-self: end;
  min-width: 100px;
  color: #7890a8;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  text-align: right;
}

.log-filter-summary.filtered {
  color: #b9cce0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.stat-value {
  color: #e7f1fd;
  font-size: 24px;
  line-height: 1.1;
  font-weight: 700;
}

.image-monitor {
  margin: 12px 0 14px;
}

.image-monitor-title {
  color: #e7f1fd;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.compact-table th,
.compact-table td {
  padding: 9px 10px;
  white-space: nowrap;
}

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

.token-summary {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.token-summary strong {
  color: #e7f1fd;
  font-size: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

#logsTable,
#runningLogsTable {
  table-layout: auto;
}

#logsTable th:nth-child(1),
#logsTable td:nth-child(1),
#runningLogsTable th:nth-child(1),
#runningLogsTable td:nth-child(1) {
  width: 70px;
}

#logsTable th:nth-child(2),
#logsTable td:nth-child(2),
#runningLogsTable th:nth-child(2),
#runningLogsTable td:nth-child(2),
#logsTable th:nth-child(4),
#logsTable td:nth-child(4),
#runningLogsTable th:nth-child(4),
#runningLogsTable td:nth-child(4),
#logsTable th:nth-child(7),
#logsTable td:nth-child(7),
#runningLogsTable th:nth-child(7),
#runningLogsTable td:nth-child(7),
#logsTable th:nth-child(12),
#logsTable td:nth-child(12),
#runningLogsTable th:nth-child(12),
#runningLogsTable td:nth-child(12) {
  width: auto;
  white-space: nowrap;
}

#logsTable th:nth-child(3),
#logsTable td:nth-child(3),
#runningLogsTable th:nth-child(3),
#runningLogsTable td:nth-child(3) {
  width: 62px;
  white-space: nowrap;
}

#logsTable th:nth-child(5),
#logsTable td:nth-child(5),
#runningLogsTable th:nth-child(5),
#runningLogsTable td:nth-child(5) {
  width: 180px;
}

#logsTable th:nth-child(6),
#logsTable td:nth-child(6),
#runningLogsTable th:nth-child(6),
#runningLogsTable td:nth-child(6) {
  min-width: 240px;
  width: 240px;
}

.queue-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 1px;
  margin: 12px 0 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border);
}

.queue-summary-item {
  min-width: 0;
  min-height: 76px;
  padding: 12px;
  background: rgba(12, 20, 31, 0.9);
}

.queue-summary-item span,
.queue-summary-item strong {
  display: block;
}

.queue-summary-item span {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
}

.queue-summary-item strong {
  color: #e7f1fd;
  font-family: "IBM Plex Mono", monospace;
  font-size: 22px;
}

.image-queue-list {
  max-height: 65vh;
  min-height: 120px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.queue-request {
  border-bottom: 1px solid var(--border);
}

.queue-request > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 58px;
  padding: 11px 4px;
  cursor: pointer;
  list-style-position: inside;
}

.queue-request > summary:hover {
  background: rgba(255, 255, 255, 0.025);
}

.queue-request-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.queue-request-main strong,
.queue-request-main > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-request-main > span:last-child {
  color: #8da6bf;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.queue-request-progress {
  color: #b9cce0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.queue-request-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 0 4px 12px 24px;
  color: #8da6bf;
  font-size: 12px;
}

.queue-request-meta code {
  color: #cce0f5;
}

.queue-request-error,
.queue-load-error {
  color: #ffb4bc;
}

.queue-output-table-wrap {
  margin: 0 0 14px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.queue-output-table {
  min-width: 980px;
  font-size: 12px;
}

.queue-output-table th,
.queue-output-table td {
  padding: 9px 10px;
  white-space: nowrap;
}

.queue-output-table td:last-child {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-mono,
.queue-output-index {
  max-width: 150px;
  overflow: hidden;
  color: #a0c3e8;
  font-family: "IBM Plex Mono", monospace;
  text-overflow: ellipsis;
}

.queue-state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #cce0f5;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.queue-state-completed { background: rgba(44, 199, 170, 0.18); color: #63e7ce; }
.queue-state-failed { background: rgba(225, 96, 104, 0.2); color: #ffb4bc; }
.queue-state-rate-limited { background: rgba(225, 163, 44, 0.2); color: #ffca58; }
.queue-state-download-retry { background: rgba(222, 137, 61, 0.2); color: #ffc08a; }
.queue-state-waiting-poll { background: rgba(48, 170, 255, 0.17); color: #7bd5ff; }
.queue-state-uploading,
.queue-state-submitting,
.queue-state-downloading { background: rgba(157, 119, 255, 0.17); color: #c5adff; }

#logsTable th:nth-child(8),
#logsTable td:nth-child(8),
#runningLogsTable th:nth-child(8),
#runningLogsTable td:nth-child(8) {
  width: 72px;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#logsTable th:nth-child(9),
#logsTable td:nth-child(9),
#runningLogsTable th:nth-child(9),
#runningLogsTable td:nth-child(9) {
  min-width: 220px;
  width: 25%;
}

#logsTable th:nth-child(10),
#logsTable td:nth-child(10),
#runningLogsTable th:nth-child(10),
#runningLogsTable td:nth-child(10) {
  min-width: 260px;
  width: 30%;
}

#logsTable th:nth-child(11),
#logsTable td:nth-child(11),
#runningLogsTable th:nth-child(11),
#runningLogsTable td:nth-child(11) {
  min-width: 220px;
  width: 30%;
}

#logsTable td,
#runningLogsTable td {
  padding: 10px 8px;
  vertical-align: top;
}

.log-account-cell {
  display: block;
  color: #a8bfd8;
  line-height: 1.35;
}

.log-time-cell {
  color: #a8bfd8;
  line-height: 1.2;
  white-space: normal;
}

.log-time-cell .date {
  display: block;
}

.log-time-cell .time {
  display: block;
  color: #7f96ad;
}

.log-account-email {
  color: #7f96ad;
  word-break: break-all;
}

.log-model-cell {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: #8fb0d3;
  word-break: break-word;
}

.log-resolution-cell,
.log-type-cell {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: #9fc0e2;
  white-space: nowrap;
}

.log-params-cell {
  color: #a8bfd8;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.log-input-url-cell {
  max-width: 360px;
  line-height: 1.35;
  word-break: break-all;
}

.log-input-url {
  color: #62d8c7;
  text-decoration: none;
}

.log-input-url:hover {
  text-decoration: underline;
}

.log-prompt-cell {
  color: #a8bfd8;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.log-prompt-button {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
}

.log-prompt-button:hover > span:first-child {
  color: #d5e7f8;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.log-prompt-detail {
  flex: 0 0 auto;
  margin-top: 1px;
  padding-left: 6px;
  border-left: 1px solid rgba(98, 216, 199, 0.35);
  color: #62d8c7;
  font-size: 10px;
  font-weight: 700;
}

th {
  text-align: left;
  padding: 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}

td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.token-val {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: #a0c3e8;
  word-break: break-all;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-active { background: rgba(44, 199, 170, 0.2); color: #4de2c4; }
.status-exhausted { background: rgba(225, 163, 44, 0.2); color: #ffca58; }
.status-invalid { background: rgba(225, 96, 104, 0.2); color: #ffb4bc; }
.status-error { background: rgba(225, 96, 104, 0.2); color: #ffb4bc; }
.status-disabled { background: rgba(255, 255, 255, 0.1); color: #aaa; }

.log-status-2xx { background: rgba(44, 199, 170, 0.2); color: #4de2c4; }
.log-status-4xx { background: rgba(225, 163, 44, 0.2); color: #ffca58; }
.log-status-5xx { background: rgba(225, 96, 104, 0.2); color: #ffb4bc; }

.log-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.log-state.running {
  color: #63d4ff;
  background: rgba(48, 170, 255, 0.16);
}

.log-state.success {
  color: #4de2c4;
  background: rgba(44, 199, 170, 0.16);
}

.log-state.failed {
  color: #ffb4bc;
  background: rgba(225, 96, 104, 0.16);
}

.log-state-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.log-state-btn.failed {
  border: 1px solid rgba(255, 180, 188, 0.55);
  background: rgba(255, 180, 188, 0.12);
}

.log-state-btn.failed:hover {
  background: rgba(255, 180, 188, 0.22);
}

.log-state-detail {
  padding-left: 6px;
  border-left: 1px solid rgba(255, 180, 188, 0.35);
  color: #ffd2d7;
  font-size: 10px;
}

.icon-spinner {
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.icon-check,
.icon-error {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  font-size: 11px;
  line-height: 1;
}

.log-row-running {
  background: rgba(48, 170, 255, 0.06);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.action-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  min-width: 120px;
}

th input[type="checkbox"],
td input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.action-btns button {
  width: 100%;
  padding: 3px 5px;
  font-size: 10px;
  border-radius: 4px;
}

.switch-btn {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  background: #2b3948;
  vertical-align: middle;
}

.switch-btn.on {
  background: rgba(44, 199, 170, 0.35);
  border-color: rgba(77, 226, 196, 0.55);
}

.switch-btn.off {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.switch-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.switch-knob {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transform: translateX(0);
  transition: transform 0.15s ease;
}

.switch-btn.on .switch-knob {
  transform: translateX(18px);
}

.switch-text {
  margin-left: 8px;
  font-size: 12px;
  color: #a8bfd8;
}

.empty-state {
  text-align: center;
  padding: 40px !important;
  color: var(--muted);
}

.logs-pagination {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 16, 0.86);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.preview-modal.open {
  display: flex;
}

.preview-modal-dialog {
  width: min(1100px, 100%);
  max-height: calc(100vh - 40px);
  background: #0d1926;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-close {
  align-self: flex-end;
  padding: 6px 12px;
  font-size: 12px;
}

.preview-content {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  max-height: calc(100vh - 130px);
}

.preview-content img,
.preview-content video {
  max-width: 100%;
  max-height: calc(100vh - 150px);
  border-radius: 8px;
  background: #08111c;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
}

.preview-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
}

.preview-download:hover {
  background: rgba(255, 255, 255, 0.2);
}

.error-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.error-detail-head h3 {
  margin: 0;
  font-size: 16px;
  color: #e9f4ff;
}

.error-detail-content {
  border: 1px solid rgba(142, 181, 221, 0.25);
  border-radius: 8px;
  background: #091321;
  padding: 12px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.error-detail-content pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cfe3f8;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

#errorDetailModal {
  padding: 10px;
}

.error-trace-dialog {
  --trace-font-scale: 1;
  width: min(1560px, 100%);
  height: calc(100vh - 20px);
  max-height: calc(100vh - 20px);
  padding: 0;
  gap: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #0a141f;
}

.error-trace-topbar {
  min-height: 66px;
  padding: 10px 12px 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(142, 181, 221, 0.22);
  background: #101d2a;
}

.error-trace-topbar .error-detail-head {
  min-width: 0;
  display: block;
}

.error-trace-topbar .error-detail-head h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-trace-kicker {
  display: block;
  margin-bottom: 2px;
  color: #78d7c5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.error-trace-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

button.trace-icon-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  line-height: 1;
}

button.trace-text-icon {
  font-size: 11px;
  font-weight: 800;
}

button.trace-icon-btn:focus-visible,
.trace-stage > summary:focus-visible,
.trace-json-node > summary:focus-visible,
.trace-copy-node:focus-visible {
  outline: 2px solid #55d9bd;
  outline-offset: 2px;
}

.error-trace-summary {
  min-height: 64px;
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  align-items: stretch;
  border-bottom: 1px solid rgba(142, 181, 221, 0.18);
  background: #0d1824;
}

.trace-summary-item {
  min-width: 0;
  padding: 10px 16px;
  border-right: 1px solid rgba(142, 181, 221, 0.14);
}

.trace-summary-item:last-child {
  border-right: 0;
}

.trace-summary-label {
  display: block;
  margin-bottom: 4px;
  color: #88a3bd;
  font-size: 10px;
  font-weight: 700;
}

.trace-summary-value {
  display: block;
  overflow: hidden;
  color: #e7f1fd;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-summary-value.failed {
  color: #ff8d96;
}

.error-trace-dialog .error-detail-content {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #09131e;
  font-size: calc(12px * var(--trace-font-scale));
}

.trace-loading,
.trace-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: #9db4ca;
  font-family: "IBM Plex Mono", monospace;
  font-size: calc(12px * var(--trace-font-scale));
}

.trace-timeline {
  position: relative;
  min-width: 720px;
  padding: 8px 18px 40px;
}

.trace-stage {
  position: relative;
  margin-left: var(--trace-indent, 0px);
  border-bottom: 1px solid rgba(142, 181, 221, 0.12);
}

.trace-stage::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 18px;
  width: 1px;
  background: rgba(130, 164, 199, 0.28);
}

.trace-stage > summary {
  position: relative;
  min-height: 54px;
  padding: 9px 10px 9px 48px;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.trace-stage > summary::-webkit-details-marker,
.trace-json-node > summary::-webkit-details-marker,
.trace-payload-section > summary::-webkit-details-marker {
  display: none;
}

.trace-stage > summary:hover {
  background: rgba(255, 255, 255, 0.025);
}

.trace-stage-marker {
  position: absolute;
  left: 11px;
  top: 17px;
  width: 15px;
  height: 15px;
  border: 3px solid #0d1824;
  border-radius: 50%;
  background: #7590aa;
  box-shadow: 0 0 0 1px rgba(142, 181, 221, 0.4);
}

.trace-stage[data-layer="client"] .trace-stage-marker {
  background: #62b7ff;
}

.trace-stage[data-layer="service"] .trace-stage-marker {
  background: #36c7aa;
}

.trace-stage[data-layer="adobe"] .trace-stage-marker {
  background: #f0b65b;
}

.trace-stage[data-status="failed"] .trace-stage-marker,
.trace-stage[data-status="interrupted"] .trace-stage-marker {
  background: #ef6d77;
}

.trace-stage-title {
  min-width: 0;
}

.trace-stage-name {
  display: block;
  overflow: hidden;
  color: #e5f0fb;
  font-size: calc(13px * var(--trace-font-scale));
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-stage-meta {
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: #8fa8c0;
  font-family: "IBM Plex Mono", monospace;
  font-size: calc(10px * var(--trace-font-scale));
}

.trace-stage-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.trace-badge {
  min-width: 54px;
  padding: 3px 7px;
  border: 1px solid rgba(142, 181, 221, 0.2);
  border-radius: 4px;
  color: #b9ccde;
  background: rgba(255, 255, 255, 0.03);
  font-family: "IBM Plex Mono", monospace;
  font-size: calc(9px * var(--trace-font-scale));
  font-weight: 700;
  text-align: center;
}

.trace-badge.failed {
  border-color: rgba(239, 109, 119, 0.45);
  color: #ff9ba3;
  background: rgba(239, 109, 119, 0.08);
}

.trace-stage-body {
  margin: 0 12px 12px 48px;
  padding: 0 0 4px;
}

.trace-payload-section {
  border-top: 1px solid rgba(142, 181, 221, 0.1);
}

.trace-payload-section > summary {
  padding: 8px 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #a9c0d6;
  font-size: calc(11px * var(--trace-font-scale));
  font-weight: 700;
  list-style: none;
}

.trace-payload-section > summary::before,
.trace-json-node > summary::before {
  content: "+";
  width: 14px;
  color: #68cdb8;
  font-family: "IBM Plex Mono", monospace;
}

.trace-payload-section[open] > summary::before,
.trace-json-node[open] > summary::before {
  content: "−";
}

.trace-json-root {
  position: relative;
  margin: 0 0 8px;
  padding: 10px 12px;
  overflow: auto;
  border-left: 2px solid rgba(92, 194, 171, 0.35);
  background: #07101a;
  color: #cfe1f1;
  font-family: "IBM Plex Mono", monospace;
  font-size: calc(11px * var(--trace-font-scale));
  line-height: 1.55;
}

.trace-json-node {
  margin-left: 14px;
}

.trace-json-node > summary {
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

.trace-json-children {
  padding-left: 8px;
  border-left: 1px solid rgba(142, 181, 221, 0.18);
}

.trace-json-row {
  min-height: 20px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.trace-json-key {
  color: #81b8e6;
}

.trace-json-string {
  color: #a7dfaa;
  white-space: pre-wrap;
  word-break: break-word;
}

.trace-json-number,
.trace-json-boolean {
  color: #f2c071;
}

.trace-json-null {
  color: #879db2;
}

.trace-json-count {
  color: #8299ae;
}

.trace-copy-node {
  width: 24px;
  height: 22px;
  margin-left: auto;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  color: #8fa8c0;
  background: transparent;
  font-size: 14px;
  opacity: 0.7;
}

.trace-copy-node:hover {
  color: #e7f1fd;
  background: rgba(255, 255, 255, 0.08);
  opacity: 1;
}

.trace-legacy {
  margin: 14px;
  padding: 14px;
  border-left: 3px solid #ef6d77;
  background: #07101a;
}

@media (max-width: 760px) {
  #errorDetailModal {
    padding: 0;
  }

  .error-trace-dialog {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .error-trace-topbar {
    min-height: 58px;
    padding: 8px 8px 8px 12px;
    gap: 8px;
  }

  .error-trace-kicker {
    display: none;
  }

  .error-trace-topbar .error-detail-head h3 {
    max-width: 120px;
    font-size: 13px;
  }

  .error-trace-tools {
    gap: 3px;
  }

  button.trace-icon-btn {
    width: 30px;
    min-width: 30px;
    height: 30px;
  }

  .error-trace-summary {
    flex: 0 0 auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 0;
    overflow: visible;
  }

  .trace-summary-item {
    min-height: 46px;
    padding: 8px 10px;
  }

  .trace-summary-item:nth-child(2n) {
    border-right: 0;
  }

  .trace-summary-item:nth-child(-n + 4) {
    border-bottom: 1px solid rgba(142, 181, 221, 0.14);
  }

  .trace-timeline {
    min-width: 0;
    width: 100%;
    padding-left: 8px;
    padding-right: 8px;
  }

  .trace-stage {
    margin-left: var(--trace-mobile-indent, 0px);
  }

  .trace-stage > summary {
    min-height: 52px;
    padding-left: 38px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }

  .trace-stage::before {
    left: 13px;
  }

  .trace-stage-marker {
    left: 6px;
  }

  .trace-stage-badges {
    gap: 3px;
  }

  .trace-badge {
    min-width: 42px;
    padding-left: 4px;
    padding-right: 4px;
  }

  .trace-stage-body {
    margin-left: 38px;
    margin-right: 4px;
  }

  .trace-stage-name {
    white-space: normal;
  }

  .trace-stage-meta {
    overflow-wrap: anywhere;
  }
}

.prompt-detail-dialog {
  width: min(820px, 100%);
}

.prompt-detail-content {
  min-height: 160px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(12, 20, 31, 0.92);
  color: #dbe9f8;
  border: 1px solid rgba(142, 181, 221, 0.28);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.4;
  z-index: 1200;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  border-color: rgba(77, 226, 196, 0.45);
}

.toast.error {
  border-color: rgba(255, 180, 188, 0.45);
}

@media (max-width: 900px) {
  .queue-summary-grid {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
  }

  .queue-request > summary {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .queue-request-progress {
    padding-left: 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .list-head .actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 10px;
  }

  .log-search-input {
    width: 100%;
  }

  .log-query-bar {
    grid-template-columns: minmax(220px, 1fr) auto;
  }

  .log-filter-summary {
    grid-column: 1 / -1;
    justify-self: start;
    min-width: 0;
    text-align: left;
  }

  .token-list-actions {
    width: 100%;
    align-items: flex-start;
  }

  .token-credits-summary {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .tabs {
    flex-wrap: wrap;
  }

  .queue-summary-grid {
    grid-template-columns: repeat(2, minmax(100px, 1fr));
  }

  .image-queue-card {
    padding: 16px;
  }

  .queue-request-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .queue-request-main > span:last-child {
    grid-column: 1 / -1;
    padding-left: 24px;
  }

  .queue-output-table-wrap,
  .queue-request-meta {
    margin-left: 0;
    padding-left: 4px;
  }

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

  .config-category-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .config-inline-row {
    grid-template-columns: 1fr;
  }

  .input-select {
    width: 100%;
  }

  .log-search-input {
    width: 100%;
  }

  .log-query-bar {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 0;
  }

  .log-filter-segment {
    width: 100%;
  }

  .log-filter-summary {
    grid-column: auto;
  }
}
