:root {
  --bg: #f4f0e8;
  --surface: rgba(250, 247, 239, 0.88);
  --surface-strong: rgba(253, 250, 243, 0.96);
  --panel-dark: #262823;
  --panel-dark-2: #181a17;
  --steel: #70746e;
  --oled: #40413c;
  --oled-2: #343531;
  --oled-border: rgba(18, 19, 16, 0.68);
  --oled-text: #f1efe8;
  --oled-muted: rgba(241, 239, 232, 0.68);
  --text: #1b1d1a;
  --muted: #5f645d;
  --border: rgba(31, 35, 30, 0.16);
  --primary: #f37021;
  --primary-strong: #ca4f11;
  --primary-soft: #fff0e1;
  --accent: #f37021;
  --signal: #ffb000;
  --electronic: #2aa7a7;
  --warn: #b85c16;
  --danger: #9f3a32;
  --done-bg: #edf5ef;
  --active-bg: #fff4e8;
  --shadow: 0 12px 28px rgba(25, 28, 24, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(36, 32, 27, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 32, 27, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text);
  font-family: "DIN Alternate", "Bahnschrift", "Aptos", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

button,
.file-button {
  min-height: 36px;
  border: 1px solid #aaa79f;
  border-radius: 3px;
  background:
    linear-gradient(#fbf8f1, #e9e4da);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.42),
    inset 0 1px rgba(255, 255, 255, 0.82),
    0 1px 2px rgba(0, 0, 0, 0.12);
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
  background:
    linear-gradient(#fffaf3, #ece5dc);
}

button:disabled {
  color: #98958e;
  background-color: #e8e5de;
  background-image:
    linear-gradient(45deg, rgba(80, 80, 75, 0.06) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(80, 80, 75, 0.06) 25%, transparent 25%);
  background-size: 4px 4px;
  border-color: #bbb8b0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
  cursor: not-allowed;
}

button.primary {
  position: relative;
  background-color: var(--primary);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.16) 0.6px, transparent 0.7px);
  background-size: 5px 5px;
  border-color: #c94d0f;
  color: #fff;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.48),
    inset 0 -3px rgba(146, 52, 5, 0.22),
    0 1px 2px rgba(0, 0, 0, 0.18);
  text-transform: none;
}

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

button.primary::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: #f4f0e8;
  border: 1px solid #88400f;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

button.primary:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(90, 30, 0, 0.28);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(75, 72, 66, 0.28);
  border-radius: 3px;
  background:
    linear-gradient(#fffdf8, #f0ece4);
  padding: 7px 10px;
  color: var(--text);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.8),
    0 1px 1px rgba(0, 0, 0, 0.06);
}

input:invalid {
  border-color: rgba(159, 58, 50, 0.48);
}

.device-field {
  display: block;
}

.device-field input {
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.device-field.is-linked input {
  color: #4f4c47;
  background:
    linear-gradient(#f9f6ef, #eee8dc);
  cursor: not-allowed;
}

.device-field.is-error input {
  border-color: var(--danger);
  background: rgba(255, 246, 244, 0.95);
  box-shadow: 0 0 0 3px rgba(159, 58, 50, 0.12);
}

.device-field.is-warn input {
  border-color: rgba(184, 92, 22, 0.32);
  box-shadow: none;
}

.device-field.is-ok input {
  border-color: rgba(43, 41, 39, 0.22);
}

.required-mark {
  color: var(--danger);
  font-weight: 800;
}

.device-field em {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(159, 58, 50, 0.08);
  color: var(--danger);
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
}

.device-field .field-code,
.device-picker .field-code {
  margin-left: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #77736b;
  font-size: 10px;
  font-weight: 500;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 10px 0;
}

body:not(.is-authenticated) .app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 22px 0;
}

body:not(.is-authenticated) #statusText,
body:not(.is-authenticated) .top-nav,
body:not(.is-authenticated) .status-grid {
  display: none;
}

body:not(.is-authenticated) .topbar {
  margin-bottom: 0;
}

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

.topbar h1 {
  margin: 0 0 4px;
  font-size: 25px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.owner-mark {
  display: inline-block;
  margin-top: 3px;
  color: rgba(27, 29, 26, 0.58);
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 700;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.top-nav {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.nav-pill {
  min-height: 34px;
  background: rgba(250, 249, 244, 0.72);
}

.nav-pill.is-active {
  border-color: rgba(243, 112, 33, 0.45);
  background: rgba(255, 239, 223, 0.9);
  color: var(--primary-strong);
  font-weight: 700;
  box-shadow: none;
}

.session-badge {
  margin-left: auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.62);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.language-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(250, 249, 244, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.05);
}

.language-control span {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.language-control select {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 0;
}

.status-grid div,
.summary-grid div,
.progress-card,
.panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: none;
  backdrop-filter: blur(14px) saturate(1.05);
}

.status-grid div,
.summary-grid div,
.progress-card,
.panel,
.auth-panel,
.auth-card,
.guide-dialog,
.wait-dialog,
.power-dialog {
  position: relative;
}

.panel::before,
.progress-card::before,
.auth-card::before,
.guide-dialog::before,
.wait-dialog::before,
.power-dialog::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  pointer-events: none;
}

.status-grid div::before,
.summary-grid div::before,
.live-status::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(117, 255, 197, 0.08);
  pointer-events: none;
}

.status-grid div,
.summary-grid div {
  min-height: 48px;
  padding: 8px 10px;
  border-color: var(--oled-border);
  background: var(--oled);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55);
}

.status-grid span,
.summary-grid span,
.progress-head span,
label span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 3px;
}

.status-grid span,
.summary-grid span {
  color: var(--oled-muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  text-transform: uppercase;
}

.status-grid strong,
.summary-grid strong {
  color: var(--oled-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(120, 247, 191, 0.26);
}

.instrument-panel {
  position: relative;
  color: var(--oled-text);
  background-color: var(--oled);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.065) 0.7px, transparent 0.8px),
    linear-gradient(rgba(255, 255, 255, 0.025), rgba(0, 0, 0, 0.08));
  background-size: 6px 6px, 100% 100%;
  border: 1px solid #252622;
  border-radius: 5px;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.2),
    inset 0 -2px rgba(0, 0, 0, 0.28),
    0 1px 3px rgba(0, 0, 0, 0.12);
}

.instrument-panel::before,
.instrument-panel::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-color: rgba(255, 255, 255, 0.42);
  pointer-events: none;
}

.instrument-panel::before {
  top: 8px;
  left: 8px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.instrument-panel::after {
  right: 8px;
  bottom: 8px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.section-number {
  color: var(--primary);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.status-code,
.field-code {
  margin-left: 10px;
  color: #c4c2bb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.progress-card {
  padding: 0;
  margin: 0;
}

.collector-display {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(0, 1.68fr);
  align-items: stretch;
  gap: 14px;
  margin-bottom: 8px;
  padding: 18px 20px 14px 36px;
  color: var(--oled-text);
  overflow: hidden;
}

.collector-display .instrument-tag {
  position: absolute;
  top: 16px;
  left: 36px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #f59a32;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.collector-display .instrument-tag small {
  color: #c4c2bb;
  font-size: 9px;
}

.display-primary,
.display-secondary {
  position: relative;
  min-width: 0;
}

.display-primary {
  display: grid;
  grid-template-rows: minmax(64px, 1fr) auto;
  gap: 12px;
  padding: 40px 18px 2px 0;
  border-right: 1px solid rgba(241, 239, 232, 0.22);
}

.display-secondary {
  display: grid;
  align-content: stretch;
  gap: 0;
}

.collector-display .progress-card,
.collector-display .status-grid div,
.collector-display .summary-grid div {
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.collector-display .progress-card::before,
.collector-display .status-grid div::before,
.collector-display .summary-grid div::before {
  display: none;
}

.collector-display .progress-head span,
.collector-display .status-grid span,
.collector-display .summary-grid span {
  color: var(--oled-muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.collector-display .status-grid div > span,
.collector-display .summary-grid div > span {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: space-between;
}

.collector-display .status-grid div > span > span,
.collector-display .summary-grid div > span > span {
  display: inline;
  margin: 0;
}

.collector-display .progress-head strong,
.collector-display .status-grid strong,
.collector-display .summary-grid strong {
  color: var(--oled-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  text-shadow: 0 0 8px rgba(120, 247, 191, 0.24);
}

.collector-display .status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid rgba(241, 239, 232, 0.18);
  padding-bottom: 12px;
}

.collector-display .status-grid div {
  min-height: 58px;
  padding: 4px 16px 0;
  border-right: 1px solid rgba(241, 239, 232, 0.2);
}

.collector-display .status-grid div:first-child {
  padding-left: 0;
}

.collector-display .status-grid div:last-child {
  border-right: 0;
}

.collector-display .status-grid strong {
  margin-top: 8px;
  font-size: 24px;
  letter-spacing: 0;
}

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

.collector-details > summary {
  cursor: pointer;
  padding: 10px 0 2px;
  color: var(--oled-muted);
  font-size: 12px;
}

.collector-details > summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.collector-display .summary-grid div {
  min-height: 34px;
  padding: 3px 16px 3px 0;
  border-bottom: 1px solid rgba(241, 239, 232, 0.13);
}

.collector-display .summary-grid strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.progress-head strong {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 30px;
}

.progress-track {
  position: relative;
  height: 12px;
  overflow: visible;
  border: 1px solid #22231f;
  border-radius: 2px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 9.6%,
      rgba(255, 255, 255, 0.35) 9.6% 10%
    ),
    #292b28;
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.45),
    0 1px rgba(255, 255, 255, 0.12);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  border-right: 2px solid #ffc08e;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.35);
  transition: width 180ms ease;
}

.scale-label {
  position: absolute;
  top: 16px;
  color: #d4d2cb;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
}

.scale-label.start {
  left: 0;
}

.scale-label.middle {
  left: 50%;
  transform: translateX(-50%);
}

.scale-label.end {
  right: 0;
}

.workspace {
  display: block;
}

.app-view[hidden] {
  display: none;
}

.panel {
  padding: 10px;
}

.action-panel {
  border-color: rgba(75, 72, 66, 0.26);
  background:
    linear-gradient(rgba(255, 255, 255, 0.54), rgba(244, 238, 228, 0.78));
}

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

.panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel h2,
.panel-head h2 {
  margin: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-size: 18px;
  line-height: 1.2;
}

.panel-head h2 small {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.panel-head p {
  margin: 0;
}

.device-panel {
  min-height: 0;
}

.initialization-panel {
  min-height: 0;
}

.initialization-focus {
  margin-bottom: 12px;
  padding: 22px 24px 20px;
}

.init-focus-main {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) minmax(110px, 150px);
  gap: 18px;
  align-items: center;
}

.init-focus-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 112, 24, 0.46);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 112, 24, 0.24), rgba(255, 112, 24, 0.06)),
    rgba(18, 18, 16, 0.7);
  box-shadow: inset 0 0 18px rgba(255, 112, 24, 0.16);
}

.init-focus-icon span {
  width: 24px;
  height: 24px;
  border: 3px solid #ff7a1a;
  border-top-color: rgba(255, 122, 26, 0.22);
  border-radius: 999px;
}

#initializationView[data-phase="connecting"] .init-focus-icon span,
#initializationView[data-phase="opening"] .init-focus-icon span,
#initializationView[data-phase="activating"] .init-focus-icon span,
#initializationView[data-phase="initializing"] .init-focus-icon span,
#initializationView[data-phase="verifying"] .init-focus-icon span {
  animation: waitSpin 1s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  #initializationView[data-phase] .init-focus-icon span {
    animation: none;
  }
}

.init-focus-copy {
  display: grid;
  gap: 7px;
}

.init-focus-kicker,
.init-focus-percent span,
.init-focus-note {
  color: rgba(247, 243, 234, 0.64);
  font-size: 12px;
  font-weight: 700;
}

.init-focus-copy strong {
  color: #f7f3ea;
  font-size: clamp(32px, 3.7vw, 54px);
  line-height: 1.02;
}

.init-focus-copy small {
  color: rgba(247, 243, 234, 0.78);
  font-size: clamp(15px, 1.4vw, 19px);
  line-height: 1.4;
}

.init-focus-percent {
  text-align: right;
}

.init-focus-percent strong {
  display: block;
  color: #ff7a1a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1;
}

.initialization-progress-track {
  margin-top: 20px;
}

.init-focus-note {
  margin-top: 13px;
  color: #f5a259;
}

.initialization-guide {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.initialization-guide p {
  margin: 0;
  padding: 10px 0 10px 14px;
  border-left: 3px solid rgba(255, 112, 24, 0.62);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.initialization-setup {
  display: grid;
  gap: 14px;
  max-width: 520px;
  margin: 18px 0;
}

.initialization-firmware {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.initialization-consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  line-height: 1.45;
}

.initialization-consent input {
  flex: 0 0 auto;
  margin-top: 3px;
}

.initialization-press-prompt:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 640px;
  margin: 14px 0;
  padding: 14px 16px;
  border: 1px solid rgba(255, 112, 24, 0.45);
  border-radius: 6px;
  background: rgba(255, 112, 24, 0.08);
}

.initialization-press-prompt p {
  margin: 5px 0 0;
  color: var(--muted);
}

@media (max-width: 480px) {
  .initialization-press-prompt:not([hidden]) {
    align-items: stretch;
    flex-direction: column;
  }
}

.auth-panel {
  position: relative;
  min-height: min(640px, calc(100vh - 126px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  align-items: center;
  gap: clamp(28px, 6vw, 72px);
  padding: clamp(28px, 5vw, 60px);
  border: 1px solid rgba(31, 35, 30, 0.15);
  border-radius: 8px;
  background: rgba(247, 246, 240, 0.92);
  box-shadow: none;
  backdrop-filter: blur(18px) saturate(1.08);
  overflow: hidden;
}

.auth-panel::before {
  display: none;
}

.auth-copy,
.auth-card {
  position: relative;
  z-index: 1;
}

.auth-copy {
  max-width: 620px;
}

.auth-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 18px;
  padding: 0 10px;
  border: 1px solid rgba(243, 112, 33, 0.28);
  border-radius: 4px;
  background: rgba(255, 246, 236, 0.76);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
}

.auth-copy h2 {
  margin: 0;
  max-width: 560px;
  color: #191817;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.04;
  font-weight: 760;
}

.auth-copy p {
  max-width: 540px;
  margin: 18px 0 0;
  color: #4f4a45;
  font-size: 16px;
  line-height: 1.7;
}

.auth-assurance {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.auth-assurance span {
  margin: 0;
  padding: 7px 10px;
  border: 1px solid rgba(31, 35, 30, 0.14);
  border-radius: 4px;
  background: rgba(250, 249, 244, 0.76);
  color: #373330;
  font-size: 12px;
  font-weight: 700;
}

.auth-card {
  width: 100%;
  padding: 22px;
  border: 1px solid rgba(31, 35, 30, 0.16);
  border-radius: 6px;
  background: rgba(253, 252, 246, 0.94);
  box-shadow: none;
  overflow: hidden;
}

.auth-card-head {
  margin-bottom: 16px;
}

.auth-card-head > span {
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
}

.auth-card-head h2 {
  margin: 6px 0 6px;
  font-size: 24px;
  line-height: 1.2;
}

.auth-form {
  display: grid;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.auth-form h3 {
  margin: 0;
  font-size: 16px;
}

.reset-code-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.reset-code-row label {
  flex: 1;
  min-width: 0;
}

.reset-code-row button {
  flex: 0 0 auto;
  min-height: 44px;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .reset-code-row {
    flex-wrap: wrap;
  }

  .reset-code-row label {
    flex-basis: 100%;
  }

  .reset-code-row button {
    width: 100%;
  }
}

.auth-switch {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-switch span {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.link-button {
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary-strong);
  padding: 0;
  box-shadow: none;
  text-decoration: underline;
}

.link-button:hover {
  background: transparent;
  color: var(--primary);
}

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

.registration-form .form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
}

.registration-batch-form {
  display: grid;
  gap: 12px;
}

.registration-meta {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto;
  align-items: end;
  gap: 12px;
}

.batch-count {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 0 12px;
  border: 1px solid rgba(243, 112, 33, 0.24);
  border-radius: 4px;
  background: rgba(255, 241, 226, 0.82);
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 700;
}

.batch-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(31, 35, 30, 0.14);
  border-radius: 6px;
  background: rgba(245, 244, 238, 0.8);
}

.batch-import-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.paste-import-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(243, 112, 33, 0.22);
  border-radius: 6px;
  background: rgba(255, 246, 236, 0.74);
}

.paste-import-panel[hidden] {
  display: none;
}

.paste-import-panel textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 251, 0.9);
  color: var(--text);
  padding: 9px 10px;
}

.registration-table-shell {
  overflow: auto;
  border: 1px solid rgba(31, 35, 30, 0.16);
  border-radius: 6px;
  background: rgba(250, 249, 244, 0.84);
  box-shadow: none;
}

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

.registration-table th,
.registration-table td {
  border-bottom: 1px solid rgba(31, 35, 30, 0.1);
  border-right: 1px solid rgba(31, 35, 30, 0.08);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

.registration-table th {
  background: #20231f;
  color: #f5f2eb;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0;
}

.registration-table td:last-child,
.registration-table th:last-child {
  border-right: 0;
}

.registration-table tr:last-child td {
  border-bottom: 0;
}

.registration-table input,
.registration-table select {
  min-width: 96px;
  min-height: 34px;
  background: rgba(255, 255, 251, 0.92);
}

.registration-table [data-field="person_name"],
.registration-table [data-field="project"] {
  min-width: 150px;
}

.registration-table [data-field="device_id"] {
  min-width: 140px;
}

.registration-table tr.is-error td {
  background: rgba(159, 58, 50, 0.08);
}

.admin-panel {
  display: grid;
  gap: 16px;
}

.history-panel {
  display: grid;
  gap: 18px;
}

.history-heading {
  align-items: start;
  flex-wrap: wrap;
  gap: 12px;
}

.history-heading h2,
.history-section h3 {
  margin: 0;
}

.history-heading p,
.history-section p {
  margin: 6px 0 0;
}

.history-panel > .form-message {
  margin: 0;
}

.history-panel > .form-message:empty {
  display: none;
}

.history-filters {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
}

.history-filters > label,
.history-date-field {
  flex: 1 1 150px;
  min-width: 0;
}

.history-date-field {
  display: grid;
  gap: 4px;
}

.history-date-control {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.history-date-control input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 4px 0 0 4px;
}

.history-date-control .history-date-picker {
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  padding: 0 8px;
  color: transparent;
  border-radius: 0 4px 4px 0;
  border-left: 0;
}

.history-date-picker::-webkit-datetime-edit {
  display: none;
}

.history-date-picker::-webkit-calendar-picker-indicator {
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.history-filters input,
.history-filters select {
  width: 100%;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.history-summary > div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(250, 249, 244, 0.84);
}

.history-summary span,
.history-notice {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.history-summary strong {
  font-size: 24px;
  line-height: 1;
}

.history-notice {
  margin: 0;
}

.history-section {
  display: grid;
  gap: 10px;
}

.history-table {
  min-width: 760px;
}

@media (max-width: 680px) {
  .history-filters > label,
  .history-date-field {
    flex-basis: calc(50% - 6px);
  }

  .history-filters > label:first-child {
    flex-basis: 100%;
  }

  .history-filters button {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .history-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.admin-panel > .panel-head {
  display: grid;
  gap: 8px;
}

.admin-search-form,
.admin-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-search-form label {
  flex: 1 1 240px;
  max-width: 420px;
}

.admin-accounts-table {
  min-width: 720px;
}

.admin-accounts-table td {
  overflow-wrap: anywhere;
}

.admin-pagination {
  align-items: center;
  margin: 12px 0 0;
}

.admin-reset-form,
.admin-password-result {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-strong);
}

.admin-reset-form[hidden],
.admin-password-result[hidden],
#adminAccountTools[hidden] {
  display: none;
}

.admin-reset-form h3,
.admin-password-result h3,
.admin-password-result p {
  margin: 0;
}

.admin-reset-form label,
.admin-password-result label {
  width: min(100%, 520px);
}

#adminNewPassword {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.row-delete {
  min-width: 54px;
  min-height: 32px;
  padding: 0 10px;
}

.form-message {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-message.is-ok {
  color: #2f5f43;
  font-weight: 700;
}

.form-message.is-warn {
  color: var(--warn);
  font-weight: 700;
}

.form-message.is-error {
  color: var(--danger);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.75fr);
  align-items: start;
  gap: 18px;
  margin-bottom: 9px;
}

.device-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.device-picker .field-hint {
  grid-column: 1 / -1;
  margin-top: -2px;
}

.field-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.device-field > span,
.device-picker label > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.field-hint.is-warn {
  color: var(--warn);
}

.field-hint.is-error {
  color: var(--danger);
}

.field-hint.is-ok {
  color: #2b2927;
}

.live-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--oled-border);
  border-radius: 6px;
  background: var(--oled);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.56);
}

.collector-display .live-status {
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.collector-display .live-status::before {
  display: none;
}

.live-status::after {
  display: none;
}

.live-status.state-waiting::after,
.live-status.state-running::after,
.live-status.state-uploading::after {
  animation: none;
  opacity: 0;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.live-dot {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: #252823;
  border: 1px solid #161814;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.12);
  flex: 0 0 auto;
}

.status-led {
  display: inline-grid;
  place-items: center;
}

.status-led::after {
  content: "";
  width: 7px;
  height: 7px;
  background: #8fbd87;
  border: 1px solid #b7d9ae;
  box-shadow:
    inset 1px 1px rgba(255, 255, 255, 0.55),
    0 0 3px rgba(143, 189, 135, 0.35);
}

.live-status strong {
  display: block;
  color: var(--oled-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 16px;
  line-height: 1.25;
  text-shadow: 0 0 8px rgba(120, 247, 191, 0.24);
}

.collector-display .live-status strong {
  font-size: 25px;
}

.live-status small {
  display: block;
  color: var(--oled-muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.4;
  margin-top: 2px;
}

.collector-display .live-status small {
  max-width: 300px;
  font-size: 11px;
}

.live-metric {
  flex: 0 0 auto;
  min-width: 100px;
  padding: 6px 10px;
  border: 1px solid rgba(117, 255, 197, 0.18);
  border-radius: 4px;
  background: var(--oled-2);
  color: var(--oled-text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 0 8px rgba(120, 247, 191, 0.24);
}

.collector-display .live-metric {
  min-width: 88px;
  padding: 8px 11px;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(35, 36, 32, 0.72);
  font-size: 16px;
}

.live-status.state-waiting .live-dot {
  background: #252823;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.12);
  animation: livePulse 1.1s ease-in-out infinite;
}

.live-status.state-running .live-dot,
.live-status.state-uploading .live-dot {
  background: #252823;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.12);
  animation: livePulse 0.9s ease-in-out infinite;
}

.live-status.state-ok .live-dot {
  background: #252823;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.12);
}

.live-status.state-error .live-dot {
  background: #252823;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.12);
}

.live-status.state-waiting .status-led::after {
  background: #f5a64a;
  border-color: #ffd09b;
  box-shadow:
    inset 1px 1px rgba(255, 255, 255, 0.55),
    0 0 5px rgba(245, 166, 74, 0.42);
}

.live-status.state-error .status-led::after {
  background: #cf4a35;
  border-color: #ffb1a4;
  box-shadow:
    inset 1px 1px rgba(255, 255, 255, 0.45),
    0 0 5px rgba(207, 74, 53, 0.45);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 9px;
}

.toolbar button,
.capture-actions button,
.guide-foot button {
  min-inline-size: 128px;
  min-height: 42px;
  padding-inline: 22px;
  white-space: normal;
}

.toolbar button,
.capture-actions button {
  flex: 0 1 auto;
}

.capture-actions {
  position: fixed;
  inset: 0;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(31, 28, 24, 0.28);
  backdrop-filter: blur(7px);
}

.capture-actions[hidden] {
  display: none;
}

.capture-choice-dialog {
  width: min(540px, calc(100vw - 32px));
  padding: 28px;
}

.capture-choice-dialog h2 {
  margin: 0 0 18px;
}

.capture-choice-dialog p {
  margin: 0 0 20px;
  color: var(--muted);
}

.capture-upload {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  margin-bottom: 18px;
}

.capture-upload-track {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(173, 92, 37, 0.32);
  border-radius: 5px;
  background: #eee8de;
}

.capture-upload-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 36%;
  background: linear-gradient(90deg, #f7bd86, #f7934c);
  animation: captureUploadProgress 1.7s ease-in-out infinite alternate;
}

.capture-upload-track[data-state="complete"] .capture-upload-fill {
  width: 100%;
  background: #f6c392;
  animation: none;
}

.capture-upload-track[data-state="error"] {
  border-color: rgba(159, 58, 50, 0.5);
  background: #f8e8e4;
}

.capture-upload-track[data-state="error"] .capture-upload-fill {
  width: 0;
  animation: none;
}

.capture-upload-status {
  position: relative;
  z-index: 1;
  padding: 11px 14px;
  color: #28231e;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  pointer-events: none;
}

.capture-upload-track[data-state="error"] + .capture-upload-status {
  color: var(--danger);
}

.capture-choice-dialog #captureChoiceError {
  color: #b6402d;
}

.capture-choice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.capture-choice-buttons button {
  flex: 1 1 130px;
  padding-inline: 14px;
}

@media (max-width: 430px) {
  .capture-choice-dialog {
    padding: 22px;
  }

  .capture-choice-buttons button {
    flex-basis: 100%;
  }
}

@keyframes captureUploadProgress {
  from { transform: translateX(0); }
  to { transform: translateX(178%); }
}

@media (prefers-reduced-motion: reduce) {
  .capture-upload-track[data-state="uploading"] .capture-upload-fill {
    animation: none;
    left: 32%;
    width: 36%;
    background: repeating-linear-gradient(135deg, #f6c392 0 12px, #f9d5b3 12px 24px);
  }
}

.privacy-consent {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 13px;
}

.privacy-consent span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.privacy-consent button {
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary-strong);
  padding: 0;
  box-shadow: none;
  text-decoration: underline;
}

.privacy-consent button:hover {
  background: transparent;
  color: var(--primary);
}

.file-button input {
  display: none;
}

.debug-tools {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 7px;
}

body.debug .debug-tools {
  display: flex;
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  color: var(--text);
}

.switch-row span {
  margin: 0;
  color: var(--text);
  font-size: 13px;
}

.data-stream {
  margin: 0;
  border-radius: 5px;
  color: #f8e4d4;
  overflow: hidden;
}

.stream-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 18px 9px;
  border-bottom: 1px solid rgba(241, 239, 232, 0.15);
  background: rgba(36, 37, 33, 0.42);
}

.stream-head > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #c7cabb;
  font-size: 12px;
}

.stream-head > span > span:not(.section-number) {
  display: inline;
  margin: 0;
}

.stream-head .section-number {
  color: var(--primary);
  font-size: 17px;
}

.stream-head strong {
  flex: 0 0 auto;
  color: #f59a32;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  text-align: right;
}

.stream-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stream-meta span {
  min-width: 74px;
  min-height: 24px;
  justify-content: center;
  border: 1px solid rgba(241, 239, 232, 0.22);
  border-radius: 2px;
  background: rgba(35, 36, 32, 0.78);
  color: #d8d4ca;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.08),
    0 1px rgba(0, 0, 0, 0.24);
}

.stream-meta i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 5px rgba(243, 112, 33, 0.5);
}

.stream-rows {
  display: grid;
  gap: 1px;
  min-height: 78px;
  padding: 8px 18px 10px;
}

.stream-row {
  display: grid;
  grid-template-columns: minmax(64px, 88px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 13px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  line-height: 1.15;
  color: rgba(248, 228, 212, 0.58);
  opacity: 0.68;
}

.stream-row.is-active {
  color: #ffffff;
  opacity: 1;
}

.stream-line {
  color: #b4a69c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-bits {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-row.is-active .stream-bits {
  color: #f1efe8;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.18);
}

.stream-row.is-active .stream-line {
  color: #ffffff;
}

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

.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(31, 28, 24, 0.28);
  backdrop-filter: blur(7px);
}

.guide-overlay.is-open {
  display: flex;
}

.guide-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid rgba(31, 35, 30, 0.18);
  border-radius: 6px;
  background: var(--surface-strong);
  box-shadow: none;
  overflow: auto;
}

.guide-device-fields {
  grid-template-columns: minmax(0, 1fr);
  padding: 16px 18px 0;
}

.guide-dialog .privacy-consent,
.guide-firmware,
.guide-port-action,
.guide-register {
  margin: 10px 18px;
}

.guide-firmware {
  display: grid;
  gap: 6px;
}

.guide-port-action {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-foot {
  justify-content: flex-end;
}

.guide-dialog button.primary:disabled {
  color: #77746e;
  background: #ddd9d1;
  border-color: #b5b1a8;
  box-shadow: none;
  cursor: not-allowed;
}

.model-settings-overlay { z-index: 35; }
.model-settings-dialog { width: min(480px, calc(100vw - 32px)); }
.model-settings-dialog > p,
.model-settings-dialog > .toolbar { margin: 12px 18px 18px; }
.account-model-controls { min-width: 240px; }
.account-model-controls [role="group"] { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 8px; }
.account-model-controls label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.account-model-controls input[type="checkbox"] { width: 16px; height: 16px; min-width: 16px; min-height: 16px; flex: 0 0 16px; margin: 0; padding: 0; }
.account-model-controls label span { font-size: 12px; }
.account-model-controls label:first-child { flex-basis: 100%; font-weight: 600; }
.guide-firmware[hidden] { display: none; }

.privacy-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.privacy-copy {
  overflow: auto;
  padding: 18px 22px;
  color: #302d2a;
}

.privacy-copy p {
  margin: 0 0 12px;
  line-height: 1.65;
}

.privacy-copy section {
  margin-top: 12px;
}

.privacy-copy h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 15px;
}

.privacy-copy ul {
  margin: 0;
  padding-left: 20px;
  color: #3d3935;
  line-height: 1.6;
}

.guide-head,
.guide-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.guide-head {
  border-bottom: 1px solid rgba(31, 35, 30, 0.12);
  background: rgba(255, 246, 236, 0.72);
}

.guide-head span {
  display: block;
  margin-bottom: 4px;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 700;
}

.guide-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.guide-lead {
  margin: 0;
  padding: 14px 18px 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
}

.guide-steps {
  list-style: none;
  margin: 0;
  padding: 12px 18px 4px;
  display: grid;
  gap: 8px;
  counter-reset: guideStep;
}

.guide-steps li {
  position: relative;
  min-height: 58px;
  padding: 10px 12px 10px 50px;
  border: 1px solid rgba(31, 35, 30, 0.12);
  border-radius: 6px;
  background: rgba(252, 251, 246, 0.78);
  counter-increment: guideStep;
}

.guide-steps li::before {
  content: counter(guideStep);
  position: absolute;
  left: 12px;
  top: 12px;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.guide-steps strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}

.guide-steps small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.guide-next {
  display: grid;
  gap: 4px;
  margin: 10px 18px 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  background: rgba(239, 123, 50, 0.08);
}

.guide-next strong {
  font-size: 14px;
}

.guide-next span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.guide-foot {
  border-top: 1px solid rgba(31, 35, 30, 0.12);
}

.guide-foot span {
  color: var(--muted);
  font-size: 13px;
}

.power-overlay {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: transparent;
  pointer-events: none;
}

.power-overlay.is-open {
  display: flex;
}

.power-diagnostics-button {
  display: block;
  margin-top: 12px;
  padding: 6px 10px;
  font-size: 13px;
}

.diagnostics-overlay {
  position: fixed;
  inset: 0;
  z-index: 36;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(31, 28, 24, 0.4);
}

.diagnostics-dialog {
  display: flex;
  flex-direction: column;
  width: min(1020px, 100%);
  max-height: calc(100dvh - 36px);
  padding: 20px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--surface-strong);
  overflow-y: auto;
}

.diagnostics-heading, .diagnostics-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.diagnostics-heading h2 {
  margin: 0;
  font-size: 21px;
}

.diagnostics-notice, .diagnostics-hint, .diagnostics-message {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.diagnostics-notice {
  padding: 10px 12px;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
}

.diagnostics-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 16px;
  margin: 0;
  font-size: 12px;
}

.diagnostics-summary div {
  min-width: 0;
}

.diagnostics-summary dt {
  color: var(--muted);
}

.diagnostics-summary dd {
  margin: 4px 0 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-wrap: anywhere;
  max-height: 4.5em;
  overflow: auto;
}

.diagnostics-log {
  flex: 1 1 240px;
  min-height: 140px;
  max-height: 42vh;
  padding: 12px;
  margin: 0 0 12px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--panel-dark-2);
  color: var(--oled-text);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  user-select: text;
}

.diagnostics-actions {
  justify-content: flex-start;
}

.diagnostics-message {
  min-height: 1.5em;
  margin: 8px 0 0;
}

.test-help-entry {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.test-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 34;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(31, 28, 24, 0.42);
  backdrop-filter: blur(4px);
}

.test-help-dialog {
  display: flex;
  flex-direction: column;
  width: min(940px, 100%);
  max-height: calc(100dvh - 36px);
  min-width: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 22px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.test-help-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

#testHelpPanel {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.test-help-heading h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.test-help-kicker {
  color: var(--primary-strong);
  font-size: 11px;
  letter-spacing: 0.09em;
}

.test-help-languages {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  flex-shrink: 0;
}

.test-help-languages button[aria-selected="true"] {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.test-help-timing {
  margin: 16px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.test-help-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(250px, 1fr);
  align-items: start;
  gap: 24px;
}

.test-help-flow {
  list-style: none;
  margin: 0;
  padding: 0;
}

.test-help-flow > li:not(:last-child)::after {
  content: "↓";
  display: block;
  padding: 3px 0;
  text-align: center;
  color: var(--primary-strong);
  font-size: 21px;
  line-height: 1;
}

.test-help-node {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.test-help-node > div {
  min-width: 0;
}

.test-help-node-urgent {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.test-help-node-done {
  background: var(--done-bg);
}

.test-help-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--panel-dark);
  color: var(--oled-text);
  font-size: 13px;
}

.test-help-node h3,
.test-help-failure h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.test-help-node p,
.test-help-failure p,
.test-help-retry-flow li {
  margin: 5px 0 0;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.test-help-branch-label {
  display: block;
  margin-top: 8px;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 600;
}

.test-help-failure {
  padding: 15px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 4px;
  background: var(--surface);
}

.test-help-failure-tag {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--primary-strong);
  font-size: 12px;
}

.test-help-retry-flow {
  margin: 13px 0;
  padding-left: 22px;
}

.test-help-retry-flow li {
  margin-top: 9px;
}

.test-help-failure .test-help-storage-note {
  padding: 10px;
  margin: 12px 0;
  background: var(--primary-soft);
}

.test-help-failure button {
  max-width: 100%;
  min-height: 38px;
  white-space: normal;
}

.test-help-failure .test-help-small,
.test-help-safety {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.test-help-safety {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 680px) {
  .test-help-overlay {
    padding: 10px;
  }

  .test-help-dialog {
    max-height: calc(100dvh - 20px);
    padding: 16px;
  }

  .test-help-heading h2 {
    font-size: 21px;
  }

  .test-help-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .test-help-languages button {
    min-height: 40px;
  }

  .test-help-timing {
    padding: 10px 12px;
    font-size: 13px;
  }
}

.wait-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(31, 28, 24, 0.22);
  backdrop-filter: blur(5px);
}

.wait-overlay.is-open {
  display: flex;
}

.wait-dialog {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(420px, calc(100vw - 32px));
  padding: 20px 22px;
  border: 1px solid rgba(243, 112, 33, 0.28);
  border-radius: 6px;
  background: var(--surface-strong);
  box-shadow: none;
  overflow: hidden;
}

.wait-spinner {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 3px solid rgba(42, 167, 167, 0.16);
  border-top-color: var(--primary);
  border-right-color: var(--signal);
  animation: waitSpin 0.82s linear infinite;
}

.wait-dialog h2 {
  margin: 0 0 5px;
  font-size: 21px;
  line-height: 1.2;
}

.wait-dialog p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.power-dialog {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(540px, calc(100vw - 32px));
  padding: 22px 24px 22px 22px;
  border: 1px solid rgba(243, 112, 33, 0.3);
  border-radius: 6px;
  background: var(--surface-strong);
  box-shadow: none;
  overflow: hidden;
}

.power-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(243, 112, 33, 0.46);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255, 122, 35, 0.18), rgba(255, 122, 35, 0.06)),
    rgba(255, 252, 246, 0.88);
  color: var(--primary);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.6),
    0 0 0 0 rgba(243, 112, 33, 0.22);
  animation: powerPulse 1.2s ease-in-out infinite;
}

.power-icon svg {
  width: 23px;
  height: 23px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.power-dialog h2 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.15;
}

.power-dialog p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.power-dialog strong {
  color: var(--primary-strong);
  font-size: 15px;
}

.state-ok {
  color: #2b2927;
}

.state-warn {
  color: var(--warn);
}

.state-error {
  color: var(--danger);
}

@keyframes livePulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.28);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes statusSweep {
  0% {
    transform: translateX(-120%);
  }
  52% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(120%);
  }
}

@keyframes powerPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(243, 112, 33, 0.28);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 16px rgba(243, 112, 33, 0);
    transform: scale(1.04);
  }
}

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

@media (max-width: 900px) {
  .app-shell {
    width: min(100vw - 20px, 860px);
    padding-top: 16px;
  }

  body:not(.is-authenticated) .app-shell {
    padding: 14px 0;
  }

  .topbar,
  .workspace {
    display: block;
  }

  .topbar-tools {
    flex-wrap: wrap;
    margin: 8px 0 0;
  }

  .language-control {
    width: auto;
  }

  .status-grid,
  .form-grid,
  .summary-grid,
  .device-picker,
  .init-focus-main,
  .registration-form,
  .registration-meta,
  .paste-import-panel {
    grid-template-columns: 1fr;
  }

  .top-nav {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .top-nav .nav-pill {
    flex: 1 1 auto;
  }

  .session-badge {
    flex: 0 1 auto;
    margin-left: 0;
  }

  .status-grid,
  .panel {
    margin-top: 12px;
  }

  .collector-display {
    grid-template-columns: 1fr;
  }

  .display-primary {
    padding-right: 0;
    padding-bottom: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(117, 255, 197, 0.13);
  }

  .collector-display .status-grid,
  .collector-display .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 0;
  }

  .collector-display .status-grid div:nth-child(2n),
  .collector-display .summary-grid div:nth-child(2n) {
    border-right: 0;
  }

  .init-focus-main {
    gap: 12px;
  }

  .init-focus-percent {
    text-align: left;
  }

  .auth-panel {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 14px;
    padding: 20px;
  }

  .auth-copy h2 {
    font-size: 30px;
    line-height: 1.08;
  }

  .auth-copy p {
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
  }

  .auth-kicker {
    margin-bottom: 12px;
  }

  .auth-assurance {
    margin-top: 14px;
  }

  .auth-card {
    padding: 18px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions,
  .guide-head,
  .guide-foot {
    width: 100%;
  }

  .guide-head,
  .guide-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .guide-head button,
  .guide-foot button {
    width: 100%;
  }

  .power-dialog {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-metric {
    width: 100%;
    text-align: left;
  }

  .stream-row {
    grid-template-columns: minmax(76px, 96px) minmax(0, 1fr);
  }
}
