/* ============================================================
   GatewayChina design system v2
   paper #F6F5F1 · ink #101318 · jade #157A63 · seal #C4402F
   ============================================================ */

:root {
  --paper: #F6F5F1;
  --card: #FFFFFF;
  --ink: #101318;
  --ink-soft: #3A4048;
  --mist: #6B7280;
  --faint: #9CA3AF;
  --line: #E6E4DC;
  --line-strong: #D8D5CB;

  --jade: #157A63;
  --jade-deep: #0C5B49;
  --jade-bright: #1B9578;
  --jade-tint: #E4F2EE;
  --jade-glow: rgba(21,122,99,.22);

  --seal: #C4402F;
  --seal-tint: #FBECE9;

  --amber-tint: #FCF3DF;
  --amber-text: #92610A;
  --green-tint: #E4F2E7;
  --green-text: #1E7A38;

  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 10px;

  --sh-1: 0 1px 2px rgba(16,19,24,.05), 0 1px 6px rgba(16,19,24,.04);
  --sh-2: 0 2px 6px rgba(16,19,24,.06), 0 10px 28px rgba(16,19,24,.07);
  --sh-3: 0 4px 12px rgba(16,19,24,.08), 0 20px 44px rgba(16,19,24,.10);
  --sh-jade: 0 6px 18px var(--jade-glow);

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.65;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
/* Ambient wash so pages never feel flat */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(520px 360px at 88% -60px, rgba(21,122,99,.09), transparent 65%),
    radial-gradient(420px 300px at -80px 12%, rgba(196,64,47,.05), transparent 60%),
    var(--paper);
}
h1, h2, h3, .display { font-family: var(--font-display); line-height: 1.15; font-weight: 700; letter-spacing: -0.015em; }
h1 { font-size: clamp(26px, 6.4vw, 34px); }
h2 { font-size: clamp(20px, 5vw, 24px); }
h3 { font-size: 16.5px; }
p { margin: 0; }
a { color: var(--jade); text-decoration: none; }
img, svg { max-width: 100%; vertical-align: middle; }
code { background: var(--jade-tint); padding: 1px 7px; border-radius: 6px; font-size: 13px; }
:focus-visible { outline: 2.5px solid var(--jade); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 620px; margin: 0 auto; padding: 0 18px; width: 100%; }
.wrap-wide { max-width: 1060px; margin: 0 auto; padding: 0 18px; width: 100%; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(246,245,241,.86);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid rgba(216,213,203,.6);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 10px; }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 17.5px; color: var(--ink); display: flex; align-items: center; gap: 9px; letter-spacing: -0.01em; }
.wordmark .dot {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--seal), #A82F20);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; box-shadow: 0 3px 8px rgba(196,64,47,.35);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: 15px; letter-spacing: .005em;
  border-radius: var(--r-sm); border: 1px solid transparent;
  padding: 12px 20px; cursor: pointer; min-height: 48px;
  text-decoration: none; user-select: none; white-space: nowrap;
  transition: transform .12s ease, box-shadow .18s ease, background .15s ease, border-color .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  background: linear-gradient(180deg, var(--jade-bright), var(--jade));
  color: #fff; box-shadow: var(--sh-jade), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--jade), var(--jade-deep)); box-shadow: 0 8px 22px var(--jade-glow); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--sh-1); }
.btn-ghost:hover { border-color: var(--faint); }
.btn-danger { background: var(--card); color: var(--seal); border-color: rgba(196,64,47,.4); }
.btn-danger:hover { background: var(--seal-tint); }
.btn-sm { padding: 8px 14px; min-height: 38px; font-size: 13.5px; border-radius: 9px; }
.btn-block { width: 100%; white-space: normal; line-height: 1.35; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .ic { width: 17px; height: 17px; flex-shrink: 0; }

/* ---------- Cards & forms ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px; box-shadow: var(--sh-2);
}
.card + .card { margin-top: 14px; }
.card.flat { box-shadow: var(--sh-1); }
.card-tint { background: linear-gradient(160deg, var(--jade-tint), #F0F7F4); border-color: rgba(21,122,99,.25); }

label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 6px; color: var(--ink-soft); }
input, select, textarea {
  width: 100%; max-width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 11px 13px; min-height: 48px; transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--jade); box-shadow: 0 0 0 3.5px rgba(21,122,99,.15); }
input:disabled { background: var(--paper); color: var(--mist); }
input[type="checkbox"] { appearance: auto; -webkit-appearance: checkbox; width: 18px; height: 18px; min-height: auto; accent-color: var(--jade); }
.field { margin-bottom: 15px; }
.hint { font-size: 12.5px; color: var(--mist); margin-top: 5px; }
.form-error {
  background: var(--seal-tint); color: #9A2E1F; border: 1px solid rgba(196,64,47,.25);
  border-radius: var(--r-sm); padding: 11px 13px; font-size: 13.5px; margin-bottom: 13px; display: none;
}

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.pill-gray  { background: #EEEDE7; color: #575C64; }
.pill-jade  { background: var(--jade-tint); color: var(--jade-deep); }
.pill-amber { background: var(--amber-tint); color: var(--amber-text); }
.pill-green { background: var(--green-tint); color: var(--green-text); }
.pill-red   { background: var(--seal-tint); color: var(--seal); }

/* ---------- Journey timeline ---------- */
.journey { position: relative; padding-left: 34px; }
.journey::before { content: ""; position: absolute; left: 11px; top: 10px; bottom: 10px; width: 2.5px; border-radius: 3px; background: var(--line-strong); }
.journey .fill { position: absolute; left: 11px; top: 10px; width: 2.5px; border-radius: 3px; background: linear-gradient(180deg, var(--jade-bright), var(--jade)); }
.stop { position: relative; padding-bottom: 22px; }
.stop:last-child { padding-bottom: 0; }
.stop::before {
  content: ""; position: absolute; left: -30px; top: 4px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--card); border: 2.5px solid var(--line-strong);
  transition: all .2s;
}
.stop.done::before {
  background: var(--jade) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/9px no-repeat;
  border-color: var(--jade);
}
.stop.current::before { background: #fff; border-color: var(--jade); box-shadow: 0 0 0 5px rgba(21,122,99,.18); animation: pulse 2.4s ease infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 5px rgba(21,122,99,.18); } 50% { box-shadow: 0 0 0 8px rgba(21,122,99,.10); } }
.stop-title { font-weight: 650; font-size: 15px; color: var(--faint); }
.stop.done .stop-title { color: var(--mist); }
.stop.current .stop-title { color: var(--ink); font-weight: 700; }
.stop-sub { font-size: 13px; color: var(--faint); }
.stop.current .stop-sub { color: var(--jade-deep); font-weight: 550; }

/* ---------- Result cards (eligibility) ---------- */
.result-card {
  border-radius: var(--r-lg); padding: 30px 22px 26px; text-align: center;
  background: linear-gradient(170deg, #FFFFFF, var(--jade-tint));
  border: 1.5px solid rgba(21,122,99,.35); box-shadow: var(--sh-3);
  animation: rise .45s ease both;
}
.result-card.no { background: linear-gradient(170deg, #FFFFFF, #FBF6EC); border-color: rgba(146,97,10,.3); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.seal-mark {
  width: 68px; height: 68px; margin: 0 auto 16px; border-radius: 16px;
  transform: rotate(-5deg);
  background: linear-gradient(140deg, var(--jade-bright), var(--jade-deep));
  box-shadow: 0 10px 24px rgba(21,122,99,.35), inset 0 1px 0 rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: #fff; font-size: 28px;
}
.result-card h1 { color: var(--jade-deep); }
.result-card.no .seal-mark { background: linear-gradient(140deg, #E2A93B, #B07708); box-shadow: 0 10px 24px rgba(146,97,10,.3); }
.result-card.no h1 { color: var(--ink); }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(16,19,24,.06);
}
.bottomnav a {
  flex: 1; max-width: 96px; text-align: center; font-size: 10.5px; font-weight: 650;
  color: var(--faint); padding: 5px 2px 4px; border-radius: 12px; position: relative;
  transition: color .15s;
}
.bottomnav a .ic { display: block; width: 22px; height: 22px; margin: 0 auto 2px; stroke-width: 1.9; }
.bottomnav a.active { color: var(--jade-deep); }
.bottomnav a.active::after {
  content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--jade);
}
.bottomnav a .nbadge {
  position: absolute; top: -1px; right: 18%; min-width: 17px; height: 17px; border-radius: 9px;
  background: var(--seal); color: #fff; font-size: 10px; font-weight: 700; line-height: 17px; padding: 0 5px;
  box-shadow: 0 2px 6px rgba(196,64,47,.4);
}
.page-pad { padding: 22px 0 104px; }

/* ---------- Doc rows ---------- */
.doc-row { display: flex; align-items: center; gap: 13px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.doc-row:last-child { border-bottom: none; padding-bottom: 4px; }
.doc-row:first-child { padding-top: 4px; }
.doc-ic {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); border: 1px solid var(--line); color: var(--mist);
}
.doc-ic.ok { background: var(--green-tint); border-color: transparent; color: var(--green-text); }
.doc-ic.warn { background: var(--seal-tint); border-color: transparent; color: var(--seal); }
.doc-ic .ic { width: 19px; height: 19px; }
.doc-main { flex: 1; min-width: 140px; }
.doc-name { font-weight: 650; font-size: 14.5px; }
.doc-note { font-size: 12.5px; color: var(--mist); overflow-wrap: anywhere; margin: 1px 0 3px; }
.doc-actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------- Chat ---------- */
.chatbox { display: flex; flex-direction: column; gap: 9px; padding-bottom: 8px; }
.msg { max-width: 84%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; box-shadow: var(--sh-1); }
.msg.me { align-self: flex-end; background: linear-gradient(150deg, var(--jade-bright), var(--jade-deep)); color: #fff; border-bottom-right-radius: 5px; }
.msg.them { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg time { display: block; font-size: 10.5px; opacity: .65; margin-top: 3px; }
.chat-input { position: sticky; bottom: 78px; display: flex; gap: 8px; background: var(--paper); padding: 10px 0; }
.chat-input input { flex: 1; border-radius: 999px; padding-left: 18px; }
.chat-input .btn { border-radius: 999px; padding: 12px 18px; }

/* ---------- Progress ---------- */
.progress { height: 9px; background: #E9E7E0; border-radius: 999px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(16,19,24,.06); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--jade-bright), var(--jade)); border-radius: 999px; transition: width .4s ease; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--sh-1); }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--mist); padding: 11px 14px; background: #FBFAF7; border-bottom: 1px solid var(--line); }
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.rowlink { cursor: pointer; transition: background .12s; }
.tbl tr.rowlink:hover { background: var(--jade-tint); }
@media (max-width: 720px) {
  .tbl { background: transparent; border: none; box-shadow: none; overflow: visible; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 11px; padding: 9px 4px; box-shadow: var(--sh-1); }
  .tbl td { border: none; padding: 4px 14px; }
  .tbl td[data-l]::before { content: attr(data-l) ": "; font-weight: 650; color: var(--mist); font-size: 12px; }
}

/* ---------- Admin ---------- */
.admin-nav { display: flex; gap: 5px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav a { padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 650; color: var(--mist); white-space: nowrap; border: 1px solid transparent; transition: all .15s; }
.admin-nav a:hover { color: var(--ink); border-color: var(--line-strong); }
.admin-nav a.active { background: var(--ink); color: #fff; box-shadow: var(--sh-1); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 11px; margin: 14px 0 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 15px 16px; box-shadow: var(--sh-1); }
.stat .n { font-family: var(--font-display); font-size: 27px; font-weight: 700; line-height: 1.2; }
.stat .l { font-size: 12px; color: var(--mist); font-weight: 550; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: 14px; font-weight: 550; opacity: 0; pointer-events: none;
  transition: all .28s cubic-bezier(.2,.9,.3,1.2); z-index: 90; max-width: 92vw; text-align: center;
  box-shadow: var(--sh-3);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Landing ---------- */
.hero { padding: 52px 0 36px; position: relative; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--jade-deep); background: var(--jade-tint); border: 1px solid rgba(21,122,99,.25);
  padding: 6px 13px; border-radius: 999px; margin-bottom: 18px;
}
.hero h1 { font-size: clamp(33px, 8.4vw, 50px); margin-bottom: 15px; letter-spacing: -0.025em; }
.hero h1 em { font-style: normal; color: var(--jade); position: relative; white-space: nowrap; }
.hero h1 em::after { content: ""; position: absolute; left: 0; right: 0; bottom: 3px; height: 9px; background: var(--jade-tint); z-index: -1; border-radius: 3px; }
.hero p.lede { font-size: 16.5px; color: var(--mist); margin-bottom: 26px; max-width: 42ch; }
.trust-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; }
.trust-row span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); font-weight: 550; }
.trust-row .ic { width: 16px; height: 16px; color: var(--jade); }

.steps { display: grid; gap: 12px; margin: 18px 0 8px; }
@media (min-width: 560px) { .steps { grid-template-columns: 1fr 1fr; } }
.step-c { display: flex; gap: 14px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 17px; box-shadow: var(--sh-1); transition: transform .18s, box-shadow .18s; }
.step-c:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.step-n {
  font-family: var(--font-display); font-weight: 700; color: #fff; font-size: 14px;
  background: linear-gradient(140deg, var(--jade-bright), var(--jade-deep));
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px var(--jade-glow);
}
.prog-card { transition: transform .18s, box-shadow .18s; }
.prog-card:hover { transform: translateY(-2px); box-shadow: var(--sh-3); }

footer { border-top: 1px solid var(--line); margin-top: 60px; padding: 30px 0 46px; font-size: 13.5px; color: var(--mist); background: #fff; }

/* ---------- Wizard ---------- */
.wiz-steps { display: flex; gap: 7px; margin: 20px 0; }
.wiz-steps span { flex: 1; height: 4.5px; border-radius: 4px; background: var(--line-strong); transition: background .3s; }
.wiz-steps span.on { background: linear-gradient(90deg, var(--jade-bright), var(--jade)); }
.choice {
  display: block; border: 1.5px solid var(--line-strong); border-radius: var(--r-md);
  padding: 16px 17px; padding-right: 46px; background: #fff; cursor: pointer; margin-bottom: 11px;
  position: relative; box-shadow: var(--sh-1); transition: border-color .15s, background .15s, box-shadow .15s;
}
.choice:hover { border-color: var(--faint); }
.choice input { display: none; }
.choice::after {
  content: ""; position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
  width: 21px; height: 21px; border-radius: 50%; border: 2px solid var(--line-strong); background: #fff;
  transition: all .15s;
}
.choice.sel { border-color: var(--jade); background: linear-gradient(160deg, #fff, var(--jade-tint)); box-shadow: 0 0 0 3.5px rgba(21,122,99,.13); }
.choice.sel::after {
  border-color: var(--jade);
  background: var(--jade) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/11px no-repeat;
}
.choice .c-t { font-weight: 700; font-size: 15px; }
.choice .c-s { font-size: 13px; color: var(--mist); }
.grade-row { display: flex; gap: 8px; margin-bottom: 9px; align-items: center; }
.grade-row select { min-width: 0; }
.grade-row select:first-child, .grade-row input:first-child { flex: 1; }
.grade-row select.g { width: 86px; flex-shrink: 0; }
.grade-row .rm { background: none; border: none; color: var(--faint); font-size: 20px; cursor: pointer; padding: 6px 8px; border-radius: 8px; line-height: 1; flex-shrink: 0; }
.grade-row .rm:hover { color: var(--seal); background: var(--seal-tint); }

/* ---------- Utilities ---------- */
.muted { color: var(--mist); }
.small { font-size: 13px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 26px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap-flex { flex-wrap: wrap; }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--line); margin: 17px 0; }
.ic { width: 18px; height: 18px; flex-shrink: 0; }

@media (max-width: 380px) {
  .wrap, .wrap-wide { padding: 0 14px; }
  .card { padding: 16px; }
  .btn { font-size: 14.5px; padding: 11px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
