/* =========================================================================
   Shupav vCards — platform UI
   Clean, minimal, product-grade. Neutral canvas, generous whitespace,
   restrained colour, one accent. Inter throughout.
   ========================================================================= */

:root {
  --accent: #00b14c;
  --accent-press: #009440;
  --accent-soft: #e3f6ea;

  --ink: #003642;
  --ink-2: #2b4a52;
  --muted: #5f7278;
  --muted-2: #869a9f;

  --canvas: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --line: #e4e4e7;
  --line-2: #d2d2d7;

  --ok: #1a7f4b;
  --ok-soft: #e6f5ec;
  --warn: #9a6a00;
  --warn-soft: #fdf3dd;
  --danger: #c81e1e;
  --danger-soft: #fdeaea;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px -4px rgba(0,0,0,0.10), 0 2px 6px -2px rgba(0,0,0,0.06);
  --shadow-lg: 0 20px 48px -16px rgba(0,0,0,0.22), 0 8px 20px -8px rgba(0,0,0,0.10);

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --maxw: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { letter-spacing: -0.02em; line-height: 1.15; font-weight: 600; }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 980px;
  font-size: 0.9375rem; font-weight: 500; white-space: nowrap;
  transition: background .2s var(--ease), transform .1s var(--ease), box-shadow .2s var(--ease), color .2s;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-press); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: rgba(0,0,0,0.05); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: var(--line-2); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn--sm { height: 32px; padding: 0 14px; font-size: 0.875rem; }
.btn--lg { height: 48px; padding: 0 26px; font-size: 1rem; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }

/* --- Forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 0.8125rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: 0.9375rem; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 92px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }

/* --- App shell ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 18px;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.95rem; }
.topbar__brand img { height: 22px; width: auto; }
.brand-chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 6px; border-radius: 980px;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-xs);
  font-size: 0.875rem; font-weight: 500; transition: background .15s, border-color .15s;
}
.brand-chip:hover { background: var(--surface-2); border-color: var(--muted-2); }
.brand-chip__logo { width: 24px; height: 24px; border-radius: 7px; object-fit: cover; background: var(--canvas); display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; color: #fff; }
.brand-chip svg { width: 15px; height: 15px; color: var(--muted); }
.topbar__nav { display: flex; align-items: center; gap: 2px; margin-left: 4px; }
.topbar__nav a { padding: 8px 13px; border-radius: 980px; font-size: 0.9rem; font-weight: 450; color: var(--muted); transition: color .15s, background .15s; }
.topbar__nav a:hover { color: var(--ink); background: rgba(0,0,0,0.04); }
.topbar__nav a.is-active { color: var(--ink); background: rgba(0,0,0,0.06); font-weight: 500; }
.topbar__spacer { margin-left: auto; }

/* User menu */
.usermenu { position: relative; }
.usermenu__btn { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 980px; transition: background .15s; }
.usermenu__btn:hover { background: rgba(0,0,0,0.05); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; font-size: 0.8rem; font-weight: 600; }
.usermenu__pop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 8px; opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .15s var(--ease), transform .15s var(--ease), visibility .15s;
}
.usermenu.open .usermenu__pop { opacity: 1; visibility: visible; transform: translateY(0); }
.usermenu__head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.usermenu__head strong { display: block; font-size: 0.9rem; }
.usermenu__head span { font-size: 0.8rem; color: var(--muted); }
.usermenu__pop a, .usermenu__pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: 0.9rem; color: var(--ink-2); text-align: left; }
.usermenu__pop a:hover, .usermenu__pop button:hover { background: var(--canvas); color: var(--ink); }

/* --- Page layout ---------------------------------------------------------- */
.page { max-width: var(--maxw); margin: 0 auto; padding: 40px 24px 96px; }
.page--narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.75rem; }
.page-head .sub { color: var(--muted); font-size: 0.95rem; margin-top: 6px; }
.eyebrow { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); text-transform: none; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb svg { width: 14px; height: 14px; opacity: .6; }

/* --- Cards ---------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card--pad { padding: 24px; }
.card-grid { display: grid; gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 2rem; font-weight: 600; letter-spacing: -0.03em; }
.stat .l { color: var(--muted); font-size: 0.875rem; margin-top: 2px; }

/* --- Brand tiles ---------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 18px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 24px; box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-2); }
.tile__logo {
  width: 56px; height: 56px; border-radius: 15px; display: grid; place-items: center;
  color: #fff; font-size: 1.35rem; font-weight: 600; overflow: hidden; box-shadow: var(--shadow-xs);
}
.tile__logo img { width: 100%; height: 100%; object-fit: cover; }
.tile__name { font-size: 1.1rem; font-weight: 600; }
.tile__meta { color: var(--muted); font-size: 0.85rem; margin-top: 3px; }
.tile__go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 0.9rem; font-weight: 500; }
.tile__go svg { width: 16px; height: 16px; transition: transform .2s var(--ease); }
.tile:hover .tile__go svg { transform: translateX(3px); }

/* --- Lists / rows --------------------------------------------------------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px;
  border-bottom: 1px solid var(--line); transition: background .12s;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-2); }
.row__main { min-width: 0; flex: 1; }
.row__title { font-weight: 500; font-size: 0.95rem; }
.row__sub { color: var(--muted); font-size: 0.85rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.thumb { width: 40px; height: 40px; border-radius: 10px; background: var(--canvas); display: grid; place-items: center; color: var(--muted); flex-shrink: 0; }

/* Tables (admin) */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

/* --- Badges / chips ------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 980px; font-size: 0.75rem; font-weight: 500; }
.badge--muted { background: var(--canvas); color: var(--muted); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Sub navigation (admin) ---------------------------------------------- */
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.subnav a { padding: 10px 14px; font-size: 0.9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s; }
.subnav a:hover { color: var(--ink); }
.subnav a.is-active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }

/* --- Flash ---------------------------------------------------------------- */
.flash-stack { position: fixed; top: 74px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(520px, calc(100vw - 32px)); }
.flash {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  box-shadow: var(--shadow-lg); font-size: 0.9rem; animation: flash-in .3s var(--ease);
}
.flash svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.flash--success { border-left: 3px solid var(--ok); }
.flash--success svg { color: var(--ok); }
.flash--error { border-left: 3px solid var(--danger); }
.flash--error svg { color: var(--danger); }
.flash__close { margin-left: auto; color: var(--muted); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* --- Empty states --------------------------------------------------------- */
.empty { text-align: center; padding: 64px 24px; }
.empty__icon { width: 56px; height: 56px; border-radius: 16px; background: var(--canvas); display: grid; place-items: center; margin: 0 auto 18px; color: var(--muted-2); }
.empty__icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: 1.2rem; }
.empty p { color: var(--muted); margin: 8px auto 22px; max-width: 42ch; font-size: 0.95rem; }

/* --- Auth screens --------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(120% 80% at 50% -10%, #ffffff 0%, var(--canvas) 55%); }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 26px; }
.auth-logo img { height: 30px; }
.auth-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 34px 30px; }
.auth-box h1 { font-size: 1.4rem; text-align: center; }
.auth-box .lead { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 8px 0 26px; }
.auth-alt { text-align: center; margin-top: 20px; font-size: 0.9rem; color: var(--muted); }
.auth-alt a { color: var(--accent); font-weight: 500; }
.auth-foot { text-align: center; margin-top: 22px; font-size: 0.8rem; color: var(--muted-2); }

/* --- Modals (progressive, toggled by JS) ---------------------------------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,0.32); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 24px; opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s; }
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); transform: scale(0.96) translateY(8px); transition: transform .22s var(--ease); max-height: calc(100vh - 48px); overflow: auto; }
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal__head { padding: 24px 26px 0; }
.modal__head h2 { font-size: 1.25rem; }
.modal__head p { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }
.modal__body { padding: 22px 26px; }
.modal__foot { padding: 16px 26px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--surface); }

/* --- QR contact grid ------------------------------------------------------ */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); position: sticky; top: 72px; z-index: 20; }
.toolbar__count { font-size: 0.9rem; color: var(--muted); }
.toolbar__count strong { color: var(--ink); }
.toolbar__spacer { margin-left: auto; }
.toolbar .selected-only { display: none; }
.toolbar.has-selection .selected-only { display: inline-flex; }

.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.qr-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-sm); transition: box-shadow .2s, border-color .2s; display: flex; flex-direction: column; gap: 12px; }
.qr-card:hover { box-shadow: var(--shadow); }
.qr-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qr-card__check { position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.qr-card__check svg { width: 14px; height: 14px; color: #fff; opacity: 0; }
.qr-card.is-selected .qr-card__check { background: var(--accent); border-color: var(--accent); }
.qr-card.is-selected .qr-card__check svg { opacity: 1; }
.qr-canvas { aspect-ratio: 1; background: #fff; border-radius: var(--r); display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.qr-canvas svg, .qr-canvas canvas, .qr-canvas img { width: 100%; height: 100%; }
.qr-card__name { font-weight: 500; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-card__sub { color: var(--muted); font-size: 0.82rem; margin-top: -8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-card__dl { display: flex; gap: 8px; }
.qr-card__dl .btn { flex: 1; }

/* progress bar for zip building */
.progress { position: fixed; left: 0; top: 0; height: 3px; width: 0; background: var(--accent); z-index: 100; transition: width .2s var(--ease); }

/* --- Divider / misc ------------------------------------------------------- */
.divider { height: 1px; background: var(--line); margin: 24px 0; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 4px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 0.9em; }
.code-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--canvas); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; font-family: ui-monospace, monospace; font-size: 0.85rem; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 720px) {
  .topbar__nav { display: none; }
  .page { padding: 28px 18px 80px; }
  .page-head h1 { font-size: 1.45rem; }
  .toolbar { top: 66px; }
  .qr-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .table-wrap { overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
