:root {
    --ink: #172230;
    --muted: #73808e;
    --line: #dfe6eb;
    --paper: #f7f9fa;
    --white: #ffffff;
    --accent: #d66c46;
    --accent-dark: #ad4e2f;
    --green: #328b69;
    --red: #bf5960;
    --shadow: 0 24px 60px rgba(29, 45, 58, .09);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font: 15px/1.5 "Segoe UI", "Microsoft YaHei", sans-serif;
}
a { color: inherit; }
.shell { width: min(1080px, calc(100% - 40px)); margin: 0 auto; padding: 64px 0 32px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.hero h1, h2, p { margin: 0; }
.hero h1 { font-size: clamp(36px, 6vw, 68px); line-height: .95; letter-spacing: 0; font-weight: 800; }
.hero p { max-width: 240px; color: var(--muted); }
.eyebrow { color: var(--accent-dark); font-size: 11px; letter-spacing: 2px; font-weight: 800; }
.panel { background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; }
.access-panel { padding: 32px; }
.panel-heading, .section-heading, .quota-line, .claim-meta { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-heading h2, .section-heading h2 { font-size: 24px; margin-top: 2px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 6px #faece7; }
.key-form { margin-top: 28px; }
label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.input-row { display: flex; gap: 12px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: #fbfcfd; font: inherit; padding: 13px 14px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(214,108,70,.12); }
.button { border: 0; border-radius: 5px; padding: 12px 18px; color: #fff; font: inherit; font-weight: 700; cursor: pointer; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { background: var(--ink); min-width: 100px; }
.button-accent { background: var(--accent); }
.button-accent:hover { background: var(--accent-dark); }
.button-large { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 24px; padding: 16px 18px; font-size: 16px; }
.form-message { min-height: 24px; margin-top: 8px; color: var(--red); font-size: 13px; }
.claim-zone { margin-top: 16px; padding-top: 24px; border-top: 1px solid var(--line); }
.quota-line strong { color: var(--accent-dark); font-size: 30px; line-height: 1; }
.quota-track { height: 5px; margin: 14px 0 10px; border-radius: 99px; background: #edf0f2; overflow: hidden; }
.quota-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .3s; }
.claim-meta { color: var(--muted); font-size: 12px; }
.results-section { margin-top: 48px; }
.count-label { color: var(--muted); font-size: 13px; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 18px; }
.qr-card { display: flex; flex-direction: column; min-width: 0; background: var(--white); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qr-image { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; padding: 20px; background: #fff; }
.qr-content { padding: 15px; border-top: 1px solid var(--line); }
.qr-number { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.qr-text { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.qr-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.qr-action { border: 1px solid var(--line); border-radius: 4px; background: #fff; padding: 9px 4px; color: var(--muted); font-size: 11px; cursor: pointer; }
.qr-action:hover { border-color: var(--ink); color: var(--ink); }
.qr-action.selected { color: #fff; border-color: transparent; background: var(--ink); }
.qr-action[data-result="not_winner"].selected { background: var(--red); }
.qr-action[data-result="redeemed"].selected { background: #778391; }
.qr-action[data-result="available"].selected { background: var(--green); }
.qr-card.is-done .qr-action:not(.selected) { opacity: .45; cursor: not-allowed; }
.site-footer { display: flex; justify-content: space-between; margin-top: 56px; color: #9aa4ad; font-size: 12px; }
.site-footer a { text-decoration: none; }
.hidden { display: none !important; }

@media (max-width: 640px) {
    .shell { width: min(100% - 24px, 560px); padding-top: 32px; }
    .hero { display: block; }
    .hero p { margin-top: 16px; }
    .access-panel { padding: 22px; }
    .input-row { display: grid; grid-template-columns: 1fr; }
    .button-primary { width: 100%; }
}

/* Admin */
.admin-shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 48px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 28px; }
.admin-header h1 { margin: 4px 0 0; font-size: 32px; }
.admin-nav { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 13px; }
.admin-nav a { text-decoration: none; }
.admin-layout { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.admin-panel { padding: 24px; }
.admin-panel h2 { font-size: 18px; margin-bottom: 18px; }
.field { margin-bottom: 16px; }
.field small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
textarea { min-height: 180px; resize: vertical; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { color: var(--muted); font-size: 11px; letter-spacing: .5px; font-weight: 700; }
.admin-table td code { overflow-wrap: anywhere; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.inline-edit, .row-actions { display: flex; align-items: center; gap: 6px; }
.inline-edit input { width: 82px; padding: 6px 7px; font-size: 12px; }
.row-actions .button { min-width: auto; padding: 6px 9px; font-size: 11px; white-space: nowrap; }
.button-danger { background: var(--red); }
.button-danger:hover { background: #9f4048; }
.table-note, .panel-note { display: block; color: var(--muted); font-size: 11px; }
.table-note { margin-top: 5px; }
.panel-note { margin: -8px 0 12px; }
.data-cell { min-width: 280px; }
.data-editor { display: block; min-height: 68px; width: min(420px, 100%); padding: 8px 9px; font-size: 12px; }
.result-editor { min-width: 92px; padding: 7px 8px; font-size: 12px; }
.tag { display: inline-block; padding: 3px 7px; border-radius: 99px; background: #edf5f1; color: var(--green); font-size: 11px; }
.tag.off { background: #f8eeee; color: var(--red); }
.admin-message { min-height: 22px; margin-top: 10px; color: var(--green); font-size: 13px; }
.login-wrap { width: min(420px, calc(100% - 32px)); margin: 12vh auto; }
.login-wrap .panel { padding: 32px; }
@media (max-width: 900px) { .admin-layout { grid-template-columns: 1fr; } }
