:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background: #f5f7fa;
  color: #172033;
  font-synthesis: none;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f5f7fa; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #f5f7fa; }
.login-panel { width: min(420px, 100%); padding: 38px; border: 1px solid #dfe4ea; border-radius: 8px; background: #fff; box-shadow: 0 18px 50px rgba(31, 41, 55, .08); }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 8px; background: #0f9f8f; color: #fff; font-size: 23px; font-weight: 750; }
.brand-mark.small { width: 38px; height: 38px; font-size: 17px; flex: 0 0 auto; }
.login-panel h1 { margin: 24px 0 6px; font-size: 26px; line-height: 1.25; }
.login-panel > p { margin: 0; color: #667085; font-size: 14px; }
.login-form { display: grid; gap: 10px; margin-top: 28px; }
.login-form label, .field > span { color: #344054; font-size: 13px; font-weight: 650; }
.login-form input, .field input, .filters select, .inline-form input { width: 100%; height: 42px; border: 1px solid #d0d5dd; border-radius: 6px; padding: 0 12px; background: #fff; color: #172033; outline: none; transition: border-color .15s, box-shadow .15s; }
.login-form input:focus, .field input:focus, .filters select:focus, .inline-form input:focus { border-color: #0f9f8f; box-shadow: 0 0 0 3px rgba(15, 159, 143, .12); }
.form-error { margin-top: 14px; border-radius: 6px; background: #fff1f0; color: #b42318; padding: 10px 12px; font-size: 13px; }
.health-line { display: flex; align-items: center; gap: 8px; margin-top: 20px; color: #667085; font-size: 12px; }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: #98a2b3; }
.health-dot.ok { background: #12b76a; }
.health-dot.bad { background: #f04438; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 18px; border-right: 1px solid #e1e6ec; background: #fff; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.brand strong { display: block; font-size: 16px; }
.brand span { display: block; margin-top: 2px; color: #98a2b3; font-size: 11px; }
.nav { display: grid; gap: 4px; }
.nav-item { width: 100%; border: 0; border-radius: 6px; padding: 11px 12px; background: transparent; color: #475467; text-align: left; font-size: 14px; font-weight: 600; }
.nav-item:hover { background: #f2f4f7; color: #172033; }
.nav-item.active { background: #eaf8f5; color: #087f73; }
.sidebar-footer { margin-top: auto; padding: 0 8px; }
.sidebar-footer .health-line { margin: 0 0 14px; }
.text-button { border: 0; padding: 0; background: transparent; color: #667085; font-size: 13px; }
.text-button:hover { color: #172033; }

.main { min-width: 0; padding: 0 30px 48px; }
.topbar { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e7eaee; }
.topbar h1 { margin: 0; font-size: 21px; line-height: 1.3; }
.topbar p { margin: 5px 0 0; color: #667085; font-size: 13px; }
.view { width: min(1280px, 100%); margin: 24px auto 0; }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 6px; padding: 0 15px; font-size: 13px; font-weight: 650; transition: background .15s, border-color .15s, color .15s; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button.primary { background: #0f9f8f; color: #fff; }
.button.primary:hover:not(:disabled) { background: #0b8a7c; }
.button.secondary { border-color: #d0d5dd; background: #fff; color: #344054; }
.button.secondary:hover:not(:disabled) { border-color: #98a2b3; background: #f9fafb; }
.button.danger-quiet { border-color: #fecdca; background: #fff; color: #b42318; }
.button.compact { min-height: 34px; padding: 0 12px; }

.callback-band { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding: 15px 18px; border: 1px solid #b9e8df; border-radius: 7px; background: #effaf8; }
.callback-band span { display: block; margin-bottom: 5px; color: #087f73; font-size: 12px; font-weight: 700; }
.callback-band code { word-break: break-all; color: #17403b; font-family: Consolas, monospace; font-size: 13px; }
.content-section { margin-top: 18px; border: 1px solid #dfe4ea; border-radius: 8px; background: #fff; overflow: hidden; }
.section-heading, .section-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 19px 22px; border-bottom: 1px solid #e8ebef; }
.section-heading h2, .section-toolbar h2, .dialog-heading h2 { margin: 0; font-size: 17px; }
.section-heading p, .section-toolbar p, .dialog-heading p { margin: 5px 0 0; color: #667085; font-size: 12px; }
.status-label { flex: 0 0 auto; border-radius: 999px; padding: 5px 10px; font-size: 11px; font-weight: 750; }
.status-label.neutral { background: #f2f4f7; color: #667085; }
.status-label.success { background: #eaf8ef; color: #087a42; }
.status-label.warning { background: #fff6e5; color: #a15c00; }
.status-label.error { background: #fff1f0; color: #b42318; }

.toggle-list { margin: 18px 22px 0; border: 1px solid #e1e6ec; border-radius: 7px; }
.toggle-row { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 14px; }
.toggle-row + .toggle-row { border-top: 1px solid #eaecf0; }
.toggle-row strong { display: block; font-size: 13px; }
.toggle-row small { display: block; margin-top: 3px; color: #667085; font-size: 11px; font-weight: 400; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 42px; height: 24px; position: relative; flex: 0 0 auto; border-radius: 999px; background: #d0d5dd; transition: background .15s; }
.switch::after { content: ""; width: 18px; height: 18px; position: absolute; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: transform .15s; }
.toggle-row input:checked + .switch { background: #0f9f8f; }
.toggle-row input:checked + .switch::after { transform: translateX(18px); }
.toggle-row input:focus-visible + .switch { box-shadow: 0 0 0 3px rgba(15,159,143,.2); }

.form-block { padding: 22px; }
.form-block + .form-block { border-top: 1px solid #eaecf0; }
.form-block h3, .auth-box h3 { margin: 0 0 14px; color: #344054; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.single { grid-template-columns: 1fr; }
.field { min-width: 0; display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field em { color: #98a2b3; font-size: 11px; font-style: normal; font-weight: 450; }
.field-help { color: #667085; font-size: 11px; line-height: 1.55; }
.check-row { display: flex; align-items: center; gap: 9px; color: #344054; font-size: 13px; }
.check-row input { width: 16px; height: 16px; accent-color: #0f9f8f; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid #eaecf0; background: #fafbfc; }

.setup-callout { margin-bottom: 18px; padding: 14px 16px; border: 1px solid #b9e8df; border-radius: 7px; background: #effaf8; color: #17403b; font-size: 12px; line-height: 1.65; }
.setup-callout strong { display: block; margin-bottom: 5px; color: #087f73; font-size: 13px; }
.setup-callout ol { margin: 0; padding-left: 20px; }
.config-status-box { min-width: 0; display: grid; align-content: start; gap: 7px; padding: 12px 14px; border: 1px solid #e1e6ec; border-radius: 7px; background: #fafbfc; }
.config-status-box > span { color: #667085; font-size: 11px; font-weight: 700; }
.config-status-box strong { color: #344054; font-size: 13px; line-height: 1.45; word-break: break-word; }
.config-status-box small { color: #667085; font-size: 11px; line-height: 1.55; }
.connection-flow { margin-top: 18px; }
.flow-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 22px; }
.flow-item { min-width: 0; display: grid; gap: 7px; padding: 14px; border: 1px solid #e1e6ec; border-radius: 7px; background: #fff; }
.flow-item strong { color: #344054; font-size: 13px; }
.flow-item code { color: #17403b; font: 11px/1.5 Consolas, monospace; word-break: break-all; }
.flow-item span { color: #667085; font-size: 11px; line-height: 1.5; }

.auth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 22px; }
.auth-box { min-width: 0; padding: 16px; border: 1px solid #e1e6ec; border-radius: 7px; }
.inline-form { display: grid; grid-template-columns: minmax(120px, 1fr) auto auto; gap: 9px; }
.face-content { min-height: 80px; display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.face-content img { width: 160px; height: 160px; object-fit: contain; border: 1px solid #e1e6ec; }
.face-content code { max-height: 110px; overflow: auto; word-break: break-all; white-space: pre-wrap; font-size: 11px; }
.face-content a { color: #087f73; font-size: 13px; font-weight: 650; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.section-toolbar { align-items: center; border: 1px solid #dfe4ea; border-radius: 8px 8px 0 0; background: #fff; }
.filters { display: flex; gap: 10px; padding: 14px 16px; border: 1px solid #dfe4ea; border-top: 0; background: #fff; }
.filters select { width: auto; min-width: 170px; }
.table-wrap { overflow-x: auto; border: 1px solid #dfe4ea; border-top: 0; border-radius: 0 0 8px 8px; background: #fff; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; background: #f8fafb; color: #667085; text-align: left; white-space: nowrap; font-size: 11px; font-weight: 750; }
td { max-width: 300px; padding: 13px 14px; border-top: 1px solid #eaecf0; color: #344054; vertical-align: middle; font-size: 12px; }
td code { font-family: Consolas, monospace; font-size: 11px; word-break: break-all; }
.cell-main { display: block; color: #172033; font-weight: 650; }
.cell-sub { display: block; margin-top: 3px; color: #98a2b3; font-size: 11px; word-break: break-all; }
.row-actions { text-align: right; white-space: nowrap; }
.row-button { border: 0; background: transparent; color: #087f73; font-size: 12px; font-weight: 650; }
.empty-state { padding: 48px 20px; color: #98a2b3; text-align: center; font-size: 13px; }
.issue-status { display: inline-block; border-radius: 999px; padding: 4px 8px; background: #f2f4f7; color: #475467; font-size: 10px; font-weight: 750; }
.issue-status.ISSUED { background: #eaf8ef; color: #087a42; }
.issue-status.VOIDED { background: #f2f4f7; color: #475467; }
.issue-status.ISSUING, .issue-status.VOIDING { background: #eef4ff; color: #175cd3; }
.issue-status.FAILED { background: #fff1f0; color: #b42318; }
.issue-status.UNKNOWN, .issue-status.AUTH_REQUIRED, .issue-status.SMS_REQUIRED, .issue-status.FACE_REQUIRED { background: #fff6e5; color: #a15c00; }
.cell-amount { white-space: nowrap; color: #172033; font-variant-numeric: tabular-nums; font-weight: 650; }
.cell-error { display: block; max-width: 220px; margin-top: 5px; overflow: hidden; color: #b42318; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.detail-section { margin-top: 18px; }
.detail-section h3 { margin: 0 0 10px; color: #344054; font-size: 13px; }
.detail-file { margin: 14px 0 0; }
.detail-file a { color: #087f73; font-size: 13px; font-weight: 650; }
.empty-inline { margin: 0; color: #98a2b3; font-size: 12px; }
.orders-table { width: 100%; border: 1px solid #eaecf0; border-radius: 6px; overflow: hidden; }
.orders-table th, .orders-table td { padding: 9px 12px; }
.detail-raw { margin-top: 16px; }
.detail-raw summary { cursor: pointer; color: #667085; font-size: 12px; font-weight: 650; }
.detail-raw .detail-json { margin-top: 10px; }

.dialog { width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 0; border-radius: 8px; padding: 0; box-shadow: 0 24px 70px rgba(16,24,40,.24); }
.dialog.wide { width: min(900px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(16, 24, 40, .46); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 19px 22px; border-bottom: 1px solid #eaecf0; }
.close-button { width: 32px; height: 32px; border: 0; border-radius: 5px; background: transparent; color: #667085; font-size: 25px; line-height: 1; }
.close-button:hover { background: #f2f4f7; }
.dialog-body { max-height: calc(100vh - 190px); overflow: auto; padding: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 15px 22px; border-top: 1px solid #eaecf0; background: #fafbfc; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.detail-item { min-width: 0; padding: 12px; border: 1px solid #eaecf0; border-radius: 6px; }
.detail-item span { display: block; margin-bottom: 5px; color: #98a2b3; font-size: 10px; font-weight: 700; }
.detail-item strong, .detail-item code { display: block; color: #344054; font-size: 12px; word-break: break-all; }
.detail-error { margin-top: 14px; padding: 12px; border-radius: 6px; background: #fff1f0; color: #b42318; font-size: 12px; word-break: break-word; }
.detail-json { margin: 14px 0 0; max-height: 280px; overflow: auto; border-radius: 6px; background: #101828; color: #d0d5dd; padding: 14px; white-space: pre-wrap; word-break: break-word; font: 11px/1.6 Consolas, monospace; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(420px, calc(100vw - 44px)); border-radius: 7px; padding: 12px 15px; background: #172033; color: #fff; box-shadow: 0 12px 30px rgba(16,24,40,.22); font-size: 13px; }
.toast.error { background: #b42318; }

.categories-list { display: grid; gap: 12px; }
.category-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid #e1e6ec; border-radius: 6px; background: #fafbfc; }
.category-fields { flex: 1; display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: center; }
.category-item .field { margin: 0; }
.category-item .field span { display: block; margin-bottom: 4px; }
.category-item .check-row { margin: 0; }
.category-search { margin-bottom: 16px; }
.category-search-form { display: flex; gap: 8px; margin-bottom: 12px; }
.category-search-form input { flex: 1; }
.category-results { max-height: 320px; overflow-y: auto; border: 1px solid #e1e6ec; border-radius: 6px; background: #fff; }
.category-result-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-bottom: 1px solid #f2f4f7; }
.category-result-item:last-child { border-bottom: 0; }
.category-result-info { flex: 1; min-width: 0; }
.category-result-info strong { display: block; color: #172033; font-size: 14px; margin-bottom: 4px; }
.category-result-info small { display: block; color: #667085; font-size: 12px; }
.category-result-info code { color: #475467; font-size: 11px; }
.text-button.danger { color: #b42318; }
.text-button.danger:hover { color: #912018; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(420px, calc(100vw - 44px)); border-radius: 7px; padding: 12px 15px; background: #172033; color: #fff; box-shadow: 0 12px 30px rgba(16,24,40,.22); font-size: 13px; }
.toast.error { background: #b42318; }

.category-search { margin-bottom: 20px; }
.category-search-form { display: flex; gap: 10px; margin-bottom: 14px; }
.category-search-form input { flex: 1; }
.category-results { border: 1px solid #d0d5dd; border-radius: 8px; padding: 12px; background: #fafbfc; max-height: 400px; overflow-y: auto; }
.category-result-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-bottom: 1px solid #e4e7ec; }
.category-result-item:last-child { border-bottom: 0; }
.category-result-info { flex: 1; min-width: 0; }
.category-result-info strong { display: block; margin-bottom: 4px; color: #101828; font-size: 13px; font-weight: 600; }
.category-result-info small { display: block; color: #667085; font-size: 11px; }
.category-result-info code { font-family: Consolas, monospace; font-size: 10px; }
.categories-list { display: flex; flex-direction: column; gap: 12px; }
.category-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; }
.category-fields { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.category-fields .field { grid-column: span 1; }
.category-fields .check-row { grid-column: span 2; }
.empty-state { padding: 32px; text-align: center; color: #667085; font-size: 13px; border: 1px dashed #d0d5dd; border-radius: 8px; }

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; border-right: 0; border-bottom: 1px solid #e1e6ec; }
  .brand { padding-bottom: 12px; }
  .nav { grid-template-columns: repeat(4, 1fr); }
  .nav-item { text-align: center; }
  .sidebar-footer { display: none; }
  .main { padding: 0 16px 34px; }
  .topbar { min-height: 72px; }
  .auth-grid, .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .flow-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-fields { grid-template-columns: 1fr; }
  .category-item { flex-direction: column; }
}

@media (max-width: 560px) {
  .login-panel { padding: 28px 22px; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .nav-item { padding: 10px 5px; font-size: 12px; }
  .topbar { align-items: flex-start; padding: 16px 0; }
  .callback-band, .section-toolbar { align-items: stretch; flex-direction: column; }
  .form-actions { flex-direction: column; }
  .form-actions .button { width: 100%; }
  .inline-form { grid-template-columns: 1fr; }
  .filters { flex-direction: column; }
  .filters select { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
}
