:root {
  --paper: #f2efe8;
  --surface: #fbfaf6;
  --ink: #19201f;
  --muted: #68706d;
  --line: #ced1ca;
  --line-strong: #9ca29e;
  --signal: #e4512c;
  --signal-dark: #b93617;
  --green: #27785e;
  --error: #b33b2e;
  --radius: 3px;
  --shadow: 0 24px 60px rgba(20, 28, 26, 0.09);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input, textarea { font: inherit; }
button { color: inherit; }

.skip-link { position: fixed; left: 16px; top: -60px; z-index: 20; padding: 10px 14px; color: white; background: var(--ink); }
.skip-link:focus { top: 12px; }
.app-shell { width: min(1440px, 100%); margin: 0 auto; padding: 0 48px 40px; }
.topbar { height: 88px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line-strong); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--surface); background: var(--ink); font-family: serif; font-size: 20px; }
.eyebrow, .section-index { margin: 0; font-family: var(--mono); font-size: 10px; line-height: 1.3; letter-spacing: .18em; color: var(--muted); }
.brand-name { margin: 3px 0 0; font-size: 15px; font-weight: 700; letter-spacing: .05em; }
.control-nav { display: flex; gap: 4px; margin-left: auto; padding: 4px; border: 1px solid var(--line); background: rgba(255,255,255,.38); }
.control-nav a { min-height: 36px; display: inline-flex; align-items: center; padding: 0 12px; color: var(--muted); font-size: 11px; font-weight: 750; text-decoration: none; }
.control-nav a[aria-current="page"] { color: var(--surface); background: var(--ink); }
.control-nav a:focus-visible { outline: 3px solid rgba(228,81,44,.22); outline-offset: 2px; }
.server-state { margin-left: auto; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); font-family: var(--mono); font-size: 11px; background: rgba(255,255,255,.38); }
.state-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(39, 120, 94, .12); }
.server-state.is-error .state-dot { background: var(--error); box-shadow: 0 0 0 3px rgba(179, 59, 46, .12); }

.hero { min-height: 330px; display: grid; grid-template-columns: 1.45fr .55fr; align-items: end; gap: 60px; padding: 74px 0 58px; }
.hero h1 { margin: 10px 0 0; max-width: 850px; font-size: clamp(44px, 5.6vw, 80px); line-height: .98; letter-spacing: -.065em; font-weight: 760; }
.hero h1 span { color: var(--signal); }
.hero-copy { max-width: 360px; margin: 0 0 8px; padding-left: 22px; border-left: 2px solid var(--signal); color: var(--muted); font-size: 14px; line-height: 1.9; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(360px, .82fr); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.issue-panel { padding: 42px 48px 48px; background: var(--surface); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 34px; }
.panel-heading h2, .ticket-panel h2 { margin: 5px 0 0; font-size: 25px; letter-spacing: -.035em; }
.step-badge, .secure-label { padding: 5px 8px; border: 1px solid currentColor; color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .08em; }
form { display: grid; gap: 28px; }
.field { display: grid; gap: 8px; }
label, legend { font-size: 13px; font-weight: 700; }
input[type="text"], input:not([type]) { appearance: none; width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 0; color: var(--ink); background: white; outline: none; transition: border-color .16s ease, box-shadow .16s ease; }
input:focus-visible, button:focus-visible { outline: 3px solid rgba(228, 81, 44, .22); outline-offset: 2px; }
input[type="text"]:focus, input:not([type]):focus { border-color: var(--signal); box-shadow: inset 3px 0 0 var(--signal); }
.mono-input { font-family: var(--mono); letter-spacing: .045em; text-transform: uppercase; }
.field-help { margin: 0; color: var(--muted); font-size: 11px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 10px; }
.expiry-row { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; }
.radio-card, .check-card, .role-card { position: relative; display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); background: white; cursor: pointer; }
.radio-card:has(input:checked), .check-card:has(input:checked), .role-card:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.radio-card input, .check-card input, .role-card input { accent-color: var(--signal); }
input[type="date"] { width: 100%; min-width: 160px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); color: var(--ink); background: white; }
input:disabled { color: var(--muted); background: #e9e7e1; cursor: not-allowed; }
textarea { width: 100%; min-height: 118px; padding: 13px 14px; resize: vertical; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 0; outline: none; font-family: var(--mono); font-size: 10px; line-height: 1.65; overflow-wrap: anywhere; }
textarea:focus { border-color: var(--signal); box-shadow: inset 3px 0 0 var(--signal); }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.role-card { min-height: 72px; align-items: flex-start; padding-top: 14px; padding-bottom: 14px; }
.role-card span { display: grid; gap: 4px; }
.role-card strong { font-size: 13px; }
.role-card small { color: var(--muted); font-size: 10px; line-height: 1.5; font-weight: 400; }
.check-card { min-height: 58px; }
.check-card span { display: grid; gap: 2px; }
.check-card strong { font-size: 13px; }
.check-card small { color: var(--muted); font-size: 10px; font-weight: 400; }
.required-feature { background: #f3f1eb; cursor: default; }
.form-message { padding: 11px 13px; border-left: 3px solid var(--error); color: var(--error); background: rgba(179, 59, 46, .07); font-size: 12px; line-height: 1.6; }
.form-message[data-type="success"] { border-color: var(--green); color: var(--green); background: rgba(39, 120, 94, .08); }
.primary-button { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 0 18px; border: 0; color: white; background: var(--signal); font-weight: 750; cursor: pointer; transition: background .16s ease, transform .16s ease; }
.primary-button:hover:not(:disabled) { background: var(--signal-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .58; cursor: wait; }

.ticket-panel { position: relative; overflow: hidden; padding: 42px 42px 48px; color: #f8f6ef; background: var(--ink); }
.ticket-panel::after { content: ""; position: absolute; right: -54px; bottom: -54px; width: 150px; height: 150px; border: 34px solid rgba(255,255,255,.045); border-radius: 50%; }
.ticket-topline { display: flex; justify-content: space-between; align-items: center; }
.ticket-panel .section-index { color: #939d99; }
.secure-label { color: #de684b; }
.machine-ruler { height: 48px; margin: 36px 0 18px; border-top: 1px solid #4d5653; background: repeating-linear-gradient(90deg, transparent 0 17px, #4d5653 17px 18px); background-size: 18px 9px; background-repeat: repeat-x; }
.ticket-code { min-height: 78px; white-space: pre-line; font-family: var(--mono); font-size: clamp(20px, 2.2vw, 31px); line-height: 1.42; letter-spacing: .035em; color: #f7bd53; }
.ticket-details { margin: 34px 0 0; border-top: 1px solid #4d5653; }
.ticket-details div { display: grid; grid-template-columns: 92px 1fr; gap: 18px; padding: 15px 0; border-bottom: 1px solid #3c4643; }
.ticket-details dt { color: #929b98; font-size: 11px; }
.ticket-details dd { margin: 0; font-size: 12px; text-align: right; }
.signature-strip { position: absolute; right: 42px; bottom: 42px; left: 42px; display: flex; align-items: center; justify-content: space-between; padding-top: 18px; border-top: 1px solid #4d5653; }
.signature-strip span { color: #929b98; font-family: var(--mono); font-size: 9px; letter-spacing: .14em; }
.signature-strip strong { font-size: 11px; }

.history-panel { margin-top: 22px; padding: 36px 42px; border: 1px solid var(--line-strong); background: var(--surface); }
.reset-panel { margin-top: 22px; padding: 36px 42px; border: 1px solid var(--line-strong); background: var(--surface); }
.reset-panel .panel-heading { align-items: center; margin-bottom: 22px; }
.reset-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); gap: 28px; }
.reset-layout form { gap: 18px; }
.reset-button { align-self: end; }
.reset-result { align-content: start; min-width: 0; padding: 22px; color: #f8f6ef; background: var(--ink); border-left: 4px solid var(--signal); }
.reset-result[hidden] { display: none; }
.reset-result > strong { display: block; margin: 16px 0 6px; font-size: 18px; }
.reset-result > p { margin: 0 0 14px; color: #abb3b0; font-family: var(--mono); font-size: 9px; line-height: 1.6; overflow-wrap: anywhere; }
.reset-result textarea { min-height: 142px; margin-bottom: 12px; color: #f7bd53; background: #111716; border-color: #4d5653; }
.reset-result .download-button { color: white; border-color: #6f7975; }
.history-panel .panel-heading { align-items: center; margin-bottom: 22px; }
.text-button { padding: 7px 0; border: 0; border-bottom: 1px solid var(--ink); background: transparent; font-size: 12px; cursor: pointer; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 12px; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line-strong); font-size: 10px; text-align: left; letter-spacing: .08em; }
td { padding: 15px 12px; border-bottom: 1px solid var(--line); }
th:last-child, td:last-child { text-align: right; }
.mono-cell { font-family: var(--mono); font-size: 11px; }
.machine-cell { color: var(--muted); }
.role-cell { white-space: nowrap; font-weight: 700; }
.role-cell--staff { color: var(--green); }
.empty-cell { padding: 38px; color: var(--muted); text-align: center !important; }
.download-button { padding: 5px 10px; border: 1px solid var(--line-strong); background: transparent; font-size: 11px; cursor: pointer; }
.download-button:hover { color: white; border-color: var(--ink); background: var(--ink); }
footer { display: flex; justify-content: space-between; gap: 24px; padding: 22px 2px 0; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.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; }

@media (max-width: 900px) {
  .app-shell { padding: 0 24px 30px; }
  .hero { min-height: auto; grid-template-columns: 1fr; gap: 28px; padding: 54px 0 44px; }
  .hero-copy { max-width: 600px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .reset-layout { grid-template-columns: 1fr; }
  .ticket-panel { min-height: 510px; }
  footer { flex-direction: column; }
}

@media (max-width: 600px) {
  .app-shell { padding: 0 14px 24px; }
  .topbar { height: 76px; }
  .server-state { padding: 7px; }
  .server-state span:last-child { display: none; }
  .control-nav { order: 3; width: 100%; margin-left: 0; }
  .control-nav a { flex: 1; justify-content: center; }
  .topbar { height: auto; min-height: 76px; flex-wrap: wrap; padding: 12px 0; }
  .hero h1 { font-size: 42px; }
  .issue-panel, .ticket-panel, .history-panel, .reset-panel { padding: 30px 22px; }
  .expiry-row { grid-template-columns: 1fr 1fr; }
  .expiry-row input[type="date"] { grid-column: 1 / -1; }
  .feature-grid { grid-template-columns: 1fr; }
  .role-grid { grid-template-columns: 1fr; }
  .ticket-panel { min-height: 500px; }
  .signature-strip { right: 22px; bottom: 30px; left: 22px; }
}

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