:root {
    --porcelain: #f7f8fa;
    --paper: #ffffff;
    --ink: #1f2530;
    --muted: #59616d;
    --coral: #e95d5d;
    --coral-dark: #9f3038;
    --action: #b33b43;
    --coral-pale: #fff1f1;
    --success: #0d6846;
    --success-pale: #eaf7f1;
    --line: #e7e9ee;
    --shadow: 0 16px 48px rgba(31, 37, 48, 0.08);
    --display: "Songti SC", "STSong", "SimSun", serif;
    --body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { color: var(--ink); background: var(--porcelain); font-family: var(--body); }

body { margin: 0; min-width: 320px; }

button, input, textarea, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button { cursor: pointer; }

a { color: inherit; }

:focus-visible {
    outline: 3px solid rgba(233, 93, 93, 0.34);
    outline-offset: 3px;
}

.buyer-page {
    min-height: 100vh;
    background:
        linear-gradient(rgba(31, 37, 48, 0.025) 1px, transparent 1px),
        var(--porcelain);
    background-size: 100% 32px;
}

.buyer-shell {
    width: min(100%, 520px);
    min-height: 100svh;
    margin: 0 auto;
    padding: 20px 14px;
    display: grid;
    align-items: center;
}

.pickup-slip {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.slip-head, .slip-body, .slip-foot { padding: 24px; }

.slip-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 20px;
}

.eyebrow, .section-kicker {
    margin: 0 0 8px;
    color: var(--coral-dark);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }

.slip-head h1, .admin-login-card h1 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(28px, 8vw, 38px);
    font-weight: 700;
    line-height: 1.14;
    letter-spacing: 0.03em;
}

.status-stamp {
    flex: 0 0 auto;
    padding: 7px 9px 6px;
    border: 1.5px solid currentColor;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    transform: rotate(2.5deg);
}

.status-stamp--pending { color: var(--coral-dark); background: var(--coral-pale); }
.status-stamp--ready { color: var(--success); background: var(--success-pale); }

.perforation {
    position: relative;
    height: 17px;
    margin: 0 -1px;
    overflow: hidden;
}

.perforation::before, .perforation::after {
    content: "";
    position: absolute;
    z-index: 2;
    top: 0;
    width: 17px;
    height: 17px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--porcelain);
}

.perforation::before { left: -9px; }
.perforation::after { right: -9px; }

.perforation span {
    position: absolute;
    top: 8px;
    left: 14px;
    right: 14px;
    border-top: 1px dashed #cbd0d9;
}

.slip-body { padding-top: 19px; }

.lead { margin: 0 0 22px; color: #535b68; font-size: 15px; line-height: 1.7; }

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

label { display: block; color: #4d5561; font-size: 13px; font-weight: 700; }

input, textarea, select {
    width: 100%;
    min-height: 48px;
    border: 1px solid #d9dde4;
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
    padding: 11px 13px;
    font-size: 16px;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea { min-height: 104px; resize: vertical; line-height: 1.55; }

input:focus, textarea:focus, select:focus {
    border-color: var(--coral);
    box-shadow: 0 0 0 4px rgba(233, 93, 93, 0.1);
    outline: none;
}

input::placeholder, textarea::placeholder { color: #676f7b; opacity: 1; }

#card-code {
    font-family: var(--mono);
    font-size: 17px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.button {
    min-height: 48px;
    border: 1px solid transparent;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    font-weight: 750;
    line-height: 1.2;
    text-decoration: none;
    transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.button:active { transform: translateY(1px); }
.button--primary { color: white; background: var(--action); }
.button--primary:hover { background: #922f36; }
.button--secondary { color: var(--coral-dark); background: var(--coral-pale); border-color: #f4caca; }
.button--quiet { color: var(--ink); background: white; border-color: var(--line); }
.button--quiet:hover { border-color: #bbc0ca; background: var(--porcelain); }
.button--danger { min-height: 44px; color: white; background: #9f3038; }
.button--danger:hover { background: #81272e; }

.slip-body > .button { width: 100%; margin-top: 18px; }

.slip-foot {
    display: grid;
    gap: 5px;
    border-top: 1px solid var(--line);
    background: #fbfbfc;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.slip-foot p { margin: 0; }
.slip-foot strong { color: var(--ink); }

.slip-foot--actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.notice {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.55;
}

.notice--error { color: #872a30; border-color: #eabcbc; background: var(--coral-pale); }
.notice--success { color: #0d6544; border-color: #b4ddcb; background: var(--success-pale); }

.resource-list { margin: 0; display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }

.resource-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 14px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.resource-row:last-child { border-bottom: 0; }
.resource-row dt { grid-column: 1 / -1; color: var(--muted); font-size: 12px; font-weight: 700; }
.resource-row dd { margin: 0; min-width: 0; align-self: center; }
.resource-value { font-size: 14px; line-height: 1.55; }
.resource-value--link { word-break: break-all; }
.resource-code { font-family: var(--mono); font-size: 23px; font-weight: 750; letter-spacing: 0.16em; }

.copy-button, .text-button {
    min-height: 44px;
    border: 0;
    padding: 8px 0;
    color: var(--coral-dark);
    background: transparent;
    font-size: 13px;
    font-weight: 750;
}

.copy-button { padding-inline: 10px; }
.updated-at { margin: 12px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.instructions { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.instructions h2 { margin: 0 0 8px; font-size: 14px; }
.instructions p { margin: 0; color: #535b68; font-size: 13px; line-height: 1.7; }

.empty-state { padding: 22px 4px 16px; text-align: center; }
.empty-state__mark { display: block; color: var(--coral); font-family: var(--mono); font-size: 30px; letter-spacing: 0.14em; }
.empty-state h2 { margin: 8px 0; font-family: var(--display); font-size: 22px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.toast {
    position: fixed;
    left: 50%;
    bottom: max(22px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 20;
    padding: 11px 17px;
    border-radius: 999px;
    color: white;
    background: var(--ink);
    box-shadow: 0 8px 26px rgba(31, 37, 48, 0.22);
    font-size: 13px;
    font-weight: 700;
}

/* Administrator surfaces */
.admin-page, .admin-login-page { min-height: 100vh; background: var(--porcelain); }

.admin-login-shell { min-height: 100svh; padding: 24px; display: grid; place-items: center; }

.admin-login-card {
    width: min(100%, 420px);
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: white;
    box-shadow: var(--shadow);
}

.admin-login-card .muted { margin: 10px 0 24px; }
.admin-login-card .stack-form { gap: 10px; }
.admin-login-card .stack-form label:not(:first-of-type) { margin-top: 7px; }
.back-link { min-height: 44px; margin-top: 10px; display: inline-flex; align-items: center; justify-content: center; width: 100%; color: var(--muted); font-size: 13px; text-align: center; }

.admin-topbar {
    min-height: 82px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px max(20px, calc((100vw - 1180px) / 2));
    background: rgba(255, 255, 255, 0.94);
}

.admin-topbar h1 { margin: 0; font-family: var(--display); font-size: 24px; }
.admin-topbar .eyebrow { margin-bottom: 3px; }
.admin-topbar .button { min-height: 44px; }

.admin-main { width: min(100% - 32px, 1180px); margin: 28px auto 64px; display: grid; gap: 20px; }

.admin-section {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
    padding: 24px;
}

.section-heading { margin-bottom: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font-family: var(--display); font-size: 21px; }
.section-heading--wrap { flex-wrap: wrap; align-items: end; }
.section-kicker { margin-bottom: 5px; }

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
}

.status-pill--ready { color: var(--success); background: var(--success-pale); }
.status-pill--muted { color: var(--muted); background: #f0f1f4; }

.admin-form { display: grid; gap: 10px; }
.admin-form--resource { grid-template-columns: minmax(140px, 0.45fr) minmax(230px, 1fr); gap: 14px; }
.admin-form--resource > div, .admin-form--generate > div { display: grid; gap: 8px; }
.admin-form--resource .form-actions { grid-column: 1 / -1; display: flex; }
.admin-form--generate { grid-template-columns: minmax(0, 1fr) 180px; gap: 14px; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 16px; }
.form-meta { color: var(--muted); font-size: 12px; }

.refresh-detail { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.refresh-detail summary { min-height: 44px; display: flex; align-items: center; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 700; }
.compact-data { margin: 14px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.compact-data div { padding: 12px; border-radius: 8px; background: var(--porcelain); }
.compact-data dt { color: var(--muted); font-size: 11px; }
.compact-data dd { margin: 5px 0 0; font-size: 13px; }

.export-ticket {
    position: relative;
    margin-top: 22px;
    padding: 20px;
    border: 1px dashed #e9aaaa;
    border-radius: 10px;
    background: var(--coral-pale);
    display: grid;
    grid-template-columns: 1fr minmax(240px, 0.9fr) auto;
    align-items: center;
    gap: 18px;
}

.export-ticket h3 { margin: 0; font-family: var(--display); font-size: 20px; }
.export-ticket p { margin: 7px 0 0; color: #714848; font-size: 12px; line-height: 1.5; }
.code-preview { max-height: 124px; overflow: auto; white-space: pre; font: 12px/1.6 var(--mono); }
.export-actions { display: grid; gap: 8px; }
.export-actions .button { width: 100%; }

.filter-form { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-form input { width: 210px; }
.filter-form select { width: 120px; }
.filter-form .button, .filter-form input, .filter-form select { min-height: 44px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; min-width: 850px; font-size: 13px; }
th { color: var(--muted); background: #fafbfc; font-size: 11px; letter-spacing: 0.03em; text-align: left; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td code { font-family: var(--mono); font-size: 12px; }
.small-data { color: var(--muted); font-size: 11px; line-height: 1.55; }
.table-empty { padding: 28px; color: var(--muted); text-align: center; }
.row-actions { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.row-actions .text-button { min-width: 44px; padding-inline: 8px; white-space: nowrap; }
.confirm-action { position: relative; }
.confirm-action summary { min-width: 44px; min-height: 44px; padding-inline: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--coral-dark); cursor: pointer; font-size: 13px; font-weight: 750; list-style: none; white-space: nowrap; }
.confirm-action summary::-webkit-details-marker { display: none; }
.confirm-action__panel { width: 220px; padding: 12px; border: 1px solid #dfb4b7; border-radius: 9px; background: var(--coral-pale); box-shadow: 0 8px 20px rgba(31, 37, 48, 0.1); }
.confirm-action__panel p { margin: 0 0 10px; color: #682e33; font-size: 12px; line-height: 1.5; }
.confirm-action__panel .button { width: 100%; min-width: 44px; padding-inline: 12px; }
.pagination { margin-top: 16px; display: flex; justify-content: center; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.pagination .button { min-height: 44px; padding: 8px 13px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.clipboard-proxy { position: fixed; inset: 0 auto auto 0; width: 1px; min-height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }

@media (max-width: 720px) {
    .buyer-shell { align-items: start; padding-top: 12px; }
    .slip-head, .slip-body, .slip-foot { padding-inline: 20px; }
    .slip-head { padding-top: 22px; }
    .admin-main { width: min(100% - 20px, 1180px); margin-top: 10px; }
    .admin-topbar { padding: 12px 14px; }
    .admin-section { padding: 18px 15px; border-radius: 11px; }
    .admin-form--resource, .admin-form--generate, .compact-data { grid-template-columns: 1fr; }
    .field-wide { grid-column: 1; }
    .form-actions { align-items: stretch; flex-direction: column; }
    .export-ticket { grid-template-columns: 1fr; }
    .filter-form, .filter-form input, .filter-form select, .filter-form .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
