:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-soft: #f0f3ef;
  --line: #d9ded8;
  --text: #1f2724;
  --muted: #65716b;
  --accent: #24715e;
  --accent-strong: #185647;
  --warn: #9a6116;
  --danger: #9b2f35;
  --code: #eef2f0;
}

* {
  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;
  line-height: 1.45;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1,
.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 720;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.logout-form {
  margin: 0;
}

.topbar nav a,
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

button:disabled {
  border-color: var(--line);
  background: #dfe4e1;
  color: var(--muted);
  cursor: not-allowed;
}

.topbar nav a,
.button.secondary,
button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  width: min(1500px, calc(100vw - 32px));
  margin: 18px auto 32px;
}

.admin-console {
  width: min(1280px, calc(100vw - 32px));
  margin: 18px auto 32px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

.health-card span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.health-card strong {
  display: block;
  overflow-wrap: anywhere;
}

.health-card.ok {
  border-color: #c8ddd2;
  background: #f5fbf7;
}

.health-card.warn {
  border-color: #e7d7b8;
  background: #fffaf0;
}

.channel-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.channel-picker a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 7px 10px;
  color: var(--text);
  font-weight: 650;
}

.channel-picker a.active {
  border-color: var(--accent);
  background: #e8f4ef;
  color: var(--accent-strong);
}

.console-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.api-panel,
.first-channel-panel {
  min-width: 0;
}

.compact-creds {
  grid-template-columns: 1fr;
}

.shell.single {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}

.sidebar,
.content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

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

.selected-panel {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  letter-spacing: 0;
  text-transform: uppercase;
}

.notice {
  margin-bottom: 16px;
  border: 1px solid #c9dfd2;
  border-radius: 6px;
  background: #eef8f2;
  color: #184b37;
  padding: 10px 12px;
  font-weight: 650;
}

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

.form-grid.compact {
  grid-template-columns: 1fr;
}

.credential-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 10px;
}

.credential-grid span,
label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.wide {
  grid-column: 1 / -1;
}

code {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  border-radius: 5px;
  background: var(--code);
  padding: 7px 8px;
  color: #26312d;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

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

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

form h3 {
  grid-column: 1 / -1;
  margin-top: 8px;
  font-size: 16px;
}

input,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(36, 113, 94, 0.16);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.check span {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

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

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

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

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

tr[aria-current="true"] td {
  background: #eef8f2;
}

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 760;
}

.status.ok {
  background: #e5f4ec;
  color: #1c634a;
}

.status.off {
  background: #f7ebe6;
  color: var(--warn);
}

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

.empty-state h2 {
  color: var(--text);
  margin-bottom: 6px;
}

.setup-panel {
  padding: 24px;
}

.setup-copy {
  margin: 0 0 18px;
  color: var(--muted);
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 20px;
}

.diagnostic-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 10px;
}

.diagnostic-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.diagnostic-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.setup-steps {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.setup-steps h3 {
  margin: 0 0 8px;
}

.setup-steps ol {
  margin: 0;
  padding-left: 20px;
}

.setup-steps li {
  margin: 8px 0;
}

.setup-steps code {
  display: inline;
  padding: 2px 5px;
}

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(36, 113, 94, 0.08), rgba(246, 247, 245, 0) 34%),
    var(--bg);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 28px;
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.login-copy {
  margin: 10px 0 22px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form button {
  min-height: 42px;
}

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

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

  .console-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100vw - 20px, 1500px);
  }

  .admin-console {
    width: min(100vw - 20px, 1280px);
  }

  .health-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 16px;
  }

  .credential-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  table {
    min-width: 0;
    table-layout: fixed;
  }

  th,
  td {
    overflow-wrap: anywhere;
  }

  .diagnostic-grid {
    grid-template-columns: 1fr;
  }
}
