:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e1ea;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --success-bg: #e8f7ef;
  --success-ink: #166534;
  --error-bg: #fee4e2;
  --error-ink: #b42318;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

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

#app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: #17202a;
  color: #f8fafc;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand strong {
  font-size: 26px;
}

.brand span {
  color: #cbd5e1;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 10px;
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-item {
  position: relative;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.nav-parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-caret {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  color: #94a3b8;
  transform: rotate(-45deg);
  transition:
    transform 0.16s ease,
    color 0.16s ease;
}

.nav-group.expanded .nav-caret {
  transform: rotate(45deg);
  color: #5eead4;
}

.sub-nav {
  position: relative;
  display: grid;
  gap: 5px;
  padding-left: 18px;
}

.sub-nav[hidden] {
  display: none;
}

.sub-nav::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 7px;
  width: 1px;
  background: #334155;
}

.sub-nav-item {
  position: relative;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    padding-left 0.16s ease;
}

.sub-nav-item::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  display: inline-block;
  width: 10px;
  height: 1px;
  margin: 0;
  background: #334155;
  transform: translateY(-50%);
}

.nav-item.active,
.nav-item:hover {
  background: #213244;
  border-color: #3b516b;
  color: #ffffff;
}

.nav-item.active {
  box-shadow: none;
}

.nav-parent.active {
  color: #ffffff;
}

.sub-nav-item:hover {
  background: #1f2d3c;
  border-color: #334b63;
  color: #ffffff;
  padding-left: 14px;
}

.sub-nav-item.active {
  background: #0f3f3c;
  border-color: transparent;
  color: #ffffff;
  box-shadow: none;
}

.sub-nav-item.active::before {
  height: 2px;
  background: #5eead4;
}

.sub-nav-nested {
  display: grid;
  gap: 5px;
  padding-left: 18px;
}

.sub-nav-item-level-3 {
  min-height: 30px;
  font-size: 12px;
}

.sub-nav-item-level-3::before {
  left: -12px;
  width: 8px;
}

.session {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.user-menu-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

.user-menu-button:hover {
  border-color: #b6c3d1;
  background: #f8fafc;
}

.user-menu-caret {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 12;
  min-width: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.user-menu-item {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  text-align: left;
  background: transparent;
}

.user-menu-item:hover {
  background: #f1f5f9;
}

.main {
  min-width: 0;
  padding: 24px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

.topbar h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

.panel > h2,
.form > h2,
.api-map > h2 {
  margin-bottom: 16px;
}

h3 {
  margin: 0;
  font-size: 15px;
}

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

.toolbar,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.toolbar-action {
  margin-left: auto;
  min-height: 32px;
  border-radius: 6px;
  padding: 0 14px;
  font-size: 12px;
}

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

.filters {
  gap: 8px;
}

.filters .field {
  gap: 4px;
  min-width: 132px;
}

.filters .field span {
  font-size: 12px;
}

.filters input,
.filters select {
  min-height: 32px;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
}

.filters .primary,
.filters .secondary {
  min-height: 32px;
  border-radius: 6px;
  padding: 0 14px;
  font-size: 12px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 16px;
}

.order-test-side {
  display: grid;
  align-content: start;
  gap: 16px;
}

.panel {
  padding: 18px;
}

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

.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.result-summary small {
  color: inherit;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.78;
}

.result-success {
  color: var(--success-ink);
  background: var(--success-bg);
}

.result-error {
  color: var(--danger);
  background: #fee4e2;
}

.result-pre {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #0f172a;
}

.result-pre code {
  display: block;
  max-width: none;
  overflow: visible;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}

.form {
  display: grid;
  gap: 14px;
  align-content: start;
}

.field {
  display: grid;
  gap: 3px;
  min-width: 180px;
}

.field-wide {
  min-width: 100%;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  min-height: 28px;
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
  background: #ffffff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--brand);
}

input[readonly] {
  color: #475467;
  background: #f8fafc;
}

.input-button-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.input-button-group .secondary {
  min-height: 28px;
  padding: 0 12px;
  font-size: 13px;
}

.order-number-field {
  min-width: 260px;
}

.primary,
.secondary,
.danger,
.text-button,
.segmented button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
}

.primary {
  background: var(--brand);
  color: #ffffff;
}

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

.secondary {
  color: var(--brand-strong);
  background: #ecfdf5;
  border-color: #a7f3d0;
}

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

.small {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
  line-height: 1;
}

.icon-button:hover {
  color: var(--ink);
  background: #f1f5f9;
}

.text-button {
  padding: 0;
  min-height: auto;
  text-align: center;
  color: var(--brand-strong);
  background: transparent;
}

.full {
  width: 100%;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.segmented button {
  min-width: 72px;
  background: transparent;
  color: var(--muted);
}

.segmented .active {
  background: var(--ink);
  color: #ffffff;
}

.tips {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}

.tip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
  font-size: 14px;
  line-height: 1.4;
  pointer-events: auto;
}

.tip-success {
  border-color: #bbf7d0;
}

.tip-error {
  border-color: #fecaca;
}

.tip-loading {
  border-color: #fed7aa;
}

.tip-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success-ink);
}

.tip-error .tip-dot {
  background: var(--error-ink);
}

.tip-loading .tip-dot {
  background: var(--accent);
}

.tip-close {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.tip-close:hover {
  color: var(--ink);
  background: #f1f5f9;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.merchant-edit-modal {
  width: min(720px, 100%);
}

.channel-enterprise-modal {
  width: min(580px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 0;
}

.modal-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modal-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.modal-title-actions h2 {
  margin: 0;
}

.confirm-modal {
  width: min(420px, 100%);
}

.confirm-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--danger);
  background: #fee4e2;
  font-weight: 800;
}

.confirm-body {
  padding: 18px 18px 4px;
}

.confirm-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.confirm-actions {
  padding: 14px 18px 18px;
}

.confirm-actions button {
  width: 112px;
}

.modal > .form {
  padding: 18px;
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.merchant-edit-body {
  grid-template-rows: auto minmax(390px, auto);
  min-height: 460px;
}

.merchant-tab-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  min-height: 390px;
}

.merchant-tab-panel > .modal-section {
  min-height: 250px;
}

.modal-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 48px;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.modal-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--muted);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  background: transparent;
}

.modal-tabs button:hover {
  color: var(--ink);
  background: #eef4fb;
}

.modal-tabs button.active {
  color: #1f3a5f;
  background: #e4edf7;
  box-shadow: inset 0 0 0 1px #bfd0e3;
}

.modal-section {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.channel-enterprise-modal > .form {
  gap: 6px;
  padding: 10px 12px 12px;
}

.channel-enterprise-modal textarea {
  min-height: 116px;
}

.channel-enterprise-modal .modal-actions {
  padding-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding-top: 4px;
}

.modal-actions button {
  width: 112px;
}

.table-panel {
  overflow: auto;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-title h2 {
  margin: 0;
}

.refresh-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #5f6368;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.refresh-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refresh-icon:hover {
  color: #202124;
  background: #f1f3f4;
}

.refresh-icon.is-loading svg {
  animation: refresh-spin 0.75s linear infinite;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  line-height: 1.35;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: #f8fafc;
}

code {
  display: block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #475467;
}

.channel-table {
  table-layout: fixed;
  min-width: 900px;
}

.aliwork-channel-table {
  min-width: 1180px;
}

.channel-table th,
.channel-table td {
  overflow: hidden;
}

.truncate-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.table-actions .small + .small {
  margin-left: 6px;
}

.channel-col-name {
  width: 38%;
}

.channel-col-id {
  width: 42%;
}

.channel-col-type {
  width: 20%;
}

.channel-col-username {
  width: 120px;
}

.channel-col-balance {
  width: 90px;
}

.channel-col-url {
  width: 150px;
}

.channel-col-app-type {
  width: 150px;
}

.channel-col-corp {
  width: 140px;
}

.channel-col-form {
  width: 190px;
}

.channel-col-process {
  width: 220px;
}

.channel-col-pay {
  width: 130px;
}

.channel-col-actions {
  width: 116px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  color: #854d0e;
  background: #fef3c7;
  font-size: 12px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.login-page {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 40px 28px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.86), rgba(15, 118, 110, 0.42)),
    url("../src/pay-control-room.svg") center / cover no-repeat;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  width: min(880px, 100%);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 22px 78px rgba(15, 23, 42, 0.34);
}

.login-copy {
  display: grid;
  align-content: center;
  gap: 12px;
  min-height: 430px;
  padding: 46px;
  color: #ffffff;
  background:
    linear-gradient(160deg, rgba(15, 118, 110, 0.9), rgba(23, 32, 42, 0.9)),
    url("../src/pay-control-room.svg") center / cover no-repeat;
}

.login-copy h1 {
  max-width: 360px;
  font-size: 52px;
  line-height: 1.04;
}

.login-copy p {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #ccfbf1;
}

.login-form {
  align-content: center;
  gap: 15px;
  padding: 48px 40px;
}

.login-form-title {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.login-form-title p {
  margin: 0;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.login-form-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
}

.login-form .primary {
  margin-top: 20px;
}

.settings {
  max-width: 1120px;
}

.settings-form {
  max-width: 520px;
}

.settings-sections {
  display: grid;
  gap: 22px;
}

.settings-section {
  display: grid;
  gap: 14px;
}

.settings-table {
  margin-top: 2px;
}

.settings-section + .settings-section {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.api-map {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.settings-section.api-map {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

dl {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
}

dt {
  color: var(--ink);
  font-weight: 700;
}

dd {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
    padding-inline: 8px;
  }

  .sub-nav {
    padding-left: 0;
  }

  .sub-nav-item {
    text-align: center;
    padding-inline: 6px;
  }

  .workbench,
  .login-panel {
    grid-template-columns: 1fr;
  }

  .login-copy {
    min-height: 210px;
    padding: 34px;
  }

  .login-copy h1 {
    font-size: 40px;
  }

  .login-form {
    padding: 34px;
  }
}

@media (max-width: 620px) {
  .main,
  .login-page {
    padding: 14px;
  }

  .login-copy {
    min-height: 170px;
    padding: 24px;
  }

  .login-copy h1 {
    font-size: 32px;
  }

  .login-form {
    padding: 26px 22px;
  }

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

  .session {
    justify-content: flex-start;
  }

  .user-menu {
    right: auto;
    left: 0;
  }

  .filters,
  .toolbar,
  .button-row {
    align-items: stretch;
  }

  .field,
  .filters .primary,
  .filters .secondary,
  .toolbar-action {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column-reverse;
    align-items: center;
  }

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

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