/* Admin Console — LLM keys + customer credits */

.wrap-admin {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.admin-head {
  margin-bottom: 18px;
}

.admin-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.admin-head h1 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.admin-lead {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-dim);
  max-width: 46em;
  line-height: 1.5;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.admin-tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.12s;
}

.admin-tab:hover:not(.on) {
  border-color: rgba(232, 180, 74, 0.22);
  color: var(--text);
}

.admin-tab.on {
  border-color: var(--gold);
  color: var(--gold);
  background: linear-gradient(180deg, rgba(232, 180, 74, 0.12), rgba(232, 180, 74, 0.05));
  box-shadow: 0 4px 16px rgba(232, 180, 74, 0.08);
}

.admin-panel[hidden] { display: none !important; }

/* Toolbar */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.admin-toolbar-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
}

.admin-stat-pill .k {
  color: var(--text-faint);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.admin-stat-pill .v {
  font-weight: 800;
  font-size: 14px;
}

.admin-stat-pill.ok .v { color: var(--green); }
.admin-stat-pill.gold .v { color: var(--gold-bright); }
.admin-stat-pill.warn .v { color: #f0c87a; }
.admin-stat-pill.red .v { color: #f0786f; }

/* Model Pool Brain state badges + section titles */
.mb-state {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}
.mb-state.green { color: #4ade80; border-color: rgba(74, 222, 128, 0.4); background: rgba(74, 222, 128, 0.08); }
.mb-state.yellow { color: #f0c87a; border-color: rgba(240, 200, 122, 0.4); background: rgba(240, 200, 122, 0.08); }
.mb-state.red { color: #f0786f; border-color: rgba(240, 120, 111, 0.45); background: rgba(240, 120, 111, 0.1); }
.mb-state.dead { color: #9aa0a6; border-color: rgba(154, 160, 166, 0.4); background: rgba(154, 160, 166, 0.08); }
.mb-state.unknown { color: #9aa0a6; border-color: rgba(154, 160, 166, 0.3); background: transparent; }
.mb-section-title {
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-search {
  min-width: min(280px, 100%);
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.admin-search:focus {
  outline: none;
  border-color: rgba(232, 180, 74, 0.45);
  box-shadow: 0 0 0 3px rgba(232, 180, 74, 0.1);
}

.admin-select-sm {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

/* Buttons */
.admin-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.admin-btn:hover:not(:disabled) {
  border-color: rgba(232, 180, 74, 0.35);
}

.admin-btn.primary {
  border: none;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #14100a;
}

.admin-btn.primary:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.admin-btn.ghost {
  background: transparent;
  color: var(--text-dim);
}

.admin-btn.xs {
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 8px;
}

.admin-btn.ok:hover { border-color: rgba(47, 191, 113, 0.45); color: #8ce8b8; }
.admin-btn.warn:hover { border-color: rgba(229, 83, 75, 0.45); color: #f0b4b0; }
.admin-btn.danger {
  border-color: rgba(229, 83, 75, 0.25);
  color: #f0b4b0;
}

.admin-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.admin-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.admin-icon-btn:hover {
  border-color: rgba(232, 180, 74, 0.35);
  color: var(--gold-bright);
}

/* Cards */
.admin-card {
  background: linear-gradient(165deg, rgba(22, 28, 38, 0.98) 0%, rgba(14, 18, 26, 0.98) 100%);
  border: 1px solid rgba(232, 180, 74, 0.08);
  border-radius: 16px;
  padding: 16px 18px 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  margin-bottom: 12px;
}

.admin-table-card {
  padding: 0;
  overflow: hidden;
}

.admin-table-card .admin-table-wrap {
  max-height: min(68vh, 720px);
}

.admin-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.admin-card-head h2 {
  font-size: 15px;
  font-weight: 800;
}

.admin-key-form-panel[hidden] { display: none !important; }

.admin-key-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.admin-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  margin: 10px 0 6px;
}

.admin-field label .hint {
  font-weight: 600;
  color: var(--text-faint);
}

.admin-field input,
.admin-field select {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.admin-field input:focus,
.admin-field select:focus {
  outline: none;
  border-color: rgba(232, 180, 74, 0.45);
  box-shadow: 0 0 0 3px rgba(232, 180, 74, 0.1);
}

.admin-field.span-2 { grid-column: span 2; }

.admin-form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.admin-form-hint {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.45;
  max-width: 36em;
}

/* Tables */
.admin-table-wrap {
  overflow: auto;
  max-height: min(68vh, 720px);
}

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

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 10px 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: rgba(12, 16, 22, 0.98);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(35, 44, 59, 0.55);
  vertical-align: middle;
}

.admin-table tbody tr {
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.admin-table tbody tr:hover td {
  background: rgba(232, 180, 74, 0.04);
}

.admin-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 rgba(232, 180, 74, 0.55);
}

.admin-empty-cell {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 16px !important;
}

.admin-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.admin-empty-icon {
  font-size: 22px;
  color: rgba(232, 180, 74, 0.35);
  line-height: 1;
}

.admin-key-cell { min-width: 140px; max-width: 220px; }

.admin-key-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.admin-secret {
  display: inline-block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.admin-cell-sub {
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-faint);
  word-break: break-all;
}

.admin-cell-dim {
  color: var(--text-dim);
  font-size: 11px;
}

.admin-mono {
  font: 11px/1.4 ui-monospace, Menlo, Consolas, monospace;
  color: var(--gold-bright);
  word-break: break-all;
}

.admin-row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  max-width: 190px;
}

/* Pool selector — chip with dot, blends with admin design */
.admin-poolwrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(232, 180, 74, 0.22);
  background: linear-gradient(180deg, rgba(232, 180, 74, 0.07), rgba(232, 180, 74, 0.02));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
  max-width: 190px;
}
.admin-poolwrap:hover {
  border-color: rgba(232, 180, 74, 0.45);
  box-shadow: 0 0 0 3px rgba(232, 180, 74, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.admin-pooldot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--gold-bright));
  box-shadow: 0 0 6px var(--dot, var(--gold-bright));
  flex: 0 0 auto;
  animation: admin-dot-pulse 2.4s ease-in-out infinite;
}
@keyframes admin-dot-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.55; }
}
.admin-pool-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  color: var(--gold-bright);
  font: 800 10px ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0 14px 0 0;
  max-width: 150px;
  background-image: linear-gradient(45deg, transparent 50%, rgba(232, 180, 74, 0.7) 50%), linear-gradient(135deg, rgba(232, 180, 74, 0.7) 50%, transparent 50%);
  background-position: calc(100% - 8px) 55%, calc(100% - 4px) 55%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}
.admin-pool-select:focus { outline: none; }
.admin-pool-select option {
  background: var(--bg-2);
  color: var(--text);
  font-weight: 600;
}

/* Icon buttons — compact, glow on hover */
.admin-ibtn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.005));
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.16s, color 0.16s, transform 0.12s, box-shadow 0.16s;
}
.admin-ibtn:hover {
  border-color: rgba(232, 180, 74, 0.45);
  color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(232, 180, 74, 0.12);
  transform: translateY(-1px);
}
.admin-ibtn:active { transform: translateY(0) scale(0.94); }
.admin-ibtn.gold {
  color: var(--gold-bright);
  border-color: rgba(232, 180, 74, 0.35);
  background: linear-gradient(180deg, rgba(232, 180, 74, 0.14), rgba(232, 180, 74, 0.04));
}
.admin-ibtn.gold:hover {
  box-shadow: 0 0 14px rgba(232, 180, 74, 0.28);
  border-color: var(--gold);
}
.admin-ibtn.ok { color: #8ce8b8; }
.admin-ibtn.ok:hover { border-color: rgba(47, 191, 113, 0.5); color: #b8f5d2; box-shadow: 0 0 10px rgba(47, 191, 113, 0.15); }
.admin-ibtn.warn { color: #f0b4b0; }
.admin-ibtn.warn:hover { border-color: rgba(229, 83, 75, 0.5); color: #f7c9c5; box-shadow: 0 0 10px rgba(229, 83, 75, 0.15); }
.admin-ibtn.danger {
  color: #f0b4b0;
  border-color: rgba(229, 83, 75, 0.25);
  background: rgba(229, 83, 75, 0.05);
}
.admin-ibtn.danger:hover {
  border-color: rgba(229, 83, 75, 0.55);
  color: #ffb8b2;
  box-shadow: 0 0 12px rgba(229, 83, 75, 0.2);
}

/* Credit pill with live bar */
.admin-stat-pill.credit {
  position: relative;
  overflow: hidden;
  padding-bottom: 6px;
  min-width: 108px;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}
.admin-stat-pill.credit .k { display: flex; justify-content: space-between; align-items: baseline; }
.admin-stat-pill.credit .v { font-size: 15px; }
.admin-credit-bar {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  margin-top: 2px;
}
.admin-credit-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-bright), #f4d48a);
  box-shadow: 0 0 8px rgba(232, 180, 74, 0.5);
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.admin-stat-pill.credit.mid .admin-credit-bar-fill {
  background: linear-gradient(90deg, #e8b44a, #f0c87a);
}
.admin-stat-pill.credit.low .admin-credit-bar-fill {
  background: linear-gradient(90deg, #e5534b, #f0786f);
  box-shadow: 0 0 10px rgba(229, 83, 75, 0.6);
  animation: admin-credit-alert 1.2s ease-in-out infinite;
}
.admin-stat-pill.credit.low .v {
  color: #ff8f87;
}
@keyframes admin-credit-alert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.admin-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-badge.ok {
  color: #8ce8b8;
  background: rgba(47, 191, 113, 0.12);
  border: 1px solid rgba(47, 191, 113, 0.28);
}

.admin-badge.off {
  color: var(--text-dim);
  background: rgba(139, 149, 165, 0.1);
  border: 1px solid rgba(139, 149, 165, 0.2);
}

/* Chips */
.admin-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.admin-chip-provider.openai {
  color: #8ce8b8;
  border-color: rgba(47, 191, 113, 0.28);
  background: rgba(47, 191, 113, 0.08);
}

.admin-chip-provider.maxplus {
  color: var(--gold-bright);
  border-color: rgba(232, 180, 74, 0.35);
  background: rgba(232, 180, 74, 0.08);
}

.admin-chip-provider.custom {
  color: #a8c4f0;
  border-color: rgba(100, 149, 237, 0.28);
  background: rgba(100, 149, 237, 0.08);
}

.admin-model-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 220px;
}

.admin-chip-model {
  color: #c8d4e8;
  border-color: rgba(120, 150, 200, 0.22);
  background: rgba(120, 150, 200, 0.08);
  text-transform: none;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
}

.admin-chip-more {
  color: var(--gold-bright);
  border-color: rgba(232, 180, 74, 0.28);
  background: rgba(232, 180, 74, 0.06);
}

.admin-model-cell {
  min-width: 180px;
}

.admin-meta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.admin-meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Stepper — markup */
.admin-stepper-cell { width: 1%; white-space: nowrap; }

.admin-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid rgba(232, 180, 74, 0.18);
  background: linear-gradient(180deg, rgba(232, 180, 74, 0.07), rgba(232, 180, 74, 0.02));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-stepper.dirty {
  border-color: rgba(232, 180, 74, 0.45);
  box-shadow: 0 0 0 3px rgba(232, 180, 74, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.admin-stepper-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--gold-bright);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}

.admin-stepper-btn:hover {
  background: rgba(232, 180, 74, 0.14);
  transform: scale(1.06);
}

.admin-stepper-btn:active { transform: scale(0.96); }

.admin-stepper-readout {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  min-width: 42px;
  padding: 0 4px;
  font-weight: 800;
  color: var(--gold-bright);
}

.admin-stepper-num { font-size: 14px; letter-spacing: -0.02em; }
.admin-stepper-unit { font-size: 10px; color: var(--text-faint); margin-left: 1px; }

.admin-stepper-commit {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #14100a;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  margin-left: 2px;
  animation: admin-pop 0.25s ease;
  transition: filter 0.15s, transform 0.12s;
}

.admin-stepper-commit:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: scale(1.06);
}

.admin-stepper-commit:disabled { opacity: 0.5; cursor: not-allowed; }

@keyframes admin-pop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Inline edit — credits */
.admin-adjust-cell { width: 1%; white-space: nowrap; }

.admin-inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-inline-field {
  display: flex;
  align-items: center;
  min-width: 108px;
  height: 32px;
  padding: 0 4px 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-inline-field:focus-within {
  border-color: rgba(232, 180, 74, 0.4);
  box-shadow: 0 0 0 3px rgba(232, 180, 74, 0.08);
}

.admin-inline-prefix {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-faint);
  margin-right: 4px;
  flex-shrink: 0;
}

.admin-inline-input {
  width: 72px;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 0;
}

.admin-inline-input:focus { outline: none; }

.admin-inline-input::placeholder {
  color: var(--text-faint);
  font-weight: 600;
}

.admin-inline-go {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #14100a;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.15s, transform 0.12s;
}

.admin-inline-go:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateX(1px);
}

.admin-inline-go:disabled { opacity: 0.5; cursor: not-allowed; }

/* Credits */
.admin-balance {
  font-size: 16px;
  font-weight: 800;
  color: var(--gold-bright);
}

.admin-balance.zero { color: var(--text-dim); }

.admin-pnl {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.admin-pnl.plus { color: #6c6; }
.admin-pnl.minus { color: #e88; }
.admin-pnl.zero { color: var(--text-dim); }

.admin-th-hint {
  font-weight: 600;
  font-size: 9px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-faint);
}

.admin-tx-drawer { margin-top: 4px; }

.admin-tx-table .delta.plus { color: var(--green); font-weight: 800; }
.admin-tx-table .delta.minus { color: #e88; font-weight: 800; }

.admin-tx-kind {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-forbidden {
  text-align: center;
  padding: 48px 20px;
  border: 1px solid rgba(229, 83, 75, 0.25);
  border-radius: 16px;
  background: rgba(229, 83, 75, 0.06);
  color: #f0b4b0;
}

.admin-forbidden h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.admin-forbidden p {
  font-size: 13px;
  color: var(--text-dim);
}

@media (max-width: 900px) {
  .admin-key-form-grid { grid-template-columns: 1fr; }
  .admin-field.span-2 { grid-column: span 1; }
  .admin-key-table th:nth-child(5),
  .admin-key-table td:nth-child(5),
  .admin-key-table th:nth-child(6),
  .admin-key-table td:nth-child(6) { display: none; }
  .admin-credit-table th:nth-child(2),
  .admin-credit-table td:nth-child(2) { display: none; }
}

/* ===== Admin Brain (สมอง) tab ===== */
.admin-brain-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 860px) {
  .admin-brain-grid { grid-template-columns: 1fr; }
}
.admin-brain-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(139, 149, 165, 0.14);
  font-size: 13px;
}
.admin-brain-kv:last-child { border-bottom: none; }
.admin-brain-kv span { color: var(--text-dim); }
.admin-brain-kv b { color: var(--text-bright); font-weight: 600; font-variant-numeric: tabular-nums; }
.admin-brain-err {
  margin: 4px 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(240, 113, 113, 0.08);
  border: 1px solid rgba(240, 113, 113, 0.22);
  color: #f3a6a6;
  font-size: 12px;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  white-space: pre-wrap;
  word-break: break-word;
}
.admin-chip.danger { color: #f3a6a6; background: rgba(240, 113, 113, 0.12); border-color: rgba(240, 113, 113, 0.3); }
.admin-chip.muted { color: var(--text-dim); background: rgba(139, 149, 165, 0.1); border-color: rgba(139, 149, 165, 0.22); }
.admin-chip.gold { color: var(--gold-bright); background: rgba(255, 193, 84, 0.1); border-color: rgba(255, 193, 84, 0.28); }
.admin-cell-nowrap { white-space: nowrap; font-size: 12px; color: var(--text-dim); }
.admin-brain-reason { max-width: 420px; white-space: normal; color: var(--text-dim); font-size: 12px; }
.admin-brain-trace-row {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(139, 149, 165, 0.12);
  font-size: 12px;
}
.admin-brain-trace-row:last-child { border-bottom: none; }
.admin-brain-trace-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.admin-brain-trace-msg { color: var(--text-dim); }
.admin-brain-detail { margin-top: 6px; }
.admin-brain-detail summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 11px;
  user-select: none;
}
.admin-brain-detail pre {
  margin: 6px 0 0;
  padding: 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-bright);
  font-size: 11px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
}
.admin-btn.small { padding: 3px 10px; font-size: 11px; }

/* --- Key Manager: MaxPlus pools / model scan --- */
.km-pool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}
.km-pool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-dim);
  font-size: 12px;
  user-select: none;
}
.km-pool-chip.on {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(212, 175, 55, 0.08);
}
.km-pool-chip input { accent-color: var(--gold); }
.km-row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.km-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.km-badge.ok { color: #8ce8b8; border-color: rgba(47, 191, 113, 0.45); }
.km-badge.bad { color: #f0b4b0; border-color: rgba(229, 83, 75, 0.45); }
.km-badge.warn { color: var(--gold-bright); border-color: rgba(212, 175, 55, 0.45); }
.km-num { font-variant-numeric: tabular-nums; }
.km-muted { color: var(--text-faint); font-size: 12px; }
.km-num-input {
  width: 72px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
}

/* ── Per-customer diagnostics ("ลูกค้า" tab) ────────────────────────────── */
.admin-badge.warn {
  color: var(--gold-bright);
  background: rgba(212, 168, 67, 0.12);
  border: 1px solid rgba(212, 168, 67, 0.3);
}
.admin-badge.fail {
  color: #f0b4b0;
  background: rgba(229, 83, 75, 0.12);
  border: 1px solid rgba(229, 83, 75, 0.32);
}
.admin-sub {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 400;
  margin-left: 6px;
}
.admin-cust-row { cursor: pointer; }
.admin-cust-row:hover { background: rgba(255, 255, 255, 0.03); }
.admin-cust-row.on { background: rgba(212, 168, 67, 0.08); }
.admin-cust-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0 14px;
}
.admin-issue {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-dim);
  margin-right: 4px;
}
.admin-issue.fail { color: #f0b4b0; border-color: rgba(229, 83, 75, 0.4); }
.admin-issue.warn { color: var(--gold-bright); border-color: rgba(212, 175, 55, 0.4); }
.admin-ok-text { color: #8ce8b8; font-size: 12px; }
.admin-check-list { display: flex; flex-direction: column; gap: 8px; }
.admin-check {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.015);
}
.admin-check.ok { border-left-color: rgba(47, 191, 113, 0.6); }
.admin-check.warn { border-left-color: rgba(212, 175, 55, 0.7); }
.admin-check.fail { border-left-color: rgba(229, 83, 75, 0.75); }
.admin-check-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.admin-check-detail {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  margin-top: 5px;
}
.admin-check-fix {
  margin-top: 6px;
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(212, 168, 67, 0.08);
  border: 1px solid rgba(212, 168, 67, 0.22);
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
}
.admin-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px 14px;
}
.admin-kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
  font-size: 12px;
}
.admin-kv .k { color: var(--text-faint); }
.admin-kv .v { color: var(--text); text-align: right; }
.admin-warn-box {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(229, 83, 75, 0.08);
  border: 1px solid rgba(229, 83, 75, 0.28);
  font-size: 12px;
  line-height: 1.7;
}
.admin-warn-box ul { margin: 6px 0 0 16px; }
