:root {
  --ink: #171916;
  --muted: #6f736b;
  --paper: #f2f0e9;
  --panel: #e7e4dc;
  --line: #cbc8bf;
  --accent: #6ff59d;
  --accent-dark: #163e25;
  --danger: #b33a2f;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(44, 151, 81, 0.32);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

[hidden] {
  display: none !important;
}

.topbar {
  align-items: center;
  background: rgba(242, 240, 233, 0.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 74px;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  position: sticky;
  top: 0;
  backdrop-filter: blur(14px);
  z-index: 20;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 700;
  gap: 12px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  align-items: flex-end;
  display: flex;
  gap: 3px;
  height: 20px;
  width: 23px;
}

.brand-mark i {
  background: var(--ink);
  border-radius: 2px;
  display: block;
  height: 100%;
  width: 5px;
}

.brand-mark i:nth-child(1) {
  height: 48%;
}

.brand-mark i:nth-child(2) {
  height: 74%;
}

.topbar-actions,
.connection-button {
  align-items: center;
  display: flex;
}

.topbar-actions {
  gap: 10px;
}

.api-docs-link {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 9px 10px;
  text-decoration: none;
  text-transform: uppercase;
}

.api-docs-link:hover {
  color: var(--ink);
}

.connection-button,
.icon-button {
  background: transparent;
  border: 0;
  cursor: pointer;
}

.connection-button {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  gap: 8px;
  padding: 10px 12px;
}

.connection-button:hover,
.icon-button:hover {
  background: rgba(23, 25, 22, 0.06);
}

.connection-dot,
.health::before,
.interlock-dot {
  background: #a8aaa4;
  border-radius: 50%;
  display: block;
  height: 8px;
  width: 8px;
}

body[data-connected="true"] .connection-dot,
.health[data-online="true"]::before,
.interlock[data-armed="true"] .interlock-dot {
  background: #2ea858;
  box-shadow: 0 0 0 4px rgba(46, 168, 88, 0.12);
}

.icon-button {
  align-items: center;
  border-radius: 50%;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.icon-button svg {
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 19px;
}

.icon-button.is-spinning svg {
  animation: spin 0.7s linear infinite;
}

main {
  min-height: calc(100vh - 74px);
}

.setup-panel {
  background: var(--ink);
  color: var(--paper);
  display: grid;
  gap: clamp(40px, 7vw, 120px);
  grid-template-columns: minmax(0, 0.9fr) minmax(340px, 1.1fr);
  padding: clamp(54px, 8vw, 108px) clamp(20px, 8vw, 128px);
}

.setup-copy h1,
.workspace-heading h1,
.activity-heading h2,
.machine h2 {
  letter-spacing: -0.055em;
  line-height: 0.95;
  margin: 0;
}

.setup-copy h1 {
  font-size: clamp(2.7rem, 5vw, 5.5rem);
  max-width: 7ch;
}

#setup-description {
  color: #afb3aa;
  margin: 26px 0 0;
  max-width: 52ch;
}

.mode-switch {
  background: #242723;
  border: 1px solid #393d38;
  border-radius: 14px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 34px;
  max-width: 430px;
  padding: 4px;
}

.mode-switch button {
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: #a9ada5;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  text-align: left;
}

.mode-switch button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
}

.mode-switch span {
  font-size: 0.78rem;
  font-weight: 800;
}

.mode-switch small {
  font-size: 0.65rem;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  margin: 0 0 18px;
  text-transform: uppercase;
}

.setup-panel .eyebrow {
  color: var(--accent);
}

.auth-surface,
.token-form,
.device-form {
  align-self: center;
}

.auth-surface {
  min-width: 0;
}

.auth-flow h2 {
  font-size: clamp(2rem, 3vw, 3.6rem);
  letter-spacing: -0.045em;
  line-height: 1;
  margin: 7px 0 24px;
}

.auth-kicker {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin: 0;
  text-transform: uppercase;
}

.setup-steps {
  border-top: 1px solid #3b3f3a;
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
}

.setup-steps li {
  align-items: baseline;
  border-bottom: 1px solid #3b3f3a;
  display: grid;
  gap: 16px;
  grid-template-columns: 30px 1fr;
  padding: 12px 0;
}

.setup-steps li > span {
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 850;
}

.setup-steps p,
.auth-summary,
.oauth-missing p {
  color: #afb3aa;
  font-size: 0.78rem;
  margin: 0;
}

.auth-summary {
  line-height: 1.7;
  max-width: 62ch;
}

.oauth-details {
  border-bottom: 1px solid #3b3f3a;
  border-top: 1px solid #3b3f3a;
  margin: 26px 0;
}

.oauth-details > div {
  display: grid;
  gap: 18px;
  grid-template-columns: 90px minmax(0, 1fr);
  padding: 13px 0;
}

.oauth-details > div + div {
  border-top: 1px solid #3b3f3a;
}

.oauth-details dt {
  color: #888d84;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.oauth-details dd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.callback-value {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-width: 0;
}

.callback-value code {
  overflow-wrap: anywhere;
}

.callback-value button {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 4px;
}

.oauth-registration {
  border-top: 1px solid #3b3f3a;
  margin-bottom: 24px;
  padding-top: 22px;
}

.oauth-registration h3 {
  font-size: 1.15rem;
  letter-spacing: -0.025em;
  margin: 5px 0 8px;
}

.oauth-registration > p:not(.registration-number) {
  color: #afb3aa;
  font-size: 0.76rem;
  margin: 0 0 20px;
  max-width: 58ch;
}

.registration-number {
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  margin: 0;
  text-transform: uppercase;
}

.oauth-config-form {
  display: grid;
  gap: 9px;
}

.oauth-config-form label {
  font-size: 0.72rem;
  font-weight: 750;
}

.oauth-config-form input {
  background: #262925;
  border: 1px solid #424640;
  border-radius: 10px;
  color: white;
  min-height: 50px;
  padding: 0 14px;
  width: 100%;
}

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

.credential-fields > div {
  display: grid;
  gap: 9px;
}

.oauth-config-form .primary-button {
  justify-self: start;
  margin-top: 10px;
}

.field-help {
  color: #8e9389;
  font-size: 0.68rem;
}

.field-help[data-warning="true"] {
  color: #e5ba6d;
}

.oauth-configured {
  align-items: center;
  border-bottom: 1px solid #3b3f3a;
  border-top: 1px solid #3b3f3a;
  display: grid;
  gap: 12px;
  grid-template-columns: auto 1fr auto;
  margin-bottom: 24px;
  padding: 15px 0;
}

.oauth-configured > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.oauth-configured strong {
  font-size: 0.76rem;
}

.oauth-configured span:last-child {
  color: #8e9389;
  font-size: 0.67rem;
}

.oauth-missing {
  background: #252824;
  border-left: 3px solid #e5a846;
  border-radius: 0 10px 10px 0;
  margin-bottom: 20px;
  padding: 15px 17px;
}

.oauth-missing strong {
  display: block;
  font-size: 0.78rem;
  margin-bottom: 5px;
}

.oauth-missing > code {
  color: #f1c87c;
  display: block;
  font-size: 0.68rem;
  margin-top: 11px;
  white-space: pre-line;
}

.oauth-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.oauth-connect {
  align-items: center;
  display: inline-flex;
  text-decoration: none;
}

.secondary-link {
  color: var(--paper);
  font-size: 0.72rem;
  font-weight: 750;
  text-underline-offset: 4px;
}

.secondary-button {
  background: transparent;
  border: 1px solid #52564f;
  border-radius: 10px;
  color: var(--paper);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 750;
  min-height: 52px;
  padding: 0 18px;
}

.secondary-button:hover:not(:disabled) {
  border-color: #858a81;
}

.token-form label,
.device-form label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 9px;
}

.token-entry {
  display: flex;
  gap: 10px;
}

.token-entry input,
.device-form select {
  background: #262925;
  border: 1px solid #424640;
  border-radius: 10px;
  color: white;
  min-height: 52px;
  padding: 0 16px;
  width: 100%;
}

.token-entry input::placeholder {
  color: #8e9389;
}

.primary-button,
.start-button {
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  color: #102417;
  cursor: pointer;
  font-weight: 800;
  min-height: 52px;
  padding: 0 22px;
  transition: background 150ms ease, transform 150ms ease;
  white-space: nowrap;
}

.primary-button:hover,
.start-button:hover:not(:disabled) {
  background: #89ffaf;
  transform: translateY(-1px);
}

.field-note {
  align-items: center;
  color: #8e9389;
  display: flex;
  font-size: 0.72rem;
  justify-content: space-between;
  margin: 13px 0 0;
}

.field-note a,
.activity-heading a {
  color: inherit;
  font-weight: 700;
  text-underline-offset: 4px;
}

.field-note a {
  color: var(--paper);
}

.device-form {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr auto;
  margin-top: 28px;
}

.device-form .primary-button {
  align-self: end;
}

.workspace {
  padding: clamp(46px, 7vw, 94px) clamp(20px, 5vw, 76px) clamp(60px, 8vw, 110px);
}

.workspace-heading,
.activity-heading {
  align-items: flex-end;
  display: flex;
  justify-content: space-between;
}

.workspace-heading {
  margin-bottom: clamp(50px, 7vw, 92px);
}

.workspace-heading h1 {
  font-size: clamp(3rem, 7vw, 7.6rem);
}

.freshness {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  font-size: 0.74rem;
  gap: 5px;
  padding-bottom: 6px;
}

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

.freshness time {
  font-weight: 750;
}

.machines {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.machine {
  min-width: 0;
  padding: clamp(36px, 4vw, 62px);
}

.machine + .machine {
  border-left: 1px solid var(--line);
}

.machine-heading {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
}

.machine-number,
.model {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  margin: 0;
  text-transform: uppercase;
}

.machine h2 {
  font-size: clamp(2.3rem, 4vw, 4.8rem);
  margin: 12px 0 10px;
}

.health {
  align-items: center;
  display: flex;
  font-size: 0.7rem;
  font-weight: 750;
  gap: 8px;
  text-transform: uppercase;
}

.health::before {
  content: "";
}

.dial-wrap {
  margin: clamp(42px, 6vw, 82px) auto;
  max-width: 340px;
  position: relative;
}

.dial {
  display: block;
  transform: rotate(-90deg);
  width: 100%;
}

.dial circle {
  fill: none;
  stroke-width: 2.5;
}

.dial-track {
  stroke: var(--line);
}

.dial-progress {
  stroke: var(--ink);
  stroke-dasharray: 616;
  stroke-dashoffset: 616;
  stroke-linecap: round;
  transition: stroke-dashoffset 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.machine[data-state="run"] .dial-progress {
  stroke: #289b50;
  animation: breathe 2.4s ease-in-out infinite;
}

.dial-content {
  align-items: center;
  display: flex;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  padding-top: 4px;
  position: absolute;
  text-align: center;
}

.dial-content .machine-state {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.dial-content strong {
  font-size: clamp(1.7rem, 3vw, 3.2rem);
  letter-spacing: -0.045em;
  line-height: 1;
  margin: 12px 0;
  max-width: 8ch;
}

.dial-content span:last-child {
  color: var(--muted);
  font-size: 0.76rem;
}

.interlock {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 13px;
  min-height: 82px;
  padding: 19px 2px;
}

.interlock-dot {
  flex: 0 0 auto;
  margin-top: 5px;
}

.interlock div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.interlock strong {
  font-size: 0.78rem;
}

.interlock span:last-child {
  color: var(--muted);
  font-size: 0.7rem;
}

.machine-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(130px, 1fr) auto auto;
  margin-top: 20px;
}

.start-button {
  width: 100%;
}

.text-button {
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 750;
  min-height: 52px;
  padding: 0 16px;
}

.text-button:hover:not(:disabled) {
  background: rgba(23, 25, 22, 0.06);
}

.stop-button[data-confirm="true"] {
  background: var(--danger);
  color: white;
}

.activity-section {
  background: var(--panel);
  padding: clamp(48px, 7vw, 92px) clamp(20px, 8vw, 128px);
}

.activity-heading {
  border-bottom: 1px solid #bebbb3;
  padding-bottom: 22px;
}

.activity-heading h2 {
  font-size: clamp(2rem, 4vw, 4rem);
}

.activity-heading a {
  color: var(--ink);
  font-size: 0.76rem;
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list li {
  align-items: center;
  border-bottom: 1px solid #cbc8c0;
  display: grid;
  font-size: 0.78rem;
  gap: 20px;
  grid-template-columns: 120px 1fr auto;
  min-height: 58px;
}

.activity-list time,
.activity-type {
  color: var(--muted);
  font-size: 0.68rem;
}

.activity-type {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.empty-activity {
  color: var(--muted);
  grid-template-columns: 1fr !important;
}

.toast {
  background: var(--ink);
  border-radius: 10px;
  bottom: 24px;
  color: white;
  font-size: 0.8rem;
  font-weight: 650;
  left: 50%;
  max-width: min(480px, calc(100vw - 32px));
  padding: 13px 18px;
  position: fixed;
  transform: translate(-50%, 18px);
  z-index: 50;
}

.toast:not([hidden]) {
  animation: toast-in 180ms ease forwards;
}

.toast[data-error="true"] {
  background: #852b23;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes breathe {
  50% { opacity: 0.52; }
}

@keyframes toast-in {
  to { transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1180px) {
  .setup-panel {
    gap: 46px;
    grid-template-columns: minmax(0, 1fr);
    padding: 64px clamp(28px, 7vw, 80px);
  }

  .setup-copy h1 {
    max-width: 10ch;
  }

  .auth-surface {
    max-width: 780px;
  }
}

@media (max-width: 820px) {
  .topbar {
    height: 64px;
    padding: 0 16px;
  }

  .brand > span:last-child,
  .connection-button #connection-label {
    display: none;
  }

  .setup-panel {
    grid-template-columns: 1fr;
    padding: 48px 20px;
  }

  .mode-switch {
    max-width: none;
  }

  .token-entry,
  .device-form,
  .credential-fields {
    display: grid;
    grid-template-columns: 1fr;
  }

  .field-note {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .workspace {
    padding: 44px 16px 64px;
  }

  .workspace-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 42px;
  }

  .freshness {
    align-items: flex-start;
  }

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

  .machine {
    padding: 34px 4px 42px;
  }

  .machine + .machine {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .dial-wrap {
    margin: 44px auto;
    max-width: 290px;
  }

  .machine-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .activity-section {
    padding: 48px 20px;
  }

  .activity-list li {
    gap: 5px 14px;
    grid-template-columns: 84px 1fr;
    padding: 13px 0;
  }

  .activity-list time {
    grid-column: 2;
  }
}
