/*
 * Flourish Legal — app shell styles.
 *
 * Palette: deep evergreen + warm cream, with a golden accent that echoes the
 * yellow used on flourishlaw-pllc.com. Headings in Fraunces (soft, organic serif),
 * body in Inter.
 */

:root {
  /* Flourish brand (Ali, #1, 2026-09-16): green #18783C, neutral #F8F8F6, coral #FF8381.
     Coral is held back until her new logo arrives. */
  --coral: #ff8381;

  --green-950: #0a2a15;
  --green-900: #0f4a24;
  --green-800: #18783c;
  --green-700: #166c37;
  --green-600: #2a8a4e;
  --green-100: #dcefe2;
  --green-50: #eef7f1;

  --gold-600: #b27f2c;
  --gold-500: #c9953f;
  --gold-200: #f3d9a4;
  --gold-50: #fbf4e6;

  --cream: #f8f8f6;
  --sand: #efefea;
  --paper: #ffffff;
  --line: #e4e4de;
  --line-strong: #d0d0c8;

  --ink: #1d2826;
  --ink-soft: #3d4a47;
  --muted: #66736f;

  --danger: #a33a2c;
  --danger-bg: #fbece9;

  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 53, 47, 0.06);
  --shadow: 0 1px 2px rgba(20, 53, 47, 0.05), 0 8px 24px rgba(20, 53, 47, 0.07);
  --ring: 0 0 0 3px rgba(201, 149, 63, 0.45);

  --sidebar-w: 276px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--green-700); }
a:hover { color: var(--green-900); }
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; background: var(--paper); color: var(--green-900);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Brand ---------- */

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--cream); text-decoration: none;
}
.brand:hover { color: #fff; }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(243, 217, 164, 0.14);
  color: var(--gold-200);
  box-shadow: inset 0 0 0 1px rgba(243, 217, 164, 0.22);
}
.brand-word {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 600; letter-spacing: -0.01em;
}
.brand-word em { font-style: normal; font-weight: 500; color: var(--gold-200); }
/* The firm's logo (#36). */
.brand-logo { display: block; height: 52px; width: auto; }
.brand-logo--panel { height: 110px; }
.brand-logo--card { height: 56px; }

/* ---------- Shell ---------- */

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

.sidebar {
  position: sticky; top: 0;
  flex: 0 0 var(--sidebar-w);
  align-self: flex-start;
  height: 100vh;
  display: flex; flex-direction: column;
  background: #18783c; /* Ali (#36): a solid brand green, no gradient */
  color: #dfe9e4;
  overflow-y: auto;
}

.sidebar-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 20px 18px;
}

.menu-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, 0.08); color: var(--cream);
  cursor: pointer;
}
.menu-toggle-close { display: none; }

.sidebar-menu { display: flex; flex-direction: column; flex: 1; padding: 4px 12px 20px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav--secondary {
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-heading {
  margin: 16px 12px 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: rgba(223, 233, 228, 0.55);
}

.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #d3e1db; text-decoration: none;
  font-weight: 500; font-size: 14.5px;
  transition: background-color .15s ease, color .15s ease;
}
.nav-link .icon { flex: none; opacity: 0.85; }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link.is-active {
  background: rgba(243, 217, 164, 0.13);
  color: #fff;
}
.nav-link.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--gold-500);
}
.nav-link.is-active .icon { color: var(--gold-200); opacity: 1; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Header ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 36px;
  min-height: 68px;
  background: rgba(250, 247, 242, 0.88);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-firm {
  font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.help-btn {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--green-800);
  font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, background-color .15s ease;
}
.help-btn:hover { border-color: var(--gold-500); background: var(--gold-50); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  min-width: 0;
}
.avatar {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-100); color: var(--green-800);
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--muted); }

.topbar form { margin: 0; }
.signout-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--ink-soft);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
}
.signout-btn:hover { background: var(--sand); color: var(--ink); }

/* ---------- Content ---------- */

.content {
  width: 100%; max-width: 1080px;
  padding: 40px 36px 72px;
  outline: none;
}

.eyebrow {
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--gold-600); margin-bottom: 10px;
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 38px);
  font-weight: 600; letter-spacing: -0.015em;
  color: var(--green-900);
}
.lede { margin-top: 10px; max-width: 62ch; font-size: 16px; color: var(--ink-soft); }

.hero {
  position: relative;
  padding: 36px 36px 34px;
  margin-bottom: 32px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(243, 217, 164, 0.45), transparent 55%),
    linear-gradient(135deg, var(--paper), var(--green-50));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  border: 1px solid rgba(29, 74, 66, 0.08);
  box-shadow: 0 0 0 28px rgba(29, 74, 66, 0.03), 0 0 0 56px rgba(29, 74, 66, 0.02);
  pointer-events: none;
}

.section { margin-top: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--green-900); }
.section-note { font-size: 13.5px; color: var(--muted); }

.module-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}
.module-card {
  display: flex; flex-direction: column; gap: 6px; height: 100%;
  padding: 18px 18px 20px; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.module-card:hover { color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.module-card-icon {
  display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 6px;
  border-radius: 10px; background: var(--green-50); color: var(--green-700);
}
.module-card-title { font-weight: 600; font-size: 15px; color: var(--green-900); }
.module-card-text { font-size: 13.5px; color: var(--muted); line-height: 1.5; }

.page-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 28px; }
.page-icon {
  display: grid; place-items: center; flex: none;
  width: 54px; height: 54px; border-radius: 14px;
  background: var(--green-800); color: var(--gold-200);
  box-shadow: var(--shadow);
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 48px 28px;
  margin-bottom: 28px;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--line-strong);
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, rgba(201, 149, 63, 0.035) 14px 28px),
    var(--paper);
}
.empty-icon {
  display: grid; place-items: center;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--gold-50); color: var(--gold-600);
  box-shadow: inset 0 0 0 1px rgba(201, 149, 63, 0.25);
  margin-bottom: 18px;
}
.empty-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--green-900); }
.empty-text { margin-top: 8px; max-width: 48ch; color: var(--muted); }
.empty-state .btn { margin-top: 20px; }

/* ---------- Flash ---------- */

.flash {
  padding: 12px 16px; margin-bottom: 20px;
  border-radius: var(--radius);
  font-size: 14px;
  border: 1px solid transparent;
}
.flash--notice { background: var(--green-50); border-color: #cfe3d9; color: var(--green-800); }
.flash--alert { background: var(--danger-bg); border-color: #f1cfc8; color: var(--danger); }
.error-list { margin: 0; padding-left: 18px; }

/* ---------- Cards & forms ---------- */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card--flush { padding: 0; overflow: hidden; }
.card-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--green-900); margin-bottom: 16px; }
.card-title--padded { padding: 22px 24px 0; }
.count {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--sand); color: var(--muted); font-family: var(--font-body); font-size: 12px; font-weight: 600;
  vertical-align: middle;
}

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.input {
  width: 100%;
  height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  /* 16px minimum: anything smaller makes iOS Safari zoom the page on focus. */
  font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 19px) 19px, calc(100% - 14px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.input:hover { border-color: var(--green-600); }
.input:focus { outline: none; border-color: var(--gold-500); box-shadow: var(--ring); }

.checkbox { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.checkbox input { width: 17px; height: 17px; accent-color: var(--green-700); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn svg { flex: none; }
.btn--primary { background: var(--green-800); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--green-900); color: #fff; }
.btn--secondary { background: var(--paper); color: var(--green-800); border-color: var(--line-strong); }
.btn--secondary:hover { border-color: var(--green-600); color: var(--green-900); }
.btn--ghost { background: transparent; color: var(--green-700); border-color: var(--line); }
.btn--ghost:hover { background: var(--green-50); border-color: #cfe3d9; }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }

/* ---------- Team ---------- */

.team-layout { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; align-items: start; }

.invite-result {
  margin-bottom: 24px; padding: 20px 22px;
  border-radius: var(--radius-lg);
  background: var(--gold-50);
  border: 1px solid rgba(201, 149, 63, 0.35);
}
.invite-result-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--green-900); }
.invite-result-text { margin-top: 4px; color: var(--ink-soft); font-size: 14px; }
.copy-field { display: flex; gap: 10px; margin-top: 14px; }
.copy-field .input { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; background: var(--paper); }

.people { list-style: none; margin: 12px 0 0; padding: 0; }
.person {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
}
.person-meta { display: flex; flex-direction: column; min-width: 0; flex: 1 1 180px; line-height: 1.3; }
.person-name { font-weight: 600; font-size: 14.5px; }
.person-email { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.person-action { margin: 0; }
/* Team page (#65): removed people and clients' portal logins, folded under the firm's own team. */
.people-group { border-top: 1px solid var(--line); padding: 12px 20px; }
.people-group-title { cursor: pointer; font-weight: 600; font-size: 14.5px; }
.people-group-note { margin: 8px 0 0; }
.people-group .people { margin-top: 4px; }
.role-pill {
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--sand); color: var(--ink-soft);
}
.role-pill--firm_admin { background: var(--green-100); color: var(--green-800); }
.role-pill--build_team { background: var(--gold-50); color: var(--gold-600); box-shadow: inset 0 0 0 1px rgba(201, 149, 63, 0.3); }

/* ---------- Auth ---------- */

.auth-body { background: var(--cream); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.auth-panel {
  position: relative; overflow: hidden;
  display: flex; align-items: flex-end;
  padding: 56px;
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(243, 217, 164, 0.22), transparent 60%),
    radial-gradient(90% 70% at 0% 100%, rgba(58, 122, 102, 0.55), transparent 60%),
    linear-gradient(160deg, var(--green-800), var(--green-950));
  color: var(--cream);
}
.auth-panel::before {
  content: ""; position: absolute; right: -120px; top: -120px;
  width: 420px; height: 420px; border-radius: 50%;
  border: 1px solid rgba(243, 217, 164, 0.18);
  box-shadow: 0 0 0 48px rgba(243, 217, 164, 0.04), 0 0 0 96px rgba(243, 217, 164, 0.025);
}
.auth-panel-inner { position: relative; max-width: 440px; }
.brand--light .brand-word { font-size: 24px; }
.auth-tagline {
  margin-top: 56px;
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(30px, 3.2vw, 44px); line-height: 1.12; letter-spacing: -0.015em;
}
.auth-sub { margin-top: 16px; font-size: 16px; color: rgba(250, 247, 242, 0.75); max-width: 38ch; }

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card {
  width: 100%; max-width: 400px;
  padding: 36px 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.auth-card-brand { display: none; color: var(--green-900); margin-bottom: 24px; }
.auth-card-brand .brand-mark { background: var(--green-800); color: var(--gold-200); box-shadow: none; }
.auth-card-brand .brand-word em { color: var(--gold-600); }
.auth-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--green-900); letter-spacing: -0.01em; }
.auth-lede { margin: 6px 0 24px; color: var(--muted); }
.auth-help { margin-top: 20px; font-size: 13.5px; color: var(--muted); text-align: center; }
.auth-foot { margin-top: 20px; font-size: 12.5px; color: var(--muted); }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .team-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }

  .sidebar {
    position: sticky; top: 0; z-index: 30;
    flex: none; align-self: stretch; height: auto; overflow: visible;
  }
  .sidebar-top { padding: 10px 16px; min-height: 60px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-word { font-size: 19px; }
  .menu-toggle { display: inline-flex; }

  .sidebar-menu {
    display: none;
    position: absolute; left: 0; right: 0; top: 100%;
    max-height: calc(100vh - 60px); overflow-y: auto;
    padding: 8px 12px 16px;
    background: var(--green-900);
    box-shadow: 0 16px 32px rgba(15, 41, 37, 0.3);
  }
  .nav-open .sidebar-menu { display: flex; }
  .nav-open .menu-toggle-open { display: none; }
  .nav-open .menu-toggle-close { display: inline; }
  .sidebar-nav--secondary { margin-top: 10px; }
  .nav-link { padding: 11px 12px; }
  .nav-link.is-active::before { left: -12px; }

  .topbar { position: static; padding: 10px 16px; min-height: 56px; }
  .content { padding: 24px 16px 56px; }
  .hero { padding: 26px 22px; }
  .page-head { gap: 14px; }
  .page-icon { width: 46px; height: 46px; }

  .auth-shell { grid-template-columns: 1fr; }
  .auth-panel { display: none; }
  .auth-card-brand { display: inline-flex; }
}

@media (max-width: 560px) {
  .topbar-firm { display: none; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .user-chip { margin-right: auto; order: -1; }
  .user-role { display: none; }
  .signout-label { display: none; }
  .signout-btn { width: 36px; padding: 0; justify-content: center; }
  .copy-field { flex-direction: column; }
  .auth-card { padding: 28px 22px; }
  .person { padding: 14px 16px; }
  .card-title--padded { padding: 20px 16px 0; }
  .card:not(.card--flush) { padding: 20px 16px; }
  .person-meta { flex-basis: calc(100% - 42px); }
  .person .role-pill { margin-left: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Build Kit: construction entry + module status ---------- */

/* Construction is the build, not a module of the finished platform: hazard yellow, set apart. */
.nav-construction {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  margin: 2px 0 6px;
  padding: 10px 12px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: #fff;
  background: #1e293b;
  border: 1px solid rgba(245, 165, 36, 0.55);
  overflow: hidden;
  transition: border-color .15s ease, transform .15s ease;
}
.nav-construction::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: repeating-linear-gradient(135deg, #f5a524 0 8px, #1e293b 8px 16px);
}
.nav-construction:hover { border-color: #f5a524; }
.nav-construction.is-active { border-color: #f5a524; box-shadow: 0 0 0 2px rgba(245, 165, 36, 0.35); }
.nav-construction-icon {
  flex: none; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: #f5a524; color: #1e293b;
}
.nav-construction-icon svg { width: 24px; height: 24px; }
.nav-construction-text { display: flex; flex-direction: column; min-width: 0; }
.nav-construction-label { font-weight: 600; font-size: 14.5px; letter-spacing: .01em; }
.nav-construction-sub { font-size: 11.5px; color: #fcd68a; }

/* Status badges the Build Kit adds to each module link */
.nav-link .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link .bk-nav-state { flex: none; font-size: 10px !important; padding: 3px 6px !important; }

/* ---------- Shared building blocks (every module uses these) ---------- */

.page-head--bar { align-items: center; flex-wrap: wrap; }
.page-head-text { flex: 1; min-width: 220px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin: -8px 0 10px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--green-800); text-decoration: underline; }

.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; margin-bottom: 24px; }
.grid-2--aside { grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); }
@media (max-width: 900px) { .grid-2, .grid-2--aside { grid-template-columns: minmax(0, 1fr); } }

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 20px 24px 12px; }
.card-head .card-title { margin: 0; }
.card-empty { padding: 20px 24px 24px; color: var(--muted); font-size: 14px; }
.card .card-empty { padding: 0; }
.card--flush .card-empty { padding: 4px 24px 24px; }
.link-sm { font-size: 13px; font-weight: 600; text-decoration: none; }
.mini-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 6px; }
.prewrap { white-space: pre-wrap; font-size: 14px; color: var(--ink-soft); }
.sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.t-right { text-align: right; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--cream); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td a { font-weight: 600; text-decoration: none; color: var(--green-800); }
.table td a:hover { text-decoration: underline; }
.table tfoot td { font-weight: 700; background: var(--cream); }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge--green { background: var(--green-100); color: var(--green-800); }
.badge--gold { background: var(--gold-50); color: var(--gold-600); border: 1px solid var(--gold-200); }
.badge--muted { background: var(--sand); color: var(--muted); }
.badge--red { background: var(--danger-bg); color: var(--danger); }
.badge--blue { background: #e7eefb; color: #2f5aa8; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.input--search { flex: 1; min-width: 200px; }
.input--auto { width: auto; }
.input--area { height: auto; padding: 10px 14px; line-height: 1.5; resize: vertical; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid--tight { grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid--step { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); } /* ring order: phones, seconds (#49) */
.field--wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; font-size: 14px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 14px; font-weight: 600; font-size: 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--green-800); }
.tab.is-active { color: var(--green-900); border-bottom-color: var(--gold-500); }

.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; min-width: 150px; padding: 14px 18px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm); }
.stat:hover { border-color: var(--line-strong); color: var(--ink); }
.stat-num { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--green-900); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.tile-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--green-900); }

.build-status-slot { margin-top: 28px; }
.build-status-slot:empty { display: none; }

/* ---------- Client Portal & Secure Logins ---------- */

.doc-actions { white-space: nowrap; }
.doc-actions .btn + .btn, .doc-actions .inline-form { margin-left: 4px; }
.inline-form { display: inline-block; margin: 0; }
.rate-set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; }
.doc-upload { padding: 12px 24px 20px; border-top: 1px solid var(--line); }
.doc-upload > summary { list-style: none; display: inline-flex; }
.doc-upload > summary::-webkit-details-marker { display: none; }
.doc-upload[open] > summary { margin-bottom: 14px; }
.doc-upload--open .mini-title { margin-top: 4px; }
.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14.5px; }
.plain-list { margin: 8px 0 12px; padding-left: 18px; font-size: 14px; color: var(--ink-soft); }
.plain-list li + li { margin-top: 4px; }
.card-pad { padding: 0 24px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.wrap { overflow-wrap: anywhere; }

.eapprove-note { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-lg); background: var(--gold-50); border: 1px solid var(--gold-200); font-size: 13.5px; color: var(--ink-soft); }
.eapprove-note--warn { background: var(--danger-bg); border-color: #f1cfc8; }
.card--flush > .eapprove-note { margin: 0 24px 12px; }

.portal-invite { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.portal-invite .invite-result { margin-bottom: 12px; padding: 14px; }
.portal-invite .invite-result-title { font-size: 16px; }
.portal-invite .copy-field { flex-direction: column; }

.approve-card { max-width: 760px; }
.approve-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 20px; }
.approve-steps > li > strong { display: block; margin-bottom: 8px; }
.approve-file { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); }
.approve-file span { font-weight: 600; overflow-wrap: anywhere; }
.approve-check { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border: 2px solid var(--green-600); border-radius: var(--radius-lg); background: var(--green-50); font-size: 16px; font-weight: 600; color: var(--green-900); cursor: pointer; }
.approve-check input { width: 22px; height: 22px; margin-top: 1px; flex: none; }

.certificate { max-width: 860px; }
.certificate-statement { font-size: 15px; }
.certificate-quote { margin: 12px 0; padding: 14px 18px; border-left: 4px solid var(--green-600); background: var(--green-50); font-size: 17px; font-weight: 600; color: var(--green-900); }

@media print {
  .sidebar, .topbar, .no-print, .skip-link, .build-status-slot, .flash { display: none !important; }
  .certificate { border: 0; box-shadow: none; max-width: none; }
}

/* ---------- Fixes found in browser QA (2026-09-14) ---------- */

/* Buttons inside tables inherited the table link colour: green text on a green button. */
.table td a.btn { text-decoration: none; }
.table td a.btn--primary, .table td a.btn--primary:hover, a.btn--primary:visited { color: #fff; }
.table td a.btn--secondary, .table td a.btn--ghost { color: var(--green-800); }

/* Matter-page cards sit in a narrow column: stack table cells instead of scrolling sideways. */
.stack .card--flush { container-type: inline-size; }
@container (max-width: 620px) {
  .stack .table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .stack .table tr:last-child { border-bottom: 0; }
  .stack .table td { display: block; padding: 0; border: 0; text-align: left; }
  .stack .table td:first-child { flex: 1 1 100%; }
  .stack .table .doc-actions { white-space: normal; display: flex; flex-wrap: wrap; gap: 6px; }
  .stack .table .doc-actions .btn + .btn, .stack .table .doc-actions .inline-form { margin-left: 0; }
}

/* ---------- Calendar ---------- */

.cal-kind { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.cal-kind::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
/* Deadlines red, court dates gold-brown (Ali, #9). */
.cal-kind--court_date, .cal-chip--court_date { background: var(--gold-50); color: #8a5f1c; }
.cal-kind--client_appointment, .cal-chip--client_appointment { background: var(--green-100); color: var(--green-800); }
.cal-kind--deadline, .cal-chip--deadline { background: var(--danger-bg); color: var(--danger); }
.cal-kind--internal, .cal-chip--internal { background: #e7eefb; color: #2f5aa8; }
/* A person's own calendar, copied in read-only (calendar sync): striped "busy" look, not a link. */
.cal-chip--external { background: repeating-linear-gradient(135deg, #f1f2f0 0 6px, #e7e9e6 6px 12px); color: var(--ink-soft); font-style: italic; }
.cal-chip--external:hover { filter: none; text-decoration: none; }

.cal-toolbar { justify-content: space-between; }
.cal-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-month-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--green-900); margin-left: 8px; }
.cal-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.cal-legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.cal-month { overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekday { padding: 8px 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  background: var(--cream); border-bottom: 1px solid var(--line); }
.cal-day { position: relative; min-height: 116px; padding: 4px 6px 8px; display: flex; flex-direction: column; gap: 3px; min-width: 0;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.is-outside { background: #fcfbf8; }
.cal-day.is-outside .cal-day-num { color: #b3bab7; }
.cal-day:hover { background: var(--green-50); }
/* The whole cell is the "add an event on this day" link; event chips sit above it. */
.cal-day-add { display: flex; align-items: center; justify-content: space-between; text-decoration: none; color: var(--ink-soft); }
.cal-day-add::after { content: ""; position: absolute; inset: 0; }
.cal-day-num { display: grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.cal-day.is-today .cal-day-num { background: var(--green-800); color: #fff; }
.cal-day-plus { opacity: 0; font-size: 18px; line-height: 1; color: var(--green-700); padding-right: 4px; }
.cal-day:hover .cal-day-plus, .cal-day-add:focus-visible .cal-day-plus { opacity: 1; }
.cal-chip { position: relative; z-index: 1; display: block; padding: 2px 6px; border-radius: 6px; font-size: 12px; line-height: 1.35; font-weight: 500;
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip:hover { filter: brightness(0.96); text-decoration: underline; }
.cal-chip-time { font-weight: 700; }
.cal-more { position: relative; font-size: 12px; color: var(--muted); padding-left: 6px; }

.cal-month-list { display: none; }
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-list-day { display: flex; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.cal-list-day:last-child { border-bottom: 0; }
.cal-list-date { flex: none; width: 48px; display: flex; flex-direction: column; align-items: center; line-height: 1.1; color: var(--muted); }
.cal-list-wday, .cal-list-mon { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.cal-list-dnum { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--green-900); }
.cal-list-date.is-today .cal-list-dnum { color: var(--gold-600); }
.cal-list-events { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.cal-list-event { padding-left: 12px; border-left: 4px solid var(--line-strong); min-width: 0; overflow-wrap: anywhere; }
.cal-list-event--court_date { border-left-color: var(--gold-500); }
.cal-list-event--client_appointment { border-left-color: var(--green-600); }
.cal-list-event--deadline { border-left-color: var(--danger); }
.cal-list-event--internal { border-left-color: #2f5aa8; }
.cal-list-event--external { border-left-style: dashed; border-left-color: #9aa39f; }
.cal-list-external { font-weight: 600; font-style: italic; color: var(--ink-soft); }
.cal-sync-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cal-list-title { font-weight: 600; text-decoration: none; color: var(--green-800); }
.cal-list-title:hover { text-decoration: underline; }

.cal-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; cursor: pointer; }
.cal-attendees { border: 0; margin: 0; padding: 0; min-width: 0; }
.cal-attendee-list { display: flex; flex-wrap: wrap; gap: 0 20px; }
.cal-form:has(#calendar_event_all_day:checked) .cal-time-field { display: none; }

@media (max-width: 640px) {
  .cal-month { display: none; }
  .cal-month-list { display: block; }
  .cal-month-title { font-size: 19px; margin-left: 4px; }
  .cal-filters, .cal-filters .input { width: 100%; }
  .cal-list-day { padding: 12px 16px; gap: 12px; }
}
/* ---------- Time Tracking ---------- */

.section-gap { margin-top: 24px; }
.sub-inline { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.stat-inline { font-weight: 600; color: var(--green-900); font-variant-numeric: tabular-nums; }
.field--grow { flex: 1 1 220px; }
.toolbar--padded { padding: 0 24px; }
.filter-summary { padding: 0 24px 12px; font-size: 14px; color: var(--ink-soft); }
.row-actions { white-space: nowrap; }
.table tr.is-running td { background: var(--gold-50); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-bg); border-color: #f1cfc8; color: var(--danger); }
.danger-zone { margin-top: 16px; }

.clock { margin-bottom: 24px; display: flex; flex-direction: column; gap: 14px; }
.clock--running { border-color: var(--gold-500); background: linear-gradient(135deg, var(--paper), var(--gold-50)); }
.clock-eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--gold-600); }
.clock-elapsed { font-family: var(--font-display); font-size: clamp(40px, 6vw, 56px); font-weight: 600; color: var(--green-900); line-height: 1.05; font-variant-numeric: tabular-nums; }
.clock-matter { font-size: 15px; }
.clock-matter a { font-weight: 600; text-decoration: none; }
.clock-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.clock-btn { height: 52px; padding: 0 28px; font-size: 16px; }
.clock-switch summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--green-700); margin-bottom: 10px; }

/* ---------- Invoicing & Payments ---------- */

.card-body { padding: 16px 24px 24px; }
.stat-row--inset { padding: 0 24px; margin-bottom: 16px; }
.stat-row--inset .stat { flex: 1 1 150px; box-shadow: none; background: var(--cream); }
.stat-row--inset .stat-num { font-size: 22px; }
.table--compact td { padding: 8px 10px; }
.expense-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 12px; }
.expense-form .field:not(.field--grow) { flex: 0 1 150px; }
.notice-bar { display: block; padding: 12px 16px; margin-bottom: 20px; border-radius: var(--radius);
  background: var(--gold-50); border: 1px solid var(--gold-200); color: var(--ink-soft); font-size: 14px; }
.archive-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.confido-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.confido-bar form { margin: 0; }
.check-list { margin: 12px 0 18px; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-spaced { margin-top: 14px; }
.table th.num { text-align: right; }
.invoice-status-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -12px 0 18px; }
.invoice-card { padding: 32px; }
.invoice-doc { display: flex; flex-direction: column; gap: 22px; }
.invoice-doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 2px solid var(--green-800); }
.invoice-doc-firm { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--gold-600); }
/* The firm's brand on the invoice (Ali, #8): text logo on top, League Spartan (the logo's font) for the
   heading, the number under it, and the balance due. */
.invoice-doc-logo { display: block; height: 56px; width: auto; margin-bottom: 10px; }
.invoice-doc-title { font-family: "League Spartan", "Helvetica Neue", Arial, sans-serif; font-size: 30px; font-weight: 700; color: var(--green-900); letter-spacing: .01em; }
.invoice-doc-number { font-family: "League Spartan", "Helvetica Neue", Arial, sans-serif; font-size: 18px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.invoice-doc-meta { font-size: 13.5px; }
.invoice-doc-billto p { font-size: 14px; }
.invoice-doc-billto .mini-title { margin-top: 0; }
.invoice-trust-note { margin-top: 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: #e7eefb; color: #2f5aa8; font-size: 13.5px; }
.invoice-section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--green-800); margin-bottom: 8px; }
.invoice-table th, .invoice-table td { padding: 8px 10px; }
.invoice-summary { margin: 0 0 0 auto; max-width: 420px; display: grid; gap: 6px; }
.invoice-summary-row { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; font-size: 15px; }
.invoice-summary-row dt, .invoice-summary-row dd { margin: 0; }
.invoice-summary-row dd { font-variant-numeric: tabular-nums; white-space: nowrap; }
.invoice-total { padding-top: 12px; margin-top: 4px; border-top: 2px solid var(--green-800); font-size: 16px; }
.invoice-total strong { font-family: "League Spartan", "Helvetica Neue", Arial, sans-serif; font-size: 28px; color: var(--green-900); font-variant-numeric: tabular-nums; }
.initials { text-decoration: none; font-weight: 600; letter-spacing: .04em; }
@media (max-width: 560px) { .invoice-card { padding: 18px 14px; } }

@media print {
  .sidebar, .topbar, .no-print, .page-head, .flash, .build-status-slot, .skip-link, [data-bk-module] { display: none !important; }
  body, .content { background: #fff; padding: 0; max-width: none; }
  .grid-2, .grid-2--aside { display: block; }
  .card, .invoice-card { border: 0; box-shadow: none; padding: 0; }
  .table th { background: #fff; }
}

/* ---------- Financial Reporting ---------- */

.report-table td.num, .report-table th.num { min-width: 110px; }
.report-table .is-negative { color: var(--danger); }
.report-table .report-trust { color: #2f5aa8; border-left: 1px dashed var(--line-strong); }
.report-notes { display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; color: var(--ink-soft); border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.input--narrow { width: 140px; height: 36px; }
/* ---------- Lead / CRM Tracking + Intake Forms ---------- */

.stat--alert { border-color: var(--gold-200); background: var(--gold-50); }
.stat--alert .stat-num { color: var(--gold-600); }
.lead-row--due td { background: var(--gold-50); }
.lead-row--due td:first-child { box-shadow: inset 3px 0 0 var(--gold-500); }
.table--compact th, .table--compact td { padding: 8px 6px; }
.table--compact th { background: transparent; }

.timeline { list-style: none; margin: 0; padding: 0 24px 16px; }
.timeline-item { position: relative; padding: 12px 0 12px 18px; border-left: 2px solid var(--line); }
.timeline-item::before { content: ""; position: absolute; left: -6px; top: 18px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--green-700); }
.timeline-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.timeline-meta .sub { margin: 0; }

.label-spaced { margin-top: 28px; }
.inline-form { display: inline; }
.copy-field--block { flex-direction: column; align-items: flex-start; }
.input--code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; white-space: pre; background: var(--cream); }
.intake-share { margin-bottom: 20px; }
.intake-share .copy-field { align-items: center; }

/* Public pages (intake form, website thank-you) */
.public-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 32px 20px 40px; }
.public-top { width: 100%; max-width: 720px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.public-brand { color: var(--green-900); }
.public-brand .brand-mark { background: var(--green-800); color: var(--gold-200); box-shadow: none; }
.public-brand .brand-word em { color: var(--gold-600); }
.public-tagline { font-family: var(--font-display); color: var(--muted); font-size: 15px; }
.public-card { width: 100%; max-width: 480px; padding: 36px 32px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.public-card--wide { max-width: 720px; }
.intake-section { border: 0; margin: 0 0 22px; padding: 0 0 22px; border-bottom: 1px solid var(--line); min-width: 0; }
.intake-legend { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--green-900); margin-bottom: 12px; padding: 0; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
@media (max-width: 560px) { .public-card { padding: 26px 18px; } }
textarea.input:not(.input--code) { font-family: inherit; }
/* ---------- Documents ---------- */

.docs-recent { margin-top: 20px; }
.docs-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.docs-problems { border-color: #f1cfc8; background: var(--danger-bg); }
.docs-problems .card-title { color: var(--danger); margin-bottom: 6px; }
.docs-problems .docs-list { margin-top: 12px; color: var(--danger); }
.docs-warnings { border-color: var(--gold-200); background: var(--gold-50); }
.docs-choices { border-color: var(--gold-200); }
.docs-choices .form-grid, .card .docs-auto { margin-top: 14px; }
.docs-aside-note { margin-top: 16px; }
.docs-typed summary { cursor: pointer; }
.docs-help p + p, .docs-help p + .docs-example, .docs-help .docs-example + p { margin-top: 10px; }
.docs-example { margin: 10px 0 0; padding: 10px 14px; background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 13px; white-space: pre-wrap; overflow-x: auto; }
code.ph { font-size: 12.5px; padding: 1px 6px; border-radius: 6px; background: var(--sand); color: var(--green-900); white-space: nowrap; }
.input--file { height: auto; padding: 8px 10px; }

/* Portal: document folders and order (shared by the firm's matter page and the client portal) */
.doc-order-hint { margin: 0; padding-top: 0; }
.doc-file-form { padding-top: 0; }
.doc-file-form .sub { margin: 4px 0 0; }
.doc-file-row { display: flex; gap: 8px; align-items: center; max-width: 520px; }
.doc-file-row .input { flex: 1; min-width: 0; }
.doc-table td.doc-pick { width: 1%; padding-left: 16px; padding-right: 0; vertical-align: middle; }
/* Folders open and close like buttons: the client's list stays short (Ali, #1). */
.doc-folder + .doc-folder { border-top: 1px solid var(--line); }
.doc-folder-btn { display: flex; align-items: center; gap: 8px; padding: 11px 16px; cursor: pointer; list-style: none; font-weight: 600; }
.doc-folder-btn::-webkit-details-marker { display: none; }
.doc-folder-btn:hover { background: var(--sand); }
.doc-folder-btn::before { content: "▸"; color: var(--muted); font-size: 12px; transition: transform .12s ease; }
.doc-folder[open] > .doc-folder-btn::before { transform: rotate(90deg); }
.doc-folder[open] > .doc-folder-btn { background: var(--sand); }
.doc-folder-name { flex: 1; min-width: 0; }
.doc-folder-btn .doc-move { display: flex; gap: 2px; }
.doc-folder .table td:first-child { padding-left: 16px; }
.doc-table td.doc-move { width: 1%; padding-left: 12px; padding-right: 0; vertical-align: middle; }
.doc-move { display: table-cell; }
.doc-move .inline-form { display: block; }
.doc-move .btn { min-height: 0; padding: 0 7px; line-height: 20px; }
.doc-move .btn[disabled] { opacity: .3; cursor: default; }
/* Portal: firm previewing a client's view */
.client-preview-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 18px;
  padding: 12px 16px; border-radius: 10px; background: var(--gold-50); border: 1px solid var(--gold-200); }
.client-preview-banner .btn { margin-left: auto; }
.btn.is-disabled { opacity: .5; pointer-events: none; }
.client-preview-note { margin: 0; padding-top: 10px; padding-bottom: 14px; }
.generated-send { display: grid; gap: 8px; margin-top: 10px; }

/* Calendar: who's attending */
.cal-chip-who { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; opacity: .75; }
.cal-chip.is-mine { box-shadow: inset 3px 0 0 var(--green-800); }
.cal-list-event .badge { margin-left: 6px; vertical-align: middle; }

/* ---------- Matter stage (client sees where their matter is; Ali, #1) ---------- */

.stage-steps { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 0; counter-reset: none; }
.stage-step { display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 104px; position: relative; padding-right: 12px; font-size: 14px; color: var(--muted); }
.stage-step:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--line); min-width: 12px; }
.stage-dot { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; border: 2px solid var(--line); background: var(--paper); flex: none; }
.stage-step--done { color: var(--green-800); }
.stage-step--done .stage-dot { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.stage-step--done:not(:last-child)::after { background: var(--green-600); }
.stage-step--current { color: var(--ink); font-weight: 700; }
.stage-step--current .stage-dot { border-color: var(--green-600); color: var(--green-800); box-shadow: 0 0 0 3px var(--green-100); }
.stage-form { display: flex; gap: 6px; align-items: center; }
@media (max-width: 560px) {
  .stage-steps { flex-direction: column; gap: 8px; }
  .stage-step { min-width: 0; }
  .stage-step::after { display: none; }
}

/* ---------- IOLTA check (one check to the firm, per-matter stub; Ali, #6) ---------- */

.trust-check { max-width: 820px; }
.trust-check-face { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--paper); padding: 22px 26px; display: grid; gap: 18px; margin-bottom: 18px; }
.trust-check-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.trust-check-line { display: inline-block; min-width: 180px; border-bottom: 1px solid var(--ink-soft); padding: 0 6px 2px; font-weight: 600; }
.trust-check-pay > div:first-child { flex: 1; }
.trust-check-payee { min-width: 60%; }
.trust-check-amount { border: 1px solid var(--ink-soft); padding: 4px 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.trust-check-words .trust-check-line { min-width: 70%; }
.trust-check-no { font-weight: 700; }
.trust-check-sign { min-width: 220px; border-top: 1px solid var(--ink-soft); padding-top: 4px; text-align: center; font-size: 12px; color: var(--muted); }
.trust-check-stub { border-top: 2px dashed var(--line-strong); padding-top: 14px; }
.trust-check-nudge { display: flex; flex-wrap: wrap; gap: 8px; }
.trust-check-nudge form { margin: 0; }
.check-print { display: none; }

/* The printed check (#55): values only, placed in inches on Letter voucher stock. --nudge-x/y come
   from the firm's print position setting. The page has no margins, so positions are from the paper edge. */
@page check { size: letter; margin: 0; }
@media print {
  body:has(.check-print) .content > :not(.check-print) { display: none !important; }
  body:has(.check-print), body:has(.check-print) .shell, body:has(.check-print) .main-col,
  body:has(.check-print) .content { display: block; margin: 0 !important; padding: 0 !important; background: #fff; min-height: 0; }
  .check-print { display: block; page: check; position: relative; width: 8.5in; height: 10.9in; overflow: hidden;
    font: 11pt/1.2 Helvetica, Arial, sans-serif; color: #000; }
  .check-print .cp { position: absolute; transform: translate(var(--nudge-x, 0in), var(--nudge-y, 0in)); white-space: nowrap; overflow: hidden; }
  .cp-date    { top: 0.74in; left: 6.85in; width: 1.35in; } /* short month: "September 21, 2026" overruns the date line */
  .cp-payee   { top: 1.28in; left: 1.05in; width: 5.45in; font-weight: 600; }
  .cp-amount  { top: 1.26in; left: 6.85in; width: 1.3in; font-weight: 700; font-variant-numeric: tabular-nums; }
  .cp-words   { top: 1.61in; left: 0.45in; width: 6.9in; }
  .cp-words::after { content: " ****************************************************************************************************"; }
  .cp-memo    { top: 2.72in; left: 0.75in; width: 4.2in; font-size: 10pt; }
  .cp-stub    { left: 0.4in; width: 7.6in; height: 2.85in; white-space: normal; font-size: 9pt; } /* ends 0.5in from the right edge: most printers can't print the last quarter inch (Drew, #55) */
  .cp-stub--1 { top: 3.92in; }
  .cp-stub--2 { top: 7.42in; }
  .cp-stub-head { display: flex; justify-content: space-between; gap: 12px; font-size: 10pt; margin-bottom: 2px; }
  .cp-stub-memo { margin-bottom: 4px; }
  .cp-stub table { width: 100%; border-collapse: collapse; }
  .cp-stub th, .cp-stub td { text-align: left; padding: 1.5pt 4pt 1.5pt 0; border-bottom: 0.5pt solid #999; vertical-align: top; }
  .cp-stub th { font-size: 8pt; text-transform: uppercase; letter-spacing: .03em; }
  .cp-stub .num { text-align: right; padding-right: 0; }
  .cp-stub tfoot th { border-bottom: 0; }
}

/* ---------- Running timer in the header on every page (Ali, #6) ---------- */

.header-timer { position: relative; display: flex; align-items: center; gap: 6px; }
.header-timer-now { display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 999px; background: var(--green-50);
  border: 1px solid var(--green-100); color: var(--green-800); text-decoration: none; font-size: 13.5px; max-width: 280px; }
.header-timer-now:hover { background: var(--green-100); }
.header-timer-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex: none; animation: header-timer-pulse 1.6s ease-in-out infinite; }
@keyframes header-timer-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .header-timer-dot { animation: none; } }
.header-timer-clock { font-weight: 700; font-variant-numeric: tabular-nums; }
.header-timer-matter { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-timer-start > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.header-timer-start > summary::-webkit-details-marker { display: none; }
.header-timer-form { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: min(320px, calc(100vw - 32px)); display: grid; gap: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
@media (max-width: 560px) {
  .header-timer-matter { display: none; }
  .header-timer-form { position: fixed; left: 16px; right: 16px; top: 64px; width: auto; }
}

/* ---------- Phone: text threads (bid 443) ---------- */

.texts { list-style: none; margin: 0; padding: 8px 24px 20px; display: grid; gap: 10px; }
.text-line { display: flex; }
.text-line--inbound { justify-content: flex-start; }
.text-line--outbound { justify-content: flex-end; }
.text-bubble { max-width: min(560px, 80%); padding: 10px 14px; border-radius: var(--radius); background: var(--sand); }
.text-line--outbound .text-bubble { background: var(--green-100); }
.text-bubble .prewrap { color: var(--ink); margin: 0; }
.text-meta { margin: 6px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
tr.is-unread td:first-child a { font-weight: 700; }

/* Two-factor sign-in (#28) */
a.user-chip { color: inherit; text-decoration: none; }
a.user-chip:hover .user-name { text-decoration: underline; }
.otp-setup { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; margin: 12px 0; }
.otp-qr { background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); line-height: 0; }
.otp-qr svg { width: 180px; height: 180px; }
.otp-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; letter-spacing: .08em; word-break: break-all; }
.backup-codes { display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); gap: 6px 24px; margin: 10px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
.input--code { max-width: 180px; font-size: 20px; letter-spacing: .2em; text-align: center; }

/* Trust accounts (#47) */
.trust-check-result { margin: 8px 0 0; }
.trust-check-result.is-ok { color: var(--success, #18783c); }
.trust-check-result.is-off { color: var(--danger); }
/* Intake forms on the client's portal (#46) */
.choice-row { display: flex; flex-wrap: wrap; gap: 8px 20px; min-height: 40px; align-items: center; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 18px; }
.intake-entry { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.intake-entry legend { font-weight: 600; padding: 0 6px; }
.intake-entry--new { border-style: dashed; }
.autosave-status { align-self: center; font-size: 13px; color: var(--muted); }
.autosave-status--problem { color: var(--danger, #b42318); }
.intake-remove { margin-top: 12px; }
.intake-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.intake-step { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); }
.intake-answers dt { margin-top: 8px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.waiting-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.waiting-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Trust ledger: the balance sits beside the money columns, and the cleared-date control stays on one line, so the table fits without sideways scrolling. */
#trust-ledger .inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; margin: 0; }
#trust-ledger .inline-form .input { width: 9.5em; }
#trust-ledger td { vertical-align: middle; }
#trust-ledger .trust-ledger-notes { min-width: 12em; max-width: 22em; white-space: normal; }

/* ---------- Touch targets ---------- */
/* On phones/tablets (coarse pointer, no hover) give the small, frequently-tapped
   controls a comfortable ~40px hit area. Desktop is left exactly as-is. */
@media (hover: none) and (pointer: coarse) {
  .btn--sm { height: 40px; padding: 0 16px; }
  .tab { padding: 12px 16px; }
  .doc-move .btn { line-height: 34px; padding: 0 12px; }
}

/* Client form: individual or business (roadmap 517). Swap the name fields from the checked option. */
.client-kind { display: flex; flex-wrap: wrap; gap: 6px 18px; border: 0; padding: 0; margin: 0 0 14px; }
.client-kind legend { width: 100%; margin-bottom: 4px; }
.form:has(.client-kind input[value="individual"]:checked) .only-business,
.form:not(:has(.client-kind input[value="business"]:checked)) .only-business { display: none; }
.form:has(.client-kind input[value="business"]:checked) .only-individual { display: none; }

/* Estate-planning portal (roadmap 546, #89) */
.topbar-firm:has(.topbar-contact) { white-space: normal; min-width: 0; }
.topbar-contact { display: block; font-size: 13px; color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
.topbar-contact a { color: inherit; }
.estate-welcome { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 18px; display: grid; gap: 14px; }
.estate-welcome-title { font-family: var(--font-display); font-size: clamp(22px, 3vw, 30px); color: var(--green-900); margin: 0; line-height: 1.2; }
.estate-appointment { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink, inherit); }
.estate-appointment .icon { color: var(--green-700, var(--green-800)); flex: none; }
.estate-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 16px; margin-bottom: 18px; }
.estate-tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.estate-tile .sub { flex: 1; }
.estate-tile-icon { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: 50%; background: var(--green-50, #e8f1ea); color: var(--green-800); }
.estate-tile-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--green-900); margin: 0; }
.estate-tile--soon { opacity: .75; }
.portal-invite-more { margin-top: 12px; }
.portal-invite-more > summary { list-style: none; cursor: pointer; }
.portal-invite-more > summary::-webkit-details-marker { display: none; }

/* Your Estate Plan Design (roadmap 546) */
.plan-design { display: grid; gap: 22px; }
.plan-group { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px 22px; }
.plan-group-title { font-family: var(--font-display); font-size: 24px; color: var(--green-800); margin: 0 0 6px; }
.plan-section { margin-top: 22px; }
.plan-section-title { font-size: 17px; font-weight: 600; color: var(--green-700); margin: 18px 0 4px; }
.plan-table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 10px 0 14px; font-size: 14.5px; }
.plan-table thead th { background: #2f4a42; color: #fff; text-align: left; padding: 10px 14px; font-weight: 600; }
.plan-table tbody th { background: #f3f5f4; text-align: left; font-weight: 500; width: 36%; }
.plan-table th, .plan-table td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.plan-table td + td, .plan-table th + td { border-left: 1px solid var(--line); }
.plan-table .muted { color: var(--muted); }
.plan-note { background: #fff5f3; border: 1px solid #f4c2b8; border-radius: 10px; padding: 10px 14px; margin: 8px 0; color: var(--ink); }
.plan-edit-section { display: grid; gap: 12px; }
.plan-field { display: grid; gap: 6px; }
.plan-field-inputs { display: grid; gap: 10px; }
.plan-field--spouses .plan-field-inputs { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.plan-input { display: grid; gap: 4px; }
.plan-note-field { border-top: 1px dashed var(--line); padding-top: 10px; }
.plan-actions { position: sticky; bottom: 0; background: var(--bg, #f8f8f6); padding: 12px 0; }
@media (max-width: 640px) { .plan-table tbody th { width: auto; } .plan-group { padding: 16px; } }
