/* ============================================================
   MatterPilot.Ai — dark theme design system
   Premium SaaS (Linear/Vercel) · blue accent · balanced density
   ============================================================ */

:root {
  /* Accent (tweakable) */
  --accent: #3b82f6;
  --accent-h: #5b9bff;
  --accent-soft: color-mix(in oklab, var(--accent) 16%, transparent);
  --accent-softer: color-mix(in oklab, var(--accent) 9%, transparent);
  --accent-border: color-mix(in oklab, var(--accent) 38%, transparent);
  --accent-text: color-mix(in oklab, var(--accent) 72%, white);

  /* Cool near-black surfaces */
  --bg: #0a0c10;
  --bg-grad-1: #0b0e13;
  --bg-grad-2: #090a0d;
  --surface: #101319;
  --surface-2: #151922;
  --surface-3: #1b2029;
  --elevated: #1d232e;
  --rail: #0c0f14;

  /* Hairline borders */
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);
  --border-faint: rgba(255,255,255,0.045);

  /* Text */
  --text: #e8eaf0;
  --text-2: #aab2c0;
  --text-3: #7f8896;
  --text-4: #5b6371;

  /* Status */
  --green: #34d399;
  --green-soft: rgba(52,211,153,0.13);
  --amber: #fbbf24;
  --amber-soft: rgba(251,191,36,0.13);
  --red: #f87171;
  --red-soft: rgba(248,113,113,0.13);
  --violet: #a78bfa;
  --violet-soft: rgba(167,139,250,0.13);
  --teal: #2dd4bf;
  --teal-soft: rgba(45,212,191,0.13);

  /* Type */
  --font-ui: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Radii */
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Density (tweakable) — scales paddings */
  --pad: 20px;
  --gap: 18px;
  --row-h: 44px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 6px 24px -8px rgba(0,0,0,0.55);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,0.7);

  --rail-w: 72px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  overflow: hidden;
}

::selection { background: var(--accent-soft); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.09); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- App layout ---------- */
#root { height: 100vh; }
.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  background:
    radial-gradient(1200px 700px at 78% -10%, color-mix(in oklab, var(--accent) 7%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
}

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.content {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 28px 32px 64px;
}
.content-inner { max-width: 1280px; margin: 0 auto; }

/* ---------- Nav rail ---------- */
.rail {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--rail);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 14px; gap: 4px; position: relative; z-index: 30;
}
.rail-logo {
  width: 40px; height: 40px; border-radius: 11px; margin-bottom: 12px;
  display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(150deg, var(--accent), color-mix(in oklab, var(--accent) 55%, #7c3aed));
  box-shadow: 0 6px 18px -6px var(--accent), inset 0 1px 0 rgba(255,255,255,0.35);
  cursor: pointer;
}
.rail-divider { width: 28px; height: 1px; background: var(--border); margin: 8px 0; }
.rail-spacer { flex: 1; }

.rail-btn {
  position: relative; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; color: var(--text-3); cursor: pointer;
  border: 1px solid transparent; background: transparent;
  transition: color .15s, background .15s, border-color .15s;
}
.rail-btn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.rail-btn.active { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-border); }
.rail-btn.active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.rail-btn svg { width: 21px; height: 21px; }

.rail-tip {
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%) translateX(-6px);
  background: var(--elevated); color: var(--text); border: 1px solid var(--border-strong);
  padding: 6px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .14s, transform .14s; box-shadow: var(--shadow-md); z-index: 50;
}
.rail-tip .tip-sub { color: var(--text-3); font-weight: 500; font-size: 11px; }
.rail-btn:hover .rail-tip { opacity: 1; transform: translateY(-50%) translateX(0); }

.rail-avatar {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; margin-top: 6px;
  background: linear-gradient(140deg, #2dd4bf, #3b82f6); color: #04121f;
  display: grid; place-items: center; font-weight: 800; font-size: 12.5px;
  border: 1px solid rgba(255,255,255,0.18);
}
.rail-avatar:hover { box-shadow: 0 0 0 3px var(--accent-softer); }

/* User menu popover (anchored off the rail avatar) */
.user-menu {
  position: absolute; bottom: 0; left: calc(100% + 14px); width: 248px; z-index: 60;
  background: var(--elevated); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 7px; animation: menupop .16s ease;
}
@keyframes menupop { from { transform: translateY(6px) scale(.98); } to { transform: none; } }
.user-menu .divider { margin: 6px 4px; }
.user-menu-head { display: flex; gap: 11px; align-items: center; padding: 8px 8px 9px; }
.user-menu-item {
  display: flex; align-items: center; gap: 11px; width: 100%; height: 38px; padding: 0 10px; border-radius: 8px;
  background: transparent; border: none; color: var(--text-2); font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; text-align: left; transition: background .13s, color .13s;
}
.user-menu-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.user-menu-item svg { color: var(--text-3); }
.user-menu-item.danger { color: var(--red); }
.user-menu-item.danger svg { color: var(--red); }
.user-menu-item.danger:hover { background: var(--red-soft); }

/* Quick-create menu (anchored under the topbar "New" button) */
.qc-menu {
  position: absolute; top: calc(100% + 9px); right: 0; width: 220px; z-index: 60;
  background: var(--elevated); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 7px; animation: menupop .16s ease;
}
.qc-menu .qc-head { font-size: 10.5px; font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4); padding: 6px 10px 8px; }

/* Row action menu (fixed-positioned, escapes table overflow) */
.row-menu {
  position: fixed; width: 186px; z-index: 90;
  background: var(--elevated); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: 6px; animation: menupop .14s ease;
}
.row-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: 7px;
  background: transparent; border: none; color: var(--text-2); font-family: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
.row-menu-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.row-menu-item svg { color: var(--text-3); }
.row-menu-item.danger { color: var(--red); }
.row-menu-item.danger svg { color: var(--red); }
.row-menu-item.danger:hover { background: var(--red-soft); }

/* Confirm modal */
.btn-danger { background: var(--red); border-color: transparent; color: #2a0d0d; font-weight: 700;
  box-shadow: 0 6px 16px -8px var(--red), inset 0 1px 0 rgba(255,255,255,0.25); }
.btn-danger:hover { background: color-mix(in oklab, var(--red) 88%, white); }
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px;
  background: rgba(4, 6, 10, 0.62); backdrop-filter: blur(4px); animation: ovfade .16s ease;
}
@keyframes ovfade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 392px; background: var(--elevated); border: 1px solid var(--border-strong);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 26px 26px 22px; text-align: center;
  animation: modalpop .18s cubic-bezier(.22,1,.36,1);
}
@keyframes modalpop { from { transform: translateY(8px) scale(.97); } to { transform: none; } }
.modal-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; margin: 0 auto 16px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.modal-icon.danger { background: var(--red-soft); border-color: color-mix(in oklab, var(--red) 28%, transparent); color: var(--red); }
.modal-title { font-size: 17px; font-weight: 750; letter-spacing: -0.01em; }
.modal-msg { font-size: 13.5px; color: var(--text-3); line-height: 1.5; margin-top: 8px; max-width: 320px; margin-left: auto; margin-right: auto; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; height: 40px; }

/* Toasts */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 300; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 380px;
  padding: 12px 12px 12px 14px; border-radius: var(--r-md); background: var(--elevated);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); animation: toastin .28s cubic-bezier(.22,1,.36,1);
}
@keyframes toastin { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.toast-success .toast-ic { background: var(--green-soft); border-color: transparent; color: var(--green); }
.toast-danger .toast-ic  { background: var(--red-soft); border-color: transparent; color: var(--red); }
.toast-info .toast-ic    { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.toast-warn .toast-ic    { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.toast-body { flex: 1; min-width: 0; }
.toast-msg { font-size: 13px; font-weight: 650; letter-spacing: -0.005em; }
.toast-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.toast-action { flex-shrink: 0; height: 28px; padding: 0 11px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--accent-text); font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.toast-action:hover { background: var(--surface-3); }
.toast-x { flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px; border: none; background: transparent; color: var(--text-4); cursor: pointer; display: grid; place-items: center; }
.toast-x:hover { color: var(--text); background: rgba(255,255,255,0.05); }
@media (max-width: 560px) { .toast-wrap { left: 14px; right: 14px; bottom: 78px; align-items: stretch; } .toast { min-width: 0; max-width: none; } }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 52px 24px; gap: 6px; }
.es-icon { width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); }
.es-title { font-size: 15px; font-weight: 750; letter-spacing: -0.01em; }
.es-msg { font-size: 13px; color: var(--text-3); max-width: 320px; line-height: 1.55; margin-bottom: 16px; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h); flex-shrink: 0; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px 0 28px;
  background: color-mix(in oklab, var(--bg) 72%, transparent); backdrop-filter: blur(12px);
}
.crumb { display: flex; align-items: center; gap: 9px; min-width: 0; }
.crumb-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent-text); flex-shrink: 0; }
.crumb-icon svg { width: 17px; height: 17px; }
.crumb-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.crumb-sub { font-size: 12px; color: var(--text-3); }

.search {
  display: flex; align-items: center; gap: 9px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 9px; padding: 0 12px; height: 36px;
  color: var(--text-3); min-width: 200px; cursor: text; transition: border-color .15s;
}
.search:hover { border-color: var(--border-strong); }
.search svg { width: 15px; height: 15px; flex-shrink: 0; }
.search input { background: none; border: none; outline: none; color: var(--text); font-family: inherit; font-size: 13px; width: 100%; }
.search .kbd { margin-left: auto; }

.kbd { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
  position: relative; transition: border-color .15s, color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); border: 2px solid var(--rail); }
.topbar-count {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 800;
  display: grid; place-items: center; line-height: 1; border: 2px solid var(--bg);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 9px; font-family: inherit; font-size: 13px;
  font-weight: 650; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px -8px var(--accent), inset 0 1px 0 rgba(255,255,255,0.25); }
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn-icon-only { padding: 0; width: 36px; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.018), transparent), var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--pad);
}
.card-pad-0 { padding: 0; }
.card-hover { transition: border-color .16s, transform .16s, background .16s; cursor: pointer; }
.card-hover:hover { border-color: var(--border-strong); transform: translateY(-2px); }

.section-title { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); }
.h-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 7px;
  font-size: 11.5px; font-weight: 650; font-family: var(--font-mono); letter-spacing: -0.01em;
  border: 1px solid var(--border); color: var(--text-2); background: var(--surface-2);
}
.badge .pip { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { color: var(--green); background: var(--green-soft); border-color: transparent; }
.badge-amber { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.badge-red   { color: var(--red); background: var(--red-soft); border-color: transparent; }
.badge-blue  { color: var(--accent-text); background: var(--accent-soft); border-color: transparent; }
.badge-violet{ color: var(--violet); background: var(--violet-soft); border-color: transparent; }
.badge-teal  { color: var(--teal); background: var(--teal-soft); border-color: transparent; }

.tag { font-size: 11.5px; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px; font-weight: 600; }

/* ---------- Avatars ---------- */
.avatar { border-radius: 50%; display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
  color: #04121f; font-size: 12px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-4); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border-faint); font-size: 13px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: rgba(255,255,255,0.018); }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text-2); }
.tbl th.sortable .sort-ind { display: inline-block; margin-left: 5px; font-size: 9px; vertical-align: middle; opacity: .35; }
.tbl th.sortable[aria-sort] .sort-ind { opacity: .9; color: var(--accent); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.input, .select {
  height: 38px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font-family: inherit; font-size: 13px; padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-softer); }
.input::placeholder { color: var(--text-4); }

/* Toggle switch */
.switch { width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong);
  position: relative; cursor: pointer; transition: background .18s, border-color .18s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-2); transition: transform .18s, background .18s; }
.switch.on { background: var(--accent); border-color: transparent; }
.switch.on::after { transform: translateX(16px); background: #fff; }

/* Progress */
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }

/* Misc */
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-3); }
.muted2 { color: var(--text-4); }
.divider { height: 1px; background: var(--border); }
.grid { display: grid; gap: var(--gap); }
.flex { display: flex; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* Entrance — animate transform ONLY (never opacity), so a frozen/offscreen
   render or paused animation clock can never leave content invisible. */
.view-enter { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .view-enter { animation: rise .42s cubic-bezier(.22,1,.36,1); }
}
@keyframes rise { from { transform: translateY(9px); } to { transform: none; } }

.page-head { margin-bottom: 24px; }
.page-head.h-row { flex-wrap: wrap; gap: 14px 16px; }
.page-head.h-row > div:first-child { flex: 1 1 auto; min-width: 0; }
.page-title { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; }
.page-sub { color: var(--text-3); font-size: 13.5px; margin-top: 3px; }

/* Density variants applied on .app */
.app.density-compact { --pad: 14px; --gap: 12px; --row-h: 38px; }
.app.density-compact .content { padding: 20px 24px 56px; }
.app.density-comfy { --pad: 26px; --gap: 24px; --row-h: 50px; }

/* ---------- Responsive ---------- */
.mobile-only { display: none; }
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    grid-row: 2; flex-direction: row; border-right: none; border-top: 1px solid var(--border);
    padding: 6px 10px; gap: 2px; overflow-x: auto; justify-content: flex-start; height: 64px;
  }
  .app { grid-template-rows: 1fr 64px; height: 100vh; }
  .main { grid-row: 1; }
  .rail-logo, .rail-divider, .rail-spacer, .rail-avatar { display: none; }
  .rail-btn.active::before { left: 50%; top: auto; bottom: -6px; transform: translateX(-50%); width: 20px; height: 3px; }
  .rail-tip { display: none; }
  .content { padding: 18px 16px 40px; }
  .search { min-width: 0; width: 38px; padding: 0; justify-content: center; }
  .search input, .search .kbd { display: none; }
  .topbar { padding: 0 14px; gap: 10px; }
  .crumb-sub { display: none; }
  .hide-sm { display: none !important; }
  .mobile-only { display: revert; }
}

/* ---------- Print ----------
   The app shell pins .app/.main to 100vh and makes .content the only
   scroll container (overflow-y:auto). A fixed-height scroll container
   only prints its visible viewport, so printing/saving as PDF would
   clip everything below the fold to a single page. Release the heights
   and overflow for print so content reflows naturally across pages. */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; }
  .app {
    display: block; height: auto; background: none;
    grid-template-columns: none; grid-template-rows: none;
  }
  .main { display: block; height: auto; min-width: 0; }
  .content {
    flex: none; height: auto; min-height: 0; overflow: visible; padding: 0;
  }
  .content-inner { max-width: none; margin: 0; }
  /* Chrome around the printed content. */
  .rail, .topbar { display: none !important; }
  /* Preserve the redline tints / badge colours in the PDF. */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Keep individual diff rows intact across page breaks where possible. */
  .cmp-diff tr { break-inside: avoid; }
}
