@font-face {
  font-family: "Spark Sans";
  src: local("PingFang SC"), local("Microsoft YaHei"), local("Noto Sans CJK SC");
  font-display: swap;
}

:root {
  color: #17191d;
  background: #f3f5f7;
  font-family: "Spark Sans", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --accent: #ec3157;
  --accent-hover: #d82449;
  --ink: #17191d;
  --muted: #6f7580;
  --line: #e3e6ea;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --success: #16865a;
  --warning: #ad6800;
  --danger: #bf203f;
  --focus: #177ddc;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  background: #f3f5f7;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  min-height: 64px;
  padding: 0 22px;
  border-bottom: 1px solid #dedfe2;
  background: rgba(255, 255, 255, 0.98);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  background: var(--surface);
}

.brand-mark::before,
.brand-mark span {
  position: absolute;
  width: 12px;
  height: 12px;
  content: "";
}

.brand-mark::before {
  top: 6px;
  left: 7px;
  border-top: 3px solid #25c6c0;
  border-left: 3px solid #25c6c0;
}

.brand-mark span {
  right: 6px;
  bottom: 6px;
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
}

.brand strong,
.brand > div:last-child > span {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 20px;
}

.brand > div:last-child > span {
  color: var(--muted);
  font-size: 11px;
  line-height: 15px;
}

.view-tabs {
  display: flex;
  justify-self: center;
  align-self: stretch;
  gap: 26px;
}

.view-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 104px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: #737985;
  cursor: pointer;
}

.view-tab svg {
  width: 18px;
  height: 18px;
}

.view-tab::after {
  position: absolute;
  right: 6px;
  bottom: 0;
  left: 6px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: transparent;
  content: "";
}

.view-tab.is-active {
  color: var(--ink);
  font-weight: 650;
}

.view-tab.is-active::after {
  background: var(--accent);
}

.topbar-actions,
.detail-actions,
.action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.service-state,
.status-badge,
.inline-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.service-state {
  color: #4f5661;
  font-size: 12px;
  white-space: nowrap;
}

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

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

.button {
  min-height: 38px;
  gap: 7px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.button svg {
  width: 17px;
  height: 17px;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.button-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-secondary {
  border-color: #d8dbe0;
  background: white;
  color: #343941;
}

.button-secondary:hover {
  border-color: #b7bbc2;
  background: #f8f9fa;
}

.button-ghost {
  background: transparent;
  color: #555c67;
}

.button-ghost:hover {
  background: #f2f3f5;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-color: #dfe2e6;
  background: white;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button:hover {
  border-color: #b9bec6;
  background: #f7f8f9;
}

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

.icon-button.danger:hover {
  border-color: #efb1be;
  background: #fff4f6;
}

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

.account-sidebar {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #f8f9fa;
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading h2,
.section-heading h2,
.logs-header h1,
.modal-header h2 {
  margin: 0;
}

.sidebar-heading h2 {
  font-size: 15px;
}

.sidebar-heading > div > span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.account-list {
  padding: 8px;
}

.account-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 62px;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.account-row:hover {
  background: #eef0f2;
}

.account-row.is-active {
  border-color: #e0c1c8;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 24, 29, 0.04);
}

.account-row-copy {
  min-width: 0;
}

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

.account-row-copy strong {
  font-size: 13px;
  line-height: 20px;
}

.account-row-copy span {
  color: var(--muted);
  font-size: 11px;
  line-height: 18px;
}

.account-row-count {
  min-width: 25px;
  color: #656b75;
  font-size: 11px;
  text-align: right;
}

.avatar,
.large-avatar {
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid #dddfe3;
  border-radius: 7px;
  background: #22252a;
  color: white;
  font-weight: 750;
  text-transform: uppercase;
}

.avatar {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

.large-avatar {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.avatar.is-logged-in,
.large-avatar.is-logged-in {
  border-color: #66b89a;
  background: #146b4d;
}

.account-workspace {
  min-width: 0;
  background: var(--surface);
}

.empty-state {
  display: flex;
  min-height: calc(100vh - 64px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

.empty-state.compact {
  min-height: 260px;
}

.empty-state .empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid #dfe2e6;
  border-radius: 8px;
  background: #f7f8f9;
  color: #606772;
}

.empty-state .empty-icon svg {
  width: 24px;
  height: 24px;
}

.empty-state h1 {
  margin: 18px 0 6px;
  font-size: 20px;
}

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

.account-detail {
  min-width: 0;
  padding-bottom: 92px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
}

.account-identity,
.title-line,
.section-heading,
.heading-copy {
  display: flex;
  align-items: center;
}

.account-identity {
  min-width: 0;
  gap: 13px;
}

.account-identity > div:last-child {
  min-width: 0;
}

.title-line {
  min-width: 0;
  gap: 9px;
}

.title-line h1 {
  overflow: hidden;
  margin: 0;
  font-size: 19px;
  line-height: 27px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-identity p {
  margin: 2px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.status-badge {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid #dedfe3;
  border-radius: 12px;
  background: #f6f7f8;
  color: #606772;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.status-badge.logged-in {
  border-color: #a7dbc7;
  background: #effaf6;
  color: #126b4b;
}

.status-badge.waiting {
  border-color: #ebcc94;
  background: #fff8e8;
  color: #8b5700;
}

.workflow-section {
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.auth-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: #fbfcfd;
}

.section-heading,
.heading-copy {
  min-width: 0;
  gap: 12px;
}

.section-heading h2 {
  font-size: 15px;
  line-height: 22px;
}

.section-heading p,
.logs-header p,
.modal-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.step-index {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border: 1px solid #d7dade;
  border-radius: 6px;
  background: white;
  color: #444a53;
  font-size: 12px;
  font-weight: 750;
}

.inline-status {
  color: #555c66;
  font-size: 12px;
  white-space: nowrap;
}

.inline-status .status-dot {
  background: #9298a2;
}

.inline-status.logged-in .status-dot {
  background: var(--success);
}

.inline-status.waiting .status-dot {
  background: #e49a18;
}

.friends-section {
  padding-bottom: 20px;
}

.friends-heading {
  justify-content: space-between;
  gap: 20px;
}

.friend-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 11px 0;
  border-top: 1px solid #eceef1;
  border-bottom: 1px solid #eceef1;
}

.search-field,
.manual-friend-form {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid #d8dbe0;
  border-radius: 6px;
  background: white;
}

.search-field {
  gap: 8px;
  padding: 0 11px;
}

.search-field svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: #858b95;
}

.search-field input,
.manual-friend-form input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.select-all-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #555c66;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

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

.manual-friend-form {
  justify-self: end;
  width: min(100%, 300px);
  padding-left: 11px;
}

.manual-friend-form .icon-button {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  border: 0;
  border-left: 1px solid #e2e4e7;
  border-radius: 0 5px 5px 0;
}

.friend-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 440px;
  overflow: auto;
  border-bottom: 1px solid #eceef1;
}

.friend-row {
  display: grid;
  grid-template-columns: 18px 36px minmax(0, 1fr);
  align-items: center;
  min-height: 58px;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid #eff0f2;
  cursor: pointer;
}

.friend-row:nth-child(odd) {
  border-right: 1px solid #eff0f2;
}

.friend-row:hover {
  background: #fafbfc;
}

.friend-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: #eceff2;
  color: #4d535c;
  font-size: 12px;
  font-weight: 750;
}

.friend-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 280px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  gap: 18px;
  padding: 14px 28px;
  border-top: 1px solid #dfe2e6;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -5px 18px rgba(30, 34, 40, 0.06);
}

.action-bar > div:first-child strong,
.action-bar > div:first-child span {
  display: block;
}

.action-bar > div:first-child strong {
  font-size: 13px;
}

.action-bar > div:first-child span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.logs-view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 26px 50px;
}

.login-view {
  min-height: calc(100vh - 64px);
  background: var(--surface);
}

.login-page-header {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 82px;
  gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.login-page-header h1 {
  margin: 0;
  font-size: 19px;
  line-height: 27px;
}

.login-page-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.login-page-body {
  display: grid;
  min-height: calc(100vh - 146px);
  place-items: center;
  padding: 34px 22px 54px;
}

.login-page-body.is-challenge {
  place-items: start center;
}

.login-panel {
  width: min(100%, 520px);
}

.login-panel.is-challenge {
  width: min(100%, 920px);
}

.login-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 22px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.login-mode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 42px;
  gap: 7px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.login-mode-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.login-mode-button.is-active {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(23, 25, 29, 0.1);
  color: var(--ink);
}

.login-mode-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.login-pane {
  width: 100%;
}

.login-view .qr-stage {
  min-height: 400px;
  background: white;
}

.login-view .qr-stage img {
  width: auto;
  max-width: 88%;
  max-height: 380px;
}

.credential-form {
  padding: 16px 0 8px;
}

.credential-field {
  display: block;
  margin-bottom: 18px;
}

.credential-field > span:first-child {
  display: block;
  margin-bottom: 7px;
  color: #474d56;
  font-size: 12px;
  font-weight: 650;
}

.credential-field > input,
.phone-input,
.code-input > input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #d3d7dc;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

.credential-field > input,
.code-input > input {
  padding: 0 13px;
}

.phone-input {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
}

.phone-input b {
  padding-left: 14px;
  border-right: 1px solid var(--line);
  color: #4d535d;
  font-size: 13px;
  font-weight: 650;
  line-height: 24px;
}

.phone-input input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 13px;
  border: 0;
  outline: 0;
}

.code-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.code-input .button {
  min-width: 132px;
  min-height: 46px;
}

.credential-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
}

.credential-status {
  min-height: 20px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

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

.credential-status.success {
  color: var(--success);
}

.challenge-pane {
  width: 100%;
}

.challenge-heading,
.challenge-heading > div,
.challenge-heading-actions {
  display: flex;
  align-items: center;
}

.challenge-heading {
  justify-content: space-between;
  min-height: 44px;
  gap: 14px;
  margin-bottom: 10px;
}

.challenge-heading > div:first-child {
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.challenge-heading > div:first-child svg {
  width: 19px;
  height: 19px;
  color: var(--success);
}

.challenge-heading-actions {
  gap: 8px;
}

.challenge-stage {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1280 / 820;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d9dce1;
  border-radius: 7px;
  background: #17191d;
}

.challenge-stage .qr-loading {
  position: absolute;
  color: #d7dbe1;
}

.challenge-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}

.challenge-text-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.challenge-text-form input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid #d3d7dc;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.challenge-text-form .button {
  min-width: 94px;
}

.session-label {
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.logs-header h1 {
  font-size: 20px;
}

.log-output {
  min-height: 520px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  margin: 0;
  padding: 18px;
  border: 1px solid #30343a;
  border-radius: 7px;
  background: #16181c;
  color: #d5dae1;
  font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal {
  width: min(92vw, 480px);
  max-height: 90vh;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 24px 70px rgba(16, 20, 26, 0.24);
}

.modal::backdrop {
  background: rgba(20, 23, 28, 0.58);
}

.modal-panel {
  margin: 0;
  padding: 22px;
  border-radius: 8px;
  background: white;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.modal-header h2 {
  font-size: 18px;
}

.mfa-dialog-icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid #b8dfcf;
  border-radius: 7px;
  background: #f1fbf7;
  color: var(--success);
}

.mfa-dialog-icon svg {
  width: 19px;
  height: 19px;
}

.field-label {
  display: block;
  margin-top: 16px;
}

.field-label > span {
  display: block;
  margin-bottom: 7px;
  color: #474d56;
  font-size: 12px;
  font-weight: 650;
}

.field-label input {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid #d3d7dc;
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.qr-modal {
  width: min(94vw, 520px);
}

.qr-stage {
  display: grid;
  width: 100%;
  min-height: 340px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #e1e3e6;
  border-radius: 7px;
  background: #f5f6f8;
}

.qr-stage img {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 420px;
  object-fit: contain;
}

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

.qr-success {
  color: var(--success);
}

.qr-success svg {
  width: 42px;
  height: 42px;
}

.qr-success strong {
  color: #155f45;
  font-size: 17px;
}

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

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #dadddf;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.pulse {
  animation: pulse 1.4s ease-in-out infinite;
}

.qr-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: grid;
  width: min(360px, calc(100vw - 40px));
  gap: 9px;
}

.toast {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 12px 13px;
  border: 1px solid #d7dade;
  border-left: 4px solid #555c66;
  border-radius: 6px;
  background: white;
  box-shadow: 0 12px 35px rgba(17, 21, 27, 0.15);
  color: #343941;
  font-size: 13px;
  line-height: 19px;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 0 14px;
  }

  .brand {
    min-width: 0;
  }

  .view-tabs {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    justify-content: center;
    min-height: 58px;
    gap: 32px;
    border-top: 1px solid #dfe2e6;
    background: white;
  }

  .view-tab {
    min-width: 110px;
  }

  .topbar-actions .service-state,
  #run-all-btn span {
    display: none;
  }

  #run-all-btn {
    width: 38px;
    padding: 0;
  }

  .workspace,
  .login-view {
    display: block;
    padding-bottom: 58px;
  }

  .account-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-heading {
    min-height: 62px;
  }

  .account-list {
    display: flex;
    overflow-x: auto;
    padding: 8px 12px 10px;
  }

  .account-row {
    width: 220px;
    flex: 0 0 220px;
  }

  .detail-header,
  .workflow-section {
    padding-right: 18px;
    padding-left: 18px;
  }

  .action-bar {
    right: 0;
    bottom: 58px;
    left: 0;
    padding-right: 18px;
    padding-left: 18px;
  }

  .logs-view {
    padding-bottom: 80px;
  }

  .login-page-header {
    min-height: 76px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .login-page-body {
    min-height: calc(100vh - 198px);
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 58px;
  }

  .brand > div:last-child > span {
    display: none;
  }

  .workspace {
    min-height: calc(100vh - 58px);
  }

  .login-page-header {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
  }

  .login-page-header #refresh-qr-btn {
    width: 38px;
    padding: 0;
  }

  .login-page-header #refresh-qr-btn span {
    display: none;
  }

  .login-mode-switch {
    gap: 2px;
  }

  .login-mode-button {
    gap: 5px;
    padding: 0 6px;
    font-size: 12px;
  }

  .login-mode-button svg {
    width: 15px;
    height: 15px;
    flex-basis: 15px;
  }

  .login-page-body {
    padding: 22px 12px 42px;
  }

  .challenge-heading {
    margin-bottom: 8px;
  }

  .challenge-text-form .button {
    min-width: 82px;
    padding: 0 11px;
  }

  .detail-header {
    align-items: flex-start;
    min-height: 82px;
  }

  .detail-actions .button span {
    display: none;
  }

  .detail-actions .button {
    width: 38px;
    padding: 0;
  }

  .auth-summary,
  .friends-heading,
  .action-bar {
    align-items: flex-start;
  }

  .auth-summary,
  .friends-heading {
    flex-direction: column;
  }

  .friends-heading .button {
    align-self: stretch;
  }

  .friend-toolbar {
    grid-template-columns: 1fr;
  }

  .manual-friend-form {
    justify-self: stretch;
    width: 100%;
  }

  .friend-list {
    grid-template-columns: 1fr;
  }

  .friend-row:nth-child(odd) {
    border-right: 0;
  }

  .action-bar {
    min-height: 82px;
    gap: 10px;
  }

  .action-bar > div:first-child span {
    display: none;
  }

  .action-buttons {
    flex: 1;
    justify-content: flex-end;
  }

  .action-buttons .button {
    padding: 0 10px;
  }

  #save-friends-btn span {
    display: none;
  }

  .qr-stage {
    min-height: 290px;
  }

  .login-view .qr-stage {
    min-height: 330px;
  }

  .code-input {
    grid-template-columns: minmax(0, 1fr) 120px;
  }

  .code-input .button {
    min-width: 120px;
    padding: 0 10px;
  }

  .qr-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .qr-footer .button {
    width: 100%;
  }
}

/* SaaS account, task and administration surfaces */
.platform-auth-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 18px;
  background:
    linear-gradient(90deg, rgba(37, 198, 192, 0.08) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(rgba(236, 49, 87, 0.06) 1px, transparent 1px) 0 0 / 48px 48px,
    #f3f5f7;
}

.platform-auth-panel {
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid #dfe2e6;
  border-radius: 8px;
  background: white;
  box-shadow: 0 16px 50px rgba(30, 34, 40, 0.1);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand strong {
  font-size: 20px;
}

.auth-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.auth-tabs,
.admin-section-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 7px;
  background: #f0f2f4;
}

.auth-tab,
.admin-section-tab {
  min-height: 36px;
  flex: 1;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #666d77;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.auth-tab.is-active,
.admin-section-tab.is-active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(30, 34, 40, 0.1);
}

.platform-auth-form,
.settings-form {
  display: grid;
  gap: 15px;
  margin-top: 20px;
}

.platform-auth-form label,
.settings-form label,
.task-config-grid label {
  display: grid;
  gap: 7px;
  color: #4f5660;
  font-size: 12px;
  font-weight: 650;
}

.platform-auth-form input,
.settings-form input,
.settings-form textarea,
.task-config-grid input,
.task-config-grid textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid #d7dade;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  resize: vertical;
}

.platform-auth-status {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 20px;
}

.user-chip {
  min-width: 86px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.site-announcement {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border-bottom: 1px solid #ead8a9;
  background: #fff8e8;
  color: #76500b;
  font-size: 12px;
}

.site-announcement svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.mfa-code-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.mfa-code-tools .button {
  min-width: 0;
}

@media (max-width: 480px) {
  .mfa-code-tools {
    grid-template-columns: 1fr;
  }
}

.user-chip span,
.user-chip small {
  display: block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip span {
  font-size: 12px;
  font-weight: 700;
}

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

.topbar {
  grid-template-columns: 210px minmax(420px, 1fr) auto;
}

.view-tabs {
  gap: 8px;
}

.view-tab {
  min-width: 86px;
}

.task-config-section {
  background: #fbfcfd;
}

.task-config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.task-config-grid .toggle-field,
.settings-form .toggle-field {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid #d7dade;
  border-radius: 6px;
  background: white;
}

.task-config-grid .toggle-field input,
.settings-form .toggle-field input {
  width: 17px;
  min-height: 17px;
  flex: 0 0 17px;
}

.task-message-field {
  grid-column: 1 / -1;
}

.task-config-actions {
  grid-column: 1 / -1;
  text-align: right;
}

.page-view,
.logs-view {
  min-height: calc(100vh - 64px);
  padding: 28px;
  background: #f5f6f8;
}

.page-header,
.data-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-header {
  margin-bottom: 22px;
}

.page-header h1,
.data-panel-header h2 {
  margin: 0;
}

.page-header h1 {
  font-size: 22px;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  min-height: 86px;
  gap: 4px 10px;
  padding: 14px;
  border: 1px solid #dfe2e6;
  border-radius: 7px;
  background: white;
}

.metric svg {
  grid-row: 1 / 3;
  width: 22px;
  color: var(--accent);
}

.metric span {
  color: var(--muted);
  font-size: 11px;
}

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

.data-panel {
  overflow: hidden;
  border: 1px solid #dfe2e6;
  border-radius: 7px;
  background: white;
}

.data-panel + .data-panel {
  margin-top: 18px;
}

.data-panel-header {
  min-height: 55px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.data-panel-header h2 {
  font-size: 14px;
}

.data-panel-header > span {
  color: var(--muted);
  font-size: 11px;
}

.data-panel-header > div {
  display: flex;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #eceef1;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: #fafbfc;
  color: #676e78;
  font-size: 11px;
  font-weight: 650;
}

td strong,
td small {
  display: block;
}

td small {
  max-width: 180px;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  text-overflow: ellipsis;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.table-empty {
  height: 100px;
  color: var(--muted);
  text-align: center;
}

.table-status,
.risk-level {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  background: #eef0f2;
  color: #5b626c;
  font-size: 11px;
  font-weight: 650;
}

.status-success,
.status-active,
.status-resolved {
  background: #eaf8f2;
  color: #116b4b;
}

.status-running,
.status-queued,
.status-open {
  background: #fff4d9;
  color: #8a5700;
}

.status-failed,
.status-frozen,
.status-disabled,
.status-blocked {
  background: #fff0f3;
  color: var(--danger);
}

.table-action {
  padding: 3px 7px;
  border: 0;
  background: transparent;
  color: #176db5;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.table-action.danger {
  color: var(--danger);
}

.row-actions {
  display: flex;
  gap: 2px;
}

.device-cell {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.plan-item {
  padding: 22px;
  border: 1px solid #dfe2e6;
  border-radius: 7px;
  background: white;
}

.plan-item.is-current {
  border-color: #ed9caf;
  box-shadow: inset 0 3px var(--accent);
}

.plan-item > div > span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.plan-item h2 {
  margin: 5px 0 18px;
  font-size: 21px;
}

.plan-item dl,
.profile-summary dl {
  margin: 0 0 20px;
}

.plan-item dl > div,
.profile-summary dl > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid #eef0f2;
}

.plan-item dt,
.profile-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.plan-item dd,
.profile-summary dd {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

.plan-item .button {
  width: 100%;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.profile-grid .data-panel + .data-panel {
  margin-top: 0;
}

.profile-summary dl,
.settings-form {
  padding: 4px 18px 18px;
}

.admin-section-tabs {
  max-width: 620px;
  margin-bottom: 14px;
}

.admin-settings-form {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  padding: 0 18px 18px;
}

.admin-settings-form label:nth-child(2) {
  grid-column: span 2;
}

.admin-settings-form button {
  width: max-content;
}

.risk-critical,
.risk-high {
  background: #fff0f3;
  color: var(--danger);
}

.risk-medium {
  background: #fff4d9;
  color: #8a5700;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 170px minmax(360px, 1fr) auto;
  }

  .view-tab {
    min-width: 66px;
  }

  .view-tab span,
  .topbar-actions .user-chip,
  .topbar-actions .service-state {
    display: none;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .task-config-grid {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .view-tabs {
    gap: 0;
    overflow-x: auto;
  }

  .view-tab {
    min-width: 64px;
    justify-content: center;
  }

  .view-tab span {
    display: none;
  }

  .page-view,
  .logs-view {
    min-height: calc(100vh - 116px);
    padding: 20px 14px 78px;
  }

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

@media (max-width: 680px) {
  .platform-auth-panel {
    padding: 22px;
  }

  .topbar-actions .user-chip,
  #logout-btn {
    display: none;
  }

  .task-config-grid,
  .profile-grid,
  .admin-settings-form {
    grid-template-columns: 1fr;
  }

  .admin-settings-form label:nth-child(2) {
    grid-column: auto;
  }

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

  .page-header {
    align-items: flex-start;
  }

  .admin-section-tabs {
    overflow-x: auto;
  }

  .admin-section-tab {
    min-width: 72px;
    flex: 0 0 auto;
  }
}
