:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  color: #1d1d1f;
  background: #f5f5f7;
  --ink: #1d1d1f;
  --ink-secondary: #3a3a3c;
  --muted: #6e6e73;
  --muted-soft: #8e8e93;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #f5f5f7;
  --surface-hover: #eeeeef;
  --line: #d2d2d7;
  --line-soft: #e5e5e7;
  --sidebar: #fbfbfd;
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --primary-soft: #e8f2ff;
  --success: #248a3d;
  --success-soft: #e9f7ed;
  --warning: #b35c00;
  --warning-soft: #fff4e5;
  --danger: #d70015;
  --danger-hover: #b80012;
  --danger-soft: #fff0f1;
  --focus: #0071e3;
  --screen: #111214;
  --screen-line: #343539;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 5%);
  --shadow-md: 0 10px 30px rgb(0 0 0 / 8%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--surface-soft);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--surface-soft);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
}

button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 13px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

button:hover:not(:disabled) {
  border-color: #b6b6bb;
  background: var(--surface-hover);
}

button:active:not(:disabled) {
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 12%);
}

button.primary,
button[type="submit"] {
  border-color: var(--primary);
  color: #ffffff;
  background: var(--primary);
}

button.primary:hover:not(:disabled),
button[type="submit"]:hover:not(:disabled) {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

button.secondary {
  color: var(--ink);
  background: var(--surface);
}

button.quiet {
  border-color: transparent;
  color: var(--primary);
  background: transparent;
}

button.quiet:hover:not(:disabled) {
  border-color: transparent;
  color: var(--primary-hover);
  background: var(--primary-soft);
}

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

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

button.compact {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
}

button.wide {
  width: 100%;
}

button.icon-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--ink-secondary);
  background: var(--surface);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  border-color: var(--line-soft);
  color: var(--muted-soft);
  background: var(--surface-soft);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.72;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 1px;
}

input,
select,
textarea {
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
}

textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.lucide {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  stroke-width: 1.8;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
}

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

.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
}

.brand-block,
.header-actions,
.brand-copy,
.connection-status {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  color: #ffffff;
  border-radius: 7px;
  background: #1d1d1f;
  place-items: center;
}

.brand-mark .lucide {
  width: 17px;
  height: 17px;
}

.brand-copy {
  align-items: baseline;
  gap: 9px;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 650;
}

.transport-badge {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.header-actions {
  gap: 10px;
}

.connection-status {
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.connection-status > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted-soft) 12%, transparent);
}

.connection-status.online > span {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 14%, transparent);
}

.connection-status.connecting > span {
  background: #e6a000;
  box-shadow: 0 0 0 3px color-mix(in srgb, #e6a000 14%, transparent);
}

.app-root {
  min-height: calc(100vh - 56px);
}

.loading-view,
.login-view {
  min-height: calc(100vh - 56px);
}

.loading-view {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

.login-view {
  display: grid;
  padding: 36px 20px;
  place-items: center;
}

.login-shell {
  display: grid;
  width: min(760px, 100%);
  grid-template-columns: 260px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: grid;
  min-height: 430px;
  color: #ffffff;
  background: #1d1d1f;
  place-items: center;
}

.login-brand .lucide {
  width: 70px;
  height: 70px;
  stroke-width: 1.2;
}

.login-panel {
  align-self: center;
  padding: 42px;
}

.login-heading {
  margin-bottom: 26px;
}

.login-heading h1 {
  margin-bottom: 8px;
  font-size: 25px;
  font-weight: 650;
}

.login-heading > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-fields {
  display: grid;
  gap: 14px;
}

.login-field {
  display: grid;
  gap: 7px;
}

.login-field > label {
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 600;
}

.password-field {
  display: block;
  position: relative;
}

.password-field input {
  width: 100%;
  padding-right: 42px;
}

.field-icon {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.field-icon:hover:not(:disabled) {
  border-color: transparent;
  background: var(--surface-hover);
}

.error {
  min-height: 19px;
  margin: 7px 0 5px;
  color: var(--danger);
  font-size: 12px;
}

.login-footnote {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.login-footnote .lucide {
  width: 14px;
  height: 14px;
}

.login-busy .lucide {
  animation: spin 800ms linear infinite;
}

.workspace {
  display: grid;
  min-height: calc(100vh - 56px);
  grid-template-columns: 216px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 56px;
  display: flex;
  height: calc(100vh - 56px);
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 10px;
  border-right: 1px solid var(--line-soft);
  background: var(--sidebar);
}

.primary-nav,
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  padding: 7px 9px;
  border-color: transparent;
  color: var(--ink-secondary);
  background: transparent;
  font-size: 13px;
  text-align: left;
}

.nav-item:hover:not(:disabled) {
  border-color: transparent;
  background: var(--surface-hover);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}

.nav-item span:not(.nav-count) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  min-width: 21px;
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-hover);
  font-size: 10px;
  text-align: center;
}

.nav-item.active .nav-count {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

.relay-health {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 7px 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.health-dot,
.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
}

.status-dot.offline {
  background: var(--muted-soft);
}

.relay-health div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.relay-health strong {
  font-size: 11px;
  font-weight: 600;
}

.relay-health span:last-child {
  color: var(--muted);
  font-size: 10px;
}

.content-shell {
  min-width: 0;
  padding: 22px clamp(18px, 3vw, 42px) 42px;
}

.content-header {
  display: flex;
  min-height: 64px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.content-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 650;
}

.content-header > div > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.content-actions,
.device-actions,
.screen-actions,
.local-controls,
.ai-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-panel {
  display: none;
  min-width: 0;
}

.view-panel.active {
  display: block;
}

.metric-strip {
  display: grid;
  margin: 0 0 22px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  min-width: 0;
  padding: 18px 20px;
  border-right: 1px solid var(--line-soft);
}

.metric:first-child {
  padding-left: 0;
}

.metric:last-child {
  border-right: 0;
}

.metric > span,
.metric small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric strong {
  display: block;
  margin: 4px 0 3px;
  overflow: hidden;
  font-size: 25px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-grid,
.account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.section-block,
.screen-section,
.tool-panel,
.wizard-panel {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.section-heading,
.panel-heading,
.tool-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  min-height: 58px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.section-heading h2,
.panel-heading h2,
.tool-heading h2,
.tool-section > h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.section-heading > .lucide {
  color: var(--muted);
}

.overview-device-rows {
  min-height: 184px;
}

.overview-device-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 61px;
  padding: 9px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.overview-device-row:last-child {
  border-bottom: 0;
}

.device-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.device-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 7px;
  color: var(--ink-secondary);
  background: var(--surface-soft);
  place-items: center;
}

.device-identity > div {
  min-width: 0;
}

.device-identity strong,
.device-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-identity strong {
  font-size: 13px;
  font-weight: 600;
}

.device-identity small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.empty-state-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state-inline > .lucide {
  width: 24px;
  height: 24px;
}

.activity-list {
  min-height: 184px;
  max-height: 246px;
  margin: 0;
  padding: 7px 15px;
  overflow-y: auto;
  list-style: none;
}

.activity-list li {
  position: relative;
  padding: 8px 0 8px 16px;
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 1.35;
}

.activity-list li::before {
  position: absolute;
  top: 13px;
  left: 1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  content: "";
}

.activity-list time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.activity-list .activity-empty {
  padding: 70px 0;
  color: var(--muted);
  text-align: center;
}

.activity-list .activity-empty::before {
  display: none;
}

.availability-band,
.task-status-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 13px 15px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}

.availability-band > div,
.task-status-band > span:first-child {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-secondary);
  font-size: 12px;
}

.availability-band .lucide,
.task-status-band .lucide {
  color: var(--success);
}

.status-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  white-space: nowrap;
}

.status-pill.online {
  color: var(--success);
  background: var(--success-soft);
}

.status-pill.offline,
.status-pill.neutral {
  color: var(--muted);
  background: var(--surface-hover);
}

.status-pill.busy {
  color: var(--warning);
  background: var(--warning-soft);
}

.page-section-heading {
  min-height: 64px;
  padding: 0 0 14px;
  border-bottom-color: var(--line);
}

.page-section-heading h2 {
  font-size: 17px;
}

.device-table-wrap {
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.device-table-head,
.device-directory-row {
  display: grid;
  grid-template-columns: minmax(230px, 1.2fr) 110px minmax(160px, 0.8fr) minmax(170px, 0.8fr) 120px;
  align-items: center;
  gap: 12px;
}

.device-table-head {
  min-height: 38px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.device-directory-row {
  min-height: 68px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.device-directory-row:last-child {
  border-bottom: 0;
}

.device-directory-row.selected {
  background: var(--primary-soft);
}

.device-directory-row > span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-directory-empty {
  min-height: 260px;
}

.wizard-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 660px);
  gap: 24px;
  align-items: start;
}

.wizard-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 7px;
  color: var(--muted);
}

.wizard-step > span {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 10px;
  place-items: center;
}

.wizard-step div {
  display: flex;
  flex-direction: column;
}

.wizard-step strong {
  color: inherit;
  font-size: 12px;
}

.wizard-step small {
  margin-top: 2px;
  font-size: 10px;
}

.wizard-step.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.wizard-step.active > span {
  border-color: var(--primary);
  color: #ffffff;
  background: var(--primary);
}

.wizard-panel {
  min-height: 420px;
  padding: 24px;
}

.wizard-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.wizard-icon,
.screen-empty-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--primary);
  background: var(--primary-soft);
  place-items: center;
}

.wizard-head h2 {
  margin: 0;
  font-size: 18px;
}

.wizard-page {
  display: none;
  min-height: 240px;
}

.wizard-page.active {
  display: block;
}

.wizard-page h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.wizard-page > p {
  max-width: 560px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.45;
}

.notice.info {
  border-color: color-mix(in srgb, var(--primary) 22%, var(--line));
  color: #07579d;
  background: var(--primary-soft);
}

.notice.unavailable {
  color: var(--muted);
  background: var(--surface-soft);
}

.verification-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.enrollment-result {
  display: grid;
  max-width: 360px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--success) 28%, var(--line));
  border-radius: 7px;
  background: var(--success-soft);
}

.enrollment-result span,
.enrollment-result small {
  color: var(--muted);
  font-size: 10px;
}

.enrollment-result strong {
  margin: 5px 0;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 21px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

#enrollmentUnavailable {
  margin-top: 12px;
}

.enrollment-history {
  margin-top: 18px;
}

.enrollment-list {
  min-height: 92px;
}

.enrollment-row {
  display: grid;
  min-height: 82px;
  grid-template-columns: minmax(210px, 1fr) minmax(130px, 0.55fr) minmax(260px, 1fr) 68px;
  align-items: center;
  gap: 16px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.enrollment-row:last-child {
  border-bottom: 0;
}

.enrollment-identity,
.enrollment-state,
.enrollment-times,
.enrollment-actions {
  min-width: 0;
}

.enrollment-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.enrollment-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 7px;
  color: var(--primary);
  background: var(--primary-soft);
  place-items: center;
}

.enrollment-identity > div,
.enrollment-state {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.enrollment-identity strong,
.enrollment-identity small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enrollment-identity strong {
  font-size: 12px;
}

.enrollment-identity small,
.enrollment-state small,
.enrollment-times small {
  color: var(--muted);
  font-size: 10px;
}

.status-pill.pending {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-pill.claimed {
  color: var(--success);
  background: var(--success-soft);
}

.status-pill.expired {
  color: var(--muted);
  background: var(--surface-hover);
}

.status-pill.cancelled {
  color: var(--danger);
  background: var(--danger-soft);
}

.enrollment-times {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.enrollment-times > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.enrollment-times time {
  overflow: hidden;
  color: var(--ink-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enrollment-actions {
  display: flex;
  justify-content: flex-end;
}

.enrollment-cancel {
  color: var(--danger) !important;
}

.enrollment-empty {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.enrollment-history-unavailable {
  margin: 14px 15px;
}

.verification-row div {
  display: flex;
  flex-direction: column;
}

.verification-row strong {
  font-size: 12px;
}

.verification-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.wizard-actions {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.wizard-actions > span {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.device-bar {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.device-picker {
  display: flex;
  align-items: center;
  gap: 9px;
}

.device-picker label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.device-picker select {
  min-width: 0;
  flex: 1;
}

.device-meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.control-layout {
  display: grid;
  min-height: 650px;
  grid-template-columns: minmax(480px, 1fr) 380px;
  gap: 12px;
}

.screen-section {
  display: flex;
  overflow: hidden;
  flex-direction: column;
}

.panel-heading {
  min-height: 54px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-heading h2 {
  margin-bottom: 3px;
}

.screen-viewport {
  display: grid;
  min-height: 590px;
  flex: 1;
  padding: 18px;
  overflow: hidden;
  background: var(--screen);
  place-items: center;
}

.screen-surface {
  position: relative;
  width: min(100%, 360px);
  max-height: min(72vh, 720px);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid var(--screen-line);
  border-radius: 8px;
  background: #050506;
  box-shadow: 0 14px 34px rgb(0 0 0 / 30%);
}

#screenCanvas {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
  cursor: crosshair;
}

.screen-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  color: #f5f5f7;
  text-align: center;
}

.screen-empty-icon {
  margin-bottom: 5px;
  color: #b8c0ca;
  background: #24262a;
}

.screen-empty strong {
  font-size: 13px;
  font-weight: 600;
}

.screen-empty > span:last-child {
  color: #8e8e93;
  font-size: 11px;
}

.tool-panel {
  overflow-y: auto;
}

.tool-section {
  padding: 13px;
  border-bottom: 1px solid var(--line-soft);
}

.tool-section:last-child {
  border-bottom: 0;
}

.tool-heading {
  margin-bottom: 10px;
}

.capability-state {
  color: var(--muted);
  font-size: 10px;
}

.capability-state.available {
  color: var(--success);
  font-weight: 600;
}

.capability-state.unavailable {
  color: var(--warning);
  font-weight: 600;
}

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

.key-grid button {
  min-width: 0;
  min-height: 54px;
  flex-direction: column;
  gap: 4px;
  padding: 6px 4px;
  border-color: var(--line-soft);
  font-size: 10px;
}

.key-grid button .lucide {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.key-grid button:disabled .lucide {
  color: var(--muted-soft);
}

.local-controls {
  margin-top: 7px;
}

.local-controls button {
  min-width: 0;
  flex: 1;
  padding-inline: 6px;
  font-size: 10px;
}

.split-tool-section {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 14px;
}

.direction-pad {
  display: grid;
  width: 124px;
  margin: 10px auto 0;
  grid-template-columns: repeat(3, 36px);
  grid-template-rows: repeat(3, 34px);
  gap: 5px;
}

.direction-pad button {
  min-height: 34px;
  padding: 0;
}

.pad-center {
  display: grid;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  color: var(--muted-soft);
  background: var(--surface-soft);
  place-items: center;
}

.pad-center .lucide {
  width: 14px;
  height: 14px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 6px;
  margin-top: 7px;
}

.inline-form input {
  min-width: 0;
  font-size: 11px;
}

.inline-form button {
  min-width: 0;
  padding-inline: 5px;
  font-size: 10px;
}

.ai-section {
  box-shadow: inset 3px 0 0 var(--warning);
}

.ai-actions {
  margin-top: 7px;
}

.ai-actions button {
  flex: 1;
}

#aiStatus {
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.task-status-band {
  margin: 14px 0 0;
  border-radius: 8px 8px 0 0;
}

.status-log {
  min-height: 440px;
  max-height: calc(100vh - 290px);
  margin: 0;
  padding: 12px 15px;
  overflow-y: auto;
  border: 1px solid #303136;
  color: #e6e6e8;
  background: #1d1d1f;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  list-style: none;
}

.status-log li {
  padding: 4px 0;
  overflow-wrap: anywhere;
}

.status-log time {
  margin-right: 10px;
  color: #8e8e93;
}

.task-api-note {
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.detail-list {
  margin: 0;
  padding: 5px 15px 11px;
}

.detail-list > div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.detail-list > div:last-child {
  border-bottom: 0;
}

.detail-list dt,
.detail-list dd {
  margin: 0;
  font-size: 12px;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.capability-list {
  display: flex;
  min-height: 70px;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 15px;
}

.capability-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  color: var(--ink-secondary);
  background: var(--surface-soft);
  font-size: 10px;
}

.capability-chip::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  content: "";
}

.quota-unavailable {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 15px 15px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--surface-soft);
}

.quota-unavailable > span {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  place-items: center;
}

.quota-unavailable strong {
  font-size: 12px;
}

.quota-unavailable p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

@media (max-width: 1120px) {
  .control-layout {
    grid-template-columns: minmax(440px, 1fr) 350px;
  }

  .device-table-head,
  .device-directory-row {
    grid-template-columns: minmax(220px, 1fr) 90px minmax(140px, 0.7fr) 110px;
  }

  .device-table-head > :nth-child(4),
  .device-directory-row > :nth-child(4) {
    display: none;
  }
}

@media (max-width: 960px) {
  .workspace {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 35;
    top: 56px;
    height: auto;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    flex-direction: row;
    padding: 6px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .primary-nav,
  .sidebar-footer {
    flex-direction: row;
  }

  .nav-item {
    width: auto;
    min-width: max-content;
  }

  .nav-count {
    margin-left: 2px;
  }

  .relay-health {
    display: none;
  }

  .content-shell {
    padding: 18px 18px 34px;
  }

  .overview-grid,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .control-layout {
    grid-template-columns: 1fr;
  }

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

  .tool-section:nth-child(odd) {
    border-right: 1px solid var(--line-soft);
  }

  .ai-section {
    grid-column: 1 / -1;
  }

  .screen-viewport {
    min-height: 600px;
  }

  .enrollment-row {
    grid-template-columns: minmax(190px, 1fr) minmax(120px, 0.55fr) minmax(220px, 0.9fr) 64px;
    gap: 12px;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 0 12px;
  }

  .transport-badge {
    display: none;
  }

  .login-shell {
    display: block;
    width: min(430px, 100%);
  }

  .login-brand {
    min-height: 96px;
  }

  .login-brand .lucide {
    width: 38px;
    height: 38px;
  }

  .login-panel {
    padding: 28px;
  }

  .content-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .content-actions {
    width: 100%;
  }

  .content-actions button {
    min-width: 0;
    flex: 1;
  }

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

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line-soft);
  }

  .metric:nth-child(3) {
    padding-left: 0;
  }

  .device-table-head {
    display: none;
  }

  .device-directory-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 12px 4px;
  }

  .device-directory-row > :nth-child(3),
  .device-directory-row > :nth-child(4) {
    display: none;
  }

  .wizard-layout {
    display: block;
  }

  .wizard-steps {
    flex-direction: row;
    margin-bottom: 12px;
  }

  .wizard-step {
    min-width: 0;
    flex: 1;
  }

  .wizard-step div {
    display: none;
  }

  .wizard-step > span {
    margin: auto;
  }

  .enrollment-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
  }

  .enrollment-state {
    align-items: flex-end;
  }

  .enrollment-state small {
    text-align: right;
  }

  .enrollment-times {
    grid-column: 1 / 2;
  }

  .enrollment-actions {
    grid-column: 2;
    align-self: end;
  }

  .device-bar {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .device-picker,
  .device-actions {
    width: 100%;
  }

  .device-picker select,
  .device-actions button {
    min-width: 0;
    flex: 1;
  }

  .screen-viewport {
    min-height: 530px;
    padding: 10px;
  }

  .tool-panel {
    display: block;
  }

  .tool-section:nth-child(odd) {
    border-right: 0;
  }

  .split-tool-section {
    grid-template-columns: 140px minmax(0, 1fr);
  }

  .status-log {
    min-height: 360px;
    max-height: 58vh;
  }
}

@media (max-width: 480px) {
  .brand-copy strong {
    font-size: 14px;
  }

  .connection-status {
    max-width: 120px;
  }

  .content-shell {
    padding: 14px 10px 28px;
  }

  .content-header h1 {
    font-size: 21px;
  }

  .content-actions .secondary {
    display: none;
  }

  .metric {
    padding: 14px 12px;
  }

  .metric strong {
    font-size: 22px;
  }

  .overview-device-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .overview-device-row > :nth-child(2) {
    display: none;
  }

  .availability-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .wizard-panel {
    padding: 18px;
  }

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

  .wizard-actions > span {
    display: none;
  }

  .enrollment-row {
    padding: 12px 10px;
  }

  .enrollment-state small {
    display: none;
  }

  .enrollment-times {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .enrollment-cancel span {
    display: none;
  }

  .screen-viewport {
    min-height: 470px;
  }

  .screen-surface {
    width: min(100%, 290px);
  }

  .split-tool-section {
    display: block;
  }

  .input-tools {
    margin-top: 16px;
  }

  .detail-list > div {
    grid-template-columns: 95px minmax(0, 1fr);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f5f5f7;
    --ink-secondary: #d1d1d6;
    --muted: #98989d;
    --muted-soft: #7c7c80;
    --surface: #1c1c1e;
    --surface-raised: #232325;
    --surface-soft: #101011;
    --surface-hover: #2c2c2e;
    --line: #48484a;
    --line-soft: #38383a;
    --sidebar: #161617;
    --primary: #0a84ff;
    --primary-hover: #409cff;
    --primary-soft: #0c2d4f;
    --success: #30d158;
    --success-soft: #143820;
    --warning: #ff9f0a;
    --warning-soft: #3d2b0d;
    --danger: #ff453a;
    --danger-hover: #ff6961;
    --danger-soft: #4a1717;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 24%);
    --shadow-md: 0 14px 36px rgb(0 0 0 / 38%);
  }

  .brand-mark,
  .login-brand {
    color: #1d1d1f;
    background: #f5f5f7;
  }

  .topbar {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
  }

  .notice.info {
    color: #8cc8ff;
  }

  .screen-viewport {
    background: #09090a;
  }
}
