/* ==========================================================================
   Scan2Card – premium UI
   ========================================================================== */
:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-3: #c026d3;
  --brand-600: #4338ca;
  --brand-50: #eef0ff;
  --brand-100: #e0e3ff;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #c026d3 100%);
  --grad-soft: linear-gradient(135deg, rgba(79, 70, 229, .10), rgba(192, 38, 211, .08));

  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f2f3f9;
  --surface-glass: rgba(255, 255, 255, .93);
  --border: #e6e8f1;
  --border-strong: #d6d9e6;
  --text: #0b1024;
  --text-2: #4b5268;
  --muted: #8a90a6;

  --hot: #e11d48;   --hot-bg: #ffe4ea;
  --warm: #c2410c;  --warm-bg: #ffedd5;
  --cold: #0369a1;  --cold-bg: #e0f2fe;
  --good: #047857;  --good-bg: #d1fae5;
  --danger: #e11d48;
  --star: #f59e0b;

  --side-bg: #0b0f22;
  --side-text: #a3a9c2;
  --side-hover: rgba(255, 255, 255, .06);

  --shadow-sm: 0 1px 2px rgba(16, 24, 64, .05);
  --shadow: 0 1px 2px rgba(16, 24, 64, .04), 0 12px 32px -14px rgba(30, 27, 75, .16);
  --shadow-lg: 0 24px 60px -20px rgba(30, 27, 75, .35);
  --glow: 0 10px 28px -10px rgba(79, 70, 229, .65);
  --radius: 20px;
  --radius-sm: 14px;
  --nav-h: 68px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-600: #a5b4fc;
    --brand-50: rgba(99, 102, 241, .14);
    --brand-100: rgba(99, 102, 241, .28);
    --bg: #070a16;
    --surface: #0f1427;
    --surface-2: #161c34;
    --surface-glass: rgba(15, 20, 39, .93);
    --border: #222a46;
    --border-strong: #2e375a;
    --text: #eef0fa;
    --text-2: #b9bfd6;
    --muted: #7d849f;
    --hot: #fb7185;  --hot-bg: rgba(225, 29, 72, .16);
    --warm: #fdba74; --warm-bg: rgba(234, 88, 12, .16);
    --cold: #7dd3fc; --cold-bg: rgba(2, 132, 199, .18);
    --good: #6ee7b7; --good-bg: rgba(16, 185, 129, .16);
    --danger: #fb7185;
    --side-bg: #060814;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand-600: #a5b4fc;
  --brand-50: rgba(99, 102, 241, .14);
  --brand-100: rgba(99, 102, 241, .28);
  --bg: #070a16;
  --surface: #0f1427;
  --surface-2: #161c34;
  --surface-glass: rgba(15, 20, 39, .93);
  --border: #222a46;
  --border-strong: #2e375a;
  --text: #eef0fa;
  --text-2: #b9bfd6;
  --muted: #7d849f;
  --hot: #fb7185;  --hot-bg: rgba(225, 29, 72, .16);
  --warm: #fdba74; --warm-bg: rgba(234, 88, 12, .16);
  --cold: #7dd3fc; --cold-bg: rgba(2, 132, 199, .18);
  --good: #6ee7b7; --good-bg: rgba(16, 185, 129, .16);
  --danger: #fb7185;
  --side-bg: #060814;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1100px 520px at 105% -10%, rgba(124, 58, 237, .10), transparent 60%),
    radial-gradient(900px 480px at -15% 0%, rgba(79, 70, 229, .09), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-600); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }
::selection { background: rgba(124, 58, 237, .22); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(-4deg); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, .45); } 100% { box-shadow: 0 0 0 16px rgba(124, 58, 237, 0); } }

#view > * { animation: rise .4s cubic-bezier(.2, .8, .2, 1) both; }
#view > *:nth-child(2) { animation-delay: .04s; }
#view > *:nth-child(3) { animation-delay: .08s; }
#view > *:nth-child(4) { animation-delay: .12s; }
#view > *:nth-child(5) { animation-delay: .16s; }
#view > *:nth-child(n+6) { animation-delay: .2s; }
.list > * { animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; }
.list > *:nth-child(2) { animation-delay: .03s; }
.list > *:nth-child(3) { animation-delay: .06s; }
.list > *:nth-child(4) { animation-delay: .09s; }
.list > *:nth-child(5) { animation-delay: .12s; }
.list > *:nth-child(n+6) { animation-delay: .15s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------------ layout */
.shell { min-height: 100vh; display: flex; }
.sidebar {
  display: none;
  width: 264px; flex-shrink: 0;
  background: var(--side-bg);
  background-image: radial-gradient(400px 260px at 0% 0%, rgba(124, 58, 237, .28), transparent 70%),
                    radial-gradient(300px 300px at 100% 100%, rgba(79, 70, 229, .18), transparent 70%);
  color: var(--side-text);
  padding: 22px 16px; position: sticky; top: 0; height: 100vh;
  flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 19px; padding: 2px 8px 22px; color: #fff; letter-spacing: -.02em; }
.brand img { width: 38px; height: 38px; border-radius: 12px; box-shadow: var(--glow); }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--side-text); letter-spacing: 0; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #5d6485; padding: 16px 12px 6px; font-weight: 700; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
  color: var(--side-text); font-weight: 600; font-size: 14px; transition: background .15s, color .15s;
}
.side-link:hover { background: var(--side-hover); color: #fff; }
.side-link.active { background: rgba(255, 255, 255, .08); color: #fff; }
.side-link.active::before {
  content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad);
}
.side-link svg { width: 20px; height: 20px; }
.side-scan {
  margin: 4px 0 10px; justify-content: center; background: var(--grad); color: #fff !important;
  box-shadow: var(--glow); padding: 13px 12px;
}
.side-scan:hover { background: var(--grad); filter: brightness(1.08); }
.side-scan.active::before { display: none; }
.side-scan.active { background: var(--grad); }
.side-foot {
  margin-top: auto; padding: 12px; border-radius: 16px; background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .06); display: flex; align-items: center; gap: 10px;
}
.side-foot .avatar { width: 38px; height: 38px; border-radius: 12px; font-size: 13px; }
.side-foot .who { flex: 1; min-width: 0; font-size: 13px; line-height: 1.3; }
.side-foot .who b { color: #fff; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.side-foot button { background: none; border: 0; color: var(--side-text); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; }
.side-foot button:hover { color: #fff; background: var(--side-hover); }
.side-foot button svg { width: 18px; height: 18px; }

.main { flex: 1; min-width: 0; overflow-x: clip; padding-bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  min-height: 62px;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 800; letter-spacing: -.02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; flex-shrink: 0;
  color: var(--text); box-shadow: var(--shadow-sm); transition: transform .15s, border-color .15s;
}
.icon-btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; }
.content { padding: 16px 16px 16px; max-width: 1160px; margin: 0 auto; }

.bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
  height: var(--nav-h);
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; color: var(--muted); font-weight: 600; position: relative;
}
.nav-item svg { width: 22px; height: 22px; transition: transform .2s; }
.nav-item.active { color: var(--brand-600); }
.nav-item.active svg { transform: translateY(-1px); }
.nav-item.active::after { content: ""; position: absolute; bottom: -8px; width: 5px; height: 5px; border-radius: 50%; background: var(--grad); }
.nav-scan { position: relative; top: -20px; }
.nav-scan::after { display: none; }
.nav-scan span.fab {
  width: 62px; height: 62px; border-radius: 22px; background: var(--grad); color: #fff;
  display: grid; place-items: center; box-shadow: var(--glow);
  border: 4px solid var(--bg); transform: rotate(0); transition: transform .2s;
}
.nav-scan:active span.fab { transform: scale(.94); }
.nav-scan svg { width: 26px; height: 26px; }

@media (min-width: 900px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 40px; }
  .topbar { padding: 18px 32px; background: transparent; border-bottom-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .topbar h1 { font-size: 26px; }
  .content { padding: 4px 32px 32px; }
  .only-mobile { display: none !important; }
}

/* ------------------------------------------------------------------ elements */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card, .section + .section { margin-top: 16px; }
.card h2, .section-title {
  font-size: 15px; font-weight: 700; margin: 0 0 14px; letter-spacing: -.01em;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card h2 .h-icon {
  width: 30px; height: 30px; border-radius: 10px; background: var(--brand-50); color: var(--brand-600);
  display: inline-grid; place-items: center; margin-right: 8px;
}
.card h2 .h-icon svg { width: 16px; height: 16px; }
.card h2 > span:first-child { display: inline-flex; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-2 > .card + .card { margin-top: 0; } }
.grid-3-2 { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 16px; }
@media (min-width: 1000px) { .grid-3-2 { grid-template-columns: 1.6fr 1fr; } }
.grid-3-2 > .card + .card { margin-top: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; cursor: pointer; background: var(--grad); color: #fff; white-space: nowrap;
  box-shadow: var(--glow); transition: transform .15s, box-shadow .15s, filter .15s; letter-spacing: -.005em;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
/* Gradients under a transparent border repeat into the border and show a pink/red edge line on the left.
   Paint them from the border box so the gradient covers the border exactly once. */
.btn, .icon-btn, .scan-tabs button, .side-scan, .action, .shutter, .nav-scan span.fab { background-origin: border-box; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.secondary:hover { border-color: var(--border-strong); filter: none; }
.btn.ghost { background: transparent; color: var(--brand-600); box-shadow: none; }
.btn.ghost:hover { background: var(--brand-50); filter: none; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--border); box-shadow: none; }
.btn.danger:hover { background: var(--hot-bg); filter: none; }
.btn.light { background: #fff; color: #3b2fc9; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .45); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 13px; border-radius: 11px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 7px; letter-spacing: .01em; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: 14px;
  border: 1.5px solid var(--border); background: var(--surface-2); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:hover { border-color: var(--border-strong); }
textarea.input { min-height: 92px; resize: vertical; }
.input:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-100); }
.input:disabled { opacity: .7; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a90a6' stroke-width='2.5' 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; background-size: 16px;
}
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.input-icon .input { padding-left: 42px; background-color: var(--surface); box-shadow: var(--shadow-sm); }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); white-space: nowrap; line-height: 1.4;
}
.chip svg { width: 12px; height: 12px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.hot { background: var(--hot-bg); color: var(--hot); border-color: transparent; }
.chip.warm { background: var(--warm-bg); color: var(--warm); border-color: transparent; }
.chip.cold { background: var(--cold-bg); color: var(--cold); border-color: transparent; }
.chip.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.chip.brand { background: var(--brand-50); color: var(--brand-600); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-select { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-select button {
  padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 700; font-size: 13px; transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
}
.chip-select button:hover { border-color: var(--border-strong); }
.chip-select button.on { border-color: var(--brand); background: var(--brand-50); color: var(--brand-600); }
.chip-select button.on.hot { border-color: var(--hot); background: var(--hot-bg); color: var(--hot); }
.chip-select button.on.warm { border-color: var(--warm); background: var(--warm-bg); color: var(--warm); }
.chip-select button.on.cold { border-color: var(--cold); background: var(--cold-bg); color: var(--cold); }

.stars { display: inline-flex; gap: 2px; }
.stars button { background: none; border: 0; padding: 2px; cursor: pointer; color: var(--border-strong); transition: transform .12s; }
.stars button:hover { transform: scale(1.15); }
.stars button.on { color: var(--star); filter: drop-shadow(0 2px 6px rgba(245, 158, 11, .45)); }
.stars svg { width: 28px; height: 28px; }
.stars.static svg { width: 13px; height: 13px; }
.stars.static span { color: var(--border-strong); display: inline-flex; }
.stars.static span.on { color: var(--star); }

.avatar {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: var(--grad); font-size: 15px; overflow: hidden; letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15);
}
.avatar { position: relative; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.img-missing {
  display: grid; place-items: center; gap: 4px; align-content: center; aspect-ratio: 1.7; border-radius: 14px;
  border: 2px dashed var(--border-strong); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: center; padding: 8px;
}
.img-missing svg { width: 22px; height: 22px; }
.card-slot { position: relative; }
.card-slot .img-missing, .card-slot img { width: 100%; aspect-ratio: 1.7; border-radius: 14px; object-fit: cover; border: 1px solid var(--border); }
.card-slot .slot-label { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 8px; z-index: 1; }
.card-slot .slot-actions { display: flex; gap: 6px; margin-top: 8px; }
.card-slot .slot-actions .btn { flex: 1; }
.avatar.lg { width: 84px; height: 84px; font-size: 28px; border-radius: 24px; border: 4px solid var(--surface); box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ skeleton */
.skel { border-radius: 14px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skel-wrap { display: grid; gap: 14px; }

/* ------------------------------------------------------------------ lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.lead-item {
  display: flex; gap: 14px; align-items: center; padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; color: inherit; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.lead-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand-100); }
.lead-item .body { flex: 1; min-width: 0; }
.lead-item .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.lead-item .sub { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-item .meta { display: flex; gap: 6px; align-items: center; margin-top: 7px; flex-wrap: wrap; }
.lead-item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.lead-item .chev { color: var(--muted); }
.lead-item .chev svg { width: 18px; height: 18px; }

.row-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; padding-bottom: 0; }
.row-item:first-child { padding-top: 0; }
.row-item .body { flex: 1; min-width: 0; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .empty-icon {
  width: 84px; height: 84px; border-radius: 28px; margin: 0 auto 16px; display: grid; place-items: center;
  background: var(--grad-soft); color: var(--brand-600); border: 1px solid var(--brand-100);
}
.empty .empty-icon svg { width: 38px; height: 38px; }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.empty p { margin: 0 auto 18px; max-width: 320px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; }
.toolbar .input-icon { flex: 1; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin-bottom: 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters select { min-height: 38px; padding: 6px 34px 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; width: auto; flex-shrink: 0; background-color: var(--surface); box-shadow: var(--shadow-sm); }
.count-line { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 10px; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ------------------------------------------------------------------ dashboard */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--grad); color: #fff; border-radius: 26px;
  padding: 22px; display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
  box-shadow: 0 24px 50px -24px rgba(79, 70, 229, .75);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; z-index: -1; }
.hero::before { width: 320px; height: 320px; right: -90px; top: -150px; background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 65%); }
.hero::after { width: 260px; height: 260px; left: -80px; bottom: -160px; background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 65%); }
.hero .grid-bg {
  position: absolute; inset: 0; z-index: -1; opacity: .18;
  background-image: radial-gradient(rgba(255, 255, 255, .9) 1px, transparent 1px); background-size: 18px 18px;
  mask-image: linear-gradient(90deg, transparent, #000 70%); -webkit-mask-image: linear-gradient(90deg, transparent, #000 70%);
}
.hero .txt { flex: 1; min-width: 0; }
.hero .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.hero h2 { margin: 4px 0 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.hero p { margin: 6px 0 0; opacity: .88; font-size: 14px; }
.hero .hero-pill {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25); font-size: 12.5px; font-weight: 700;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); max-width: 100%;
}
.hero .hero-pill svg { width: 14px; height: 14px; flex-shrink: 0; }
.hero .hero-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero .hero-card {
  width: 128px; height: 80px; border-radius: 14px; flex-shrink: 0; position: relative;
  background: linear-gradient(135deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .75));
  box-shadow: 0 18px 30px -12px rgba(0, 0, 0, .45); animation: float 5s ease-in-out infinite; display: none;
}
.hero .hero-card i { position: absolute; left: 14px; height: 6px; border-radius: 3px; background: #c7c9f5; }
.hero .hero-card i:nth-child(1) { top: 16px; width: 58px; background: #6d5ef0; }
.hero .hero-card i:nth-child(2) { top: 30px; width: 40px; }
.hero .hero-card i:nth-child(3) { top: 50px; width: 70px; }
.hero .hero-card i:nth-child(4) { top: 60px; width: 52px; }
.hero .hero-card b { position: absolute; right: 12px; top: 14px; width: 24px; height: 24px; border-radius: 7px; background: var(--grad); }
.hero-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
@media (min-width: 640px) { .hero { padding: 28px 30px; } .hero .hero-card { display: block; } .hero h2 { font-size: 28px; } }
@media (max-width: 520px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .hero-actions { width: 100%; }
}

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.stat {
  position: relative; overflow: hidden; color: inherit; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); transition: transform .15s;
}
a.stat:hover { transform: translateY(-2px); }
.stat .s-icon {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 12px;
  background: var(--brand-50); color: var(--brand-600);
}
.stat .s-icon svg { width: 20px; height: 20px; }
.stat .s-icon.hot { background: var(--hot-bg); color: var(--hot); }
.stat .s-icon.good { background: var(--good-bg); color: var(--good); }
.stat .s-icon.warm { background: var(--warm-bg); color: var(--warm); }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1.15; }
.stat .hint { font-size: 12px; color: var(--text-2); margin-top: 4px; font-weight: 500; }

.bars { position: relative; display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 22px; }
.bars::before {
  content: ""; position: absolute; inset: 22px 0 0 0; pointer-events: none;
  background-image: linear-gradient(var(--border) 1px, transparent 1px); background-size: 100% 25%; opacity: .7;
}
.bars .bar-wrap { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default; z-index: 1; }
.bars .bar {
  width: 100%; background: linear-gradient(180deg, #8b7cf6, #4f46e5); border-radius: 6px 6px 2px 2px; min-height: 3px;
  transition: filter .15s, transform .15s; transform-origin: bottom;
}
.bars .bar.zero { background: var(--border); }
.bars .bar-wrap:hover .bar { filter: brightness(1.15) saturate(1.1); }
.bars .bar-wrap .tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--text); color: var(--surface); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 8px;
  white-space: nowrap; pointer-events: none; opacity: 0; transition: all .12s; z-index: 2;
}
.bars .bar-wrap:hover .tip { opacity: 1; transform: translateX(-50%) translateY(0); }
.bar-labels { display: flex; gap: 6px; margin-top: 8px; }
.bar-labels span { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); font-weight: 600; }

.quality-row { margin-bottom: 14px; }
.quality-row .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.quality-row .top b { font-variant-numeric: tabular-nums; }
.meter { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter > div { height: 100%; border-radius: 999px; background: var(--grad); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.meter.hot > div { background: linear-gradient(90deg, #fb7185, #e11d48); }
.meter.warm > div { background: linear-gradient(90deg, #fdba74, #ea580c); }
.meter.cold > div { background: linear-gradient(90deg, #7dd3fc, #0284c7); }
.status-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 16px; }
.status-grid div { background: var(--surface-2); border-radius: 12px; padding: 8px 4px; text-align: center; }
.status-grid b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.status-grid span { font-size: 10.5px; color: var(--muted); font-weight: 600; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 8px 6px; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .06em; }
.tbl td { padding: 11px 6px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.tbl .who .avatar { width: 30px; height: 30px; border-radius: 10px; font-size: 11px; }
.rank { width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.rank.r1 { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #78350f; }
.rank.r2 { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #1f2937; }
.rank.r3 { background: linear-gradient(135deg, #fed7aa, #c2410c); color: #fff; }

/* ------------------------------------------------------------------ lead detail */
.profile { padding: 0; overflow: hidden; }
.profile .cover {
  height: 96px; background: var(--grad); position: relative; overflow: hidden;
}
.profile .cover::after {
  content: ""; position: absolute; inset: 0; opacity: .2;
  background-image: radial-gradient(rgba(255, 255, 255, .9) 1px, transparent 1px); background-size: 16px 16px;
}
.profile .cover .cover-chips { position: absolute; right: 14px; top: 14px; display: flex; gap: 6px; z-index: 1; }
.profile .cover .cover-chips .chip { background: rgba(255, 255, 255, .2); color: #fff; border-color: rgba(255, 255, 255, .3); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.profile .p-body { padding: 0 18px 18px; margin-top: -42px; position: relative; }
.profile h2 { margin: 12px 0 2px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.profile .role { color: var(--text-2); font-weight: 500; }
.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 18px; }
.action {
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px;
  border-radius: 16px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 700;
  border: 1px solid transparent; cursor: pointer; transition: transform .15s, border-color .15s;
}
.action:hover { transform: translateY(-2px); border-color: var(--border); }
.action .a-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #fff; }
.action .a-ic svg { width: 19px; height: 19px; }
.action.call .a-ic { background: linear-gradient(135deg, #34d399, #059669); }
.action.wa .a-ic { background: linear-gradient(135deg, #4ade80, #16a34a); }
.action.mail .a-ic { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.action.web .a-ic { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.action.save .a-ic { background: linear-gradient(135deg, #f472b6, #c026d3); }
.action.disabled { opacity: .38; pointer-events: none; filter: grayscale(1); }
.kv { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; padding-bottom: 0; }
.kv:first-child { padding-top: 0; }
.kv .k-ic { width: 34px; height: 34px; border-radius: 11px; background: var(--brand-50); color: var(--brand-600); display: grid; place-items: center; }
.kv .k-ic svg { width: 16px; height: 16px; }
.kv .k { color: var(--muted); font-size: 12px; font-weight: 600; }
.kv .v { word-break: break-word; font-weight: 600; }
.kv.plain { grid-template-columns: 120px 1fr; }
.kv.plain .k { font-size: 13px; }
.card-images { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card-images img { border-radius: 14px; border: 1px solid var(--border); width: 100%; aspect-ratio: 1.7; object-fit: cover; cursor: zoom-in; background: var(--surface-2); box-shadow: var(--shadow-sm); transition: transform .15s; }
.card-images img:hover { transform: scale(1.02); }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 2px; }
.note { position: relative; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); margin-bottom: 10px; }
.timeline .note::before { content: ""; position: absolute; left: -21px; top: 16px; width: 10px; height: 10px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 3px var(--surface); }
.note .meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-weight: 500; }
.note .meta button { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 12px; padding: 0; font-weight: 600; }
.warn {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warm-bg); color: var(--warm); border-radius: 16px; padding: 12px 14px; font-size: 13px; margin-bottom: 14px; font-weight: 600;
}
.warn svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.warn a { color: inherit; text-decoration: underline; }

/* ------------------------------------------------------------------ scanner */
.scan-tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 5px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.scan-tabs button { border: 0; background: none; padding: 11px 6px; border-radius: 13px; font-weight: 700; font-size: 13.5px; cursor: pointer; color: var(--text-2); display: flex; align-items: center; justify-content: center; gap: 7px; transition: all .15s; }
.scan-tabs button svg { width: 18px; height: 18px; }
.scan-tabs button.on { background: var(--grad); color: #fff; box-shadow: var(--glow); }

.camera {
  position: relative; background: #05060d; border-radius: 26px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%;
  margin: 0 auto; box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, .06);
}
@media (max-width: 899px) { .camera { max-height: max(280px, calc(100svh - 440px)); } }
@media (min-width: 720px) { .camera { aspect-ratio: 16 / 10; } }
.camera video, .camera img.preview { width: 100%; height: 100%; object-fit: cover; }
.camera .frame {
  position: absolute; left: 8%; right: 8%; top: 50%; transform: translateY(-50%); aspect-ratio: 1.75;
  border-radius: 18px; box-shadow: 0 0 0 9999px rgba(3, 4, 12, .55); pointer-events: none;
}
.camera .frame.qr { left: 50%; right: auto; width: 62%; max-width: 280px; aspect-ratio: 1; transform: translate(-50%, -50%); }
.camera .frame .c { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; filter: drop-shadow(0 0 8px rgba(139, 124, 246, .9)); }
.camera .frame .c.tl { left: -2px; top: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 18px; }
.camera .frame .c.tr { right: -2px; top: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 18px; }
.camera .frame .c.bl { left: -2px; bottom: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 18px; }
.camera .frame .c.br { right: -2px; bottom: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 18px; }
.camera .scanline {
  position: absolute; left: 6%; right: 6%; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, #a78bfa, #fff, #a78bfa, transparent); box-shadow: 0 0 16px #8b5cf6;
  animation: scan 2.2s ease-in-out infinite;
}
@keyframes scan { 0%, 100% { top: 8%; } 50% { top: 90%; } }
.camera .hint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; font-weight: 600;
  background: rgba(0, 0, 0, .45); padding: 7px 14px; border-radius: 999px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, .12);
}
.camera .cam-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #cbd5e1; text-align: center; padding: 24px; font-size: 14px; background: rgba(5, 6, 13, .6); }
.cam-state {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 20px; text-align: center; color: #cbd5e1; font-size: 14px; font-weight: 600; background: rgba(5, 6, 13, .55);
  overflow-y: auto;
}
.cam-state .spinner { margin: 0; border-color: rgba(255, 255, 255, .15); border-top-color: #a78bfa; }
.cam-state.error { background: #070914; justify-content: flex-start; padding-top: 28px; }
@media (min-height: 700px) { .cam-state.error { justify-content: center; padding-top: 20px; } }
.cam-state .cs-ic { width: 56px; height: 56px; border-radius: 18px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: var(--glow); flex-shrink: 0; }
.cam-state .cs-ic svg { width: 26px; height: 26px; }
.cam-state b { color: #fff; font-size: 17px; font-weight: 800; }
.cam-state p { margin: 0; color: #aab0c8; font-weight: 500; max-width: 360px; }
.cam-state ol { margin: 2px 0 0; padding: 12px 14px 12px 32px; text-align: left; color: #c9cee2; font-weight: 500; font-size: 13px; line-height: 1.55;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; max-width: 380px; }
.cam-state ol b { font-size: 13px; font-weight: 700; }
.cam-state .cs-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.cam-state .cs-actions .btn { min-height: 42px; }
.cam-state .cs-help { max-width: 380px; width: 100%; }
.cam-state .cs-help summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: #c4b5fd; font-size: 13px; font-weight: 700; padding: 6px 4px; }
.cam-state .cs-help summary svg { width: 16px; height: 16px; }
.cam-state .cs-help ol { margin-top: 6px; }
.cam-state .cs-actions .btn.secondary { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .14); }
.cam-state .cs-actions .btn.ghost { color: #c4b5fd; }
.camera.failed { aspect-ratio: auto; min-height: 340px; max-height: none; }
.camera.failed video, .camera.failed .frame, .camera.failed .hint { display: none; }
.camera.failed .cam-state { position: relative; inset: auto; min-height: 340px; }
.camera .drop-hint {
  position: absolute; inset: 12px; z-index: 4; border: 2px dashed #a78bfa; border-radius: 20px; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #fff; background: rgba(79, 70, 229, .35);
}
.camera .drop-hint svg { width: 32px; height: 32px; }
.camera.dragging .drop-hint { display: flex; }
.shutter:disabled { opacity: .5; animation: none; cursor: wait; }
.shutter.native { animation: pulse-ring 2s infinite; }
@media (min-width: 900px) {
  .content:has(#scan-stage) { max-width: 820px; }
  .camera { max-height: calc(100vh - 340px); min-height: 300px; }
}
.shutter-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding: 0 6px; }
.shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 0; background: var(--grad);
  cursor: pointer; display: grid; place-items: center; color: #fff; flex-shrink: 0;
  box-shadow: 0 0 0 6px var(--surface), 0 0 0 8px var(--brand-100), var(--glow);
  animation: pulse-ring 2s infinite; transition: transform .12s;
}
.shutter:active { transform: scale(.93); }
.shutter svg { width: 30px; height: 30px; }
.side-action { width: 96px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); background: none; border: 0; cursor: pointer; }
.side-action .icon-btn { pointer-events: none; width: 48px; height: 48px; border-radius: 16px; }
.side-action.go { color: var(--brand-600); font-weight: 700; }
.side-action.go .icon-btn { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--glow); }
/* Back-side step: small front thumbnail + flip button on top of the camera. */
.camera .front-mini { position: absolute; left: 12px; bottom: 12px; z-index: 2; width: 74px; border-radius: 10px; overflow: hidden; border: 2px solid rgba(255, 255, 255, .8); box-shadow: 0 6px 18px rgba(0, 0, 0, .45); }
.camera .front-mini img { display: block; width: 100%; aspect-ratio: 1.7; object-fit: cover; }
.camera .front-mini span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 10px; font-weight: 700; text-align: center; padding: 2px 0; }
.camera .cam-flip { position: absolute; right: 12px; bottom: 12px; z-index: 2; width: 44px; height: 44px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.camera .cam-flip svg { width: 20px; height: 20px; }
.camera.failed .front-mini, .camera.failed .cam-flip { display: none; }
/* "Front side captured" step. */
.captured-card { text-align: center; }
.captured-card img { border-radius: 16px; margin: 0 auto 10px; max-height: 260px; box-shadow: var(--shadow-lg); }
.captured-card .cc-tools { display: flex; justify-content: center; gap: 6px; margin-bottom: 6px; }
.captured-card h3 { margin: 4px 0; font-size: 18px; font-weight: 800; }
.captured-card p { margin: 0; }
.scan-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; margin-top: 16px; }
.scan-actions .btn { min-width: 0; white-space: nowrap; }
.thumbs { display: flex; gap: 12px; margin-top: 14px; }
.thumbs .thumb { flex: 1; position: relative; }
.thumbs .thumb img { border-radius: 14px; aspect-ratio: 1.7; object-fit: cover; width: 100%; border: 1px solid var(--border); box-shadow: var(--shadow); }
.thumbs .thumb span { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 8px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 14px auto; max-width: 320px; }
.progress > div { height: 100%; background: var(--grad); width: 0; transition: width .3s; border-radius: 999px; }
.processing { text-align: center; padding: 34px 14px; }
.processing b { font-size: 17px; font-weight: 800; }
.scan-orb {
  width: 92px; height: 92px; margin: 0 auto 18px; border-radius: 30px; background: var(--grad); color: #fff;
  display: grid; place-items: center; box-shadow: var(--glow); position: relative;
  animation: pulse-ring 1.6s infinite;
}
.scan-orb svg { width: 40px; height: 40px; }
.scan-orb::after { content: ""; position: absolute; inset: -8px; border-radius: 36px; border: 2px dashed rgba(124, 58, 237, .35); animation: spin 8s linear infinite; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--brand-100); border-top-color: var(--brand); animation: spin 1s linear infinite; margin: 0 auto 14px; }

.active-event {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px;
  background: var(--surface); margin-bottom: 14px; cursor: pointer; border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: border-color .15s;
}
.active-event:hover { border-color: var(--brand-100); }
.active-event .ae-ic { width: 40px; height: 40px; border-radius: 13px; background: var(--grad); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.active-event .ae-ic svg { width: 20px; height: 20px; }
.active-event .body { flex: 1; min-width: 0; font-size: 13px; color: var(--text-2); }
.active-event b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.active-event .change { font-size: 13px; color: var(--brand-600); font-weight: 700; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; margin-right: 6px; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); vertical-align: 1px; }

.tag-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px; border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface-2); min-height: 48px; align-items: center; }
.tag-input:focus-within { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-100); }
.tag-input .chip { background: var(--brand-50); color: var(--brand-600); border-color: transparent; }
.tag-input .chip button { background: none; border: 0; padding: 0; margin-left: 2px; cursor: pointer; color: inherit; font-size: 15px; line-height: 1; }
.tag-input input { border: 0; outline: none; background: none; flex: 1; min-width: 120px; padding: 6px; }
.tag-suggest { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag-suggest button { cursor: pointer; }

/* ------------------------------------------------------------------ auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 960px) { .auth { grid-template-columns: 1.05fr 1fr; } }
.auth-brand {
  position: relative; overflow: hidden; isolation: isolate; color: #fff;
  background: #0b0f22;
  padding: 34px 24px 70px;
}
.auth-brand::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(600px 400px at 0% 0%, rgba(124, 58, 237, .65), transparent 60%),
    radial-gradient(500px 400px at 100% 30%, rgba(79, 70, 229, .55), transparent 60%),
    radial-gradient(500px 400px at 40% 110%, rgba(192, 38, 211, .45), transparent 60%);
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .12;
  background-image: radial-gradient(#fff 1px, transparent 1px); background-size: 22px 22px;
}
.auth-brand .brand { padding: 0 0 28px; }
.auth-brand h1 { font-size: 30px; line-height: 1.15; margin: 0 0 12px; font-weight: 800; letter-spacing: -.03em; }
.auth-brand h1 em { font-style: normal; background: linear-gradient(90deg, #c4b5fd, #f0abfc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand > p { margin: 0; color: #c7cbe0; max-width: 440px; }
.auth-feats { display: none; margin-top: 30px; gap: 14px; }
.auth-feat { display: flex; gap: 12px; align-items: flex-start; }
.auth-feat .f-ic { width: 40px; height: 40px; border-radius: 13px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .14); display: grid; place-items: center; flex-shrink: 0; }
.auth-feat .f-ic svg { width: 19px; height: 19px; }
.auth-feat b { display: block; font-size: 14.5px; }
.auth-feat span { font-size: 13px; color: #b3b8d4; }
.mock-card {
  display: none; position: absolute; right: 8%; bottom: 9%; width: 260px; height: 156px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .96), rgba(236, 233, 255, .9));
  box-shadow: 0 40px 70px -24px rgba(0, 0, 0, .7); animation: float 6s ease-in-out infinite; color: #1e1b4b; padding: 20px;
}
.mock-card b { display: block; font-size: 16px; }
.mock-card small { color: #6b6b9a; font-weight: 600; }
.mock-card i { display: block; height: 7px; border-radius: 4px; background: #d9d6fb; margin-top: 10px; }
.mock-card .qr { position: absolute; right: 18px; bottom: 18px; width: 46px; height: 46px; border-radius: 10px; background: var(--grad); }
@media (min-width: 960px) {
  .auth-brand { padding: 48px 56px; display: flex; flex-direction: column; justify-content: center; }
  .auth-brand .brand { position: absolute; top: 40px; left: 56px; }
  .auth-brand h1 { font-size: 44px; }
  .auth-feats { display: grid; }
  .mock-card { display: block; }
}
/* position + z-index: the form card must paint above the (positioned) brand panel it overlaps. */
.auth-main { position: relative; z-index: 1; display: grid; place-items: center; padding: 0 16px 32px; margin-top: -44px; }
@media (min-width: 960px) { .auth-main { margin-top: 0; padding: 40px; } }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .card { padding: 26px; box-shadow: var(--shadow-lg); }
.auth-box h2 { margin: 0 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.auth-box .sub { margin: 0 0 22px; color: var(--muted); }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.auth-switch a { font-weight: 700; }

/* ------------------------------------------------------------------ modal & toast */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 10, 25, .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 100; display: flex;
  align-items: flex-end; justify-content: center; animation: fade .15s;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--surface); width: 100%; max-width: 540px; max-height: 92vh; overflow-y: auto;
  border-radius: 28px 28px 0 0; padding: 12px 18px calc(22px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.modal::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 0 auto 14px; }
@media (min-width: 640px) { .modal { border-radius: 28px; padding: 26px; } .modal::before { display: none; } }
.modal h3 { margin: 0 0 18px; font-size: 19px; font-weight: 800; letter-spacing: -.02em; display: flex; justify-content: space-between; align-items: center; }
.modal.image { background: transparent; max-width: 900px; padding: 0; border: 0; box-shadow: none; }
.modal.image::before { display: none; }
.modal.image img { border-radius: 16px; margin: 0 auto; max-height: 86vh; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 34px); transform: translateX(-50%) translateY(20px);
  background: #0b1024; color: #fff; padding: 12px 18px; border-radius: 16px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s cubic-bezier(.2, .8, .2, 1); z-index: 200; max-width: calc(100vw - 32px); text-align: center;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, .08);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: #be123c; }
@media (min-width: 900px) { #toast { bottom: 32px; } }

.menu-list { padding: 6px 18px; }
.menu-list a, .menu-list button {
  display: flex; align-items: center; gap: 14px; padding: 14px 0; border: 0; border-bottom: 1px solid var(--border);
  background: none; width: 100%; color: var(--text); text-align: left; cursor: pointer; font-weight: 600;
}
.menu-list > :last-child { border-bottom: 0; }
.menu-list .m-ic { width: 38px; height: 38px; border-radius: 12px; background: var(--brand-50); color: var(--brand-600); display: grid; place-items: center; flex-shrink: 0; }
.menu-list .m-ic svg { width: 18px; height: 18px; }
.menu-list .m-ic.red { background: var(--hot-bg); color: var(--hot); }
.menu-list .arrow { margin-left: auto; color: var(--muted); display: grid; }
.profile-mini { display: flex; gap: 14px; align-items: center; overflow: hidden; position: relative; }
.profile-mini .avatar { width: 60px; height: 60px; border-radius: 20px; font-size: 20px; }

.event-card { display: block; color: inherit; transition: transform .15s, box-shadow .15s; }
.event-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.event-card .top { display: flex; gap: 14px; align-items: flex-start; }
.event-date {
  width: 58px; flex-shrink: 0; text-align: center; border-radius: 16px; background: var(--grad); color: #fff;
  padding: 8px 0; font-weight: 800; line-height: 1.1; box-shadow: var(--glow);
}
.event-date small { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; opacity: .85; letter-spacing: .06em; }
.event-date span { font-size: 22px; }
.event-card b { font-size: 16px; letter-spacing: -.01em; }
.badge-active { background: var(--good-bg); color: var(--good); border-color: transparent; }
.stall { border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 10px; background: var(--surface-2); }
.stall:last-child { margin-bottom: 0; }
.stall-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-list input { width: 18px; height: 18px; accent-color: var(--brand); flex-shrink: 0; }
.check-list label > span { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.check-list label .muted { display: block; font-weight: 500; }
details summary { list-style: none; }

/* ==========================================================================
   Mobile & responsive hardening
   ========================================================================== */
/* Grid/flex children may shrink below their content width (prevents page-wide overflow). */
.grid > *, .grid-2 > *, .grid-3-2 > *, .form-grid > *, .stats > *, .card-images > *, .btn-row > * { min-width: 0; }
/* Long emails, URLs and addresses wrap instead of widening the page. */
.kv .v, .row-item .body, .note, .profile .role, .profile h2, .event-card .muted, .stall-head b,
.auth-box, .modal, .lead-item .sub, .menu-list, .warn span { overflow-wrap: anywhere; }
/* Buttons in a row never squeeze their label: they wrap onto the next line instead. */
.btn-row > .btn { min-width: fit-content; }
.chip { max-width: 100%; }
.chips .chip { white-space: normal; text-align: left; }

/* Tables scroll inside their card instead of widening the page. */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; -webkit-overflow-scrolling: touch; }

/* Chart tooltips at the edges stay inside the card. */
.bars .bar-wrap:nth-child(-n+3) .tip, .bars .bar-wrap:nth-child(-n+3):hover .tip { left: 0; transform: none; }
.bars .bar-wrap:nth-last-child(-n+3) .tip, .bars .bar-wrap:nth-last-child(-n+3):hover .tip { left: auto; right: 0; transform: none; }

/* Export format buttons wrap on narrow screens. */
.fmt-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }

/* Lead list: compact meta time on phones. */
.lead-item .time-sm { display: none; font-size: 11.5px; color: var(--muted); font-weight: 600; }

/* Sticky save bar for lead forms on phones. */
.form-actions { margin-top: 16px; }

@media (max-width: 899px) {
  /* iOS zooms into inputs below 16px; keep them at 16px on touch layouts. */
  .input, select.input, textarea.input, .tag-input input { font-size: 16px; }
  .form-actions {
    position: sticky; bottom: calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)); z-index: 15;
    background: var(--surface-glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: 20px; padding: 10px; box-shadow: var(--shadow-lg);
  }
  /* Scan: capture / continue controls always visible above the bottom nav, no scrolling. */
  .shutter-row, .scan-actions {
    position: sticky; bottom: calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)); z-index: 15;
    background: var(--surface-glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg);
  }
  .shutter-row { margin-top: 12px; padding: 8px 10px; }
  .scan-actions { padding: 10px; margin-top: 12px; }
  .shutter { box-shadow: 0 0 0 5px var(--surface), 0 0 0 7px var(--brand-100), var(--glow); }
  .camera { max-height: max(220px, calc(100svh - 450px)); }
  .camera.failed, .camera.failed .cam-state { min-height: 260px; }
  /* Camera failed: the panel has its own Take photo / Gallery / Retry buttons, so drop the shutter bar. */
  .camera.failed + .shutter-row { display: none; }
  .scan-actions .btn { padding: 0 12px; }
  .captured-card img { max-height: min(240px, calc(100svh - 470px)); min-height: 120px; object-fit: contain; }
  .auth { min-height: 100dvh; }
  .modal { max-height: 88dvh; }
  .bottom-nav { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); }
}

@media (max-width: 560px) {
  .content { padding: 12px 14px 16px; }
  .card { padding: 16px; border-radius: 18px; }
  .card h2, .section-title { font-size: 14.5px; }
  .hero { padding: 20px 18px; border-radius: 22px; }
  .hero h2 { font-size: 21px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat .s-icon { width: 36px; height: 36px; margin-bottom: 10px; }
  .stat .value { font-size: 26px; }
  .bars { height: 140px; gap: 4px; }
  .lead-item { padding: 12px; gap: 12px; }
  .lead-item .right, .lead-item .chev { display: none; }
  .lead-item .time-sm { display: inline; margin-left: auto; }
  .lead-item .meta { gap: 5px; }
  .hide-sm { display: none; }
  .profile .p-body { padding: 0 14px 16px; }
  .profile h2 { font-size: 20px; }
  .actions { gap: 6px; }
  .action { padding: 10px 2px; font-size: 11px; border-radius: 14px; }
  .action .a-ic { width: 36px; height: 36px; border-radius: 12px; }
  .a-lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .kv.plain { grid-template-columns: 96px 1fr; }
  .stall-head { flex-wrap: wrap; }
  .stall-head .btn-row { width: 100%; justify-content: flex-start; }
  .row-item { flex-wrap: wrap; }
  .row-item .body { flex-basis: calc(100% - 140px); }
  .event-card .top { gap: 12px; }
  .event-date { width: 52px; }
  .scan-tabs button { font-size: 13px; gap: 5px; padding: 10px 4px; }
  .side-action { width: 72px; }
  .shutter { width: 70px; height: 70px; }
  .modal { padding-left: 16px; padding-right: 16px; }
  .auth-brand { padding: calc(22px + env(safe-area-inset-top)) 18px 64px; }
  .auth-brand .brand { padding-bottom: 20px; }
  .auth-brand h1 { font-size: 26px; }
  .auth-brand > p { font-size: 14px; }
  .auth-box .card { padding: 20px; }
  .menu-list { padding: 4px 14px; }
}

@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 24px; }
  .stat .hint { font-size: 11px; }
  .status-grid { grid-template-columns: repeat(3, 1fr); }
  .action { font-size: 10px; }
  .action .a-ic { width: 34px; height: 34px; }
  .hero .btn.light { width: 100%; }
  .topbar h1 { font-size: 18px; }
  .chip-select button { padding: 8px 12px; }
  .stars svg { width: 26px; height: 26px; }
  .nav-item { font-size: 10px; }
}

/* ==========================================================================
   iOS / Safari
   ========================================================================== */
/* Remove iOS default inner shadows / rounded native styling from fields. */
.input, textarea.input { -webkit-appearance: none; appearance: none; }
/* iOS date fields: keep height, left-align the value, show a placeholder look when empty. */
input[type="date"].input { display: block; min-width: 0; line-height: 24px; text-align: left; }
input[type="date"].input::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"].input::-webkit-calendar-picker-indicator { opacity: .6; }
/* Touch devices (incl. iPad): 16px fields so Safari never zooms on focus. */
@media (pointer: coarse) {
  .input, select.input, textarea.input, .tag-input input { font-size: 16px; }
}
/* No hover on touch screens: avoid "stuck" lifted cards/buttons after a tap. */
@media (hover: none) {
  body { background-attachment: scroll; }
  .lead-item:hover, .event-card:hover, a.stat:hover, .btn:hover, .icon-btn:hover, .action:hover,
  .card-images img:hover, .stars button:hover { transform: none; box-shadow: inherit; filter: none; }
  .lead-item:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
  .btn:hover { box-shadow: var(--glow); }
  .btn.secondary:hover, .btn.ghost:hover, .btn.danger:hover { box-shadow: none; }
  .btn:active, .lead-item:active, .action:active, .icon-btn:active { transform: scale(.97); }
}
/* Browsers without backdrop blur: make "glass" surfaces solid so text never shows through. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bottom-nav, .topbar, .form-actions { background: var(--surface); }
  .modal-backdrop { background: rgba(8, 10, 25, .72); }
}
/* While the on-screen keyboard is open, hide the floating nav so it never covers fields. */
body.kb-open .bottom-nav, body.kb-open #toast { display: none; }
body.kb-open .form-actions { bottom: calc(10px + env(safe-area-inset-bottom)); }
body.kb-open .main { padding-bottom: 24px; }

/* Landscape phones: keep the camera usable. */
@media (max-height: 500px) and (orientation: landscape) {
  .camera { aspect-ratio: 16 / 9; max-height: 70vh; }
  .bottom-nav { height: 56px; }
  .nav-item span { display: none; }
}
details summary::-webkit-details-marker { display: none; }
