/* ============================================================
   Bestway vCard Portal — Design System
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  /* Brand (sampled from logo) */
  --brand-50:  #e8f6fd;
  --brand-100: #cbeafa;
  --brand-200: #99d6f3;
  --brand-300: #5cbdea;
  --brand-400: #2ba5df;
  --brand-500: #1195d6;
  --brand-600: #0d78b0;
  --brand-700: #0b5f8c;
  --brand-800: #0a4c70;
  --brand-900: #083d5b;

  --green-400: #4fbd6c;
  --green-500: #3ba455;
  --green-600: #2f8544;

  --amber-500: #e0921a;
  --rose-500:  #e0475f;

  /* Neutrals */
  --n-0:   #ffffff;
  --n-25:  #fbfcfe;
  --n-50:  #f5f7fa;
  --n-100: #eef1f6;
  --n-200: #e2e7ef;
  --n-300: #cbd3e0;
  --n-400: #98a3b6;
  --n-500: #6b7789;
  --n-600: #4d5769;
  --n-700: #36404f;
  --n-800: #222a37;
  --n-900: #141a24;
  --n-950: #0c111a;

  /* Semantic — light */
  --bg:            var(--n-50);
  --bg-elevated:   var(--n-0);
  --bg-sunken:     var(--n-100);
  --bg-hover:      var(--n-100);
  --surface:       var(--n-0);
  --border:        var(--n-200);
  --border-strong: var(--n-300);
  --text:          var(--n-900);
  --text-muted:    var(--n-500);
  --text-subtle:   var(--n-400);
  --text-invert:   var(--n-0);
  --accent:        var(--brand-500);
  --accent-hover:  var(--brand-600);
  --accent-soft:   var(--brand-50);
  --accent-text:   var(--brand-700);
  --ring:          color-mix(in srgb, var(--brand-500) 35%, transparent);

  --grad-brand: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 45%, var(--green-500) 130%);
  --grad-mesh:
    radial-gradient(1000px 520px at 12% -10%, rgba(17,149,214,.22), transparent 60%),
    radial-gradient(760px 420px at 96% 6%, rgba(59,164,85,.16), transparent 62%);

  /* Elevation */
  --sh-xs: 0 1px 2px rgba(16,24,40,.05);
  --sh-sm: 0 1px 3px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.04);
  --sh-md: 0 4px 12px -2px rgba(16,24,40,.09), 0 2px 6px -2px rgba(16,24,40,.05);
  --sh-lg: 0 14px 34px -8px rgba(16,24,40,.14), 0 6px 14px -6px rgba(16,24,40,.07);
  --sh-xl: 0 28px 60px -14px rgba(16,24,40,.22), 0 10px 22px -10px rgba(16,24,40,.10);

  /* Shape & motion */
  --r-xs: 7px;  --r-sm: 10px; --r-md: 14px;
  --r-lg: 18px; --r-xl: 24px; --r-2xl: 32px; --r-full: 999px;
  --t-fast: 130ms cubic-bezier(.4,0,.2,1);
  --t-base: 220ms cubic-bezier(.4,0,.2,1);
  --t-slow: 420ms cubic-bezier(.22,1,.36,1);

  --nav-h: 66px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg:            var(--n-950);
  --bg-elevated:   var(--n-900);
  --bg-sunken:     #090d14;
  --bg-hover:      rgba(255,255,255,.05);
  --surface:       var(--n-900);
  --border:        rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.16);
  --text:          #eef2f8;
  --text-muted:    #93a0b3;
  --text-subtle:   #6b7789;
  --accent:        var(--brand-400);
  --accent-hover:  var(--brand-300);
  --accent-soft:   rgba(17,149,214,.14);
  --accent-text:   var(--brand-300);

  --grad-mesh:
    radial-gradient(1000px 520px at 12% -10%, rgba(17,149,214,.20), transparent 60%),
    radial-gradient(760px 420px at 96% 6%, rgba(59,164,85,.13), transparent 62%);

  --sh-xs: 0 1px 2px rgba(0,0,0,.4);
  --sh-sm: 0 1px 3px rgba(0,0,0,.45);
  --sh-md: 0 4px 14px -2px rgba(0,0,0,.55);
  --sh-lg: 0 16px 38px -10px rgba(0,0,0,.65);
  --sh-xl: 0 30px 64px -16px rgba(0,0,0,.75);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--t-base), color var(--t-base);
}

body::before {
  content: ""; position: fixed; inset: 0;
  background: var(--grad-mesh);
  pointer-events: none; z-index: 0;
}
body > * { position: relative; z-index: 1; }

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4 { line-height: 1.22; font-weight: 650; letter-spacing: -.019em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }

::selection { background: var(--accent); color: #fff; }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); background-clip: content-box; }

/* ---------- 3. Layout ---------- */
.shell { max-width: 1240px; margin-inline: auto; padding: 0 22px; }
.shell-narrow { max-width: 940px; margin-inline: auto; padding: 0 22px; }
.page { padding: 30px 0 72px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.grow { flex: 1 1 auto; min-width: 0; }
.hide { display: none !important; }

/* ---------- 4. Navbar ---------- */
.nav {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { height: 100%; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: -.02em; }
.brand img { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; }
.brand-name { font-size: 1rem; line-height: 1.15; }
.brand-sub { display: block; font-size: .68rem; font-weight: 500; color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase; }

.nav-links { display: flex; align-items: center; gap: 3px; margin-left: 14px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 500; color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-link svg { width: 17px; height: 17px; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); cursor: pointer;
  transition: all var(--t-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: block; }

.nav-toggle { display: none; }

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 17px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 600; letter-spacing: -.005em;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast);
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; pointer-events: none; }

.btn-primary { background: var(--grad-brand); color: #fff; box-shadow: 0 2px 8px -1px color-mix(in srgb, var(--brand-600) 45%, transparent); }
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 6px 18px -4px color-mix(in srgb, var(--brand-600) 55%, transparent); }

.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--sh-xs); }
.btn-ghost:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-subtle { background: var(--bg-sunken); color: var(--text-muted); }
.btn-subtle:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger { background: transparent; color: var(--rose-500); border-color: color-mix(in srgb, var(--rose-500) 35%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--rose-500) 12%, transparent); }

.btn-lg { padding: 13px 24px; font-size: .94rem; border-radius: var(--r-md); }
.btn-sm { padding: 7px 12px; font-size: .8rem; }
.btn-block { width: 100%; }

/* ---------- 6. Cards & surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 22px; }

.panel-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 1rem; }
.panel-head > svg { width: 18px; height: 18px; flex: none; color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  background: var(--bg-sunken); color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge svg { width: 13px; height: 13px; flex: none; }
.badge-brand { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.badge-green { background: color-mix(in srgb, var(--green-500) 13%, transparent); color: var(--green-600); border-color: color-mix(in srgb, var(--green-500) 28%, transparent); }
[data-theme="dark"] .badge-green { color: var(--green-400); }

/* ---------- 7. Page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .eyebrow { font-size: .74rem; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.page-head p { color: var(--text-muted); font-size: .9rem; margin-top: 5px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 8. Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px 18px; box-shadow: var(--sh-xs);
  transition: transform var(--t-base), box-shadow var(--t-base);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.stat::after { content:""; position:absolute; inset:0 0 auto auto; width:110px; height:110px; background: var(--grad-brand); opacity:.07; border-radius:50%; transform: translate(38%,-42%); }
.stat-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-text); margin-bottom: 11px; }
.stat-ico svg { width: 17px; height: 17px; }
.stat-val { font-size: 1.65rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 5px; font-weight: 500; }

/* ---------- 9. Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 11px 13px; margin-bottom: 22px;
  box-shadow: var(--sh-xs);
}
.search { position: relative; flex: 1 1 260px; min-width: 200px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-subtle); pointer-events: none; }
.search input {
  width: 100%; padding: 10px 14px 10px 40px;
  background: var(--bg-sunken); border: 1px solid transparent;
  border-radius: var(--r-sm); font-size: .88rem; outline: none;
  transition: all var(--t-fast);
}
.search input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.search input::placeholder { color: var(--text-subtle); }

.seg { display: flex; background: var(--bg-sunken); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 0; background: transparent; border-radius: 7px;
  font-size: .8rem; font-weight: 550; color: var(--text-muted); cursor: pointer;
  transition: all var(--t-fast);
}
.seg button svg { width: 15px; height: 15px; }
.seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--sh-xs); }

.select-wrap { position: relative; }
.select-wrap select {
  appearance: none; padding: 10px 34px 10px 13px;
  background: var(--bg-sunken); border: 1px solid transparent;
  border-radius: var(--r-sm); font-size: .85rem; font-weight: 500; cursor: pointer; outline: none;
}
.select-wrap select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.select-wrap::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}

/* ---------- 10. Contact card grid ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); gap: 20px; }

.vcard {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-sm);
  display: flex; flex-direction: column;
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
  animation: rise var(--t-slow) both;
}
.vcard:hover { transform: translateY(-4px); box-shadow: var(--sh-lg); border-color: color-mix(in srgb, var(--accent) 32%, var(--border)); }

.vcard-cover { height: 78px; background: var(--grad-brand); position: relative; }
.vcard-cover::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.28) 1px, transparent 1px);
  background-size: 13px 13px; opacity: .5;
}
.vcard-qrbtn {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center; cursor: pointer;
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.32);
  color: #fff; backdrop-filter: blur(6px); transition: all var(--t-fast);
}
.vcard-qrbtn:hover { background: rgba(255,255,255,.34); transform: scale(1.06); }
.vcard-qrbtn svg { width: 17px; height: 17px; }

/* position+z-index so the avatar lifts above the positioned cover instead of being clipped by it */
.vcard-body { position: relative; z-index: 3; padding: 0 20px 18px; margin-top: -34px; flex: 1; display: flex; flex-direction: column; }

.avatar {
  width: 68px; height: 68px; border-radius: 20px; object-fit: cover;
  border: 3px solid var(--surface); background: var(--bg-sunken);
  box-shadow: var(--sh-md);
}
.avatar-fb {
  display: grid; place-items: center;
  font-weight: 700; font-size: 1.32rem; color: #fff; letter-spacing: -.02em;
  background: var(--grad-brand);
}
.avatar-lg { width: 108px; height: 108px; border-radius: 28px; font-size: 2.1rem; border-width: 4px; }

.vcard-name { font-size: 1.06rem; font-weight: 660; letter-spacing: -.02em; margin-top: 13px; }
.vcard-role { font-size: .845rem; color: var(--accent-text); font-weight: 550; margin-top: 2px; }
.vcard-org { font-size: .81rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.vcard-org svg { width: 14px; height: 14px; flex: none; opacity: .8; }

.vcard-meta { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 8px; }
.meta-row { display: flex; align-items: center; gap: 9px; font-size: .82rem; color: var(--text-muted); min-width: 0; }
.meta-row svg { width: 14px; height: 14px; flex: none; color: var(--text-subtle); }
.meta-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-row a:hover { color: var(--accent); }

.vcard-foot { margin-top: auto; padding-top: 16px; display: flex; align-items: center; gap: 7px; }
.vcard-foot .btn { flex: 1; }
.act {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  transition: all var(--t-fast);
}
.act svg { width: 16px; height: 16px; }
.act:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.act-danger:hover { color: var(--rose-500); border-color: var(--rose-500); background: color-mix(in srgb, var(--rose-500) 10%, transparent); }

/* Flip-to-QR */
.vcard-qr {
  position: absolute; inset: 0; z-index: 5;
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
  opacity: 0; visibility: hidden; transform: scale(.94);
  transition: opacity var(--t-base), transform var(--t-base), visibility var(--t-base);
}
.vcard.show-qr .vcard-qr { opacity: 1; visibility: visible; transform: scale(1); }
.vcard-qr img { width: 158px; height: 158px; border-radius: var(--r-md); background: #fff; padding: 8px; box-shadow: var(--sh-md); }
.vcard-qr .qr-name { font-weight: 640; font-size: .95rem; }
.vcard-qr .qr-hint { font-size: .78rem; color: var(--text-muted); max-width: 210px; }

/* ---------- 11. List view ---------- */
.grid-cards.as-list { grid-template-columns: 1fr; gap: 10px; }
.as-list .vcard { flex-direction: row; align-items: center; gap: 16px; padding: 12px 16px; border-radius: var(--r-md); }
.as-list .vcard:hover { transform: none; }
.as-list .vcard-cover { display: none; }
.as-list .vcard-body { flex-direction: row; align-items: center; gap: 16px; margin: 0; padding: 0; width: 100%; }
.as-list .avatar { width: 46px; height: 46px; border-radius: 13px; font-size: .95rem; border-width: 2px; box-shadow: none; }
.as-list .vcard-ident { min-width: 0; flex: 1 1 200px; }
.as-list .vcard-name { margin: 0; font-size: .93rem; }
.as-list .vcard-role { font-size: .78rem; }
.as-list .vcard-org { display: none; }
.as-list .vcard-meta { margin: 0; padding: 0; border: 0; flex: 1 1 240px; flex-direction: row; gap: 20px; }
.as-list .vcard-meta .meta-row:nth-child(n+3) { display: none; }
.as-list .vcard-foot { margin: 0; padding: 0; }
.as-list .vcard-foot .btn-primary { display: none; }
.as-list .vcard-qr { border-radius: var(--r-md); }
@media (max-width: 860px) {
  .as-list .vcard-meta { display: none; }
}

/* ---------- 12. Empty state ---------- */
.empty { text-align: center; padding: 74px 24px; }
.empty-ico {
  width: 82px; height: 82px; margin: 0 auto 22px; border-radius: var(--r-xl);
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.empty-ico svg { width: 38px; height: 38px; }
.empty h3 { font-size: 1.12rem; margin-bottom: 8px; }
.empty p { color: var(--text-muted); font-size: .9rem; max-width: 400px; margin: 0 auto 22px; }

/* ---------- 13. Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.label { font-size: .8rem; font-weight: 600; color: var(--text-muted); letter-spacing: .005em; }
.label .req { color: var(--rose-500); margin-left: 2px; }

.input, .textarea, .select {
  width: 100%; padding: 11px 14px;
  background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: .9rem; outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover { border-color: var(--text-subtle); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.input-ico { position: relative; }
.input-ico > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-subtle); pointer-events: none; }
.input-ico .input { padding-left: 40px; }
.select { appearance: none; cursor: pointer; background-image: none; padding-right: 36px; }
.select-arrow { position: relative; }
.select-arrow::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.hint { font-size: .74rem; color: var(--text-subtle); }

.form-section + .form-section { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--border); }
.form-section-head { display: flex; align-items: center; gap: 11px; margin-bottom: 18px; }
.form-section-num {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  border-radius: 8px; background: var(--accent-soft); color: var(--accent-text);
  font-size: .76rem; font-weight: 700;
}
.form-section-head h3 { font-size: .95rem; }
.form-section-head p { font-size: .78rem; color: var(--text-muted); margin-top: 1px; }

/* Photo dropzone */
.dropzone {
  display: flex; align-items: center; gap: 16px;
  padding: 15px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--bg-sunken); cursor: pointer;
  transition: all var(--t-fast);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type=file] { display: none; }
.dz-preview {
  width: 60px; height: 60px; flex: none; border-radius: var(--r-md); object-fit: cover;
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text-subtle);
}
.dz-preview svg { width: 22px; height: 22px; }
.dz-text strong { display: block; font-size: .86rem; font-weight: 600; }
.dz-text span { font-size: .76rem; color: var(--text-muted); }

/* ---------- 14. Live preview card ---------- */
.preview-col { position: sticky; top: calc(var(--nav-h) + 24px); }
.preview-shell { display: flex; flex-direction: column; gap: 16px; }
.preview-shell > .row > svg { width: 14px; height: 14px; flex: none; }

.bizcard {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--sh-xl);
}
.bizcard-cover { height: 92px; background: var(--grad-brand); position: relative; }
.bizcard-cover::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.28) 1px, transparent 1px);
  background-size: 14px 14px; opacity: .5;
}
.bizcard-logo { position: absolute; top: 13px; right: 14px; height: 30px; width: auto; padding: 4px;
  background: rgba(255,255,255,.92); border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.bizcard-body { position: relative; z-index: 3; padding: 0 22px 22px; margin-top: -38px; }
.bizcard-name { font-size: 1.24rem; font-weight: 680; letter-spacing: -.025em; margin-top: 14px; }
.bizcard-role { font-size: .88rem; color: var(--accent-text); font-weight: 570; margin-top: 3px; }
.bizcard-org { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.bizcard-lines { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 10px; }

.preview-note { display: flex; gap: 10px; padding: 13px 15px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-text); font-size: .8rem; line-height: 1.5; }
.preview-note svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ---------- 15. Profile view ---------- */
.profile-grid { display: grid; grid-template-columns: 1.35fr .85fr; gap: 24px; align-items: start; }
/* Grid/flex children default to min-width:auto and refuse to shrink below their
   content — that is what pushes long URLs and addresses past the viewport. */
.profile-grid > *, .split > *, .stack { min-width: 0; }

.hero { position: relative; overflow: hidden; border-radius: var(--r-2xl); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--sh-md); }
.hero-cover { height: 150px; background: var(--grad-brand); position: relative; }
.hero-cover::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.25) 1.2px, transparent 1.2px);
  background-size: 17px 17px; opacity: .55;
}
.hero-logo { position: absolute; top: 20px; right: 24px; height: 42px; width: auto; padding: 5px;
  background: rgba(255,255,255,.92); border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.14); }
.hero-body { position: relative; z-index: 3; padding: 0 28px 28px; margin-top: -56px; }
.hero-name { font-size: 1.72rem; font-weight: 700; letter-spacing: -.032em; margin-top: 16px; }
.hero-role { font-size: .98rem; color: var(--accent-text); font-weight: 570; margin-top: 4px; }
.hero-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border); }

.contact-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.contact-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 15px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg-sunken);
  transition: all var(--t-fast); min-width: 0;
}
.contact-item:hover { border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); transform: translateX(2px); }
.contact-ico { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); color: var(--accent); }
.contact-ico svg { width: 17px; height: 17px; }
.contact-txt { min-width: 0; flex: 1 1 auto; }
.contact-txt .k { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-subtle); font-weight: 600; line-height: 1.5; }
/* Contact values wrap rather than truncate — a clipped email address is useless. */
.contact-txt .v { display: block; font-size: .88rem; font-weight: 540; line-height: 1.35; overflow-wrap: anywhere; }
.contact-item.wide { grid-column: 1 / -1; }

/* QR panel */
.qr-panel { text-align: center; padding: 26px 22px; }
.qr-frame {
  position: relative; display: inline-block; padding: 16px;
  background: #fff; border-radius: var(--r-xl); box-shadow: var(--sh-md);
}
.qr-frame img { width: 100%; max-width: 224px; height: auto; display: block; }
.qr-frame::before, .qr-frame::after,
.qr-frame > .c1, .qr-frame > .c2 {
  content: ""; position: absolute; width: 20px; height: 20px;
  border: 2.5px solid var(--accent); border-radius: 4px;
}
.qr-frame::before { top: 7px; left: 7px; border-right: 0; border-bottom: 0; }
.qr-frame::after { top: 7px; right: 7px; border-left: 0; border-bottom: 0; }
.qr-frame > .c1 { bottom: 7px; left: 7px; border-right: 0; border-top: 0; }
.qr-frame > .c2 { bottom: 7px; right: 7px; border-left: 0; border-top: 0; }
.qr-caption { font-size: .82rem; color: var(--text-muted); margin-top: 18px; line-height: 1.55; }
.qr-actions { display: grid; gap: 9px; margin-top: 20px; }

.link-box { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: var(--r-sm); background: var(--bg-sunken); border: 1px solid var(--border); }
.link-box > svg { width: 15px; height: 15px; flex: none; color: var(--text-subtle); }
.link-box code { flex: 1; min-width: 0; font-family: var(--mono); font-size: .74rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 16. Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside {
  position: relative; overflow: hidden; padding: 52px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--grad-brand); color: #fff;
}
.auth-aside::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.22) 1.2px, transparent 1.2px);
  background-size: 22px 22px; opacity: .45;
}
.auth-aside > * { position: relative; z-index: 2; }
.auth-blob { position: absolute; border-radius: 50%; filter: blur(58px); opacity: .45; z-index: 1; }
.auth-blob.b1 { width: 380px; height: 380px; background: #7fe0a5; top: -90px; right: -80px; animation: float 13s ease-in-out infinite; }
.auth-blob.b2 { width: 320px; height: 320px; background: #6fd0ff; bottom: -80px; left: -60px; animation: float 17s ease-in-out infinite reverse; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.05rem; }
.auth-brand img { width: 42px; height: 42px; border-radius: 10px; background: #fff; padding: 4px; }
.auth-hero h1 { font-size: 2.55rem; letter-spacing: -.038em; line-height: 1.1; }
.auth-hero p { margin-top: 16px; font-size: 1rem; opacity: .9; max-width: 430px; line-height: 1.6; }
.auth-feats { display: flex; flex-direction: column; gap: 13px; margin-top: 32px; }
.auth-feat { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.auth-feat i { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 9px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.25); }
.auth-feat svg { width: 15px; height: 15px; }
.auth-foot { font-size: .78rem; opacity: .72; }

.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-box { width: 100%; max-width: 392px; }
.auth-box h2 { font-size: 1.6rem; letter-spacing: -.03em; }
.auth-box .sub { color: var(--text-muted); font-size: .89rem; margin-top: 7px; margin-bottom: 28px; }
.auth-mobile-brand { display: none; align-items: center; gap: 11px; margin-bottom: 26px; font-weight: 700; }
.auth-mobile-brand img { width: 38px; height: 38px; }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); font-size: .84rem; margin-bottom: 18px; animation: shake .4s; }
.alert svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert-error { background: color-mix(in srgb, var(--rose-500) 11%, transparent); color: var(--rose-500); border: 1px solid color-mix(in srgb, var(--rose-500) 28%, transparent); }

.pw-wrap { position: relative; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: transparent; color: var(--text-subtle); cursor: pointer; display: grid; place-items: center; border-radius: 7px; }
.pw-toggle:hover { color: var(--text); background: var(--bg-hover); }
.pw-toggle svg { width: 17px; height: 17px; }
.pw-wrap .input { padding-right: 44px; }

/* ---------- 17. Toast ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 17px; border-radius: var(--r-full);
  background: var(--n-900); color: #fff; font-size: .85rem; font-weight: 500;
  box-shadow: var(--sh-lg); animation: toastIn var(--t-slow);
}
[data-theme="dark"] .toast { background: var(--n-100); color: var(--n-900); }
.toast svg { width: 16px; height: 16px; color: var(--green-400); }
.toast.out { animation: toastOut var(--t-base) forwards; }

/* ---------- 18. Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-26px, 26px) scale(1.09); } }
@keyframes shake { 0%,100%{transform:translateX(0)} 22%{transform:translateX(-6px)} 45%{transform:translateX(6px)} 68%{transform:translateX(-3px)} }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.96); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- 19. Responsive ---------- */
@media (max-width: 1080px) {
  .profile-grid { grid-template-columns: 1fr; }
  .preview-col { position: static; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-mobile-brand { display: flex; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr !important; }
}
@media (max-width: 760px) {
  .nav-toggle { display: inline-grid; }
  .nav-links {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: 12px 20px 18px; margin: 0;
    background: var(--bg-elevated); border-bottom: 1px solid var(--border);
    box-shadow: var(--sh-lg);
    display: none;
  }
  .nav-links.open { display: flex; }
  .brand-sub { display: none; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .contact-list { grid-template-columns: 1fr; }
  .hero-body, .card-pad { padding-left: 20px; padding-right: 20px; }
  h1 { font-size: 1.5rem; }
  .hero-name { font-size: 1.42rem; }
  .auth-main { padding: 28px 20px; }
}
@media (max-width: 460px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-val { font-size: 1.4rem; }
  .shell, .shell-narrow { padding: 0 16px; }
}

/* ---------- 20. Print ---------- */
@media print {
  .nav, .toolbar, .hero-actions, .qr-actions, .act, .toast-wrap, .page-head .actions { display: none !important; }
  body::before { display: none; }
  body { background: #fff; }
  .card, .hero, .vcard { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .profile-grid { grid-template-columns: 1.3fr .7fr; }
}

/* ---------- 21. Scan analytics ---------- */
/* Bar hues validated with the dataviz palette checker (light #1195d6 on #fff,
   dark #1e9ddb on #0c111a): lightness band, chroma floor and 3:1 contrast all pass. */
:root          { --chart-bar: #1195d6; --chart-grid: var(--border); }
[data-theme="dark"] { --chart-bar: #1e9ddb; }

.scan-hero { display: flex; align-items: baseline; gap: 12px; }
.scan-hero .figure { font-size: 2.8rem; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.scan-hero .unit { font-size: .84rem; color: var(--text-muted); font-weight: 500; }
.scan-sub { font-size: .82rem; color: var(--text-muted); margin-top: 8px; }

.scan-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.scan-split .cell { padding: 12px 14px; border-radius: var(--r-md); background: var(--bg-sunken); border: 1px solid var(--border); }
.scan-split .n { font-size: 1.2rem; font-weight: 680; letter-spacing: -.025em; }
.scan-split .k { font-size: .72rem; color: var(--text-muted); margin-top: 3px; }

/* Column chart: bars grow from one baseline, capped thickness, 4px rounded top */
.chart { margin-top: 4px; }
.chart-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.chart-head h3 { font-size: .9rem; }
.chart-head .spacer { flex: 1; }
.chart-toggle { display: flex; background: var(--bg-sunken); border-radius: 8px; padding: 2px; gap: 2px; }
.chart-toggle button { border: 0; background: transparent; border-radius: 6px; padding: 4px 10px; font-size: .74rem; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.chart-toggle button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--sh-xs); }

.plot { position: relative; height: 132px; }
.plot-grid { position: absolute; inset: 18px 0 0 0; display: flex; flex-direction: column; justify-content: space-between; }
.plot-grid span { display: block; height: 1px; background: var(--chart-grid); }   /* hairline, solid */
.plot-bars { position: absolute; inset: 18px 0 0 0; display: flex; align-items: flex-end; gap: 2px; }  /* 2px surface gap */
.bar-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; cursor: default; }
.bar {
  width: 100%; max-width: 18px; min-height: 2px;
  background: var(--chart-bar);
  border-radius: 4px 4px 0 0;                 /* rounded data-end, square at baseline */
  transition: opacity var(--t-fast);
}
.bar-zero { background: var(--border); min-height: 2px; }
.bar-slot:hover .bar { opacity: .78; }
.bar-peak-label { position: absolute; left: 50%; transform: translateX(-50%); font-size: .68rem; font-weight: 700; color: var(--text); white-space: nowrap; }

.plot-axis { display: flex; justify-content: space-between; margin-top: 9px; }
.plot-axis .tick { font-size: .66rem; color: var(--text-subtle); font-variant-numeric: tabular-nums; white-space: nowrap; }

.bar-tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--n-900); color: #fff; border-radius: 7px; padding: 5px 9px;
  font-size: .72rem; font-weight: 500; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity var(--t-fast); z-index: 6; box-shadow: var(--sh-md);
}
[data-theme="dark"] .bar-tip { background: var(--n-100); color: var(--n-900); }
.bar-slot:hover .bar-tip, .bar-slot:focus-within .bar-tip { opacity: 1; }

/* Table twin — every value readable without hovering */
.scan-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.scan-table th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); padding: 7px 10px; border-bottom: 1px solid var(--border); }
.scan-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.scan-table tr:last-child td { border-bottom: 0; }
.scan-table td:last-child, .scan-table th:last-child { text-align: right; }
.scan-scroll { max-height: 232px; overflow-y: auto; overflow-x: auto; }

/* Device split: labelled rows with a single-hue meter — never colour alone */
.dev-row { display: flex; align-items: center; gap: 11px; padding: 7px 0; }
.dev-row .name { font-size: .82rem; font-weight: 550; width: 68px; flex: none; }
.dev-row .track { flex: 1; height: 7px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; }
.dev-row .fill { display: block; height: 100%; border-radius: 99px; background: var(--chart-bar); }
.dev-row .n { font-size: .78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; width: 68px; text-align: right; flex: none; white-space: nowrap; }

/* Scan badge on dashboard cards */
.scan-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent-text);
  font-size: .72rem; font-weight: 650; font-variant-numeric: tabular-nums;
}
.scan-chip svg { width: 12px; height: 12px; }
.scan-chip.is-zero { background: var(--bg-sunken); color: var(--text-subtle); }
.vcard-cover .scan-chip {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.32);
  color: #fff; backdrop-filter: blur(6px);
}
.as-list .vcard-cover .scan-chip { position: static; }
.as-list .vcard-scans { flex: none; }

@media (max-width: 760px) {
  .scan-split { grid-template-columns: 1fr; }
  .plot { height: 108px; }
}

/* ---------- 22. Full scan log ---------- */
.scan-table-full { min-width: 720px; }
.scan-table-full th { padding: 11px 22px; white-space: nowrap; }
.scan-table-full td { padding: 11px 22px; vertical-align: middle; }
.scan-table-full td:last-child, .scan-table-full th:last-child { text-align: left; }
.scan-table-full tbody tr { transition: background var(--t-fast); }
.scan-table-full tbody tr:hover { background: var(--bg-sunken); }
.scan-table-full .badge { font-weight: 550; }

.visitor-id {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 6px;
  background: var(--bg-sunken); border: 1px solid var(--border);
  color: var(--text-muted);
}

.table-foot {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 22px; border-top: 1px solid var(--border);
}
.table-foot .range { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pager { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pager .page-of { font-size: .8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pager .btn svg { width: 15px; height: 15px; }

@media (max-width: 560px) {
  .scan-table-full th, .scan-table-full td { padding-left: 16px; padding-right: 16px; }
  .table-foot { padding-inline: 16px; }
  .pager { margin-left: 0; width: 100%; justify-content: space-between; }
}
