:root {
  --ink: #17202a;
  --muted: #64748b;
  --line: #dbe4e9;
  --soft: #f6faf9;
  --surface: #ffffff;
  --surface-alt: #fbfdfe;
  --brand: #046f6d;
  --brand-dark: #045d5b;
  --focus: #2563eb;
  --danger: #b42318;
  --ok: #027a48;
  --warn: #b54708;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  margin: 0;
  background: #eef3f2;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body,
button,
input,
select,
textarea {
  line-height: 1.45;
}

.shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: clamp(12px, 2vw, 24px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 20px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  padding: 24px;
  box-shadow: var(--shadow);
}

.topbar > * {
  min-width: 0;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 100%;
  font-size: clamp(24px, 1.9vw, 30px);
  line-height: 1.12;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

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

.subtle {
  max-width: 70ch;
  margin: 10px 0 0;
}

a {
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
  border-color: var(--focus);
}

.admin-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.admin-box label {
  grid-column: 1 / -1;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.card label {
  margin-top: 14px;
}

.card h2 + label {
  margin-top: 18px;
}

input,
select,
textarea,
button {
  max-width: 100%;
  border-radius: 6px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 300px;
  margin: 8px 0 12px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 10px 14px;
  text-align: center;
  white-space: nowrap;
}

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

.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.primary:hover {
  background: var(--brand-dark);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 0 16px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  scrollbar-width: thin;
}

.tab {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 15px 12px 13px;
  white-space: nowrap;
}

.tab.active {
  border-bottom-color: var(--brand);
  color: var(--brand);
}

.panel {
  display: none;
  min-width: 0;
  padding-top: 20px;
}

.panel.active {
  display: block;
}

[hidden] {
  display: none !important;
}

.grid {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
}

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

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
}

.card-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.card-title > *,
.item-head > * {
  min-width: 0;
}

.card-title p {
  margin: 8px 0 0;
}

.badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

#tokenStatus {
  min-width: 52px;
  min-height: 30px;
}

.badge.neutral {
  background: #f1f5f9;
  color: #475569;
}

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

.badge.fail {
  background: #fef3f2;
  color: var(--danger);
}

.steps {
  margin: 18px 0;
  border-left: 4px solid var(--brand);
  border-radius: 0 6px 6px 0;
  background: var(--soft);
  padding: 12px 16px;
}

.steps p {
  margin: 8px 0;
  overflow-wrap: anywhere;
}

pre {
  max-width: 100%;
  max-height: 520px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-alt);
  padding: 14px;
  color: #243447;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.command {
  background: #0f172a;
  color: #d1fae5;
}

.list {
  display: grid;
  gap: 10px;
  max-height: 620px;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.list.compact {
  max-height: none;
}

.item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-alt);
  padding: 12px;
  overflow-wrap: anywhere;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.item-title {
  font-weight: 800;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 10px;
  margin: 18px 0;
}

.stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-alt);
  padding: 12px;
}

.stat strong {
  display: block;
  margin-bottom: 8px;
  font-size: 24px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-links {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.doc-link {
  display: grid;
  min-width: 0;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-alt);
  padding: 12px;
  overflow-wrap: anywhere;
}

.doc-link small,
.mini-links a {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.code-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.code-list code,
.chips span {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  padding: 6px 9px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.chips,
.mini-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.api-call ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.api-call li + li {
  margin-top: 6px;
}

.api-call .badge {
  flex: 1 1 auto;
  justify-content: flex-start;
  min-width: min(100%, 180px);
  overflow-wrap: anywhere;
  text-align: left;
  white-space: normal;
}

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

@media (max-width: 780px) {
  .topbar {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .admin-box {
    grid-template-columns: 1fr auto;
  }

  h1 {
    font-size: 24px;
  }

  .card {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 10px;
  }

  .topbar {
    border-radius: 8px;
  }

  .admin-box,
  .tabs {
    grid-template-columns: 1fr;
  }

  .admin-box button,
  .card > button {
    width: 100%;
  }

  .tabs {
    position: static;
    display: grid;
    gap: 6px;
    overflow: visible;
    border-top: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 10px;
    padding: 8px;
  }

  .tab {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    white-space: normal;
  }

  .tab.active {
    border-color: var(--brand);
    border-bottom-color: var(--brand);
    background: var(--soft);
  }

  .panel {
    padding-top: 12px;
  }

  .grid {
    gap: 12px;
    margin-bottom: 12px;
  }

  .card {
    padding: 16px;
  }

  .card-title,
  .item-head {
    flex-direction: column;
    gap: 10px;
  }

  .badge {
    align-self: flex-start;
  }

  textarea {
    min-height: 220px;
  }

  pre {
    max-height: 420px;
    padding: 12px;
  }
}
