/* ==========================================================================
   Offline Pages — Scouts eHealth Admin Portal
   Minimal self-contained styles matching the Scout purple theme.
   Used by offline.html and offline-reports.html (served from SW cache).
   ========================================================================== */

:root {
  --color-primary: #7b2d8e;
  --color-primary-dark: #5e2270;
  --color-primary-light: #9b4dae;
  /* Primary ACTION colour — matches the main portal's blue button token
     (kept distinct from the Scout purple used for selected/nav state). */
  --btn-primary-bg: #1d4ed8;
  --btn-primary-hover: #1e40af;
  --btn-primary-fg: #ffffff;
  --color-white: #ffffff;
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

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

body {
  font-family: var(--font-family);
  color: var(--color-gray-800);
  background: var(--color-gray-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */

.offline-header {
  background: var(--color-primary);
  color: var(--color-white);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
  flex-shrink: 0;
}

.offline-header img {
  height: 36px;
  width: auto;
}

.offline-header-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.offline-header-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.2);
  color: var(--color-white);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* ── Main Content ── */

.offline-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.offline-container {
  max-width: 560px;
  width: 100%;
}

.offline-card {
  background: var(--color-white);
  border-radius: 0.75rem;
  box-shadow:
    0 4px 6px -1px rgb(0 0 0 / 0.1),
    0 2px 4px -2px rgb(0 0 0 / 0.1);
  padding: 2.5rem 2rem;
  text-align: center;
}

.offline-icon {
  font-size: 3rem;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

.offline-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-gray-800);
  margin-bottom: 0.75rem;
}

.offline-card p {
  color: var(--color-gray-600);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.offline-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 150ms ease;
}

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
}

.btn-secondary {
  background: var(--color-white);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
  background: var(--color-gray-50);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.btn-danger-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  background: none;
  color: var(--color-error);
  border: 1px solid var(--color-error);
}

.btn-danger-sm:hover {
  background: var(--color-error-bg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Reconnect Hint ── */

.reconnect-hint {
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  border-radius: 0.5rem;
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--color-gray-600);
  line-height: 1.5;
}

.reconnect-hint strong {
  color: var(--color-gray-700);
}

/* ── Online Banner ── */

.online-banner {
  display: none;
  background: var(--color-success-bg);
  border: 1px solid var(--color-success);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
  color: var(--color-success);
  font-weight: 600;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.online-banner.visible {
  display: flex;
}

/* ── Reports Page Layout ── */

.reports-header {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}

.reports-main {
  flex: 1;
  padding: 1.5rem 1rem;
}

.reports-container {
  max-width: 800px;
  margin: 0 auto;
}

.reports-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.reports-title-bar h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-gray-800);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reports-title-bar h1 i {
  color: var(--color-primary);
}

.back-link {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.back-link:hover {
  text-decoration: underline;
}

/* ── Report Cards ── */

.report-card {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: box-shadow 150ms ease;
}

.report-card:hover {
  box-shadow:
    0 4px 6px -1px rgb(0 0 0 / 0.1),
    0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.report-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

.report-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-gray-800);
  word-break: break-word;
}

.report-card-type {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-primary);
  color: var(--color-white);
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.report-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--color-gray-500);
  margin-bottom: 0.75rem;
}

.report-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.report-card-expiry {
  font-size: 0.8125rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  margin-bottom: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.expiry-valid {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.expiry-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.expiry-expired {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.report-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Orphaned Passkey copy (2026-09-28): its device vault was replaced/removed —
   it can only be removed or set up again online, never unlocked. */
.report-card--needs-setup {
  border-color: var(--color-warning);
}

.report-card--needs-setup .report-card-lock {
  color: var(--color-warning);
}

.report-card-needs-setup {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--color-gray-700);
  background: var(--color-warning-bg);
  border-radius: 0.375rem;
  padding: 0.5rem 0.625rem;
  margin-bottom: 0.75rem;
}

/* OFF-11 owner-check state actions (2026-09-28). */
.owner-check-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Passkey offline-readiness panel (2026-09-28). */
.offline-readiness {
  border: 1px solid var(--color-gray-200);
  border-left-width: 4px;
  border-radius: 0.5rem;
  background: var(--color-white);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

.offline-readiness[hidden] {
  display: none;
}

.offline-readiness--verified {
  border-left-color: var(--color-success);
}

.offline-readiness--unverified {
  border-left-color: var(--color-warning);
}

.offline-readiness-title {
  display: block;
  color: var(--color-gray-800);
  margin-bottom: 0.25rem;
}

.offline-readiness-text,
.offline-readiness-hint {
  color: var(--color-gray-600);
  margin: 0 0 0.5rem;
}

.offline-readiness-hint {
  font-size: 0.8125rem;
  margin: 0.5rem 0 0;
}

/* ── Empty & Error States ── */

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-gray-500);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-gray-300);
}

.empty-state h3 {
  font-size: 1.125rem;
  color: var(--color-gray-600);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.875rem;
  line-height: 1.5;
}

.error-banner {
  background: var(--color-error-bg);
  border: 1px solid var(--color-error);
  color: var(--color-error);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Toast Notification ── */

.offline-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: var(--color-gray-800);
  color: var(--color-white);
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  box-shadow:
    0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);
  z-index: 1000;
  opacity: 0;
  transition:
    transform 300ms ease,
    opacity 300ms ease;
  max-width: 90%;
  text-align: center;
}

.offline-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Footer ── */

.offline-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--color-gray-400);
  border-top: 1px solid var(--color-gray-200);
}

/* ── Confirm Dialog ── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1rem;
}

.confirm-dialog {
  background: var(--color-white);
  border-radius: 0.75rem;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.confirm-dialog h3 {
  font-size: 1.0625rem;
  margin-bottom: 0.5rem;
}

.confirm-dialog p {
  font-size: 0.875rem;
  color: var(--color-gray-600);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.confirm-dialog-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ── PDF Viewer Overlay ── */

.pdf-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--color-gray-100);
  display: flex;
  flex-direction: column;
  /* Native page zoom must never scale this shell (toolbar, title, icons):
     pinch/double-tap on ANY part of the viewer is refused here and turned into
     PDF zoom by offlineApp.js (the meta viewport is locked while open too).
     Single-finger panning stays native. */
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
}

.pdf-viewer-toolbar {
  background: var(--color-primary);
  color: var(--color-white);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.15);
  z-index: 2;
}

.pdf-toolbar-btn {
  background: none;
  border: none;
  color: var(--color-white);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pdf-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.pdf-toolbar-title {
  font-weight: 600;
  font-size: 0.875rem;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdf-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pdf-page-info {
  font-size: 0.8125rem;
  padding: 0 0.5rem;
  white-space: nowrap;
}

/* ── PDF Search Bar ── */

.pdf-search-bar {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-gray-200);
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  z-index: 2;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}

.pdf-search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-300);
  border-radius: 0.375rem;
  padding: 0 0.625rem;
  gap: 0.5rem;
}

.pdf-search-input-wrap i {
  color: var(--color-gray-400);
  font-size: 0.8125rem;
}

.pdf-search-input-wrap input {
  border: none;
  background: none;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  width: 100%;
  outline: none;
  font-family: var(--font-family);
}

.pdf-search-count {
  font-size: 0.75rem;
  color: var(--color-gray-500);
  white-space: nowrap;
}

.pdf-search-nav {
  background: none;
  border: 1px solid var(--color-gray-300);
  color: var(--color-gray-600);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.375rem;
  cursor: pointer;
  flex-shrink: 0;
}

.pdf-search-nav:hover {
  background: var(--color-gray-100);
}

/* ── PDF Content Area ── */

.pdf-viewer-content {
  flex: 1;
  /* Both axes: a zoomed page is wider than the viewport and pans sideways. */
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  /* Mobile zoom (2026-09-02): pinch is handled in-app (re-render), so the
     browser must not page-zoom here; single-finger panning stays native.
     Double-tap zoom is excluded as well (no `manipulation`/auto). */
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  background: var(--color-gray-200);
}

/* Zoom level readout in the toolbar (tap = back to fit-width). */
.pdf-zoom-level {
  font-variant-numeric: tabular-nums;
  min-width: 3.25rem;
  justify-content: center;
  font-size: 0.8125rem;
}

.pdf-toolbar-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.pdf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--color-gray-500);
  font-size: 0.9375rem;
}

.pdf-loading i {
  font-size: 1.5rem;
  color: var(--color-primary);
}

.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

/* Zoomed (> fit-width): pages grow past the viewport and the content area
   pans both ways; nothing is CSS-scaled — the shells are re-laid out and the
   canvases re-rendered at the new scale (offlineApp.js applyViewerLayout).
   ALIGNMENT is the horizontal-scroll fix: a `center`-aligned block that is
   wider than its scroll container overflows EQUALLY on both sides, and the
   left half can never be scrolled into view (desktop "zoom clips the page").
   `safe center` centres only while the block fits and START-aligns it once it
   overflows, so the left edge stays reachable; the plain `flex-start` line
   before it is the fallback for engines without `safe`. Both the scroll
   container and the page block carry it (the container aligns the block, the
   block aligns its pages). */
.pdf-viewer-content.pdf-viewer-content--zoomed {
  align-items: flex-start;
  align-items: safe center;
}

.pdf-pages.pdf-pages--zoomed {
  align-items: flex-start;
  align-items: safe center;
  width: max-content;
  min-width: 100%;
}

.pdf-page-wrapper {
  position: relative;
  background: var(--color-white);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.15);
  line-height: 0;
  max-width: 100%;
  overflow: hidden;
}

.pdf-page-wrapper.pdf-page--zoomed {
  max-width: none;
  flex-shrink: 0;
}

.pdf-page-wrapper canvas {
  display: block;
  /* width (not max-width): a canvas rendered BELOW css size under the
     windowed canvas budget (renderPageCanvas) must still fill the page box. */
  width: 100%;
  height: auto;
}

/* Text layer for search highlight. Built once at the open-time scale and
   scaled as a UNIT on zoom/resize (transform from the top-left corner), so the
   search spans follow the re-rendered canvas without being repositioned. */
.pdf-text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.3;
  transform-origin: 0 0;
  line-height: 1;
}

.pdf-text-layer span {
  color: transparent;
  position: absolute;
  white-space: pre;
  transform-origin: 0% 0%;
  cursor: text;
}

.pdf-text-layer .search-highlight {
  background: #ffff00;
  border-radius: 2px;
}

.pdf-text-layer .search-highlight-active {
  background: #ff8c00;
}

/* ── Responsive — Tablet (<= 768px) ── */

@media (max-width: 768px) {
  .online-banner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .pdf-toolbar-title {
    max-width: 140px;
  }

  .pdf-search-nav {
    width: 44px;
    height: 44px;
    font-size: 0.9375rem;
  }
}

/* ── Responsive — Mobile (≤ 480px) ── */

@media (max-width: 480px) {
  .offline-header {
    padding: 0 0.75rem;
    height: 56px;
    gap: 0.5rem;
  }

  .offline-header img {
    height: 30px;
  }

  .offline-header-title {
    font-size: 1rem;
  }

  .offline-card {
    padding: 1.5rem 1.25rem;
  }

  .offline-icon {
    font-size: 2.5rem;
  }

  .offline-card h1 {
    font-size: 1.25rem;
  }

  .reports-main {
    padding: 1rem 0.75rem;
  }

  .reports-title-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .reports-title-bar h1 {
    font-size: 1.125rem;
  }

  .report-card {
    padding: 1rem;
  }

  .report-card-meta {
    flex-direction: column;
    gap: 0.25rem;
  }

  .report-card-actions {
    flex-direction: column;
  }

  .report-card-actions .btn,
  .report-card-actions .btn-sm,
  .report-card-actions .btn-danger-sm {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* ── PDF Viewer Mobile ── */
  .pdf-viewer-toolbar {
    height: 48px;
    padding: 0 0.25rem;
  }

  .pdf-toolbar-btn {
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }

  .pdf-toolbar-title {
    max-width: 100px;
    font-size: 0.75rem;
  }

  .pdf-page-info {
    font-size: 0.6875rem;
    padding: 0 0.25rem;
  }

  .pdf-toolbar-right {
    gap: 0;
  }

  .pdf-search-bar {
    padding: 0.375rem 0.5rem;
  }

  .pdf-search-input-wrap input {
    font-size: 1rem; /* prevent iOS zoom on focus */
  }

  .pdf-viewer-content {
    padding: 0.375rem 0;
  }

  .pdf-pages {
    gap: 0.25rem;
  }
}

/* ── Responsive — Small phones (≤ 360px) ── */

@media (max-width: 360px) {
  .offline-header-badge {
    padding: 0.1875rem 0.5rem;
    font-size: 0.6875rem;
  }

  .offline-card h1 {
    font-size: 1.125rem;
  }

  .offline-card p {
    font-size: 0.875rem;
  }

  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }

  .pdf-toolbar-title {
    max-width: 80px;
    font-size: 0.6875rem;
  }

  .report-card-title {
    font-size: 0.9375rem;
  }
}

/* PDF viewer toolbar at phone widths (2026-09-26) — MIRROR of the report
   viewer toolbar block in dashboard.css (keep the two identical). The zoom
   controls (2026-09-02) made the single row ~414px wide at its 44px phone
   targets, so Next page was painted off-screen on 320–390px phones.
   Every width: the Back button may shrink to its 44px target (title
   ellipsises) — inert wherever the row fits. ≤560px: TWO rows — Back + title
   + page count, then the seven controls spread across the width, each ≥44px;
   .pdf-toolbar-right is display: contents (DOM/focus order unchanged) and its
   ::before is the row break. Nothing hidden, no font changes. */
.pdf-viewer-toolbar > .pdf-toolbar-btn {
  min-width: 44px;
}

@media (max-width: 560px) {
  .pdf-viewer-toolbar {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 0 0.25rem;
  }

  .pdf-toolbar-right {
    display: contents;
  }

  .pdf-viewer-toolbar > .pdf-toolbar-btn {
    flex: 1 1 0;
    min-height: 44px;
    justify-content: flex-start;
  }

  .pdf-toolbar-title {
    max-width: none;
  }

  .pdf-page-info {
    order: 1;
  }

  .pdf-toolbar-right::before {
    content: "";
    order: 2;
    flex-basis: 100%;
  }

  .pdf-toolbar-right > .pdf-toolbar-btn {
    order: 3;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }

  .pdf-zoom-level {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
}

/* Offline vault modal (Option B) — setup + unlock (CSP-safe, built in JS).
   MIRROR of the block in dashboard.css — keep the two identical (pinned).
   Mobile/PWA (2026-09-02): the overlay scrolls and is safe-area padded; the
   dialog is capped to the VISIBLE viewport (dvh) and scrolls internally;
   `margin: auto` centres it when it fits and top-anchors it (scrollable) when
   it does not, so no content is ever trapped above/below the viewport; the
   action row sticks to the bottom of the dialog's scroll area so Save/Cancel
   (and the passkey/passphrase choices' Cancel) stay reachable. */
.vault-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-start; justify-content: center; z-index: 1000;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: max(1rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px)); }
.vault-modal { background: #fff; color: #1f2937; border-radius: 10px; max-width: 420px; width: 100%;
  padding: 1.25rem 1.25rem 0; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  box-sizing: border-box; margin: auto; display: flex; flex-direction: column;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.vault-modal-title { margin: 0 0 0.5rem; font-size: 1.1rem; }
.vault-modal-notes { margin: 0 0 0.75rem 1.1rem; padding: 0; font-size: 0.85rem; color: #4b5563; }
.vault-modal-notes li { margin: 0.15rem 0; }
.vault-modal label { display: block; margin: 0.5rem 0 0.2rem; font-size: 0.85rem; font-weight: 600; }
.vault-modal input { width: 100%; padding: 0.55rem 0.6rem; border: 1px solid #d1d5db; border-radius: 6px; box-sizing: border-box; }
.vault-modal-error { color: #b91c1c; font-size: 0.85rem; margin: 0.5rem 0 0; }
.vault-modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem;
  position: sticky; bottom: 0; background: #fff; padding: 0.75rem 0 1rem; }
.vault-modal > :last-child:not(.vault-modal-actions):not(.passkey-modal-actions) { padding-bottom: 1rem; }
.vault-modal-actions .btn, .passkey-modal-actions .btn { min-height: 44px; }

/* Reduced motion (quality floor) — the offline pages are standalone and do
   not load styles.css, so they carry their own block. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ── F-100 Offline Passkey UI (setup / unlock / reset) ─────────────────────────
   Component styling layered on the existing .vault-modal / .vault-modal-overlay
   shell. Mobile-first: cards stack, buttons go full width and wrap on narrow
   screens; theme accent #7b2d8e. */
.passkey-modal .passkey-modal-body { margin-top: 0.5rem; }
.passkey-choice-card {
  border: 1px solid #e0d6e6;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.85rem;
  background: #faf7fc;
}
.passkey-choice-title { margin: 0 0 0.35rem; font-size: 1rem; font-weight: 600; color: #4a2557; }
.passkey-choice-desc { margin: 0 0 0.75rem; color: #444; font-size: 0.9rem; line-height: 1.4; }
.passkey-choice-hint { margin: 0 0 0.5rem; color: #6b5b73; font-size: 0.82rem; line-height: 1.35; }
.passkey-select-wrap { margin-bottom: 0.75rem; }
.passkey-modal-status { margin: 0.6rem 0 0; min-height: 1.2em; font-size: 0.88rem; color: #4a2557; }
.passkey-modal-status--error { color: #b3261e; }
.passkey-modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-top: 0.75rem;
  position: sticky; bottom: 0; background: #fff; padding: 0.6rem 0 0.75rem; }
.passkey-modal .passkey-modal-status { padding-bottom: 1rem; }
.passkey-progress-line, .passkey-unlock-line, .passkey-success-line { margin: 0 0 0.6rem; color: #333; font-size: 0.92rem; line-height: 1.45; }
.passkey-warning-line {
  margin: 0.5rem 0 0.75rem; padding: 0.6rem 0.75rem;
  background: #fff6e6; border: 1px solid #f0d9a8; border-radius: 6px;
  color: #6b4e00; font-size: 0.86rem; line-height: 1.4;
}
.passkey-progress-spinner {
  width: 34px; height: 34px; margin: 0.5rem auto; border-radius: 50%;
  border: 3px solid #e0d6e6; border-top-color: #7b2d8e;
  animation: passkeySpin 0.9s linear infinite;
}
@keyframes passkeySpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .passkey-progress-spinner { animation: none; } }
.passkey-modal .btn-block { display: block; width: 100%; margin-top: 0.4rem; }
@media (max-width: 480px) {
  .passkey-modal-actions .btn-inline { flex: 1 1 auto; }
}

/* F-100 — device-specific offline notice (INFORMATIONAL, not a warning/error).
   Shown above the Passkey/passphrase choice; blue info accent, device-agnostic. */
.passkey-notice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.85rem;
  background: #eef4fb;
  border: 1px solid #cfe0f2;
  border-left: 4px solid #2f6fb0;
  border-radius: 6px;
}
.passkey-notice-icon { color: #2f6fb0; font-size: 1.05rem; line-height: 1.4; flex: 0 0 auto; margin-top: 0.05rem; }
.passkey-notice-content { min-width: 0; }
.passkey-notice-title { display: block; color: #234b73; font-size: 0.92rem; margin-bottom: 0.25rem; }
.passkey-notice-text { margin: 0 0 0.4rem; color: #33475b; font-size: 0.84rem; line-height: 1.4; }
.passkey-notice-text:last-child { margin-bottom: 0; }

/* Mobile form-control zoom guard — MIRROR of the block at the end of
   src/public/css/styles.css (the standalone offline pages load only this
   stylesheet). Keep the two blocks identical; see styles.css for rationale. */
@media (max-width: 768px), (pointer: coarse) and (max-width: 1024px) {
  input:not(.regid-input):not(.form-input-code),
  select,
  textarea {
    font-size: max(16px, 1em) !important;
  }
}

/* A page whose canvas is outside the render window (lazy/released) — mirrors
   .rv-page-pending in dashboard.css. */
.pdf-page-wrapper.pdf-page-pending {
  background: linear-gradient(180deg, #fafafa 0%, #f3f4f6 100%);
}

/* ── Non-printable offline report viewer (mirrors dashboard.css F-104) ──────
   While a report is open (body.report-viewer-open, toggled by offlineApp.js),
   print media shows ONLY the notice: direct Ctrl+P / browser-menu Print can
   never expose report canvases or the transparent .pdf-text-layer search
   text. Offline Access has NO authorised Print Report flow — controlled
   offline printing requires separate review if operationally required. */
.rv-print-blocked-notice {
  display: none;
}
@media print {
  body.report-viewer-open > * {
    display: none !important;
  }
  body.report-viewer-open .rv-print-blocked-notice {
    display: block !important;
    padding: 2rem;
    font-size: 14pt;
    color: #111827;
  }
}
