:root {
  --bg: #f4f4f5;
  --bg-sidebar: #ffffff;
  --card: #ffffff;
  --card-border: #e4e4e7;
  --text: #11181c;
  --text-2: #3f3f46;
  --muted: #71717a;
  --brand: #006fee;
  --brand-hover: #005bc4;
  --brand-soft: #e6f1fe;
  --ink: #080808;
  --ink-hover: #27272a;
  --danger: #f31260;
  --danger-hover: #c20e4d;
  --danger-soft: #fdd0df;
  --success: #17c964;
  --success-soft: #d1f4e0;
  --warning: #f5a524;
  --warning-soft: #fdedd3;
  --border: #e4e4e7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --sidebar-w: 248px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tab-btn,
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.tab-btn:hover,
.nav-link:hover {
  background: #f4f4f5;
  text-decoration: none;
}

.tab-btn.active,
.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.topbar-metrics {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.metric {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  color: var(--muted);
}

.metric strong {
  color: var(--text);
  font-size: 13px;
}

.metric.ok strong {
  color: var(--success);
}

.content {
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.header,
.kicker,
.bg-orb,
.shell {
  display: contents;
}

h1,
h2 {
  color: var(--text);
}

h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}

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

.tabs {
  display: none;
}

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

.tab-pane.active {
  display: flex;
}

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

.config-category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafa;
}

.config-cat-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.config-cat-btn:hover {
  background: #fff;
}

.config-cat-btn.active {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.config-cat-pane {
  display: none;
}

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

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

.config-inline-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

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

.input-text,
.input-select,
textarea#tokenInput,
textarea#cookieInput,
textarea#refreshBundleInput,
textarea#confArpSessionId {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
}

.input-select {
  height: 32px;
  padding: 5px 28px 5px 10px;
}

textarea#tokenInput,
textarea#cookieInput,
textarea#confArpSessionId,
textarea#refreshBundleInput {
  min-height: 110px;
  resize: vertical;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.input-text:focus,
.input-select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 111, 238, 0.16);
}

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

.refresh-status {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fafafa;
  color: var(--text-2);
  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,
.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 950;
  padding: 20px;
}

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

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

.preview-modal-dialog {
  width: min(1100px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.selection-summary {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f4f4f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

button {
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 7px 11px;
  font-weight: 650;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

button:hover {
  background: var(--ink-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.secondary,
button.small {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover,
button.small:hover {
  background: #f4f4f5;
}

button.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger-soft);
}

button.danger:hover {
  background: var(--danger);
  color: #fff;
}

button.small {
  padding: 6px 10px;
  font-size: 12px;
}

.msg {
  font-size: 13px;
}

.msg.is-error {
  color: var(--danger);
}

.msg.is-ok {
  color: var(--success);
}

.toolbar-row,
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.list-head h2 {
  margin: 0;
}

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

.quick-actions-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
}

.quick-actions-card h2 {
  margin: 0;
  font-size: 13px;
}

.search-input {
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
}

.list-head .search-input {
  width: min(320px, 42vw);
  flex: 0 1 320px;
}

.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 111, 238, 0.16);
}

.token-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}

.token-filter-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
}

.token-filter-select {
  width: auto;
  min-width: 150px;
  flex: 0 0 auto;
}

.token-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.log-filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafa;
}

.compact-filter-row {
  margin-top: -2px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafa;
}

.log-filter-row .token-filters,
.compact-filter-row .token-filters {
  flex: 0 0 auto;
}

.compact-select,
.log-filter-row .input-select {
  width: auto;
  min-width: 112px;
  flex: 0 0 auto;
  padding: 7px 28px 7px 10px;
  font-size: 12px;
}

.toolbar-search {
  flex: 1 1 300px;
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-search .search-input {
  min-width: 0;
  width: 100%;
  flex: 1 1 auto;
  padding: 7px 10px;
  font-size: 12px;
}

.toolbar-search button {
  flex: 0 0 auto;
}

button.filter-chip {
  background: #fff;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 650;
  font-size: 12px;
}

button.filter-chip:hover {
  background: #fafafa;
  border-color: #d4d4d8;
}

button.filter-chip.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

.type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.type-paid {
  background: var(--brand-soft);
  color: #005bc4;
}

.type-free {
  background: #f4f4f5;
  color: #52525b;
}

.type-unknown {
  background: var(--warning-soft);
  color: #b45309;
}

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

.token-credits-summary strong {
  color: var(--text);
  font-size: 15px;
}

.input-select {
  min-width: 120px;
}

.token-pagesize-select,
.row-action-select,
.compact-select,
.token-filter-select,
.logs-pagination .input-select,
.token-pagination .input-select {
  width: auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(116px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafa;
  padding: 7px 9px;
}

.stat-card.warn {
  background: var(--warning-soft);
  border-color: #f5c97a;
}

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

.stat-value {
  color: var(--text);
  font-size: 16px;
  line-height: 1.1;
  font-weight: 700;
}

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

/* Token table: scroll area with sticky header */
.token-table-wrapper {
  overflow: auto;
  max-height: calc(100vh - 260px);
  min-height: 240px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.token-table-wrapper #tokenTable thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f4f6f9;
  box-shadow: inset 0 -1px 0 var(--border);
}

/* Compact rows to reduce height */
.compact-table td {
  padding: 4px 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.compact-table th {
  padding: 6px 8px;
}

.compact-table .account-cell {
  line-height: 1.25;
  font-size: 12px;
  max-width: 260px;
  text-align: left;
}

.account-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.account-line .account-name,
.account-line .account-email-inline {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-line .account-name {
  max-width: 92px;
  color: var(--text);
  font-weight: 650;
}

.account-line .account-email-inline {
  max-width: 150px;
  color: var(--muted);
}

.proxy-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.proxy-badge.system {
  background: #f4f4f5;
  color: #71717a;
}

.proxy-badge.dedicated {
  background: var(--success-soft);
  color: #0d7a3e;
}

.compact-table .action-btns {
  gap: 4px;
  min-width: 128px;
}

.compact-table .action-btns button,
.compact-table .action-mini {
  padding: 3px 5px;
  font-size: 10.5px;
  border-radius: 6px;
}

.row-action-select {
  width: 78px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  padding: 2px 6px;
}

.compact-table .switch-btn {
  width: 30px;
  height: 16px;
  padding: 1px;
}

/* Token pagination footer: sticky at bottom of card */
.token-pagination {
  position: sticky;
  bottom: 0;
  justify-content: space-between;
  background: var(--card, #fff);
  padding: 10px 4px 2px;
  border-top: 1px solid var(--border);
  z-index: 2;
}

.token-pagination .pagination-left,
.token-pagination .pagination-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-pagesize-select {
  min-width: 62px;
  height: 30px;
  padding: 4px 24px 4px 8px;
}

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

.token-summary strong {
  color: var(--text);
  font-size: 13px;
}

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

#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: 132px;
  white-space: nowrap;
}

#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(8),
#logsTable td:nth-child(8),
#runningLogsTable th:nth-child(8),
#runningLogsTable td:nth-child(8) {
  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: 220px;
}

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

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

#logsTable td,
#runningLogsTable td {
  padding: 5px 7px;
  vertical-align: middle;
  line-height: 1.22;
}

.log-account-cell {
  display: block;
  color: var(--text-2);
  line-height: 1.2;
  font-size: 12px;
}

.log-time-cell {
  color: var(--text-2);
  line-height: 1.2;
  white-space: nowrap;
  font-size: 12px;
}

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

.log-time-cell .time {
  display: inline;
  color: var(--muted);
}

.log-time-cell .date::after {
  content: " ";
}

.log-account-email {
  color: var(--muted);
  word-break: break-all;
}

.log-account-name {
  display: block;
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}

.log-account-id {
  display: block;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.log-model-cell {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-2);
  word-break: break-word;
}

.log-model-name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.log-quality-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--brand-soft);
  color: var(--brand);
}

.log-quality-badge.low {
  background: #f4f4f5;
  color: var(--muted);
}

.log-quality-badge.medium {
  background: var(--warning-soft);
  color: #b45309;
}

.log-quality-badge.high {
  background: var(--success-soft);
  color: #0f7a45;
}

.log-size-cell {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.4;
  white-space: nowrap;
}

.log-size-sub {
  color: var(--muted);
  font-size: 11px;
}

.log-id-cell {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-2);
  word-break: break-all;
  max-width: 180px;
}

.log-error-cell {
  color: var(--danger);
  font-size: 12px;
  line-height: 1.35;
  max-width: 420px;
  word-break: break-word;
  white-space: pre-wrap;
}

button.log-error-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.log-state-btn.failed span {
  max-width: 180px;
  white-space: normal;
  text-align: left;
  word-break: break-word;
}

.log-prompt-cell {
  white-space: nowrap;
}

.json-preview-content pre {
  white-space: pre;
  word-break: normal;
  overflow: auto;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
}

th {
  text-align: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: #fafafa;
  white-space: nowrap;
}

td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: center;
}

tbody tr:hover {
  background: #fafafa;
}

.token-val {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-2);
  word-break: break-all;
}

.status-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-active {
  background: var(--success-soft);
  color: #0d7a3e;
}

.status-exhausted {
  background: var(--warning-soft);
  color: #b45309;
}

.status-invalid,
.status-error {
  background: var(--danger-soft);
  color: #c20e4d;
}

.status-disabled {
  background: #f4f4f5;
  color: #52525b;
}

.log-status-2xx {
  background: var(--success-soft);
  color: #0d7a3e;
}

.log-status-4xx {
  background: var(--warning-soft);
  color: #b45309;
}

.log-status-5xx {
  background: var(--danger-soft);
  color: #c20e4d;
}

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

.log-state.running {
  color: #005bc4;
  background: var(--brand-soft);
}

.log-state.success {
  color: #0d7a3e;
  background: var(--success-soft);
}

.log-state.failed {
  color: #c20e4d;
  background: var(--danger-soft);
}

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

.log-state-btn.failed {
  border: 1px solid var(--danger-soft);
  background: var(--danger-soft);
  color: #c20e4d;
}

.log-state-btn.failed:hover {
  background: var(--danger);
  color: #fff;
}

.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: #f0f7ff;
}

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

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

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

.action-btns button,
.action-mini {
  width: 100%;
  padding: 4px 6px;
  font-size: 11px;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.action-btns button:hover,
.action-mini:hover {
  background: #f4f4f5;
}

.action-mini.danger,
.action-btns button.danger {
  color: var(--danger);
  border-color: var(--danger-soft);
}

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

.switch-btn.on {
  background: var(--brand);
  border-color: var(--brand);
}

.switch-btn.off {
  background: #e4e4e7;
}

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

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

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

.switch-text {
  margin-left: 4px;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}

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

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

.logs-pagination .pagination-left,
.logs-pagination .pagination-right {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.logs-pagination .help,
.token-pagination .help {
  white-space: nowrap;
}

.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: #09090b;
}

.preview-empty {
  color: var(--muted);
  font-size: 13px;
}

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

.error-detail-head h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.error-detail-content {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafafa;
  padding: 12px;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.error-detail-content pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-2);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #11181c;
  color: #fff;
  border: 1px solid #11181c;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
  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 {
  background: #0d7a3e;
  border-color: #0d7a3e;
}

.toast.error {
  background: var(--danger);
  border-color: var(--danger);
}

.text-muted {
  color: var(--muted);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: #b45309;
}

.text-success {
  color: #0d7a3e;
}

.text-body {
  color: var(--text-2);
}

.account-cell {
  color: var(--text-2);
  font-size: 12px;
}

.model-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  white-space: normal;
}

.switch-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}

body.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 12% 8%, rgba(0, 111, 238, 0.08), transparent 36%),
    var(--bg);
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
}

.login-card .brand {
  padding: 0 0 18px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-card .actions {
  margin-top: 8px;
}

.login-card button {
  width: 100%;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 960px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 20px 0 40px rgba(0, 0, 0, 0.12);
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.28);
    z-index: 15;
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

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

  .list-head,
  .toolbar-row {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .search-input {
    width: 100%;
  }

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

  .token-filter-row {
    width: 100%;
  }

  .topbar-metrics {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .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,
  .search-input {
    width: 100%;
  }

  .content {
    padding: 16px;
  }
}

@media (min-width: 561px) {
  .log-filter-row .input-select,
  .compact-select,
  .token-filter-select {
    width: auto;
  }
}

@media (min-width: 720px) {
  .stats-grid {
    grid-template-columns: repeat(6, minmax(96px, 1fr));
  }
}

@media (min-width: 561px) and (max-width: 719px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
