:root {
  color-scheme: light;
  --ink: #16242a;
  --muted: #5d6f78;
  --line: #d7e0e5;
  --panel: #ffffff;
  --surface: #f6f8fa;
  --surface-strong: #eaf0f2;
  --brand: #0f6f7b;
  --brand-dark: #0a4f59;
  --accent: #a96817;
  --ok: #18764f;
  --ok-bg: #e9f7f0;
  --warn: #b85b16;
  --warn-bg: #fff4e5;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 16px 42px rgba(28, 48, 56, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #ffffff 0, var(--surface) 320px),
    var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.auth-screen {
  align-items: center;
  background: var(--surface);
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 520px;
  padding: 28px;
  width: 100%;
}

.auth-logo {
  display: block;
  height: auto;
  margin-bottom: 6px;
  max-width: 360px;
  width: 100%;
}

.auth-card h1 {
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1.15;
  margin: 0 0 8px;
}

.auth-card label {
  margin-bottom: 0;
}

.auth-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.auth-row button {
  width: auto;
}

.auth-message {
  color: var(--danger);
  font-size: 0.92rem;
  min-height: 18px;
}

.app-shell {
  margin: 0 auto;
  max-width: 1240px;
  padding: 24px;
  width: 100%;
}

.topbar {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  margin-bottom: 34px;
}

.brand-mark {
  align-items: center;
  display: inline-flex;
  gap: 12px;
  min-width: 0;
}

.brand-symbol {
  background: var(--brand);
  border-radius: 8px;
  color: #ffffff;
  display: grid;
  flex: 0 0 auto;
  font-weight: 900;
  height: 40px;
  place-items: center;
  width: 40px;
}

.brand-mark strong,
.brand-mark small {
  display: block;
}

.brand-mark strong {
  font-size: 1rem;
}

.brand-mark small {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.nav-links {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
}

.nav-links a {
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  min-width: 92px;
  padding: 10px 14px;
  text-align: center;
}

.nav-links a.is-active {
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(28, 48, 56, 0.08);
  color: var(--brand-dark);
}

.page-view {
  display: grid;
  gap: 22px;
}

.page-heading {
  align-items: end;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 0 4px;
}

.page-heading-compact {
  align-items: center;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 2.75rem;
  line-height: 1.05;
  margin-bottom: 12px;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.25;
  margin-bottom: 8px;
}

.lede {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  margin-bottom: 0;
  max-width: 720px;
}

.status-panel {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(28, 48, 56, 0.08);
  color: var(--ink);
  display: inline-flex;
  font-weight: 850;
  gap: 10px;
  min-width: 230px;
  padding: 12px 14px;
}

.status-dot {
  background: var(--warn);
  border-radius: 50%;
  flex: 0 0 auto;
  height: 10px;
  width: 10px;
}

.status-dot.is-ok {
  background: var(--ok);
}

.metric-grid,
.connection-grid,
.log-summary {
  display: grid;
  gap: 14px;
}

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

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

.log-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.connection-card,
.log-summary article,
.tool-card,
.response-panel,
.logs-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card,
.log-summary article {
  padding: 18px;
}

.metric-label,
.log-summary span {
  color: var(--muted);
  display: block;
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.metric-card strong,
.log-summary strong {
  display: block;
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 10px;
}

.metric-card small {
  color: var(--muted);
  display: block;
  line-height: 1.35;
}

.metric-card.is-alert strong {
  color: var(--danger);
}

.connection-card {
  display: grid;
  gap: 22px;
  min-height: 260px;
  padding: 22px;
}

.connection-card p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0;
}

.connection-meta {
  align-self: end;
  display: grid;
  gap: 10px;
}

.connection-meta code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--brand-dark);
  display: block;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
  padding: 10px;
}

.health-badge,
.status-badge {
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 850;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  width: fit-content;
}

.connection-card.is-ready .health-badge,
.status-badge.is-success {
  background: var(--ok-bg);
  border-color: #bce4ce;
  color: var(--ok);
}

.connection-card.is-warning .health-badge,
.status-badge.is-warning {
  background: var(--warn-bg);
  border-color: #f3c685;
  color: var(--warn);
}

.connection-card.is-error .health-badge,
.status-badge.is-error {
  background: var(--danger-bg);
  border-color: #ffc5c0;
  color: var(--danger);
}

.config-copy {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.secondary-button,
.ghost-button,
button {
  align-items: center;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 850;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
}

button {
  background: var(--brand);
  border: 0;
  color: #ffffff;
  width: 100%;
}

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

.button-row {
  display: flex;
  gap: 10px;
}

.button-row button {
  flex: 1;
}

.secondary-button {
  background: var(--brand);
  border: 0;
  color: #ffffff;
  min-width: 140px;
  width: auto;
}

.ghost-button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--brand-dark);
  min-width: 98px;
  width: auto;
}

.logs-shell {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

td {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.4;
}

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

.log-row.is-warning td:first-child {
  box-shadow: inset 4px 0 0 var(--warn);
}

.log-row.is-error td:first-child {
  box-shadow: inset 4px 0 0 var(--danger);
}

.empty-state {
  color: var(--muted);
  padding: 32px 16px;
  text-align: center;
}

.route-cell {
  color: var(--muted);
  display: block;
  font-size: 0.8rem;
  margin-top: 4px;
}

.portal-grid {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
}

.tools-panel {
  display: grid;
  gap: 18px;
}

.tool-card,
.response-panel {
  padding: 22px;
}

.response-panel {
  position: sticky;
  top: 18px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading .eyebrow {
  color: var(--accent);
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.92rem;
  font-weight: 750;
  gap: 7px;
  margin-bottom: 14px;
}

fieldset {
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 0 0 14px;
  padding: 0;
}

legend {
  color: var(--muted);
  flex: 0 0 100%;
  font-size: 0.92rem;
  font-weight: 750;
  margin-bottom: 2px;
}

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

.option-inline input {
  min-height: 0;
  width: auto;
}

input,
select,
textarea {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

textarea {
  min-height: 96px;
  padding: 11px 12px;
  resize: vertical;
}

pre {
  background: #102f35;
  border-radius: 8px;
  color: #d9f2ed;
  line-height: 1.5;
  margin: 0;
  min-height: 340px;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 980px) {
  .topbar,
  .page-heading,
  .metric-grid,
  .connection-grid,
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    justify-content: stretch;
    width: 100%;
  }

  .nav-links a {
    flex: 1;
    min-width: 0;
  }

  .status-panel,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

  .response-panel {
    position: static;
  }
}

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

  .auth-row,
  .log-summary {
    grid-template-columns: 1fr;
  }

  .button-row {
    flex-direction: column;
  }

  .auth-row button {
    width: 100%;
  }

  .topbar {
    margin-bottom: 24px;
  }

  h1 {
    font-size: 2rem;
  }

  .connection-card {
    min-height: auto;
  }
}
