:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1e2329;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
}

p,
.label {
  color: var(--muted);
}

.layout {
  width: min(1280px, calc(100vw - 32px));
  margin: 24px auto 40px;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.credit-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
}

.credit-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
}

.credit-card strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  font-weight: 700;
}

.credit-card.primary {
  background: linear-gradient(135deg, #ecfdf5, #f0fdfa);
  border-color: #99f6e4;
}

.credit-card.primary strong {
  font-size: 34px;
  color: var(--accent-strong);
}

.credit-bar {
  margin-top: 12px;
  height: 8px;
  border-radius: 999px;
  background: #d1fae5;
  overflow: hidden;
}

.credit-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.credit-bar span.warn {
  background: var(--warn);
}

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

.credit-card.primary .muted-note {
  display: block;
  margin-top: 6px;
}

.credit-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.credit-cell.ok {
  color: var(--ok);
}

.credit-cell.warn {
  color: var(--warn);
}

.credit-cell.bad {
  color: var(--danger);
}

.endpoints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

code {
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f2f4f7;
}

.form-grid,
.provider-config {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.provider-config {
  grid-template-columns: 150px 1fr 170px 1fr 170px 170px;
  margin-top: 12px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

textarea {
  min-height: 116px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
}

button,
.icon-button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  min-height: 36px;
  padding: 0 12px;
  font: inherit;
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: var(--accent);
}

button.secondary:hover {
  background: #ecfdf3;
}

button:hover,
.icon-button:hover {
  background: var(--accent-strong);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.import-area {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: start;
}

.status-line {
  margin-top: 10px;
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #f8fafc;
}

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

.filter-input {
  width: 220px;
  min-height: 36px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

.pagination button {
  min-height: 32px;
}

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

.pagination .muted-note {
  font-variant-numeric: tabular-nums;
}

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

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef4ff;
  color: #175cd3;
}

.pill.ok {
  background: #ecfdf3;
  color: var(--ok);
}

.pill.bad {
  background: #fef3f2;
  color: var(--danger);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions button {
  min-height: 30px;
  padding: 0 8px;
}

.row-actions .secondary {
  background: #fff;
  color: var(--accent);
}

.row-actions .danger {
  border-color: var(--danger);
  background: var(--danger);
}

pre {
  min-height: 96px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101828;
  color: #e4e7ec;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 6px;
  background: #101828;
  color: white;
  box-shadow: 0 16px 38px rgba(16, 24, 40, 0.22);
}

@media (max-width: 900px) {
  .metrics,
  .form-grid,
  .provider-config,
  .import-area,
  .credit-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 18px 16px;
  }
}
