/* =====================================================================
   微信支付 APIv3 演示工程 —— 唯一一套极简卡片样式
   不做 UI 打磨，只保证：能看、能点、状态颜色可区分
   ===================================================================== */

:root {
    --green: #07c160;
    --green-dark: #06ad56;
    --blue: #1677ff;
    --yellow-bg: #fffbe6;
    --yellow-border: #ffe58f;
    --yellow-text: #b8860b;
    --red-bg: #fff1f0;
    --red-border: #ffa39e;
    --red-text: #cf1322;
    --gray-bg: #f5f5f5;
    --border: #e5e5e5;
    --text: #1f1f1f;
    --text-muted: #8c8c8c;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0 0 40px;
    background: #f0f2f5;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------------- 布局 ---------------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.topbar .nav {
    display: flex;
    gap: 14px;
    font-size: 14px;
}

.wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: 18px 16px 0;
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}

.card-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 600;
}

/* ---------------- 告警条 ---------------- */

.alert {
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.7;
    display: none;
}

.alert.show {
    display: block;
}

.alert-warn {
    background: var(--yellow-bg);
    border: 1px solid var(--yellow-border);
    color: var(--yellow-text);
}

.alert-error {
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    color: var(--red-text);
}

.alert-info {
    background: #e6f4ff;
    border: 1px solid #91caff;
    color: #0958d9;
}

.alert ul {
    margin: 6px 0 0;
    padding-left: 20px;
}

.alert li {
    word-break: break-all;
}

/* ---------------- 商品卡 ---------------- */

.product {
    display: flex;
    align-items: center;
    gap: 16px;
}

.product-thumb {
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--green), #43d97f);
    color: #fff;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-info h2 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
}

.product-info .price {
    color: var(--red-text);
    font-size: 20px;
    font-weight: 700;
}

.product-info .hint {
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------------- 按钮 ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.btn:hover:not(:disabled) {
    background: #fafafa;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    background: var(--gray-bg);
}

.btn-primary {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
    font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
    background: var(--green-dark);
    border-color: var(--green-dark);
}

.btn-danger {
    color: var(--red-text);
    border-color: var(--red-border);
}

.btn-block {
    width: 100%;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-row .btn {
    flex: 1 1 0;
    min-width: 130px;
}

/* ---------------- 字段表 ---------------- */

.kv {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.kv th,
.kv td {
    padding: 9px 0;
    border-bottom: 1px dashed var(--border);
    text-align: left;
    vertical-align: top;
}

.kv th {
    width: 104px;
    color: var(--text-muted);
    font-weight: 400;
    white-space: nowrap;
}

.kv td {
    word-break: break-all;
}

.kv tr:last-child th,
.kv tr:last-child td {
    border-bottom: none;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

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

/* ---------------- 状态色 ---------------- */

.state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
}

.state-INIT,
.state-NOTPAY,
.state-PAYING {
    background: #fff7e6;
    color: #d46b08;
}

.state-SUCCESS {
    background: #f6ffed;
    color: #389e0d;
}

.state-CLOSED,
.state-REFUND {
    background: var(--gray-bg);
    color: #595959;
}

.state-PAYERROR,
.state-FAILED {
    background: var(--red-bg);
    color: var(--red-text);
}

/* ---------------- 二维码 / 收银台 ---------------- */

.qr-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
}

.qr-box img {
    display: block;
    width: 260px;
    height: 260px;
    image-rendering: pixelated;
}

.qr-box.masked img {
    opacity: .15;
    filter: grayscale(1);
}

.qr-mask {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    font-weight: 600;
    color: var(--red-text);
}

.qr-box.masked .qr-mask {
    display: flex;
}

.center {
    text-align: center;
}

.big-state {
    font-size: 26px;
    margin: 8px 0 4px;
    font-weight: 700;
}

.big-state-label {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 12px;
}

.countdown {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.status-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* ---------------- 服务端渲染的六参数 ---------------- */

pre.params {
    margin: 0;
    padding: 12px;
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---------------- 步骤说明 ---------------- */

.steps {
    margin: 0 0 16px;
    padding-left: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.steps li {
    margin-bottom: 4px;
}

/* ---------------- 表格（订单列表） ---------------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

table.list {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

table.list th,
table.list td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.list th {
    background: #fafafa;
    color: var(--text-muted);
    font-weight: 500;
}

table.list tbody tr:last-child td {
    border-bottom: none;
}

table.list tbody tr:hover {
    background: #fafafa;
}

.empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
}

/* ---------------- 加载态 ---------------- */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

.hidden {
    display: none !important;
}

.footer-note {
    margin-top: 20px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.8;
}

@media (max-width: 480px) {
    .wrap {
        padding: 14px 12px 0;
    }

    .qr-box img {
        width: 220px;
        height: 220px;
    }

    .btn-row .btn {
        flex: 1 1 100%;
    }
}

/* =====================================================================
   下单表单（首页）与收银台补充样式
   仅用原生 CSS，不引入任何框架/CDN（离线部署要求）
   ===================================================================== */

.field {
    margin: 0 0 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.field .required {
    color: var(--red-text);
}

.field input,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
}

.field input:disabled,
.field textarea:disabled {
    background: var(--gray-bg);
    color: var(--text-muted);
}

.field textarea {
    resize: vertical;
    min-height: 56px;
}

.field-hint {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-muted);
}

/* 校验态：红框 + 红字提示，错误原因就写在该字段下方 */
.field.invalid input,
.field.invalid textarea {
    border-color: var(--red-border);
    background: var(--red-bg);
}

.field.invalid .field-hint {
    color: var(--red-text);
}

.form-actions {
    margin-top: 20px;
}

.amount-line {
    margin: 0 0 16px;
    font-size: 15px;
}

.amount-line strong {
    font-size: 26px;
    color: var(--text);
}

/* 用 <a class="btn"> 当按钮时（如「返回首页」）需要显式对齐 */
a.btn {
    display: inline-block;
    text-align: center;
    text-decoration: none;
    line-height: 1.4;
}

/* =====================================================================
   订单详情页：流水折叠区（默认收起，点开才请求 /logs）
   ===================================================================== */

.logs-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 0;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.logs-toggle-icon {
    display: inline-block;
    width: 14px;
    color: var(--text-muted);
}

table.list.logs {
    font-size: 12px;
}

table.list.logs th,
table.list.logs td {
    padding: 8px 10px;
}

table.list.logs tbody tr:hover {
    background: #fafafa;
}
