:root {
  color-scheme: light;
  --ink: #20292a;
  --muted: #5d626a;
  --line: #cdccd5;
  --paper: #faf9fb;
  --canvas: #f0eff2;
  --wash: #e7e6ec;
  --accent: #20292a;
  --accent-hover: #3b4445;
  --on-accent: #f3f2f6;
  --control-border: #888c94;
  --green: #087a50;
  --red: #b82d3c;
  --focus: #5d626a;
  --shadow: 0 12px 36px rgba(32, 41, 42, 0.07);
  accent-color: var(--accent);
  font-family: Aptos, "Segoe UI Variable", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  background: var(--canvas); color: var(--ink); line-height: 1.5; margin: 0;
  min-width: 320px;
}
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }
.sr-only {
  clip: rect(0, 0, 0, 0); clip-path: inset(50%); height: 1px; overflow: hidden;
  position: absolute; white-space: nowrap; width: 1px;
}
.topbar {
  align-items: center; background: var(--canvas); color: var(--ink); display: flex;
  border-bottom: 1px solid var(--line);
  justify-content: space-between; min-height: 72px; padding: 12px clamp(20px, 4vw, 56px);
}
.brand { align-items: center; display: flex; gap: 12px; }
.brand > span:last-child { display: grid; gap: 2px; }
.brand small { color: var(--muted); }
.topbar-actions { align-items: center; display: flex; gap: 10px; }
.brand-mark {
  align-items: center; background: var(--accent); color: var(--on-accent); border-radius: 8px; display: flex;
  font-weight: 800; height: 42px; justify-content: center; width: 42px;
}
main { margin: 0 auto; max-width: 1280px; padding: clamp(24px, 3vw, 44px); }
h1, h2, h3, p { margin-top: 0; }
h1 {
  font-size: clamp(1.8rem, 3vw, 2.45rem); letter-spacing: -.025em;
  line-height: 1.12; margin-bottom: 10px;
}
#console-heading:focus { outline: 0; }
h2 { font-size: 1.18rem; margin-bottom: 18px; }
h3 { font-size: 1rem; margin: 0; }
.muted, label small, .optional { color: var(--muted); }
.login-shell { display: grid; min-height: calc(100vh - 160px); place-items: center; }
.login-card {
  border: 0; box-shadow: var(--shadow); max-width: 505px;
  padding: clamp(28px, 4vw, 42px); width: 100%;
}
.login-card .muted { margin-bottom: 10px; max-width: 43ch; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: clamp(20px, 2.4vw, 30px);
}
.page-heading, .section-heading, .toolbar {
  align-items: center; display: flex; gap: 12px; justify-content: space-between;
}
.page-heading { margin-bottom: 24px; }
.page-heading .muted { margin-bottom: 0; }
.section-heading.compact { margin: 22px 0 12px; }
.compact-copy { margin: 4px 0 0; }
.session-label {
  background: #e9f6f0; border-radius: 999px; color: var(--green);
  font-size: .8rem; font-weight: 700; padding: 7px 11px;
}
.session-label:empty { display: none; }
form { display: grid; gap: 15px; }
label {
  align-content: start; display: grid; font-size: .875rem; font-weight: 700;
  gap: 7px; grid-auto-rows: max-content;
}
input, select, textarea {
  background: var(--paper); border: 1px solid var(--control-border); border-radius: 7px; color: var(--ink);
  font-size: 1rem; min-height: 42px; padding: 9px 11px; width: 100%;
}
input:not([type="checkbox"]):not([type="radio"]), select { height: 42px; }
label small, .plan-picker > small { font-size: .875rem; font-weight: 400; line-height: 1.4; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(32, 41, 42, .14); outline: 0;
}
.form-grid { display: grid; gap: 14px; }
.business-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.client-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.access-selectors {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.access-selectors select, .access-action .button {
  height: 44px; min-height: 44px;
}
.access-action { align-items: center; display: flex; flex-wrap: wrap; gap: 10px 14px; }
.access-action .compact-copy { flex: 1 1 260px; }
.subtask-disclosure {
  border-top: 1px solid var(--line); margin-top: 24px; padding-top: 20px;
}
.subtask-disclosure summary {
  color: var(--accent-hover); cursor: pointer; font-weight: 700; width: fit-content;
}
.subtask-disclosure[open] summary { margin-bottom: 6px; }
.create-client-form { margin-top: 16px; }
.button {
  border: 1px solid transparent; border-radius: 7px; cursor: pointer;
  font-weight: 700; min-height: 42px; padding: 9px 15px;
}
.button:disabled { cursor: not-allowed; opacity: .56; }
.button[aria-busy="true"] { cursor: progress; opacity: .72; }
.button.primary { background: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { background: var(--paper); border-color: var(--control-border); color: var(--ink); }
.button.secondary:hover { background: var(--wash); border-color: var(--muted); }
.button.secondary:disabled:hover { background: var(--paper); border-color: var(--control-border); }
.button.tertiary {
  background: transparent; border-color: transparent; color: var(--accent-hover);
}
.button.tertiary:hover { background: var(--wash); }
.button:focus-visible {
  box-shadow: 0 0 0 3px var(--focus); outline: 2px solid var(--paper);
  outline-offset: 1px;
}
.topbar .button.secondary { background: transparent; border-color: var(--control-border); color: var(--ink); }
.topbar .button.secondary:hover { background: var(--wash); }
.button.danger { background: #fff1f2; border-color: #f0bdc2; color: var(--red); }
.button.danger:hover { background: #ffe4e7; }
.button.small { min-height: 36px; padding: 6px 11px; }
.button.wide { width: 100%; }
.status { color: var(--muted); margin-bottom: 18px; min-height: 0; }
.status:empty { display: none; }
.status:not(:empty) {
  background: var(--wash); border-radius: 8px; padding: 10px 12px;
}
.status.error { background: #fff0f1; color: var(--red); }
.status.success { background: #e8f6f0; color: var(--green); }
.status.warning { background: #fff8dc; color: #6b5612; }
.local-status { margin: 0; }
.workflow {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  display: grid; gap: 0; margin: 0; overflow: hidden;
}
.workflow-stage {
  border: 0; border-radius: 0; min-width: 0; padding: clamp(24px, 3vw, 36px);
}
.workflow-stage + .workflow-stage { border-top: 1px solid var(--line); }
.stage-heading {
  margin-bottom: 22px;
}
.stage-heading h2 { margin-bottom: 5px; }
.stage-heading .muted { margin-bottom: 0; max-width: 76ch; }
.subtask-form {
  border-top: 1px solid var(--line); margin-top: 26px; padding-top: 24px;
}
.subtask-form > div:first-child { margin-bottom: 14px; }
.contract-preview {
  align-items: center; background: var(--wash); border-radius: 9px; display: flex;
  flex-wrap: wrap; gap: 8px 14px; padding: 12px 14px;
}
.contract-preview span {
  color: var(--muted); font-size: .76rem; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase;
}
.contract-preview code {
  color: var(--ink); font-family: "Cascadia Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}
.reference-grid { display: grid; gap: 22px; }
.reference-grid {
  align-items: start; grid-template-columns: minmax(0, 1fr);
}
.reference-grid > .card { min-width: 0; }
.reference-grid h3 { margin-bottom: 16px; }
.keys-heading {
  align-items: end; display: flex; gap: 16px; justify-content: space-between;
  margin-bottom: 14px;
}
.keys-heading-copy { display: grid; gap: 3px; }
.reference-grid .keys-heading h3 { margin-bottom: 0; }
.keys-summary { color: var(--muted); font-size: .82rem; margin: 0; }
.plan-picker {
  border: 0; margin: 0; min-width: 0; padding: 0;
}
.plan-picker legend {
  font-size: .84rem; font-weight: 700; margin-bottom: 7px; padding: 0;
}
.plan-options {
  border: 1px solid var(--control-border); border-radius: 7px; display: grid;
  max-height: 190px; overflow-y: auto; padding: 4px;
}
.plan-option {
  align-items: center; border-radius: 5px; cursor: pointer; display: flex;
  font-size: .875rem; font-weight: 600; gap: 9px; min-height: 40px; padding: 7px 8px;
}
.plan-option:hover { background: var(--wash); }
.plan-option input { flex: 0 0 auto; margin: 0; min-height: 18px; width: 18px; }
.plan-picker > small { display: block; margin-top: 6px; }
.reference-section { margin-top: 34px; }
.reference-section > .section-heading { margin-bottom: 14px; }
.reference-section h2 { margin-bottom: 5px; }
.reference-section .muted { margin-bottom: 0; }
.function-list { display: grid; gap: 10px; margin-bottom: 16px; }
.function-row {
  align-items: end; border: 1px solid var(--line); border-radius: 9px; display: grid;
  gap: 10px; grid-template-areas:
    "function-id function-description result-type remove"
    "result-value result-value result-value result-value";
  grid-template-columns: .8fr 1.4fr 1fr auto; padding: 12px;
}
.function-id { grid-area: function-id; }
.function-description { grid-area: function-description; }
.result-type { grid-area: result-type; }
.function-result { grid-area: result-value; }
.remove-function {
  align-self: end; grid-area: remove; height: 42px; min-height: 42px;
}
.matrix-editor {
  font-family: "Cascadia Mono", Consolas, monospace; min-height: 138px;
  tab-size: 2; white-space: pre;
}
.table-wrap { max-width: 100%; overflow-x: auto; }
table { border-collapse: collapse; min-width: 720px; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 9px; text-align: left; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
td { font-size: .875rem; }
.editions-table { table-layout: fixed; }
.editions-table th:nth-child(1) { width: 15%; }
.editions-table th:nth-child(2) { width: 14%; }
.editions-table th:nth-child(3) { width: 15%; }
.editions-table th:nth-child(4) { width: 27%; }
.editions-table th:nth-child(5) { width: 11%; }
.editions-table th:nth-child(6) { width: 18%; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; }
.function-contract summary {
  color: var(--accent-hover); cursor: pointer; font-weight: 700; white-space: nowrap;
}
.function-contract[open] summary { margin-bottom: 9px; }
.function-contract-list {
  display: flex; flex-wrap: wrap; gap: 6px; max-width: 76ch;
}
.function-contract-list code {
  background: var(--wash); border-radius: 5px; color: var(--ink);
  font-family: "Cascadia Mono", Consolas, monospace; font-size: .75rem;
  overflow-wrap: anywhere; padding: 3px 6px;
}
.pill {
  background: #e9f6f0; border-radius: 999px; color: var(--green);
  display: inline-block; font-size: .72rem; font-weight: 800; padding: 4px 8px;
}
.pill.off { background: var(--wash); color: var(--muted); }
.pill.warning { background: #fff6d8; color: #725711; }
.status-pills { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; }
.coverage-heading {
  align-items: end; display: flex; gap: 18px; justify-content: space-between;
  margin-bottom: 12px;
}
.coverage-heading h3 { margin: 0; }
.coverage-selector {
  align-items: center; display: flex; flex: 0 1 340px; font-size: .78rem;
  gap: 9px; grid-auto-rows: unset;
}
.coverage-selector select { min-width: 210px; }
.edition-access {
  align-items: center; display: flex; flex-wrap: wrap; gap: 7px; min-width: 0;
}
.edition-access .button {
  flex: 0 1 auto; max-width: 100%; min-width: 0; white-space: normal;
}
.inventory { display: grid; gap: 10px; }
.inventory-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.inventory-item strong { display: block; margin-bottom: 4px; }
.inventory-item small { color: var(--muted); overflow-wrap: anywhere; }
.secret-box {
  background: #fff8dc; border: 1px solid #ead58c; border-radius: 9px;
  display: grid; gap: 10px; margin-top: 18px; padding: 14px;
}
.secret-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.keys-table { table-layout: fixed; }
.keys-table { min-width: 900px; }
.keys-table th:nth-child(1) { width: 19%; }
.keys-table th:nth-child(2) { width: 15%; }
.keys-table th:nth-child(3) { width: 17%; }
.keys-table th:nth-child(4) { width: 14%; }
.keys-table th:nth-child(5) { width: 13%; }
.keys-table th:nth-child(6) { width: 22%; }
.key-client { display: grid; gap: 3px; }
.key-client small { color: var(--muted); overflow-wrap: anywhere; }
.keys-table th:last-child, .key-action-cell { text-align: right; }
.table-actions {
  align-items: center; display: flex; flex-wrap: nowrap; gap: 7px;
  justify-content: flex-end;
}
.icon-button {
  align-items: center; display: inline-flex; flex: 0 0 36px; height: 36px;
  justify-content: center; padding: 0; width: 36px;
}
.icon-button svg {
  fill: none; height: 17px; stroke: currentColor; stroke-linecap: round;
  stroke-linejoin: round; stroke-width: 1.8; width: 17px;
}
.revoked-key-row { color: var(--muted); }
.revoked-key-row .mono { color: var(--muted); }
.key-origin-note { color: var(--muted); display: inline-block; line-height: 1.35; max-width: 18rem; }
.key-dialog {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); color: var(--ink); max-width: 560px; padding: 0;
  width: calc(100% - 32px);
}
.key-dialog::backdrop { background: rgba(32, 41, 42, .52); }
.dialog-content { display: grid; gap: 14px; padding: 24px; }
.dialog-content p { margin: 0; }
.dialog-content textarea { min-height: 92px; overflow-wrap: anywhere; }
@media (max-width: 1200px) {
  .reference-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .business-grid, .client-grid, .reference-grid {
    grid-template-columns: 1fr;
  }
  .function-row {
    grid-template-areas:
      "function-id"
      "function-description"
      "result-type"
      "result-value"
      "remove";
    grid-template-columns: 1fr;
  }
  .remove-function { justify-self: stretch; width: 100%; }
  .page-heading, .section-heading { align-items: flex-start; flex-direction: column; }
  .coverage-heading { align-items: stretch; flex-direction: column; }
  .coverage-selector { align-items: stretch; flex: 0 0 auto; flex-direction: column; }
  .coverage-selector select { min-width: 0; }
  .toolbar {
    align-items: stretch; flex-wrap: wrap; justify-content: flex-start; width: 100%;
  }
}
@media (max-width: 760px) {
  .keys-table { min-width: 0; }
  .keys-table thead {
    clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute;
    white-space: nowrap; width: 1px;
  }
  .keys-table, .keys-table tbody { display: block; width: 100%; }
  .keys-table tbody { display: grid; gap: 10px; }
  .keys-table tr {
    border: 1px solid var(--line); border-radius: 8px; display: grid; padding: 9px;
  }
  .keys-table td {
    border: 0; display: grid; gap: 10px;
    grid-template-columns: minmax(88px, .45fr) minmax(0, 1fr); padding: 6px;
  }
  .keys-table td::before {
    color: var(--muted); content: attr(data-label); font-size: .7rem;
    font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  }
  .keys-table td:empty { display: none; }
  .keys-table td[colspan] { display: block; }
  .keys-table td[colspan]::before { content: none; }
  .keys-table td > .pill, .keys-table .button { justify-self: start; }
  .keys-table .table-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .topbar { min-height: 64px; padding: 10px 16px; }
  .brand-mark { height: 38px; width: 38px; }
  main { padding: 20px 14px 30px; }
  .login-shell { min-height: calc(100vh - 104px); }
  .card { border-radius: 10px; padding: 20px 16px; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .session-label { grid-column: 1 / -1; justify-self: start; }
  .toolbar .button, .secret-actions .button { min-height: 44px; width: 100%; }
  input:not([type="checkbox"]):not([type="radio"]), select { height: 44px; }
  .workflow .button { min-height: 44px; }
  .button.small { min-height: 44px; }
  .icon-button { flex-basis: 44px; height: 44px; width: 44px; }
  .remove-function { height: 44px; }
  th, td { padding: 10px 7px; }
}
