:root {
  color: #17201f;
  background: #f4f7f6;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --ink: #17201f;
  --muted: #56615f;
  --line: #d4dddb;
  --soft-line: #e3e9e7;
  --paper: #fff;
  --canvas: #f4f7f6;
  --medical: #087f79;
  --medical-dark: #056c67;
  --medical-soft: #e8f3f1;
  --gold: #9a6612;
  --gold-soft: #fff6df;
  --danger: #a33b2b;
  --danger-soft: #fff1ed;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
a { text-underline-offset: 3px; }

.admin-shell, .access-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}
.access-shell { width: min(900px, calc(100% - 32px)); }
.admin-header, .section-title, .section-row, .auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 44px; line-height: 1.14; letter-spacing: 0; }
h2 { margin-bottom: 6px; font-size: 20px; }
p { color: #56615f; line-height: 1.65; }
.eyebrow { margin-bottom: 8px; color: #087f79; font-size: 12px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
.lead { font-size: 18px; }

.auth-panel, .section-row, section, .notice {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid #d4dddb;
  border-radius: 8px;
  background: #fff;
}
.auth-panel label, form label { display: grid; gap: 6px; color: #45504e; font-size: 13px; font-weight: 600; }
input { min-width: 260px; min-height: 42px; padding: 9px 11px; border: 1px solid #b9c6c3; border-radius: 6px; background: #fff; color: #17201f; }
button { min-height: 42px; padding: 9px 15px; border: 1px solid #087f79; border-radius: 6px; background: #087f79; color: #fff; font-weight: 700; }
button:hover { background: #056c67; }
button:disabled { cursor: not-allowed; opacity: .45; }
.secondary-button, .table-button { background: #fff; color: #17201f; border-color: #bdc9c7; }
.secondary-button:hover, .table-button:hover { background: #edf3f1; }
.table-button { min-height: 34px; padding: 5px 10px; font-size: 13px; }
form { display: flex; align-items: end; gap: 10px; }
output { display: block; margin-top: 14px; color: #8e3a21; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 10px; border-bottom: 1px solid #e3e9e7; text-align: left; white-space: nowrap; }
th { color: #66716f; font-size: 12px; font-weight: 700; }
td { font-size: 14px; }
.status { font-weight: 700; }
.status-online, .status-active, .status-completed { color: #087f79; }
.status-disabled, .status-revoked, .status-failed { color: #a33b2b; }
.status-invited, .status-running { color: #9a6612; }
.message { margin-top: 20px; color: #a33b2b; font-weight: 700; }
.notice strong { color: #8e3a21; }
.notice p { margin: 6px 0 0; }
.text-link { color: #087f79; font-weight: 700; }

.admin-topbar {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.admin-topbar-inner {
  display: flex;
  width: min(1180px, calc(100% - 32px));
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto;
}
.admin-brand {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.admin-guide-link { color: var(--medical); font-size: 13px; font-weight: 700; }
.admin-header { align-items: flex-end; }
.admin-header h1 { margin-bottom: 8px; font-size: 36px; }
.admin-subtitle { max-width: 680px; margin-bottom: 0; }
.admin-header-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.danger-button { color: var(--danger); border-color: #dfb6ad; }
.danger-button:hover { background: var(--danger-soft); }

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .9fr);
  align-items: start;
  gap: 24px 40px;
  padding: 28px;
  border-top: 4px solid var(--medical);
}
.auth-copy p:last-child { max-width: 600px; margin-bottom: 0; }
.credential-form { display: grid; align-items: stretch; gap: 9px; }
.credential-form label, .invite-form label { color: #45504e; font-size: 13px; font-weight: 700; }
.token-input-row, .invite-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.token-input-row input, .invite-input-row input { min-width: 0; width: 100%; }
.token-toggle { min-width: 68px; }
.credential-help {
  grid-column: 1 / -1;
  padding-top: 16px;
  border-top: 1px solid var(--soft-line);
}
.credential-help summary { color: var(--medical-dark); cursor: pointer; font-size: 13px; font-weight: 800; }
.credential-help p { margin: 10px 0 0; font-size: 13px; }

.summary-section {
  margin-top: 32px;
  padding: 0;
  border: 0;
  background: transparent;
}
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.section-heading h2 { margin-bottom: 0; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.metric-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.metric-item strong { color: var(--ink); font-size: 30px; line-height: 1; }
.metric-item span { color: var(--muted); font-size: 13px; }

.invite-section {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(380px, 1.1fr);
  align-items: end;
  gap: 24px 40px;
  border-left: 4px solid var(--medical);
}
.invite-copy p:last-child { margin-bottom: 0; }
.invite-form { display: grid; align-items: stretch; gap: 9px; }
.invite-result-panel {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 18px 20px;
  border-top: 1px solid #bcd8d3;
  background: var(--medical-soft);
}
.result-label { display: block; margin-bottom: 5px; color: var(--medical-dark); font-size: 12px; font-weight: 800; }
.invite-result-panel code { color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 22px; font-weight: 800; }
.invite-result-panel p { margin: 6px 0 0; font-size: 13px; }
.invite-result-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.records-section { padding: 0; overflow: hidden; }
.records-heading { padding: 22px 22px 16px; }
.record-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
  background: var(--canvas);
}
.record-tab {
  min-height: 48px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}
.record-tab:last-child { border-right: 0; }
.record-tab:hover { background: var(--medical-soft); color: var(--medical-dark); }
.record-tab[aria-selected="true"] {
  box-shadow: inset 0 -3px 0 var(--medical);
  background: var(--paper);
  color: var(--ink);
}
.record-tab span {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  margin-left: 5px;
  border-radius: 50%;
  background: #dce5e3;
  color: var(--ink);
  font-size: 11px;
}
.record-panel { padding: 6px 18px 16px; }
.records-section table { table-layout: auto; }
.empty-cell { padding: 34px 10px; color: var(--muted); text-align: center; white-space: normal; }
.table-button-danger { color: var(--danger); border-color: #dfb6ad; }
.table-button-danger:hover { background: var(--danger-soft); }

.admin-message {
  min-height: 24px;
  margin: 18px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.message-success { color: var(--medical-dark); }
.message-error { color: var(--danger); }
.admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.admin-footer a { color: var(--medical); font-weight: 700; }

.access-topbar {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.access-topbar-inner {
  display: flex;
  width: min(900px, calc(100% - 32px));
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto;
}
.access-brand {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.access-mode {
  padding-left: 12px;
  border-left: 3px solid var(--medical);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.access-shell section {
  margin-top: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.access-intro { padding: 38px 0 28px; }
.access-intro .eyebrow { margin-bottom: 10px; }
.access-lead {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}
.access-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 28px 0 0;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  list-style: none;
  overflow: hidden;
}
.access-meta li {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 16px;
  background: var(--paper);
}
.access-meta strong { font-size: 15px; }
.access-meta span { color: var(--muted); font-size: 13px; }

.flow-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-block: 1px solid var(--line);
  background: var(--paper);
}
.flow-summary a {
  display: flex;
  min-width: 0;
  min-height: 58px;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-right: 1px solid var(--soft-line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.flow-summary a:last-child { border-right: 0; }
.flow-summary a:hover { background: var(--medical-soft); }
.flow-summary span {
  display: grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--medical);
  border-radius: 50%;
  color: var(--medical);
  font-size: 12px;
}

.access-shell .prerequisites {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px 32px;
  margin: 30px 0 0;
  padding: 22px 24px;
  border: 1px solid #e8d49c;
  border-radius: 8px;
  background: var(--gold-soft);
}
.section-label, .step-kicker {
  margin: 0 0 7px;
  color: var(--medical);
  font-size: 12px;
  font-weight: 800;
}
.prerequisites h2, .finish-strip h2, .scope-section h2 { margin-bottom: 0; }
.check-list {
  display: grid;
  align-content: start;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.check-list li {
  position: relative;
  padding-left: 25px;
  color: var(--ink);
  font-weight: 700;
}
.check-list li::before {
  position: absolute;
  top: 1px;
  left: 0;
  color: var(--gold);
  content: "✓";
  font-weight: 900;
}
.prerequisite-note {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid #e8d49c;
  color: #715218;
  font-size: 13px;
}

.setup-flow { margin-top: 34px; }
.setup-step {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 22px;
  padding: 32px 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 18px;
}
.setup-step:last-child { border-bottom: 1px solid var(--line); }
.step-number {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 6px;
  background: var(--medical);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.step-content { min-width: 0; }
.step-content h2 { margin-bottom: 10px; font-size: 24px; }
.step-copy { margin-bottom: 18px; }
.plain-list {
  display: grid;
  gap: 9px;
  margin: 14px 0 20px;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.65;
}
.plain-list li::marker { color: var(--medical); font-weight: 800; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; }
.primary-link, .secondary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 1px solid var(--medical);
  border-radius: 6px;
  font-weight: 800;
  text-decoration: none;
}
.primary-link { background: var(--medical); color: #fff; }
.primary-link:hover { background: var(--medical-dark); }
.secondary-link { background: var(--paper); color: var(--medical); }

.command-stack { display: grid; gap: 10px; }
.command-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  border: 1px solid #cbd7d4;
  border-radius: 6px;
  background: var(--paper);
  overflow: hidden;
}
.command-row code {
  min-width: 0;
  padding: 13px 14px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.copy-button {
  min-width: 72px;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-left: 1px solid #cbd7d4;
  border-radius: 0;
  background: var(--medical-soft);
  color: var(--medical-dark);
  font-size: 13px;
}
.copy-button:hover { background: #d8ebe8; }
.success-signal {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--medical);
  background: var(--medical-soft);
  color: #315d59;
  font-size: 13px;
}

.pair-form { display: block; margin-top: 18px; }
.pair-fields {
  display: grid;
  grid-template-columns: 1.15fr 1fr .8fr;
  gap: 12px;
}
.pair-form label {
  display: grid;
  gap: 7px;
  color: #45504e;
  font-size: 13px;
  font-weight: 700;
}
.pair-form input { min-width: 0; width: 100%; }
.generate-button { margin-top: 14px; }
.form-message {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--medical-dark);
  font-size: 13px;
  font-weight: 700;
}
.pair-output { margin-top: 10px; }
.single-command { margin-top: 18px; }

.access-shell .finish-strip {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  align-items: center;
  gap: 28px;
  margin-top: 34px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  background: var(--paper);
}
.finish-strip p:last-child { margin: 0; }
kbd {
  padding: 2px 6px;
  border: 1px solid #b9c6c3;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--canvas);
  font: inherit;
  font-size: 14px;
}

.access-shell .scope-section { margin-top: 42px; }
.scope-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}
.scope-item {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
.scope-item h3 { margin: 0 0 10px; font-size: 16px; }
.scope-item ul { display: grid; gap: 8px; margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.55; }
.scope-allowed { border-top: 4px solid var(--medical); }
.scope-blocked { border-top: 4px solid var(--danger); }
.boundary-note {
  margin: 14px 0 0;
  padding: 11px 12px;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  color: #715218;
  font-size: 13px;
}

.help-panel {
  margin-top: 28px;
  padding: 0;
  border-block: 1px solid var(--line);
  background: var(--paper);
}
.help-panel summary {
  padding: 16px 2px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}
.help-panel dl { margin: 0; padding: 0 2px 18px; }
.help-panel dt { margin-top: 14px; color: var(--ink); font-weight: 800; }
.help-panel dd { margin: 5px 0 0; color: var(--muted); line-height: 1.6; }
.help-panel a { color: var(--medical); }
.access-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 36px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(8, 127, 121, .25);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .admin-shell, .access-shell { padding-top: 28px; }
  .admin-header, .section-row, .auth-panel { align-items: stretch; flex-direction: column; }
  .admin-header .secondary-button { align-self: flex-start; }
  form { align-items: stretch; flex-direction: column; width: 100%; }
  input { min-width: 0; width: 100%; }
  h1 { font-size: 34px; }
  .admin-topbar-inner { min-height: 54px; }
  .admin-header { align-items: flex-start; }
  .admin-header h1 { font-size: 30px; }
  .admin-header-actions { width: 100%; }
  .auth-panel { grid-template-columns: 1fr; gap: 22px; padding: 20px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .invite-section { grid-template-columns: 1fr; gap: 20px; padding: 20px; }
  .invite-result-panel { grid-column: auto; align-items: flex-start; flex-direction: column; }
  .invite-result-actions { width: 100%; justify-content: flex-start; }
  .record-tab { padding-inline: 8px; font-size: 12px; }
  .records-heading { padding: 20px 16px 14px; }
  .record-panel { padding-inline: 10px; }
  .admin-footer { align-items: flex-start; flex-direction: column; }
  .access-topbar-inner { min-height: 54px; }
  .access-shell { padding-top: 0; }
  .access-intro { padding: 30px 0 22px; }
  .access-lead { font-size: 16px; }
  .access-meta { grid-template-columns: 1fr; }
  .access-meta li { padding: 13px 14px; }
  .flow-summary { grid-template-columns: repeat(2, 1fr); }
  .flow-summary a:nth-child(2) { border-right: 0; }
  .flow-summary a:nth-child(-n + 2) { border-bottom: 1px solid var(--soft-line); }
  .access-shell .prerequisites { grid-template-columns: 1fr; gap: 16px; padding: 20px; }
  .prerequisite-note { grid-column: auto; }
  .setup-step { grid-template-columns: 44px minmax(0, 1fr); gap: 14px; padding: 27px 0; }
  .step-number { width: 40px; height: 40px; font-size: 12px; }
  .step-content h2 { font-size: 21px; }
  .pair-fields, .scope-grid, .access-shell .finish-strip { grid-template-columns: 1fr; }
  .command-row { grid-template-columns: minmax(0, 1fr); }
  .copy-button { width: 100%; border-top: 1px solid #cbd7d4; border-left: 0; }
  .access-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 460px) {
  .summary-grid { grid-template-columns: 1fr; }
  .token-input-row, .invite-input-row { grid-template-columns: 1fr; }
  .token-toggle { width: 100%; }
  .invite-result-actions button { width: 100%; }
}
