/* ============================================================
   ConnectMeQR dashboard — design system
   Identity drawn from the QR matrix: finder-pattern logo,
   module-grid texture, restrained scan-line motion.
   ============================================================ */

:root {
  --paper: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --ink: #11182a;
  --muted: #5b6478;
  --faint: #8a93a6;
  --brand: #2f4bd1;
  --brand-700: #243aa6;
  --brand-50: #eef1ff;
  --accent: #12b8a6;
  --accent-50: #e4f7f4;
  --warn: #e5533c;
  --warn-50: #fdecea;
  --line: #e2e7f1;
  --line-strong: #d2d9e8;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 42, 0.05);
  --shadow: 0 1px 2px rgba(17, 24, 42, 0.04), 0 10px 30px rgba(17, 24, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(17, 24, 42, 0.18);

  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: var(--font-mono); }

/* ---- scan-line motif (used once, on auth + load) ---------------------- */
@keyframes scan-sweep {
  0% { transform: translateY(-120%); opacity: 0; }
  15% { opacity: 0.9; }
  85% { opacity: 0.9; }
  100% { transform: translateY(120%); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* =========================== AUTH ============================ */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth__brandside {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 12% 0%, #34539e 0%, #1f3585 45%, #16265f 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
/* faint module grid */
.auth__brandside::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(110% 80% at 30% 20%, #000 35%, transparent 80%);
}
.auth__brandside > * { position: relative; }
.auth__pitch h2 { font-size: 38px; line-height: 1.08; max-width: 11ch; }
.auth__pitch p { color: rgba(255,255,255,0.72); max-width: 36ch; margin-top: 16px; }
.auth__hero {
  align-self: center;
  position: relative;
  width: 220px; height: 220px;
  border-radius: 22px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  display: grid; place-items: center;
  overflow: hidden;
}
.auth__hero svg { width: 140px; height: 140px; }
.auth__hero::after {
  content: "";
  position: absolute; left: 0; right: 0; height: 40%;
  background: linear-gradient(180deg, transparent, rgba(18,184,166,0.35), transparent);
  animation: scan-sweep 3.4s ease-in-out infinite;
}
.auth__formside {
  display: grid; place-items: center; padding: 40px;
}
.auth__card { width: 100%; max-width: 380px; }
.auth__card h1 { font-size: 26px; }
.auth__card .sub { color: var(--muted); margin: 6px 0 28px; }
.auth__switch { margin-top: 22px; color: var(--muted); font-size: 14px; }
.auth__switch button {
  background: none; border: none; color: var(--brand); font-weight: 600; padding: 0;
}
.brandmark { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; }
.brandmark svg { width: 26px; height: 26px; }
.brandmark .tld { color: var(--faint); font-weight: 500; }

/* =========================== APP SHELL ====================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand { padding: 6px 8px 22px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav__item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; border: none; background: none;
  text-align: left; width: 100%; font-size: 14.5px;
}
.nav__item svg { width: 18px; height: 18px; stroke: currentColor; }
.nav__item:hover { background: var(--surface-2); color: var(--ink); }
.nav__item.is-active { background: var(--brand-50); color: var(--brand-700); }
.nav__item.is-active svg { stroke: var(--brand); }
.sidebar__foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.who { padding: 4px 8px; }
.who__name { font-weight: 600; font-size: 14px; }
.who__tenant { color: var(--faint); font-size: 12.5px; }
.who__tenant .mono { font-size: 12px; }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px; gap: 16px; flex-wrap: wrap;
}
.topbar h1 { font-size: 22px; }
.topbar .eyebrow { color: var(--faint); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
.content { padding: 4px 32px 56px; }

/* =========================== BUTTONS ======================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 15px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-700); }
.btn--ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--subtle { background: var(--surface-2); color: var(--ink); }
.btn--subtle:hover { background: var(--line); }
.btn--danger { background: var(--surface); border-color: var(--line-strong); color: var(--warn); }
.btn--danger:hover { background: var(--warn-50); border-color: var(--warn); }
.btn--sm { padding: 6px 11px; font-size: 13px; border-radius: var(--radius-xs); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* =========================== FORMS ========================== */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field .hint { color: var(--faint); font-size: 12.5px; margin-top: 5px; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font-size: 14px; background: var(--surface);
  color: var(--ink); font-family: inherit;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50);
}
.input::placeholder { color: var(--faint); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { border: none; background: none; padding: 7px 13px; border-radius: var(--radius-xs); font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.is-active { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-sm); }

.colorpick { display: flex; align-items: center; gap: 10px; }
.colorpick input[type=color] { width: 42px; height: 38px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-xs); background: none; }
.colorpick .input { flex: 1; }

/* =========================== CARDS ========================== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.grid { display: grid; gap: 16px; }

/* metrics */
.metrics { grid-template-columns: repeat(3, 1fr); }
.metric { padding: 18px 20px; }
.metric .k { color: var(--faint); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.metric .v { font-family: var(--font-mono); font-size: 30px; font-weight: 700; margin-top: 8px; letter-spacing: -0.02em; }
.metric .v small { font-size: 14px; color: var(--faint); font-weight: 400; }
.metric.is-accent .v { color: var(--accent); }

/* chart */
.panel { padding: 20px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel__head h3 { font-size: 15px; }
.chart { width: 100%; height: 200px; display: block; }
.chart .bar { fill: var(--brand); }
.chart .bar:hover { fill: var(--brand-700); }
.chart .axis { fill: var(--faint); font-size: 10px; font-family: var(--font-mono); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }

/* lists */
.list { display: flex; flex-direction: column; }
.list__row { display: flex; align-items: center; gap: 14px; padding: 13px 6px; border-bottom: 1px solid var(--line); }
.list__row:last-child { border-bottom: none; }
.rank { font-family: var(--font-mono); color: var(--faint); width: 22px; font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-family: var(--font-mono); font-weight: 700; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; letter-spacing: 0.02em; }
.badge--dynamic { background: var(--brand-50); color: var(--brand-700); }
.badge--static { background: var(--surface-2); color: var(--muted); }
.badge--default { background: var(--accent-50); color: #0a7d6f; }
.badge--off { background: var(--warn-50); color: var(--warn); }

/* =========================== QR / THEME CARDS =============== */
.cards-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.qrcard { display: flex; flex-direction: column; overflow: hidden; }
.qrcard__thumb { aspect-ratio: 1; background: var(--surface-2); display: grid; place-items: center; border-bottom: 1px solid var(--line); padding: 18px; }
.qrcard__thumb svg, .qrcard__thumb img { width: 100%; height: 100%; max-width: 180px; max-height: 180px; }
.qrcard__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.qrcard__title { font-family: var(--font-display); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qrcard__meta { color: var(--muted); font-size: 13px; }
.linkrow { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 6px 8px; }
.linkrow .mono { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.iconbtn { background: none; border: none; padding: 5px; border-radius: 6px; color: var(--muted); display: inline-grid; place-items: center; }
.iconbtn:hover { background: var(--line); color: var(--ink); }
.iconbtn svg { width: 16px; height: 16px; stroke: currentColor; }
.qrcard__actions { display: flex; gap: 6px; padding: 0 16px 14px; flex-wrap: wrap; }

.swatches { display: flex; gap: 5px; }
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,.08); }

/* =========================== DRAWER / BUILDER ============== */
.scrim { position: fixed; inset: 0; background: rgba(17,24,42,0.42); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(880px, 100%); background: var(--paper);
  box-shadow: var(--shadow-lg); display: grid; grid-template-rows: auto 1fr;
  animation: drawer-in .22s ease;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer__head h2 { font-size: 18px; }
.drawer__body { display: grid; grid-template-columns: 1fr 320px; gap: 0; overflow: hidden; }
.builder__form { padding: 24px; overflow-y: auto; }
.builder__preview {
  border-left: 1px solid var(--line); background: var(--surface);
  padding: 24px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}
.preview-stage {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  aspect-ratio: 1; display: grid; place-items: center; padding: 22px;
}
.preview-stage img, .preview-stage svg { width: 100%; height: 100%; max-width: 240px; max-height: 240px; }
.preview-note { color: var(--faint); font-size: 12.5px; text-align: center; }
.drawer__foot { grid-column: 1 / -1; }

/* =========================== STATES ========================= */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty__art { width: 84px; height: 84px; margin: 0 auto 18px; opacity: .9; }
.empty h3 { font-size: 18px; color: var(--ink); margin-bottom: 6px; }
.loading { display: grid; place-items: center; padding: 60px; color: var(--faint); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 700; margin: 28px 0 12px; font-family: var(--font-body); }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--warn); }

.chips { display: inline-flex; gap: 6px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

.devicebar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; display: flex; }
.devicebar > span { height: 100%; }

/* =========================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__brandside { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto; flex-direction: row; align-items: center;
    padding: 12px 16px; z-index: 30;
  }
  .sidebar__brand { padding: 0; }
  .nav { flex-direction: row; margin-left: auto; gap: 2px; }
  .nav__item span { display: none; }
  .sidebar__foot { display: none; }
  .metrics { grid-template-columns: 1fr; }
  .drawer__body { grid-template-columns: 1fr; }
  .builder__preview { border-left: none; border-top: 1px solid var(--line); }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
}

/* ============================================================
   PUBLIC HOMEPAGE (index.html)
   ============================================================ */
.home-body { background: var(--paper); }

.site-nav {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 20px 24px;
}
.site-nav .brandmark { text-decoration: none; color: var(--ink); font-size: 17px; }
.site-nav .brandmark svg { width: 28px; height: 28px; }
.site-nav__links { display: flex; gap: 10px; align-items: center; }
.btn[href] { text-decoration: none; }

.home { max-width: 1100px; margin: 0 auto; padding: 0 24px 64px; }

/* hero */
.hero {
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 48px; align-items: center;
  padding: 36px 0 56px;
}
.hero__copy .eyebrow {
  display: inline-block; color: var(--brand); font-size: 12px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 16px;
}
.hero__copy h1 {
  font-size: clamp(38px, 6vw, 60px); line-height: 1.02; letter-spacing: -0.025em;
}
.hero .lede { color: var(--muted); font-size: 18px; max-width: 42ch; margin: 20px 0 28px; }
.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero__cta .btn { padding: 12px 20px; }

/* generator */
.generator { padding: 22px; }
.generator__opts { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.generator__optlabel { font-size: 13px; font-weight: 600; color: var(--muted); }
.generator__stage {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  aspect-ratio: 1; display: grid; place-items: center; padding: 26px; margin-bottom: 16px;
}
.generator__stage img { width: 100%; height: 100%; max-width: 280px; max-height: 280px; }
.generator__stage.is-empty img { display: none; }
.generator__stage.is-empty::after {
  content: "Type a link above"; color: var(--faint); font-size: 14px;
}
.generator__actions { display: flex; gap: 10px; }
.generator__actions .btn { flex: 1; }
.generator__note { color: var(--faint); font-size: 12.5px; text-align: center; margin: 12px 0 0; }

/* tiers */
.tiers { padding: 24px 0 0; }
.tiers__head { text-align: center; max-width: 56ch; margin: 0 auto 28px; }
.tiers__head h2 { font-size: clamp(26px, 4vw, 34px); letter-spacing: -0.02em; }
.tiers__head p { color: var(--muted); margin-top: 12px; font-size: 16px; }
.tiers__grid { grid-template-columns: 1fr 1fr; max-width: 860px; margin: 0 auto; align-items: start; }
.tier { padding: 26px; }
.tier--pro { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.tier__name { font-family: var(--font-display); font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.tier__price { color: var(--muted); font-size: 14px; margin: 4px 0 18px; }
.tier__list { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-direction: column; gap: 11px; }
.tier__list li { position: relative; padding-left: 28px; font-size: 14.5px; line-height: 1.4; }
.tier__list li::before {
  position: absolute; left: 0; top: -1px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.tier__list li.yes::before { content: "✓"; background: var(--accent-50); color: #0a7d6f; }
.tier__list li.no::before { content: "×"; background: var(--surface-2); color: var(--faint); }
.tier__list li.no { color: var(--muted); }

.site-foot {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line); margin-top: 56px; padding-top: 22px;
  color: var(--faint); font-size: 14px;
}
.site-foot a { color: var(--muted); text-decoration: none; font-weight: 600; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 28px; padding-bottom: 36px; }
  .tiers__grid { grid-template-columns: 1fr; }
}
