:root {
  color-scheme: light;
  --ink: #1c2830;
  --ink-soft: #3c4c55;
  --muted: #6b787f;
  --line: #d8dedb;
  --line-strong: #b7c2c4;
  --paper: #fcfcfa;
  --cloud: #eff1ed;
  --postal: #2356a8;
  --postal-dark: #1b4486;
  --signal: #c63b30;
  --signal-dark: #a32f26;
  --warning: #8f5f0d;
  --stripe: repeating-linear-gradient(-45deg, var(--postal) 0 10px, var(--paper) 10px 20px, var(--signal) 20px 30px, var(--paper) 30px 40px);
  --stripe-alert: repeating-linear-gradient(-45deg, var(--signal) 0 10px, var(--paper) 10px 20px);
  font-family: "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--cloud);
  color: var(--ink);
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; touch-action: manipulation; }
input, select { touch-action: manipulation; }
h1, h2 { text-wrap: balance; }

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.topbar::after {
  content: "";
  display: block;
  height: 5px;
  background: var(--stripe);
}
.topbar-inner {
  width: min(1120px, calc(100% - 48px));
  height: 71px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  position: relative;
  width: 38px;
  height: 31px;
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--paper);
}
.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  top: 6px;
  width: 20px;
  height: 2px;
  background: var(--ink);
}
.brand-mark::before { left: 1px; transform: rotate(32deg); }
.brand-mark::after { right: 1px; transform: rotate(-32deg); }
.brand-copy { display: grid; gap: 2px; min-width: 0; }
.brand-copy strong {
  font-family: "Avenir Next", "Noto Sans SC", sans-serif;
  font-size: 16px;
  font-weight: 750;
}
.brand-copy span { color: var(--muted); font: 500 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.service-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}
.service-state > .state-dot {
  position: relative;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #27966b;
  box-shadow: 0 0 0 3px #e3f3ec;
}
.service-state > .state-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgb(39 150 107 / 28%);
  animation: dot-pulse 2.4s ease-out infinite;
}
.state-divider { color: var(--line-strong); }
.public-queue { white-space: nowrap; }
.public-queue strong {
  color: var(--postal-dark);
  font: 750 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.workspace {
  width: min(760px, calc(100% - 32px));
  margin: 48px auto 80px;
}
.workspace-heading { margin-bottom: 20px; }
.workspace-label,
.eyebrow {
  margin: 0 0 5px;
  color: var(--postal);
  font: 750 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.workspace-heading h1 {
  margin: 0;
  font-family: "Avenir Next", "Noto Sans SC", sans-serif;
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 48px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #e5e9e6;
}
.mode-button {
  min-width: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: background 120ms ease, color 120ms ease;
}
.mode-button:hover { color: var(--ink-soft); }
.mode-button.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 4px rgb(24 43 51 / 12%);
}
.mode-button:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible { outline: 3px solid rgb(35 86 168 / 26%); outline-offset: 2px; }

.tool-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  box-shadow: 0 16px 42px rgb(24 43 51 / 8%);
  animation: panel-in 180ms ease-out;
}
.tool-panel::before {
  content: "";
  display: block;
  height: 6px;
  background: var(--stripe);
}
#panel-password::before { background: var(--stripe-alert); }
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 28px 21px;
  border-bottom: 1px solid #e4e9e6;
}
.panel-heading h2 {
  margin: 0;
  font-family: "Avenir Next", "Noto Sans SC", sans-serif;
  font-size: 21px;
  line-height: 1.25;
}
.panel-status {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #b9cbdf;
  border-radius: 4px;
  background: #eef3fb;
  color: var(--postal-dark);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.panel-status.warning { border-color: #e0caa4; background: #fbf6eb; color: var(--warning); }

.operation-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 16px;
  padding: 26px 28px 28px;
}
.operation-form label { display: grid; gap: 7px; min-width: 0; }
.operation-form label > span { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder { color: #93a0a5; }
input:hover,
select:hover { border-color: #96a5ab; }
input:focus,
select:focus { border-color: var(--postal); box-shadow: 0 0 0 3px rgb(35 86 168 / 12%); }

.primary-button,
.danger-button {
  position: relative;
  min-height: 48px;
  padding: 11px 18px;
  border: 0;
  border-radius: 5px;
  color: #fff;
  font-weight: 750;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgb(24 43 51 / 16%);
  transition: background 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.primary-button { background: var(--postal); }
.primary-button:hover { background: var(--postal-dark); box-shadow: 0 4px 12px rgb(27 68 134 / 26%); }
.danger-button { background: var(--signal); }
.danger-button:hover { background: var(--signal-dark); box-shadow: 0 4px 12px rgb(163 47 38 / 26%); }
.primary-button:active,
.danger-button:active { transform: translateY(1px); box-shadow: 0 1px 3px rgb(24 43 51 / 18%); }
.primary-button:disabled,
.danger-button:disabled { opacity: .58; cursor: wait; transform: none; box-shadow: none; }

.delivery-receipt {
  position: relative;
  margin: 0 28px 26px;
  padding: 18px 20px 17px;
  border: 1px solid #b6c7d8;
  border-radius: 5px;
  background: #f5f8fb;
  animation: receipt-in 180ms ease-out;
}
.delivery-receipt::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  bottom: 0;
  border-left: 2px dotted #b6c7d8;
}
.receipt-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}
.receipt-heading strong {
  padding: 3px 7px;
  border: 2px solid var(--postal);
  border-radius: 3px;
  color: var(--postal);
  font: 750 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(-2deg);
}
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 11px; }
#otp-code {
  color: var(--ink);
  font: 760 32px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}
.copy-button {
  min-width: 64px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #a9bcc8;
  border-radius: 4px;
  background: #fff;
  color: var(--ink-soft);
  font-weight: 700;
  transition: border-color 120ms ease, color 120ms ease;
}
.copy-button:hover { border-color: var(--postal); color: var(--postal-dark); }
#otp-subject { margin: 10px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.otp-received-time { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 10px 0 0; padding-top: 10px; border-top: 1px dashed #b6c7d8; color: var(--muted); font-size: 11px; }
.otp-received-time time {
  color: var(--ink-soft);
  font: 700 12px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.form-message { min-height: 20px; margin: -10px 28px 22px; color: var(--muted); font-size: 12px; }
.form-message.error { color: var(--signal-dark); }
.form-message.success { color: var(--postal-dark); }

@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes receipt-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dot-pulse { 0% { opacity: .9; } 70%, 100% { opacity: 0; } }

@media (max-width: 600px) {
  .topbar-inner { width: calc(100% - 28px); height: 63px; }
  .brand-mark { width: 33px; height: 27px; }
  .brand-mark::before, .brand-mark::after { width: 17px; top: 5px; }
  .service-state { gap: 6px; font-size: 11px; }
  .service-state .state-label, .service-state .state-divider { display: none; }
  .workspace { width: min(100% - 20px, 760px); margin: 26px auto 60px; }
  .workspace-heading h1 { font-size: 23px; }
  .mode-switch { min-height: 46px; }
  .panel-heading { padding: 19px 18px 17px; }
  .panel-heading h2 { font-size: 19px; }
  .operation-form { grid-template-columns: 1fr; gap: 16px; padding: 21px 18px 23px; }
  .field-wide { grid-column: auto; }
  .delivery-receipt { margin: 0 18px 22px; padding: 16px 16px 15px; }
  .form-message { margin: -7px 18px 18px; }
  #otp-code { font-size: 28px; }
  .otp-received-time { align-items: flex-start; flex-direction: column; gap: 4px; }
}

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