:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dce3ee;
  --text: #182230;
  --muted: #667085;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --green: #0f766e;
  --amber: #b45309;
  --red: #b42318;
  --shadow: 0 12px 35px rgba(24, 34, 48, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  display: grid;
  gap: 18px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin: 0 0 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.nav-item {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 38px;
  padding: 9px 12px;
  font-weight: 700;
}

.primary-btn {
  background: var(--blue);
  color: white;
}

.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.secondary-btn {
  background: var(--blue-soft);
  color: var(--blue);
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.error-line {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: #111827;
  color: #fff;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  min-height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eab308;
  color: #111827;
  font-weight: 900;
}

.brand small {
  display: block;
  color: #cbd5e1;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-item {
  background: transparent;
  color: #cbd5e1;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar p {
  color: var(--muted);
  margin-top: 5px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 18px;
}

.wizard-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.wizard-panel {
  align-content: start;
}

.provider-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.provider-choice {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  align-content: start;
}

.provider-choice input {
  width: auto;
  margin: 0;
}

.provider-choice span {
  font-size: 15px;
  font-weight: 800;
}

.provider-choice small,
.hint-line,
.setup-summary small {
  color: var(--muted);
}

.provider-choice:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.hint-line {
  min-height: 20px;
  font-size: 13px;
  font-weight: 600;
}

.result-panel {
  min-height: 456px;
}

.empty-result {
  min-height: 330px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
}

.failure-result {
  align-content: center;
  gap: 10px;
  border-color: #fecdca;
  background: #fffbfa;
  color: var(--red);
}

.failure-result small {
  max-width: 680px;
  color: var(--red);
  overflow-wrap: anywhere;
}

.copy-list {
  display: grid;
  gap: 10px;
}

.copy-field {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.copy-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.copy-field code {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.5;
}

.copy-btn {
  min-height: 32px;
  padding: 6px 10px;
}

.setup-summary {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  border-left: 3px solid var(--green);
  padding-left: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-height: 92px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  font-size: 27px;
  margin-top: 10px;
}

.panel {
  padding: 16px;
  box-shadow: none;
}

.panel-head {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.form-panel {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.field-with-action .secondary-btn {
  min-width: 82px;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.token-auth-panel {
  display: grid;
  gap: 12px;
}

.auth-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.auth-toolbar small {
  color: var(--muted);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkbox-line input,
.model-check input {
  width: auto;
}

.model-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.model-check {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  color: var(--text);
  cursor: pointer;
  min-height: 86px;
  align-content: start;
}

.model-check span {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.model-check small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.model-check:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.model-check.disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.empty-inline {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 800;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  background: #ecfdf3;
  color: var(--green);
}

.status.off {
  background: #fff7ed;
  color: var(--amber);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.list-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-item small,
.muted {
  color: var(--muted);
}

.compact .list-item {
  font-size: 13px;
}

.json-box,
.secret-box {
  min-height: 110px;
  max-height: 440px;
  overflow: auto;
  background: #101828;
  color: #d1fadf;
  border-radius: 8px;
  padding: 12px;
  margin: 0;
  font-size: 12px;
  white-space: pre-wrap;
}

.tall {
  min-height: 320px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #111827;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 340px;
  font-size: 13px;
}

.toast.error {
  background: var(--red);
}

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

  .sidebar {
    min-height: auto;
  }

  .metric-grid,
  .split,
  .wizard-grid {
    grid-template-columns: 1fr;
  }

  .provider-picker {
    grid-template-columns: 1fr;
  }

  .copy-field {
    grid-template-columns: 1fr;
  }

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

  .auth-toolbar,
  .auth-actions,
  .row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .model-checkbox-grid {
    grid-template-columns: 1fr;
  }

  .field-with-action {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
