/* ============================================================
   Visiting Card — Design System
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --brand-50:  #EEF2FF;
  --brand-100: #E0E7FF;
  --brand-200: #C7D2FE;
  --brand-400: #818CF8;
  --brand-500: #6366F1;
  --brand-600: #4F46E5;
  --brand-700: #4338CA;
  --violet-500:#8B5CF6;
  --violet-600:#7C3AED;

  /* Semantic */
  --success:   #10B981;
  --success-bg:#D1FAE5;
  --danger:    #EF4444;
  --danger-bg: #FEE2E2;
  --warning:   #F59E0B;
  --warning-bg:#FEF3C7;
  --info:      #3B82F6;

  /* Neutrals */
  --gray-50:  #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* Semantic UI */
  --bg:         var(--gray-50);
  --surface:    #FFFFFF;
  --surface-2:  var(--gray-100);
  --text:       var(--gray-900);
  --text-muted: var(--gray-500);
  --border:     var(--gray-200);

  /* Radius */
  --r-sm: 8px;
  --r:    12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-full: 9999px;

  /* Shadow */
  --sh-xs: 0 1px 2px rgba(15,23,42,.04);
  --sh-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --sh:    0 4px 6px -1px rgba(15,23,42,.06), 0 2px 4px -2px rgba(15,23,42,.04);
  --sh-md: 0 10px 15px -3px rgba(15,23,42,.08), 0 4px 6px -4px rgba(15,23,42,.05);
  --sh-lg: 0 20px 25px -5px rgba(15,23,42,.08), 0 8px 10px -6px rgba(15,23,42,.04);
  --sh-xl: 0 25px 50px -12px rgba(15,23,42,.18);

  /* Spacing */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  /* Motion */
  --ease:     cubic-bezier(.4,0,.2,1);
  --ease-out: cubic-bezier(0,0,.2,1);
  --t-fast: 150ms;
  --t:      250ms;
  --t-slow: 400ms;

  /* Layout */
  --header-h:    60px;
  --bottomnav-h: 68px;
  --container:   480px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:         #0B1120;
    --surface:    #1E293B;
    --surface-2:  #334155;
    --text:       #F1F5F9;
    --text-muted: #94A3B8;
    --border:     #334155;
    --gray-100:   #1E293B;
    --gray-200:   #334155;
  }
}

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--brand-600); text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }

/* ============================================================
   Header
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header__inner {
  max-width: var(--container);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--s4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}
.brand {
  display: flex; align-items: center; gap: var(--s2);
  font-weight: 700; font-size: 15px; color: var(--text);
}
.brand__logo {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), var(--violet-600));
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,.35);
}
.brand__logo svg { width: 18px; height: 18px; }
.header-actions { display: flex; align-items: center; gap: var(--s2); }
.header-icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r);
  color: var(--text-muted);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.header-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.header-icon-btn svg { width: 20px; height: 20px; }

/* ============================================================
   Main / Layout
   ============================================================ */
.app-main {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--s5) var(--s4) var(--s8);
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--s2);
}
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: var(--s5); }

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: var(--sh-sm);
}
.card + .card { margin-top: var(--s4); }
.card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: var(--s4);
}

/* ============================================================
   Hero / Welcome
   ============================================================ */
.hero {
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--violet-600) 100%);
  color: #fff;
  border-radius: var(--r-xl);
  padding: var(--s6) var(--s5);
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 40px -12px rgba(99,102,241,.45);
  margin-bottom: var(--s5);
}
.hero::before {
  content: '';
  position: absolute; inset: -50%;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.18), transparent 45%);
  pointer-events: none;
}
.hero__row {
  display: flex; align-items: center; gap: var(--s3);
  position: relative; z-index: 1;
}
.hero__avatar {
  width: 52px; height: 52px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.2);
  backdrop-filter: blur(10px);
  display: grid; place-items: center;
  font-size: 24px;
  flex-shrink: 0;
}
.hero__greeting {
  font-size: 12px; opacity: .85;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 500;
  margin-bottom: 2px;
}
.hero__name {
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: var(--s2);
  flex-wrap: wrap;
}
.hero__badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.22);
  backdrop-filter: blur(10px);
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
}

/* ============================================================
   Stats
   ============================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s3);
  margin-bottom: var(--s5);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s4) var(--s3);
  text-align: center;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.stat__value {
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--brand-500), var(--violet-600));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  line-height: 1.1;
}
.stat__label {
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 4px;
}

/* ============================================================
   Action grid
   ============================================================ */
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s3);
}
.action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  text-align: left;
  transition: all var(--t) var(--ease);
  position: relative;
  overflow: hidden;
}
.action:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: var(--brand-200);
}
.action:active { transform: scale(.98); }
.action__icon {
  width: 40px; height: 40px;
  border-radius: var(--r);
  display: grid; place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.action__icon svg { width: 20px; height: 20px; }
.action__label { font-size: 14px; font-weight: 600; }
.action__hint  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.action--scan    .action__icon { background: linear-gradient(135deg, #6366F1, #8B5CF6); }
.action--contacts.action__icon { background: linear-gradient(135deg, #06B6D4, #3B82F6); }
.action--profile .action__icon { background: linear-gradient(135deg, #10B981, #059669); }
.action--users   .action__icon { background: linear-gradient(135deg, #F59E0B, #EF4444); }
.action--logout  .action__icon { background: linear-gradient(135deg, #64748B, #334155); }
.action--login   .action__icon { background: linear-gradient(135deg, #4F46E5, #7C3AED); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 12px 20px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
  cursor: pointer;
  text-align: center;
  min-height: 44px;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn--primary {
  background: linear-gradient(135deg, var(--brand-600), var(--violet-600));
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,.35);
}
.btn--primary:hover { box-shadow: 0 8px 20px rgba(99,102,241,.45); }

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn--secondary:hover { background: var(--surface-2); }

.btn--ghost { color: var(--text-muted); background: transparent; }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

.btn--danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239,68,68,.3);
}
.btn--danger:hover { box-shadow: 0 8px 20px rgba(239,68,68,.4); }

.btn--block { width: 100%; }
.btn--sm { padding: 8px 14px; font-size: 13px; min-height: 36px; }
.btn--sm svg { width: 16px; height: 16px; }

.btn-group { display: flex; gap: var(--s2); }
.btn-group .btn { flex: 1; }

/* ============================================================
   Forms
   ============================================================ */
.field { margin-bottom: var(--s4); }
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--s2);
}
.field__label .req { color: var(--danger); margin-left: 2px; }
.field__hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.field__error { font-size: 12px; color: var(--danger); margin-top: 6px; }

.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  min-height: 44px;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.textarea { resize: vertical; min-height: 90px; padding: 12px 14px; }

.input-icon { position: relative; }
.input-icon svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}
.input-icon .input { padding-left: 40px; }

input[type="file"] {
  padding: 10px;
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: var(--r);
  cursor: pointer;
  font-size: 13px;
  width: 100%;
}
input[type="file"]:hover { border-color: var(--brand-400); }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--s4);
  border: 1px solid transparent;
  animation: slideIn var(--t) var(--ease);
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert--success { background: var(--success-bg); color: #065F46; border-color: #A7F3D0; }
.alert--error   { background: var(--danger-bg);  color: #991B1B; border-color: #FECACA; }
.alert--info    { background: var(--brand-50);   color: var(--brand-700); border-color: var(--brand-200); }
.alert--warning { background: var(--warning-bg); color: #92400E; border-color: #FDE68A; }

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  text-align: center;
  padding: var(--s10) var(--s5);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
}
.empty__icon {
  width: 64px; height: 64px;
  margin: 0 auto var(--s4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-muted);
}
.empty__icon svg { width: 32px; height: 32px; }
.empty__title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.empty__text  { font-size: 13px; color: var(--text-muted); margin-bottom: var(--s4); }

/* ============================================================
   Bottom nav
   ============================================================ */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.bottom-nav__link {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  transition: color var(--t-fast) var(--ease);
  padding: 6px 4px;
}
.bottom-nav__link svg { width: 22px; height: 22px; }
.bottom-nav__link:hover { color: var(--text); }
.bottom-nav__link.is-active { color: var(--brand-600); }
.bottom-nav__link.is-active svg { filter: drop-shadow(0 2px 6px rgba(99,102,241,.4)); }

/* ============================================================
   Toast
   ============================================================ */
.toast-wrap {
  position: fixed;
  left: 50%; bottom: calc(var(--bottomnav-h) + 20px);
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}
.toast {
  background: var(--gray-900);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--sh-lg);
  animation: toastIn var(--t) var(--ease-out);
  max-width: 90vw;
}
.toast--success { background: var(--success); }
.toast--error   { background: var(--danger);  }

/* ============================================================
   Modal (bottom sheet on mobile)
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn var(--t-fast) var(--ease);
}
.modal.is-open { display: flex; }
.modal__panel {
  background: var(--surface);
  width: 100%;
  max-width: var(--container);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s5);
  padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
  animation: sheetUp var(--t-slow) var(--ease-out);
}
@media (min-width: 520px) {
  .modal { align-items: center; }
  .modal__panel { border-radius: var(--r-xl); max-width: 440px; }
}
.modal__handle {
  width: 40px; height: 4px;
  border-radius: var(--r-full);
  background: var(--border);
  margin: 0 auto var(--s4);
}
.modal__title { font-size: 17px; font-weight: 700; margin-bottom: var(--s4); }

/* ============================================================
   Misc
   ============================================================ */
.avatar {
  width: 44px; height: 44px;
  border-radius: var(--r);
  background: linear-gradient(135deg, var(--brand-500), var(--violet-600));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 84px; height: 84px; border-radius: var(--r-lg); font-size: 28px; }

.divider { height: 1px; background: var(--border); margin: var(--s4) 0; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
}
.chip--brand { background: var(--brand-50); color: var(--brand-700); }
.chip--success { background: var(--success-bg); color: #065F46; }
.chip--danger { background: var(--danger-bg); color: #991B1B; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r);
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn   { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideIn  { from { opacity:0; transform: translateY(-6px) } to { opacity:1; transform: none } }
@keyframes sheetUp  { from { transform: translateY(100%) } to { transform: none } }
@keyframes toastIn  { from { opacity:0; transform: translate(-50%, 12px) } to { opacity:1; transform: translate(-50%,0) } }
@keyframes shimmer  { to { background-position: -200% 0 } }
@keyframes fadeUp   { from { opacity:0; transform: translateY(10px) } to { opacity:1; transform: none } }

.anim-in { animation: fadeUp var(--t-slow) var(--ease-out) both; }
.d1 { animation-delay: 40ms; }
.d2 { animation-delay: 80ms; }
.d3 { animation-delay: 120ms; }
.d4 { animation-delay: 160ms; }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s5);
  background:
    radial-gradient(circle at 20% 0%, rgba(99,102,241,.14), transparent 45%),
    radial-gradient(circle at 80% 100%, rgba(139,92,246,.14), transparent 45%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s8) var(--s6);
  box-shadow: var(--sh-lg);
}
.auth-logo {
  width: 56px; height: 56px;
  margin: 0 auto var(--s4);
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand-600), var(--violet-600));
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 12px 28px -6px rgba(99,102,241,.5);
}
.auth-logo svg { width: 28px; height: 28px; }
.auth-title { text-align: center; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.auth-sub   { text-align: center; color: var(--text-muted); font-size: 13px; margin: 6px 0 var(--s6); }
.auth-footer { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: var(--s5); }

/* ============================================================
   Utilities
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-center { text-align: center; }
.mt-2 { margin-top: var(--s2); }
.mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); }
.mt-5 { margin-top: var(--s5); }
.mb-2 { margin-bottom: var(--s2); }
.mb-3 { margin-bottom: var(--s3); }
.mb-4 { margin-bottom: var(--s4); }
.mb-5 { margin-bottom: var(--s5); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--s2); }
.gap-3 { gap: var(--s3); }
.hidden { display: none !important; }