/* CatScape Marketing Funnel — console styles
 *
 * Theming: every colour is a variable on :root. `html[data-theme="dark"]`
 * swaps the palette, and an inline script in partials/head.ejs sets that
 * attribute before first paint so there is no flash of the wrong theme.
 * Nothing below should hard-code a colour — if you need a new one, add a
 * variable to BOTH blocks.
 */

:root {
  color-scheme: light;

  --cs-1: #2f7bff;
  --cs-2: #22d3ee;
  --cs-3: #a78bfa;
  --ramp: linear-gradient(135deg, var(--cs-1), var(--cs-2) 55%, var(--cs-3));

  --bg: #f1f5f9;
  --card: #ffffff;
  --card-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --line-2: #cbd5e1;

  --side-bg: #0b1220;
  --side-ink: #cbd5e1;
  --side-ink-2: #64748b;
  --side-hover: #172033;
  --side-line: #1e293b;

  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #e11d48;

  --chip-bg: #f1f5f9;
  --chip-ink: #475569;
  --ok-bg: #dcfce7;    --ok-ink: #14532d;    --ok-line: #bbf7d0;
  --bad-bg: #ffe4e6;   --bad-ink: #881337;   --bad-line: #fecdd3;
  --warn-bg: #fef3c7;  --warn-ink: #78350f;  --warn-line: #fde68a;
  --info-bg: #dbeafe;  --info-ink: #1e3a8a;  --info-line: #bfdbfe;

  --wa-bg: #e5ddd5;
  --wa-bubble: #ffffff;
  --term-bg: #0b1220;
  --term-ink: #e2e8f0;

  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .32);
  --r: 14px;
  --sidebar: 244px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #070c16;
  --card: #111a2b;
  --card-2: #16203350;
  --ink: #e6edf7;
  --ink-2: #a3b2c9;
  --muted: #6b7c96;
  --line: #1f2b41;
  --line-2: #2c3b57;

  --side-bg: #050a13;
  --side-ink: #b9c6da;
  --side-ink-2: #5a6a83;
  --side-hover: #131e30;
  --side-line: #1a2536;

  --ok: #22c55e;
  --warn: #fbbf24;
  --bad: #fb7185;

  --chip-bg: #1a2537;
  --chip-ink: #a3b2c9;
  --ok-bg: #0d2c1a;    --ok-ink: #86efac;    --ok-line: #17492c;
  --bad-bg: #3a1220;   --bad-ink: #fda4af;   --bad-line: #5c1e30;
  --warn-bg: #372410;  --warn-ink: #fcd34d;  --warn-line: #55391a;
  --info-bg: #10233f;  --info-ink: #93c5fd;  --info-line: #1c3a63;

  --wa-bg: #0b141a;
  --wa-bubble: #202c33;
  --term-bg: #05090f;
  --term-ink: #cbd5e1;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--cs-1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── shell ────────────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--side-bg);
  color: var(--side-ink);
  padding: 18px 14px 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--side-line); border-radius: 8px; }

.brand-row { display: flex; align-items: flex-start; gap: 8px; padding: 4px 4px 16px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 0 4px; }
.brand img { width: 34px; height: 34px; flex: 0 0 auto; }
.brand b { color: #fff; font-size: 15px; letter-spacing: -.2px; display: block; }
.brand span { font-size: 11px; color: var(--side-ink-2); letter-spacing: .5px; text-transform: uppercase; }

.nav-group { margin: 14px 0 6px; padding: 0 10px; font-size: 10.5px; letter-spacing: .9px; text-transform: uppercase; color: var(--side-ink-2); }

.sidebar a.nav {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; margin: 2px 0;
  border-radius: 10px; color: var(--side-ink); font-size: 14px; text-decoration: none;
  transition: background .12s, color .12s;
}
.sidebar a.nav:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.sidebar a.nav.on { background: var(--ramp); color: #fff; font-weight: 600; }
.sidebar a.nav .ico { width: 20px; text-align: center; font-size: 15px; }
.sidebar a.nav .count {
  margin-left: auto; background: var(--side-line); color: var(--side-ink-2);
  border-radius: 20px; padding: 1px 8px; font-size: 11px; font-weight: 700;
}
.sidebar a.nav.on .count { background: rgba(255,255,255,.22); color: #fff; }

.sidebar-foot { margin-top: 18px; padding: 12px 11px; border-top: 1px solid var(--side-line); font-size: 12px; color: var(--side-ink-2); }
.sidebar-foot form { margin: 8px 0 0; }
.sidebar-foot button {
  width: 100%; background: var(--side-hover); color: var(--side-ink); border: 1px solid var(--side-line);
  border-radius: 9px; padding: 9px; cursor: pointer; font: inherit; font-size: 12.5px;
}
.sidebar-foot button:hover { background: var(--side-line); color: #fff; }

/* Theme toggle — top of the sidebar on desktop, top bar on mobile. */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 auto;
  background: var(--side-hover); color: var(--side-ink);
  border: 1px solid var(--side-line); border-radius: 10px;
  cursor: pointer; font: inherit; font-size: 16px; line-height: 1; padding: 0;
}
.theme-toggle:hover { background: var(--side-line); color: #fff; }

/* Show only the label for the theme you'd switch TO. Used by both the sidebar
   toggle and the compact one in the mobile bar. */
html[data-theme="dark"] .lbl-light { display: none; }
html:not([data-theme="dark"]) .lbl-dark { display: none; }

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }

.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.5px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 13.5px; max-width: 70ch; }
.page-head .spacer { flex: 1; }

/* ── cards, tables, chips ─────────────────────────────────────────────────── */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 4px; font-size: 16px; letter-spacing: -.2px; }
.card h2 + .sub { margin: 0 0 14px; color: var(--ink-2); font-size: 13px; }
.card .sub { color: var(--ink-2); font-size: 13px; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
/* A grid item's automatic minimum is its min-content width, so one wide child
   (a long input, an unbreakable URL) silently pushes the whole track past the
   viewport. Letting items shrink to 0 keeps the page from scrolling sideways. */
.grid > * { min-width: 0; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 16px; box-shadow: var(--shadow); }
.stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; }
.stat .v { font-size: 27px; font-weight: 700; letter-spacing: -1px; margin: 3px 0 0; }
.stat .d { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.stat.accent { border-top: 3px solid var(--cs-1); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: .7px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--card); z-index: 2;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--card-2); }
tbody tr.sel { background: var(--info-bg); }
.table-wrap {
  overflow: auto; max-height: 68vh; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); -webkit-overflow-scrolling: touch;
}
.table-wrap table { font-size: 13px; }

/* A report table dropped straight into a card gets its own horizontal
   scroller, so a wide one never pushes the whole page sideways on a narrow
   laptop or a tablet. Below 760px `.rt` stacks instead — see the media query
   at the bottom — so this only covers the range in between. */
@media (min-width: 761px) {
  .card > table { display: block; overflow-x: auto; }
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 30px; font-size: 11.5px; font-weight: 700;
  background: var(--chip-bg); color: var(--chip-ink); border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.ok   { background: var(--ok-bg);   color: var(--ok-ink);   border-color: var(--ok-line); }
.chip.bad  { background: var(--bad-bg);  color: var(--bad-ink);  border-color: var(--bad-line); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.chip.info { background: var(--info-bg); color: var(--info-ink); border-color: var(--info-line); }
.chip.mute { background: var(--chip-bg); color: var(--muted); }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── forms ────────────────────────────────────────────────────────────────── */

label.f { display: block; margin-bottom: 12px; }
label.f > span {
  display: block; font-size: 12px; font-weight: 700; color: var(--ink-2);
  margin-bottom: 4px; letter-spacing: .2px;
}
label.f > small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 3px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 10px;
  font: inherit; font-size: 16px; background: var(--card); color: var(--ink);
}
@media (min-width: 761px) {
  /* 16px on mobile stops iOS zooming the page when a field is focused */
  input[type=text], input[type=email], input[type=password], input[type=number],
  input[type=url], input[type=search], select, textarea { font-size: 14px; }
}
input[type=file] { padding: 7px 9px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--cs-1); box-shadow: 0 0 0 3px rgba(47,123,255,.2);
}
input[type=checkbox] { accent-color: var(--cs-1); }
textarea { resize: vertical; min-height: 110px; line-height: 1.6; font-family: inherit; }
textarea.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
select { appearance: none; background-image: none; }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 10px; font-size: 13.5px; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--ramp); color: #fff; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; line-height: 1.2; min-height: 40px;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--card-2); color: var(--ink); }
.btn.danger { background: var(--bad); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; min-height: 32px; }
.btn.wide { width: 100%; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 150px; }
.row > .fit { flex: 0 0 auto; min-width: 0; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }

/* ── banners ──────────────────────────────────────────────────────────────── */

.banner {
  padding: 11px 15px; border-radius: 11px; margin-bottom: 16px;
  font-size: 13.5px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.banner.ok   { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok-ink); }
.banner.bad  { background: var(--bad-bg);  border-color: var(--bad-line);  color: var(--bad-ink); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.banner.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.banner a { color: inherit; text-decoration: underline; }

/* ── product + channel bits ───────────────────────────────────────────────── */

.prod {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}
.prod img { height: 26px; max-width: 96px; object-fit: contain; }
.prod .nm { font-weight: 700; font-size: 14px; display: block; }
.prod .tg { font-size: 11.5px; color: var(--muted); display: block; }
.prod:has(input:checked) { border-color: var(--cs-1); box-shadow: 0 0 0 3px rgba(47,123,255,.16); }

/* Product logos are drawn for a white page; keep them on one in dark mode. */
.logo-tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; background: #fff;
  border: 1px solid var(--line); flex: 0 0 auto;
}
.logo-tile img { max-width: 30px; max-height: 26px; object-fit: contain; }
html[data-theme="dark"] .prod img { background: #fff; border-radius: 6px; padding: 3px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* ── preview panes ────────────────────────────────────────────────────────── */

.phone {
  background: var(--wa-bg); border-radius: 16px; padding: 14px; border: 1px solid var(--line-2);
  max-height: 460px; overflow: auto;
}
.bubble {
  background: var(--wa-bubble); color: var(--ink); border-radius: 10px 10px 10px 2px; padding: 10px 12px;
  font-size: 13.5px; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,.12); max-width: 100%;
}
.bubble .bold { font-weight: 700; }
.bubble .ital { font-style: italic; }

.mail-preview { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.mail-preview iframe { width: 100%; height: 460px; border: 0; display: block; background: #f1f5f9; }
.mail-head { padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); font-size: 13px; }

.sms-preview {
  background: var(--term-bg); color: var(--term-ink); border-radius: 12px; padding: 14px;
  border: 1px solid var(--line);
  font: 13px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}

/* ── chart ────────────────────────────────────────────────────────────────── */

.chart { width: 100%; height: 190px; display: block; }
.chart .grid-line { stroke: var(--line); }
.chart .axis { stroke: var(--line-2); }
.bar-track { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; background: var(--ramp); }

.funnel-step { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.funnel-step .lbl { width: 118px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; flex: 0 0 auto; }
.funnel-step .track { flex: 1; height: 26px; background: var(--chip-bg); border-radius: 8px; overflow: hidden; }
.funnel-step .fill { height: 100%; background: var(--ramp); border-radius: 8px; min-width: 2px; }
.funnel-step .n { width: 64px; text-align: right; font-weight: 700; font-size: 14px; flex: 0 0 auto; }

/* ── modal / drawer ───────────────────────────────────────────────────────── */

.modal-back {
  position: fixed; inset: 0; background: rgba(2, 6, 16, .62); z-index: 90;
  display: flex; align-items: flex-start; justify-content: center; padding: 34px 16px; overflow: auto;
}
.modal {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 780px;
  box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--line);
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 18px 20px; max-height: 68vh; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--card-2); flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 6px; }

details.tpl { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--card); }
details.tpl > summary {
  padding: 11px 14px; cursor: pointer; display: flex; align-items: center; gap: 10px;
  list-style: none; font-size: 14px; flex-wrap: wrap;
}
details.tpl > summary::-webkit-details-marker { display: none; }
details.tpl > summary:hover { background: var(--card-2); }
details.tpl[open] > summary { border-bottom: 1px solid var(--line); background: var(--card-2); }
details.tpl .body { padding: 16px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mb0 { margin-bottom: 0; }
.mt16 { margin-top: 16px; }
.hidden { display: none !important; }

.code-line {
  font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; word-break: break-all; color: var(--ink-2);
}

/* ── auth + public form ───────────────────────────────────────────────────── */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--info-bg), transparent), var(--bg); }
.auth { width: 100%; max-width: 400px; }
.auth .card { padding: 26px; }
.auth .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth .logo img { width: 44px; height: 44px; }

.pub { min-height: 100vh; background: var(--bg); padding: 0 0 60px; }
.pub-hero { padding: 36px 20px 30px; color: #fff; }
.pub-inner { max-width: 900px; margin: 0 auto; }
.pub-card {
  max-width: 900px; margin: -46px auto 0; background: var(--card); border-radius: 18px;
  box-shadow: var(--shadow); padding: 26px 28px 30px; border: 1px solid var(--line);
}
.pub-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 30px; }
.pub ul.hl { margin: 0; padding: 0; list-style: none; }
.pub ul.hl li { padding: 7px 0 7px 26px; position: relative; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.pub-form { border: 1px solid var(--line); border-radius: 14px; padding: 20px; background: var(--card-2); }

/* ── mobile ───────────────────────────────────────────────────────────────── */

.mobile-bar { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 1000px) {
  .pub-grid { grid-template-columns: 1fr; gap: 22px; }
  .pub-card { padding: 22px 18px 26px; margin-top: -34px; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 100;
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }

  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 99;
    background: rgba(2, 6, 16, .55); opacity: 0; pointer-events: none; transition: opacity .22s;
  }
  .nav-backdrop.on { opacity: 1; pointer-events: auto; }

  .main { padding: 14px 14px 60px; }

  .mobile-bar {
    display: flex; align-items: center; gap: 10px; margin: -14px -14px 14px;
    background: var(--side-bg); color: #fff; padding: 11px 14px;
    position: sticky; top: 0; z-index: 40;
  }
  .mobile-bar img { width: 26px; height: 26px; }
  .mobile-bar .t { font-weight: 700; font-size: 14px; flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-bar button {
    background: var(--side-hover); border: 1px solid var(--side-line); color: #fff;
    border-radius: 9px; padding: 7px 11px; cursor: pointer; font-size: 16px; line-height: 1;
    min-height: 38px; min-width: 40px;
  }

  .page-head h1 { font-size: 20px; }
  .page-head p { font-size: 13px; }
  .page-head .btn { flex: 1; min-width: 140px; }

  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 13px; }
  .stat .v { font-size: 22px; }

  .grid { gap: 12px; }
  .card { padding: 14px; }
  .card + .card { margin-top: 12px; }

  .modal-back { padding: 0; align-items: stretch; }
  .modal { max-width: none; border-radius: 0; min-height: 100vh; display: flex; flex-direction: column; border: 0; }
  .modal-head { position: sticky; top: 0; background: var(--card); z-index: 3; }
  .modal-body { max-height: none; flex: 1; }
  .modal-foot { position: sticky; bottom: 0; }
  .modal-foot .btn { flex: 1; }

  .funnel-step .lbl { width: 92px; font-size: 11.5px; }
  .funnel-step .n { width: 52px; font-size: 13px; }

  .toolbar > select, .toolbar > input { flex: 1 1 100%; min-width: 0; }
}

/*
 * Tables become stacked cards on a phone. Any table marked `.rt` gets its
 * header row hidden and each cell labelled from its own `data-l` attribute,
 * because a nine-column contact list inside a horizontal scroller is
 * unusable on a 380px screen.
 */
@media (max-width: 760px) {
  .table-wrap { max-height: none; border: 0; background: none; border-radius: 0; overflow: visible; }

  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt thead { display: none; }
  table.rt tr {
    border: 1px solid var(--line); border-radius: 12px; background: var(--card);
    margin-bottom: 10px; padding: 10px 12px; box-shadow: var(--shadow);
  }
  table.rt tr:hover { background: var(--card); }
  table.rt tr.sel { background: var(--info-bg); border-color: var(--cs-1); }
  table.rt td {
    border: 0; padding: 4px 0; display: flex; gap: 10px; align-items: flex-start;
    text-align: left !important;
    /* long emails, URLs and phone numbers must break rather than push the
       stacked card wider than the screen */
    overflow-wrap: anywhere; min-width: 0;
  }
  table.rt td > * { min-width: 0; overflow-wrap: anywhere; }
  table.rt td::before {
    content: attr(data-l); flex: 0 0 88px; color: var(--muted);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
    font-weight: 700; padding-top: 3px;
  }
  table.rt td[data-l=""]::before, table.rt td:not([data-l])::before { display: none; }
  table.rt td.rt-hide { display: none; }
  table.rt td .btn { min-height: 36px; }
  table.rt td:last-child { padding-top: 8px; flex-wrap: wrap; gap: 8px; }

  thead th { position: static; }
}

@media (max-width: 460px) {
  .g4 { grid-template-columns: 1fr; }
  .page-head .btn { width: 100%; flex: 1 1 100%; }
  .row > * { flex: 1 1 100%; min-width: 0; }
  table.rt td::before { flex-basis: 74px; }
}

@media print {
  .sidebar, .mobile-bar, .nav-backdrop, .page-head .btn, .toolbar { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; }
}
