:root {
  color: #18221e;
  background: #f3f5f4;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --green: #126b49;
  --green-dark: #0b5137;
  --green-soft: #e8f3ee;
  --red: #bd3d42;
  --line: #d9e0dc;
  --muted: #6b756f;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
form[hidden] { display: none; }

.panel-heading, .panel-actions, .mode-row, .captcha-row, .section-heading, .schedule-item {
  display: flex;
  align-items: center;
}
.logout-button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; color: #44504a; background: #fff; font-size: 12px; }
.logout-button:hover { border-color: #aebbb4; background: #f8faf9; }

main { width: min(820px, calc(100% - 32px)); margin: 32px auto 56px; }
.login-panel { width: min(440px, 100%); margin: 64px auto 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.login-panel[hidden], #adminApp[hidden] { display: none; }
.login-heading { padding: 26px 28px 20px; border-bottom: 1px solid var(--line); }
.login-heading h1 { font-size: 22px; }
.login-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.login-field { display: grid; gap: 7px; margin-bottom: 18px; color: #3f4944; font-size: 13px; font-weight: 700; }
.login-field input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid #c8d2cd; border-radius: 5px; outline: none; }
.login-field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
#deviceCode { letter-spacing: 1px; text-transform: uppercase; }
.draw-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.panel-heading { justify-content: space-between; gap: 24px; padding: 24px 28px; border-bottom: 1px solid var(--line); }
.panel-actions { gap: 18px; }
.panel-heading span, .latest span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 27px; }
h2 { font-size: 16px; }
.latest { min-width: 0; text-align: right; }
.latest strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

form { padding: 26px 28px 28px; }
fieldset { margin: 0 0 24px; padding: 0; border: 0; }
legend { margin-bottom: 10px; color: #3f4944; font-size: 13px; font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.numbers-heading { min-height: 34px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.numbers-heading > span { color: #3f4944; font-size: 13px; font-weight: 700; }
.number-actions { display: flex; gap: 7px; }
.number-actions button { min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 4px; color: #44504a; background: #fff; font-size: 12px; }
.number-actions button:hover { border-color: #aebbb4; background: #f8faf9; }
.numbers { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.number-field { position: relative; min-width: 0; }
.number-field span { position: absolute; top: 6px; left: 9px; color: #8a948f; font-size: 10px; pointer-events: none; }
.number-field input {
  width: 100%; height: 68px; padding: 17px 5px 2px; border: 1px solid #c8d2cd; border-radius: 5px;
  outline: none; text-align: center; color: var(--green-dark); background: #fafcfb; font-size: 23px; font-weight: 800;
}
.number-field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.number-field.special { margin-left: 7px; }
.number-field.special input { color: #a52d32; border-color: #e3c4c3; background: #fff9f8; }
.number-field.special input:focus { border-color: var(--red); box-shadow: 0 0 0 3px #fff0ef; }

#issueSelect {
  width: min(240px, 100%);
  height: 44px;
  padding: 0 36px 0 12px;
  border: 1px solid #c8d2cd;
  border-radius: 5px;
  outline: none;
  color: #26312c;
  background: #fff;
  font-weight: 700;
}
#issueSelect:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.mode-row { align-items: flex-end; gap: 14px; }
.mode-control { display: inline-grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #f1f4f2; }
.mode-control label { cursor: pointer; }
.mode-control input { position: absolute; opacity: 0; }
.mode-control span { min-width: 104px; height: 38px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); font-size: 13px; }
.mode-control input:checked + span { color: var(--green-dark); background: #fff; box-shadow: 0 1px 4px rgba(18, 35, 27, 0.13); }
.mode-control input:focus-visible + span { outline: 2px solid var(--green); }
.schedule-time { width: 225px; display: grid; gap: 5px; }
.schedule-time[hidden] { display: none; }
.schedule-time label { color: var(--muted); font-size: 11px; }
.schedule-time input, #captchaAnswer { height: 46px; padding: 0 11px; border: 1px solid #c8d2cd; border-radius: 5px; outline: none; background: #fff; }
.schedule-time input:focus, #captchaAnswer:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.captcha-row { gap: 9px; }
#captchaImage { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 5px; background: #f7f9f8; object-fit: cover; }
.refresh-captcha { width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 5px; color: #435049; background: #fff; font-size: 20px; }
#captchaAnswer { width: 150px; letter-spacing: 3px; }
.form-message { min-height: 20px; margin: -8px 0 8px; color: var(--red); font-size: 12px; }
.submit-button { width: 100%; height: 48px; border: 0; border-radius: 5px; color: #fff; background: var(--green); font-weight: 700; }
.submit-button:hover { background: var(--green-dark); }
.submit-button:disabled { cursor: not-allowed; opacity: 0.55; }

.scheduled { margin-top: 24px; }
.scheduled[hidden] { display: none; }
.section-heading { justify-content: space-between; margin-bottom: 10px; }
.section-heading span { color: var(--muted); font-size: 12px; }
#scheduleList { display: grid; gap: 8px; }
.schedule-item { min-height: 62px; padding: 10px 12px 10px 16px; gap: 18px; border: 1px solid var(--line); border-left: 3px solid #d89b2b; border-radius: 5px; background: #fff; }
.schedule-item > div { display: grid; gap: 3px; }
.schedule-item strong { font-size: 13px; }
.schedule-item span { color: var(--muted); font-size: 11px; }
.schedule-item code { flex: 1; font-size: 12px; }
.schedule-item button { min-height: 34px; padding: 0 12px; border: 1px solid #e0bdbc; border-radius: 4px; color: #a52d32; background: #fff; font-size: 12px; }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: calc(100% - 40px); padding: 12px 15px; border-radius: 5px; color: #fff; background: #20342b; opacity: 0; transform: translateY(10px); pointer-events: none; transition: 150ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #8e292d; }

@media (max-width: 660px) {
  main { width: calc(100% - 24px); margin-top: 16px; }
  .login-panel { margin-top: 32px; }
  .login-heading { padding: 22px 16px 18px; }
  .panel-heading { align-items: flex-start; padding: 20px 16px; }
  .panel-actions { align-items: flex-end; flex-direction: column-reverse; gap: 10px; }
  .latest { max-width: 52%; }
  form { padding: 22px 16px; }
  .numbers { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .numbers-heading { align-items: flex-start; flex-direction: column; }
  .number-actions { width: 100%; }
  .number-actions button { flex: 1; }
  .number-field.special { margin-left: 0; }
  .mode-row { align-items: stretch; flex-direction: column; }
  .mode-control, .schedule-time { width: 100%; }
  .mode-control span { min-width: 0; }
  .captcha-row { flex-wrap: wrap; }
  #captchaAnswer { flex: 1; min-width: 130px; }
  .schedule-item { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; }
  .schedule-item code { grid-column: 1 / -1; grid-row: 2; }
  .schedule-item button { grid-column: 2; grid-row: 1; }
}

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