/*
 * Dashboard layout and components. Builds on qrme/css/base.css tokens;
 * never hard-code colours here.
 */

/* Shell ------------------------------------------------------------------------ */
.shell { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
.sidebar {
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-4); background: var(--surface); border-inline-end: 1px solid var(--border);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }

/* Sheet: the one bottom sheet and side drawer (plan 6.4). Below 1024 px, with JavaScript, a .sheet
   leaves the page and slides in over the shared scrim; app.js traps the focus while it is open (the
   rest of the page is inert) and keeps a closed sheet inert (UX-N06). On wide screens, and without
   JavaScript, a sheet is an ordinary part of the page. .sheet-only elements (openers, headings,
   Apply) exist only while sheets do. */
.scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: var(--backdrop); }
.scrim[hidden] { display: none; }
.sheet-only, .sheet-close { display: none; }
.sheet-head { align-items: center; justify-content: space-between; gap: var(--space-3); }
.sheet-head h2 { font-size: var(--text-lg); }
@media (max-width: 1023px) {
  .js .sheet {
    position: fixed; z-index: var(--z-sheet); inset-inline: 0; bottom: 0; max-height: 85dvh; overflow: auto;
    padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
    background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow);
    transform: translateY(105%); visibility: hidden;
    transition: transform 220ms var(--ease), visibility 0s linear 220ms;
  }
  .js .sheet-start { inset-block: 0; inset-inline-end: auto; width: min(272px, 86vw); max-height: none;
    border-radius: 0; transform: translateX(-105%); }
  .js[dir="rtl"] .sheet-start { transform: translateX(105%); }
  .js .sheet[data-state="open"] { transform: none; visibility: visible; transition: transform 220ms var(--ease); }
  .js .sheet-only, .js .sheet-close { display: inline-flex; }
  .js .sheet-head.sheet-only { display: flex; }
}
.brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; font-size: var(--text-lg); color: var(--text); text-decoration: none; padding: var(--space-1) var(--space-2); }
.brand img { width: 30px; height: 30px; }
.brand-tag { font-size: var(--text-xs); font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); border-radius: var(--radius-full); padding: 2px 10px; }
.nav { display: grid; gap: 2px; }
.nav-group { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); padding: var(--space-3) var(--space-3) var(--space-1); }
.nav-link {
  display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); padding: 0 var(--space-3);
  border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 500; font-size: var(--text-sm); text-decoration: none;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-cta { margin-block: var(--space-2); }
.sidebar-footer { margin-top: auto; display: grid; gap: var(--space-2); border-top: 1px solid var(--border); padding-top: var(--space-3); }
.user-chip { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); padding: 0 var(--space-2); min-width: 0; }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .segmented { display: grid; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-header); display: flex; align-items: center; gap: var(--space-2);
  min-height: 60px; padding: 0 var(--space-3); background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar .brand { font-size: var(--text-base); }
.content { width: 100%; max-width: 1200px; margin-inline: auto; padding: var(--space-5) var(--space-4) var(--space-7); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); align-content: start; }

@media (min-width: 1024px) {
  .shell { grid-template-columns: 272px 1fr; }
  .sidebar { position: sticky; top: 0; height: 100dvh; }
  .topbar, .scrim { display: none; }
  .content { padding: var(--space-6) var(--space-6) var(--space-8); }
}

/* Page header ------------------------------------------------------------------ */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.page-title { font-size: var(--text-2xl); }
.page-sub { color: var(--text-muted); font-size: var(--text-sm); margin-top: 2px; }
.head-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.back-link { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); color: var(--text-muted); text-decoration: none; min-height: var(--control-sm); }
.back-link:hover { color: var(--text); }

/* Toolbar ---------------------------------------------------------------------- */
/* The codes list's search, filters and view switch (the one toolbar). */
.toolbar { display: grid; gap: var(--space-2); grid-template-columns: 1fr auto auto; align-items: start; }
.js [data-js-hide] { display: none; }
.search { position: relative; }
.search .icon { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search .input { padding-inline-start: 40px; }

/* Code cards ----------------------------------------------------------------------- */
.code-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 228px), 1fr)); list-style: none; padding: 0; }
.code-card { position: relative; display: grid; grid-template-rows: auto 1fr; overflow: hidden; transition: box-shadow var(--duration) var(--ease), border-color var(--duration) var(--ease); }
.code-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.code-thumb { display: grid; place-items: center; padding: var(--space-4); background: var(--surface-2); border-bottom: 1px solid var(--border); }
/* A code on its white tile keeps a margin inside it: a framed code is taller than wide and would touch it. */
.code-thumb img { width: 148px; height: 148px; padding: var(--space-2); object-fit: contain; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); background: var(--paper); }
.code-body { display: grid; gap: var(--space-2); padding: var(--space-4); align-content: start; min-width: 0; }
.code-title { font-weight: 600; font-size: var(--text-base); line-height: 1.35; overflow-wrap: anywhere; }
.code-title a { color: inherit; text-decoration: none; }
.code-title a::after { content: ""; position: absolute; inset: 0; }
.code-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }
.code-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-size: var(--text-sm); }
.code-foot .scans { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.code-card .raise { position: relative; z-index: var(--z-raised); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Short link with copy ---------------------------------------------------------------- */
.short-link { display: flex; align-items: center; gap: var(--space-1); min-width: 0; direction: ltr; }
.short-link code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.short-link code.secret-value { white-space: normal; overflow-wrap: anywhere; }
.copy-btn { min-height: var(--control-sm); width: var(--control-sm); padding: 0; }
.copy-btn[data-copied="true"] { color: var(--success); }

/* Empty state --------------------------------------------------------------------- */
.empty { display: grid; justify-items: center; gap: var(--space-3); text-align: center; padding: var(--space-8) var(--space-4); }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); }
.empty-icon .icon { width: 28px; height: 28px; }
.empty p { color: var(--text-muted); max-width: 42ch; }

/* Pager (the only pagination component) --------------------------------------------- */
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-2); }
.pager .btn { min-width: var(--tap); }
.pager-status { font-size: var(--text-sm); color: var(--text-muted); padding: 0 var(--space-2); }

/* Type picker -------------------------------------------------------------------------- */
.type-group { display: grid; gap: var(--space-3); }
.type-group h2 { font-size: var(--text-lg); }
.type-group > p { color: var(--text-muted); font-size: var(--text-sm); margin-top: calc(var(--space-2) * -1); }
.type-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); list-style: none; padding: 0; }
.type-card {
  display: flex; gap: var(--space-3); align-items: flex-start; height: 100%; padding: var(--space-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text); text-decoration: none; transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.type-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.type-icon { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-ink); }
.type-icon .icon { width: 24px; height: 24px; }
.type-card strong { display: block; font-size: var(--text-base); }
.type-card strong + span { display: block; font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }

/* Editor layout -------------------------------------------------------------------------- */
/* Grid tracks of minmax(0, 1fr): a wide child scrolls or wraps inside, it never widens the page. */
.editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.editor-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); min-width: 0; }
.editor-aside { display: grid; gap: var(--space-4); }
@media (min-width: 1024px) {
  .editor { grid-template-columns: minmax(0, 1fr) 340px; }
  .editor-aside { position: sticky; top: var(--space-5); }
}
.panel { padding: var(--space-5); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.panel-head { display: flex; align-items: center; gap: var(--space-3); }
.panel-head h2, .panel-head h3 { font-size: var(--text-lg); }
.panel-head p { font-size: var(--text-sm); color: var(--text-muted); }
.panel-num { display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--text-sm); font-weight: 700; }
.grid-2 { display: grid; gap: var(--space-4); }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
details.panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); }
details.panel > summary::-webkit-details-marker { display: none; }
.form-errors { display: grid; gap: var(--space-1); }
.sticky-actions {
  position: sticky; bottom: 0; z-index: var(--z-sticky); display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end;
  padding: var(--space-3) 0 calc(var(--space-3) + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--page) 75%, transparent);
}

/* Colour field ----------------------------------------------------------------------------- */
.color-field { display: flex; gap: var(--space-2); align-items: center; }
.color-field input[type="color"] { width: var(--tap); height: var(--tap); padding: 3px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; flex-shrink: 0; }
.input-color { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }

/* Choice controls: three, and only three (plan 6.4) --------------------------------------------------
   1. Choice tiles (.choice-grid): visual options and options that need a line of explanation — radio
      tiles (_choice_tiles.html, the kind of code, formats, access rules) or pressed buttons (templates).
   2. Segmented control (.segmented > .segment): two to four options of one setting (period, view,
      language), as links with aria-current or buttons with aria-pressed. Its rules are in base.css:
      the site's public pages show the language switch too.
   3. Tabs (.tabs > .tab): sections of one place (library kinds, the preview's Code and Page). */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--space-2); list-style: none; padding: 0; }
/* Tiles of a row share its height (a label may wrap to two lines); the content starts at the top. */
.choice-grid label, .choice-tile {
  width: 100%; height: 100%; display: grid; justify-items: center; align-content: start; gap: var(--space-2); padding: var(--space-3) var(--space-2); cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--text-sm); font-weight: 500; text-align: center;
  transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}
.choice-grid input { position: absolute; opacity: 0; pointer-events: none; }
.choice-grid label:has(input:checked), .choice-tile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: 0 0 0 1px var(--accent); }
.choice-tile:hover, .choice-grid label:hover { border-color: var(--accent); }
.choice-grid label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice-grid strong + span { font-size: var(--text-xs); color: var(--text-muted); font-weight: 400; }


.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-3); margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-muted);
  font: inherit; font-size: var(--text-sm); font-weight: 600; text-decoration: none; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"], .tab[aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* Checkbox list (countries) -------------------------------------------------------------------- */
.check-list { max-height: 260px; overflow: auto; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: var(--space-2); display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 var(--space-3); }
.check-list div { min-width: 0; }
.check-list label { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-sm); font-size: var(--text-sm); cursor: pointer; }
.check-list input { width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.check-list [hidden] { display: none; }

/* Content editor (schema-driven) ------------------------------------------------------------------ */
.json-fallback { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-sm); }
.schema-editor { display: grid; gap: var(--space-4); }
.list-editor { display: grid; gap: var(--space-3); }
.list-editor > .label { display: flex; align-items: center; gap: var(--space-2); }
.list-items { display: grid; gap: var(--space-3); list-style: none; padding: 0; }
.list-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--page); }
.list-item-head { display: flex; align-items: center; gap: var(--space-1); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
[dir="rtl"] .list-item-head { padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); }
.list-item-title { flex: 1; min-width: 0; font-size: var(--text-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-head .btn { min-height: var(--control-sm); width: var(--control-sm); padding: 0; }
.list-item-body { display: grid; gap: var(--space-3); padding: var(--space-3); }
/* One column that may shrink below its content: a long item name in a nested list widened the page at 390 px. */
.schema-editor, .list-editor, .list-items, .list-item-body { grid-template-columns: minmax(0, 1fr); }
.list-item .list-item { background: var(--surface); }
.list-empty { font-size: var(--text-sm); color: var(--text-muted); padding: var(--space-3); border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; }
.map-row { display: grid; grid-template-columns: minmax(120px, 170px) 1fr auto; gap: var(--space-2); align-items: center; }
.map-row .error-text { grid-column: 1 / -1; }
.list-count { color: var(--text-muted); font-weight: 500; }
.list-item.dragging { opacity: 0.5; }
.list-item.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }
.drag-handle { cursor: grab; color: var(--text-muted); }
.list-toggle .icon { transition: transform var(--duration) var(--ease); }
.list-toggle[aria-expanded="false"] .icon { transform: rotate(-90deg); }
[dir="rtl"] .list-toggle[aria-expanded="false"] .icon { transform: rotate(90deg); }
.raw-content { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: var(--space-3); }
.raw-content > summary { cursor: pointer; display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); min-height: var(--control-sm); }
.raw-content[open] > summary { margin-bottom: var(--space-3); }

/* Image drop zone (the one upload control) --------------------------------------------------- */
.dropzone { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3) var(--space-4); align-items: center;
  padding: var(--space-4); border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
  transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease); }
.dropzone[data-drag="true"] { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { border-color: var(--accent); }
.dropzone-preview { grid-row: span 2; width: 72px; height: 72px; border-radius: var(--radius-sm); overflow: hidden; display: grid; place-items: center;
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 14px 14px; border: 1px solid var(--border); }
.dropzone-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.dropzone-body { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.dropzone[data-has-image="true"] .dropzone-icon { display: none; }
.dropzone-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); flex-shrink: 0; }
.dropzone-text { display: grid; gap: 2px; min-width: 0; }
.dropzone-text strong { font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-text span { font-size: var(--text-xs); color: var(--text-muted); }
.dropzone-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.dropzone:not([data-has-image="true"]) .dropzone-actions { grid-column: 1 / -1; }
.dropzone:not([data-has-image="true"]) { grid-template-columns: 1fr; }
.dropzone .error-text, .dropzone-status { grid-column: 1 / -1; }
.dropzone-status { font-size: var(--text-sm); color: var(--text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.dropzone-errors { list-style: none; padding: 0; display: grid; gap: var(--space-1); }
.dropzone-preview .icon { width: 28px; height: 28px; color: var(--text-muted); }
.dropzone .dropzone-preview[hidden] { display: none; }
.dropzone.is-enhanced .dropzone-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone.is-enhanced .dropzone-input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Preview ------------------------------------------------------------------------------------ */
.preview-card { padding: var(--space-5); display: grid; gap: var(--space-4); justify-items: center; text-align: center; }
.preview-frame { width: 100%; max-width: 260px; aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--radius); background: var(--surface-2); position: relative; }
.preview-frame img { position: absolute; inset: 6%; width: 88%; height: 88%; object-fit: contain; }
.preview-skeleton { position: absolute; inset: 6%; border-radius: var(--radius-sm); display: none;
  background: linear-gradient(100deg, var(--surface-2) 30%, color-mix(in srgb, var(--surface) 70%, var(--surface-2)) 50%, var(--surface-2) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.3s linear infinite; }
.preview-frame[data-state="loading"] .preview-skeleton { display: block; }
.preview-frame[data-state="empty"], .preview-frame[data-state="error"] { outline: 1.5px dashed var(--border-strong); outline-offset: -12px; }
.preview-busy { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); opacity: 0; transition: opacity var(--duration) var(--ease); }
.preview-frame[data-busy="true"] .preview-busy { opacity: 0.8; animation: pulse 1s ease-in-out infinite; }
.preview-logo-note { text-align: start; }
@keyframes shimmer { to { background-position: -300% 0; } }
@keyframes pulse { 50% { transform: scale(0.6); } }
.preview-note { font-size: var(--text-xs); color: var(--text-muted); }
.download-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); width: 100%; }
.download-row .btn { padding: 0; font-size: var(--text-xs); }

/* Stats (the number tiles themselves: qrme/css/kpis.css) -------------------------------------- */
.chart { padding: var(--space-5); display: grid; gap: var(--space-3); }
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 2px; height: 180px; padding-top: var(--space-2); border-bottom: 1px solid var(--border); }
.bar { position: relative; height: 100%; display: flex; align-items: flex-end; }
.bar span { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--accent); opacity: 0.85; transition: opacity var(--duration) var(--ease); }
.bar:hover span { opacity: 1; }
.bar span.zero { background: var(--border); }
.bars-axis { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text-muted); }
.breakdowns { display: grid; gap: var(--space-4); }
@media (min-width: 720px) { .breakdowns { grid-template-columns: 1fr 1fr; } }
.breakdown { padding: var(--space-5); display: grid; gap: var(--space-3); align-content: start; }
.breakdown h2, .chart h2, .table-card h2 { font-size: var(--text-base); }
.meter-list { display: grid; gap: var(--space-3); list-style: none; padding: 0; }
.meter-row { display: grid; gap: 6px; }
.meter-top { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--text-sm); }
.meter-top span:last-child { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: var(--radius-full); background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.muted-note { font-size: var(--text-sm); color: var(--text-muted); }
.stat-note { display: flex; align-items: center; gap: var(--space-2); margin-top: calc(var(--space-2) * -1); }
.table-card { padding: var(--space-5); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
.table-wrap { overflow-x: auto; min-width: 0; position: relative; } /* scroll inside, never widen the page: a grid child, and it contains its visually-hidden labels (UX-N05) */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: start; font-weight: 600; color: var(--text-muted); font-size: var(--text-xs); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
/* Audit events (History, Activity, earlier destinations): long links wrap instead of widening the table. */
.audit-table td { vertical-align: top; }
/* A table cell ignores min-width; its content does not. */
.audit-table td.audit-what, .audit-table td.audit-object { white-space: normal; overflow-wrap: anywhere; }
.audit-table td.audit-what > div { min-width: 13rem; }
.audit-table td.audit-object { min-width: 9rem; }

.audit-change { display: block; margin-top: var(--space-1); }
.audit-values { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--space-2); margin: 2px 0 0; }
.audit-values dt { color: var(--text-muted); font-size: var(--text-xs); line-height: 1.7; }
.audit-values dd { margin: 0; min-width: 0; }


.detail-grid { display: grid; gap: var(--space-5); align-items: start; }
.export-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.content-card { align-content: start; }
.summary-list { display: grid; gap: var(--space-3); margin: 0; }
.summary-list div { display: grid; gap: 2px; min-width: 0; }
.summary-list dt { font-size: var(--text-xs); color: var(--text-muted); }
.summary-list dd { margin: 0; font-size: var(--text-sm); overflow-wrap: anywhere; }
@media (min-width: 1024px) { .detail-grid { grid-template-columns: minmax(0, 1fr) 320px; } }

/* Messages ------------------------------------------------------------------------------------- */
.messages { display: grid; gap: var(--space-2); list-style: none; padding: 0; }
.messages .alert { align-items: center; }
.messages .alert > span { flex: 1; }
.alert-dismiss { color: inherit; margin-block: calc(var(--space-2) * -1); margin-inline-end: calc(var(--space-2) * -1); flex-shrink: 0; }
/* A button at work (the busy-state helper, UX-N11). */
.btn[data-busy="true"]::after { content: ""; width: 1em; height: 1em; border: 2px solid currentColor; border-inline-end-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* Auth pages ------------------------------------------------------------------------------------ */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-5) var(--space-4); }
.auth-card { width: 100%; max-width: 400px; padding: var(--space-6) var(--space-5); display: grid; gap: var(--space-5); }
.auth-head { display: grid; justify-items: center; gap: var(--space-2); text-align: center; }
.auth-head img { width: 48px; height: 48px; }
.auth-head h1 { font-size: var(--text-xl); }
.auth-head p { color: var(--text-muted); font-size: var(--text-sm); }
.auth form { display: grid; gap: var(--space-4); }
.auth-foot { display: flex; justify-content: center; }

/* Organization brand preview ----------------------------------------------------------------------- */
.brand-preview { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.brand-preview-page { padding: var(--space-5) var(--space-4); display: grid; gap: var(--space-3); justify-items: center; text-align: center; background: color-mix(in srgb, var(--p-text) 3.5%, var(--p-bg)); color: var(--p-text); }
.brand-preview-page img { max-height: 40px; max-width: 150px; }
.brand-preview-page .pv-title { font-weight: 700; }
.brand-preview-page .pv-muted { font-size: var(--text-xs); color: color-mix(in srgb, var(--p-text) 68%, var(--p-bg)); }
.brand-preview-page .pv-btn { width: 100%; min-height: 44px; display: grid; place-items: center; border-radius: var(--radius); background: var(--p-accent); color: var(--p-on-accent); font-weight: 600; font-size: var(--text-sm); }
.brand-preview-page .pv-link { width: 100%; min-height: 44px; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3); border-radius: var(--radius); background: var(--p-bg); border: 1px solid color-mix(in srgb, var(--p-text) 12%, var(--p-bg)); font-size: var(--text-sm); font-weight: 600; }
.brand-preview-page .pv-link i { width: 24px; height: 24px; border-radius: 6px; background: color-mix(in srgb, var(--p-accent) 14%, var(--p-bg)); }
.member-list { list-style: none; padding: 0; display: grid; gap: var(--space-2); }
.member-list li { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.org-logo-thumb { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: contain; background: var(--surface-2); flex-shrink: 0; }

.main-col { min-width: 0; }
.skip-link { position: absolute; inset-inline-start: var(--space-3); top: -60px; z-index: var(--z-skip); padding: var(--space-2) var(--space-4); background: var(--accent); color: var(--on-accent); border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: var(--space-3); }
.narrow { max-width: 560px; width: 100%; }

/* Below the two-column layout the code page shows its code first; the code editor uses a sheet (below). */
@media (max-width: 1023px) {
  .editor-aside { order: -1; }
}

/* Field groups and rows (schema sections, half-width fields, buttons beside an input) ------------ */
.field-group { border: 0; padding: 0; display: grid; gap: var(--space-4); min-width: 0; }
/* Fieldsets default to their content's width: inside list items on a phone that widened the page. */
.schema-editor fieldset { min-width: 0; }
.field-group + .field-group, .schema-editor > .field + .field-group { padding-top: var(--space-4); border-top: 1px solid var(--border); }
.field-group > legend { font-size: var(--text-sm); font-weight: 700; color: var(--text-muted); margin-bottom: var(--space-3); padding: 0; }
.control-row { display: flex; gap: var(--space-2); align-items: center; }
.control-row > .input, .control-row > .select { flex: 1; min-width: 0; }
@media (max-width: 480px) { .hide-sm { display: none; } }

.mode-change-note { text-align: start; }

/* Media library picker: the Dialog's picker variant ------------------------------------------- */
.dialog-picker { width: min(760px, calc(100vw - 24px)); max-height: min(640px, calc(100dvh - 24px)); }
.dialog-picker[open] { display: grid; grid-template-rows: auto auto 1fr; }
.dialog-picker > .dialog-head { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.picker-actions { display: grid; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.picker-more { display: flex; justify-content: center; padding-top: var(--space-3); }
.picker-body { overflow: auto; padding: 0 var(--space-4) var(--space-4); }
.picker-status { font-size: var(--text-sm); color: var(--text-muted); padding-bottom: var(--space-2); }
.picker-grid { list-style: none; padding: 0; display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.picker-item { width: 100%; display: grid; gap: var(--space-1); padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: start; }
.picker-item:hover, .picker-item:focus-visible { border-color: var(--accent); }
.picker-item img, .picker-file { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); display: grid; place-items: center;
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 12px 12px; color: var(--text-muted); }
.picker-name { font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Media library page --------------------------------------------------------------------------- */
.media-upload { grid-template-columns: 1fr; }
@media (min-width: 720px) { .media-upload { grid-template-columns: 1fr 220px; align-items: start; } }
.media-grid { list-style: none; padding: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
.media-card { overflow: hidden; display: grid; grid-template-rows: auto 1fr; }
.media-visual { aspect-ratio: 4 / 3; display: grid; place-items: center; color: var(--text-muted);
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 14px 14px; border-bottom: 1px solid var(--border); }
.media-visual img { width: 100%; height: 100%; object-fit: contain; }
.media-body { display: grid; gap: 2px; padding: var(--space-3); min-width: 0; }
.media-name { font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta { font-size: var(--text-xs); color: var(--text-muted); }
.media-actions { display: flex; justify-content: flex-end; gap: var(--space-1); margin-top: var(--space-1); }
.media-actions .btn { min-height: var(--control-sm); width: var(--control-sm); }

/* Type picker ------------------------------------------------------------------------------------ */
.picker-intro { display: grid; gap: var(--space-3); }
.type-search { max-width: 520px; }
.mode-legend { display: grid; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); }
@media (min-width: 900px) { .mode-legend { grid-template-columns: 1fr 1fr; } }
.mode-legend div { display: flex; gap: var(--space-2); align-items: baseline; }
.mode-legend dd { margin: 0; }
.type-text { display: grid; gap: 2px; }
.type-modes { display: flex; gap: var(--space-1); margin-top: var(--space-1); }
.type-modes .badge { font-size: var(--text-xs); padding: 0 8px; }

/* Quick create ------------------------------------------------------------------------------------ */
.quick-create { padding: var(--space-4); display: grid; gap: var(--space-2); }
.quick-label { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: var(--text-sm); }
.quick-row { display: flex; gap: var(--space-2); }
.quick-row .input { flex: 1; min-width: 0; }

/* Switch (the code's Active state in the editor header) ------------------------------------------- */
.switch { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; max-width: 360px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 44px; height: 26px; flex-shrink: 0; border-radius: var(--radius-full); background: var(--border-strong); transition: background-color var(--duration) var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--duration) var(--ease); }
.switch input:checked + .switch-track { background: var(--success); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .switch-track::after { transform: translateX(-18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-text { display: grid; gap: 2px; font-size: var(--text-sm); }
.switch-text span { font-size: var(--text-xs); color: var(--text-muted); }
.draft-banner { align-items: center; flex-wrap: wrap; }
.draft-actions { display: flex; gap: var(--space-2); margin-inline-start: auto; }

/* Design section --------------------------------------------------------------------------------- */
.design-panel { gap: var(--space-3); }
.design-part { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.design-part > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-lg); padding: 0 var(--space-4); }
.design-part > summary::-webkit-details-marker { display: none; }
.part-title { font-weight: 600; }
.part-summary { font-size: var(--text-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; text-align: end; }
.design-part[open] .part-summary { visibility: hidden; }
.design-part > :not(summary) { margin: 0 var(--space-4) var(--space-4); }
.design-part > * + :not(summary) { margin-top: var(--space-4); }
.sub-part > summary { cursor: pointer; font-size: var(--text-sm); color: var(--accent-ink); min-height: var(--control-sm); display: flex; align-items: center; }
.sub-part[open] > summary { margin-bottom: var(--space-3); }
.grid-3 { display: grid; gap: var(--space-3); }
@media (min-width: 720px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.choice-grid.with-samples { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
/* A square box for every sample: a framed code, taller than wide, fits inside it undistorted. */
.choice-grid.with-samples img { width: 56px; height: 56px; object-fit: contain; border-radius: 4px; }
.choice-grid label span { line-height: 1.3; }
.tiles-field { border: 0; padding: 0; min-width: 0; }
.tiles-field > legend { margin-bottom: var(--space-2); }
.inline-choices { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.inline-choices label { justify-items: start; text-align: start; gap: 2px; }

.preset-save { display: grid; gap: var(--space-2); padding-top: var(--space-3); border-top: 1px dashed var(--border); }
@media (min-width: 720px) { .preset-save { grid-template-columns: 1fr auto auto; align-items: center; } .preset-save .help { grid-column: 1 / -1; } }

.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); background: var(--sw); cursor: pointer; }
.swatch:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.range { width: 100%; accent-color: var(--accent); min-height: var(--tap); }
.contrast-note { margin: 0; }

.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; }
.chip-btn { display: inline-flex; align-items: center; gap: var(--space-1); text-decoration: none; color: var(--text); min-height: var(--control-sm); padding: 0 var(--space-3); border-radius: var(--radius-full); border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--text-sm); cursor: pointer; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.chip-tag { display: inline-flex; align-items: center; gap: 2px; padding-inline-start: var(--space-3); border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent-ink); font-size: var(--text-sm); }
.chip-remove { display: grid; place-items: center; width: var(--control-sm); height: var(--control-sm); border: 0; background: transparent; color: inherit; cursor: pointer; border-radius: 50%; }
.chip-remove .icon { width: 14px; height: 14px; }
.selected-countries { display: grid; gap: var(--space-2); }
.countries { display: grid; gap: var(--space-3); border: 0; padding: 0; }
.sub-title { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-base); }
.visitor-password { display: grid; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.tz-note { margin-top: calc(var(--space-2) * -1); }
.access-panel fieldset { border: 0; padding: 0; }

/* The code editor's preview: a Sheet on phones and tablets ------------------------------------------ */
.preview-toggle img { width: 28px; height: 28px; padding: 2px; object-fit: contain; border-radius: 4px; background: var(--paper); }
.editor-aside > .sheet-close { justify-self: end; }
@media (max-width: 1023px) {
  .js .preview-toggle { margin-inline-end: auto; }
  .js #code-form .editor-aside { background: var(--page); }
}
.org-design-sample { width: 120px; height: auto; margin-inline: auto; }
.preset-list li { justify-content: space-between; }
.preset-list li span { flex: 1; }

/* The phone frame of the page preview ------------------------------------------------------------ */
.preview-tabs .tab { flex: 1; }
.phone-frame { display: grid; gap: var(--space-2); justify-items: center; }
.phone-frame iframe { width: 300px; max-width: 100%; height: 600px; border: 10px solid var(--device); border-radius: 36px; background: var(--paper); box-shadow: var(--shadow); }
.phone-frame[data-loading="true"] iframe { opacity: 0.85; }

/* Page style tiles (illustrations of the three layouts) --------------------------------------------- */
.page-thumb { width: 54px; height: 76px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); display: grid; align-content: start; gap: 5px; padding: 8px 7px; position: relative; overflow: hidden; }
.page-thumb i { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); justify-self: center; position: relative; z-index: var(--z-raised); }
.page-thumb b { height: 7px; border-radius: 3px; background: var(--border-strong); position: relative; z-index: var(--z-raised); }
.page-thumb.cover::before { content: ""; position: absolute; inset: 0 0 auto; height: 26px; background: var(--accent); }
.page-thumb.cover i { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); margin-top: 6px; }
.page-thumb.card { background: var(--accent-soft); }
.page-thumb.card b { background: var(--surface); box-shadow: 0 0 0 3px var(--surface); }

/* Account, members, contrast ------------------------------------------------------------------------ */
.account-grid { display: grid; gap: var(--space-4); max-width: 760px; }
.password-rules { list-style: none; padding: 0; display: grid; gap: 2px; font-size: var(--text-xs); color: var(--text-muted); }
.password-rules li::before { content: "○"; display: inline-block; width: 1.4em; }
.password-rules li[data-ok="true"] { color: var(--success); }
.password-rules li[data-ok="true"]::before { content: "✓"; }
.inline-form { display: flex; gap: var(--space-2); align-items: center; }
.inline-form .select { min-width: 140px; }
.invite-form { align-items: end; }
.invite-list { list-style: none; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.invite-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); }
.invite-row .short-link { flex: 1; min-width: 200px; }
/* Integrations (MKT-7) */
.webhook-url { overflow-wrap: anywhere; font-size: var(--text-sm); }
.webhook-form { display: grid; gap: var(--space-4); }
.auth-divider { text-align: center; }
/* Google and Apple: their own marks at the text's size; on the account page, a column of buttons. */
.social-btn img { width: 18px; height: 18px; flex-shrink: 0; }
.social-buttons { display: grid; gap: var(--space-2); max-width: 360px; }
.member-list li .badge { margin-inline-start: auto; }
.contrast-list { list-style: none; padding: 0; display: grid; gap: var(--space-2); font-size: var(--text-sm); }
.contrast-list li { display: flex; justify-content: space-between; gap: var(--space-2); }
.contrast-badge { font-weight: 700; font-variant-numeric: tabular-nums; }
.contrast-badge[data-level="ok"] { color: var(--success); }
.contrast-badge[data-level="bad"] { color: var(--danger); }

/* Codes list: summary, folders, filters, views, bulk, menus ------------------------------------------ */
.btn-sm { min-height: var(--control-sm); padding: 0 var(--space-3); font-size: var(--text-xs); }
@media (min-width: 1024px) { .head-new { display: none; } }   /* the sidebar holds "New QR code" */
.summary-kpis { list-style: none; padding: 0; }
.kpi-link { font-weight: 700; font-size: var(--text-base); color: var(--accent-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-change { font-size: var(--text-xs); color: var(--text-muted); }
.kpi-change[data-trend="up"] { color: var(--success); }
.kpi-change[data-trend="down"] { color: var(--danger); }
.folder-rail { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.folder-rail .chip-btn[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip-count { font-size: var(--text-xs); font-weight: 700; padding: 0 6px; border-radius: var(--radius-full); background: var(--surface-2); color: var(--text-muted); }
.filters-body { display: grid; gap: var(--space-3); }
@media (min-width: 1024px) {
  .toolbar { grid-template-columns: minmax(220px, 1fr) auto auto; }
  .filters-body { grid-auto-flow: column; grid-auto-columns: minmax(140px, 190px); gap: var(--space-2); }
  .js .filters-apply { display: none; }   /* wide screens filter as soon as a choice changes */
}
.active-filters { align-items: center; }
.active-filters .chip-remove { text-decoration: none; }
.bulk-bar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); background: var(--surface); border: 1px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow); }
@media (max-width: 1023px) { .bulk-bar { top: 60px; } }
.bulk-move { display: inline-flex; gap: var(--space-1); }
.bulk-move .select { min-height: var(--control-sm); width: auto; }
/* A row or card checkbox: the box is 18 px, the target around it the tap size (UX-N15). */
.check-target { display: grid; place-items: center; width: var(--tap); height: var(--tap); cursor: pointer; border-radius: var(--radius-sm); }
.check-target input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.codes-table td.select-cell { padding-block: 0; padding-inline: var(--space-1); width: var(--tap); }
.code-select { position: absolute; top: var(--space-1); inset-inline-start: var(--space-1); z-index: var(--z-raised);
  background: color-mix(in srgb, var(--surface) 85%, transparent); }
.code-card[data-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus); }
/* Menu: a popover in the top layer, so no card or scrolling table clips it (UX-N01). app.js places it
   under its button; without JavaScript it opens in the middle of the screen. */
.menu-list { min-width: 200px; padding: var(--space-1); color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.menu-list:popover-open { display: grid; }
.js .menu-list[popover] { position: fixed; inset: auto; margin: 0; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: var(--control-sm); padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: inherit; font-size: var(--text-sm); text-decoration: none; cursor: pointer; text-align: start; }
.menu-list a:hover, .menu-list button:hover, .menu-list a:focus-visible, .menu-list button:focus-visible { background: var(--surface-2); }
.menu-list .danger { color: var(--danger); }
.menu-list form { display: contents; }
.table-name { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text); font-weight: 600; text-decoration: none; }
.table-name img { padding: 2px; object-fit: contain; border-radius: 4px; background: var(--paper); }
.codes-table td.num { font-variant-numeric: tabular-nums; }
.codes-table td { vertical-align: middle; }
.empty-types { list-style: none; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }

/* Code page: period, dialogs ------------------------------------------------------------------------ */
.period-bar { display: grid; gap: var(--space-3); }
.period-bar .segmented { width: min(100%, 460px); }
.custom-range { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: end; }
.custom-range .field { min-width: 150px; }
/* Dialog: the one modal component (confirm, form and picker variants). The dialog itself has no
   padding, so a click that lands on it is a click on the backdrop and closes it. */
.dialog { margin: auto; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0;
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: var(--backdrop); }
.dialog-body { display: grid; gap: var(--space-4); padding: var(--space-5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.dialog-head h2 { font-size: var(--text-lg); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
.dialog fieldset { border: 0; padding: 0; min-width: 0; }
.test-qr { justify-self: center; width: 220px; height: auto; background: var(--paper); border-radius: var(--radius-sm); }

/* Toast -------------------------------------------------------------------------------------------- */
.toast { position: fixed; z-index: var(--z-toast); bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); inset-inline-start: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--space-2); width: max-content; max-width: min(560px, calc(100vw - 32px));
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4); border-radius: var(--radius-lg); background: var(--text); color: var(--bg);
  font-size: var(--text-sm); font-weight: 600; box-shadow: var(--shadow); }
[dir="rtl"] .toast { padding: var(--space-1) var(--space-4) var(--space-1) var(--space-1); }
.toast .toast-close { color: inherit; flex-shrink: 0; }
.toast .toast-close:hover { background: color-mix(in srgb, var(--bg) 16%, transparent); }
[dir="rtl"] .toast { transform: translateX(50%); }
.toast[data-tone="error"] { background: var(--danger); color: var(--bg); }

/* Codes list on phones: keep the codes on the first screen ------------------------------------------ */
@media (max-width: 719px) {
  /* The tiles and the folders scroll sideways, edge to edge, without a scrollbar. */
  .summary-kpis, .folder-rail { display: flex; flex-wrap: nowrap; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; margin-inline: calc(var(--space-4) * -1); padding-inline: var(--space-4); }
  .summary-kpis::-webkit-scrollbar, .folder-rail::-webkit-scrollbar { display: none; }
  .summary-kpis .kpi { flex: 0 0 auto; min-width: 128px; padding: var(--space-2) var(--space-3); gap: 0; scroll-snap-align: start; }
  .summary-kpis .kpi-value { font-size: var(--text-lg); }
  .summary-kpis .kpi-label { font-size: var(--text-xs); white-space: nowrap; }
  .quick-create { padding: var(--space-3); gap: var(--space-1); }
  .quick-create .quick-label span { font-size: var(--text-xs); }
  .quick-create .help { display: none; }
  .folder-rail > * { flex-shrink: 0; }
  .folder-rail .chip-btn { white-space: nowrap; }
  .content { gap: var(--space-4); }
}
/* Account, recovery, onboarding, notifications (phase 6) ------------------------------------ */
.inline-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: calc(-1 * var(--space-2)); }
.wrap-form { flex-wrap: wrap; }
.wrap-form .input { flex: 1 1 12rem; width: auto; }
.steps { display: grid; gap: var(--space-3); padding-inline-start: var(--space-5); font-size: var(--text-sm); }
.totp-qr { display: grid; place-items: center; margin-block: var(--space-3); }
.totp-qr svg { width: 180px; height: 180px; border-radius: var(--radius); }
.totp-key summary { cursor: pointer; color: var(--accent-ink); min-height: var(--tap); display: flex; align-items: center; }
.totp-key code, .recovery-codes code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; overflow-wrap: anywhere; }
.code-input { font-size: var(--text-xl); letter-spacing: .2em; text-align: center; }
.recovery-codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.recovery-codes li { padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); text-align: center; }
.plain-list { display: grid; gap: var(--space-2); padding-inline-start: var(--space-5); font-size: var(--text-sm); }
.stack-form { display: grid; gap: var(--space-4); }
.lifecycle { margin-top: var(--space-4); }
.onboarding-bar { width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--accent-soft); accent-color: var(--accent); }
.onboarding-bar::-webkit-progress-bar { background: var(--accent-soft); }
.onboarding-bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.onboarding-bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.onboarding-steps { list-style: none; padding: 0; display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.onboarding-steps li { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); }
.onboarding-steps li[data-done="true"] span { color: var(--text-muted); text-decoration: line-through; }
.onboarding-steps .step-icon { color: var(--success); flex: none; }
.step-dot { width: 18px; height: 18px; flex: none; border: 2px solid var(--border-strong); border-radius: 50%; margin-inline: 3px; }
.nav-count { margin-inline-start: auto; background: var(--accent); color: var(--on-accent); }
.topbar-bell { position: relative; margin-inline-start: auto; }
.bell-dot { position: absolute; top: 9px; inset-inline-end: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.notice-list { list-style: none; padding: 0; margin: 0; }
.notice { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--border); }
.notice:last-child { border-bottom: 0; }
.notice > div { display: grid; gap: var(--space-1); min-width: 0; }
.notice-title { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.notice-dot { width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: transparent; }
.notice[data-unread="true"] .notice-dot { background: var(--accent); }
.prefs-table td { text-align: center; }
.prefs-table input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

/* Spreadsheet import (MKT-4) ------------------------------------------------------ */
.template-list { list-style: none; padding: 0; display: grid; gap: var(--space-1); }
.template-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.template-list li > span { min-width: 9rem; font-size: var(--text-sm); font-weight: 600; }
.import-table th[scope="row"] { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.import-table .row-error th { box-shadow: inset 3px 0 0 var(--danger); color: var(--danger); }
[dir="rtl"] .import-table .row-error th { box-shadow: inset -3px 0 0 var(--danger); }
.import-status { white-space: normal; min-width: 14rem; }
.import-status .error-list { list-style: none; padding: 0; margin-top: var(--space-1); display: grid; gap: 2px; }

/* Responses inbox (MKT-5) -------------------------------------------------------------------------- */
.inbox-filters { display: grid; gap: var(--space-3); }
.status-tabs { max-width: 360px; }
.inbox-org { max-width: 320px; }
.response-list { list-style: none; padding: 0; display: grid; gap: var(--space-3); }
.response { padding: var(--space-4); display: grid; gap: var(--space-3); min-width: 0; }
.response.is-handled { background: var(--surface-2); }
.response-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: var(--text-sm); }
.response-code { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.response-time { color: var(--text-muted); margin-inline-start: auto; }
.response-rating { color: var(--accent-ink); font-weight: 600; letter-spacing: 1px; }
.response-contact { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.response-contact li { display: inline-flex; align-items: center; gap: var(--space-1); min-width: 0; overflow-wrap: anywhere; }
.response-message { overflow-wrap: anywhere; }
.response-consent { font-size: var(--text-xs); color: var(--text-muted); }
.response-consent summary { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; min-height: 32px; }
.response-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }

/* Public home page and generator (KSA-6): the editor's own components, without the dashboard shell. */
.site-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
  width: 100%; max-width: 1200px; margin-inline: auto; padding: var(--space-3) var(--space-4); }
.site-head-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.home { width: 100%; max-width: 1200px; margin-inline: auto; padding: var(--space-3) var(--space-4) var(--space-7); display: grid; gap: var(--space-5); align-content: start; }
.home-hero { display: grid; gap: var(--space-2); max-width: 60ch; }
.home-hero .page-title { font-size: var(--text-2xl); }
.home-hero .page-sub { font-size: var(--text-base); }
.save-actions { display: grid; gap: var(--space-2); justify-items: start; }
/* Under the generator: sections of panels, side by side where there is room. */
.home-section { display: grid; gap: var(--space-4); padding-top: var(--space-5); }
.home-section > h2 { font-size: var(--text-xl); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: var(--space-4); align-items: start; }
.home-grid.pairs { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.home-section .panel { gap: var(--space-3); }
.home-section .panel > p, .home-section .panel > ul { font-size: var(--text-sm); color: var(--text-muted); max-width: 72ch; }
.home-section .panel > ul { display: grid; gap: var(--space-2); padding-inline-start: var(--space-5); }
.faq { display: grid; gap: var(--space-3); max-width: 820px; }
.site-foot { width: 100%; max-width: 1200px; margin-inline: auto; padding: var(--space-5) var(--space-4) var(--space-7); color: var(--text-muted); font-size: var(--text-sm); border-top: 1px solid var(--border); }

