:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #141a1f;
  --muted: #59636e;
  --subtle: #7a8490;
  --line: #d9dee5;
  --line-strong: #b8c0cc;
  --brand: #00796b;
  --brand-strong: #00594f;
  --blue: #405b9f;
  --danger: #bd2d24;
  --warn: #b66a00;
  --ok: #24924a;
  --focus: 0 0 0 3px rgba(0, 121, 107, .18);
  --shadow: 0 12px 28px rgba(21, 32, 43, .08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Arial, Helvetica, sans-serif;
}

a {
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 12px 24px;
  background: #11181f;
  color: #ffffff;
  border-bottom: 1px solid #26323f;
}

.brandBlock {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.brandMark,
.heroLogo {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e7f6f3;
  color: var(--brand-strong);
  font-weight: 900;
}

.brandMark {
  width: 36px;
  height: 36px;
  font-size: 17px;
}

.heroLogo {
  width: 54px;
  height: 54px;
  margin-bottom: 22px;
  font-size: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.topbar p {
  max-width: 560px;
  margin: 3px 0 0;
  overflow: hidden;
  color: #bdc8d2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topnav,
.actions,
.docLinks,
.deviceActions,
.endpointList,
.unitToolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.authShell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(420px, 520px);
  gap: 24px;
  align-items: stretch;
  width: min(100%, 1060px);
  margin: 30px auto 0;
}

.authHero,
.authCard,
.panel,
.summaryCard,
.stepPanel,
.flowHeader {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(21, 32, 43, .03);
}

.authHero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 560px;
  padding: 28px;
  color: white;
  background:
    linear-gradient(155deg, rgba(17, 24, 31, .96), rgba(0, 89, 79, .94)),
    #11181f;
  border-color: #273641;
  box-shadow: var(--shadow);
}

.authHero h2 {
  margin: 8px 0 24px;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

.authHero .eyebrow {
  color: #b8e7df;
}

.authHero .docLinks a {
  border-color: rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .1);
  color: #f3fffc;
}

.authPoints {
  display: grid;
  gap: 10px;
  margin: auto 0 24px;
}

.authPoints span {
  min-height: 42px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  color: #e6f4f1;
  font-weight: 700;
}

.authCard {
  min-height: 560px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.authHeader,
.authMode,
.workspace,
.view,
.flowColumn,
.sideColumn,
.grid,
.checklist,
.list,
.deviceList {
  display: grid;
  gap: 14px;
}

.formMessage {
  margin: -8px 0 18px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.formMessage.error {
  border-color: #f0b7b2;
  background: #fff2f1;
  color: #8e2018;
}

.formMessage.ok {
  border-color: #bfe4ca;
  background: #eff9f2;
  color: #176c35;
}

.authHeader {
  margin-bottom: 24px;
}

.authHeader h2 {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.15;
}

.authTabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.authTab {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.authTab:hover {
  background: #eef3f2;
  color: var(--ink);
}

.authTab.active {
  border-color: var(--brand);
  background: #ffffff;
  color: var(--brand-strong);
  box-shadow: 0 4px 12px rgba(21, 32, 43, .08);
}

.eyebrow,
.panelHead span,
.summaryCard span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel {
  padding: 18px;
}

.panelHead,
.stepHead,
.flowHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.flowHeader {
  align-items: center;
  padding: 18px;
  border-top: 4px solid var(--brand);
}

.flowHeader h2,
.panel h2,
.panelHead h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.flowHeader .eyebrow,
.authHeader .eyebrow {
  margin: 0;
}

.panel p,
.stepHead p,
.docsIntro p {
  margin: 4px 0 0;
  color: var(--muted);
}

.progressBadge,
.stepState {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stepState.done {
  border-color: #bee7cc;
  background: #edf9f0;
  color: #176c35;
}

.setupBoard {
  display: grid;
  grid-template-columns: minmax(620px, 1.35fr) minmax(340px, .65fr);
  gap: 16px;
  align-items: start;
}

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

.summaryCard {
  display: grid;
  gap: 4px;
  min-height: 104px;
  padding: 16px;
}

.summaryCard strong {
  overflow: hidden;
  font-size: 24px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summaryCard small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stepPanel {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  padding: 16px;
}

.stepNumber {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #e8f7f4;
  color: var(--brand-strong);
  font-size: 17px;
  font-weight: 900;
}

.stepContent {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.stepHead h3 {
  margin: 0;
  font-size: 18px;
}

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

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

label {
  display: grid;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-weight: 400;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--brand);
  box-shadow: var(--focus);
}

button {
  min-height: 40px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 8px 14px;
  background: var(--brand);
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.primaryAction {
  width: 100%;
  min-height: 46px;
}

button.secondary,
.endpoint {
  background: white;
  color: var(--brand);
}

.topbar button {
  min-height: 38px;
}

.topbar button.secondary,
.topbar .navButton {
  border-color: #3a4755;
  background: #18212a;
  color: #edf3f7;
}

.topbar .navButton.active {
  border-color: #bfe9e2;
  background: #e8f7f4;
  color: var(--brand-strong);
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

button.danger:hover {
  background: #941f18;
}

.advanced,
.inlineAdvanced {
  border-top: 1px solid var(--line);
}

.advanced {
  margin-top: 18px;
  padding-top: 16px;
}

.inlineAdvanced {
  padding-top: 10px;
}

.advanced summary,
.inlineAdvanced summary {
  color: var(--brand);
  font-weight: 800;
  cursor: pointer;
}

.advancedBlock {
  margin-top: 12px;
}

.scopes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.scope {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface-2);
  font-weight: 700;
}

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

.secretBox,
.setupQrCard,
.apiBaseBox,
.resultLine,
.row,
.device,
.empty,
.checklist span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.secretBox {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-color: #b7d9d3;
  background: #f0fbf8;
}

.secretBox p {
  margin: 2px 0 0;
  color: var(--muted);
}

.setupQr {
  margin-top: 2px;
}

.setupQrCard {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border-color: var(--line-strong);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.setupQrCard img {
  width: 190px;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
}

.setupQrCard div {
  display: grid;
  gap: 9px;
}

.row,
.device,
.empty,
.checklist span,
.resultLine {
  padding: 12px;
}

.row strong,
.deviceHead strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--muted);
}

.checklist span {
  color: var(--ink);
  font-weight: 700;
}

.checklist span.done {
  border-color: #bee7cc;
  background: #edf9f0;
  color: #176c35;
}

.device {
  border-color: var(--line-strong);
}

.deviceHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 92px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-weight: 800;
}

.status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
}

.status.online::before {
  background: var(--ok);
}

.deviceActions {
  margin-top: 12px;
}

.unitToolbar {
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--muted);
}

.docsGrid {
  display: grid;
  grid-template-columns: minmax(280px, .6fr) minmax(520px, 1.4fr);
  gap: 16px;
}

.docLinks a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.apiBaseBox {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  padding: 12px;
}

.apiBaseBox span {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.apiBaseBox code {
  overflow-wrap: anywhere;
}

.endpoint.active {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.output {
  min-height: 82px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid #202a33;
  border-radius: 8px;
  background: #11181f;
  color: #edf3f7;
  white-space: pre-wrap;
}

.compactOutput {
  max-height: 220px;
}

.codeOutput {
  min-height: 360px;
}

.supportLog {
  margin-top: 16px;
  padding: 0;
}

.supportLog details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.supportLog summary {
  padding: 14px 18px;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

#log {
  max-height: 220px;
  margin: 0 18px 18px;
}

@media (max-width: 1180px) {
  .authShell,
  .setupBoard,
  .docsGrid {
    grid-template-columns: 1fr;
  }

  .authHero,
  .authCard {
    min-height: auto;
  }

  .summaryGrid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

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

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
  }

  .brandBlock {
    min-width: 0;
    width: 100%;
  }

  .topbar p {
    max-width: calc(100vw - 86px);
  }

  .topnav {
    width: 100%;
  }

  .topnav button {
    flex: 1 1 132px;
  }

  main {
    padding: 14px;
  }

  .authHero h2,
  .authHeader h2 {
    font-size: 25px;
  }

  .summaryGrid,
  .two,
  .three,
  .scopes,
  .setupQrCard,
  .stepPanel {
    grid-template-columns: 1fr;
  }

  .stepNumber {
    width: 32px;
    height: 32px;
  }

  .stepHead,
  .panelHead,
  .flowHeader {
    align-items: stretch;
    flex-direction: column;
  }

  .setupQrCard img {
    width: 100%;
    max-width: 260px;
    height: auto;
    aspect-ratio: 1;
  }
}
