/* ============================================================
   QR Tracker — design system
   Warm off-white canvas, one confident orange accent,
   generous spacing, soft shadows, gentle motion.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&family=Poppins:wght@500;600;700&display=swap');

:root {
  /* Canvas & surfaces */
  --bg:             #faf7f1;
  --surface:        #fffdf9;
  --surface-white:  #ffffff;

  /* Ink */
  --ink:            #2b2622;
  --ink-soft:       #6e655a;
  --ink-mute:       #a59c8f;

  /* Accent */
  --accent:         #e8590c;
  --accent-deep:    #c94a08;
  --accent-dark:    #a83e06;
  --accent-tint:    #fdeee3;
  --accent-wash:    #fbe9db;
  --accent-ring:    rgba(232, 89, 12, 0.22);

  /* Structure */
  --line:           #ebe3d6;
  --line-strong:    #ddd3c2;

  /* Feedback */
  --danger:         #bb3a2e;

  /* Elevation */
  --shadow-sm:      0 1px 2px rgba(75, 60, 40, 0.06);
  --shadow-md:      0 2px 6px rgba(75, 60, 40, 0.05), 0 10px 28px -14px rgba(75, 60, 40, 0.16);
  --shadow-lg:      0 4px 10px rgba(75, 60, 40, 0.06), 0 24px 48px -18px rgba(75, 60, 40, 0.22);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Poppins', 'Nunito', system-ui, sans-serif;

  --ease: cubic-bezier(0.33, 1, 0.68, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 480px at 50% -160px, #fdf1e5 0%, rgba(253, 241, 229, 0) 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a { color: inherit; }

.lucide { width: 18px; height: 18px; flex-shrink: 0; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 22px;
}

.hidden, [hidden] { display: none !important; }

/* ============================== Top bar ============================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 247, 241, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(235, 227, 214, 0.7);
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 3px 8px rgba(232, 89, 12, 0.35);
}

.brand-mark .lucide { width: 19px; height: 19px; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

/* ============================== Buttons ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease),
              background-color 0.2s var(--ease), border-color 0.2s var(--ease),
              color 0.2s var(--ease);
}

.btn:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
}

.btn:active { transform: translateY(1px) scale(0.99); }

.btn .lucide { width: 17px; height: 17px; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  box-shadow: 0 4px 14px -4px rgba(232, 89, 12, 0.55),
              inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgba(232, 89, 12, 0.6),
              inset 0 1px 0 rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, #ef6215 0%, var(--accent-deep) 100%);
}

.btn-outline {
  background: var(--surface-white);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-tint);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}

.btn-ghost:hover {
  background: var(--accent-tint);
  color: var(--accent-dark);
}

.btn-soft {
  background: var(--accent-tint);
  color: var(--accent-dark);
}

.btn-soft:hover {
  background: var(--accent-wash);
  transform: translateY(-1px);
}

.btn-wide { width: 100%; max-width: 320px; }

.btn-lg {
  height: 56px;
  font-size: 1.08rem;
  padding: 0 26px;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.75;
  cursor: progress;
  transform: none !important;
}

/* Spinner shown while the button is working */
.btn-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================== Hero + form ============================== */

.hero {
  text-align: center;
  padding: 64px 0 30px;
}

.hero-title {
  font-size: clamp(1.95rem, 5.2vw, 2.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-sub {
  max-width: 520px;
  margin: 16px auto 0;
  font-size: 1.07rem;
  color: var(--ink-soft);
}

.gen-form {
  display: flex;
  gap: 12px;
  max-width: 660px;
  margin: 34px auto 0;
}

.input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-mute);
  pointer-events: none;
  transition: color 0.2s var(--ease);
}

#destination_url {
  width: 100%;
  height: 56px;
  padding: 0 18px 0 46px;
  border: 1.5px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface-white);
  font-family: var(--font-body);
  font-size: 1.04rem;
  font-weight: 600;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

#destination_url::placeholder {
  color: var(--ink-mute);
  font-weight: 400;
}

#destination_url:hover { border-color: var(--accent); }

#destination_url:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

#destination_url:focus + .input-icon { color: var(--accent); }
.input-wrap:focus-within .input-icon { color: var(--accent); }

.field-error {
  max-width: 660px;
  margin: 14px auto 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: #fbeae7;
  border: 1px solid #f2cdc7;
  color: var(--danger);
  font-weight: 700;
  font-size: 0.96rem;
}

.hero-hint {
  margin-top: 18px;
  font-size: 0.92rem;
  color: var(--ink-mute);
}

/* ============================== Result card ============================== */

.result {
  margin-top: 42px;
  animation: rise-in 0.45s var(--ease);
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 26px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.qr-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.qr-frame {
  padding: 14px;
  background: var(--surface-white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

#qr-image {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  border-radius: 8px;
}

.tiny-note {
  margin: -4px 0 0;
  font-size: 0.82rem;
  color: var(--ink-mute);
}

.result-side {
  padding: 26px 4px 0;
}

.result-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 14px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.88rem;
}

.result-eyebrow .lucide { width: 15px; height: 15px; }

.result-heading {
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-mute);
  margin: 22px 0 8px;
}

.dest-display {
  margin: 0;
  padding: 12px 16px;
  background: var(--surface-white);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  font-weight: 700;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

/* ============================== Links list ============================== */

.links-section { margin: 58px 0 40px; }

.links-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.links-head h2 { font-size: 1.35rem; }

.links-count {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.84rem;
}

.table-card { overflow: hidden; }

.links-table {
  width: 100%;
  border-collapse: collapse;
}

.links-table th {
  padding: 13px 18px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-mute);
  border-bottom: 1px solid var(--line);
  background: rgba(253, 248, 240, 0.6);
}

.links-table td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 0.97rem;
  vertical-align: middle;
}

.links-table tbody tr:last-child td { border-bottom: none; }

.site-cell { min-width: 0; }

.site-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--ink);
}

.site-favicon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
}

.site-url {
  display: block;
  margin-top: 2px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
}

.num-col, .td-num { text-align: right; }

.td-num {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.scan-chip {
  display: inline-block;
  min-width: 34px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.88rem;
  text-align: center;
}

.scan-chip.zero {
  background: #f1ede6;
  color: var(--ink-mute);
}

.created-cell {
  white-space: nowrap;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
}

.reveal-col { width: 130px; text-align: right; }

.show-stats {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-deep);
  font-weight: 800;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
}

.show-stats .lucide { width: 16px; height: 16px; transition: transform 0.2s var(--ease); }

tr.row-link { cursor: pointer; transition: background-color 0.15s var(--ease); }

tr.row-link:hover,
tr.row-link:focus-visible {
  background: var(--accent-tint);
  outline: none;
}

tr.row-link:hover .show-stats,
tr.row-link:focus-visible .show-stats {
  opacity: 1;
  transform: translateX(0);
}

tr.row-link:hover .show-stats .lucide { transform: translateX(3px); }

tr.row-link:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 4px;
}

.empty-state {
  padding: 52px 24px;
  text-align: center;
  color: var(--ink-soft);
}

.empty-state p { margin: 0; font-size: 1rem; }

.empty-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
}

.empty-icon .lucide { width: 26px; height: 26px; }

/* ============================== How it works ============================== */

.how-it-works { margin: 58px 0 40px; }

.how-title { font-size: 1.35rem; margin-bottom: 14px; }

.how-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.how-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.how-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.how-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  border-radius: 13px;
  background: var(--accent-tint);
  color: var(--accent-deep);
}

.how-icon .lucide { width: 21px; height: 21px; }

.how-card h3 {
  font-size: 1rem;
  margin-bottom: 5px;
}

.how-card p {
  margin: 0;
  font-size: 0.93rem;
  color: var(--ink-soft);
}

/* ============================== Footer ============================== */

.footer {
  padding: 26px 0 40px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 0.88rem;
}

.footer p { margin: 0; }

/* ============================== Stats page ============================== */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 38px 0 22px;
  flex-wrap: wrap;
}

.page-title {
  font-size: clamp(1.6rem, 4.5vw, 2.15rem);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dest-line {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.97rem;
  overflow-wrap: anywhere;
}

.dest-line a {
  color: var(--accent-deep);
  text-decoration-color: rgba(232, 89, 12, 0.35);
  text-underline-offset: 3px;
}

.dest-line a:hover { color: var(--accent-dark); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-hero {
  background:
    radial-gradient(420px 200px at 12% 0%, rgba(232, 89, 12, 0.14), rgba(232, 89, 12, 0) 70%),
    var(--surface);
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.5rem;
  line-height: 1.1;
  color: var(--accent-deep);
  letter-spacing: -0.02em;
}

.stat-tile:not(.stat-hero) .stat-value { color: var(--ink); font-size: 1.9rem; }

.stat-value-sm { font-size: 1.35rem !important; line-height: 1.3 !important; padding-top: 8px; }

.stat-label {
  margin-top: 4px;
  font-size: 0.87rem;
  font-weight: 700;
  color: var(--ink-mute);
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}

.chart-panel { padding: 20px 22px; }

.chart-panel h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-range {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-mute);
}

.chart-wrap { position: relative; height: 270px; }

.chart-wrap-donut { height: 210px; }

.empty-note {
  margin: 0;
  padding: 30px 10px;
  text-align: center;
  color: var(--ink-mute);
  font-weight: 600;
}

.recent-card { padding: 20px 22px 8px; }

.recent-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.scans-table th { background: none; }

.when-cell { white-space: nowrap; color: var(--ink-soft); font-weight: 600; }

.device-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 800;
}

.device-pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.device-pill.mobile   { background: #fdeee3; color: #c2410c; }  /* slot 1 family */
.device-pill.desktop  { background: #fdeadd; color: #b5470b; }
.device-pill.tablet   { background: #e7f6f0; color: #0f7a55; }
.device-pill.unknown  { background: #f1efe9; color: #6e655a; }

.referrer-cell {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.referrer-cell span {
  display: inline-block;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* ============================== Notices / errors ============================== */

.notice-card {
  max-width: 470px;
  margin: 80px auto;
  padding: 44px 36px;
  text-align: center;
}

.notice-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
}

.notice-icon .lucide { width: 28px; height: 28px; }

.notice-card h1 { font-size: 1.45rem; margin-bottom: 10px; }

.notice-card p {
  margin: 0 auto 24px;
  color: var(--ink-soft);
  max-width: 330px;
}

.error-box {
  margin: 40px 0;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: #fbeae7;
  border: 1px solid #f2cdc7;
  color: var(--danger);
  font-weight: 700;
}

/* Centered standalone pages (friendly 404) */
body.page-center { display: grid; place-items: center; }
body.page-center main { width: 100%; padding: 24px; }
body.page-center .notice-card { margin: 0; }

/* ============================== Skeleton loader ============================== */

.skeleton-line {
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg, #f0eae0 40%, #faf6ef 50%, #f0eae0 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  margin-bottom: 14px;
}

.skeleton-title { height: 34px; width: 55%; margin-top: 38px; }
.skeleton-sub { height: 18px; width: 38%; }

.skeleton-tile { height: 96px; border: none; }

/* Skeleton rows for the "Your QR codes" table while the list loads */
.links-skeleton { padding: 6px 0; }

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}

.skeleton-row:last-child { border-bottom: none; }

.sk {
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg, #f0eae0 40%, #faf6ef 50%, #f0eae0 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

.sk-tile { width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px; }
.sk-lines { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 0; }
.sk-line { height: 11px; }
.sk-line.w30 { width: 30%; } .sk-line.w35 { width: 35%; }
.sk-line.w45 { width: 45%; } .sk-line.w50 { width: 50%; }
.sk-line.w55 { width: 55%; } .sk-line.w60 { width: 60%; }
.sk-chip { width: 46px; height: 24px; border-radius: 999px; flex-shrink: 0; }
.sk-date { width: 74px; height: 11px; margin-left: auto; flex-shrink: 0; }

@media (max-width: 620px) {
  /* Created column hides on phones — drop its placeholder too */
  .sk-date { display: none; }
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ============================== Responsive ============================== */

@media (max-width: 860px) {
  .chart-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .qr-card { max-width: 360px; margin: 0 auto; }
  .result-side { padding-top: 0; }
  .how-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .hero { padding-top: 44px; }

  .gen-form { flex-direction: column; }
  .btn-lg { width: 100%; }

  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-tile:first-child { grid-column: 1 / -1; }

  .links-table th:nth-child(3),
  .created-cell { display: none; }   /* created date hides on phones; site + scans stay */

  .links-table th, .links-table td { padding: 13px 14px; }

  .site-url { max-width: 150px; }
  .reveal-col { width: auto; }
  .show-stats { display: none; }     /* whole row is tappable on touch screens anyway */
}

/* ============================== Reduced motion ============================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
