:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --accent: #2f6fed;
  --accent-contrast: #ffffff;
  --ok: #1a7f37;
  --ok-bg: #dafbe1;
  --warn: #9a6700;
  --warn-bg: #fff8c5;
  --error: #cf222e;
  --error-bg: #ffebe9;
  --info: #0969da;
  --info-bg: #ddf4ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1f2630;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #4c8dff;
    --ok: #3fb950;
    --ok-bg: #12261e;
    --warn: #d29922;
    --warn-bg: #2b2111;
    --error: #f85149;
    --error-bg: #2d1416;
    --info: #58a6ff;
    --info-bg: #0f2540;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
  margin: 0 0 4px;
}

h2 {
  font-size: 16px;
  margin: 0;
}

p {
  margin: 0;
}

code,
pre,
.mono {
  font-family: var(--mono);
  font-size: 13px;
}

code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.55;
}

pre code {
  background: none;
  padding: 0;
  overflow-wrap: normal;
}

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

.small {
  font-size: 13px;
}

.nowrap {
  white-space: nowrap;
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  gap: 8px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  color: var(--accent);
}

.nav {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
}

.nav a {
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--muted);
  white-space: nowrap;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.session {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

/* Page layout */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  display: grid;
  /* minmax(0, …) stops long code lines from widening the column past the viewport. */
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card.flush {
  padding: 0;
}

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

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.stats {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.stat {
  gap: 2px;
}

.stat-value {
  font-size: 26px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

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

.empty {
  justify-items: center;
  text-align: center;
  padding: 40px 20px;
}

/* Controls */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.button.primary:hover {
  filter: brightness(1.08);
}

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

.button.danger:hover {
  background: var(--error-bg);
}

.button.ghost {
  background: transparent;
  border-color: transparent;
}

.button.ghost:hover {
  background: var(--surface-2);
}

.button.small {
  padding: 4px 10px;
  font-size: 13px;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

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

input,
select {
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input:focus-visible,
select:focus-visible,
.button:focus-visible,
.nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.toolbar .grow {
  flex: 1;
  min-width: 200px;
}

form.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

/* Status */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.error {
  background: var(--error-bg);
  color: var(--error);
}

.notice {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--info-bg);
  color: var(--info);
  overflow-wrap: anywhere;
}

.notice.success {
  background: var(--ok-bg);
  color: var(--ok);
}

.notice.error {
  background: var(--error-bg);
  color: var(--error);
}

.new-key {
  display: grid;
  gap: 10px;
}

/* Tables */

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.table th,
.table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.table tbody tr:hover td {
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.table .num {
  text-align: right;
}

.money.negative {
  color: var(--error);
}

.money.positive {
  color: var(--ok);
}

.method {
  display: inline-block;
  min-width: 56px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.method.get {
  color: var(--info);
}

.method.post {
  color: var(--ok);
}

.method.delete {
  color: var(--error);
}

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

/* Connections */

.connection-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.connection-title {
  flex: 1;
  min-width: 0;
}

.connection-title p {
  margin-top: 2px;
}

.logo {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.logo.placeholder {
  display: inline-grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 0;
}

.meta dt,
.facts dt {
  font-size: 12px;
  color: var(--muted);
}

.meta dd,
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 13px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.actions form {
  margin: 0;
}

/* Connect */

.bank-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bank-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.bank-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Developers */

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  margin-bottom: -1px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.snippet {
  position: relative;
}

.snippet > .button {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--surface);
}

.response {
  max-height: 420px;
}

.response-meta {
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 13px;
}

.checks {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 13px;
}

.checks li {
  display: flex;
  gap: 10px;
}

.check-ok {
  color: var(--ok);
}

.check-fail {
  color: var(--error);
}

/* Login */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.auth-card {
  width: min(380px, 100%);
}

.auth-card h1 {
  font-size: 20px;
}

.hint {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1100px) {
  .session .muted {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 16px;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
  }

  .page {
    padding: 20px 16px 48px;
  }

  .stats {
    gap: 8px;
  }

  .stat {
    padding: 12px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 12px;
  }

  .bank-list {
    grid-template-columns: 1fr;
  }
}
