:root {
  --brand-pink: #de3d96;
  --brand-purple: #924199;
  --brand-purple-hover: #78347e;
  --ink: #191919;
  --secondary: #66666b;
  --tertiary: #86868b;
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --surface-hover: #f7f7f9;
  --control-fill: #ededf0;
  --separator: #d2d2d7;
  --separator-soft: #e5e5ea;
  --focus-ring: rgb(222 61 150 / 32%);
  --success: #176b47;
  --success-bg: #edf8f1;
  --danger: #a52a21;
  --danger-bg: #fff1ef;
  --warning: #7a4b0e;
  --warning-bg: #fff7e8;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  border-bottom: 1px solid rgb(210 210 215 / 84%);
  background: rgb(255 255 255 / 88%);
  backdrop-filter: saturate(180%) blur(18px);
}

.topbar-inner {
  width: min(1120px, calc(100% - 40px));
  min-height: 64px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
}

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

.brand-logo {
  display: block;
  width: 132px;
  height: auto;
  flex: 0 0 auto;
}

.product-name {
  min-width: 0;
  padding-left: 12px;
  border-left: 1px solid var(--separator);
  color: var(--secondary);
  font-size: 13px;
  line-height: 20px;
  white-space: nowrap;
}

.release-label {
  min-width: 0;
  padding: 2px 6px;
  border: 1px solid rgb(146 65 153 / 42%);
  border-radius: 5px;
  background: rgb(146 65 153 / 7%);
  color: var(--brand-purple);
  font-size: 10px;
  font-weight: 650;
  line-height: 14px;
  text-transform: uppercase;
  white-space: nowrap;
}

.mode-tabs {
  min-width: 360px;
  min-height: 36px;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  border-radius: 8px;
  background: var(--control-fill);
}

.mode-tab {
  position: relative;
  min-width: 0;
  min-height: 30px;
  padding: 4px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 22px;
  white-space: nowrap;
  cursor: pointer;
}

.mode-tab:hover {
  background: rgb(255 255 255 / 52%);
  color: var(--ink);
}

.mode-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(25 25 25 / 14%);
}

.count {
  display: inline-flex;
  min-width: 18px;
  height: 18px;
  margin-left: 4px;
  padding: 0 5px;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--brand-purple);
  color: var(--surface);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
}

.topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.identity {
  min-width: 0;
  overflow: hidden;
  color: var(--secondary);
  font-size: 13px;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

section {
  width: 100%;
}

.login-view {
  min-height: min(620px, calc(100vh - 176px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.login-mark {
  display: block;
  width: 92px;
  height: 92px;
  margin-bottom: 12px;
  object-fit: contain;
}

.login-view h1 {
  font-size: 28px;
  line-height: 36px;
}

.login-view p {
  margin: 8px 0 24px;
}

.login-view .button {
  min-width: 176px;
}

.loading-view {
  min-height: min(520px, calc(100vh - 176px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--secondary);
  font-size: 14px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--separator);
  border-top-color: var(--brand-purple);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 650;
  line-height: 36px;
}

h2 {
  margin: 0 0 5px;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
}

p {
  margin: 7px 0 0;
  color: var(--secondary);
  font-size: 14px;
  line-height: 22px;
}

.page-heading {
  min-height: 104px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.page-heading > div {
  min-width: 0;
}

.status {
  min-height: 28px;
  padding: 3px 10px 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--separator);
  border-radius: 14px;
  background: var(--surface);
  color: var(--secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}

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

.status.ready,
.status.approved,
.status.connected {
  border-color: #a9cfbc;
  background: var(--success-bg);
  color: var(--success);
}

.status.ready::before,
.status.approved::before,
.status.connected::before {
  background: var(--success);
}

.status.pending,
.status.pending_admin,
.status.starting,
.status.updating,
.status.missing,
.status.provisioned {
  border-color: #e1c38d;
  background: var(--warning-bg);
  color: var(--warning);
}

.status.pending::before,
.status.pending_admin::before,
.status.starting::before,
.status.updating::before,
.status.missing::before,
.status.provisioned::before {
  background: #b36b0b;
}

.status.error,
.status.rejected,
.status.unavailable,
.status.unhealthy,
.status.exited,
.status.disabled {
  border-color: #dfaaa5;
  background: var(--danger-bg);
  color: var(--danger);
}

.status.error::before,
.status.rejected::before,
.status.unavailable::before,
.status.unhealthy::before,
.status.exited::before,
.status.disabled::before {
  background: var(--danger);
}

.facts {
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--separator-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(25 25 25 / 3%);
}

.facts div {
  min-width: 0;
  min-height: 86px;
  padding: 18px 20px;
}

.facts div + div {
  border-left: 1px solid var(--separator-soft);
}

.facts dt {
  margin-bottom: 7px;
  color: var(--tertiary);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
}

.workflow-list {
  overflow: hidden;
  border: 1px solid var(--separator-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(25 25 25 / 3%);
}

.workflow {
  min-height: 112px;
  padding: 22px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
}

.workflow + .workflow {
  border-top: 1px solid var(--separator-soft);
}

.workflow-copy {
  min-width: 0;
}

.workflow-copy p {
  margin: 0;
}

.workflow-copy .workflow-detail {
  margin-top: 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

button,
a.button {
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--separator);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 24px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

button:hover,
a.button:hover {
  border-color: #b9b9bf;
  background: var(--surface-hover);
}

button:active,
a.button:active {
  background: #e9e9ed;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
.table-scroll:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

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

.primary,
a.button.primary {
  border-color: var(--brand-purple);
  background: var(--brand-purple);
  color: var(--surface);
  box-shadow: 0 1px 1px rgb(25 25 25 / 8%);
}

.primary:hover,
a.button.primary:hover {
  border-color: var(--brand-purple-hover);
  background: var(--brand-purple-hover);
}

.primary:active,
a.button.primary:active {
  border-color: #67306b;
  background: #67306b;
}

a.button.primary[aria-disabled="true"] {
  pointer-events: none;
  border-color: var(--separator);
  background: var(--separator-soft);
  color: var(--tertiary);
  box-shadow: none;
}

.quiet {
  min-height: 36px;
  padding: 5px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--secondary);
  font-size: 13px;
}

.quiet:hover {
  border-color: transparent;
  background: var(--control-fill);
  color: var(--ink);
}

.danger {
  border-color: #d7aaa6;
  color: var(--danger);
}

.danger:hover {
  border-color: #c9827c;
  background: var(--danger-bg);
}

.verification {
  width: fit-content;
  max-width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-radius: 7px;
  background: var(--canvas);
}

.verification a {
  color: #713579;
  font-size: 13px;
  font-weight: 600;
  line-height: 22px;
}

.verification code {
  min-width: 0;
  padding: 3px 7px;
  overflow-wrap: anywhere;
  border: 1px solid var(--separator);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 20px;
}

.weixin-verification {
  width: fit-content;
  max-width: 100%;
  margin-top: 12px;
  display: grid;
  grid-template-columns: 216px minmax(0, 220px);
  align-items: center;
  gap: 14px;
}

.weixin-verification img {
  width: 216px;
  height: 216px;
  padding: 8px;
  border: 1px solid var(--separator-soft);
  border-radius: 7px;
  background: #fff;
  object-fit: contain;
}

.weixin-verification p {
  color: var(--secondary);
  font-size: 13px;
  line-height: 20px;
}

.inline-form {
  min-height: 92px;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid var(--separator-soft);
  border-radius: 8px;
  background: var(--surface);
}

input,
select {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--separator);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 24px;
}

select {
  padding-right: 36px;
}

.admin-heading {
  min-height: 96px;
}

.admin-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-scroll {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--separator-soft);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(25 25 25 / 3%);
}

.enrollment-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

.enrollment-table th,
.enrollment-table td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--separator-soft);
  text-align: left;
  vertical-align: top;
}

.enrollment-table th {
  background: #fafafd;
  color: var(--tertiary);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
}

.enrollment-table tbody tr {
  transition: background-color 120ms ease;
}

.enrollment-table tbody tr:hover {
  background: var(--surface-hover);
}

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

.enrollment-table th:nth-child(1) { width: 18%; }
.enrollment-table th:nth-child(2) { width: 18%; }
.enrollment-table th:nth-child(3) { width: 23%; }
.enrollment-table th:nth-child(4) { width: 16%; }
.enrollment-table th:nth-child(5) { width: 11%; }
.enrollment-table th:nth-child(6) { width: 14%; }

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

.operations-table th:nth-child(1) { width: 27%; }
.operations-table th:nth-child(2) { width: 27%; }
.operations-table th:nth-child(3) { width: 16%; }
.operations-table th:nth-child(4) { width: 30%; }

.enrollment-table code {
  overflow-wrap: anywhere;
  white-space: normal;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 18px;
}

.cell-primary {
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 600;
  line-height: 20px;
}

.cell-secondary {
  overflow-wrap: anywhere;
  color: var(--tertiary);
  font-size: 12px;
  line-height: 18px;
}

.cell-mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}

.status-stack .error-detail {
  width: 100%;
}

.bot-status-detail {
  width: 100%;
}

.row-actions {
  white-space: nowrap;
}

.row-actions button {
  min-height: 38px;
  padding: 4px 10px;
  font-size: 13px;
  line-height: 24px;
}

.row-actions button + button {
  margin-left: 6px;
}

.empty-row {
  padding: 44px 14px !important;
  color: var(--tertiary);
  text-align: center !important;
}

.error-detail {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--danger);
  font-size: 12px;
  line-height: 18px;
}

.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;
}

.notice {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(420px, calc(100% - 40px));
  padding: 12px 15px;
  border: 1px solid #ddb77b;
  border-radius: 8px;
  background: var(--warning-bg);
  color: var(--warning);
  box-shadow: 0 10px 30px rgb(25 25 25 / 14%);
  font-size: 13px;
  line-height: 20px;
}

.hidden {
  display: none !important;
}

@media (max-width: 800px) {
  .topbar-inner {
    width: min(100% - 24px, 1040px);
    min-height: 64px;
    padding: 8px 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }

  .mode-tabs {
    width: 100%;
    min-width: 0;
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .identity {
    display: none;
  }

  main {
    width: min(100% - 24px, 1040px);
    padding: 28px 0 56px;
  }

  .page-heading {
    min-height: 88px;
    margin-bottom: 16px;
  }

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

  .facts div + div {
    border-left: 0;
  }

  .facts div:nth-child(even) {
    border-left: 1px solid var(--separator-soft);
  }

  .facts div:nth-child(n + 3) {
    border-top: 1px solid var(--separator-soft);
  }

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

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

  .workflow-actions.single-action {
    grid-template-columns: minmax(0, 1fr);
  }

  .workflow button {
    width: 100%;
  }

  .admin-heading {
    min-height: 0;
    padding: 16px 0 20px;
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .admin-controls {
    width: 100%;
  }

  .admin-controls select {
    min-width: 0;
    flex: 1 1 auto;
  }

  .table-scroll {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .enrollment-table {
    min-width: 0;
    table-layout: auto;
  }

  .enrollment-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .enrollment-table tbody,
  .enrollment-table tr {
    display: block;
    width: 100%;
  }

  .enrollment-table tr {
    margin-bottom: 10px;
    padding: 10px 16px;
    border: 1px solid var(--separator-soft);
    border-radius: 8px;
    background: var(--surface);
  }

  .enrollment-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .enrollment-table td {
    padding: 8px 0;
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 6px 10px;
    border: 0;
  }

  .enrollment-table td::before {
    grid-column: 1;
    color: var(--tertiary);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
  }

  .enrollment-table td > * {
    grid-column: 2;
  }

  .enrollment-table .row-actions {
    display: grid;
    grid-template-columns: 84px repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    white-space: normal;
  }

  .enrollment-table .row-actions button {
    width: 100%;
    min-height: 40px;
    margin-left: 0;
    grid-column: auto;
  }

  .enrollment-table .empty-row {
    display: block;
  }

  .enrollment-table .empty-row::before {
    content: none;
  }
}

@media (max-width: 480px) {
  .brand-logo {
    width: 118px;
  }

  .product-name {
    display: none;
  }

  .release-label {
    margin-left: -4px;
  }

  .mode-tab {
    padding-right: 6px;
    padding-left: 6px;
    font-size: 12px;
  }

  .count {
    min-width: 16px;
    height: 16px;
    margin-left: 2px;
    padding: 0 4px;
    line-height: 16px;
  }

  h1,
  .login-view h1 {
    font-size: 24px;
    line-height: 32px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
  }

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

  .facts div:nth-child(even) {
    border-left: 0;
  }

  .facts div + div,
  .facts div:nth-child(n + 3) {
    border-top: 1px solid var(--separator-soft);
  }

  .workflow {
    padding: 20px 18px;
  }

  .workflow-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .inline-form {
    padding: 20px 18px;
  }

  .inline-form button {
    width: 100%;
  }

  .verification {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .weixin-verification {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
  }

  .weixin-verification img {
    width: min(216px, 100%);
    height: auto;
    aspect-ratio: 1;
  }

  .notice {
    right: 12px;
    bottom: 12px;
    max-width: calc(100% - 24px);
  }
}

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