* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
    background: #f5f7fb;
    color: #1f2937;
}

.container {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    background: #0f172a;
    color: #fff;
}

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

.logo,
.nav a {
    color: #fff;
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.main-content {
    padding: 24px 0 40px;
}

.card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
    margin-bottom: 20px;
}

.narrow {
    max-width: 420px;
}

.muted {
    color: #6b7280;
}

.center {
    text-align: center;
}

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

.stack-form {
    display: grid;
    gap: 16px;
}

.span-2 {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.field-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: #dbeafe;
    color: #1d4ed8;
    vertical-align: middle;
}

.field-tag.danger {
    background: #fee2e2;
    color: #b91c1c;
}

.field-tag.neutral {
    background: #eef2ff;
    color: #4338ca;
}

input,
textarea,
button {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    padding: 12px 14px;
    font: inherit;
}

textarea {
    resize: vertical;
}

.readonly-field {
    background: #f8fafc;
    color: #334155;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    text-decoration: none;
    padding: 12px 18px;
}

.button.secondary {
    background: #475569;
}

.actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.flash-list {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.flash {
    padding: 12px 14px;
    border-radius: 10px;
}

.flash.success {
    background: #dcfce7;
    color: #166534;
}

.flash.error {
    background: #fee2e2;
    color: #991b1b;
}

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

.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filters a {
    text-decoration: none;
    color: #334155;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e2e8f0;
}

.filters a.active {
    background: #2563eb;
    color: #fff;
}

.search-form {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.search-form input {
    flex: 1 1 320px;
}

.search-form button,
.search-form .button {
    width: auto;
}

.scope-option-list {
    display: grid;
    gap: 12px;
}

.scope-option-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
}

.scope-option-card:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.scope-option-card input {
    width: auto;
    margin-top: 2px;
}

.scope-option-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 500;
}

.check-row input {
    width: auto;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e2e8f0;
}

.badge.pending {
    background: #fef3c7;
}

.badge.processing {
    background: #dbeafe;
}

.badge.issued {
    background: #dcfce7;
}

.badge.failed {
    background: #fee2e2;
}

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

pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 12px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.error-text {
    color: #b91c1c;
}

.result-block + .result-block {
    margin-top: 20px;
}

.tip-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
}

.tip-box ul {
    margin: 8px 0 0 18px;
}

.purchase-list {
    display: grid;
    gap: 12px;
}

.purchase-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 16px;
    row-gap: 8px;
    padding: 16px;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.purchase-item:hover {
    border-color: #93c5fd;
    background: #f8fbff;
}

.purchase-item input[type="radio"] {
    width: auto;
    margin: 0;
    justify-self: end;
    align-self: center;
}

.purchase-main {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.purchase-title {
    font-weight: 700;
    color: #0f172a;
}

.purchase-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: #334155;
    font-size: 14px;
}

.purchase-sub {
    font-size: 13px;
    line-height: 1.5;
}

.clean-config-header h1 {
    margin: 0 0 8px;
}

.clean-config-header p {
    margin: 0;
}

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

.clean-stat {
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    transition: all 0.2s;
}

.clean-stat:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.clean-stat-label {
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clean-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #0f172a;
}

.clean-config-notice {
    padding: 20px 24px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-left: 4px solid #2563eb;
}

.notice-title {
    font-weight: 700;
    margin-bottom: 12px;
    color: #1e40af;
    font-size: 15px;
}

.clean-config-notice ul {
    margin: 0;
    padding-left: 20px;
    color: #1e40af;
    line-height: 1.6;
}

.clean-config-notice li + li {
    margin-top: 8px;
}

.clean-field-list {
    display: grid;
    gap: 16px;
}

.clean-field-item {
    padding: 24px;
    border: 2px solid #f1f5f9;
    transition: all 0.2s;
}

.clean-field-item:hover {
    border-color: #e2e8f0;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.clean-field-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.clean-field-title {
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

.clean-field-key {
    margin-top: 8px;
    color: #94a3b8;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
}

.clean-field-status {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mini-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.mini-badge.ok {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.mini-badge.off {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.mini-badge.readonly {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.mini-badge.normal {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.clean-switch-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.clean-switch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 16px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
}

.clean-switch-item:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.clean-switch-item input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #2563eb;
}

.clean-fixed-block {
    margin-top: 4px;
    margin-bottom: 16px;
}

.clean-field-save {
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

.save-single {
    width: auto;
    min-width: 120px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.save-single:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.clean-fixed-block label {
    margin-bottom: 10px;
    font-size: 14px;
    color: #475569;
}

.clean-fixed-block input,
.clean-fixed-block textarea {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    transition: all 0.2s;
}

.clean-fixed-block input:focus,
.clean-fixed-block textarea:focus {
    outline: none;
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clean-save-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
}

.clean-save-bar strong {
    font-size: 16px;
    color: #0f172a;
}

.clean-save-bar button {
    min-width: 160px;
    font-weight: 600;
    transition: all 0.2s;
}

.clean-save-bar button:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

@media (max-width: 768px) {
    .form-grid,
    .detail-grid,
    .summary {
        grid-template-columns: 1fr;
    }

    .clean-config-stats,
    .clean-switch-row {
        grid-template-columns: 1fr;
    }

    .clean-field-top,
    .clean-save-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .clean-save-bar button {
        width: 100%;
    }
}


.channel-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}

.channel-badge.wxpay {
    color: #166534;
    background: #dcfce7;
    border-color: #bbf7d0;
}

.channel-badge.alipay {
    color: #1d4ed8;
    background: #dbeafe;
    border-color: #bfdbfe;
}

.channel-badge.paylog {
    color: #7c2d12;
    background: #ffedd5;
    border-color: #fed7aa;
}

.channel-badge.unknown,
.channel-badge.epaylog {
    color: #6b7280;
    background: #f3f4f6;
    border-color: #e5e7eb;
}
