@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Manrope:wght@500;600;700&display=swap");

:root {
  --canvas: #ecebe4;
  --surface: #f8f7f1;
  --ink: #111813;
  --muted: #5d675f;
  --line: #aab0aa;
  --green: #174c3c;
  --green-hover: #10382d;
  --table-head: #18221b;
  --row-alt: #f0efe8;
  --error: #8c2727;
  --focus: #2768d7;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Manrope", sans-serif;
}

button,
input,
select { font: inherit; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--ink);
}

.eyebrow,
.field-label {
  display: block;
  color: var(--muted);
  font: 600 11px "IBM Plex Mono", monospace;
  letter-spacing: .09em;
}

h1,
h2,
p { margin: 0; }

h1 {
  margin-top: 9px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: -.045em;
}

.page-header p {
  max-width: 430px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.controls {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1px;
  margin-top: 20px;
  border: 1px solid var(--line);
  background: var(--line);
}

.login-form,
.fetch-panel {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
}

.login-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font: 600 11px "IBM Plex Mono", monospace;
  letter-spacing: .04em;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border: 1px solid #747e76;
  border-radius: 2px;
  color: var(--ink);
  background: #fffef9;
  font-family: "Manrope", sans-serif;
  font-size: 15px;
  text-transform: none;
}

select {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border: 1px solid #747e76;
  border-radius: 2px;
  color: var(--ink);
  background: #fffef9;
}

button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--green);
  border-radius: 2px;
  color: white;
  background: var(--green);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

button:hover:not(:disabled) { background: var(--green-hover); }
button:disabled { opacity: .45; cursor: not-allowed; }

.fetch-panel {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.fetch-panel strong {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.saved-accounts { display: grid; grid-template-columns: minmax(260px,1fr) minmax(250px,.8fr) auto; align-items: end; gap: 12px; margin-top: 12px; padding: 16px 20px; border: 1px solid var(--line); background: var(--surface); }
.saved-accounts strong { display: block; margin-top: 6px; font-size: 13px; }

.message {
  min-height: 22px;
  padding: 12px 2px 0;
  color: var(--muted);
  font: 500 12px "IBM Plex Mono", monospace;
}

.message[data-state="ready"] { color: var(--green); }
.message[data-state="error"] { color: var(--error); }

.output-section {
  margin-top: 26px;
  border: 1px solid var(--ink);
  background: var(--surface);
}

.output-header {
  min-height: 76px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  color: white;
  background: var(--table-head);
  border-bottom: 1px solid var(--ink);
}

.output-header .eyebrow { color: #97a79c; }

h2 {
  margin-top: 4px;
  font-size: 22px;
  letter-spacing: -.02em;
}

#outputMeta {
  color: #aebbb2;
  font: 500 11px "IBM Plex Mono", monospace;
  text-align: right;
}

.endpoint-explorer {
  min-height: 590px;
  display: grid;
  grid-template-columns: minmax(260px, 32%) minmax(0, 1fr);
}

.endpoint-pane {
  min-width: 0;
  max-height: 72vh;
  overflow: auto;
  border-right: 1px solid var(--ink);
  background: #e4e4dc;
}

.pane-heading {
  position: sticky;
  z-index: 3;
  top: 0;
  padding: 14px 15px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: #e4e4dc;
  border-bottom: 1px solid #969e97;
}

.pane-heading strong {
  font: 600 11px "IBM Plex Mono", monospace;
}

.endpoint-group {
  margin: 0;
  padding: 17px 14px 7px;
  color: var(--muted);
  font: 600 10px "IBM Plex Mono", monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.endpoint-item {
  width: 100%;
  min-height: 68px;
  padding: 11px 14px;
  display: block;
  border: 0;
  border-top: 1px solid #c0c4bd;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.endpoint-item:last-child { border-bottom: 1px solid #c0c4bd; }
.endpoint-item:hover { background: #f0f0e9 !important; }
.endpoint-item[aria-pressed="true"] {
  color: white;
  background: var(--green);
  box-shadow: inset 5px 0 0 #d6ed71;
}

.endpoint-item[aria-pressed="true"]:hover { background: var(--green-hover) !important; }

.endpoint-item-line {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.endpoint-item strong {
  min-width: 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.endpoint-item code {
  margin-top: 6px;
  display: block;
  color: #566159;
  font: 10px/1.4 "IBM Plex Mono", monospace;
  overflow-wrap: anywhere;
}

.endpoint-item[aria-pressed="true"] code { color: #c8d6cd; }

.item-status {
  flex: 0 0 auto;
  color: #566159;
  font: 600 8px "IBM Plex Mono", monospace;
  letter-spacing: .05em;
}

.endpoint-item[aria-pressed="true"] .item-status { color: #e6eee8; }

.detail-pane {
  min-width: 0;
  background: var(--surface);
}

.detail-header {
  min-height: 154px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--ink);
}

.detail-badges {
  display: flex;
  gap: 8px;
}

.source-badge,
.response-status {
  padding: 5px 7px;
  border: 1px solid #808981;
  color: var(--muted);
  background: #efeee7;
  font: 600 9px "IBM Plex Mono", monospace;
  letter-spacing: .05em;
}

.response-status[data-state="returned"],
.response-status[data-state="computed"] {
  color: var(--green);
  border-color: var(--green);
  background: #e3eee8;
}

.response-status[data-state="error"],
.response-status[data-state="unavailable"] {
  color: var(--error);
  border-color: var(--error);
  background: #f2e4e1;
}

.detail-header h3 {
  margin: 12px 0 0;
  font-size: 22px;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}

.detail-header code {
  margin-top: 7px;
  display: block;
  color: #2c4738;
  font: 11px/1.45 "IBM Plex Mono", monospace;
  overflow-wrap: anywhere;
}

.detail-header p {
  margin-top: 8px;
  max-width: 760px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.field-table-wrap {
  min-height: 435px;
  max-height: calc(72vh - 154px);
  overflow: auto;
  background: var(--surface);
}

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

thead {
  position: sticky;
  z-index: 2;
  top: 0;
}

th {
  text-align: left;
}

thead th {
  padding: 11px 16px;
  color: #5d6961;
  background: #dedfd8;
  border-bottom: 1px solid #919991;
  font: 600 10px "IBM Plex Mono", monospace;
  letter-spacing: .07em;
  text-transform: uppercase;
}

thead th:nth-child(1) { width: 48%; }
thead th:nth-child(2) { width: 42%; }
thead th:nth-child(3) { width: 10%; }

tbody td {
  padding: 10px 16px;
  vertical-align: top;
  border-bottom: 1px solid #d0d3cc;
}

tbody tr:nth-child(even) td { background: var(--row-alt); }

.field-path,
.field-value,
.field-type {
  font: 12px/1.5 "IBM Plex Mono", monospace;
  overflow-wrap: anywhere;
}

.field-path { color: #253229; }
.field-value { color: #111813; font-weight: 500; }
.field-type { color: #6d776f; text-transform: uppercase; }
.value-null { color: #8a5621; }
.value-boolean { color: #145944; font-weight: 600; }
.value-number { color: #174f78; }

.empty-output {
  padding: 24px 20px;
  color: var(--muted);
  font: 12px "IBM Plex Mono", monospace;
}

@media (max-width: 850px) {
  .page-header { display: block; }
  .page-header p { margin-top: 14px; }
  .controls { grid-template-columns: 1fr; }
  .endpoint-explorer { grid-template-columns: minmax(220px, 38%) minmax(0, 1fr); }
}

@media (max-width: 620px) {
  main { width: min(100% - 24px, 1180px); padding-top: 28px; }
  .login-form { grid-template-columns: 1fr; }
  .fetch-panel { align-items: stretch; flex-direction: column; }
  .output-header { display: block; }
  #outputMeta { display: block; margin-top: 10px; text-align: left; }
  .endpoint-explorer { display: block; }
  .endpoint-pane { max-height: 300px; border-right: 0; border-bottom: 1px solid var(--ink); }
  .detail-header { min-height: 0; }
  .field-table-wrap { min-height: 420px; max-height: 65vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
