/* QRWala Design System
 * ------------------------------------------
 * Editorial-modern Indian SaaS aesthetic.
 * Layered on top of Bootstrap 5.
 */

/* SELF-HOSTED FONTS — variable woff2 served from /static/fonts (same origin,
   one HTTP/2 connection, no Google Fonts two-hop, no third-party IP leak).
   unicode-range gates each subset so an English page only fetches `latin`;
   Devanagari downloads only if Hindi script actually renders. Paths are
   relative to this file (/static/css/) so they survive any context path. */
/* latin-ext */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 100%;
  font-display: swap;
  src: url(/qrwala/static/fonts/bricolage-grotesque-latin-ext-c4c7bb6a8d9bf486ff286d332f3c82f3.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 100%;
  font-display: swap;
  src: url(/qrwala/static/fonts/bricolage-grotesque-latin-ad33cbc6d23292050f1f2010848ab619.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/qrwala/static/fonts/jetbrains-mono-latin-ext-bd4781a31b4215a1e80868802b3d0e05.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/qrwala/static/fonts/jetbrains-mono-latin-b636a65da4f00129f08c7df6e5dd75ac.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* devanagari */
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: swap;
  src: url(/qrwala/static/fonts/noto-sans-devanagari-devanagari-266e3e271d4fb27a45865a8409e1b58e.woff2) format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}
/* latin-ext */
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: swap;
  src: url(/qrwala/static/fonts/noto-sans-devanagari-latin-ext-468bd6d6fa09c26d0c8b118ba0a328a6.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 400 700;
  font-stretch: 100%;
  font-display: swap;
  src: url(/qrwala/static/fonts/noto-sans-devanagari-latin-206b3179e9ea4a03bb53a26da8c95f1d.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/qrwala/static/fonts/plus-jakarta-sans-latin-ext-341687eeeb6afd29502e2277d9762c7e.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/qrwala/static/fonts/plus-jakarta-sans-latin-7660bd9909fb097989b19471a75f1b7a.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Core palette */
  --ink: #0E0F1A;
  --ink-soft: #1B1D2C;
  --ink-mute: #4A4D63;
  --ink-light: #8A8DA3;
  --line: #E7E1D3;
  --line-soft: #EFEAD9;
  --cream: #FAF6EE;
  --cream-deep: #F2EDDF;
  --paper: #FFFFFF;
  --clay: #E8DCC4;

  /* Brand accents */
  --saffron: #FF6A2B;       /* primary CTA */
  --saffron-deep: #E8551A;
  --saffron-soft: #FFE3D2;
  --peacock: #1F4E8C;       /* secondary */
  --peacock-soft: #DCE7F4;
  --lime: #D6F25E;          /* highlight */
  --lime-deep: #B8D43C;
  --plum: #4A1E5C;
  --rose: #E84B7B;

  /* Status */
  --good: #1B7A4E;
  --warn: #B86E00;
  --bad: #B5283C;

  /* Type */
  --f-display: 'Bricolage Grotesque', 'Plus Jakarta Sans', sans-serif;
  --f-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, monospace;
  --f-deva: 'Noto Sans Devanagari', sans-serif;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 32px;

  /* Shadow */
  --sh-sm: 0 1px 0 rgba(14,15,26,.04), 0 1px 2px rgba(14,15,26,.04);
  --sh-md: 0 2px 0 rgba(14,15,26,.04), 0 8px 24px -8px rgba(14,15,26,.12);
  --sh-lg: 0 30px 60px -20px rgba(14,15,26,.25);
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

html, body {
  font-family: var(--f-sans);
  color: var(--ink);
  background: var(--cream);
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
  /* Hard guarantee: no horizontal page scroll on any viewport. Individual
     wide elements (tables, code blocks) handle their own internal scroll.
     `overflow-x: clip` suppresses scroll WITHOUT making body a scroll
     container — `overflow-x: hidden` (the previous setting) silently
     promoted body to a scroll container, which breaks `position: sticky`
     anywhere in the page (e.g. the live preview on /create). `clip` is
     supported in Chrome 90+, Firefox 81+, Safari 16+ — fine for modern
     browsers. We keep `hidden` as a fallback so older browsers still
     suppress horizontal scroll. */
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100vw;
}
img, svg, video, canvas { max-width: 100%; height: auto; }

/* Typography overrides */
.f-display { font-family: var(--f-display); letter-spacing: -0.035em; line-height: 0.96; font-weight: 600; }
.f-mono { font-family: var(--f-mono); letter-spacing: -0.01em; }
.f-deva { font-family: var(--f-deva); }

h1, h2, h3, h4 { font-family: var(--f-display); letter-spacing: -0.03em; }
h1 { font-weight: 600; }

.eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
}

/* Logo */
.qw-logo {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
}
.qw-logo:hover { color: var(--ink); }
.qw-logo-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--ink);
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.qw-logo-mark::before, .qw-logo-mark::after {
  content: ""; position: absolute;
  width: 8px; height: 8px;
  background: var(--cream);
  border-radius: 2px;
}
.qw-logo-mark::before { top: 5px; left: 5px; box-shadow: 0 12px 0 var(--cream); }
.qw-logo-mark::after  { top: 5px; right: 5px; background: var(--saffron); }

/* Buttons */
.btn { font-family: var(--f-sans); font-weight: 600; letter-spacing: -0.005em; border-radius: 999px; padding: 10px 20px; transition: transform .15s ease, background .2s; }
.btn:active { transform: translateY(1px); }
.btn-ink { background: var(--ink); color: var(--cream); }
.btn-ink:hover { background: var(--ink-soft); color: var(--cream); }
.btn-saffron { background: var(--saffron); color: #fff; }
.btn-saffron:hover { background: var(--saffron-deep); color: #fff; }
.btn-cream { background: var(--cream-deep); color: var(--ink); border: 1px solid var(--line); }
.btn-cream:hover { background: var(--clay); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--cream-deep); color: var(--ink); }
.btn-outline-ink { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn-outline-ink:hover { background: var(--ink); color: var(--cream); }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* Cards */
.qw-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.qw-card-cream { background: var(--cream-deep); border: 1px solid var(--line); border-radius: var(--r-lg); }
.qw-card-ink { background: var(--ink); color: var(--cream); border-radius: var(--r-lg); }

/* Pills */
.qw-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  background: var(--cream-deep);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}
.qw-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--saffron); }
.qw-pill.success { background: #E5F2EB; border-color: #BFDDC9; color: var(--good); }
.qw-pill.success .qw-pill-dot { background: var(--good); }
.qw-pill.warn { background: #FAEFD9; border-color: #E8D5A8; color: var(--warn); }
.qw-pill.warn .qw-pill-dot { background: var(--warn); }

/* Form */
.form-control, .form-select {
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  padding: 12px 14px;
  font-size: 15px;
  background: var(--paper);
  color: var(--ink);
}
.form-control:focus, .form-select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(14,15,26,.08);
}
/* Invalid-state ring: 2px red border + soft red glow on focus. Mirrors
   Bootstrap's .is-invalid look but uses our own --bad token so it matches
   the palette. The :focus override keeps the red even when focused, so a
   user who clicks back into the offending input still sees they're wrong. */
.form-control.is-invalid, .form-select.is-invalid, textarea.is-invalid {
  border-color: var(--bad);
  background-color: #FDF6F7;
}
.form-control.is-invalid:focus, .form-select.is-invalid:focus, textarea.is-invalid:focus {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px rgba(193,40,57,.15);
}
.field-error {
  display: block;
  color: var(--bad);
  font-size: 12.5px;
  margin-top: 4px;
  font-weight: 500;
}
.field-error::before {
  content: "⚠ ";
  font-size: 12px;
}
/* A top-of-form "this field is wrong" banner used by GlobalErrorAdvice's
   ?error= fallback path on pages that haven't been fragment-wired yet.
   Lets every form template benefit even without per-input changes. */
.form-error-banner {
  background: #FCEAED;
  border: 1px solid #E8B6BE;
  border-left: 4px solid var(--bad);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--bad);
}
.form-error-banner i { margin-right: 6px; }
.form-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-soft);
}

/* Topnav (marketing) */
.qw-nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(20px) saturate(1.2);
  background: rgba(250,246,238,.78);
  border-bottom: 1px solid var(--line);
}
.qw-nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0;
}
.qw-nav-links { display: flex; gap: 28px; align-items: center; }
.qw-nav-links a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
}
.qw-nav-links a:hover { color: var(--ink); }

/* Marketing mobile menu — hamburger + dropdown shown below the lg breakpoint,
   where the inline .qw-nav-links row is hidden (d-none d-lg-flex). */
.qw-nav-toggle {
  background: none; border: none; color: var(--ink);
  font-size: 20px; line-height: 1; padding: 6px 8px; cursor: pointer;
}
.qw-nav-mobile {
  display: none; flex-direction: column;
  padding: 4px 0 12px; border-top: 1px solid var(--line);
}
.qw-nav-mobile.open { display: flex; }
.qw-nav-mobile a {
  color: var(--ink-soft); text-decoration: none;
  font-size: 16px; font-weight: 500; padding: 13px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.qw-nav-mobile a:last-child { border-bottom: none; }

/* Footer */
.qw-footer {
  background: var(--ink);
  color: var(--cream);
  padding: 70px 0 30px;
}
.qw-footer a { color: rgba(250,246,238,.7); text-decoration: none; }
.qw-footer a:hover { color: var(--cream); }
.qw-footer-col h6 {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(250,246,238,.5);
  margin-bottom: 16px;
}
.qw-footer-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }

/* Marquee */
.qw-marquee {
  overflow: hidden;
  border-block: 1px solid var(--line);
  background: var(--cream);
}
.qw-marquee-track {
  display: flex; gap: 60px;
  animation: qw-scroll 40s linear infinite;
  padding: 18px 0;
  font-family: var(--f-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  white-space: nowrap;
}
@keyframes qw-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Jaali pattern (Indian latticework) */
.qw-jaali {
  background-image: 
    radial-gradient(circle at 50% 50%, var(--clay) 1px, transparent 1.5px),
    radial-gradient(circle at 0 0, var(--clay) 1px, transparent 1.5px),
    radial-gradient(circle at 100% 100%, var(--clay) 1px, transparent 1.5px);
  background-size: 18px 18px;
}

/* QR code visual placeholder */
.qw-qr {
  display: grid;
  grid-template-columns: repeat(21, 1fr);
  grid-template-rows: repeat(21, 1fr);
  gap: 0;
  background: #fff;
  padding: 8%;
  border-radius: 8%;
  aspect-ratio: 1;
  width: 100%;
}
.qw-qr i { background: var(--ink); border-radius: 1px; }
.qw-qr i.b { background: transparent; }

/* Inline QR thumbnails on list pages (rendered server-side, no per-row request). */
.qr-inline { display: inline-block; line-height: 0; box-sizing: border-box; }
.qr-inline svg { width: 100%; height: 100%; display: block; }

/* Sidebar (app shell) */
.qw-app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  background: var(--cream);
}
.qw-side {
  background: var(--ink);
  color: var(--cream);
  padding: 22px 18px;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.qw-side .qw-logo { color: var(--cream); }
.qw-side-section {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(250,246,238,.45);
  margin: 26px 12px 8px;
}
.qw-side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: rgba(250,246,238,.8);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
}
.qw-side-link:hover { background: rgba(255,255,255,.06); color: var(--cream); }
.qw-side-link.active { background: var(--cream); color: var(--ink); }
.qw-side-link i { width: 18px; text-align: center; font-size: 14px; }

.qw-main {
  padding: 24px 32px 60px;
  max-width: 1400px;
  width: 100%;
}
.qw-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}

/* Stat tile */
.qw-stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
}
.qw-stat .lbl { font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
.qw-stat .val { font-family: var(--f-display); font-size: 36px; font-weight: 600; letter-spacing: -0.04em; margin-top: 6px; }

/* DataTable styling */
.qw-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.qw-table thead th {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: var(--cream-deep);
}
.qw-table tbody td {
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14.5px;
  vertical-align: middle;
}
.qw-table tbody tr:hover { background: var(--cream); }

/* Misc */
.divider { height: 1px; background: var(--line); margin: 24px 0; }
.text-mute { color: var(--ink-mute); }
.text-saffron { color: var(--saffron); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--clay); }

/* ========================================================
 * Mobile list-card primitive
 * Used on mobile/tablet to replace wide tables. Renders one
 * row per stacked card with the row's primary identifier on
 * top, secondary metadata as pills, and actions on the right.
 * ======================================================== */
.qw-list { display: flex; flex-direction: column; gap: 10px; }
.qw-list-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--sh-sm);
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-column-gap: 12px;
  align-items: start;
}
.qw-list-card.no-thumb { grid-template-columns: 1fr auto; }
.qw-list-card .lc-thumb {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--cream-deep);
  flex-shrink: 0;
}
.qw-list-card .lc-thumb .qw-qr { width: 36px !important; height: 36px !important; }
.qw-list-card .lc-body { min-width: 0; }
.qw-list-card .lc-title {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qw-list-card .lc-sub {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qw-list-card .lc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-mute);
  align-items: center;
}
.qw-list-card .lc-meta .qw-pill { font-size: 11px; padding: 3px 8px; }
.qw-list-card .lc-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.qw-list-card .lc-actions .btn-sm { padding: 6px 9px; min-width: 32px; }
.qw-list-empty {
  background: var(--cream-deep);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 14px;
}

/* ========================================================
 * Responsive — tablet (≤991px), phone (≤575px)
 * ======================================================== */

/* Hamburger toggle (hidden on desktop, shown on tablet/phone) */
.qw-menu-toggle {
  display: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  transition: background .15s;
}
.qw-menu-toggle:hover { background: var(--cream-deep); }
.qw-menu-toggle i { font-size: 16px; color: var(--ink); }

/* Make the topbar use a flex layout with a clear left/right split */
.qw-topbar { gap: 12px; flex-wrap: wrap; }
.qw-topbar > .qw-topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.qw-topbar > .qw-topbar-left > div { min-width: 0; }
.qw-topbar h1 { font-size: clamp(22px, 5vw, 38px) !important; line-height: 1.05 !important; word-wrap: break-word; }

/* Tablet + phone */
@media (max-width: 991px) {
  /* App shell becomes a single column; sidebar becomes a slide-in drawer */
  .qw-app { grid-template-columns: 1fr; }
  /* CRITICAL: min-width: 0 lets the grid item shrink below its content width.
     Without this, a wide table inside qw-main forces qw-main to grow and the
     entire page becomes horizontally scrollable. */
  /* `overflow-x: clip` (with `hidden` fallback) prevents horizontal scroll
     without breaking `position: sticky` for descendants. */
  .qw-main { padding: 16px 14px 60px; max-width: 100vw; min-width: 0; width: 100%; overflow-x: hidden; overflow-x: clip; }

  .qw-side {
    display: block;
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    max-width: 84vw;
    height: 100vh;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 60px rgba(0,0,0,.35);
  }
  .qw-side.open { transform: translateX(0); }

  body.qw-drawer-open::before {
    content: '';
    position: fixed; inset: 0;
    background: rgba(14,15,26,.55);
    backdrop-filter: blur(2px);
    z-index: 1099;
    animation: qw-fade-in .15s ease;
  }
  @keyframes qw-fade-in { from { opacity: 0 } to { opacity: 1 } }

  .qw-menu-toggle { display: inline-flex; }

  /* Tables: keep them at natural width but make their containing card the
     horizontal-scroll viewport. Wrapping in <div class="table-responsive">
     gives the same effect; this catches templates that don't use it. */
  .qw-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .qw-card > .qw-table,
  .qw-card > table.qw-table,
  .qw-card > .compare-table {
    display: table;
    width: max-content;
    min-width: 100%;
    white-space: nowrap;
  }
  .qw-card .qw-table th,
  .qw-card .qw-table td { white-space: nowrap; }

  /* DataTables: the wrapper itself scrolls so the page doesn't grow */
  .dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .dataTables_wrapper table.dataTable {
    width: max-content !important;
    min-width: 100%;
  }

  /* DataTables' top filter row stacks */
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_length {
    float: none !important;
    text-align: left !important;
    margin-bottom: 8px;
  }
  .dataTables_wrapper .dataTables_filter input { width: 100% !important; }
  .dataTables_wrapper .dataTables_paginate { float: none !important; text-align: center; padding-top: 8px; }
  .dataTables_wrapper .dataTables_info { float: none !important; text-align: center; }

  /* Bootstrap-style table-responsive wrapper (in case some templates use it) */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Marketing hero floaters use absolute negative offsets — hide off-canvas
     decorations on small screens to prevent body width from blowing up. */
  .float-1, .float-2, .float-3, .floater,
  .hero-floater, .marketing-floater { display: none !important; }

  /* Any element with a fixed pixel width that exceeds viewport — clamp it */
  .qw-card, .qw-card-cream, .qw-card-ink, .signin-card, .auth-form { max-width: 100%; }

  /* Bootstrap grid utility: ensure rows wrap as columns */
  .qw-card { padding: 16px !important; }
  .qw-card.p-4 { padding: 16px !important; }

  /* Marketing nav: collapse the link row underneath the brand */
  .qw-nav-inner { flex-wrap: wrap; row-gap: 8px; }
  .qw-nav-links { gap: 16px !important; }

  /* Footer columns stack */
  .qw-footer { padding: 50px 0 24px; }

  /* Topbar avatar: hide the second-line phone number to save room */
  .qw-topbar .d-md-block { display: none !important; }
  .qw-topbar > .d-flex.gap-2 .ms-2 { padding: 4px !important; }
  .qw-topbar > .d-flex.gap-2 i.fa-chevron-down { display: none !important; }

  /* Avatar/notif/cmd-K dropdowns become full-width sheets */
  .qw-pop {
    right: 8px !important;
    left: 8px !important;
    top: 60px !important;
    min-width: auto !important;
    max-width: calc(100vw - 16px) !important;
  }

  /* Custom 2-column editor grids stack */
  .designer, .detail-grid, .lp-grid { grid-template-columns: 1fr !important; }

  /* Form-builder: palette + canvas + preview all stack */
  .fb-grid { grid-template-columns: 1fr !important; }
  .fb-grid > div:nth-child(1) { order: 1; }   /* palette */
  .fb-grid > div:nth-child(2) { order: 3; }   /* canvas */
  .fb-grid > div:nth-child(3) { order: 2; }   /* preview between */
  .fld-palette { display: grid !important; grid-template-columns: repeat(3, 1fr) !important; }
  .fld-palette .pal { font-size: 11.5px !important; padding: 8px !important; }

  /* Step rows on the marketing landing page collapse */
  .step-row { grid-template-columns: 1fr !important; gap: 14px !important; padding: 24px 0 !important; }

  /* Welcome card on dashboard already collapses at 768; reinforce */
  .welcome { grid-template-columns: 1fr !important; padding: 22px !important; }
  .welcome h2 { font-size: 26px !important; }
  .welcome .qw-qr { max-width: 140px; margin: 0 auto; }

  /* Stat tiles get smaller numbers */
  .qw-stat .val { font-size: 28px !important; }

  /* Settings tab nav becomes horizontally scrollable */
  #setNav { display: flex; overflow-x: auto; gap: 4px; padding: 4px !important; }
  #setNav .qw-side-link { white-space: nowrap; padding: 8px 10px !important; }

  /* Settings rows: on desktop the layout is description-left / input-right via
     `.set-row { display: flex; }`. On mobile that pinches the input column to a
     sliver. Stack vertically and let any inline `style="width: 280px"` (used to
     keep the input from filling the desktop column) expand to the row width. */
  .set-row { flex-direction: column !important; gap: 10px !important; padding: 16px 0 !important; }
  .set-row > div { width: 100% !important; }
  .set-row input.form-control,
  .set-row select.form-select,
  .set-row textarea.form-control { width: 100% !important; max-width: 100% !important; }
  .set-row .d-flex.gap-2 { flex-wrap: wrap; }

  /* QR detail: stat row tiles fit two-up */
  .qr-hero { padding: 18px !important; }

  /* Onboarding step rows: smaller numbers */
  .step .num { width: 40px; height: 40px; font-size: 16px; }

  /* Preview frame inside create page: smaller QR preview */
  .preview-frame { padding: 22px; }

  /* Live strip on dashboard wraps nicely */
  .live-strip { flex-wrap: wrap; gap: 6px !important; }

  /* Bigger touch targets on cream/saffron buttons in the topbar */
  .qw-topbar .btn-sm { min-height: 38px; min-width: 38px; }
}

/* Phone-only tightening */
@media (max-width: 575px) {
  /* Hide marketing nav links — collapse to brand + CTA */
  .qw-nav-links { display: none !important; }

  /* Buttons on auth screens take full width */
  .signin-card {
    /* The grid place-items:center on .signin-shell lets the card grow to its
       intrinsic max-width (440px) instead of clamping to the parent. Force a
       hard width cap on phones. */
    padding: 22px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .signin-shell {
    padding: 12px !important;
    /* Switch to flex so width: 100% on the child actually means parent width. */
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
  .auth-form-col { padding: 16px !important; }
  .auth-form { padding: 0 !important; max-width: 100% !important; width: 100% !important; }

  /* OTP inputs shrink so 6 boxes + gaps fit a 360–390px viewport */
  .otp-input { gap: 6px !important; }
  .otp-input input {
    width: auto !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 52px !important;
    font-size: 22px !important;
    padding: 0 !important;
  }

  /* Phone-wrap: keep on one line, allow input to shrink */
  .phone-wrap input { font-size: 16px !important; padding: 11px 10px !important; min-width: 0 !important; }
  .phone-wrap .cc { padding: 11px 10px !important; font-size: 13px !important; }

  /* Auth card heading scales down */
  .signin-card h2 { font-size: 26px !important; }

  /* Footer text shrinks */
  .qw-footer-col h6 { font-size: 10px !important; }

  /* Pricing cards stack tightly */
  .pricing-card { padding: 22px !important; }

  /* Use-cases / showcase grid go single column */
  .style-grid, .type-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* QR-detail stats from 4 cols → 2 cols already via Bootstrap col-6, OK */
  .qw-stat { padding: 12px !important; }
  .qw-stat .val { font-size: 22px !important; }
  .qw-stat .lbl { font-size: 10.5px !important; }

  /* Dashboard quick-tiles: pack 4 tiles + 4 stats above the fold on phones.
     The default 18px padding + 42px icon + larger text was eating 110px/tile
     so only the first row was visible before scrolling. Tighten radically. */
  .quick-tile { padding: 12px !important; gap: 10px !important; }
  .quick-tile .icn { width: 34px !important; height: 34px !important; font-size: 14px !important; }
  .quick-tile h6 { font-size: 13.5px !important; line-height: 1.2 !important; }
  .quick-tile small { font-size: 11px !important; }
  /* Tighter row gap so two rows of tiles + two rows of stats are within
     scroll-reach instead of pushed below the fold. */
  .row.g-3 { --bs-gutter-y: 0.5rem !important; --bs-gutter-x: 0.5rem !important; }

  /* Topbar h1 even smaller */
  .qw-topbar h1 { font-size: 20px !important; }

  /* Landing-pages catalog: ensure the small tile previews fit two-up */
  .tpl-prev { padding: 8px !important; }
}

/* Make all interactive elements have a sane minimum tap target */
@media (hover: none) and (pointer: coarse) {
  .btn, .qw-side-link, .qw-menu-item, .qw-pill {
    min-height: 40px;
  }
  .swatch { width: 36px; height: 36px; }
}
