:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-alt: #f7f8fa;
    --text: #20262f;
    --muted: #69717d;
    --line: #dfe3e8;
    --primary: #176b4d;
    --primary-hover: #10563d;
    --accent: #1877d2;
    --success: #138a52;
    --warning-bg: #fff4cf;
    --warning-line: #f1d06c;
    --warning-text: #735500;
    --danger: #b42318;
    --danger-bg: #fff0ee;
    --shadow: 0 10px 30px rgba(29, 39, 51, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif; font-size: 15px; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button, .btn { min-height: 42px; }
.site-header { height: 68px; padding: 0 max(24px, calc((100% - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 750; font-size: 18px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--primary); font-weight: 800; }
.site-header nav { display: flex; align-items: center; gap: 26px; color: var(--muted); }
.site-header nav a:hover { color: var(--primary); }
.site-main { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 70px; min-height: calc(100vh - 128px); }
.site-footer { height: 60px; display: grid; place-items: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); background: var(--surface); }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 30px; line-height: 1.25; }
h2 { font-size: 20px; }
.eyebrow { margin-bottom: 8px; color: var(--primary); font-weight: 700; font-size: 13px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 17px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; font-weight: 650; white-space: nowrap; }
.btn:hover { border-color: #b9c0c8; }
.btn:disabled { cursor: not-allowed; color: #959ca5; background: #f1f2f4; }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { color: var(--primary); border-color: #aac7bc; }
.btn-block { width: 100%; }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.product-card { min-height: 230px; display: flex; flex-direction: column; justify-content: space-between; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.product-card:hover { border-color: #b6c6c0; box-shadow: var(--shadow); }
.product-card h2 { margin: 18px 0 8px; }
.product-card p { color: var(--muted); line-height: 1.75; }
.product-card-bottom { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin-top: 24px; }
.stock { display: inline-flex; padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.in-stock { color: var(--success); background: #e9f7ef; }
.out-stock { color: var(--muted); background: #eef0f2; }
.price { display: flex; align-items: baseline; gap: 6px; color: var(--primary); }
.price strong { font-size: 27px; }
.price span { color: var(--muted); font-size: 12px; }
.price-large strong { font-size: 38px; }
.purchase-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 28px; align-items: start; }
.product-detail { padding: 6px 10px 20px 0; }
.back-link { display: inline-block; margin-bottom: 34px; color: var(--muted); }
.detail-title { display: flex; align-items: start; justify-content: space-between; gap: 24px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.description { padding: 28px 0; color: #444c56; line-height: 1.9; }
.notice-line { padding: 14px 16px; background: #edf6f2; border-left: 3px solid var(--primary); color: #365d4f; }
.checkout-panel { padding: 24px; }
.checkout-panel h2 { margin-bottom: 22px; }
label { display: block; margin-bottom: 18px; color: #454d57; font-weight: 650; }
input, textarea, select { width: 100%; margin-top: 8px; padding: 11px 12px; color: var(--text); background: #fff; border: 1px solid #cfd5dc; border-radius: 5px; outline: none; }
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 107, 77, .1); }
.field-help { margin: -9px 0 18px; color: var(--muted); font-size: 12px; }
.checkout-meta { margin-top: 20px; padding-top: 18px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); }
.checkout-meta strong { color: var(--success); }
.payment-shell { width: min(720px, 100%); margin: 0 auto; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.payment-title { display: flex; align-items: center; gap: 12px; padding: 20px 28px; border-bottom: 1px solid var(--line); }
.payment-title p { margin: 0 0 4px; font-size: 19px; font-weight: 750; }
.payment-title div span { color: var(--muted); font-size: 13px; }
.usdt-badge { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #fff; background: #26a17b; font-size: 22px; font-weight: 800; }
.amount-block { padding: 38px 24px 26px; display: flex; align-items: center; flex-direction: column; }
.amount-block > span { color: var(--muted); }
.amount-block strong { margin: 6px 0 2px; font-size: 48px; line-height: 1.15; }
.amount-block small { color: var(--muted); font-size: 15px; }
.address-block { margin: 0 28px; padding: 18px; display: grid; grid-template-columns: 1fr auto; gap: 9px 18px; background: var(--surface-alt); border: 1px solid #eceff2; border-radius: 7px; }
.address-block > span { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.address-block code { align-self: center; overflow-wrap: anywhere; color: #344052; font-size: 15px; }
.payment-warning { margin: 20px 28px 0; padding: 15px 17px; display: flex; flex-direction: column; gap: 5px; color: var(--warning-text); background: var(--warning-bg); border: 1px solid var(--warning-line); border-radius: 7px; }
.payment-warning span { font-size: 13px; line-height: 1.6; }
.payment-meta { margin: 22px 28px 0; }
.payment-meta div { padding: 9px 0; display: flex; justify-content: space-between; gap: 20px; }
.payment-meta dt { color: var(--muted); }
.payment-meta dd { margin: 0; text-align: right; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.payment-checking { padding: 22px 28px 30px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.spinner { width: 19px; height: 19px; border: 3px solid #d9dfe4; border-top-color: var(--primary); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.payment-state { padding: 60px 28px; text-align: center; }
.payment-state p { color: var(--muted); }
.query-shell { width: min(880px, 100%); margin: 0 auto; }
.center-heading { margin-bottom: 26px; text-align: center; }
.center-heading p:last-child { color: var(--muted); }
.query-form { margin-bottom: 24px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.query-form input { margin: 0; min-height: 48px; }
.order-result { padding: 26px; }
.order-result-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.order-result h2 { margin: 12px 0 0; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 750; }
.status-pending { color: #7a5900; background: #fff2c3; }
.status-paid { color: var(--success); background: #e7f7ee; }
.status-expired, .status-cancelled { color: var(--muted); background: #edf0f2; }
.detail-list { margin: 10px 0 24px; }
.detail-list div { padding: 12px 0; display: grid; grid-template-columns: 120px 1fr; border-bottom: 1px solid #edf0f2; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }
.delivery-box { padding: 18px; background: #eef8f3; border: 1px solid #c5e5d7; border-radius: 7px; }
.delivery-box h3 { margin-bottom: 14px; color: var(--success); }
.code-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #d4e9df; }
.code-row code { overflow-wrap: anywhere; color: #b42318; font-size: 15px; }
.icon-copy { padding: 5px 8px; color: var(--accent); background: transparent; border: 0; cursor: pointer; }
.alert { padding: 13px 16px; border: 1px solid; border-radius: 6px; line-height: 1.5; }
.alert-danger { color: var(--danger); background: var(--danger-bg); border-color: #f2c2bc; }
.alert-success { color: var(--success); background: #e9f7ef; border-color: #bce0cc; }
.global-alert { width: min(1180px, calc(100% - 36px)); margin: 18px auto -20px; }
.empty-state { padding: 80px 24px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed #cbd1d7; border-radius: 8px; }
.empty-state h1, .empty-state h2 { color: var(--text); }
.setup-page { padding: 48px 18px; }
.setup-shell { width: min(760px, 100%); margin: 0 auto; }
.setup-heading { margin-bottom: 22px; display: flex; align-items: center; gap: 14px; }
.setup-heading h1 { margin: 0 0 4px; font-size: 25px; }
.setup-heading p { margin: 0; color: var(--muted); }
.setup-shell > .alert { margin-bottom: 16px; }
.form-grid { padding: 25px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.span-2 { grid-column: 1 / -1; }

/* Admin */
.admin-body { min-width: 320px; background: #f1f3f5; }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: 218px; display: flex; flex-direction: column; color: #dce4e9; background: #26343a; }
.admin-brand { height: 70px; padding: 0 22px; display: flex; align-items: center; gap: 11px; color: #fff; font-size: 17px; font-weight: 750; border-bottom: 1px solid rgba(255,255,255,.08); }
.admin-sidebar nav { padding: 18px 12px; display: flex; flex-direction: column; gap: 5px; }
.admin-sidebar nav a { padding: 12px 15px; border-radius: 5px; }
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { color: #fff; background: #176b4d; }
.admin-side-bottom { margin-top: auto; padding: 18px 25px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.admin-side-bottom button { min-height: auto; padding: 0; color: #dce4e9; background: transparent; border: 0; cursor: pointer; }
.admin-content { min-height: 100vh; margin-left: 218px; }
.admin-topbar { height: 70px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.admin-topbar h1 { margin: 0; font-size: 21px; }
.admin-topbar span { color: var(--muted); font-size: 13px; }
.admin-main { padding: 26px; }
.admin-main > .alert { margin-bottom: 18px; }
.admin-notice a { margin-left: 8px; text-decoration: underline; }
.stat-grid { margin-bottom: 20px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-box { min-height: 126px; padding: 20px; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.stat-box span { color: var(--muted); }
.stat-box strong { margin-top: 11px; font-size: 31px; }
.stat-box small { margin-top: 4px; color: var(--primary); }
.admin-section, .admin-form { margin-bottom: 20px; padding: 22px; box-shadow: none; }
.section-heading { min-height: 42px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading h2 { margin: 0; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.section-heading > a:not(.btn) { color: var(--accent); }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid #e8ebee; }
th { color: var(--muted); background: #f7f8f9; font-size: 12px; font-weight: 650; }
td { font-size: 13px; }
tbody tr:hover { background: #fafbfb; }
.table-link, .actions a { color: var(--accent); }
.number-success { color: var(--success); font-weight: 750; }
.actions { display: flex; align-items: center; gap: 12px; }
.actions form { margin: 0; }
.actions button, .link-danger { min-height: auto; padding: 0; color: var(--accent); background: transparent; border: 0; cursor: pointer; }
.link-danger { color: var(--danger); }
.admin-empty { padding: 45px 15px; text-align: center; color: var(--muted); }
.admin-form { max-width: 880px; }
.admin-form label small { margin-top: 6px; display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.toggle-label { display: flex; align-items: center; gap: 9px; }
.toggle-label input { width: 17px; height: 17px; margin: 0; }
.form-actions { padding-top: 8px; display: flex; justify-content: flex-end; gap: 10px; }
.form-section-title { margin: 28px 0 17px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.form-section-title:first-child { margin-top: 0; }
.form-section-title h2 { margin: 0; font-size: 17px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.inventory-strip { margin-bottom: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.inventory-strip > div { padding: 16px 20px; display: flex; align-items: baseline; justify-content: space-between; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.inventory-strip span { color: var(--muted); }
.inventory-strip strong { font-size: 25px; }
.code-input { min-height: 180px; font-family: "Cascadia Mono", Consolas, monospace; }
.admin-code { max-width: 480px; display: inline-block; overflow: hidden; text-overflow: ellipsis; color: #374151; }
.filter-bar { margin-bottom: 18px; display: grid; grid-template-columns: 180px minmax(240px, 1fr) auto; gap: 10px; }
.filter-bar input, .filter-bar select { margin: 0; }
.order-number { margin: 10px 0 0; font-family: "Cascadia Mono", Consolas, monospace; }
.admin-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.admin-detail-grid > div { padding: 14px 0; border-bottom: 1px solid #e9ecef; }
.admin-detail-grid .wide { grid-column: 1 / -1; }
.admin-detail-grid dt { margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.admin-detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.admin-delivery { margin-top: 22px; padding: 18px; background: #f6f8f8; border: 1px solid var(--line); border-radius: 6px; }
.admin-delivery h3 { margin-bottom: 10px; }
.manual-confirm { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.login-page { padding: 8vh 18px; }
.login-panel { width: min(420px, 100%); margin: 0 auto; padding: 28px; }
.login-heading { margin-bottom: 25px; display: flex; align-items: center; gap: 13px; }
.login-heading h1 { margin: 0 0 4px; font-size: 24px; }
.login-heading p { margin: 0; color: var(--muted); }
.login-panel .alert { margin-bottom: 18px; }

@media (max-width: 820px) {
    .product-grid { grid-template-columns: 1fr 1fr; }
    .purchase-layout { grid-template-columns: 1fr; }
    .checkout-panel { width: 100%; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    .site-header { height: auto; min-height: 64px; padding: 13px 18px; align-items: flex-start; gap: 14px; }
    .site-header nav { gap: 15px; padding-top: 8px; font-size: 13px; }
    .brand { max-width: 55%; font-size: 15px; }
    .brand-mark { flex: 0 0 30px; width: 30px; height: 30px; }
    .site-main { width: min(100% - 24px, 1180px); padding: 28px 0 50px; }
    h1 { font-size: 25px; }
    .page-heading { align-items: start; gap: 18px; }
    .product-grid { grid-template-columns: 1fr; }
    .detail-title, .order-result-head { flex-direction: column; }
    .price-large strong { font-size: 32px; }
    .payment-title { padding: 18px; }
    .amount-block strong { font-size: 38px; }
    .address-block, .payment-warning, .payment-meta { margin-left: 14px; margin-right: 14px; }
    .address-block { grid-template-columns: 1fr; }
    .address-block .btn { width: 100%; }
    .query-form { grid-template-columns: 1fr; }
    .detail-list div { grid-template-columns: 90px 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .admin-sidebar { position: static; width: 100%; }
    .admin-brand { height: 60px; }
    .admin-sidebar nav { padding: 8px 12px; flex-direction: row; overflow-x: auto; }
    .admin-sidebar nav a { padding: 9px 12px; white-space: nowrap; }
    .admin-side-bottom { display: none; }
    .admin-content { margin-left: 0; }
    .admin-topbar { height: 58px; padding: 0 16px; }
    .admin-main { padding: 14px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-box { min-height: 104px; padding: 15px; }
    .stat-box strong { font-size: 26px; }
    .admin-section, .admin-form { padding: 15px; }
    .filter-bar { grid-template-columns: 1fr; }
    .settings-grid, .admin-detail-grid { grid-template-columns: 1fr; }
    .admin-detail-grid .wide { grid-column: auto; }
    .inventory-strip { grid-template-columns: 1fr; }
}
