/* FamilyCase Client Portal — base styles
 * Mobile-first, 7-surface clean rule, separate from attorney chrome.
 * Tokens layered on top of /tokens.css (firm-wide).
 */

:root {
  --portal-ink: var(--fc-text-default, #1a1a1a);
  --portal-ink-soft: var(--fc-color-neutral-600, #444);
  --portal-ink-muted: var(--fc-text-muted, #666);
  --portal-bg: var(--fc-surface-canvas, #fafaf7);
  --portal-surface: var(--fc-surface-raised, #fff);
  --portal-border: var(--fc-border-default, #e5e5df);
  --portal-border-strong: var(--fc-border-strong, #d4d4d0);
  --portal-navy: var(--fc-color-neutral-900, #0b1530);
  --portal-navy-soft: #1a2547;
  --portal-good: var(--fc-color-success-700, #0F6E56);
  --portal-good-soft: var(--fc-color-success-50, #E1F5EE);
  --portal-good-line: #9FE1CB;
  --portal-warn: var(--fc-color-warning-700, #BA7517);
  --portal-warn-soft: var(--fc-color-warning-50, #FAEEDA);
  --portal-warn-line: #FAC775;
  --portal-danger: var(--fc-color-danger-700, #791F1F);
  --portal-danger-soft: var(--fc-color-danger-50, #FCEBEB);
  --portal-danger-line: #F7C1C1;
  --portal-ai: var(--fc-color-brand-500, #534AB7);
  --portal-ai-soft: var(--fc-color-brand-50, #EEEDFE);
  --portal-ai-line: var(--fc-color-brand-100, #AFA9EC);
  --portal-info: var(--fc-color-info-700, #0C447C);
  --portal-info-soft: var(--fc-color-info-50, #E6F1FB);
  --portal-info-line: #B5D4F4;
  /* FC-UX-054: one-off surface/ink colors promoted to tokens so high-contrast
   * mode can re-theme them and every enumerated hex resolves through --portal-*. */
  --portal-chip-bg: #f1efe8;         /* neutral chip / phase-step / stat surface */
  --portal-hover-bg: #f4f3ed;        /* nav item / row hover surface */
  --portal-badge-red: #E24B4A;       /* unread / notification badge */
  --portal-ai-ink: #3C3489;          /* AI text on --portal-ai-soft */
  --portal-warn-ink: #412402;        /* dark ink on --portal-warn-line */
  --portal-warn-ink-strong: #633806; /* warn chip / nav-warn text */
  --portal-on-navy: #fff;            /* foreground on --portal-navy surfaces */
  --portal-on-navy-muted: #a8b2c8;   /* muted foreground on --portal-navy surfaces */
  --portal-other-soft: #FBEAF0;      /* "other party" parenting-schedule cell surface */
  --portal-other-ink: #72243E;       /* "other party" parenting-schedule cell ink */
  --portal-chart-magenta: #D4537E;   /* billing cost-category chart series */
  --portal-unread-soft: #FAFAFF;     /* unread notification row surface */
  --portal-radius: var(--fc-radius-lg, 9px);
  --portal-radius-lg: var(--fc-radius-xl, 12px);
  --portal-shadow: var(--fc-shadow-xs, 0 0 0 0.5px rgba(0,0,0,0.06));
  --portal-touch: 44px;
  --portal-tap: 36px;
  --portal-gutter: 14px;
  --portal-side-w: 200px;
  --portal-tabbar-h: 64px;
  --portal-mobile-header-h: 52px;
  /* Modal scrim: dialog backdrop dim. Token shared by showConfirmModal
   * and any future portal dialog so the dim level is design-managed,
   * not inlined as a raw rgba(). */
  --fc-overlay-scrim: rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--portal-bg);
  color: var(--portal-ink);
  font-family: var(--fc-font-sans, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--portal-navy); color: #fff;
  padding: 8px 12px; border-radius: 0 0 6px 0;
  font-size: 13px; z-index: 1000;
}
.skip-link:focus { left: 0; }

/* Screen-reader-only clip utility (FC-UX-045). Used by the dedicated
 * aria-live status region so announcements are not visually rendered. */
.portal-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- LAYOUT ---- */

.portal-grid {
  display: grid;
  grid-template-columns: var(--portal-side-w) 1fr;
  min-height: 100vh;
}
@supports (height: 100dvh) {
  .portal-grid {
    min-height: 100dvh;
  }
}

.portal-sidebar {
  background: var(--portal-surface);
  border-right: 0.5px solid var(--portal-border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
@supports (height: 100dvh) {
  .portal-sidebar {
    height: 100dvh;
  }
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 14px;
  border-bottom: 0.5px solid var(--portal-border);
  margin-bottom: 8px;
}
.portal-firm-logo,
.portal-firm-logo-sm {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: var(--portal-navy);
  color: #fff;
  font-weight: 500;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.portal-firm-logo-sm { width: 26px; height: 26px; font-size: 10px; border-radius: 6px; }
.portal-brand-text strong { display: block; font-size: 13px; font-weight: 500; }
.portal-brand-text small { font-size: 10.5px; color: var(--portal-ink-muted); }

.portal-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.portal-nav-item {
  appearance: none;
  background: transparent;
  border: none;
  text-align: left;
  color: var(--portal-ink-soft);
  font-size: 13px;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
  min-height: var(--portal-tap);
  position: relative;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.portal-nav-item:hover { background: var(--portal-hover-bg); }
.portal-nav-item[aria-current="page"] {
  background: var(--portal-navy);
  color: #fff;
}
.portal-nav-item[aria-current="page"] .portal-nav-icon { color: #fff; }
.portal-nav-warn {
  background: var(--portal-warn-soft);
  color: var(--portal-warn-ink-strong);
  font-weight: 500;
}
.portal-nav-warn:hover { background: #f8e5c0; }
.portal-nav-icon { font-size: 15px; color: var(--portal-ink-muted); flex-shrink: 0; }
.portal-nav-label { flex: 1; }
.portal-nav-badge {
  background: var(--portal-badge-red);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 6px;
  font-weight: 500;
  min-width: 18px;
  text-align: center;
}
.portal-nav-bottom { margin-top: auto; }

/* ---- MAIN ---- */

.portal-main {
  padding: 18px 22px 90px;
  max-width: 1100px;
  width: 100%;
}

.portal-loading {
  padding: 60px 0;
  color: var(--portal-ink-muted);
  text-align: center;
  font-size: 13px;
}

/* ---- BREADCRUMB BAR ---- */

#portal-breadcrumb-bar:empty,
#portal-breadcrumb-bar[hidden] { display: none; }

.portal-breadcrumb-nav {
  padding: 0 0 6px;
}

.portal-breadcrumb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 0;
  font-size: 13px;
  line-height: 1.3;
  color: var(--portal-ink-muted);
}

.portal-breadcrumb-item {
  display: flex;
  align-items: center;
  min-width: 0;
}

.portal-breadcrumb-link {
  background: none;
  border: none;
  padding: 2px 0;
  margin: 0;
  font: inherit;
  font-size: 13px;
  color: var(--portal-info);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.portal-breadcrumb-link:hover { text-decoration: underline; }
.portal-breadcrumb-link:focus-visible {
  outline: 2px solid var(--portal-info);
  outline-offset: 2px;
  border-radius: 2px;
}

.portal-breadcrumb-sep {
  margin: 0 6px;
  color: var(--portal-ink-muted);
  flex-shrink: 0;
  font-size: 11px;
}

.portal-breadcrumb-current {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
  color: var(--portal-ink);
  font-weight: 500;
}

/* ---- BACK BUTTON (mobile header) ---- */

.portal-back-btn {
  background: transparent;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  color: var(--portal-ink);
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.portal-back-btn:hover { background: var(--portal-hover-bg); }
.portal-back-btn:focus-visible {
  outline: 2px solid var(--portal-info);
  outline-offset: 2px;
}

/* ---- SHARED KEYBOARD FOCUS RING (FC-UX-046) ----
 * One visible focus-visible outline across every interactive surface:
 * nav, tabs, filter pills, buttons, the FAB, sheet rows, and switch toggles.
 * Uses the --portal-info token (no raw colors). A light variant keeps the
 * ring legible where the control sits on the navy / purple (AI) backgrounds.
 */
.portal-nav-item:focus-visible,
.portal-nav-warn:focus-visible,
.portal-tab:focus-visible,
.portal-more-btn:focus-visible,
.portal-bell-btn:focus-visible,
.pill:focus-visible,
.btn:focus-visible,
.portal-sheet-row:focus-visible,
.tog:focus-visible {
  outline: 2px solid var(--portal-info);
  outline-offset: 2px;
}
/* Light ring on dark/branded backgrounds so it stays visible. */
.portal-fab:focus-visible,
.portal-nav-item[aria-current="page"]:focus-visible,
.btn-primary:focus-visible,
.btn-approve:focus-visible,
.pill.ai:focus-visible,
.card.dark .btn:focus-visible {
  outline: 2px solid var(--portal-info-soft);
  outline-offset: 2px;
}

/* ---- MOBILE HEADER + TAB BAR (hidden on desktop) ---- */

.portal-mobile-header,
.portal-tab-bar { display: none; }

.portal-mobile-header {
  position: sticky;
  top: 0;
  background: var(--portal-surface);
  border-bottom: 0.5px solid var(--portal-border);
  padding: 0 12px;
  height: var(--portal-mobile-header-h);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 100;
}
.portal-more-btn,
.portal-bell-btn {
  background: transparent;
  border: none;
  width: 38px; height: 38px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  color: var(--portal-ink);
  position: relative;
}
.portal-more-btn:hover,
.portal-bell-btn:hover { background: var(--portal-hover-bg); }
.portal-firm-tag { display: flex; align-items: center; gap: 8px; }
.portal-firm-name { font-size: 13px; font-weight: 500; }
.portal-bell-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--portal-badge-red);
  border-radius: 50%;
}

.portal-tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--portal-surface);
  border-top: 0.5px solid var(--portal-border);
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: center;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  height: var(--portal-tabbar-h);
  z-index: 100;
}
.portal-tab {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10.5px;
  color: var(--portal-ink-muted);
  cursor: pointer;
  font-family: inherit;
  padding: 4px 0;
  position: relative;
}
.portal-tab[aria-current="page"] { color: var(--portal-navy); }
.portal-tab-icon { font-size: 17px; }
.portal-tab-badge {
  position: absolute;
  top: 2px;
  right: 18%;
  background: var(--portal-badge-red);
  color: #fff;
  border-radius: 999px;
  font-size: 9px;
  padding: 0 5px;
  font-weight: 500;
  min-width: 16px;
  text-align: center;
}
.portal-fab {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--portal-ai);
  color: #fff;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(83, 74, 183, 0.4);
  margin-top: -22px;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
}
.portal-fab:active { transform: scale(0.95); }

/* ---- SHEETS (FAB target) ---- */

.portal-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(11, 21, 48, 0.45);
  z-index: 200;
  animation: portalFade 0.15s ease;
}
.portal-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--portal-surface);
  border-radius: 16px 16px 0 0;
  padding: 14px 18px max(20px, env(safe-area-inset-bottom));
  z-index: 201;
  animation: portalSlideUp 0.2s ease;
  max-width: 540px;
  margin: 0 auto;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.18);
}
.portal-sheet-grabber {
  width: 36px; height: 4px;
  background: var(--portal-border-strong);
  border-radius: 99px;
  margin: 0 auto 10px;
}
.portal-sheet-title {
  font-size: 14px;
  font-weight: 500;
  margin: 0 0 12px;
}
.portal-sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--portal-surface);
  border: 0.5px solid var(--portal-border);
  border-radius: 9px;
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--portal-ink);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  margin-bottom: 8px;
  min-height: var(--portal-touch);
}
.portal-sheet-row span { font-size: 17px; }
.portal-sheet-row:hover { background: var(--portal-hover-bg); }

@keyframes portalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes portalSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---- PRIVACY STRIP ---- */

.portal-privacy-strip {
  position: fixed;
  left: var(--portal-side-w);
  right: 0;
  bottom: 0;
  background: var(--portal-bg);
  border-top: 0.5px solid var(--portal-border);
  padding: 8px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--portal-ink-muted);
  z-index: 50;
}
.portal-link {
  background: transparent;
  border: none;
  color: var(--portal-info);
  font-size: inherit;
  cursor: pointer;
  padding: 0 4px;
  font-weight: 500;
  font-family: inherit;
}

/* ---- NEXT-EVENT STICKY CHIP ---- */

.portal-next-event-chip {
  position: fixed;
  bottom: calc(var(--portal-tabbar-h) + 12px);
  left: 50%; transform: translateX(-50%);
  background: var(--portal-warn-line);
  color: var(--portal-warn-ink);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ---- SHARED COMPONENTS ----
 * Reusable bits: page-section, ai-mini, cards, etc.
 * Per-page styles can live inline or in pages/<page>.css if they grow.
 */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 0.5px solid var(--portal-border);
  margin-bottom: 16px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.page-header p {
  font-size: 13.5px;
  color: var(--portal-ink-muted);
  margin: 0;
}

.section { margin-bottom: 14px; }

.card {
  background: var(--portal-surface);
  border: 0.5px solid var(--portal-border);
  border-radius: var(--portal-radius);
  padding: 14px 16px;
}
.card.dark { background: var(--portal-navy); color: #fff; }
.card.warn { border: 1px solid var(--portal-warn); background: #FFFBF0; padding: 10px 14px; }
.card.ai { border: 1px solid var(--portal-ai-line); box-shadow: 0 0 0 3px rgba(175,169,236,0.10); }
.card.good { background: var(--portal-good-soft); border-color: var(--portal-good-line); }

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
}
.card-sub { font-size: 12px; color: var(--portal-ink-muted); margin: 0; }

/* AI mini prompt */
.ai-mini {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--portal-surface);
  border: 1px solid var(--portal-ai-line);
  border-radius: 9px;
  padding: 7px 10px;
  box-shadow: 0 0 0 3px rgba(175,169,236,0.10);
  min-width: 280px;
}
.ai-mini input {
  flex: 1;
  border: none;
  outline: none;
  font: inherit;
  font-size: 13px;
  background: transparent;
  color: var(--portal-ink);
}
.ai-mini .ai-scope-pill {
  background: var(--portal-ai-soft);
  color: var(--portal-ai-ink);
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 500;
}
.ai-mini .ai-send {
  background: var(--portal-ai);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 0.5px solid var(--portal-border-strong);
  background: var(--portal-surface);
  color: var(--portal-ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  min-height: 34px;
}
.btn-primary { background: var(--portal-navy); color: #fff; border-color: var(--portal-navy); }
.btn-approve { background: var(--portal-good); color: #fff; border-color: var(--portal-good); }
.btn-danger { background: var(--portal-danger-soft); color: var(--portal-danger); border-color: var(--portal-danger-line); }
.btn-ghost { background: transparent; border: 0.5px solid transparent; }
.btn-ai { background: var(--portal-ai-soft); color: var(--portal-ai-ink); border-color: var(--portal-ai-line); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--portal-chip-bg);
  color: var(--portal-ink-soft);
  font-weight: 500;
}
.pill.good { background: var(--portal-good-soft); color: #04342C; }
.pill.warn { background: var(--portal-warn-soft); color: var(--portal-warn-ink-strong); }
.pill.danger { background: var(--portal-danger-soft); color: var(--portal-danger); }
.pill.info { background: var(--portal-info-soft); color: var(--portal-info); }
.pill.ai { background: var(--portal-ai-soft); color: var(--portal-ai-ink); }

/* Slot chips (scheduling card) */
.slot-chip { display:inline-block; padding:4px 10px; border:1px solid var(--fc-border); border-radius:16px; font-size:11px; cursor:pointer; margin:4px 4px 0 0 }
.slot-chip:hover { background:var(--portal-info-soft); border-color:var(--portal-info-line) }

/* Stat tile */
.stat {
  background: var(--portal-surface);
  border: 0.5px solid var(--portal-border);
  border-radius: var(--portal-radius);
  padding: 11px 12px;
}
.stat .lbl { font-size: 11px; color: var(--portal-ink-muted); display: block; margin-bottom: 2px; }
.stat .val { font-size: 20px; font-weight: 500; line-height: 1.1; }
.stat .sub { font-size: 11px; color: var(--portal-ink-muted); display: block; margin-top: 2px; }
.stat.good .val { color: var(--portal-good); }
.stat.warn .val { color: #854F0B; }
.stat.danger .val { color: var(--portal-danger); }

/* Toggle (reactive input) */
.tog {
  width: 32px; height: 18px;
  background: var(--portal-border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
  display: inline-block;
  /* Reset so a real <button role="switch" class="tog"> matches the legacy
   * <span> styling exactly (FC-UX-042). */
  padding: 0;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
}
/* Drive on-state from aria-checked when the toggle is a real switch button,
 * keeping the legacy .on class working for static markup. */
.tog[aria-checked="true"] { background: var(--portal-good); }
.tog[aria-checked="true"]::after { left: 16px; }
.tog::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.15s ease;
}
.tog.on { background: var(--portal-good); }
.tog.on::after { left: 16px; }

/* Reactive input shell */
.input-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--portal-surface);
  border: 0.5px solid var(--portal-border-strong);
  border-radius: 8px;
  padding: 0 12px;
  height: 38px;
}
.input-shell.valid { border-color: var(--portal-good); box-shadow: 0 0 0 2px rgba(29,158,117,0.12); }
.input-shell.invalid { border-color: var(--portal-danger); }
.input-shell input {
  flex: 1;
  border: none;
  outline: none;
  font: inherit;
  font-size: 14px;
  background: transparent;
}

/* ---- RESPONSIVE ---- */

@media (max-width: 1023px) {
  :root { --portal-side-w: 64px; }
  .portal-nav-label,
  .portal-brand-text,
  .portal-nav-bottom .portal-nav-label { display: none; }
  .portal-brand { justify-content: center; padding: 8px 4px; }
  .portal-nav-item { justify-content: center; padding: 10px 0; }
  .portal-nav-badge {
    position: absolute; top: 4px; right: 8px;
    min-width: 14px; font-size: 9px; padding: 0 4px;
  }
  .portal-privacy-strip { left: var(--portal-side-w); padding-left: 14px; padding-right: 14px; }
}

@media (max-width: 767px) {
  :root { --portal-side-w: 0px; }
  .portal-sidebar { display: none; }
  .portal-mobile-header { display: flex; }
  .portal-tab-bar { display: grid; }
  .portal-grid { grid-template-columns: 1fr; }
  .portal-main {
    padding: 14px 14px calc(var(--portal-tabbar-h) + 24px);
  }
  .portal-privacy-strip {
    left: 0;
    bottom: var(--portal-tabbar-h);
    font-size: 10.5px;
    padding: 6px 12px;
  }
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .ai-mini { min-width: 0; width: 100%; }

  /* Back button: visible on mobile when not [hidden] */
  .portal-back-btn:not([hidden]) { display: flex; }

  /* Breadcrumb: tighter truncation on mobile */
  .portal-breadcrumb-link { max-width: 120px; }
  .portal-breadcrumb-current { max-width: 150px; }
  .portal-breadcrumb-list { font-size: 12px; }
  .portal-breadcrumb-link { font-size: 12px; }

  /* iOS input zoom prevention (must be >= 16px) */
  input, textarea, select { font-size: 16px !important; }
}

/* Privacy mode — applied via JS toggling [data-privacy-mode="on"] on body */
body[data-privacy-mode="on"] .portal-main { filter: blur(0); }
body[data-privacy-mode="on"] .portal-main img,
body[data-privacy-mode="on"] .doc-thumb,
body[data-privacy-mode="on"] .preview-text { filter: blur(8px); }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast / large text data-attr overrides for accessibility */
body[data-large-text="on"] { font-size: 17px; }
body[data-large-text="on"] .page-header h1 { font-size: 24px; }
body[data-high-contrast="on"] {
  --portal-ink: #000;
  --portal-ink-muted: #333;
  --portal-border: #888;
  --portal-border-strong: #555;
  /* FC-UX-054: re-theme the previously-hardcoded surfaces so high-contrast
   * mode visibly re-colors them (they now flow through --portal-* tokens). */
  --portal-chip-bg: #fff;
  --portal-hover-bg: #eaeaea;
  --portal-badge-red: #c50000;
  --portal-ai-ink: #14104a;
  --portal-warn-ink: #000;
  --portal-warn-ink-strong: #000;
  --portal-on-navy-muted: #dfe6f2;
  --portal-other-soft: #fff;
  --portal-other-ink: #000;
  --portal-chart-magenta: #a01050;
  --portal-unread-soft: #e6efff;
}

/* Plain-language mode — applied via JS toggling [data-plain-language="on"] on
 * body. Content marked [data-plain-hide] (legalese / secondary detail) is
 * suppressed and its plain-language alternate [data-plain-show] is revealed, so
 * a screen can carry both a legal phrasing and a plain phrasing and switch
 * between them with zero markup change. Default (mode off) shows the standard
 * copy and keeps the plain alternate hidden. */
[data-plain-show] { display: none; }
body[data-plain-language="on"] [data-plain-hide] { display: none; }
body[data-plain-language="on"] [data-plain-show] { display: revert; }

/* ---- PHASE BAR ---- */
.portal-phase-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 10px 0;
}
.portal-phase-step {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 4px;
  border-radius: 4px;
  background: var(--portal-chip-bg);
  color: var(--portal-ink-muted);
  position: relative;
}
.portal-phase-step.completed {
  background: var(--portal-good-soft);
  color: var(--portal-good);
}
.portal-phase-step.active {
  background: var(--portal-navy);
  color: #fff;
}
/* FC-UX-050: the phase label and its description must stack, not collide.
 * Force the description <small> onto its own line under the label. */
.portal-phase-step small {
  display: block;
  font-weight: 400;
  opacity: 0.75;
  margin-top: 2px;
}

/* ---- STATUS CHIPS (document cards) ---- */
.portal-status-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 999px;
}
.portal-status-chip.neutral {
  background: var(--portal-chip-bg);
  color: var(--portal-ink-soft);
}
.portal-status-chip.warn {
  background: var(--portal-warn-soft);
  color: var(--portal-warn-ink-strong);
}
.portal-status-chip.good {
  background: var(--portal-good-soft);
  color: var(--portal-good);
}
.portal-status-chip.danger {
  background: var(--portal-danger-soft);
  color: var(--portal-danger);
}

/* ---- DOCUMENT THUMBNAIL ---- */
.doc-thumb {
  width: 60px;
  height: 80px;
  background: var(--fc-surface-2, #f8f8f8);
  border: 1px solid var(--fc-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

/* ---- DOCUMENT TILE (home page) ---- */
.portal-doc-tile {
  border: 0.5px solid var(--portal-border);
  border-radius: 6px;
  padding: 8px 10px;
}
.portal-doc-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.portal-doc-icon {
  font-size: 15px;
}

/* ---- DISCLAIMER INLINE ICON ---- */
.portal-disclaimer-inline {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.portal-disclaimer-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
}
.portal-disclaimer-icon:hover { background: var(--portal-good-soft); }
.portal-disclaimer-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--portal-good-soft);
  color: #04342C;
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 11.5px;
  line-height: 1.4;
  width: 300px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 10;
}
.portal-disclaimer-body {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 0.5px solid var(--portal-good-line);
}
.portal-text-link-ai {
  font-size: 12px;
  font-weight: 500;
  color: var(--portal-ai-ink);
  text-decoration: none;
}
.portal-text-link-ai:hover { text-decoration: underline; }

/* ---- CONTACT CARD (legal team) ---- */
.portal-contact-card {
  background: var(--portal-surface);
}
.portal-contact-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.portal-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--portal-navy);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.portal-contact-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.portal-contact-info strong {
  font-size: 14px;
}
.portal-contact-info small {
  font-size: 12px;
}

/* ---- TAB BAR: ensure hidden on desktop (>= 768px) ---- */
@media (min-width: 768px) {
  .portal-tab-bar {
    display: none !important;
  }
}

/* IOLTA disclosure (draft) — client trust account plain-English summary */
.iolta-disclosure { border: 0.5px solid var(--portal-border); border-radius: 8px; padding: 10px 14px; background: #fff; }
.iolta-disclosure summary { cursor: pointer; font-weight: 600; padding: 4px 0; margin-bottom: 6px; }
.iolta-disclosure[open] summary { margin-bottom: 10px; }
.iolta-draft-banner {
  border: 1px solid #b91c1c;
  background: #fee2e2;
  color: #7f1d1d;
  padding: 12px;
  font-weight: 700;
  border-radius: 6px;
  margin-bottom: 12px;
}
.iolta-disclosure-body p { font-size: 13px; line-height: 1.55; margin: 0 0 10px 0; color: var(--portal-ink); }

/* ---- SUB-FILTER PILL BAR (Documents page) ---- */
.portal-subfilter-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--portal-surface);
  border: 0.5px solid var(--portal-border);
  border-radius: 9px;
  margin-bottom: 16px;
  width: fit-content;
}
.portal-subfilter-pill {
  appearance: none;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--portal-ink-muted);
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
  min-height: 30px;
}
.portal-subfilter-pill:hover {
  background: var(--portal-hover-bg);
  color: var(--portal-ink);
}
.portal-subfilter-pill.active {
  background: var(--portal-navy);
  color: #fff;
}

/* ---- NAV CLUSTER (Home group with sub-items) ---- */
.portal-nav-cluster {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.portal-nav-sub-item {
  padding-left: 28px;
  font-size: 12px;
}
@media (max-width: 1023px) {
  .portal-nav-sub-item { padding-left: 0; }
}

/* ---- GUIDE TABLE OF CONTENTS ---- */
.portal-guide-toc { display:flex; flex-wrap:wrap; gap:8px; }
.portal-guide-toc a {
  font-size:12.5px;
  padding:5px 10px;
  border-radius:99px;
  background:var(--portal-chip-bg);
  color:var(--portal-ink-soft);
  text-decoration:none;
}
.portal-guide-toc a:hover { background:var(--portal-hover-bg); }

/* ---- EVIDENCE DROP ZONE (enhanced) ---- */
.portal-drop-zone-enhanced { background:var(--portal-info-soft); border:2px dashed var(--portal-info); border-radius:12px; padding:24px; text-align:center; transition:background 0.2s }
.portal-drop-zone-enhanced:hover { background:var(--portal-info-line) }

.portal-action-nudge { font-size:13px; color:var(--fc-info,var(--portal-info)); margin-top:2px; font-weight:500; }

/* ---- WELCOME BANNER ---- */
.portal-welcome { background: var(--portal-info-soft); border: 1px solid var(--portal-info-line); border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.portal-welcome-dismiss { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--portal-ink-muted); padding: 0 0 0 12px; font-family: inherit; }

/* ---- PORTAL GRID CLASSES ---- */
.portal-billing-summary-5col { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.portal-billing-stats-5col { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.portal-billing-ledger-layout { display: grid; grid-template-columns: 1fr 280px; gap: 14px; }
.portal-billing-ledger-row { display: grid; grid-template-columns: 60px 1fr auto auto; gap: 8px; font-size: 13px; align-items: center; }
.portal-billing-invoice-row { display: grid; grid-template-columns: 60px 1fr auto auto auto; gap: 10px; padding: 8px 0; border-top: 0.5px solid var(--portal-border); font-size: 13px; align-items: center; }
.portal-billing-work-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.portal-billing-progress-row { display: grid; grid-template-columns: 80px 1fr 40px; gap: 5px; font-size: 11.5px; align-items: center; padding: 3px 0; }
.portal-case-status-5col { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 6px 0; }
.portal-case-main-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.portal-case-calendar-7col { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 11px; text-align: center; }
.portal-case-finances-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.portal-profile-dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; margin: 8px 0; }
.portal-profile-edit-form { margin-top: 8px; display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.portal-profile-attorney-card { display: grid; grid-template-columns: 72px 1fr 140px; gap: 18px; }
.portal-profile-detail-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin-top: 10px; font-size: 13px; line-height: 1.4; }
.portal-profile-availability-5col { display: grid; grid-template-columns: 1.4fr repeat(4, 0.7fr); gap: 1px; background: #f0efe9; border-radius: 6px; overflow: hidden; font-size: 12.5px; }
.portal-profile-section-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.portal-messages-2pane { display: grid; grid-template-columns: 200px 1fr; gap: 10px; }
.portal-cal-event-row { display: grid; grid-template-columns: 60px 1fr; gap: 10px; align-items: center; }
.portal-docs-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.portal-docs-grid-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.portal-home-calendar-grid { display: grid; grid-template-columns: 48px 1fr; gap: 8px 12px; font-size: 13px; line-height: 1.4; }
.portal-home-docs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.portal-upload-checklist-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: 13px; }

@media (max-width: 1023px) {
  .portal-billing-summary-5col,
  .portal-billing-stats-5col,
  .portal-case-status-5col { grid-template-columns: repeat(2, 1fr); }
  .portal-billing-ledger-layout,
  .portal-billing-ledger-row,
  .portal-billing-invoice-row,
  .portal-billing-work-layout,
  .portal-billing-progress-row { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .portal-billing-summary-5col,
  .portal-billing-stats-5col,
  .portal-billing-ledger-layout,
  .portal-billing-ledger-row,
  .portal-billing-invoice-row,
  .portal-billing-work-layout,
  .portal-billing-progress-row,
  .portal-case-status-5col,
  .portal-case-main-2col,
  .portal-case-calendar-7col,
  .portal-case-finances-3col,
  .portal-profile-dl,
  .portal-profile-edit-form,
  .portal-profile-attorney-card,
  .portal-profile-detail-2col,
  .portal-profile-availability-5col,
  .portal-profile-section-2col,
  .portal-messages-2pane,
  .portal-cal-event-row,
  .portal-docs-3col,
  .portal-docs-grid-3col,
  .portal-home-calendar-grid,
  .portal-home-docs-grid,
  .portal-upload-checklist-2col { grid-template-columns: 1fr; }
}
