:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657085;
  --line: #dbe1ea;
  --brand: #1368e8;
  --brand-dark: #0d52ba;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

#status {
  margin-top: 4px;
  color: var(--muted);
}

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

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

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

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  letter-spacing: 0;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.token-form,
.inline-form,
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-form {
  flex-wrap: wrap;
  justify-content: flex-end;
}

input,
select,
button {
  height: 36px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  min-width: 120px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}

.provider-form input[name="base_url"] {
  min-width: 220px;
}

.provider-form input[name="api_key"] {
  min-width: 180px;
}

button {
  padding: 0 14px;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

button.small {
  width: auto;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

button.secondary {
  color: var(--text);
  background: #fff;
  border-color: var(--line);
}

button.secondary:hover {
  background: #eef2f7;
  border-color: #c7d0df;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  color: var(--muted);
  white-space: nowrap;
}

.check input {
  width: 16px;
  min-width: 16px;
  height: 16px;
}

.notice {
  margin: 14px 16px 0;
  padding: 12px;
  overflow-wrap: anywhere;
  color: #064e3b;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
}

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

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

th,
td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  color: var(--text);
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

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

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

@media (max-width: 860px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .token-form,
  .inline-form {
    width: 100%;
  }

  input,
  select,
  button {
    width: 100%;
  }

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

@media (max-width: 520px) {
  .metrics {
    grid-template-columns: 1fr;
  }
}
