:root {
  --bg: #070912;
  --panel: #0b0e18;
  --panel-2: #111522;
  --card: rgba(17, 21, 34, 0.88);
  --card-border: rgba(148, 163, 184, 0.18);
  --text: #eef3ff;
  --muted: #8994aa;
  --brand: #7c6cff;
  --brand-2: #38d6b6;
  --brand-hover: #8e81ff;
  --danger: #ff5f70;
  --danger-hover: #e34c5d;
  --border: rgba(148, 163, 184, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at 18% 10%, rgba(124, 108, 255, 0.28), transparent 34%),
    radial-gradient(circle at 82% 18%, rgba(56, 214, 182, 0.14), transparent 30%),
    linear-gradient(135deg, #070912 0%, #0a0d17 44%, #050711 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: #7c6cff;
  top: -150px;
  right: -100px;
}
.bg-orb-b {
  width: 500px;
  height: 500px;
  background: #38d6b6;
  left: -200px;
  bottom: -200px;
}

.login-page {
  min-height: 100vh;
  overflow: hidden;
}

.login-shell {
  min-height: 100vh;
  width: 100%;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.login-card {
  width: min(440px, 100%);
  padding: 34px 34px 30px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 34%),
    rgba(15, 19, 31, 0.9);
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(18px);
}

.login-brand {
  width: fit-content;
  margin-bottom: 18px;
  padding: 8px 12px;
  border: 1px solid rgba(124, 108, 255, 0.28);
  border-radius: 999px;
  color: #b8f7e8;
  background: rgba(56, 214, 182, 0.08);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 0;
  color: #f7f9ff;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.login-hint {
  margin: 12px 0 28px;
  color: #9aa6bd;
  font-size: 15px;
  font-weight: 700;
}

.login-card .form-group {
  margin: 0 0 18px;
}

.login-card .input-text {
  width: 100%;
  height: 54px;
  border-radius: 18px;
}

.login-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.login-actions button {
  min-width: 108px;
  height: 52px;
  border-radius: 18px;
}

.login-actions .msg {
  min-height: 20px;
}

.shell {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 0;
}

.overview-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.mini-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(5, 12, 22, 0.38);
  padding: 16px;
}

.mini-panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-stat-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.mini-stat-row span,
.mini-stat-row strong {
  position: relative;
  z-index: 1;
}

.mini-stat-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-stat-row i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(44, 199, 170, 0.22), rgba(44, 199, 170, 0.03));
}

.testgen-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.testgen-result img {
  max-width: min(520px, 100%);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #08111c;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
  word-break: break-all;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  padding: 24px;
}

.header {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.header.card {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 112px;
  justify-content: center;
  text-align: left !important;
  border-radius: 0;
  border: 0;
  border-right: 1px solid rgba(148, 163, 184, 0.16);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  background:
    linear-gradient(145deg, rgba(124, 108, 255, 0.2), transparent 44%),
    rgba(9, 12, 22, 0.96);
  box-shadow: none;
  padding: 24px 28px !important;
}

.header h1 {
  position: relative;
  padding-left: 54px;
  color: #f5f7ff;
  letter-spacing: -0.02em !important;
}

.header h1::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent),
    linear-gradient(135deg, var(--brand), #4b9dff);
  box-shadow: 0 10px 28px rgba(124, 108, 255, 0.45);
}

.header h1::after {
  content: "API";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 700;
}

.header .muted {
  padding-left: 54px;
  color: #6f7b92;
}
.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;
  grid-column: 1;
  grid-row: 2;
  position: sticky;
  top: 112px;
  height: calc(100vh - 112px);
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  border-bottom: 0;
  border-right: 1px solid rgba(148, 163, 184, 0.16);
  padding: 26px 14px;
  background: rgba(8, 11, 20, 0.94);
}

.tab-btn {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  color: #9aa5bb;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
  text-align: left;
  letter-spacing: 0.01em;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecff;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(124, 108, 255, 0.28), rgba(124, 108, 255, 0.13));
  color: #ffffff;
  border: 1px solid rgba(124, 108, 255, 0.45);
  box-shadow: 0 12px 30px rgba(34, 27, 83, 0.35);
}

.tab-btn::before {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: #dce2ff;
  font-size: 14px;
}

.tab-btn[data-target="overview"]::before { content: "▥"; }
.tab-btn[data-target="testgen"]::before { content: "◉"; }
.tab-btn[data-target="tokens"]::before { content: "◍"; }
.tab-btn[data-target="config"]::before { content: "⚙"; }
.tab-btn[data-target="logs"]::before { content: "▤"; }

.tab-btn.active::after {
  content: "";
  position: absolute;
  right: -15px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 999px;
  background: var(--brand);
}

.tab-pane {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: none;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  padding: 34px 40px 60px;
}

.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: 14px;
  background: rgba(255, 255, 255, 0.035);
}

.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(124, 108, 255, 0.2);
  color: #dcd7ff;
  border-color: rgba(124, 108, 255, 0.45);
}

.config-cat-pane {
  display: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  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: #d8def0;
}

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

.input-text {
  width: 100%;
  background: rgba(6, 9, 17, 0.86);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  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(6, 9, 17, 0.86);
  border: 1px solid var(--border);
  border-radius: 12px;
  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(6, 9, 17, 0.86);
  border: 1px solid var(--border);
  border-radius: 12px;
  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: #101522;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  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: linear-gradient(135deg, var(--brand), #5c8cff);
  color: #ffffff;
  border: none;
  border-radius: 11px;
  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.08);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.18);
}
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;
  gap: 18px;
}
.list-head h2 {
  font-size: 34px;
  letter-spacing: -0.04em;
  white-space: nowrap;
  flex: 0 0 auto;
}
.list-head h2 {
  margin: 0;
}

.list-head .actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.logs-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  width: min(100%, 800px);
  gap: 10px;
}

.logs-toolbar .input-select,
.logs-toolbar .input-text {
  min-width: 0;
}

.logs-toolbar #logStatsRange,
.logs-toolbar #logsStatusFilter,
.logs-toolbar #logsPageSize {
  width: 120px;
}

.logs-toolbar #logsTokenFilter {
  width: min(260px, 100%);
  flex: 1 1 180px;
}

.logs-toolbar #logsSearchInput {
  width: min(260px, 100%);
  flex: 1 1 220px;
}

.logs-toolbar .help {
  white-space: nowrap;
}

.logs-toolbar button {
  white-space: nowrap;
  padding-left: 14px;
  padding-right: 14px;
}

.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(6, 9, 17, 0.86);
  border: 1px solid var(--border);
  border-radius: 12px;
  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: 14px;
  margin-bottom: 12px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(124, 108, 255, 0.1), transparent 48%),
    rgba(255, 255, 255, 0.04);
  padding: 18px;
  min-height: 108px;
}

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

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

.table-wrapper {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(7, 10, 18, 0.42);
}

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

.token-filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(3, minmax(150px, 0.7fr)) auto;
  gap: 10px;
  align-items: center;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid rgba(158, 177, 214, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.014)),
    rgba(5, 10, 22, 0.48);
}

.token-filter-bar .input-text,
.token-filter-bar .input-select {
  min-width: 0;
}

.token-filter-bar button {
  white-space: nowrap;
}

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

#logsTable,
#runningLogsTable {
  table-layout: fixed;
  min-width: 1240px;
}

#logsTable .log-col-detail { width: 78px; }
#logsTable .log-col-time { width: 108px; }
#logsTable .log-col-token { width: 118px; }
#logsTable .log-col-account { width: 245px; }
#logsTable .log-col-model { width: 220px; }
#logsTable .log-col-prompt { width: 330px; }
#logsTable .log-col-size { width: 100px; }
#logsTable .log-col-status { width: 150px; }
#logsTable .log-col-preview { width: 86px; }

#logsTable th,
#logsTable td {
  box-sizing: border-box;
}

#logsTable td,
#runningLogsTable td {
  padding: 14px 12px;
  vertical-align: middle;
  min-width: 0;
}

#logsTable th {
  padding: 14px 12px;
  white-space: nowrap;
}

.log-account-cell {
  color: #a8bfd8;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-time-cell {
  color: #a8bfd8;
  line-height: 1.2;
  white-space: nowrap;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.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 {
  color: #c7b6ff;
  font-size: 12px;
  font-weight: 700;
  word-break: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-prompt-cell {
  color: #e7f1fd;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-model-badge {
  display: inline-block;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(124, 108, 255, 0.16);
  color: #cbbfff;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.log-size-cell {
  color: #e7f1fd;
  line-height: 1.25;
  font-size: 12px;
  white-space: nowrap;
}

th {
  text-align: left;
  padding: 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  color: #59667c;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.035);
}

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

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

.status-active { background: rgba(44, 199, 170, 0.18); color: #60e6c8; }
.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;
  justify-content: center;
  gap: 6px;
  min-width: 78px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

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

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

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-field {
  border: 1px solid rgba(142, 181, 221, 0.18);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.detail-field strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.detail-field span {
  display: block;
  color: #e7f1fd;
  word-break: break-word;
}

.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) {
  .shell {
    display: flex;
    flex-direction: column;
  }

  .header.card {
    position: relative;
    min-height: auto;
    border-right: 0;
  }

  .tabs {
    position: relative;
    top: auto;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  }

  .tab-btn {
    min-width: max-content;
  }

  .tab-btn.active::after {
    display: none;
  }

  .tab-pane {
    padding: 24px 16px 44px;
  }

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

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

  .logs-toolbar #logStatsRange,
  .logs-toolbar #logsStatusFilter,
  .logs-toolbar #logsPageSize,
  .logs-toolbar #logsTokenFilter,
  .logs-toolbar #logsSearchInput {
    width: 100%;
    flex: 1 1 180px;
  }

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

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

  .token-filter-bar {
    grid-template-columns: 1fr 1fr;
  }

  .overview-panels,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@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 {
    width: 100%;
  }

  .token-filter-bar {
    grid-template-columns: 1fr;
  }
}

/* Premium console polish */
:root {
  --bg: #060811;
  --panel: #090d19;
  --panel-2: #10182a;
  --card: rgba(13, 18, 32, 0.76);
  --card-border: rgba(158, 177, 214, 0.18);
  --text: #f4f7ff;
  --muted: #8d99b2;
  --brand: #4ee0c1;
  --brand-2: #ffb457;
  --brand-hover: #71ebd2;
  --danger: #ff6577;
  --danger-hover: #ff7a8a;
  --border: rgba(158, 177, 214, 0.16);
  --field: rgba(4, 8, 18, 0.78);
  --field-border: rgba(158, 177, 214, 0.2);
  --field-focus: rgba(78, 224, 193, 0.78);
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.46);
}

html {
  scrollbar-color: rgba(78, 224, 193, 0.45) rgba(7, 10, 20, 0.7);
}

body {
  background:
    radial-gradient(circle at 12% 8%, rgba(78, 224, 193, 0.2), transparent 28%),
    radial-gradient(circle at 78% 16%, rgba(255, 180, 87, 0.14), transparent 26%),
    radial-gradient(circle at 70% 84%, rgba(86, 114, 255, 0.18), transparent 31%),
    linear-gradient(135deg, #050711 0%, #090d18 48%, #050710 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.88), transparent 84%);
}

.bg-orb {
  opacity: 0.34;
  filter: blur(72px);
}

.bg-orb-a {
  background: #4ee0c1;
}

.bg-orb-b {
  background: #ffb457;
}

.shell {
  grid-template-columns: 292px minmax(0, 1fr);
}

.header.card,
.tabs {
  background:
    linear-gradient(180deg, rgba(14, 20, 37, 0.96), rgba(7, 10, 20, 0.96)),
    rgba(7, 10, 20, 0.96);
  border-right: 1px solid rgba(158, 177, 214, 0.14);
}

.header.card {
  min-height: 126px;
  padding: 28px 26px !important;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
}

.header h1 {
  font-size: 25px !important;
  letter-spacing: -0.035em !important;
}

.header h1::before {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 42%),
    linear-gradient(135deg, #4ee0c1, #5576ff 55%, #ffb457);
  box-shadow:
    0 16px 34px rgba(78, 224, 193, 0.23),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.header .muted {
  color: #8190aa;
}

.tabs {
  top: 126px;
  height: calc(100vh - 126px);
  padding: 24px 14px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
}

.tab-btn {
  min-height: 54px;
  border: 1px solid transparent;
  color: #97a4bd;
  font-size: 15px;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.tab-btn:hover {
  transform: translateX(2px);
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.06);
}

.tab-btn.active {
  background:
    linear-gradient(135deg, rgba(78, 224, 193, 0.2), rgba(85, 118, 255, 0.15)),
    rgba(255, 255, 255, 0.045);
  border-color: rgba(78, 224, 193, 0.36);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tab-btn::before {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #dbe7ff;
}

.tab-btn.active::before {
  color: #061015;
  background: linear-gradient(135deg, #4ee0c1, #ffd28a);
}

.tab-btn.active::after {
  right: -15px;
  background: linear-gradient(180deg, #4ee0c1, #ffb457);
  box-shadow: 0 0 22px rgba(78, 224, 193, 0.55);
}

.tab-pane {
  padding: 38px 44px 70px;
}

.card,
.dialog-card {
  position: relative;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(12, 17, 31, 0.78);
  border: 1px solid rgba(158, 177, 214, 0.18);
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.075);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(78, 224, 193, 0.09), transparent 34%, rgba(255, 180, 87, 0.045));
  opacity: 0.7;
}

.card > * {
  position: relative;
  z-index: 1;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(158, 177, 214, 0.13);
}

.section-title h2,
.list-head h2,
.config-card > h2 {
  margin: 0;
  color: #f8fbff;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1;
  letter-spacing: -0.055em;
}

.section-title .muted {
  max-width: 560px;
  color: #99a7be;
  text-align: right;
}

.config-card {
  overflow: hidden;
}

.config-form {
  gap: 20px;
}

.config-category-tabs {
  position: sticky;
  top: 18px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(158, 177, 214, 0.16);
  background:
    linear-gradient(180deg, rgba(10, 15, 28, 0.94), rgba(7, 11, 22, 0.9));
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
}

.config-cat-btn {
  min-height: 44px;
  border-radius: 13px;
  background: transparent;
  color: #93a2bc;
  border: 1px solid transparent;
  padding: 10px 12px;
}

.config-cat-btn:hover {
  background: rgba(255, 255, 255, 0.055);
  color: #f0f5ff;
}

.config-cat-btn.active {
  color: #061015;
  background: linear-gradient(135deg, #4ee0c1, #ffd08b);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(78, 224, 193, 0.18);
}

.config-cat-pane {
  border-radius: 22px;
  padding: 22px;
  gap: 18px;
  border: 1px solid rgba(158, 177, 214, 0.15);
  background:
    linear-gradient(145deg, rgba(78, 224, 193, 0.055), rgba(255, 255, 255, 0.02) 38%, rgba(255, 180, 87, 0.04)),
    rgba(6, 10, 21, 0.46);
}

.form-group {
  gap: 8px;
}

.form-group label {
  color: #ecf2ff;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.01em;
}

.help {
  color: #8391aa;
  line-height: 1.55;
}

.field-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.field-title-row label {
  display: block;
  margin-bottom: 6px;
}

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

.api-key-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.api-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid rgba(158, 177, 214, 0.16);
  border-radius: 20px;
  background:
    radial-gradient(circle at 100% 0%, rgba(78, 224, 193, 0.1), transparent 32%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    rgba(3, 8, 18, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.api-key-row-main {
  display: grid;
  grid-template-columns: minmax(150px, 0.28fr) minmax(260px, 1fr) minmax(130px, 0.22fr);
  gap: 12px;
  min-width: 0;
}

.api-key-value-wrap,
.api-key-limit-wrap {
  min-width: 0;
}

.api-key-usage {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: #93a2bc;
  font-size: 12px;
}

.api-key-usage span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(158, 177, 214, 0.14);
  background: rgba(255, 255, 255, 0.045);
}

.api-key-usage strong {
  color: #f3f7ff;
  font-weight: 900;
}

.api-key-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-bottom: 1px;
}

.api-key-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 999px;
  color: #dce7f7;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  border: 1px solid rgba(158, 177, 214, 0.16);
  background: rgba(255, 255, 255, 0.055);
}

.api-key-empty {
  padding: 18px;
  border: 1px dashed rgba(158, 177, 214, 0.28);
  border-radius: 18px;
  color: #93a2bc;
  background: rgba(255, 255, 255, 0.035);
}

.input-text,
.input-select,
textarea,
textarea#tokenInput,
textarea#refreshBundleInput,
textarea#cookieInput,
#testGenPrompt {
  width: 100%;
  color: #f4f8ff;
  caret-color: var(--brand);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012)),
    var(--field);
  border: 1px solid var(--field-border);
  border-radius: 16px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 12px 28px rgba(0, 0, 0, 0.16);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.input-text,
textarea,
textarea#tokenInput,
textarea#refreshBundleInput,
textarea#cookieInput,
#testGenPrompt {
  padding: 13px 15px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.input-select {
  min-height: 44px;
  padding: 10px 38px 10px 13px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #9fafc8 50%),
    linear-gradient(135deg, #9fafc8 50%, transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012));
  background-position:
    calc(100% - 19px) 50%,
    calc(100% - 14px) 50%,
    0 0;
  background-size: 5px 5px, 5px 5px, 100% 100%;
  background-repeat: no-repeat;
  background-color: var(--field);
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.55;
}

.input-text::placeholder,
textarea::placeholder {
  color: #5f6f88;
}

.input-text:hover,
.input-select:hover,
textarea:hover {
  border-color: rgba(158, 177, 214, 0.34);
}

.input-text:focus,
.input-select:focus,
textarea:focus {
  outline: none;
  border-color: var(--field-focus);
  box-shadow:
    0 0 0 4px rgba(78, 224, 193, 0.12),
    0 16px 36px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus {
  -webkit-text-fill-color: #f4f8ff;
  -webkit-box-shadow: 0 0 0 1000px #071020 inset;
  transition: background-color 9999s ease-out;
}

.checkbox-label {
  width: fit-content;
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(158, 177, 214, 0.14);
}

input[type="checkbox"] {
  accent-color: var(--brand);
}

button {
  border-radius: 14px;
  min-height: 40px;
  background:
    linear-gradient(135deg, #4ee0c1, #5e7cff 58%, #ffb457);
  color: #071017;
  font-weight: 850;
  box-shadow:
    0 14px 32px rgba(78, 224, 193, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  background:
    linear-gradient(135deg, #75efd8, #7891ff 58%, #ffd08c);
  box-shadow:
    0 18px 42px rgba(78, 224, 193, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

button:disabled {
  cursor: not-allowed;
  transform: none;
  opacity: 0.55;
}

button.secondary,
button.small {
  color: #eaf0ff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(158, 177, 214, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

button.secondary:hover,
button.small:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(78, 224, 193, 0.35);
}

button.danger {
  color: #ff9baa;
  background: rgba(255, 101, 119, 0.1);
  border-color: rgba(255, 101, 119, 0.34);
}

button.danger:hover {
  color: #fff;
  background: rgba(255, 101, 119, 0.24);
}

.stats-grid {
  gap: 16px;
}

.stat-card,
.mini-panel,
.table-wrapper,
.refresh-status {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    rgba(5, 10, 22, 0.56);
  border-color: rgba(158, 177, 214, 0.14);
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(78, 224, 193, 0.2), transparent 64%);
}

.stat-label {
  color: #93a1b9;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  color: #f9fbff;
  letter-spacing: -0.055em;
}

.table-wrapper {
  border-radius: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

th {
  color: #7f8ca4;
  background: rgba(255, 255, 255, 0.025);
}

td {
  border-bottom-color: rgba(158, 177, 214, 0.1);
}

tbody tr:hover {
  background: rgba(78, 224, 193, 0.045);
}

.status-badge,
.log-state,
.log-model-badge {
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.toast {
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)),
    rgba(8, 12, 24, 0.92);
  border-color: rgba(78, 224, 193, 0.28);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.36);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: rgba(6, 9, 18, 0.78);
}

::-webkit-scrollbar-thumb {
  border: 3px solid rgba(6, 9, 18, 0.78);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(78, 224, 193, 0.68), rgba(255, 180, 87, 0.5));
}

@media (max-width: 1100px) {
  .config-category-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .api-key-row {
    grid-template-columns: 1fr;
  }

  .api-key-row-actions {
    justify-content: flex-start;
  }

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

  .section-title .muted {
    text-align: left;
  }
}

@media (max-width: 900px) {
  .header.card {
    min-height: auto;
  }

  .tabs {
    top: auto;
    height: auto;
  }

  .tab-pane {
    padding: 26px 16px 48px;
  }

  .config-category-tabs {
    position: relative;
    top: auto;
  }
}

@media (max-width: 560px) {
  .config-category-tabs {
    grid-template-columns: 1fr;
  }

  .field-title-row,
  .api-key-row-main,
  .api-key-row-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .inline-actions,
  .api-key-row-actions {
    justify-content: stretch;
  }

  .inline-actions button,
  .api-key-row-actions button {
    width: 100%;
  }

  .section-title h2,
  .list-head h2 {
    font-size: 28px;
  }
}
