:root {
  color-scheme: light;
  --paper: #f0f5fb;
  --surface: #ffffff;
  --ink: #162740;
  --muted: #536782;
  --line: #d7e2ee;
  --accent: #285ed4;
  --deep: #17345d;
  --ticket-ink: #b9eee8;
  --error: #942d24;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner, .shell { width: min(1040px, calc(100% - 56px)); margin-inline: auto; }
.top-inner { display: flex; justify-content: space-between; align-items: center; min-height: 54px; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--ticket-ink); background: var(--deep); font: 700 23px/1 system-ui; }
nav { display: flex; align-items: center; gap: 8px; }
nav a { padding: 10px 14px; border-radius: 7px; text-decoration: none; font-size: 14px; color: var(--muted); white-space: nowrap; }
nav a[aria-current] { background: #e8eff9; color: var(--deep); font-weight: 700; }
nav a:hover { color: var(--deep); }

.shell { padding-block: 32px 48px; }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(21px, 3vw, 27px); letter-spacing: -.025em; }
h2 { font-size: 16px; letter-spacing: -.015em; }
h3 { font-size: 13px; }
.mode { border: 1px solid #ffffff5c; border-radius: 20px; background: #ffffff17; color: #ecf7ff; padding: 6px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.admin-mode { background: #e3eef9; border-color: #ccdcec; color: #264e80; margin-right: auto; }
.admin-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: clamp(18px, 3.5vw, 26px); min-width: 0; }
.customer { max-width: 914px; }
.customer-workspace { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--surface); }
.customer-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 17px; }
.customer-nav a { min-width: 0; text-align: center; padding: 8px 13px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; background: var(--surface); transition: background-color .14s, color .14s, transform .14s cubic-bezier(.22,.8,.25,1); }
.customer-nav a[aria-current] { background: var(--accent); border-color: var(--accent); color: white; }
.customer-nav a:active { transform: scale(.97); }
.flow, .tool-panel { padding: clamp(18px, 3.5vw, 26px); min-height: 0; }

.hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: 8px; }
.stage:not([hidden]), .tool-panel:not([hidden]) { animation: appear .21s cubic-bezier(.22,.8,.25,1) both; }
#redeem[data-direction="back"] .stage { --entry-offset: -7px; }
@keyframes appear { from { opacity: .45; transform: translateX(var(--entry-offset, 7px)); } to { opacity: 1; transform: none; } }
form { display: grid; gap: 12px; margin-top: 23px; }
label { font-size: 13px; font-weight: 650; display: grid; gap: 8px; min-width: 0; }
input:not([type=checkbox]), textarea, select { border: 1px solid var(--line); border-radius: 12px; width: 100%; background: #ebf1f9; color: var(--ink); padding: 9px 12px; min-height: 39px; font-size: 14px; }
textarea { resize: vertical; min-height: 100px; line-height: 1.5; }
.code-entry, #codes { font-family: 'Cascadia Mono', Consolas, monospace; letter-spacing: .035em; }
.primary, .secondary { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 38px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--accent); font-size: 12px; font-weight: 700; text-decoration: none; transition: background-color .14s, transform .14s cubic-bezier(.22,.8,.25,1); }
.flow form > .primary, .tool-panel form > .primary { justify-self: start; }
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: #204f9d; }
.primary:active:not(:disabled) { transform: translateY(1px); }
.secondary { background: var(--surface); color: var(--accent); }
.text-btn { border: 0; padding: 5px 0; background: transparent; color: var(--accent); font-size: 13px; font-weight: 700; }
.text-btn:hover { text-decoration: underline; text-underline-offset: 4px; }
.stage > .text-btn { margin-bottom: 13px; }
.field-head, .actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.actions { justify-content: start; margin-top: 19px; }
.preset { color: var(--muted); font-weight: 600; font-size: 13px; margin-top: 9px; }
.summary { margin: 16px 0 20px; }
.summary > div { display: flex; justify-content: space-between; gap: 18px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.summary dt { color: var(--muted); min-width: 0; }
.summary dd { margin: 0; text-align: right; font-weight: 650; overflow-wrap: anywhere; }
.status { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: 13px; }
.status[data-kind="error"] { color: var(--error); }

.field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; min-height: 30px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.issued { margin-top: 25px; border-top: 1px solid var(--line); padding-top: 16px; }
.issued textarea { margin-top: 8px; }
.login { max-width: 480px; }
.codes-list { list-style: none; margin: 14px 0 0; padding: 0; }
.codes-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 0; border-top: 1px solid var(--line); }
.codes-list code { font-weight: 700; }
.codes-list li > div:first-child { min-width: 0; }
.codes-list code { font-size: 12px; overflow-wrap: anywhere; user-select: all; }
.code-actions, .code-flags { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.code-actions { justify-content: end; flex: 0 0 auto; }
.code-flags { margin-top: 5px; }
.usage-pill { font-size: 11px; color: #355a43; background: #eaf4ed; padding: 3px 8px; border-radius: 8px; }
.usage-pill[data-used="true"] { color: #3b5273; background: #edf2fa; }
.phone-tools { margin-bottom: 14px; }
.phone-signout { text-align: right; margin-bottom: 10px; }
.code-meta { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.row-status { white-space: nowrap; font-size: 12px; color: var(--accent); }
.lookup-results { list-style: none; padding: 0; margin: 20px 0 0; }
.lookup-results:empty, .receipt-summary:empty { display: none; }
.lookup-results li { border-top: 1px solid var(--line); padding-block: 13px; }
.lookup-results li div { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.lookup-results code { font-size: 13px; }
.lookup-results strong { font-size: 13px; text-align: right; }
.guide-list { margin-block: 24px; padding-left: 22px; }
.guide-list li { padding: 6px 0 12px 5px; }
.guide-list p, .guide details p { margin-top: 5px; color: var(--muted); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.guide details { border-top: 1px solid var(--line); padding: 13px 0; }
.guide details summary { cursor: pointer; font-size: 14px; font-weight: 650; }
.clipboard-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.input-meta { margin-top: 0; }
.input-meta > :last-child { white-space: nowrap; }
.account-preview, .credential-tip { padding: 12px 16px; border-radius: 8px; background: #ecf3fb; color: var(--deep); line-height: 1.6; font-size: 13px; overflow-wrap: anywhere; }
dialog { width: min(520px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); border: 1px solid var(--line); border-radius: 16px; padding: 27px; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: #10274466; }
dialog[open] { animation: modal-in .18s cubic-bezier(.22,.8,.25,1) both; }
@keyframes modal-in { from {opacity: .5; transform: translateY(5px) scale(.985)} to {opacity: 1; transform: none} }
dialog form { float: right; margin: 0 0 0 10px; }
dialog .restore-form { float: none; margin: 16px 0 0; }
.restore-form .actions { margin-top: 0; }
dialog h2 { margin: 5px 0 0; }
.dialog-close { display: grid; place-items: center; width: 33px; height: 33px; padding: 0; border: 0; border-radius: 50%; background: #edf2f8; color: var(--ink); font-size: 23px; }
.guide-link { margin-top: 9px; }
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; white-space: nowrap; overflow: hidden; }

@media (max-width: 700px) {
  .top-inner, .shell { width: min(100% - 36px, 500px); }
  .top-inner { min-height: 50px; gap: 7px; }
  .mark { width: 28px; height: 28px; border-radius: 8px; font-size: 18px; }
  .brand { gap: 7px; font-size: 14px; }
  nav { gap: 2px; }
  nav a { font-size: 12px; padding: 8px; }
  .shell { padding-block: 23px 32px; }
  .intro { margin-bottom: 17px; }
  .admin-layout { grid-template-columns: 1fr; gap: 13px; }
  .customer-nav { gap: 6px; }
  .customer-nav a { padding: 8px 10px; font-size: 12px; }
  .panel { border-radius: 16px; padding: 16px; }
  .flow, .tool-panel { padding: 16px; }
  .code-actions { flex-direction: column; align-items: end; gap: 3px; }
}
@media (max-width:700px) and (pointer:coarse) {
  input:not([type=checkbox]), textarea, select { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
