: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: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", 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%;
  display: none;
  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 {
  width: calc(100% - 48px);
  max-width: 1760px;
  margin: 24px auto 40px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;

  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);
}

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

.tab-pane.active {
  display: flex;

}

/* In-app reference guide: readable on desktop and narrow screens. */
.guide-card {
  max-width: 100%;
  box-shadow: none;
}

.guide-card h2 {
  margin-bottom: 12px;
}

.guide-card p,
.guide-list {
  margin: 0 0 12px;
  line-height: 1.65;
}

.guide-card p:last-child,
.guide-list:last-child {
  margin-bottom: 0;
}

.guide-card code {
  color: #c5e9ff;
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.guide-nav a {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
}

.guide-nav a:hover,
.guide-nav a:focus-visible {
  border-color: var(--brand);
  color: var(--brand);
}

.guide-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 12px 0;
}

.guide-table {
  width: 100%;
  min-width: 780px;
  table-layout: auto;
  border-collapse: collapse;
  font-size: 13px;
}

.guide-table th,
.guide-table td {
  text-align: left;
  vertical-align: top;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  overflow-wrap: anywhere;
}

.guide-table th {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.guide-code {
  margin: 10px 0 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #081321;
  overflow-x: auto;
  line-height: 1.5;
}

.guide-code code {
  white-space: pre;
}

.guide-list {
  padding-left: 22px;
}

@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;
}

.request-detail-wrap { display: inline-block; position: relative; }
.request-detail-wrap .request-detail-btn { white-space: nowrap; }
.request-history-count {
  position: absolute; top: -5px; right: -6px; min-width: 15px;
  height: 15px; line-height: 15px; border-radius: 8px; padding: 0 2px;
  text-align: center; font-size: 10px; background: #57441f; color: #ffda86;
}
.channel-switch-count { white-space: nowrap; font-size: 11px; }
#dzineReloginModal .dialog-card { width: min(520px, 94vw); }
#dzineReloginModal label { display: block; margin: 12px 0; }
#dzineReloginModal input:not([type="checkbox"]) { display: block; width: 100%; }
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-credit-meter {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 0;
  width: 100%;
}
.token-credit-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  white-space: nowrap;
}
.token-credit-main .token-credit-text {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.token-credit-meter.usable .token-credit-text { color: #b6ece2; }
.token-credit-meter.unusable .token-credit-text,
.token-credit-meter.unusable .token-credit-status { color: #e6b64c; }
.token-credit-meter.snapshot .token-credit-text,
.token-credit-meter.snapshot .token-credit-status { color: #9ebbd2; }
.token-credit-meter.depleted .token-credit-text,
.token-credit-meter.depleted .token-credit-status { color: #f2a3aa; }
.token-credit-track {
  width: min(100%, 146px);
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #263849;
}
.token-credit-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #27c3b0;
}
.token-credit-meter.unusable .token-credit-fill { background: #e6b64c; }
.token-credit-status { font-size: 10px; font-weight: 600; }
.token-credit-text.muted { color: #91a9bc; }
.token-profile-summary {
  display: block;
  width: min(100%, 146px);
  max-width: 146px;
  padding: 0;
  border: 0;
  background: none;
  color: #8fb6ce;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.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);
}

.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;
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
  scrollbar-gutter: stable;
}

.token-list-actions .actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.token-list-actions .actions button {
  padding: 8px 12px;
  font-size: 12px;
}

.token-toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.token-toolbar-management {
  border-left: 1px solid var(--border);
  margin-left: 4px;
  padding-left: 12px;
}
.token-toolbar button { white-space: nowrap; }

.token-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.token-summary > span {
  white-space: nowrap;
}

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

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

#tokenTable,
#dzineAccountsTable {
  min-width: 0;
  table-layout: fixed;
  font-size: 12px;
}

#tokenTable th,
#tokenTable td,
#dzineAccountsTable th,
#dzineAccountsTable td {
  overflow-wrap: normal;
  word-break: normal;
}

#tokenTable th:nth-child(1) { width: 32px; }
#tokenTable th:nth-child(2) { width: 16%; }
#tokenTable th:nth-child(3) { width: 8%; }
#tokenTable th:nth-child(4) { width: 14%; }
#tokenTable th:nth-child(5) { width: 5%; }
#tokenTable th:nth-child(6) { width: 10%; }
#tokenTable th:nth-child(7) { width: 11%; }
#tokenTable th:nth-child(8) { width: 7%; }
#tokenTable th:nth-child(9) { width: 5%; }
#tokenTable th:nth-child(10) { width: 5%; }
#tokenTable th:nth-child(11) { width: 5%; }

.token-table-wrapper {
  overflow-x: hidden;
  scrollbar-gutter: auto;
}

.row-menu {
  position: relative;
  display: flex;
  width: 100%;
  justify-content: center;
}

.row-menu-list {
  position: fixed;
  right: auto;
  top: auto;
  z-index: 60;
  box-sizing: border-box;
  min-width: 184px;
  max-width: min(292px, calc(100vw - 16px));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 6px;
  border: 1px solid #22334d;
  border-radius: 8px;
  background: #101a2b;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .4);
  display: none;
}

.row-menu-list.open { display: block; }

.row-menu-group + .row-menu-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(80, 111, 144, .36);
}

.row-menu-group-title {
  padding: 2px 8px 4px;
  color: #7f96ad;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1.2;
}

.menu-item {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 7px 9px;
  background: transparent;
  color: #d7e2f5;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
  text-align: left;
  white-space: nowrap;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: #1b2b45;
  color: #fff;
  outline: none;
}

.menu-item.danger { color: #ffb4bc; }
.menu-item.danger:hover,
.menu-item.danger:focus-visible { background: #3a1c24; }

.token-log-cell { text-align: center; }
.account-operation-log-btn { min-width: 38px; }

.token-list-card {
  padding: 18px 20px;
}

.token-list-card .list-head {
  margin-bottom: 8px;
}

#tokenTable th {
  padding: 8px 5px;
  white-space: nowrap;
  line-height: 1.2;
}

#tokenTable td {
  padding: 7px 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#dzineAccountsTable th {
  padding: 8px 5px;
  white-space: nowrap;
  line-height: 1.2;
}

#dzineAccountsTable td {
  padding: 7px 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#dzineAccountsTable .token-account-cell {
  min-width: 0;
  line-height: 1.25;
}

#dzineAccountsTable .dzine-account-name,
#dzineAccountsTable .dzine-account-status,
#dzineAccountsTable .dzine-config-cell span,
#dzineAccountsTable .dzine-config-cell small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#dzineAccountsTable .dzine-account-status,
#dzineAccountsTable .dzine-config-cell small {
  color: var(--muted);
  font-size: 11px;
}

#dzineAccountsTable button:not(.switch-btn) {
  padding: 3px 8px;
  height: 26px;
  min-height: 26px;
  font-size: 11px;
}

.dzine-dialog-card { width: min(940px, 94vw); }
.dzine-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dzine-dialog-head h2 { margin: 0; }
.dzine-account-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.dzine-account-form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.dzine-account-form input { width: 100%; }
@media (max-width: 900px) { .dzine-account-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .dzine-account-form { grid-template-columns: 1fr; } }

#tokenTable th,
#logsTable th,
#runningLogsTable th {
  white-space: nowrap;
}

#logsTable,
#runningLogsTable {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

#logsTable th:nth-child(1), #runningLogsTable th:nth-child(1) { width: 4%; }
#logsTable th:nth-child(2), #runningLogsTable th:nth-child(2) { width: 7%; }
#logsTable th:nth-child(3), #runningLogsTable th:nth-child(3) { width: 6%; }
#logsTable th:nth-child(4), #runningLogsTable th:nth-child(4) { width: 5%; }
#logsTable th:nth-child(5), #runningLogsTable th:nth-child(5) { width: 9%; }
#logsTable th:nth-child(6), #runningLogsTable th:nth-child(6) { width: 4%; }
#logsTable th:nth-child(7), #runningLogsTable th:nth-child(7) { width: 5%; }
#logsTable th:nth-child(8), #runningLogsTable th:nth-child(8) { width: 12%; }
#logsTable th:nth-child(9), #runningLogsTable th:nth-child(9) { width: 6%; }
#logsTable th:nth-child(10), #runningLogsTable th:nth-child(10) { width: 12%; }
#logsTable th:nth-child(11), #runningLogsTable th:nth-child(11) { width: 5%; }
#logsTable th:nth-child(12), #runningLogsTable th:nth-child(12) { width: 16%; }
#logsTable th:nth-child(13), #runningLogsTable th:nth-child(13) { width: 5%; }
#logsTable th:nth-child(14), #runningLogsTable th:nth-child(14) { width: 4%; }

/* Request logs have a separate Dzine project column. The account/project
   cells stay single-line so the extra column does not increase row height. */
#logsTable th:nth-child(8) { width: 11%; }
#logsTable th:nth-child(9) { width: 7%; }
#logsTable th:nth-child(10) { width: 5%; }
#logsTable th:nth-child(11) { width: 11%; }
#logsTable th:nth-child(12) { width: 5%; }
#logsTable th:nth-child(13) { width: 12%; }
#logsTable th:nth-child(14) { width: 5%; }
#logsTable th:nth-child(15) { width: 4%; }

#logsTable th, #runningLogsTable th {
  padding: 8px 4px;
  white-space: normal;
  overflow-wrap: anywhere;
}

#logsTable td, #runningLogsTable td {
  overflow: hidden;
  text-overflow: ellipsis;
}

#logsTable .log-account-email, #runningLogsTable .log-account-email {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#logsTable .log-project-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#logsTable .log-project-cell a,
#dzineAccountsTable td a {
  color: #fff;
  text-decoration: none;
  border-bottom: 0;
}

#logsTable .log-project-cell a:visited,
#dzineAccountsTable td a:visited {
  color: #fff;
}

#logsTable .log-project-cell a:hover,
#dzineAccountsTable td a:hover {
  color: #fff;
  text-decoration: underline;
}

#logsTable .log-model-cell, #logsTable .log-prompt-cell,
#runningLogsTable .log-model-cell, #runningLogsTable .log-prompt-cell {
  display: table-cell;
  white-space: nowrap;
}

#logsTable td,
#runningLogsTable td {
  padding: 7px 4px;
  vertical-align: middle;
}

.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-word;
  overflow-wrap: anywhere;
}

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

.log-prompt-cell {
  color: #a8bfd8;
  line-height: 1.35;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

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 {
  display: block;
  width: 100%;
  max-width: 100%;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: #a0c3e8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}

.arp-session-summary {
  margin-top: 5px;
  padding: 6px 7px;
  border: 1px solid rgba(115, 154, 193, 0.28);
  border-radius: 7px;
  background: rgba(4, 18, 31, 0.72);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  line-height: 1.35;
}

.arp-session-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #bdd3e8;
  font-weight: 700;
}

.arp-session-state {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.arp-session-state.changed {
  color: #38e2c2;
  background: rgba(25, 185, 153, 0.18);
}

.arp-session-state.unchanged,
.arp-session-state.current {
  color: #9eb7d0;
  background: rgba(112, 143, 174, 0.16);
}

.arp-session-updated {
  margin-top: 4px;
  color: #7f96ad;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arp-session-identifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 4px 0;
  color: #9eb7d0;
}

.arp-session-view-btn {
  padding: 4px 9px;
  font-size: 11px;
}

.arp-session-empty {
  color: #7f96ad;
}

.log-stage-timing {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 8px;
  color: #8fb0d3;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

#tokenTable td:nth-child(3) {
  overflow: hidden;
}

#tokenTable th:nth-child(4),
#tokenTable td:nth-child(4) {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

#tokenTable th:nth-child(5),
#tokenTable td:nth-child(5) {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

.fingerprint-id-editor {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
}

.fingerprint-id-editor input {
  box-sizing: border-box;
  flex: 0 1 70px;
  width: 70px;
  min-width: 62px;
  padding: 5px 6px;
  border: 1px solid rgba(115, 154, 193, 0.38);
  border-radius: 6px;
  background: rgba(4, 18, 31, 0.8);
  color: #cce3f7;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.fingerprint-id-help {
  display: block;
  margin-top: 5px;
  color: #7f96ad;
  font-size: 10px;
}

.generation-mode-editor {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
}

.generation-mode-editor select {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  padding: 3px 5px;
  color: #d9e8f7;
  background: #081522;
  border: 1px solid #28445d;
  border-radius: 6px;
}

.browser-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.browser-session-control {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto auto;
  align-items: center;
  gap: 3px;
  width: 100%;
  min-width: 0;
}

.browser-state-badge {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  height: 22px;
  padding: 0 6px;
  border: 1px solid rgba(115, 154, 193, 0.35);
  border-radius: 999px;
  background: rgba(35, 57, 76, 0.58);
  color: #a9bfd3;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browser-state-badge::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: currentColor;
}

.browser-state-badge.open {
  border-color: rgba(77, 226, 196, 0.45);
  background: rgba(33, 132, 116, 0.2);
  color: #4de2c4;
}

.browser-state-badge.busy,
.browser-state-badge.pending {
  border-color: rgba(245, 193, 74, 0.48);
  background: rgba(139, 102, 23, 0.2);
  color: #f5c14a;
}

.browser-state-badge.closed,
.browser-state-badge.loading {
  color: #91a8bb;
}

.browser-state-badge.unavailable {
  border-color: rgba(255, 126, 139, 0.42);
  background: rgba(132, 43, 56, 0.18);
  color: #ff9ba5;
}

#tokenTable .browser-session-control button {
  padding-left: 6px;
  padding-right: 6px;
}

#tokenTable .browser-close-btn:not(:disabled) {
  border-color: rgba(255, 126, 139, 0.55);
  color: #ffc0c7;
}

#tokenTable td:nth-child(2) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-account-cell,
.token-account-cell span,
.token-credit-cell,
.token-credit-text,
.token-expiry-cell,
.token-expiry-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-account-cell { color: #a8bfd8; }
.login-method-badge {
  display: block;
  width: fit-content;
  margin-top: 5px;
  padding: 2px 7px;
  border: 1px solid #33506c;
  border-radius: 999px;
  color: #9fb8cf;
  font-size: 11px;
  line-height: 1.3;
}
.login-method-badge.google {
  border-color: rgba(66, 133, 244, 0.6);
  background: rgba(66, 133, 244, 0.12);
  color: #9fc2ff;
}
.token-session-cell { text-align: center; }
.token-session-view-btn { padding: 4px 8px; font-size: 11px; }
.token-credit-text,
.token-expiry-text { display: block; color: #a8bfd8; }
.token-credit-text.error,
.token-expiry-text.expired { color: #ffb4bc; }
.token-expiry-text.warning { color: #ffca58; }

.status-badge {
  display: inline-block;
  white-space: nowrap;
  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);
}

.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: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.log-state.queued {
  color: #ffca58;
  background: rgba(255, 202, 88, 0.14);
  border-color: rgba(255, 202, 88, 0.32);
}

.concurrency-test-dialog {
  width: min(940px, 100%);
}

.concurrency-test-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.concurrency-test-warning {
  color: #ffca58;
}

.concurrency-test-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.concurrency-test-summary span {
  padding: 9px 10px;
  border: 1px solid rgba(142, 181, 221, 0.22);
  background: #091321;
  color: #a8bfd8;
}

.concurrency-test-summary .success { color: #4de2c4; }
.concurrency-test-summary .failed { color: #ffb4bc; }

.concurrency-test-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.concurrency-test-result {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(142, 181, 221, 0.22);
  background: #091321;
}

.concurrency-test-result.success { border-color: rgba(77, 226, 196, 0.42); }
.concurrency-test-result.failed { border-color: rgba(255, 180, 188, 0.42); }
.concurrency-test-result.running { border-color: rgba(255, 202, 88, 0.35); }

.concurrency-test-result .result-head {
  display: flex;
  justify-content: space-between;
  color: #e7f1fd;
}

.concurrency-test-result.success .result-head span { color: #4de2c4; }
.concurrency-test-result.failed .result-head span { color: #ffb4bc; }
.concurrency-test-result.running .result-head span { color: #ffca58; }

.concurrency-test-result .result-meta {
  margin-top: 5px;
  color: #7f96ad;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.fingerprint-id-editor .action-mini {
  flex: 0 0 auto;
}

.concurrency-test-result .result-error {
  margin-top: 6px;
  color: #ffb4bc;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.action-btns button {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 5px 3px;
  font-size: 12px;
  line-height: 1;
  border-radius: 6px;
}

.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;
}

.request-detail-section + .request-detail-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(142, 181, 221, 0.2);
}

.request-detail-section h4 {
  margin: 0 0 10px;
  color: #8fe3d1;
  font-size: 14px;
}

.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) {
  .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;
  }

  .token-list-actions {
    width: 100%;
    align-items: flex-start;
  }
  .token-toolbar-management {
    border-left: 0;
    margin-left: 0;
    padding-left: 0;
  }

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

  .concurrency-test-form,
  .concurrency-test-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .row-menu-list {
    min-width: min(184px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .row-menu-group-title {
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .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%;
  }

  .concurrency-test-form,
  .concurrency-test-summary,
  .concurrency-test-results {
    grid-template-columns: 1fr;
  }
}

/* Keep feedback cheap: no full-panel blur or entrance animation. */
#tokenTable tr[aria-busy] { opacity: .7; }
#logsTable tbody[aria-busy] { opacity: .75; }
/* Team balances are login snapshots; keep the account table compact. */
.account-teams-dialog { width: min(680px, 94vw); }
.account-teams-options { display: grid; gap: 8px; max-height: 42vh; overflow-y: auto; margin: 14px 0; }
.account-team-option { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid #304556; border-radius: 8px; cursor: pointer; }
.account-team-option input { width: auto; flex: 0 0 auto; }
.account-team-option span { overflow-wrap: anywhere; }
.account-team-option small { display: block; margin-top: 4px; color: #9bb4c9; }
.account-cooldown-badge { display: block; width: max-content; margin-top: 5px; padding: 2px 6px; border: 1px solid #93732d; border-radius: 5px; background: #382e16; color: #ffd978; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.account-cooldown-badge[hidden] { display: none; }
.account-cooldown-badge button { margin-left: 6px; padding: 0 3px; border: 0; background: transparent; color: #9ed4ff; cursor: pointer; font: inherit; text-decoration: underline; }
.account-cooldown-badge button[hidden] { display: none; }
.token-credit-reset { display: block; max-width: 100%; color: #91a9bc; font-size: 10px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Account password editor */
.account-password-card {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 20px;
  background: linear-gradient(145deg, #122333, #0d1926 70%);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .55);
}
.account-password-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.account-password-eyebrow { margin: 0 0 6px; color: var(--brand); font-size: 12px; letter-spacing: .1em; }
.account-password-heading h2 { margin: 0; font-size: 22px; line-height: 1.35; }
.account-password-close { padding: 0; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.account-password-close:hover { background: rgba(255,255,255,.07); color: var(--text); }
.account-password-account { display: flex; align-items: center; gap: 12px; padding: 14px; margin: 22px 0; background: rgba(44,199,170,.05); border: 1px solid rgba(44,199,170,.16); border-radius: 12px; }
.account-password-account > div { min-width: 0; }
.account-password-avatar { flex: 0 0 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: rgba(44,199,170,.12); color: var(--brand); font-size: 19px; font-weight: 600; }
.account-password-account-label { color: var(--muted); font-size: 11px; }
.account-password-account p { margin: 3px 0 0; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.account-password-fields { display: grid; gap: 18px; }
.account-password-fields .form-group { gap: 9px; }
.account-password-fields label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.account-password-visible { color: var(--muted); font-size: 11px; font-weight: 400; }
.account-password-fields .input-text { min-height: 46px; padding: 12px 14px; border-radius: 10px; background: #091522; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.account-password-fields .input-text:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(44,199,170,.12); }
.account-password-fields .input-text::placeholder { color: #7890a6; font-family: system-ui, sans-serif; }
.account-password-help { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.account-password-error { margin: 12px 0 0; color: #ffb4bc; font-size: 12px; line-height: 1.6; }
.account-password-error:empty { display: none; }
.account-password-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.account-password-footer button { min-width: 96px; min-height: 42px; border-radius: 10px; }
@media (max-width: 540px) {
  .account-password-card { padding: 22px; border-radius: 16px; }
  .account-password-heading h2 { font-size: 20px; }
  .account-password-footer button { flex: 1; }
}


/* 20260930: keep cooldown controls inside the narrow enable column. */
.account-cooldown-badge { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:0 3px; box-sizing:border-box; max-width:100%; width:auto; margin:5px auto 0; padding:2px; font-size:10px; line-height:13px; white-space:normal; }
.account-cooldown-badge [data-cooldown-text] { max-width:100%; overflow-wrap:anywhere; }
.account-cooldown-badge button { flex:0 0 auto; margin:0; padding:0 3px; }

/* 20260930: countdown and restore button always share one line. */
.account-cooldown-badge { display:flex; flex-wrap:nowrap; gap:3px; width:max-content; max-width:100%; white-space:nowrap; }
.account-cooldown-badge [data-cooldown-text] { flex:0 0 auto; white-space:nowrap; overflow-wrap:normal; }
#tokenTable { min-width:1400px; }
.token-table-wrapper { overflow-x:auto; }
