:root {
  --navy: #2b267b;
  --navy-700: #221e63;
  --navy-900: #17154a;
  --navy-50: #f0f0f8;
  --navy-100: #e1e0f1;
  --red: #ed2024;
  --red-50: #fef2f2;
  --green: #12805c;
  --green-50: #ecfdf5;
  --amber: #b45309;
  --amber-50: #fffbeb;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #f4f5fa;
  --card: #ffffff;
  --r-lg: 24px;
  --r: 16px;
  --r-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -6px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, 0.04), 0 24px 48px -12px rgba(23, 21, 74, 0.22);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
input { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; }
svg { display: block; }

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  padding: 0 28px;
  border-radius: var(--r);
  border: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled { cursor: default; }
.btn-primary {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(43, 38, 123, 0.55);
}
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }
.btn-primary:disabled { background: #b9b8d6; box-shadow: none; }
.btn-secondary { background: #fff; color: var(--navy); border: 1.5px solid var(--line-2); }
.btn-secondary:hover:not(:disabled) { border-color: var(--navy); }
.btn-ghost { background: transparent; color: var(--muted); min-height: 48px; padding: 0 14px; font-size: 17px; font-weight: 600; }
.btn-ghost:hover { color: var(--navy); }
.btn-block { width: 100%; }
.btn .spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
.btn-secondary .spin { border-color: var(--navy-100); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r-sm);
  font-size: 17px; font-weight: 550; line-height: 1.4;
}
.alert svg { flex: none; margin-top: 1px; }
.alert-error { background: var(--red-50); color: #b42318; }
.alert-warn { background: var(--amber-50); color: var(--amber); }
.alert-ok { background: var(--green-50); color: var(--green); }
.alert-info { background: var(--navy-50); color: var(--navy); }

/* ---------- Sign in ---------- */
.login { flex: 1; display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.login-brand {
  position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 0% 0%, #3a34a0 0%, var(--navy) 42%, var(--navy-900) 100%);
  color: #fff; padding: 56px 56px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-brand::after {
  content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px;
  border-radius: 50%; border: 60px solid rgba(255, 255, 255, 0.04);
}
.stripes { display: flex; flex-direction: column; gap: 7px; width: 64px; }
.stripes span { height: 9px; border-radius: 2px; background: #fff; }
.stripes span:first-child { background: var(--red); width: 80%; }
.login-brand h1 { font-size: 46px; line-height: 1.08; letter-spacing: -0.03em; margin: 28px 0 18px; font-weight: 800; max-width: 520px; }
.login-brand p.lead { font-size: 20px; line-height: 1.5; color: rgba(255, 255, 255, 0.78); margin: 0; max-width: 460px; }
.points { list-style: none; padding: 0; margin: 36px 0 0; display: grid; gap: 16px; }
.points li { display: flex; gap: 14px; align-items: center; font-size: 18px; font-weight: 550; color: rgba(255, 255, 255, 0.92); }
.points .dot {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: rgba(255, 255, 255, 0.10);
}
.brand-foot { font-size: 14px; color: rgba(255, 255, 255, 0.55); position: relative; z-index: 1; }

.login-form { display: grid; place-items: center; padding: 40px; background: #fff; }
.login-card { width: 100%; max-width: 440px; }
.login-card .logo { width: 170px; height: auto; display: block; margin-bottom: 36px; }
.login-card h2 { font-size: 32px; letter-spacing: -0.02em; margin: 0 0 8px; }
.login-card .sub { font-size: 17px; color: var(--muted); margin: 0 0 30px; line-height: 1.5; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 15px; font-weight: 650; color: var(--ink-2); margin-bottom: 8px; }
.input {
  width: 100%; height: 62px; padding: 0 18px;
  font-size: 20px; font-family: inherit; color: var(--ink);
  border: 1.5px solid var(--line-2); border-radius: var(--r-sm); background: #fff;
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus { border-color: var(--navy); box-shadow: 0 0 0 4px rgba(43, 38, 123, 0.12); }
.login-card .alert { margin-bottom: 18px; }
.install-hint { margin-top: 22px; font-size: 15px; color: var(--muted); text-align: center; line-height: 1.5; }

/* ---------- App shell ---------- */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 76px; padding: 0 28px;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.appbar::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--red); }
.appbar-left { display: flex; align-items: center; gap: 18px; }
.appbar-left img { height: 38px; width: auto; }
.appbar-tag {
  font-size: 14px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--navy); background: var(--navy-50); padding: 7px 12px; border-radius: 999px;
}
.appbar-right { display: flex; align-items: center; gap: 10px; }
.staff { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--ink-2); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 15px;
}

.stepper { display: flex; align-items: center; justify-content: center; gap: 0; padding: 18px 28px 6px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; color: var(--muted); white-space: nowrap; }
.step .num {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  background: #fff; border: 1.5px solid var(--line-2); color: var(--muted);
}
.step.active { color: var(--navy); }
.step.active .num { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 0 0 5px rgba(43, 38, 123, 0.12); }
.step.done { color: var(--ink-2); }
.step.done .num { background: var(--green); border-color: var(--green); color: #fff; }
.step-line { width: 56px; height: 2px; background: var(--line-2); margin: 0 14px; border-radius: 2px; }
.step-line.done { background: var(--green); }

.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 28px 28px; display: flex; flex-direction: column; }
.card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.eyebrow { font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red); margin: 0 0 10px; }
.title { font-size: 40px; line-height: 1.1; letter-spacing: -0.03em; font-weight: 800; margin: 0 0 12px; }
.lead { font-size: 19px; line-height: 1.55; color: var(--muted); margin: 0; }

/* ---------- Find ---------- */
.find { flex: 1; display: grid; grid-template-columns: 1fr 420px; gap: 28px; align-items: stretch; }
.find-left { padding: 44px; display: flex; flex-direction: column; }
.res-display {
  margin: 30px 0 18px; height: 104px; border-radius: var(--r);
  border: 2px solid var(--line-2); background: #fbfbfe;
  display: flex; align-items: center; gap: 14px; padding: 0 26px;
  font-size: 54px; font-weight: 800; letter-spacing: 0.04em; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.res-display.focus { border-color: var(--navy); box-shadow: 0 0 0 5px rgba(43, 38, 123, 0.10); }
.res-display .hash { color: var(--line-2); font-weight: 700; }
.res-display .ph { color: #c4c9d4; font-weight: 700; }
.res-display .caret { width: 3px; height: 52px; margin: 0 -8px 0 -6px; background: var(--navy); border-radius: 2px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.find-left .alert { margin-bottom: 16px; }
.find-left .grow { flex: 1; }
.keypad { padding: 22px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-content: center; }
.key {
  height: 82px; border-radius: var(--r); border: 0;
  background: #f4f5fa; color: var(--ink);
  font-size: 32px; font-weight: 700; cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.1s ease, transform 0.08s ease;
}
.key:active { background: var(--navy-100); transform: scale(0.97); }
.key.fn { background: transparent; color: var(--muted); font-size: 17px; font-weight: 650; }

/* ---------- Customer ---------- */
.review { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: center; }
.review-intro { padding: 12px 8px 40px; }
.res-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 22px; padding: 10px 16px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  font-size: 17px; font-weight: 650; color: var(--ink-2);
}
.res-chip b { color: var(--navy); }
.person { padding: 32px; }
.person-head { display: flex; align-items: center; gap: 18px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.person-head .avatar { width: 72px; height: 72px; font-size: 26px; background: linear-gradient(135deg, var(--navy), #4a43b8); }
.person-name { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; word-break: break-word; }
.person-sub { font-size: 16px; color: var(--muted); margin-top: 4px; }
.rows { margin: 8px 0 0; }
.row-item { display: flex; align-items: center; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: 0; }
.row-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--navy-50); color: var(--navy); flex: none; }
.row-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.row-value { font-size: 23px; font-weight: 700; margin-top: 2px; word-break: break-word; }
.row-value.missing { color: #b42318; }
.prior { margin-top: 18px; padding: 18px; border-radius: var(--r); background: var(--green-50); }
.prior-top { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; color: var(--green); }
.prior-meta { font-size: 15px; color: var(--ink-2); margin: 6px 0 12px; }
.prior img { width: 100%; max-height: 120px; object-fit: contain; background: #fff; border-radius: var(--r-sm); border: 1px solid var(--line); }
.prior .btn { margin-top: 12px; min-height: 52px; font-size: 17px; }
.actions { display: flex; gap: 12px; margin-top: 24px; }
.actions .btn { flex: 1; }
.review-intro .alert { margin-top: 18px; }

/* ---------- Agree & sign ---------- */
.sign {
  flex: none; display: grid; grid-template-columns: 1fr 420px; grid-template-rows: minmax(0, 1fr); gap: 24px;
  /* App bar, progress bar, and page padding sit above. */
  height: calc(100vh - 186px); height: calc(100dvh - 186px); min-height: 520px;
}
.terms { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.terms-scroll { flex: 1; overflow-y: auto; padding: 32px 36px 48px; -webkit-overflow-scrolling: touch; user-select: text; -webkit-user-select: text; }
.terms::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 56px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  transition: opacity 0.2s ease;
}
.terms.end::after { opacity: 0; }
.terms h1 { font-size: 30px; letter-spacing: -0.02em; margin: 0 0 6px; font-weight: 800; }
.terms .intro { font-size: 18px; color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
.contacts { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 10px; margin: 0 0 8px; }
.contact {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r);
  background: var(--red-50); border: 1px solid #fde2e2;
}
.contact.alt { background: var(--navy-50); border-color: var(--navy-100); }
.contact .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--red); color: #fff; flex: none; }
.contact.alt .ic { background: var(--navy); }
.contact .lbl { font-size: 13px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.contact .num { font-size: 19px; font-weight: 800; color: var(--ink); }
.section { padding-top: 26px; }
.section h2 { display: flex; align-items: center; gap: 12px; font-size: 21px; letter-spacing: -0.01em; margin: 0 0 14px; font-weight: 800; color: var(--navy); }
.section h2 .badge { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--navy-50); color: var(--navy); flex: none; }
.section p { font-size: 22px; line-height: 1.55; color: var(--ink-2); margin: 0 0 14px; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 16px 52px; font-size: 22px; line-height: 1.55; color: var(--ink-2); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 1px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px; font-weight: 800;
  background: var(--navy); color: #fff;
}
.steps li::after { content: ''; position: absolute; left: 16px; top: 40px; bottom: 6px; width: 2px; background: var(--navy-100); }
.steps li:last-child::after { display: none; }

.panel { display: flex; flex-direction: column; padding: 26px; min-height: 0; }
.panel-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel h3 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.signer { font-size: 16px; color: var(--muted); margin: 0 0 18px; }
.signer b { color: var(--ink); }
.agree {
  display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--r);
  border: 2px solid var(--line-2); background: #fff; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.agree.on { border-color: var(--navy); background: var(--navy-50); }
.agree input { position: absolute; opacity: 0; pointer-events: none; }
.tick {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  border: 2px solid var(--line-2); background: #fff; color: transparent;
  display: grid; place-items: center; transition: all 0.15s ease;
}
.agree.on .tick { background: var(--navy); border-color: var(--navy); color: #fff; }
.agree-text { font-size: 19px; font-weight: 700; line-height: 1.3; }
.pad-wrap { position: relative; flex: 1; min-height: 170px; margin-top: 18px; border-radius: var(--r); background: #fff; border: 2px dashed var(--line-2); overflow: hidden; }
.pad-wrap.inked { border-style: solid; border-color: var(--navy-100); }
.pad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.pad-hint {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-80%);
  text-align: center; font-size: 22px; font-weight: 650; color: #b8bfcc; pointer-events: none;
}
.pad-line { position: absolute; left: 26px; right: 26px; bottom: 44px; border-bottom: 2px solid var(--line); pointer-events: none; }
.pad-x { position: absolute; left: 26px; bottom: 50px; font-size: 24px; font-weight: 700; color: #b8bfcc; pointer-events: none; }
.pad-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 14px; color: var(--muted); }
.panel .alert { margin-top: 12px; }
.panel .btn-primary { margin-top: 14px; }

/* ---------- Done ---------- */
.finish { flex: 1; display: grid; place-items: center; }
.done-card { width: 100%; max-width: 640px; padding: 48px 44px 40px; text-align: center; }
.check {
  width: 104px; height: 104px; margin: 0 auto 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--green-50); color: var(--green);
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.check svg path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.45s 0.2s ease forwards; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done-card .title { font-size: 38px; }
.done-card .lead { margin: 0 auto; max-width: 480px; }
.done-sign { margin: 28px auto 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.done-sign img { width: 100%; max-height: 130px; object-fit: contain; display: block; }
.done-sign .cap { font-size: 13px; color: var(--muted); margin-top: 6px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 650; }
.done-card .alert { margin-top: 22px; text-align: left; }
.done-card .btn { margin-top: 26px; }
.auto { font-size: 14px; color: var(--muted); margin-top: 14px; }

/* ---------- Motion ---------- */
.enter { animation: enter 0.28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Portrait / small ---------- */
@media (max-width: 960px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 36px 32px; min-height: auto; }
  .login-brand h1 { font-size: 34px; margin-top: 20px; }
  .points, .brand-foot { display: none; }
  .find, .review, .sign { grid-template-columns: 1fr; }
  .sign { height: auto; grid-template-rows: auto; }
  .terms { max-height: 52vh; }
  .stepper .step .lbl { display: none; }
  .step-line { width: 36px; }
  .contacts { grid-template-columns: 1fr; }
}
