:root {
  color-scheme: light;
  --page: #f8faff;
  --page-soft: #f3f6ff;
  --card: rgba(255, 255, 255, 0.96);
  --text: #171b25;
  --muted: #8490aa;
  --muted-strong: #596781;
  --line: #e4e8f1;
  --field: #f5f6fb;
  --field-border: #e7eaf2;
  --primary: #3f7df5;
  --primary-deep: #4939db;
  --success: #27b988;
  --warning: #f59e42;
  --danger: #eb5365;
  --shadow: 0 28px 70px rgba(49, 62, 112, 0.12), 0 4px 14px rgba(49, 62, 112, 0.05);
  --soft-shadow: 0 8px 22px rgba(46, 57, 101, 0.08);
  --radius-card: 26px;
  --radius-control: 14px;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d1220;
  --page-soft: #11182a;
  --card: rgba(20, 28, 46, 0.97);
  --text: #f3f5fb;
  --muted: #8f9ab2;
  --muted-strong: #bac3d5;
  --line: #29334a;
  --field: #171f33;
  --field-border: #2b354c;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.32), 0 4px 14px rgba(0, 0, 0, 0.18);
  --soft-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 86% -6%, rgba(88, 93, 233, 0.11), transparent 28%),
    radial-gradient(circle at 15% 40%, rgba(63, 125, 245, 0.055), transparent 26%),
    var(--page);
  transition: color 180ms ease, background-color 180ms ease;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.18;
  pointer-events: none;
}

.glow-one {
  top: -260px;
  right: 8%;
  background: #7d73ff;
}

.glow-two {
  bottom: -300px;
  left: 12%;
  background: #5c9cff;
}

.topbar {
  display: flex;
  width: min(1320px, calc(100% - 48px));
  min-height: 100px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
}

.brand-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #4d3ce4, #3b83f6);
  box-shadow: 0 12px 25px rgba(62, 80, 226, 0.3);
  font-size: 31px;
  font-weight: 500;
  line-height: 1;
}

.brand-copy strong,
.brand-copy small {
  display: block;
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.025em;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.queue-chip,
.language-switch,
.icon-button {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--soft-shadow);
}

.queue-chip {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 12px;
  white-space: nowrap;
}

.queue-chip b {
  color: var(--text);
}

.live-dot {
  width: 8px;
  height: 8px;
  margin-right: 2px;
  border-radius: 50%;
  background: #31c597;
  box-shadow: 0 0 0 4px rgba(49, 197, 151, 0.13);
}

.queue-separator {
  color: #b4bdcd;
}

.language-switch {
  display: flex;
  overflow: hidden;
  height: 38px;
  border-radius: 12px;
}

.language-button {
  width: 39px;
  border: 0;
  color: var(--muted-strong);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.language-button.is-active {
  color: #fff;
  background: linear-gradient(145deg, #4744e2, #3f82f5);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  cursor: pointer;
}

.moon-icon {
  position: relative;
  width: 15px;
  height: 15px;
  border: 2px solid var(--muted-strong);
  border-radius: 50%;
}

.moon-icon::after {
  content: "";
  position: absolute;
  top: -4px;
  left: 4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--card);
}

html[data-theme="dark"] .moon-icon::after {
  top: -2px;
  left: -2px;
  width: 15px;
  height: 15px;
  background: #f9d66d;
  transform: scale(0.55);
}

.page-shell {
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 30px 0 54px;
}

.hero {
  text-align: center;
}

.hero-kicker {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 0 18px;
  border-radius: 999px;
  color: #4544d9;
  background: rgba(88, 83, 224, 0.1);
  font-size: 12px;
  font-weight: 800;
}

.hero-kicker > span:first-child {
  color: #ffad32;
  font-size: 20px;
  line-height: 1;
}

html[data-theme="dark"] .hero-kicker {
  color: #aeb9ff;
  background: rgba(101, 97, 229, 0.17);
}

.hero h1 {
  margin: 24px 0 10px;
  font-size: clamp(38px, 6vw, 52px);
  font-weight: 950;
  line-height: 1.15;
  letter-spacing: -0.065em;
}

.hero h1 span {
  color: #405be4;
  background: linear-gradient(90deg, #493ddc, #3b86f7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero > p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 14px;
}

.announcement {
  display: flex;
  max-width: 620px;
  gap: 10px;
  margin: 20px auto 0;
  padding: 10px 14px;
  border: 1px solid rgba(245, 158, 66, 0.22);
  border-radius: 12px;
  color: #a46824;
  background: rgba(255, 178, 79, 0.1);
  font-size: 12px;
}

.portal-card {
  width: min(620px, 100%);
  min-height: 390px;
  margin: 32px auto 0;
  padding: 28px 30px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow);
}

.main-tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  gap: 8px;
  margin: 0 auto 22px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page-soft);
}

.main-tab {
  min-width: 104px;
  height: 44px;
  padding: 0 19px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted-strong);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  transition: transform 150ms ease, color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.main-tab:hover:not(.is-active) {
  color: var(--text);
  background: var(--card);
}

.main-tab.is-active {
  color: #fff;
  background: #171c27;
  box-shadow: 0 7px 16px rgba(18, 24, 39, 0.18);
}

html[data-theme="dark"] .main-tab.is-active {
  color: #12172a;
  background: #f2f4f8;
}

.stepper {
  display: flex;
  width: 330px;
  max-width: 100%;
  align-items: flex-start;
  justify-content: center;
  margin: 0 auto 28px;
}

.step-item {
  display: flex;
  width: 70px;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #9ca6ba;
  font-size: 11px;
  white-space: nowrap;
}

.step-dot {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #98a3b7;
  background: var(--field);
  font-size: 12px;
  font-weight: 800;
}

.step-item.is-active {
  color: var(--text);
}

.step-item.is-active .step-dot {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(145deg, #4d3ee2, #3e83f6);
  box-shadow: 0 8px 17px rgba(61, 84, 225, 0.25);
}

.step-item.is-done .step-dot {
  color: #fff;
  border-color: transparent;
  background: var(--success);
}

.step-line {
  width: 48px;
  height: 1px;
  flex: 0 1 auto;
  margin-top: 19px;
  background: var(--line);
}

.step-line.is-done {
  background: var(--success);
}

.form-stage,
.tab-panel {
  animation: stageIn 180ms ease;
}

@keyframes stageIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 850;
}

.field-icon {
  color: #4c45df;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 17px;
  font-weight: 900;
}

.field-input,
.field-textarea {
  width: 100%;
  border: 1px solid var(--field-border);
  outline: none;
  color: var(--text);
  background: var(--field);
  box-shadow: inset 0 1px 2px rgba(31, 41, 75, 0.025);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field-input {
  height: 55px;
  padding: 0 17px;
  border-radius: var(--radius-control);
}

.field-textarea {
  min-height: 138px;
  padding: 15px 17px;
  resize: vertical;
  border-radius: var(--radius-control);
  line-height: 1.65;
}

.code-field {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.field-input::placeholder,
.field-textarea::placeholder {
  color: #a6afc1;
}

.field-input:focus,
.field-textarea:focus {
  border-color: rgba(63, 105, 233, 0.55);
  background: var(--card);
  box-shadow: 0 0 0 4px rgba(67, 88, 224, 0.08);
}

.field-hint,
.task-hint {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 850;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.primary-button {
  width: 100%;
  border: 0;
  color: #fff;
  background: linear-gradient(100deg, var(--primary-deep), var(--primary));
  box-shadow: 0 12px 24px rgba(62, 71, 224, 0.22);
}

.secondary-button {
  min-width: 108px;
  padding: 0 22px;
  border: 1px solid var(--line);
  color: var(--muted-strong);
  background: var(--card);
}

.danger-button {
  width: 100%;
  border: 0;
  color: #fff;
  background: linear-gradient(100deg, #dc4255, #f06d62);
  box-shadow: 0 12px 24px rgba(223, 65, 87, 0.18);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.danger-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row .primary-button {
  flex: 1;
}

.feedback,
.query-result {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted-strong);
  background: var(--page-soft);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.feedback.is-success,
.query-result.is-success {
  color: #17835f;
  border-color: rgba(39, 185, 136, 0.24);
  background: rgba(39, 185, 136, 0.075);
}

.feedback.is-error,
.query-result.is-error {
  color: #bd3f51;
  border-color: rgba(235, 83, 101, 0.23);
  background: rgba(235, 83, 101, 0.07);
}

.verified-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid rgba(39, 185, 136, 0.2);
  border-radius: 13px;
  background: rgba(39, 185, 136, 0.06);
}

.verified-strip span:first-child {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
}

.verified-strip strong {
  display: block;
  max-width: 370px;
  overflow: hidden;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-pill {
  flex: 0 0 auto;
  padding: 6px 11px;
  border: 1px solid rgba(75, 67, 222, 0.18);
  border-radius: 999px;
  color: #4b43de;
  background: rgba(75, 67, 222, 0.08);
  font-size: 10px;
  font-weight: 850;
}

.confirm-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: -4px 0 17px;
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 11px;
  line-height: 1.55;
}

.confirm-line input {
  width: 15px;
  height: 15px;
  margin: 1px 0 0;
  accent-color: #4b50e3;
}

.task-state {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--page-soft);
}

.task-state-icon {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #4c3fe0, #3f83f6);
  font-size: 13px;
  letter-spacing: 1px;
}

.task-state-icon.is-success { background: var(--success); font-size: 22px; }
.task-state-icon.is-error { background: var(--danger); font-size: 22px; }

.task-state-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
}

.task-state strong {
  font-size: 15px;
}

.progress-track {
  overflow: hidden;
  height: 6px;
  margin: 18px 0;
  border-radius: 999px;
  background: var(--field);
}

.progress-track span {
  display: block;
  width: 24%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4b3ee0, #3f83f6);
  transition: width 500ms ease;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
}

.result-grid div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.result-grid dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
}

.result-grid dd {
  overflow: hidden;
  margin: 0;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 2px 0 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  color: #4b43df;
  background: rgba(75, 67, 223, 0.09);
  font-size: 24px;
}

.panel-heading-icon.refresh-icon {
  color: #1e9d73;
  background: rgba(39, 185, 136, 0.09);
}

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading h2 {
  font-size: 18px;
}

.panel-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.sub-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 21px;
  padding: 4px;
  border-radius: 12px;
  background: var(--field);
}

.sub-tab {
  height: 38px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.sub-tab.is-active {
  color: var(--text);
  background: var(--card);
  box-shadow: 0 3px 12px rgba(53, 64, 106, 0.08);
}

.query-result {
  margin: 16px 0 0;
}

.eligibility-card {
  margin-top: 18px;
  padding: 17px;
  border: 1px solid rgba(39, 185, 136, 0.22);
  border-radius: 15px;
  background: rgba(39, 185, 136, 0.055);
}

.eligibility-top {
  display: flex;
  align-items: center;
  gap: 11px;
}

.success-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--success);
  font-weight: 900;
}

.eligibility-top > div {
  min-width: 0;
  flex: 1;
}

.eligibility-top strong {
  font-size: 13px;
}

.eligibility-top p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.danger-note {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 15px 0;
  padding: 10px 12px;
  border: 1px solid rgba(235, 83, 101, 0.16);
  border-radius: 10px;
  color: #ad4b59;
  background: rgba(235, 83, 101, 0.06);
  font-size: 10px;
  line-height: 1.55;
}

.refresh-success {
  padding: 8px 0 2px;
  text-align: center;
}

.success-big {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 13px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--success);
  box-shadow: 0 12px 28px rgba(39, 185, 136, 0.23);
  font-size: 26px;
  font-weight: 900;
}

.refresh-success h3 {
  margin: 0;
  font-size: 20px;
}

.refresh-success > p {
  margin: 7px 0 17px;
  color: var(--muted);
  font-size: 11px;
}

.new-code-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
  padding: 10px 10px 10px 14px;
  border: 1px dashed rgba(75, 67, 223, 0.35);
  border-radius: 12px;
  background: rgba(75, 67, 223, 0.055);
}

.new-code-box code {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: #4b43de;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-code-box button {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 13px;
  border: 0;
  border-radius: 9px;
  color: #fff;
  background: #4b43de;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.footer {
  margin-top: 32px;
  color: #98a3b8;
  font-size: 10px;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--card);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.is-hidden {
  display: none !important;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #5c62e8;
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .topbar {
    width: min(100% - 24px, 1320px);
    min-height: 82px;
  }

  .brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    font-size: 27px;
  }

  .brand-copy strong {
    font-size: 14px;
  }

  .brand-copy small {
    display: none;
  }

  .queue-chip {
    min-height: 34px;
    padding: 0 10px;
  }

  #queueLabel,
  .queue-separator {
    display: none;
  }

  .language-switch,
  .icon-button {
    height: 34px;
  }

  .language-button,
  .icon-button {
    width: 34px;
  }

  .page-shell {
    padding-top: 28px;
  }

  .hero h1 {
    margin-top: 18px;
    font-size: clamp(34px, 10.6vw, 48px);
  }

  .hero > p {
    max-width: 330px;
    margin-inline: auto;
    line-height: 1.7;
  }

  .portal-card {
    margin-top: 26px;
    padding: 19px 16px 22px;
    border-radius: 21px;
  }

  .main-tabs {
    width: 100%;
    gap: 4px;
  }

  .main-tab {
    min-width: 0;
    flex: 1;
    height: 41px;
    padding: 0 8px;
    font-size: 12px;
  }

  .stepper {
    margin-bottom: 24px;
  }

  .step-line {
    width: 30px;
  }

  .button-row {
    flex-direction: column-reverse;
  }

  .button-row .secondary-button {
    width: 100%;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}

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