:root {
  --blue: #0B63D6;
  --blue-dark: #0A4FA8;
  --blue-tint: #EAF2FD;
  --ink: #15171C;
  --ink-2: #6B7280;
  --ink-3: #9AA0A8;
  --line: #DADDE1;
  --line-soft: #ECEEF1;
  --page: #F7F7F8;
  --ok: #16A34A;
  --warn: #E0A339;
  --danger: #E5484D;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  font-family: "Manrope", -apple-system, system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }

/* ============ Entrance animation ============ */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.anim { animation: rise .65s var(--ease) both; }
.d1 { animation-delay: .04s; }
.d2 { animation-delay: .12s; }
.d3 { animation-delay: .2s; }
.d4 { animation-delay: .28s; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .anim { animation: none; }
}

/* ============ Navbar ============ */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
  padding-top: env(safe-area-inset-top);
}
.nav-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 13px; font-weight: 700; color: var(--ink-2); text-decoration: none;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  transition: border-color .15s, color .15s;
}
.nav-link svg { width: 15px; height: 15px; }
.nav-link:hover { border-color: var(--ink-3); color: var(--ink); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand img.amech { height: 20px; }
.brand img.flow { height: 18px; border-radius: 3px; }

.status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.status.pending .dot { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ============ Hero ============ */
.hero { position: relative; overflow: hidden; background: #fff; border-bottom: 1px solid var(--line-soft); }
.hero::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(#EFF1F4 1px, transparent 1px),
    linear-gradient(90deg, #EFF1F4 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 50% 0%, #000 35%, transparent 78%);
  mask-image: radial-gradient(ellipse 75% 65% at 50% 0%, #000 35%, transparent 78%);
}
.hero-inner { position: relative; max-width: 1080px; margin: 0 auto; padding: 54px 20px 46px; text-align: center; }
.eyebrow {
  display: inline-block; font-size: 11.5px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--blue);
  padding: 6px 12px; border-radius: 999px; background: var(--blue-tint);
}
.hero h1 {
  font-size: clamp(30px, 6vw, 50px); font-weight: 800; letter-spacing: -.028em; line-height: 1.06;
  margin: 18px 0 16px; text-wrap: balance;
}
.hero h1 em { font-style: normal; color: var(--blue); }
.hero p { max-width: 520px; margin: 0 auto; color: var(--ink-2); font-size: 16px; line-height: 1.6; }
.hero-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 28px; }
.hero-tag {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font-size: 12.5px; font-weight: 700; color: var(--ink-2);
}
.hero-tag svg { width: 13px; height: 13px; color: var(--blue); flex: none; }

/* ============ Form ============ */
.form-section { padding: 34px 20px calc(72px + env(safe-area-inset-bottom)); }
.form-wrap { max-width: 720px; margin: 0 auto; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 26px; }
.form-head { margin-bottom: 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.form-head h2 { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.form-head p { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; max-width: 42ch; }

.scan-btn {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 10px 15px; border-radius: 9px; border: 1.5px solid var(--ink); background: var(--ink); color: #fff;
  font-size: 13.5px; font-weight: 700; transition: background .15s, transform .15s;
}
.scan-btn svg { width: 16px; height: 16px; }
.scan-btn:hover { background: #000; }
.scan-btn:active { transform: scale(.97); }
.scan-raw {
  margin: -8px 0 18px; padding: 10px 12px; border-radius: 9px; background: var(--page);
  border: 1px solid var(--line-soft); font-size: 12.5px; color: var(--ink-2); word-break: break-all;
}

.scan-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(10, 12, 16, .68); backdrop-filter: blur(4px);
  animation: fade .2s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.scan-sheet { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; overflow: hidden; }
.scan-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.scan-sheet-head b { font-size: 15px; font-weight: 800; }
.scan-close { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-2); }
.scan-close:hover { background: var(--page); color: var(--ink); }
.scan-close svg { width: 16px; height: 16px; }
.scan-view { position: relative; aspect-ratio: 4 / 3; background: #0B0D11; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; inset: 16% 14%; border-radius: 14px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 0 0 9999px rgba(10, 12, 16, .35);
}
.scan-status { padding: 14px 16px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); text-align: center; }

.grid { display: grid; grid-template-columns: 1fr; column-gap: 14px; }
.col-12 { grid-column: 1 / -1; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field input[type=text], .field input[type=tel], .field input[type=email], .field input[type=date], .field textarea {
  font-size: 16px; padding: 12px 13px; border-radius: 9px; border: 1.5px solid var(--line); background: transparent;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-3); }
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 99, 214, .1); }

.input-wrap { position: relative; }
.field .input-wrap input { padding-left: 41px; width: 100%; }
.input-wrap .ic { position: absolute; left: 13px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; transition: color .15s, transform .15s; }
.input-wrap:has(input:focus) .ic { color: var(--blue); transform: translateY(-50%) scale(1.08); }

.chip-group { display: flex; gap: 8px; }
.chip { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; border-radius: 9px; border: 1.5px solid var(--line); background: transparent; font-weight: 700; color: var(--ink-2); transition: border-color .15s, background .15s, color .15s; }
.chip svg { width: 14px; height: 14px; opacity: .55; transition: opacity .15s; }
.chip:hover { border-color: var(--ink-3); }
.chip.on { background: var(--blue-tint); border-color: var(--blue); color: var(--blue); }
.chip.on svg { opacity: 1; }

.form-foot { border-top: 1px solid var(--line-soft); margin-top: 8px; padding-top: 20px; }
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 18px; }
.consent input { width: 20px; height: 20px; flex: none; margin-top: 2px; accent-color: var(--blue); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; width: 100%; padding: 0 20px; border-radius: 11px; font-weight: 800; font-size: 15.5px; transition: transform .15s, background .15s; }
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: var(--line); color: var(--ink-3); }
.btn-primary svg { transition: transform .2s var(--ease); }
.btn-primary:hover svg { transform: translateX(3px); }
.btn-line { background: #fff; border: 1.5px solid var(--line); color: var(--ink); }
.btn-line:hover { border-color: var(--ink-3); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 420px; margin: 0 auto; background: var(--ink); color: #fff; padding: 14px 18px; border-radius: 10px; font-weight: 600; text-align: center; opacity: 0; transform: translateY(12px); transition: opacity .25s var(--ease), transform .25s var(--ease); pointer-events: none; z-index: 40; }
.toast.on { opacity: 1; transform: none; }

/* ============ Admin ============ */
.app { max-width: 640px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line);
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.app main { flex: 1; padding: 18px 18px calc(36px + env(safe-area-inset-bottom)); }

.login-card { max-width: 360px; margin: 60px auto; }
.login-card h1 { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.login-card p { color: var(--ink-2); font-size: 13.5px; margin-bottom: 18px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar input[type=date] { flex: 1; min-width: 140px; font-size: 15px; padding: 11px 13px; border-radius: 9px; border: 1.5px solid var(--line); background: #fff; }
.toolbar input[type=search]:focus, .toolbar input[type=date]:focus { outline: none; border-color: var(--blue); }
.toolbar .btn { width: auto; min-height: 44px; padding: 0 16px; }

.lead-list { display: flex; flex-direction: column; gap: 8px; }
.lead { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; transition: border-color .15s; }
.lead:hover { border-color: var(--ink-3); }
.lead b { display: block; font-size: 15px; font-weight: 700; }
.lead .meta { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.lead .obs { font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.empty { padding: 32px 16px; text-align: center; color: var(--ink-2); background: #fff; border: 1.5px dashed var(--line); border-radius: 11px; }

@media (min-width: 960px) {
  .app-admin { max-width: none; }
  .app-admin main { width: 100%; max-width: 1040px; margin: 0 auto; padding: 40px 48px 64px; }
  .app-admin .top { padding: 24px 48px; }
  .app-admin .lead-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
}
