:root {
  color-scheme: light;
  --bg: #f7f6f0;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #17201d;
  --muted: #66716b;
  --line: #d9d6ca;
  --teal: #0f766e;
  --teal-2: #2fa58d;
  --amber: #d97706;
  --rose: #be3455;
  --shadow: 0 16px 40px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: #26322e;
}

button.secondary {
  background: #edf7f3;
  color: #075e58;
  border: 1px solid #c7e8df;
}

button.secondary:hover {
  background: #dff1ec;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 5px;
  font-size: 12px;
  background: #edf7f3;
  color: #075e58;
  border: 1px solid #c7e8df;
}

.small-button:hover {
  background: #dff1ec;
}

.danger-button {
  background: #fff1f2;
  color: #9f1239;
  border-color: #fecdd3;
}

.danger-button:hover {
  background: #ffe4e6;
}

.icon-button {
  width: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

textarea {
  min-height: 360px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

label {
  display: block;
  margin: 14px 0 7px;
  color: #34413b;
  font-size: 13px;
  font-weight: 750;
}

a {
  color: var(--teal);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #10201e;
  color: #eef7f3;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  font-size: 20px;
  font-weight: 850;
}

.brand img {
  width: 42px;
  height: 42px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: #c7d7d1;
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 700;
  text-align: left;
}

.nav button:hover,
.nav button.active,
.nav button[aria-selected="true"] {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.account-rail {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.account-rail span {
  color: #bdd0c9;
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 48px) 52px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.02;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.band {
  margin: 18px 0;
}

.tab-panels {
  min-width: 0;
}

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

.tab-panel[hidden] {
  display: none !important;
}

.auth-band {
  background: #fff8e7;
  border: 1px solid #ead9ad;
  border-radius: 8px;
  padding: 16px;
}

.auth-form {
  max-width: 640px;
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  min-height: 132px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.meter {
  height: 8px;
  overflow: hidden;
  background: #eee7d9;
  border-radius: 99px;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.split,
.publish-layout,
.infra {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

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

.panel h2 {
  margin: 0;
  font-size: 20px;
}

.token-once {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  background: #f0fbf7;
  border: 1px solid #bce4d9;
  border-radius: 6px;
}

.token-once-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.token-once-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.token-once-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.token-value {
  min-height: 84px;
  resize: none;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
  white-space: pre-wrap;
}

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

code {
  overflow-wrap: anywhere;
}

.list {
  display: grid;
  gap: 8px;
}

.list.empty {
  color: var(--muted);
  font-size: 14px;
}

.token-row,
.endpoint,
.policy-item {
  border: 1px solid #e6e0d2;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fffefa;
}

.token-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.token-row span,
.endpoint span {
  color: var(--muted);
  font-size: 12px;
}

.token-meta,
.token-actions,
.site-token-list {
  display: grid;
  gap: 5px;
}

.token-actions {
  justify-items: end;
}

.site-create-form {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 4px 0 18px;
}

.site-create-form label {
  margin-top: 0;
}

.site-token {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 260px;
}

.site-access {
  display: grid;
  gap: 8px;
  min-width: 210px;
}

.site-access-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.site-access-form input {
  min-height: 30px;
  padding: 6px 8px;
  font-size: 12px;
}

.site-access-form .small-button {
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid #d8e1dc;
  background: #fffefa;
}

.status-pill.public {
  color: #0f5f58;
  background: #edf7f3;
  border-color: #c7e8df;
}

.status-pill.protected {
  color: #8a4b05;
  background: #fff8e7;
  border-color: #ead9ad;
}

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

.policy-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.policy-item b {
  display: block;
  margin-bottom: 4px;
}

.publish-form .result {
  margin-top: 14px;
}

.result {
  min-height: 24px;
  color: var(--muted);
}

.result.ok {
  color: #0f766e;
}

.result.error {
  color: var(--rose);
}

.console-panel pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #18231f;
  color: #f7f3e8;
  border-radius: 8px;
  padding: 16px;
  min-height: 360px;
}

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

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

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #e7e0d4;
  vertical-align: middle;
}

th {
  color: #53615b;
  font-size: 12px;
  text-transform: uppercase;
}

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

.endpoint b {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.check-list {
  margin: 14px 0 0;
  padding-left: 18px;
  color: #37443e;
}

.check-list li {
  margin: 8px 0;
}

.flow {
  min-height: 280px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: center;
  background:
    linear-gradient(135deg, rgba(15,118,110,.08), transparent 36%),
    linear-gradient(315deg, rgba(217,119,6,.12), transparent 42%),
    var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.flow span,
.flow b {
  display: grid;
  place-items: center;
  min-height: 54px;
  border-radius: 6px;
  border: 1px solid #d8e1dc;
  background: rgba(255,255,255,.8);
  text-align: center;
}

.flow b {
  color: #0f5f58;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  background: #17201d;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0,0,0,.24);
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: relative;
    height: auto;
    padding: 16px;
  }

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

  .nav button {
    text-align: center;
  }

  .account-rail {
    margin-top: 0;
  }

  .metrics-grid,
  .split,
  .publish-layout,
  .infra,
  .endpoint-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .main {
    padding: 20px 14px 42px;
  }

  .topbar,
  .panel-head,
  .inline-form,
  .site-create-form,
  .site-access-form,
  .token-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metrics-grid,
  .split,
  .publish-layout,
  .infra,
  .endpoint-grid,
  .policy-list,
  .nav {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 30px;
  }
}
