:root {
    --ink: #18261f;
    --muted: #65736e;
    --paper: #f6f3ec;
    --panel: #fffdf8;
    --line: #e6ddd0;
    --brand: #145c43;
    --brand-2: #0c4633;
    --gold: #b47728;
    --danger: #ae3a35;
    --danger-bg: #fff0ee;
    --ok: #237647;
    font-family: "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
}
button, input, textarea, select { font: inherit; }
button {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 14px;
    background: #fff;
    cursor: pointer;
}
button:hover { border-color: var(--brand); }
button.primary {
    color: #fff;
    background: var(--brand);
    border-color: var(--brand);
}
button.danger { color: var(--danger); border-color: #e8c6c2; background: var(--danger-bg); }
button.quiet { background: transparent; padding: 7px 12px; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 11px;
    background: #fff;
}
textarea { min-height: 94px; resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
h1, h2, h3 { margin: 0 0 14px; }
p { margin: 8px 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); min-height: 20px; font-size: 13px; }
.eyebrow { font-size: 11px; letter-spacing: .16em; color: var(--gold); font-weight: bold; }
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at 30% 20%, #fff8e8, var(--paper) 50%);
}
.login-card {
    width: min(420px, 100%);
    display: grid;
    gap: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 18px 48px rgba(37, 30, 18, .08);
    padding: 34px;
    border-radius: 18px;
}
.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 234px 1fr;
    grid-template-rows: 64px 1fr;
}
.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.warning, .tag {
    display: inline-block;
    margin-left: 14px;
    padding: 4px 9px;
    font-size: 12px;
    border-radius: 50px;
}
.warning { color: var(--gold); background: #fff2db; }
.tag { color: var(--brand); background: #e6f1eb; }
.profile { display: flex; align-items: center; gap: 9px; }
.sidebar {
    background: #ede7da;
    border-right: 1px solid var(--line);
    padding: 20px 12px;
}
.nav-btn {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    margin-bottom: 5px;
    color: var(--ink);
}
.nav-btn.active {
    background: var(--panel);
    color: var(--brand);
    font-weight: bold;
}
.content { padding: 26px; overflow-x: hidden; }
.page-head {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 20px;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 13px;
    margin: 20px 0;
}
.stat, .panel, .work-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--panel);
}
.stat strong { display: block; margin-top: 8px; font-size: 25px; }
.panel { margin-bottom: 18px; overflow-x: auto; }
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 13px;
    align-items: end;
}
.grid-form .wide { grid-column: 1 / -1; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th, .table td {
    border-bottom: 1px solid var(--line);
    padding: 11px 8px;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}
.table th { color: var(--muted); font-weight: normal; }
.status {
    padding: 3px 8px;
    border-radius: 50px;
    background: #edf5ef;
    color: var(--ok);
    font-size: 12px;
}
.status.exception, .status.timeout, .status.review_interrupted { color: var(--danger); background: var(--danger-bg); }
.work-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
}
.work-card dl {
    display: grid;
    grid-template-columns: 105px 1fr;
    gap: 6px;
    font-size: 13px;
    margin: 12px 0;
}
.work-card dt { color: var(--muted); }
.work-card dd { margin: 0; word-break: break-all; }
.message {
    white-space: pre-wrap;
    padding: 12px;
    margin: 12px 0;
    background: #f2efe6;
    border-radius: 8px;
    font-size: 13px;
}
.qr { max-width: 280px; max-height: 280px; object-fit: contain; display: block; margin: auto; }
.modal {
    position: fixed;
    inset: 0;
    background: rgba(18, 22, 19, .45);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 10;
}
.modal-box {
    position: relative;
    width: min(600px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: var(--panel);
    border-radius: 15px;
    padding: 28px;
}
.modal-close { position: absolute; right: 12px; top: 12px; }
.toast {
    position: fixed;
    bottom: 22px;
    right: 22px;
    color: #fff;
    background: var(--brand-2);
    padding: 12px 16px;
    border-radius: 8px;
    z-index: 30;
}
.review-screen {
    max-width: 950px;
    margin: 0 auto;
}
.countdown {
    font-size: 42px;
    color: var(--brand);
    text-align: center;
    padding: 15px;
}
.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.callout {
    border-left: 4px solid var(--gold);
    background: #fff4e3;
    padding: 12px 15px;
    margin: 14px 0;
    font-size: 13px;
}
@media (max-width: 760px) {
    .shell { display: block; }
    .topbar { height: 62px; padding: 0 14px; }
    .sidebar { display: flex; overflow-x: auto; padding: 9px; }
    .nav-btn { width: auto; white-space: nowrap; }
    .content { padding: 15px; }
    .work-grid { grid-template-columns: 1fr; }
    .result-grid { grid-template-columns: 1fr; }
}


/* === UI polish for receipt system === */
:root {
    --ink: #17202a;
    --muted: #6b7280;
    --paper: #f3f6fb;
    --panel: #ffffff;
    --line: #e5e7eb;
    --brand: #3458e6;
    --brand-2: #2439ad;
    --gold: #b7791f;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --ok: #15803d;
    --soft: #eef2ff;
}

body {
    background:
        radial-gradient(circle at top left, rgba(52, 88, 230, .12), transparent 32%),
        linear-gradient(180deg, #f7fafc 0%, #eef2f7 100%);
}

.topbar {
    height: 68px;
    position: sticky;
    top: 0;
    z-index: 8;
    backdrop-filter: blur(14px);
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 8px 28px rgba(15, 23, 42, .06);
}

.shell {
    grid-template-columns: 248px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #172554 0%, #312e81 100%);
    border-right: 0;
    padding: 18px 12px;
}

.nav-btn {
    color: rgba(255,255,255,.82);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 7px;
}

.nav-btn:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

.nav-btn.active {
    color: var(--brand);
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(0,0,0,.12);
}

.content {
    padding: 28px;
}

.page-head {
    padding: 20px 22px;
    background: rgba(255,255,255,.72);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(15,23,42,.06);
}

.page-head h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.panel, .work-card, .stat {
    border: 1px solid rgba(226,232,240,.9);
    border-radius: 18px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 12px 32px rgba(15, 23, 42, .06);
}

.highlight-panel {
    border-color: rgba(22, 101, 52, .22);
    background: linear-gradient(180deg, #ffffff 0%, #f7fff9 100%);
}

button {
    border-radius: 12px;
    padding: 9px 15px;
    transition: all .15s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15,23,42,.08);
}

button.primary {
    background: linear-gradient(135deg, #3458e6, #6d4dea);
    border-color: transparent;
    box-shadow: 0 10px 20px rgba(52, 88, 230, .22);
}

button.danger {
    background: #fff5f5;
}

input, textarea, select {
    border-radius: 12px;
    border-color: #d9e1ea;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: rgba(52, 88, 230, .55);
    box-shadow: 0 0 0 4px rgba(52, 88, 230, .10);
}

.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background: #f8fafc;
    color: #64748b;
    font-weight: 700;
    position: sticky;
    top: 0;
}

.table th, .table td {
    padding: 13px 10px;
}

.table tbody tr:hover {
    background: #f8fbff;
}

.status {
    font-weight: 700;
    background: #eaf7ee;
}

.status.exception,
.status.timeout,
.status.review_interrupted,
.status.failed,
.status.disabled {
    color: var(--danger);
    background: var(--danger-bg);
}

.cards {
    gap: 16px;
}

.stat {
    min-height: 120px;
}

.stat strong {
    font-size: 30px;
}

.work-grid {
    grid-template-columns: repeat(auto-fill, minmax(390px, 1fr));
}

.work-card {
    border-top: 4px solid var(--brand);
}

.message {
    background: #f8fafc;
    border: 1px dashed #d7dee8;
    border-radius: 14px;
}

.modal {
    backdrop-filter: blur(8px);
}

.modal-box {
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(15,23,42,.24);
}

.toast {
    border-radius: 14px;
    box-shadow: 0 16px 42px rgba(20,83,45,.24);
}

.qr {
    max-width: 340px;
    max-height: 340px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
}

.qr-preview {
    text-align: center;
    padding: 14px;
    margin: 12px 0 18px;
    background: #f8fafc;
    border-radius: 18px;
    border: 1px solid #e5e7eb;
}

.qr-empty {
    padding: 14px;
    margin: 12px 0 18px;
    border-radius: 14px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.qr-upload-form {
    display: grid;
    gap: 14px;
}

.qr-state {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.qr-state.ok {
    color: #166534;
    background: #dcfce7;
}

.qr-state.missing {
    color: #92400e;
    background: #fef3c7;
}

.qr-state.pending {
    color: #1d4ed8;
    background: #dbeafe;
}

.qr-state.rejected {
    color: #b91c1c;
    background: #fee2e2;
}

button:disabled,
button.loading {
    cursor: wait;
    opacity: .72;
    transform: none;
    box-shadow: none;
}

.feedback-title {
    font-size: 20px;
    line-height: 1.3;
    font-weight: 700;
    margin: 0 0 14px;
}

.feedback-title.error {
    color: var(--danger);
}

.feedback-message {
    color: var(--ink);
    line-height: 1.7;
    padding: 13px 15px;
    margin: 0 0 20px;
    border-radius: 12px;
    background: var(--danger-bg);
    border: 1px solid #fecaca;
}

.upload-help {
    color: #64748b;
    font-size: 12px;
    margin-top: -7px;
}

.diagnosis {
    background: #f8fafc;
    margin: 8px 0 0;
}

.status.enabled,
.status.normal,
.status.sent,
.status.confirmed_received,
.status.binance_completed,
.status.manual_release_recorded,
.status.released,
.status.resolved {
    color: #15803d;
    background: #dcfce7;
}

.status.send_ready,
.status.pending_customer_service_send,
.status.pending_auditor_review,
.status.pending_admin_review,
.status.pending_manual_release,
.status.wait_assign,
.status.assigned,
.status.locked_reviewing,
.status.waiting_release,
.status.receiving,
.status.reviewing {
    color: #1d4ed8;
    background: #dbeafe;
}

.status.pending,
.status.buyer_paid,
.status.sent_to_buyer {
    color: #9a3412;
    background: #ffedd5;
}

.status.pending_review {
    color: #1d4ed8;
    background: #dbeafe;
}

.status.approved, .status.paid, .status.manual_done {
    color: #15803d;
    background: #dcfce7;
}

.status.success {
    color: #15803d;
    background: #dcfce7;
}

.status.rejected, .status.expired, .status.underpaid, .status.overpaid {
    color: var(--danger);
    background: var(--danger-bg);
}

.warning-text {
    color: #b45309;
    font-size: 12px;
    font-weight: 700;
}

.work-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.work-card-head h3 {
    margin: 0;
    font-size: 16px;
    word-break: break-all;
}

.order-amount {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 16px;
    margin: 15px 0;
    border-radius: 14px;
    color: #166534;
    background: #ecfdf3;
    border: 1px solid #bbf7d0;
}

.order-amount span {
    color: #64748b;
    font-size: 13px;
}

.order-amount strong {
    font-size: 28px;
    letter-spacing: .02em;
}

.order-amount small {
    font-size: 14px;
    font-weight: 500;
}

.bound-account {
    padding: 14px 15px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.bound-account .section-label {
    display: block;
    color: #0f5132;
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 10px;
}

.bound-account dl {
    margin: 0;
}

.qr-action {
    color: var(--brand);
    border-color: #a7f3d0;
    background: #ecfdf3;
    font-weight: 700;
}

.mock-badge {
    display: inline-flex;
    padding: 4px 9px;
    border-radius: 999px;
    color: #6d28d9;
    background: #ede9fe;
    font-size: 12px;
    font-weight: 700;
}

.bottom-nav {
    display: none;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.stat.accent {
    color: #fff;
    background: linear-gradient(135deg, #3458e6, #6d4dea);
}

.stat.accent .muted {
    color: rgba(255, 255, 255, .82);
}

.payment-address {
    padding: 18px;
    margin: 14px 0;
    border-radius: 16px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
}

.payment-address code {
    display: block;
    padding: 12px;
    margin: 8px 0 18px;
    border-radius: 10px;
    background: #fff;
    word-break: break-all;
}

.pay-amount {
    display: block;
    color: var(--brand);
    font-size: 28px;
    margin: 8px 0 12px;
}

.receive-qr {
    display: block;
    width: min(220px, 100%);
    height: auto;
    margin: 16px auto;
    padding: 6px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    image-rendering: pixelated;
}

.countdown-panel {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 16px 18px;
    margin-bottom: 18px;
    color: #64748b;
    font-size: 13px;
    background: #ffffff;
    border: 1px solid #dbeafe;
    border-radius: 20px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .06);
}

.countdown-panel .countdown {
    padding: 0;
    font-size: clamp(46px, 7vw, 64px);
    line-height: 1.1;
    letter-spacing: .08em;
    font-weight: 700;
    color: #1d4ed8;
}

.review-info h3 {
    color: #0f5132;
}

.review-choices {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    gap: 10px;
    padding: 0;
    margin: 0 0 8px;
    border: 0;
}

.review-choices legend {
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

.review-choice {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 13px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 13px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.review-choice input {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    accent-color: var(--brand);
}

.review-choice.success {
    color: #166534;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.review-choice.alert {
    color: #991b1b;
    background: #fff7f7;
    border-color: #fecaca;
}

.review-choice.admin {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

.review-choice:has(input:checked) {
    box-shadow: 0 0 0 2px rgba(22, 101, 52, .18);
}

.review-submit {
    min-height: 48px;
    padding-left: 22px;
    padding-right: 22px;
    font-weight: 700;
}

@media (max-width: 760px) {
    .shell {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .topbar strong { font-size: 14px; }
    .topbar .warning { display: none; }
    .profile #user-name { display: none; }

    .page-head {
        display: block;
    }

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

    .content {
        padding: 14px 14px 82px;
    }

    .bottom-nav {
        position: fixed;
        z-index: 9;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        padding: 7px 6px max(7px, env(safe-area-inset-bottom));
        background: rgba(255,255,255,.97);
        border-top: 1px solid var(--line);
        box-shadow: 0 -8px 22px rgba(15,23,42,.07);
    }

    .bottom-btn {
        border: 0;
        padding: 10px 2px;
        min-height: 43px;
        font-size: 12px;
        color: var(--muted);
        background: transparent;
    }

    .bottom-btn.active {
        color: var(--brand);
        font-weight: 700;
        background: #eef2ff;
    }

    .panel {
        padding: 14px;
    }

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

    .table thead {
        display: none;
    }

    .table tr {
        margin-bottom: 12px;
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: 13px;
        background: #fff;
    }

    .table td {
        border: 0;
        padding: 5px 3px;
        white-space: normal;
        word-break: break-word;
    }

    button {
        min-height: 43px;
    }

    .order-amount strong {
        font-size: 24px;
    }

    .review-choices {
        grid-template-columns: 1fr;
    }
}
