/* Inter (variable, Latin), self-hosted — SIL Open Font License, assets/fonts/Inter-LICENSE.txt */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
}

/* ---------- Design tokens ----------
   One palette, type scale, radius and motion for the whole app. Brand:
   navy and amber. Status colours are used sparingly (text and small marks,
   soft backgrounds), never as large fills. */
:root {
  /* brand */
  --navy: #031A2C;
  --navy-700: #0d2b45;
  --amber: #F0A314;
  --amber-600: #d8920e;
  --amber-50: #fff7e8;
  --white: #FFFFFF;
  /* surfaces and lines */
  --gray-blue: #F5F7FA;        /* page background (kept name: used across the app) */
  --surface: #FFFFFF;
  --surface-subtle: #F8FAFC;   /* hover rows, inset areas */
  --surface-hover: #F1F4F8;
  --border: #E3E8EE;
  --border-strong: #CDD5DF;
  /* text */
  --text: #13212D;
  --text-muted: #5D6B79;
  --text-subtle: #8996A4;
  /* status (text / soft background) */
  --danger: #B42318;   --danger-bg: #FEF0EE;
  --warn: #A15C00;     --warn-bg: #FFF5E6;
  --info: #1D4E89;     --info-bg: #EEF4FB;
  --success: #1E7A3C;  --success-bg: #ECF7F0;
  --violet: #5B3AA8;   --violet-bg: #F3EFFB;
  /* type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --fs-xs: 0.75rem;   /* 12 */
  --fs-sm: 0.8125rem; /* 13 */
  --fs-base: 0.875rem;/* 14 */
  --fs-md: 0.9375rem; /* 15 */
  --fs-lg: 1.125rem;  /* 18 */
  --fs-xl: 1.375rem;  /* 22 */
  /* shape, depth, motion */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-pop: 0 12px 32px rgba(3, 26, 44, 0.16);
  --focus-ring: 0 0 0 3px rgba(240, 163, 20, 0.4);
  --ease: 150ms ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--gray-blue);
  color: var(--text);
}

button, input, select, textarea { font-family: inherit; }

a { color: var(--navy); }

/* One keyboard focus style everywhere (mouse clicks don't show it). */
:where(a, button, [tabindex], summary, input[type=checkbox], input[type=radio]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ---------- Login ---------- */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: 10px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 28px rgba(3, 26, 44, 0.12);
}

.login-card h1 {
  color: var(--navy);
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.login-card p.subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 0.9rem;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--white);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus,
.search-input:focus { outline: none; border-color: var(--amber); box-shadow: var(--focus-ring); }

.field textarea { resize: vertical; min-height: 70px; }

/* Buttons: amber = the one main action on a screen; outline = secondary;
   ghost = quiet secondary (toolbars); text = inline link-style action. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease);
}
.btn .lucide { flex: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--navy); color: var(--white); width: 100%; }
.btn-primary:hover { background: var(--navy-700); }

.btn-amber { background: var(--amber); color: var(--navy); box-shadow: var(--shadow-xs); }
.btn-amber:hover { background: var(--amber-600); }

.btn-outline {
  background: var(--white);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover { background: var(--surface-subtle); border-color: #b9c3cf; }

.btn-ghost { background: transparent; color: var(--text-muted); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-ghost .lucide { color: var(--text-subtle); transition: color var(--ease); }
.btn-ghost:hover .lucide { color: var(--text-muted); }

.btn-text { background: none; color: var(--navy); text-decoration: underline; text-underline-offset: 2px; padding: 4px; min-height: 0; border: none; font-weight: 600; }
.btn-text:hover { color: var(--navy-700); text-decoration-thickness: 2px; }

.icon-btn-group { display: flex; gap: 2px; align-items: center; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  background: none; border: none; border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn { transition: background-color var(--ease), color var(--ease); }
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn-edit:hover { color: var(--navy); }
.icon-btn-activate { color: var(--text-muted); }
.icon-btn-activate:hover { color: var(--success); }
.icon-btn-deactivate { color: var(--success); }
.icon-btn-deactivate:hover { color: #946200; }
.icon-btn-delete:hover { color: var(--danger); }

.status-icon { display: inline-flex; align-items: center; justify-content: center; }
.status-icon svg { width: 20px; height: 20px; }
.status-icon-verified { color: #2fb344; }
.status-icon-needs-review { color: var(--amber); }

.error-text { color: var(--danger); font-size: var(--fs-sm); margin-top: 8px; }
.hint-text { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 8px; line-height: 1.45; }

.whats-new-list { margin: 0; padding-left: 20px; }
.whats-new-list li { margin-bottom: 10px; font-size: 0.88rem; line-height: 1.4; }
.whats-new-list li:last-child { margin-bottom: 0; }

.hidden { display: none !important; }

/* ---------- App shell ---------- */

#app-shell { display: none; min-height: 100vh; flex-direction: column; }
#app-shell.active { display: flex; }

/* Top bar: navy, 56px tall. Icons are Lucide at 18px / 1.75 stroke
   (lucideIcon() in app.js); every control is at least 36px and shows a
   focus ring when reached by keyboard. */
header.topbar {
  --topbar-fg: rgba(255, 255, 255, 0.72);
  --topbar-hover: rgba(255, 255, 255, 0.08);
  --topbar-active: rgba(255, 255, 255, 0.14);
  --topbar-ring: 0 0 0 2px var(--navy), 0 0 0 4px rgba(240, 163, 20, 0.85);
  position: relative;
  z-index: 50;
  background: var(--navy);
  color: var(--white);
  min-height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

header.topbar .brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; white-space: nowrap; }
header.topbar .brand span { color: var(--amber); }
header.topbar .lucide { display: block; flex: none; }

.topbar-actions { display: flex; align-items: center; gap: 4px; }

.topbar-icon-btn, .account-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--topbar-fg);
  font: inherit;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.topbar-icon-btn:hover, .account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--topbar-hover); color: var(--white); }
.topbar-icon-btn:active, .account-btn:active { background: var(--topbar-active); }
.topbar-icon-btn:focus-visible, .account-btn:focus-visible { outline: none; box-shadow: var(--topbar-ring); color: var(--white); }

/* Tooltips: shown on hover and on keyboard focus, after a short pause. */
header.topbar [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translate(-50%, -2px);
  padding: 5px 8px;
  border-radius: 6px;
  background: #1c2b36;
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(3, 26, 44, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 70;
}
header.topbar [data-tooltip]:hover::after, header.topbar [data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 400ms;
}
header.topbar .account-btn[data-tooltip]::after { left: auto; right: 0; transform: translateY(-2px); }
header.topbar .account-btn[data-tooltip]:hover::after, header.topbar .account-btn[data-tooltip]:focus-visible::after { transform: translateY(0); }
header.topbar .account-btn[aria-expanded="true"]::after, header.topbar .is-busy::after { display: none; }

/* Account: avatar with initials, name and role; opens a menu. */
.account { position: relative; margin-left: 6px; }
.account-btn { gap: 8px; padding: 0 6px 0 4px; height: 40px; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: rgba(240, 163, 20, 0.16);
  color: var(--amber);
  box-shadow: inset 0 0 0 1px rgba(240, 163, 20, 0.35);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}
.avatar-lg { width: 36px; height: 36px; font-size: 0.82rem; }
.account-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.account-name { color: var(--white); font-size: 0.84rem; font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role { color: rgba(255, 255, 255, 0.55); font-size: 0.72rem; }
.account-chevron { color: rgba(255, 255, 255, 0.55); transition: transform 150ms ease; }
.account-chevron .lucide { width: 16px; height: 16px; }
.account-btn[aria-expanded="true"] .account-chevron { transform: rotate(180deg); }

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  padding: 6px;
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(3, 26, 44, 0.18);
  z-index: 80;
  animation: account-menu-in 150ms ease;
}
@keyframes account-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.account-menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.account-menu-head .avatar { background: #fdf3df; box-shadow: inset 0 0 0 1px #f3d79f; color: #8a5a00; }
.account-menu-name { font-weight: 600; font-size: 0.9rem; }
.account-menu-email { color: var(--text-muted); font-size: 0.78rem; margin: 1px 0 5px; word-break: break-all; }
.account-role-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--gray-blue); border: 1px solid var(--border); color: var(--text-muted); font-size: 0.72rem; font-weight: 500; }
.account-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease;
}
.account-menu-item .lucide { color: var(--text-muted); }
.account-menu-item:hover, .account-menu-item:focus-visible { background: var(--gray-blue); outline: none; }
.account-menu-item:focus-visible { box-shadow: inset 0 0 0 2px rgba(240, 163, 20, 0.85); }

@media (prefers-reduced-motion: reduce) {
  .topbar-icon-btn, .account-btn, .account-chevron, .account-menu-item, header.topbar [data-tooltip]::after { transition: none; }
  .account-menu { animation: none; }
}

nav.tabs {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 16px;
  gap: 2px;
}

/* Tabs: quiet text, a soft pill on hover, navy text and a 2px amber line
   when active. */
nav.tabs button {
  position: relative;
  background: none;
  border: none;
  margin: 6px 0;
  padding: 0 12px;
  min-height: 36px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--ease), color var(--ease);
}
nav.tabs button:hover { background: var(--surface-hover); color: var(--text); }
nav.tabs button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
nav.tabs button::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -7px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  transition: background-color var(--ease);
}

nav.tabs button.active {
  color: var(--navy);
  font-weight: 600;
}
nav.tabs button.active::after { background: var(--amber); }

/* Narrow screens: the tabs wrap onto more lines instead of running off the
   edge (Billing, Admin and Trash used to end up out of view). */
@media (max-width: 900px) {
  nav.tabs { flex-wrap: wrap; padding: 0 8px; gap: 0 2px; }
  nav.tabs button { padding: 0 10px; font-size: var(--fs-sm); margin: 4px 0; }
  nav.tabs button::after { bottom: -5px; }
}

.subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.subtabs button {
  background: none;
  border: none;
  padding: 8px 12px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--ease), border-color var(--ease);
}
.subtabs button:hover { color: var(--text); }

.subtabs button.active {
  color: var(--navy);
  font-weight: 600;
  border-bottom-color: var(--amber);
}

main.content { flex: 1; padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; }

.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em; color: var(--text); display: flex; align-items: center; gap: 8px; }
.panel-header h2 .lucide { color: var(--text-subtle); }

.panel-header-actions { display: flex; align-items: center; gap: 8px; }
/* When the window is too narrow for one line, the buttons move to a second
   line instead of spilling past the panel's edge or squeezing the labels. */
.panel-header { flex-wrap: wrap; row-gap: 10px; }
.panel-header-actions { flex-wrap: wrap; justify-content: flex-end; min-width: 0; max-width: 100%; }
.panel-header-actions > .btn, .panel-header-actions > label { flex: none; white-space: nowrap; }
.panel-header-actions > .search-input { flex: 1 1 200px; min-width: 160px; }

/* Filter dropdowns next to a list (status, currency, category …): the same
   height, border and corners as the search box beside them. */
.panel-header-actions select, .doc-toolbar select, .review-filter select, #setup-client-filter, .list-filter-select {
  height: 36px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235D6B79' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  max-width: 100%;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.panel-header-actions select:hover, .doc-toolbar select:hover, .review-filter select:hover, #setup-client-filter:hover, .list-filter-select:hover { border-color: var(--text-subtle); }
.panel-header-actions select:focus, .doc-toolbar select:focus, .review-filter select:focus, #setup-client-filter:focus, .list-filter-select:focus, .review-filter input:focus { outline: none; border-color: var(--amber); box-shadow: var(--focus-ring); }

.search-input {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  min-width: 220px;
  background: var(--white);
  transition: border-color var(--ease), box-shadow var(--ease);
}

table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); font-variant-numeric: tabular-nums; }
table.data-table th {
  text-align: left;
  color: var(--text-subtle);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: none; }

#matters-table td { padding: 8px 12px; }
.cell-sub { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; }
table.data-table tr { transition: background-color var(--ease); }
table.data-table tr.clickable { cursor: pointer; }
table.data-table tr.clickable:hover { background: var(--surface-subtle); }

table.data-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.data-table th.sortable:hover { color: var(--navy); }
table.data-table th.sortable::after { content: ""; display: inline-block; width: 10px; margin-left: 3px; opacity: 0.4; }
table.data-table th.sortable.sort-asc::after { content: "▲"; font-size: 0.65rem; opacity: 1; color: var(--amber); }
table.data-table th.sortable.sort-desc::after { content: "▼"; font-size: 0.65rem; opacity: 1; color: var(--amber); }

/* Badges: sentence case, soft background. Deadline statuses also get a
   small dot so the colour isn't the only signal. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--surface-hover);
  color: var(--text-muted);
}
.badge-overdue::before, .badge-soon::before, .badge-upcoming::before, .badge-ok::before,
.badge-done::before, .badge-reconcile::before, .badge-in_progress::before, .badge-qc_pending::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none;
}

.badge-domestic { background: var(--success-bg); color: var(--success); }
.badge-inbound { background: var(--info-bg); color: var(--info); }
.badge-outbound { background: #fdf0e3; color: #9a520f; }

.badge-overdue { background: var(--danger-bg); color: var(--danger); }
.badge-soon { background: var(--warn-bg); color: var(--warn); }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-done { background: var(--surface-hover); color: var(--text-muted); }

.badge-not_started { background: var(--surface-hover); color: var(--text-muted); }
.badge-in_progress { background: var(--info-bg); color: var(--info); }
.badge-qc_pending { background: var(--warn-bg); color: var(--warn); }

.stage-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.stage-row:last-child { border-bottom: none; }

.activity-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.activity-row:last-child { border-bottom: none; }
.activity-row .activity-meta { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }
.stage-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy); color: var(--white);
  font-size: 0.78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stage-main { flex: 1; min-width: 0; }
.stage-name { font-weight: 600; color: var(--navy); }
.stage-meta { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.stage-qc-flag { color: var(--amber); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; margin-left: 6px; }
.stage-actions { display: flex; gap: 6px; flex-shrink: 0; }
.stage-actions select { font-size: 0.82rem; padding: 4px 6px; }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pagination-controls { display: flex; align-items: center; gap: 10px; }

.btn-sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Dashboard ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.stat-tile .stat-number { font-size: 1.625rem; font-weight: 600; letter-spacing: -0.02em; color: var(--text); line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-tile .stat-number.stat-danger { color: var(--danger); }
.stat-tile .stat-number.stat-warn { color: var(--warn); }
.stat-tile .stat-label { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }

.dashboard-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .dashboard-cols { grid-template-columns: 1fr; } }

table.data-table td.num { text-align: right; font-weight: 600; }

/* ---------- Trademark logo ---------- */

.logo-preview {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo-preview img {
  max-width: 140px;
  max-height: 140px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  object-fit: contain;
  padding: 8px;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(3, 26, 44, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { margin: 0 0 18px; color: var(--text); font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
.modal-wide { max-width: 760px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.detail-grid .field { margin-bottom: 0; }

.mfa-qr { display: flex; justify-content: center; margin: 16px 0; }
.mfa-qr img { border: 1px solid var(--border); border-radius: 6px; }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--navy); color: var(--white);
  padding: 10px 16px; border-radius: var(--radius); font-size: var(--fs-sm); font-weight: 500;
  box-shadow: var(--shadow-pop);
  z-index: 100;
}
.toast.error { background: var(--danger); }

/* ---------- Admin: email reminders ---------- */
.reminder-settings { max-width: 420px; }
.reminder-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- Billing ---------- */
.modal-xl { max-width: 1120px; }
.invoice-head { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
@media (max-width: 860px) { .invoice-head { grid-template-columns: 1fr 1fr; } }
.invoice-section { margin: 8px 0 18px; }
.invoice-section-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--navy); margin-bottom: 8px; }
.inv-add-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.inv-add-row select, .inv-add-row input:not([type=checkbox]) {
  flex: 1 1 260px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; background: var(--white);
}
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--gray-blue); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 0.85rem; }
.chip .cell-sub { margin-top: 0; }
.chip-remove { border: none; background: none; cursor: pointer; font-size: 1rem; line-height: 1; color: var(--text-muted); padding: 0 4px; }
.chip-remove:hover { color: var(--danger); }
.table-scroll { overflow-x: auto; margin: 0 -2px; padding: 0 2px; }
.table-scroll > table.data-table { min-width: 100%; }
/* long titles: two lines at most in a list (the matter page shows all of it) */
#all-deadlines-table td[data-col="matter"] strong, #matters-table td[data-ck="matter"] strong, #matters-table td[data-ck="mark"] strong,
#client-matters-table td strong, #applicant-matters-table td strong {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#all-deadlines-table td[data-col="matter"] { min-width: 200px; max-width: 340px; }
#all-deadlines-table td[data-col="description"] { min-width: 160px; }
table.data-table td.row-actions { white-space: nowrap; }
table.invoice-lines input, table.invoice-lines select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.88rem; background: var(--white);
}
table.invoice-lines td { vertical-align: top; }
table.invoice-lines td:first-child { min-width: 240px; }
table.invoice-lines .num-input { text-align: right; min-width: 92px; }
table.invoice-lines .qty-input { min-width: 64px; max-width: 80px; }
table.invoice-lines td.num { white-space: nowrap; padding-top: 12px; }
table.invoice-lines tr.line-needs-amount input.num-input { border-color: var(--amber); background: #fffaf0; }
.line-warning { color: #946200; }
table.invoice-lines tfoot td { font-weight: 700; color: var(--navy); border-top: 2px solid var(--border); }
.invoice-grand-total { font-size: 1.05rem; }
table.fee-table th.fee-cur { text-align: center; border-bottom: 1px solid var(--border); }
table.fee-table td.num { font-weight: 400; }
tr.fee-section-row td { background: var(--gray-blue); font-weight: 600; color: var(--navy); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr.row-inactive td { color: var(--text-muted); }
table.fee-amounts { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
table.fee-amounts th { font-size: 0.8rem; color: var(--navy); text-align: left; padding: 4px; }
table.fee-amounts td { padding: 4px; }
table.fee-amounts input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; text-align: right; }
table.invoice-lines td:nth-child(2) { min-width: 150px; }

/* ---------- Internal notes ---------- */
.note-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.note-body { white-space: pre-wrap; }

/* ---------- Applicants / parties ---------- */
.party-warning { background: #fff8e1; border: 1px solid #f0d58c; border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; font-size: 0.88rem; color: #6b4e00; }
.party-warning .btn-text { padding: 0 0 0 6px; font-size: 0.88rem; }
.party-ok { background: #eaf6ee; border: 1px solid #a9d8b8; border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; font-size: 0.88rem; color: #1f5c33; }
a.party-link { color: var(--navy); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
a.chip-link { text-decoration: none; color: var(--navy); padding-right: 12px; }
a.chip-link:hover { background: #e3e9f0; }
.nm-new-party { display: grid; gap: 6px; margin-top: 6px; }
.nm-new-party input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem; }

/* ---------- Matter page header ---------- */
.matter-header { padding: 18px 20px; }
.mh-top { display: flex; gap: 16px; align-items: flex-start; }
.mh-thumb {
  position: relative; flex: 0 0 96px; width: 96px; height: 96px; padding: 6px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--white);
  display: flex; align-items: center; justify-content: center; cursor: zoom-in; overflow: hidden;
}
.mh-thumb:hover { border-color: var(--navy); }
.mh-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.mh-wordmark {
  font-family: Georgia, "Times New Roman", serif; font-weight: 700; color: var(--navy);
  font-size: 0.82rem; line-height: 1.15; text-align: center; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.mh-iptype { font-family: inherit; color: var(--text-muted); letter-spacing: 0.05em; }
.mh-thumb-caption {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 0.62rem; text-align: center;
  background: rgba(243, 246, 249, 0.92); color: var(--text-muted); padding: 1px 2px;
}
.mh-thumb-caption.warn { background: #fff2dc; color: #946200; }
.mh-main { flex: 1; min-width: 0; }
.mh-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.mh-title-row h2 { margin: 0; font-size: 1.35rem; color: var(--navy); line-height: 1.25; word-break: break-word; }
.mh-refs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; font-size: 0.86rem; color: var(--text-muted); }
.mh-ref { display: inline-flex; align-items: center; gap: 4px; }
.mh-ref-label { color: var(--text-muted); opacity: 0.8; }
.mh-sep { color: var(--border); margin: 0 2px; }
.mh-registry { color: var(--navy); font-weight: 600; text-decoration: none; }
.mh-registry:hover { text-decoration: underline; }
.mh-registry svg, .copy-btn svg { width: 13px; height: 13px; }
.copy-btn { border: none; background: none; color: var(--text-muted); cursor: pointer; padding: 2px; border-radius: 4px; display: inline-flex; }
.copy-btn:hover { color: var(--navy); background: var(--gray-blue); }
.mh-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip-status { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; border: 1px solid transparent; }
.chip-status.tone-success { background: #e3f1ea; color: var(--success); }
.chip-status.tone-info { background: #e6effa; color: #1d4e89; }
.chip-status.tone-violet { background: #efe9fb; color: #5b3aa8; }
.chip-status.tone-warn { background: #fff2dc; color: #946200; }
.chip-status.tone-danger { background: #fbe4e2; color: var(--danger); }
.chip-status.tone-neutral { background: var(--gray-blue); color: var(--text-muted); }
.chip-status.chip-mini { padding: 0 7px; font-size: 0.68rem; margin-left: 4px; vertical-align: 1px; }
.chip-status.tone-plain { background: var(--white); color: var(--text-muted); border-color: var(--border); font-weight: 500; }
.mh-verify {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-top: 14px; padding: 8px 12px; border: 1px solid #f0d58c; background: #fffaeb; border-radius: 8px;
}
.mh-verify-text { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: #6b4e00; }
.mh-verify-text svg { color: var(--amber); }
.mh-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px;
  margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--border);
}
.mh-facts dt, .mh-party-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
.mh-facts dd { margin: 2px 0 0; font-size: 0.92rem; }
.mh-parties {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 16px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 0.92rem;
}
.mh-parties .mh-party-label { margin-bottom: 2px; }
.mh-parties a { color: var(--navy); }
.mh-missing { color: #946200; font-size: 0.86rem; }
.mh-notes { margin: 12px 0 0; font-size: 0.88rem; color: var(--text-muted); white-space: pre-wrap; }
.matter-tabs { margin: 4px 0 16px; }
@media (max-width: 640px) {
  .mh-thumb { flex-basis: 72px; width: 72px; height: 72px; }
  .mh-title-row h2 { font-size: 1.15rem; }
}

/* ---------- Mark representations ---------- */
.rep-viewer {
  height: 52vh; min-height: 220px; border: 1px solid var(--border); border-radius: 8px; background: var(--white);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.rep-viewer img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.rep-wordmark { font-family: Georgia, "Times New Roman", serif; font-weight: 700; color: var(--navy); font-size: clamp(1.4rem, 4vw, 2.6rem); text-align: center; word-break: break-word; }
.rep-viewer-tag { margin: 8px 0 14px; display: flex; gap: 8px; align-items: center; font-size: 0.88rem; }
.rep-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.rep-card { display: flex; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 0.86rem; }
.rep-card.active { border-color: var(--navy); }
.rep-card-thumb { flex: 0 0 64px; height: 64px; border: 1px solid var(--border); border-radius: 6px; background: var(--white); padding: 3px; cursor: zoom-in; }
.rep-card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.rep-card .btn-text { padding: 0 6px 0 0; font-size: 0.82rem; }
.rep-remove { color: var(--danger) !important; }
.rep-upload { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.rep-upload input:not([type=checkbox]) { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }
.rep-official-check { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; }
.rep-upload .btn { justify-self: start; }
.rep-viewer.is-text { height: auto; min-height: 160px; }

/* ---------- Dashboard ---------- */
.dash-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.dash-toolbar h2 { margin: 0; color: var(--text); font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; }
.dash-sub { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }
.dash-role { font-weight: 500; color: var(--text); }

/* Segmented control: a soft track with the chosen option raised. */
.segmented { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-hover); }
.segmented button { border: none; background: none; min-height: 30px; padding: 0 12px; border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; color: var(--text-muted); transition: background-color var(--ease), color var(--ease), box-shadow var(--ease); }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--white); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 0 0 1px var(--border); }
.segmented-sm button { min-height: 26px; padding: 0 10px; font-size: var(--fs-xs); }

/* Quick actions: one amber main action, quiet secondary ones. */
.dash-quick { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.dash-quick .btn-amber { margin-right: 6px; }

/* Metric cards */
.dash-cards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
@media (max-width: 1100px) { #dashboard-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.dash-card { display: flex; flex-direction: column; gap: 8px; }
/* tiles written number-first (portfolio, payments) show the label on top too */
.dash-card > .stat-number { order: 2; }
.dash-card > .stat-label { order: 1; margin-top: 0; }
button.dash-card { text-align: left; cursor: pointer; font: inherit; color: inherit; transition: border-color var(--ease), background-color var(--ease), box-shadow var(--ease); }
button.dash-card:hover { border-color: var(--border-strong); background: var(--surface-subtle); }
button.dash-card:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--amber); }
.stat-head { display: flex; align-items: center; gap: 8px; min-width: 0; order: 1; }
.stat-head .stat-label { flex: 1; min-width: 0; font-weight: 500; }
.stat-head .lucide { color: var(--text-subtle); flex: none; }
.stat-head .stat-go { opacity: 0; transform: translateX(-2px); transition: opacity var(--ease), transform var(--ease); }
button.dash-card:hover .stat-go, button.dash-card:focus-visible .stat-go { opacity: 1; transform: none; }
.dash-card.tone-navy .stat-head .lucide:first-child { color: var(--navy); }
.dash-card.tone-danger .stat-head .lucide:first-child { color: var(--danger); } .dash-card.tone-danger .stat-number { color: var(--danger); }
.dash-card.tone-warn .stat-head .lucide:first-child { color: var(--warn); }
.dash-card.tone-info .stat-head .lucide:first-child { color: var(--info); }
.dash-card.tone-violet .stat-head .lucide:first-child { color: var(--violet); }
.dash-card.tone-zero .stat-number { color: var(--text-subtle); }

/* Panels */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-grid .panel { margin-bottom: 0; }
.dash-wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } .dash-grid .panel { min-width: 0; overflow-x: auto; } }
.panel-pill { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.panel-pill.tone-danger { background: var(--danger-bg); color: var(--danger); }
.panel-pill.tone-success { background: var(--success-bg); color: var(--success); }
.dash-h3 { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); margin: 16px 0 4px; }
.dash-empty { color: var(--text-muted); font-size: var(--fs-sm); margin: 6px 0; }
.dash-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.dash-links a { color: var(--text); }

/* Counts that open a list: pills, table cells, and "queue" rows. */
.dash-count { display: inline-flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; font-size: var(--fs-sm); border-radius: var(--radius-sm); transition: background-color var(--ease), color var(--ease); }
.dash-count strong { display: inline-block; background: var(--surface-hover); color: var(--text); border-radius: 999px; padding: 0 8px; min-width: 24px; line-height: 20px; text-align: center; font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; transition: background-color var(--ease), color var(--ease); }
a.dash-count:hover strong { background: var(--navy); color: var(--white); }
.dash-count.zero { color: var(--text-muted); }
.dash-count.zero strong { background: transparent; color: var(--text-subtle); box-shadow: inset 0 0 0 1px var(--border); font-weight: 500; }
.dash-links .dash-count { padding: 3px 4px 3px 8px; border: 1px solid var(--border); border-radius: 999px; }
.dash-links a.dash-count:hover { border-color: var(--border-strong); background: var(--surface-subtle); }
.dc-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dc-label .lucide { color: var(--text-subtle); flex: none; transition: color var(--ease); }
.dash-queue { justify-content: space-between; gap: 10px; min-height: 36px; padding: 0 8px; }
.dash-queue:hover { background: var(--surface-hover); }
.dash-queue:hover .dc-label .lucide { color: var(--text-muted); }
.dash-queue:not(.zero) strong { background: var(--surface-hover); }
.dash-queue.zero .dc-label { color: var(--text-muted); }
.queue-list { display: flex; flex-direction: column; }
.queue-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0 8px; margin: -4px -8px 4px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.mw-queues { display: grid; gap: 4px; margin: -4px -8px 0; }
.mw-queues .queue-list + .queue-list { border-top: 1px solid var(--border); padding-top: 4px; }

.dash-matter { color: var(--text); text-decoration: none; border-radius: 4px; }
.dash-matter strong { font-weight: 600; }
.dash-matter:hover strong { text-decoration: underline; text-underline-offset: 2px; }
.pa-list, .mw-list, .ra-list, .dq-list { list-style: none; margin: 0; padding: 0; }

/* Priority actions */
.pa-item { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; margin: 0 -8px; padding: 8px; border-radius: var(--radius-sm); font-size: var(--fs-base); cursor: pointer; transition: background-color var(--ease); }
.pa-item + .pa-item { box-shadow: 0 -1px 0 var(--border); }
.pa-item:hover { background: var(--surface-subtle); box-shadow: none; }
.pa-item:hover + .pa-item { box-shadow: none; }
.pa-item .badge { justify-self: start; }
.pa-urgent .pa-title { font-weight: 600; }
.pa-title { color: var(--text); line-height: 1.35; overflow-wrap: anywhere; }
.pa-meta, .mw-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-muted); }
.pa-meta .dash-matter strong, .mw-meta .dash-matter strong { font-weight: 500; }
.pa-meta .cell-sub, .mw-meta .cell-sub { font-size: var(--fs-xs); }
.pa-sep { color: var(--text-subtle); }
.pa-when { text-align: right; }
.pa-more { margin: 10px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.pa-main { min-width: 0; }

/* Due dates: compact date, then how far away (coloured only when close). */
.due { display: inline-flex; flex-direction: column; line-height: 1.3; white-space: nowrap; }
.due-date { font-size: var(--fs-sm); font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.due-rel { font-size: var(--fs-xs); color: var(--text-muted); }
.due-rel.due-overdue { color: var(--danger); font-weight: 500; }
.due-rel.due-soon { color: var(--warn); font-weight: 500; }
.dash-table td.due-col { width: 1%; }
.dash-table .cell-person { white-space: nowrap; color: var(--text-muted); }

/* My work */
.mw-item { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; margin: 0 -8px; padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; transition: background-color var(--ease); }
.mw-item + .mw-item { box-shadow: 0 -1px 0 var(--border); }
.mw-item:hover { background: var(--surface-subtle); box-shadow: none; }
.mw-item:hover + .mw-item { box-shadow: none; }
.mw-item > .badge:first-child { justify-self: start; }
.mw-title { font-size: var(--fs-base); line-height: 1.35; overflow-wrap: anywhere; }
.mw-main { min-width: 0; }

/* Data quality, activity, billing lists */
.dq-group + .dq-group { margin-top: 4px; }
.dq-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 32px; padding: 4px 0; font-size: var(--fs-sm); border-bottom: 1px solid var(--border); }
.dq-list li:last-child { border-bottom: none; }
.dq-list li > span:first-child { color: var(--text-muted); }
.origin-row { display: flex; flex-wrap: wrap; gap: 10px; font-size: var(--fs-sm); }
.origin-row a { color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.ra-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); line-height: 1.45; }
.ra-list li:last-child { border-bottom: none; }
.ra-list .cell-sub { font-size: var(--fs-xs); }
.dash-table td, .dash-table th { padding: 8px 10px; }
.dash-table tr.clickable:hover { background: var(--surface-subtle); }
details.whats-new { margin-top: 16px; }
details.whats-new summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; border-radius: var(--radius-sm); }
details.whats-new summary::-webkit-details-marker { display: none; }
details.whats-new summary h2 { display: inline; font-size: var(--fs-md); font-weight: 600; color: var(--text); }
details.whats-new summary::after { content: "▸"; color: var(--text-subtle); font-size: 0.8em; transition: transform var(--ease); }
details.whats-new[open] summary::after { transform: rotate(90deg); }

@media (max-width: 640px) {
  main.content { padding: 16px 12px; }
  .panel { padding: 16px; }
  .panel-header { flex-wrap: wrap; }
  .dash-toolbar h2 { font-size: var(--fs-lg); }
  .dash-cards, #dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-tile { padding: 12px; }
  .stat-tile .stat-number { font-size: 1.375rem; }
  .dash-quick .btn-ghost span { display: none; }   /* icons only; their labels stay as tooltips */
  .pa-item, .mw-item { grid-template-columns: minmax(0, 1fr) auto; }
  .pa-item > .badge, .mw-item > .badge:first-child { grid-column: 1 / -1; }
  .mw-item > .mw-due { grid-column: 1 / -1; }
  .queue-strip { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  button.dash-card, .dash-count, .pa-item, .mw-item, .stat-head .stat-go, .segmented button { transition: none; }
}
details.whats-new[open] summary::after { content: " ▾"; }

/* ---------- Deadline origin / risk / filters ---------- */
.origin-badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 1px 7px; border-radius: 4px; border: 1px solid; white-space: nowrap; }
.origin-auto { color: #1d4e89; border-color: #b9cce6; background: #f1f6fc; }
.origin-manual { color: var(--text); border-color: var(--border); background: var(--white); }
.origin-imported { color: #6b4e00; border-color: #f0d58c; background: #fffaeb; }
.origin-reported { color: #5b3aa8; border-color: #d6c9f2; background: #f6f2fd; }
.verified-tick { display: inline-block; margin-left: 6px; font-size: 0.72rem; font-weight: 700; color: var(--success); white-space: nowrap; }
.badge-reconcile { background: var(--violet-bg); color: var(--violet); }
.badge-upcoming { background: var(--info-bg); color: var(--info); }
.kind-tag { display: inline-block; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; margin-left: 4px; }
.row-actions { white-space: nowrap; }
/* Row actions: quiet text buttons that light up on hover / focus. */
.row-actions .btn-text { padding: 3px 6px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted); text-decoration: none; border-radius: var(--radius-sm); transition: background-color var(--ease), color var(--ease); }
.row-actions .btn-text:hover { color: var(--navy); background: var(--surface-hover); text-decoration: none; }
.preset-banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #e6effa; color: #1d4e89; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 0.88rem; }
.preset-banner .btn-text { color: #1d4e89; }

/* ---------- Undo ---------- */
.toast-undo { display: flex; align-items: center; gap: 14px; }
.toast-undo button {
  background: none; border: 1px solid rgba(255, 255, 255, 0.5); color: var(--amber); font-weight: 700;
  border-radius: 6px; padding: 3px 10px; cursor: pointer; font-size: 0.86rem;
}
.toast-undo button:hover { background: rgba(255, 255, 255, 0.1); }
.btn-text.btn-quiet { color: var(--text-muted); }

/* ---------- Document preview ---------- */
.modal-preview { max-width: 1100px; width: 100%; height: 90vh; display: flex; flex-direction: column; padding: 16px 20px; }
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.preview-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.preview-title strong { word-break: break-all; }
.preview-actions { display: flex; align-items: center; gap: 6px; }
.preview-body { flex: 1; min-height: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--gray-blue); display: flex; align-items: center; justify-content: center; overflow: auto; }
.preview-frame { width: 100%; height: 100%; border: none; background: var(--white); }
.preview-image { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-text { align-self: stretch; width: 100%; margin: 0; padding: 14px; background: var(--white); font-size: 0.84rem; white-space: pre-wrap; word-break: break-word; overflow: auto; }
.preview-none { text-align: center; color: var(--text-muted); }
.preview-none-icon .doc-icon { font-size: 1rem; padding: 10px 14px; }
.doc-name { color: var(--navy); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.doc-name:hover { text-decoration: underline; }
.doc-icon { display: inline-block; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.03em; padding: 2px 5px; border-radius: 4px; background: var(--gray-blue); color: var(--text-muted); }
.doc-icon-pdf { background: #fbe4e2; color: var(--danger); }
.doc-icon-image { background: #e6effa; color: #1d4e89; }
.doc-icon-text { background: #e3f1ea; color: var(--success); }

/* ---------- Delete (behind "⋯") + Trash ---------- */

.more-menu { position: relative; display: inline-block; vertical-align: middle; }
.more-menu-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.more-menu-btn:hover { background: var(--gray-blue); color: var(--text); }
.more-menu-list {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 40;
  min-width: 180px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(3, 26, 44, 0.12);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.more-menu-list.hidden { display: none; }
/* In the bill window the menu sits at the bottom-left: open up and to the right. */
#inv-delete-wrap .more-menu-list { left: 0; right: auto; top: auto; bottom: 100%; }
.more-menu-item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.more-menu-item:hover { background: var(--gray-blue); }
.more-menu-danger { color: var(--danger); }
.more-menu-danger:hover { background: #fbe4e2; }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #921f19; }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }

.confirm-delete-layer { z-index: 60; }
.confirm-delete-label { word-break: break-word; }
#confirm-delete-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.05em; }

.note-actions { display: inline-flex; align-items: center; gap: 2px; }
.tab-btn.tab-quiet { margin-left: auto; opacity: 0.7; }
.trash-expiring { color: var(--danger); font-weight: 600; }
.mh-title-actions { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ---------- QuickBooks migration review ---------- */

.review-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.review-head .subtabs { margin-bottom: 0; border-bottom: none; }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); grid-auto-flow: dense; gap: 16px; }
.review-grid > .panel { min-width: 0; overflow-x: auto; }
.review-grid > .review-wide { grid-column: span 2; }
.stat-tile.clickable, li.clickable { cursor: pointer; }
.stat-tile.clickable:hover { border-color: var(--amber); }
.review-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.review-filter { display: flex; flex-direction: column; font-size: 12px; color: var(--text-muted); gap: 3px; }
.review-filter input { height: 36px; font-size: var(--fs-sm); padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--white); }
.review-views { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.review-bulkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.review-preview-list { max-height: 220px; overflow: auto; font-size: 13px; border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; margin: 8px 0; }
.review-record-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.review-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.review-original { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
table.rv-raw th { width: 38%; font-weight: 600; font-size: 12px; vertical-align: top; }
table.rv-raw td { font-size: 13px; word-break: break-word; }
.rv-raw-val + .rv-raw-val { border-top: 1px dashed var(--border); margin-top: 3px; padding-top: 3px; }
.rv-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; margin-bottom: 8px; }
.rv-field label { display: block; font-size: 12px; color: var(--text-muted); }
.rv-h { font-size: 14px; margin: 18px 0 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.rv-inline, .rv-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.rv-inline input:not([type="checkbox"]) { flex: 1 1 200px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 4px; }
.rv-check { font-size: 12px; display: flex; gap: 4px; align-items: center; }
.rv-main-actions { display: flex; gap: 6px; }
.rv-links > div { padding: 3px 0; }
.rv-unlinked { color: var(--text-muted); text-decoration: line-through; }
.rv-flags { margin: 0; padding-left: 18px; font-size: 13px; }
.rv-related { display: flex; flex-direction: column; gap: 2px; font-size: 13px; margin-bottom: 8px; }
.rv-history { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

@media (max-width: 900px) {
  .review-grid > .review-wide { grid-column: auto; }
  .review-split { grid-template-columns: 1fr; }
  .review-original { position: static; max-height: none; }
}

/* ---------- loading indicator ---------- */

#busy-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000;
  overflow: hidden; opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
#busy-bar::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
  background: var(--amber); animation: busy-slide 1.1s ease-in-out infinite;
}
body.is-loading #busy-bar { opacity: 1; }
body.is-loading { cursor: progress; }
@keyframes busy-slide { from { left: -40%; } to { left: 100%; } }

button.is-busy { position: relative; color: transparent !important; cursor: progress; }
button.is-busy::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid var(--text-muted); border-right-color: transparent; border-radius: 50%;
  animation: busy-spin 0.7s linear infinite;
}
.btn-amber.is-busy::after { border-color: var(--white); border-right-color: transparent; }
/* the top bar's refresh button keeps its spinner (::after is its tooltip elsewhere) */
#refresh-btn.is-busy::after { display: block; content: ""; opacity: 1; top: 50%; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; padding: 0; transform: none; background: none; box-shadow: none;
  border: 2px solid var(--white); border-right-color: transparent; border-radius: 50%; animation: busy-spin 0.7s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  #busy-bar::before { animation-duration: 3s; }
  button.is-busy::after { animation-duration: 2s; }
}

/* ---------- billing setup ---------- */

.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.setup-summary { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 6px 20px; }
.setup-summary li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.setup-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.setup-dot.ok { background: var(--success); }
.setup-dot.todo { background: var(--amber); }
.setup-missing { color: #9a6200; }
#setup-clients-table select, #setup-clients-table input { font-size: 13px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; max-width: 100%; }
#setup-clients-table input[type="number"] { width: 90px; }
tr.setup-dirty { background: #fff8e8; }
code.fee-code { font-size: 11px; color: var(--text-muted); }

/* ---------- bill editor ---------- */

.bill-editor-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.bill-editor-head h2 { margin: 0; font-size: 20px; color: var(--navy); flex: 1 1 auto; }
.bill-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bill-header-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.bill-header-grid .field:first-child { grid-column: span 2; }
.be-default-matters { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
table.bill-lines td { vertical-align: top; padding: 8px 6px; }
table.bill-lines input, table.bill-lines select { font-size: 13px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 4px; max-width: 100%; }
.line-desc { width: 100%; min-width: 220px; }
.line-reason { width: 100%; margin-top: 4px; border-color: var(--amber) !important; }
.line-num { width: 92px; text-align: right; }
.line-qty { width: 64px; }
.line-discount { white-space: nowrap; }
.line-move { display: flex; }
.line-move .btn { padding: 0 3px; font-size: 12px; }
.line-matters .chip { font-size: 12px; margin: 0 2px 2px 0; display: inline-block; }
tr.line-override { background: #fff8e8; }
.bill-bottom { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.bill-totals .bill-grand { font-size: 17px; border-top: 2px solid var(--navy); padding-top: 6px; }
#be-problems { margin-top: 10px; color: #9a6200; }
.mp-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; margin: 8px 0; }
.mp-row { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.mp-row:hover { background: var(--gray-blue); }
@media (max-width: 900px) {
  .bill-bottom { grid-template-columns: 1fr; }
  .bill-header-grid .field:first-child { grid-column: auto; }
}

/* ---------- printable Statement of Account ---------- */

.modal-soa { max-width: 860px; }
.soa-toolbar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 12px; }
.soa { position: relative; color: #111; font-size: 13px; padding: 24px; border: 1px solid var(--border); background: #fff; overflow: hidden; }
.soa-watermark { position: absolute; top: 40%; left: 0; right: 0; text-align: center; font-size: 96px; font-weight: 800; color: rgba(179, 38, 30, 0.08); transform: rotate(-20deg); pointer-events: none; }
.soa-top { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.soa-company { font-size: 18px; font-weight: 700; color: var(--navy); }
.soa-title h1 { margin: 0 0 6px; font-size: 20px; text-align: right; color: var(--navy); }
.soa-meta th { text-align: left; font-weight: 600; padding: 1px 10px 1px 0; color: #555; }
.soa-billto { margin-bottom: 16px; }
.soa-small { font-size: 11px; color: #555; }
.soa-lines { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.soa-lines th { text-align: left; border-bottom: 2px solid #333; padding: 6px 4px; font-size: 12px; }
.soa-lines td { border-bottom: 1px solid #ddd; padding: 6px 4px; vertical-align: top; }
.soa-lines .num, .soa-totals td { text-align: right; }
.soa-totals { margin-left: auto; min-width: 300px; border-collapse: collapse; }
.soa-totals th { text-align: left; font-weight: 500; padding: 3px 12px 3px 0; }
.soa-grand th, .soa-grand td { font-weight: 700; font-size: 15px; border-top: 2px solid #333; padding-top: 6px; }
.soa-notes { margin-top: 14px; white-space: pre-wrap; }
.soa-foot { margin-top: 24px; text-align: center; }
@media print {
  html:has(body.printing-soa), body.printing-soa { background: #fff !important; }
  body.printing-soa > *:not(#modal-root) { display: none !important; }
  body.printing-soa #modal-root .modal-overlay { position: static; background: none; padding: 0; }
  body.printing-soa .modal { max-width: none; max-height: none; overflow: visible; padding: 0; box-shadow: none; }
  body.printing-soa .soa-toolbar { display: none; }
  body.printing-soa .soa { border: none; padding: 14mm 16mm; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
}
/* Zero page margin: browsers then leave out their own header and footer
   (date, page title, web address, page numbers). The letter's own padding
   (cloned onto every page) gives the white border instead. */
@page { margin: 0; }

/* ---------- tax checks ---------- */
.tax-warning { color: #9a6200; font-size: 13px; }
.tax-check-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- inquiries ---------- */
.inq-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 900px) { .inq-board { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .inq-board { grid-template-columns: 1fr; } }
.inq-col { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 10px; min-height: 120px; }
.inq-col-head { font-weight: 700; font-size: 0.86rem; margin-bottom: 8px; display: flex; justify-content: space-between; }
.inq-card { background: var(--gray-blue); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; font-size: 0.88rem; }
.inq-card:hover { border-color: var(--amber); }
.inq-card-top { display: flex; justify-content: space-between; gap: 8px; }
.inq-card-due { margin-top: 6px; }
.inq-card-due .badge { white-space: normal; text-align: left; }
/* contact channels (phase35a) */
.inq-card-contact { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: var(--fs-xs); }
.inq-sort { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.ch-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ch-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: var(--fs-sm); text-decoration: none; min-height: 32px; transition: border-color var(--ease), background var(--ease); }
a.ch-chip:hover { border-color: var(--amber); background: var(--amber-50); }
a.ch-chip:focus-visible, a.ch-pref:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ch-chip .lucide { color: var(--text-muted); flex: none; }
.ch-chip.ch-preferred { border-color: var(--amber); }
.ch-name { font-weight: 600; }
.ch-value { color: var(--text-muted); overflow-wrap: anywhere; }
.ch-star { color: var(--amber-600); }
.ch-pref { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--navy); text-decoration: none; }
a.ch-pref:hover { text-decoration: underline; }
.ch-last { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); }
.ch-editor { display: flex; flex-direction: column; gap: 6px; }
.ch-row { display: grid; grid-template-columns: 130px minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.ch-pref-pick { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; cursor: pointer; }
@media (max-width: 640px) { .ch-row { grid-template-columns: 1fr 1fr; } .ch-row .ch-val, .ch-row .ch-note { grid-column: span 2; } .ch-list { justify-content: flex-start; } }
.inq-empty { padding: 6px 2px; }
.inq-mark { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.inq-logo { max-width: 120px; max-height: 90px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.inq-mark-name { font-size: 1.2rem; font-weight: 700; }
.inq-goods-table textarea, .inq-goods-table .inq-activity { width: 100%; box-sizing: border-box; }
.inq-goods-table .inq-activity { margin-bottom: 6px; }
.inq-goods-table .inq-class { width: 70px; }
.inq-pipeline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.inq-pipe-step { display: flex; flex-direction: column; align-items: center; min-width: 96px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--gray-blue); cursor: pointer; font: inherit; }
.inq-pipe-step strong { font-size: 1.3rem; color: var(--navy); }
.inq-pipe-step span { font-size: 0.78rem; color: var(--text-muted); }
.inq-pipe-arrow { color: var(--text-muted); }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 14px; }
.role-grid label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.role-grid input { width: auto; }
.role-panels li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.role-panels li input { width: auto; }
.role-panels { list-style: none; padding: 0; margin: 0; }

/* ---------- trademark search report & proposal ---------- */
.tsr { font-size: 14px; line-height: 1.5; padding: 0; }
.tsr-page { padding: 36px 40px; }
.tsr-page + .tsr-page { border-top: 1px dashed var(--border); }
.tsr-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.tsr-firm { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; color: var(--navy); text-transform: lowercase; }
.tsr-firm::first-letter { color: var(--amber); }
.tsr-head-right { text-align: right; font-size: 11px; color: #666; }
.tsr-meta { color: #555; font-size: 13px; }
.tsr-title { font-size: 34px; margin: 6px 0 14px; color: var(--navy); letter-spacing: 0.5px; }
.tsr-verdict { border-radius: 10px; padding: 14px 18px; margin-bottom: 18px; border: 2px solid; }
.tsr-verdict-label { font-size: 19px; font-weight: 800; margin-bottom: 2px; }
.tsr-ok { background: #eaf6ee; border-color: #6fbf8a; color: #14532d; }
.tsr-warn { background: #fff7e0; border-color: #e9b949; color: #6b4e00; }
.tsr-danger { background: #fdecea; border-color: #e07a72; color: #8a1c14; }
.tsr-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.tsr-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tsr-card-k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: #666; font-weight: 700; }
.tsr-card-v { font-size: 18px; font-weight: 800; color: var(--navy); margin: 2px 0; }
.tsr-small { font-size: 12px; color: #555; }
.tsr-h { font-size: 17px; color: var(--navy); margin: 18px 0 8px; }
.tsr-todo { padding-left: 22px; margin: 0 0 10px; }
.tsr-todo li { margin-bottom: 6px; }
.tsr-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.tsr-table th { text-align: left; font-size: 12px; color: #555; border-bottom: 2px solid #333; padding: 6px 8px; }
.tsr-table td { border-bottom: 1px solid #ddd; padding: 8px; vertical-align: top; }
.tsr-table .num { text-align: right; white-space: nowrap; }
.tsr-classes .tsr-class { font-weight: 800; font-size: 16px; color: var(--navy); white-space: nowrap; }
.tsr-classes td:first-child { width: 28%; font-weight: 600; }
.tsr-cost td:last-child { width: 35%; }
.tsr-total td { font-weight: 800; font-size: 16px; border-top: 2px solid #333; }
.tsr-steps .tsr-step-n { width: 28px; font-weight: 800; color: var(--amber); }
.tsr-steps .tsr-step-when { width: 30%; font-weight: 700; }
.tsr-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tsr-close-identical, .tsr-close-very_similar { background: #fdecea; color: #8a1c14; }
.tsr-close-similar { background: #fff7e0; color: #6b4e00; }
.tsr-close-not_close { background: #eaf6ee; color: #14532d; }
.tsr-list { padding-left: 20px; }
.tsr-text { white-space: pre-wrap; }
@media screen and (max-width: 700px) { .tsr-cards { grid-template-columns: 1fr; } .tsr-page { padding: 20px 16px; } }
@media print {
  body.printing-soa .tsr { padding: 0; }
  body.printing-soa .tsr-page { break-after: page; border-top: none; padding: 14mm 16mm; }
  body.printing-soa .tsr-page:last-child { break-after: auto; }
  body.printing-soa .tsr * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.filing-items { list-style: none; padding: 0; margin: 0 0 8px; }
.filing-items li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.filing-items label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.filing-items input { width: auto; }
.filing-done { text-decoration: line-through; color: var(--text-muted); }

/* the firm's logo on letters (phase27a) */
.letterhead-logo { display: block; max-height: 56px; max-width: 240px; object-fit: contain; margin-bottom: 6px; }
.tsr-firm.has-logo::first-letter { color: inherit; }
.tsr-firm.has-logo .letterhead-logo { max-height: 48px; margin: 0; }
.letterhead-admin { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.letterhead-admin .letterhead-preview { min-width: 200px; min-height: 60px; border: 1px dashed var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 8px; background: #fff; }
.letterhead-admin .letterhead-preview img { max-height: 56px; max-width: 240px; }

/* missing important details on clients / applicants */
.missing-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 400; white-space: nowrap; }
.missing-toggle input { width: auto; }
.missing-summary { font-size: 0.85rem; color: #6b4e00; margin: 0 0 8px; }
.missing-badge { margin-left: 6px; font-size: 0.68rem; vertical-align: middle; }

/* Migration review: step by step */
.rv-progress { height: 10px; background: var(--gray-blue); border-radius: 5px; overflow: hidden; margin: 4px 0 8px; }
.rv-progress > div { height: 100%; background: var(--amber); }
.rv-steps { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rv-step { display: flex; gap: 14px; background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.rv-step-current { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(232, 160, 32, 0.18); }
.rv-step-done, .rv-step-idle { opacity: 0.65; }
.rv-step-idle .rv-step-num { background: var(--text-muted); }
.rv-step-num { flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.rv-step-done .rv-step-num { background: #2e7d4f; }
.rv-step-main { flex: 1; min-width: 0; }
.rv-step-main .panel { box-shadow: none; border: none; padding: 0; margin: 8px 0 0; }
.rv-step-main .panel-header h2 { font-size: 0.95rem; }
.rv-step-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.rv-step-status { font-size: 0.85rem; color: var(--text-muted); }
.rv-step-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.rv-nextstep { background: #fff8e6; border: 1px solid var(--amber); border-radius: 6px; padding: 10px 12px; margin: 8px 0 12px; }
.rv-nextstep-flags { margin: 6px 0 0 18px; padding: 0; font-size: 0.85rem; }
.rv-more { margin-top: 14px; }
.rv-more > summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 8px 0; border-top: 1px solid var(--border); }

/* With the logo on a statement, the firm's name is in the logo: the big
   name line steps aside and the legal name moves into the small address line. */
.soa-legal { display: none; }
.has-logo + .soa-company { display: none; }
.has-logo ~ .soa-small .soa-legal { display: inline; }

/* the in-app guide (js/guide.js) */
.modal.modal-guide { max-width: 1000px; width: 100%; height: 86vh; display: flex; flex-direction: column; }
.guide-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.guide-head h3 { margin: 0; }
.guide-head .search-input { flex: 1; max-width: 360px; margin-left: auto; }
.guide { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; flex: 1; min-height: 0; }
.guide-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; border-right: 1px solid var(--border); padding-right: 10px; }
.guide-nav a { padding: 7px 10px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 0.9rem; }
.guide-nav a:hover { background: var(--gray-blue); }
.guide-nav a.active { background: var(--navy); color: #fff; font-weight: 600; }
.guide-body { overflow-y: auto; padding-right: 6px; line-height: 1.55; font-size: 0.93rem; }
.guide-body h2 { margin-top: 0; font-size: 1.25rem; }
.guide-body h4 { margin: 16px 0 6px; color: var(--navy); }
.guide-body ul, .guide-body ol { padding-left: 20px; }
.guide-body li { margin-bottom: 4px; }
.guide-dl dt { font-weight: 700; margin-top: 8px; }
.guide-dl dd { margin: 2px 0 0; color: var(--text-muted); }
@media (max-width: 700px) {
  .guide { grid-template-columns: 1fr; }
  .guide-nav { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); padding: 0 0 8px; overflow: visible; }
  .guide-head { flex-wrap: wrap; }
}

/* case documents (js/documents.js) */
.doc-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.doc-toolbar .search-input { flex: 1; min-width: 200px; max-width: 360px; }
#documents-table td:first-child, #documents-table th:first-child { width: 28px; }
#documents-table input[type="checkbox"] { width: auto; }
.doc-links { margin-top: 3px; }
.doc-history { margin-top: 4px; font-size: 0.82rem; }
.doc-history summary { cursor: pointer; color: var(--text-muted); }
.doc-history ul { margin: 4px 0 0; padding-left: 18px; }
.doc-chip { display: inline-block; font-size: 0.8rem; padding: 1px 8px; margin: 2px 4px 0 0; border: 1px solid var(--border); border-radius: 999px; background: var(--gray-blue); color: var(--navy); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.doc-chip:hover { border-color: var(--amber); }
.event-docs { margin-top: 6px; }
.event-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.event-head .row-actions { display: inline-flex; align-items: center; gap: 4px; }
.panel .party-warning[data-event-mismatch] { margin: 6px 0; }
.filing-item-side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.doc-quick-upload { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.doc-quick-upload .field { margin: 0; }
@media (max-width: 700px) {
  #documents-table th:nth-child(3), #documents-table td:nth-child(3), #documents-table th:nth-child(5), #documents-table td:nth-child(5) { display: none; }
}

/* matter structure (js/structure.js) */
.mh-family { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; font-size: 0.86rem; }
.mh-family .family-link { font-weight: 600; }
tr.party-ended td { color: var(--text-muted); }
tr.party-ended .party-link { color: var(--text-muted); }
#nm-dupes ul, #em-dupes ul { margin: 4px 0 4px 18px; padding: 0; }

/* who owes us (js/reports.js) */
.who-owes-summary { font-size: 1.05rem; margin: 0 0 6px; line-height: 1.5; }
#who-owes-table .badge { font-size: 0.68rem; vertical-align: middle; }

/* ---------- global search (top bar) ---------- */
.global-search { position: relative; flex: 1; max-width: 460px; }
.global-search input { width: 100%; height: 36px; padding: 0 36px 0 36px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.06); color: var(--white); font: inherit; font-size: 0.88rem;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease; }
.global-search input:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.22); }
.global-search input::placeholder { color: rgba(255, 255, 255, 0.55); }
.global-search input:focus { outline: none; background: var(--white); border-color: var(--white); color: var(--text); box-shadow: 0 0 0 3px rgba(240, 163, 20, 0.45); }
.global-search-icon { position: absolute; left: 10px; top: 9px; color: rgba(255, 255, 255, 0.55); pointer-events: none; transition: color 150ms ease; }
.global-search:focus-within .global-search-icon { color: var(--text-muted); }
.global-search-kbd { position: absolute; right: 9px; top: 8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.2); color: rgba(255, 255, 255, 0.55);
  font-family: inherit; font-size: 0.72rem; font-weight: 600; line-height: 18px; text-align: center; pointer-events: none; }
.global-search:focus-within .global-search-kbd { display: none; }
.global-search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; background: var(--white); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(3, 26, 44, 0.18); max-height: 70vh; overflow-y: auto; padding: 6px 0; }
.gs-group-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); padding: 8px 14px 4px; }
.gs-hit { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left; background: none; border: none; padding: 6px 14px; font: inherit; cursor: pointer; color: inherit; }
.gs-hit:hover, .gs-hit:focus { background: #f4f6f9; }
.gs-empty { padding: 10px 14px; color: var(--text-muted); font-size: 0.9rem; }
@media (max-width: 860px) { .account-text { display: none; } }
@media (max-width: 640px) {
  header.topbar { flex-wrap: wrap; padding: 8px 12px; row-gap: 8px; }
  .global-search { order: 3; flex-basis: 100%; max-width: none; }
  .global-search-kbd { display: none; }
}

/* ---------- applicant = client (js/same-as-client.js) ---------- */
.inline-check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-base); color: var(--text); cursor: pointer; }
.inline-check input { width: 16px; height: 16px; accent-color: var(--navy); margin: 0; }
.same-as-note { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-subtle); font-size: var(--fs-sm); color: var(--text); }
.same-as-note .lucide { color: var(--text-subtle); flex: none; margin-top: 1px; }
.same-as-note .cell-sub { display: block; margin-top: 2px; }
.same-as-empty { margin: 0 0 10px; }
.same-as-empty .btn-text { font-size: var(--fs-sm); padding: 0 4px; }
.same-as-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.choice-list { display: grid; gap: 8px; margin: 14px 0 4px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 10px 12px; text-align: left; font: inherit; color: var(--text); background: var(--white); border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; transition: border-color var(--ease), background-color var(--ease); }
.choice:hover { border-color: var(--navy); background: var(--surface-subtle); }
.choice:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--amber); }
.choice .cell-sub { margin: 0; }
.choice-note { color: var(--warn); }
details.same-review { padding: 0; }
details.same-review > summary { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 16px 20px; cursor: pointer; list-style: none; }
details.same-review > summary::-webkit-details-marker { display: none; }
details.same-review > summary h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
details.same-review > summary::after { content: "▸"; color: var(--text-subtle); margin-left: auto; transition: transform var(--ease); }
details.same-review[open] > summary::after { transform: rotate(90deg); }
details.same-review > :not(summary) { margin-left: 20px; margin-right: 20px; }
details.same-review > :last-child { margin-bottom: 20px; }
.detail-grid .field-wide { grid-column: 1 / -1; }
.detail-grid .ch-list { justify-content: flex-start; }

/* ---------- inquiries: stages, next step, checklist (UX review) ---------- */
.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; }
.req { color: var(--danger); font-weight: 600; }
.inq-col-hint { font-size: var(--fs-xs); color: var(--text-muted); margin: -4px 0 8px; }
.inq-steps { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 4px 0 16px; padding: 0; counter-reset: none; }
.inq-step { position: relative; display: flex; gap: 0; align-items: flex-start; padding: 0 12px 0 0; }
.inq-step::after { content: ""; position: absolute; top: 13px; left: 28px; right: 0; height: 2px; background: var(--border); }
.inq-step:last-child::after { display: none; }
.inq-step-done::after { background: var(--success); }
.inq-step-dot { position: relative; z-index: 1; flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 700; border: 2px solid var(--border-strong); background: var(--surface); color: var(--text-muted); }
.inq-step-done .inq-step-dot { background: var(--success); border-color: var(--success); color: var(--white); }
.inq-step-closed .inq-step-dot { background: var(--text-subtle); border-color: var(--text-subtle); }
.inq-step-current .inq-step-dot { border-color: var(--amber); color: var(--navy); background: var(--amber-50); box-shadow: 0 0 0 3px rgba(240, 163, 20, 0.2); }
.inq-step-text { position: relative; z-index: 1; display: flex; flex-direction: column; background: var(--surface); padding: 0 10px; margin-top: 3px; }
.inq-step-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.inq-step-todo .inq-step-label { color: var(--text-muted); font-weight: 500; }
.inq-step-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.inq-step-current .inq-step-sub { color: var(--warn); font-weight: 500; }
.inq-actionbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 12px; }
.inq-ab-main, .inq-ab-group, .inq-ab-end { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inq-ab-group { padding-left: 18px; border-left: 1px solid var(--border); }
.inq-ab-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.inq-ab-end { margin-left: auto; }
.inq-checklist { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-top: 12px; background: var(--surface-subtle); }
.inq-checklist-ok { border-color: var(--success); background: var(--success-bg); }
.inq-checklist-head { font-weight: 600; font-size: var(--fs-sm); margin-bottom: 4px; }
.inq-checklist ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.inq-checklist li { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.inq-checklist li.ok { color: var(--success); }
.inq-checklist li.missing { color: var(--text); }
.inq-check-mark { font-weight: 700; width: 14px; text-align: center; }
.inq-check-text { display: inline-block; }
.inq-check-text::first-letter { text-transform: uppercase; }
/* search & proposal */
.tsr-part { display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.tsr-part:first-of-type { border-top: none; padding-top: 0; margin-top: 4px; }
.tsr-part-n { width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: var(--white); font-size: var(--fs-xs); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tsr-add-hit { margin-top: 8px; }
.tsr-footer { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 18px -20px -20px; padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.tsr-footer-info { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-sm); color: var(--text-muted); }
.tsr-footer-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tsr-dirty { color: var(--warn); font-weight: 600; }
.tsr-sent-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: var(--fs-sm); color: var(--text-muted); }
/* the channel editor inside forms: keep the radio and its label inline */
.ch-row .ch-pref-pick { display: inline-flex; margin: 0; font-weight: 500; }
.ch-row input[type="radio"] { width: auto; padding: 0; }
@media (max-width: 760px) {
  .inq-steps { grid-template-columns: 1fr; gap: 10px; }
  .inq-step::after { display: none; }
  .inq-ab-group { padding-left: 0; border-left: none; }
  .inq-ab-end { margin-left: 0; }
  #view-inquiries .panel-header { flex-wrap: wrap; gap: 10px; }
  #view-inquiries .panel-header-actions { flex-wrap: wrap; width: 100%; }
  #view-inquiries #inquiries-search { flex: 1 1 100%; }
  .tsr-footer { margin: 18px -16px -16px; padding: 12px 16px; }
}
.ch-editor-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 4px; }
.ch-same { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.contact-channels .ch-list { justify-content: flex-start; }
.inq-entry { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.inq-entry .icon-btn { flex: none; opacity: 0.6; }
.inq-entry:hover .icon-btn, .inq-entry .icon-btn:focus-visible { opacity: 1; }
.ch-same[hidden] { display: none; }
.filing-deposit-bill { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: var(--fs-sm); }
.filing-deposit-bill label { font-weight: 600; }
.filing-deposit-bill select { padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); max-width: 100%; }

/* patents: claim counter, "To check" list (phase36a) */
.claims-counter { display: inline-flex; align-items: center; gap: 4px; }
.claims-counter input { width: 64px; padding: 4px 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); text-align: center; font: inherit; }
.claims-counter .btn { min-width: 30px; padding: 2px 8px; }
.mh-fact-wide { grid-column: 1 / -1; }
.matter-checks { border: 1px solid var(--warn); background: var(--warn-bg); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
.matter-checks-head { margin-bottom: 6px; }
.matter-checks-list, .matter-checks-done ul { list-style: none; margin: 0; padding: 0; }
.matter-checks-list li, .matter-checks-done li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px solid rgba(161, 92, 0, 0.15); font-size: var(--fs-sm); }
.matter-checks-list li:first-child { border-top: none; }
.matter-checks-done summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 6px; }
.matters-checks-hint { display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 10px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); font-size: var(--fs-sm); }

/* Matters: one tab per IP type, with counts and quick filters */
.ip-tabs { flex-wrap: wrap; margin-bottom: 10px; }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--surface-hover); color: var(--text-muted); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.subtabs button.active .tab-count { background: var(--navy); color: #fff; }
.matters-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.quick-chip { border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); border-radius: 999px; padding: 4px 10px; font-size: var(--fs-sm); cursor: pointer; transition: border-color var(--ease), color var(--ease); }
.quick-chip:hover { border-color: var(--border-strong); color: var(--text); }
.quick-chip.active { border-color: var(--navy); color: var(--navy); font-weight: 600; background: var(--surface-subtle); }
.quick-chip.active .tab-count { background: var(--navy); color: #fff; }
#matters-table td .due-overdue { color: var(--danger); font-weight: 600; }
#matters-table td .due-soon { color: var(--warn); font-weight: 600; }

/* Missed deadlines (phase39a) */
.missed-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: #FDECEA; border-bottom: 1px solid #F5C2BD; color: #8A1C14; font-size: var(--fs-sm); }
.missed-banner.hidden { display: none; }
.nav-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.btn-missed { color: var(--danger); font-weight: 600; }
.missed-flag { color: var(--danger); font-weight: 600; }
.missed-seen { color: var(--text-muted); }
.ack-reasons { display: flex; flex-direction: column; gap: 4px; }

/* Search inside documents (phase40a) */
.doc-text-hit { margin-top: 4px; font-size: var(--fs-sm); color: var(--text); background: var(--surface-subtle); border-left: 3px solid var(--amber); padding: 4px 8px; border-radius: 4px; }
.doc-text-hit mark, .gs-hit mark { background: #FFE8A3; color: inherit; padding: 0 1px; border-radius: 2px; }
.doc-text-status { display: inline-flex; align-items: center; gap: 6px; }
.gs-snippet { display: block; margin-top: 2px; white-space: normal; }
/* Matters list: fixed column widths (set per tab in renderMattersTable) */
#matters-table { table-layout: fixed; width: 100%; }
#matters-table td { overflow-wrap: anywhere; }
#matters-table td .due-cell { white-space: nowrap; }
#matters-table th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Contracts (phase41a) */
.progress { display: inline-block; width: 90px; height: 7px; border-radius: 999px; background: var(--surface-hover); vertical-align: middle; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--navy); border-radius: 999px; }
.progress.done > span { background: var(--success, #1e8e4f); }
.contract-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.contract-kpi { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--surface-subtle); }
.contract-kpi-value { font-size: 1.15rem; font-weight: 700; color: var(--navy); margin: 2px 0; }
.contract-kpi .progress { width: 100%; }
.milestone-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.milestone-card.is-cancelled { opacity: 0.6; }
.milestone-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.milestone-amount { text-align: right; font-weight: 600; white-space: nowrap; }
.milestone-progress { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: var(--fs-sm); color: var(--text-muted); }
.milestone-progress .progress { width: 220px; height: 9px; }
.milestone-bills { font-size: var(--fs-sm); margin-bottom: 6px; }
.milestone-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.contract-matters .ms-col { text-align: center; width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-done { color: var(--success, #1e8e4f); font-weight: 700; }
.ms-open { color: var(--text-muted); }
.table-scroll { overflow-x: auto; margin: 0 -2px; padding: 0 2px; }
.table-scroll > table.data-table { min-width: 100%; }
/* long titles: two lines at most in a list (the matter page shows all of it) */
#all-deadlines-table td[data-col="matter"] strong, #matters-table td[data-ck="matter"] strong, #matters-table td[data-ck="mark"] strong,
#client-matters-table td strong, #applicant-matters-table td strong {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#all-deadlines-table td[data-col="matter"] { min-width: 200px; max-width: 340px; }
#all-deadlines-table td[data-col="description"] { min-width: 160px; }
table.data-table td.row-actions { white-space: nowrap; }
.tick-list { max-height: 55vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.tick-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tick-row:last-child { border-bottom: none; }
.tick-proof { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tick-proof input[type="file"] { max-width: 210px; font-size: var(--fs-sm); }
.tick-proof select, .tick-proof input[data-tick-note] { max-width: 220px; font-size: var(--fs-sm); }
.tick-done { font-size: var(--fs-sm); color: var(--text-muted); }
.detail-back { margin-bottom: 8px; }
.old-group .panel-header-actions select { max-width: 280px; }
.old-group td select { max-width: 240px; }

/* Smaller laptops and tablets lying flat: a row's buttons can wrap onto a
   second line instead of pushing the list off the right edge. */
/* (row buttons stay on one line: a wide list scrolls inside its own box instead — .table-scroll) */

/* ---------- Phones and upright tablets (≤ 820px) ----------
   Lists become cards: one card per row, each value with its column name
   (js/mobile.js puts the names on the cells). The column names you can sort
   by stay at the top as small buttons. Nothing scrolls sideways. */
@media (max-width: 820px) {
  main.content { padding: 12px; }
  .panel { padding: 14px; border-radius: var(--radius); }
  .panel-header { flex-wrap: wrap; }
  .panel-header-actions { flex-wrap: wrap; width: 100%; }
  .search-input { min-width: 0; }
  .panel-header-actions .search-input { flex: 1 1 100%; }
  .panel-header-actions label { white-space: normal; }

  table.data-table { display: block; width: auto; }
  table.data-table > tbody, table.data-table > tfoot { display: block; width: 100%; }
  .subtabs { flex-wrap: wrap; }
  .subtabs button { padding: 8px 10px; }
  details.same-review > :not(summary) { margin-left: 14px; margin-right: 14px; }
  details.same-review > summary { padding: 14px; }
  table.data-table > colgroup { display: none; }
  table.data-table > thead { display: block; }
  table.data-table > thead tr { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; }
  table.data-table > thead th { display: none; }
  table.data-table > thead th.sortable { display: inline-flex; align-items: center; width: auto !important; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--white); overflow: visible; }
  table.data-table > tbody > tr, table.data-table > tfoot > tr { display: block; border: 1px solid var(--border); border-radius: 8px; padding: 4px 12px; margin-bottom: 8px; background: var(--white); }
  table.data-table > tbody > tr.hidden { display: none; }
  table.data-table > tbody > tr > td, table.data-table > tfoot > tr > td, table.data-table > tfoot > tr > th {
    display: block; position: relative; padding: 6px 0 6px 38%; min-height: 30px; border-bottom: 1px dashed var(--border); text-align: left !important; overflow-wrap: anywhere; white-space: normal; width: auto !important;
  }
  table.data-table > tbody > tr > td:last-child, table.data-table > tfoot > tr > td:last-child { border-bottom: none; }
  table.data-table > tbody > tr > td::before, table.data-table > tfoot > tr > td::before {
    content: attr(data-label); position: absolute; left: 0; top: 8px; width: calc(38% - 10px);
    color: var(--text-subtle); font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; overflow-wrap: anywhere;
  }
  table.data-table td[data-label=""], table.data-table td:not([data-label]) { padding-left: 0; min-height: 0; }
  table.data-table td[data-label=""]::before, table.data-table td:not([data-label])::before { display: none; }
  table.data-table td:empty { display: none; }
  table.data-table td .row-actions, table.data-table td .btn { flex-wrap: wrap; }
  table.data-table input[type="checkbox"] { width: 20px; height: 20px; }
  #matters-table { table-layout: auto; }
  #matters-table td { padding: 6px 0 6px 38%; }
  #matters-table td .due-cell { white-space: normal; }

  .modal-overlay { padding: 8px; }
  .modal { padding: 18px 16px; max-height: 92vh; border-radius: 12px; }
  .modal-actions { flex-wrap: wrap; gap: 8px; }
  .detail-grid { grid-template-columns: 1fr; }
  input[type="file"] { max-width: 100%; min-width: 0; }
  .btn { min-height: 36px; }
  /* iPhones zoom in on any text box under 16px when you tap it */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea, .search-input, .global-search input { font-size: 16px; }
}

/* old docket numbers (phase42a) */
.mh-former { color: var(--text-muted); font-style: italic; }
.former-ref { color: var(--text-muted); font-style: italic; }

/* ---------- Phone snapshot (body.phone, ≤ 640px; js/mobile.js) ----------
   A read-only snapshot: the Today home, a bar at the bottom, short cards in
   the main lists, "What's next" on a matter, and nothing that changes data. */
.phone-only { display: none; }
body.phone .phone-only { display: block; }
body.phone nav.tabs { display: none; }
body.phone main.content { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
body.phone header.topbar { padding-top: max(8px, env(safe-area-inset-top)); }

.phone-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--white); border-top: 1px solid var(--border);
  padding: 4px 4px env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(3, 26, 44, 0.06); }
body.phone .phone-bar { display: flex; }
.phone-bar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 8px; min-height: 56px;
  background: none; border: none; color: var(--text-muted); font: inherit; font-size: 0.72rem; font-weight: 500; cursor: pointer; }
.phone-bar button .lucide { width: 22px; height: 22px; }
.phone-bar button.active { color: var(--navy); font-weight: 700; }
.phone-bar button.active .lucide { color: var(--amber); }
.phone-bar button.hidden { display: none; }
.phone-more { display: grid; gap: 6px; margin-bottom: 12px; }
.phone-more-item { text-align: left; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); font: inherit; font-weight: 600; color: var(--text); }

/* Today */
body.phone #view-dashboard .dash-quick, body.phone #view-dashboard .dash-cards, body.phone #view-dashboard .dash-grid,
body.phone #view-dashboard .whats-new, body.phone #view-dashboard .dash-scope { display: none; }
.pt-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.pt-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--white); text-decoration: none; color: var(--text); }
.pt-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.pt-label { font-size: 0.8rem; color: var(--text-muted); }
.pt-tile.tone-danger .pt-num { color: var(--danger); }
.pt-tile.tone-warn .pt-num { color: var(--warn); }
.pt-tile.tone-info .pt-num { color: var(--navy); }
.pt-tile.tone-zero .pt-num { color: var(--text-subtle); }
.pt-panel h2 { margin: 0 0 8px; font-size: var(--fs-md); }
.pt-list { list-style: none; margin: 0; padding: 0; }
.pt-list li + li { border-top: 1px solid var(--border); }
.pt-item { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 10px 0; text-decoration: none; color: var(--text); }
.pt-what { display: block; color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }
.pt-more { display: inline-block; margin-top: 6px; font-size: var(--fs-sm); }
.pt-activity .ra-list li:nth-child(n+7) { display: none; }

/* Matter: What's next */
.matter-next { margin: 12px 0 4px; padding: 12px; border-radius: 10px; background: var(--surface-subtle); border: 1px solid var(--border); }
.matter-next h3 { margin: 0 0 6px; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle); }
.mn-row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 4px 0; }
.mn-label { font-size: 0.72rem; color: var(--text-subtle); font-weight: 600; }
.mn-what { font-weight: 600; }
.phone-note { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-subtle); border: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-sm); }

/* Read only: nothing that changes data (pagination, Back and Close stay) */
body.phone main .btn:not(.phone-keep):not([id^="back-to-"]):not(.detail-back),
body.phone #modal-root .btn:not(.phone-keep):not([data-close-modal]),
body.phone main .more-menu, body.phone #matter-more, body.phone main .row-actions, body.phone main .icon-btn,
body.phone main input[type="file"], body.phone main .doc-quick-upload, body.phone main .rep-upload,
body.phone main table.data-table input[type="checkbox"], body.phone main .doc-toolbar .btn { display: none !important; }
body.phone main .pagination .btn { display: inline-flex !important; }

/* Short cards: Matters and Deadlines */
body.phone .missed-banner { display: none; }
body.phone #deadlines-table > tbody > tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; padding: 10px 12px; }
body.phone #deadlines-table td[data-col] { padding: 0 !important; min-height: 0; border: none; }
body.phone #deadlines-table td[data-col]::before { display: none; }
body.phone #deadlines-table td[data-col="origin"], body.phone #deadlines-table td[data-col="actions"] { display: none; }
body.phone #deadlines-table td[data-col="due"] { grid-column: 1; grid-row: 1; }
body.phone #deadlines-table td[data-col="status"] { grid-column: 2; grid-row: 1; text-align: right !important; }
body.phone #deadlines-table td[data-col="description"] { grid-column: 1 / -1; font-weight: 600; }
body.phone #deadlines-table td[data-col="assigned"] { grid-column: 1 / -1; color: var(--text-muted); font-size: var(--fs-sm); }
body.phone #matters-table > tbody > tr, body.phone #all-deadlines-table > tbody > tr {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; padding: 10px 12px; }
body.phone #matters-table td[data-col], body.phone #all-deadlines-table td[data-col] { padding: 0 !important; min-height: 0; border: none; }
body.phone #matters-table td[data-col]::before, body.phone #all-deadlines-table td[data-col]::before { display: none; }
body.phone #matters-table td[data-col]:not([data-col="matter"]):not([data-col="mark"]):not([data-col="next"]):not([data-col="nextAction"]) { display: none; }
body.phone #matters-table td[data-col="matter"], body.phone #matters-table td[data-col="mark"] { grid-column: 1; grid-row: 1; }
body.phone #matters-table td[data-col="next"] { grid-column: 2; grid-row: 1; text-align: right !important; }
body.phone #matters-table td[data-col="nextAction"] { grid-column: 1 / -1; color: var(--text-muted); font-size: var(--fs-sm); }
body.phone #all-deadlines-table td[data-col="origin"], body.phone #all-deadlines-table td[data-col="assigned"], body.phone #all-deadlines-table td[data-col="actions"] { display: none; }
body.phone #all-deadlines-table td[data-col="due"] { grid-column: 1; grid-row: 1; }
body.phone #all-deadlines-table td[data-col="status"] { grid-column: 2; grid-row: 1; text-align: right !important; }
body.phone #all-deadlines-table td[data-col="matter"] { grid-column: 1 / -1; }
body.phone #all-deadlines-table td[data-col="description"] { grid-column: 1 / -1; color: var(--text-muted); font-size: var(--fs-sm); }

/* each person's own columns (js/list-prefs.js) */
table.data-table .col-hidden { display: none !important; }
.list-tools { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.list-cols-btn .lucide { width: 16px; height: 16px; }
.cols-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--border); border-radius: 8px; }
.cols-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; }
.cols-list li + li { border-top: 1px solid var(--border); }
.cols-move { display: inline-flex; gap: 2px; }
.cols-move .icon-btn { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 6px; background: var(--white); cursor: pointer; }
.cols-move .icon-btn:disabled { opacity: 0.35; cursor: default; }
/* a list with many columns scrolls inside its panel, not the whole page */
.table-scroll { overflow-x: auto; margin: 0 -2px; padding: 0 2px; }
.table-scroll > table.data-table { min-width: 100%; }
/* long titles: two lines at most in a list (the matter page shows all of it) */
#all-deadlines-table td[data-col="matter"] strong, #matters-table td[data-ck="matter"] strong, #matters-table td[data-ck="mark"] strong,
#client-matters-table td strong, #applicant-matters-table td strong {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#all-deadlines-table td[data-col="matter"] { min-width: 200px; max-width: 340px; }
#all-deadlines-table td[data-col="description"] { min-width: 160px; }
table.data-table td.row-actions { white-space: nowrap; }
@media (max-width: 820px) { .table-scroll { overflow-x: visible; } }
@media (max-width: 820px) { table.data-table td.row-actions { white-space: normal; } }

/* wide lists: headings on one line; dates and numbers don't break; long names two lines */
.table-scroll > table.data-table th { white-space: nowrap; }
#bills-table td[data-ck="date"], #bills-table td[data-ck="due"], #bills-table td[data-ck="number"], #bills-table td.num { white-space: nowrap; }
#bills-table td[data-ck="matters"] { min-width: 200px; max-width: 300px; }
#bills-table td[data-ck="matters"] .cell-sub, #all-deadlines-table td[data-col="matter"] .cell-sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#matters-table td .matter-ref { white-space: normal; }
#clients-table td[data-ck="lastContact"], #clients-table td[data-ck="next"] { white-space: nowrap; }
@media (max-width: 820px) { .table-scroll > table.data-table th { white-space: normal; } #bills-table td[data-ck="matters"] { min-width: 0; max-width: none; } }
#matters-table td[data-ck="docket"], #matters-table td[data-ck="appNo"], #matters-table td[data-ck="filed"], #matters-table td[data-ck="registered"], #matters-table td[data-ck="added"],
#all-deadlines-table td[data-col="docket"], #all-deadlines-table td[data-col="doneOn"], #clients-table td[data-ck="phone"] { white-space: nowrap; }
/* a soft shadow on the side that has more columns to scroll to */
@media (min-width: 821px) {
  .table-scroll {
    background:
      linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)) left center / 40px 100% no-repeat local,
      linear-gradient(to left, var(--surface) 30%, rgba(255, 255, 255, 0)) right center / 40px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgba(3, 26, 44, 0.14), rgba(3, 26, 44, 0)) left center / 12px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgba(3, 26, 44, 0.14), rgba(3, 26, 44, 0)) right center / 12px 100% no-repeat scroll;
  }
}

/* ---------- Phone: a calmer, simpler look (body.phone) ----------
   Lists sit on the page (no box around a box); one search row with a
   Filter & sort button; IP-type tabs and quick filters swipe sideways on
   one line; rows in one rounded list with thin dividers; empty values left
   out; the search at the top opens from the bar. */
.phone-filter-btn { display: none; }
body.phone .phone-filter-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex: 0 0 auto; height: 44px; min-width: 44px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--white); color: var(--text); }
.pf-count:not(:empty) { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--navy); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center; }
body.phone .global-search { display: none; }
body.phone.phone-search-open .global-search { display: block; }
body.phone header.topbar { row-gap: 6px; }

body.phone main .panel { background: transparent; border: none; padding: 0; margin-bottom: 16px; }
body.phone main .panel-header { margin-bottom: 10px; }
body.phone main .panel-header h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; width: 100%; }
body.phone main .panel-header-actions { flex-wrap: nowrap; gap: 8px; }
body.phone main .panel-header-actions .search-input { flex: 1 1 auto; height: 44px; border-radius: 10px; background: var(--white); }
/* the tick boxes and dropdowns live in Filter & sort */
body.phone #view-matters .panel-header-actions > label, body.phone #view-deadlines .panel-header-actions > label,
body.phone #view-clients .panel-header-actions > label, body.phone #view-applicants .panel-header-actions > label,
body.phone #view-contracts .panel-header-actions > select, body.phone #billing-bills-view .panel-header-actions > select,
body.phone .missing-toggle, body.phone #matters-checks-hint, body.phone .missing-summary { display: none !important; }
body.phone table.data-table > thead { display: none; }

/* one line each, swipe sideways */
body.phone #matters-ip-tabs, body.phone #matters-quick, body.phone .subtabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
body.phone #matters-ip-tabs::-webkit-scrollbar, body.phone #matters-quick::-webkit-scrollbar, body.phone .subtabs::-webkit-scrollbar { display: none; }
body.phone #matters-ip-tabs button, body.phone #matters-quick button, body.phone .subtabs button { flex: 0 0 auto; white-space: nowrap; }
body.phone #matters-ip-tabs { border-bottom: none; margin-bottom: 8px; gap: 6px; }
body.phone #matters-ip-tabs button { border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; margin: 0; background: var(--white); }
body.phone #matters-ip-tabs button.active { background: var(--navy); border-color: var(--navy); color: #fff; }
body.phone #matters-ip-tabs button.active .tab-count { background: rgba(255, 255, 255, 0.2); color: #fff; }
body.phone #matters-quick { margin-bottom: 12px; }
body.phone .quick-chip { border-radius: 999px; }

/* rows in one rounded list */
body.phone table.data-table > tbody { background: var(--white); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 2px rgba(3, 26, 44, 0.06); border: 1px solid var(--border); }
body.phone table.data-table > tbody > tr { border: none !important; border-radius: 0 !important; margin: 0 !important; box-shadow: none; padding: 12px 14px !important; position: relative; }
body.phone table.data-table > tbody > tr + tr { border-top: 1px solid var(--border) !important; }
body.phone table.data-table > tbody > tr.clickable { padding-right: 30px !important; }
body.phone table.data-table > tbody > tr.clickable::after { content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--text-subtle); border-top: 2px solid var(--text-subtle); transform: translateY(-50%) rotate(45deg); }
body.phone table.data-table > tbody > tr:active { background: var(--surface-subtle); }
@media (max-width: 820px) { table.data-table td.cell-empty { display: none !important; } }
body.phone #matters-table td .cell-sub.matter-ref { margin-top: 4px; }
body.phone #matters-table td[data-col="next"] .due-cell, body.phone #matters-table td[data-col="next"] { font-size: var(--fs-sm); font-weight: 600; }

/* Filter & sort: a panel from the bottom */
.modal-overlay:has(> .modal.sheet) { align-items: flex-end; padding: 0; }
.modal.sheet { max-width: 560px; width: 100%; border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 85vh; }
.modal.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: -6px auto 12px; }
.sheet-group { margin-bottom: 14px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.sheet-title { padding: 8px 14px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle); background: var(--surface-subtle); }
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; padding: 8px 14px; border: none; border-top: 1px solid var(--border); background: var(--white); font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.sheet-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--navy); }
.sheet-row select { max-width: 55%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); }
.sheet-dir { color: var(--amber); font-weight: 700; font-size: var(--fs-sm); }
.modal.sheet .modal-actions .btn { width: 100%; justify-content: center; min-height: 46px; }

/* Phone: every other list in the same short style — the main name on top,
   the other details as small "Label value" pieces on a line or two. */
body.phone main table.data-table:not(#matters-table):not(#all-deadlines-table):not(#deadlines-table) > tbody > tr {
  display: flex !important; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
body.phone main table.data-table:not(#matters-table):not(#all-deadlines-table):not(#deadlines-table) > tbody > tr > td {
  padding: 0 !important; min-height: 0; border: none !important; font-size: var(--fs-sm); color: var(--text-muted); width: auto !important; }
body.phone main table.data-table:not(#matters-table):not(#all-deadlines-table):not(#deadlines-table) > tbody > tr > td::before {
  position: static; display: inline; width: auto; content: attr(data-label); margin-right: 4px; text-transform: none; letter-spacing: 0; font-size: var(--fs-xs); font-weight: 500; color: var(--text-subtle); }
body.phone main table.data-table:not(#matters-table):not(#all-deadlines-table):not(#deadlines-table) > tbody > tr > td:has(strong) {
  order: -1; flex-basis: 100%; font-size: var(--fs-base); color: var(--text); margin-bottom: 2px; }
body.phone main table.data-table:not(#matters-table):not(#all-deadlines-table):not(#deadlines-table) > tbody > tr > td:has(strong)::before { display: none; }
body.phone main table.data-table > tbody > tr > td[colspan] { flex-basis: 100%; }
/* a shorter page title */
body.phone #view-deadlines .panel-header h2 { font-size: 0; }
body.phone #view-deadlines .panel-header h2::after { content: "Deadlines"; font-size: 1.6rem; }
/* Phone: no to-do boxes or long explanations meant for the computer */
body.phone details.same-review, body.phone main .panel > p.hint-text, body.phone #view-applicants .party-warning,
body.phone #view-clients .party-warning { display: none !important; }
/* matter page: just the two statuses under the name; the rest is in the facts below */
body.phone #detail-chips .chip-status.tone-plain, body.phone #detail-chips .badge { display: none; }
body.phone #detail-refs .mh-sep { display: none; }
body.phone #detail-refs { display: flex; flex-wrap: wrap; gap: 2px 12px; }
body.phone .matter-header { background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 16px !important; }
body.phone .mh-verify { padding: 8px 12px; font-size: var(--fs-sm); }
/* Today: its two lists as white rounded cards, headings normal size */
body.phone main .panel.pt-panel { background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
body.phone main .pt-panel h2, body.phone main .pt-panel .panel-header h2 { font-size: 1.05rem !important; font-weight: 700; width: auto; }
body.phone main .pt-panel .panel-header h2 .lucide { display: none; }
body.phone .pt-tile { border-radius: 14px; }
body.phone #view-dashboard .dash-toolbar h2 { font-size: 1.35rem; }

/* ---------- client letters (js/letters.js) ---------- */
.modal-xwide { max-width: 1180px; width: 100%; }
.letter-modal { max-width: 860px; }
.letter-page { background: #fff; color: #1a1f24; font-family: "Inter", system-ui, sans-serif; font-size: 10.5pt; line-height: 1.45; padding: 18mm 20mm; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 24px rgba(3, 26, 44, 0.08); }
.letter-page p { margin: 0 0 3.6mm; }
.letter-page h3 { font-size: 11.5pt; margin: 1.5mm 0 2mm; }
.letter-page ul, .letter-page ol { margin: 0 0 3.6mm; padding-left: 6mm; }
.letter-page li { margin-bottom: 1.2mm; }
.lt-letterhead.has-logo { margin-bottom: 8mm; }
.lt-letterhead .letterhead-logo { max-height: 16mm; max-width: 70mm; }
.lt-final { max-height: 62vh; overflow-y: auto; outline: none; }
.lt-final:focus { border-color: var(--amber); }
mark.lt-missing { background: #fff1b8; color: #7a5a00; border-radius: 3px; padding: 0 3px; cursor: text; }
.lt-check-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.lt-missing-count { color: #946200; font-weight: 600; font-size: var(--fs-sm); }
.lt-pick { max-height: 60vh; overflow-y: auto; display: grid; gap: 8px; }
.lt-group { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle); margin: 8px 0 2px; }
.lt-card { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--white); font: inherit; cursor: pointer; }
.lt-card:hover, .lt-card:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(240, 163, 20, 0.15); }
.lt-manager { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; min-height: 60vh; }
.lt-side { border-right: 1px solid var(--border); padding-right: 12px; overflow-y: auto; max-height: 75vh; }
.lt-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.lt-side-head h3 { margin: 0; font-size: var(--fs-md); }
.lt-item { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; border-radius: 6px; background: none; font: inherit; color: var(--text); cursor: pointer; }
.lt-item:hover { background: var(--gray-blue); }
.lt-item.active { background: var(--navy); color: #fff; }
.lt-item.active .cell-sub { color: rgba(255, 255, 255, 0.7); }
.lt-main { overflow-y: auto; max-height: 75vh; padding-right: 4px; }
.lt-starter { background: #fff8e1; border: 1px solid #f2d48a; color: #7a5a00; border-radius: 8px; padding: 8px 12px; font-size: var(--fs-sm); }
.lt-meta { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 10px; }
.lt-ip { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.lt-edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.lt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; border: 1px solid var(--border); border-bottom: none; border-radius: 8px 8px 0 0; background: var(--surface-subtle); }
.lt-toolbar button { min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: none; font: inherit; font-size: var(--fs-sm); cursor: pointer; color: var(--text); }
.lt-toolbar button:hover { background: var(--white); border-color: var(--border); }
.lt-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.lt-insert { position: relative; }
.lt-insert-btn { background: var(--navy) !important; color: #fff !important; font-weight: 600 !important; }
.lt-insert-menu { position: absolute; z-index: 30; top: 34px; left: 0; width: 240px; max-height: 360px; overflow-y: auto; background: var(--white); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-pop); padding: 6px; }
.lt-insert-menu button { display: block; width: 100%; text-align: left; height: auto; padding: 6px 8px; }
.lt-editor { min-height: 360px; max-height: 55vh; overflow-y: auto; padding: 16px 18px; border: 1px solid var(--border); border-radius: 0 0 8px 8px; background: #fff; outline: none; }
.lt-editor:focus { border-color: var(--amber); }
.letter-text { font-size: 10.5pt; line-height: 1.5; }
.letter-text p { margin: 0 0 8px; } .letter-text h3 { font-size: 11.5pt; margin: 4px 0 6px; } .letter-text ul, .letter-text ol { margin: 0 0 8px; padding-left: 22px; }
.lt-chip { display: inline-block; padding: 0 7px; margin: 0 1px; border-radius: 999px; background: #e6effa; color: #1d4e89; font-size: 0.86em; font-weight: 600; line-height: 1.6; white-space: nowrap; user-select: all; }
.lt-chip.lt-ask { background: #fff1d6; color: #8a5a00; }
.lt-preview-col { position: sticky; top: 0; }
.lt-preview-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.lt-preview-head select { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; }
.lt-preview { padding: 12mm 12mm; font-size: 9pt; max-height: 62vh; overflow-y: auto; }
.lt-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
@media (max-width: 900px) { .lt-manager, .lt-edit-grid, .lt-meta { grid-template-columns: 1fr; } .lt-side { border-right: none; max-height: none; } }
@media print { body.printing-soa .lt-check-head, body.printing-soa .letter-modal > .hint-text, body.printing-soa .letter-modal .modal-actions { display: none !important; }
  body.printing-soa .letter-page { border: none; box-shadow: none; max-height: none; overflow: visible; padding: 18mm 20mm; } body.printing-soa mark.lt-missing { background: none; color: inherit; } }
mark:not(.lt-missing) { background: none; color: inherit; }
/* statement: the matter once, not on every line */
.soa-matter { margin: 0 0 12px; padding: 8px 0; border-top: 1px solid #d8dde3; }
.soa-matter-title { font-size: 0.85em; color: #555; text-transform: none; }
.soa-lines tr.soa-group td { padding-top: 12px; background: #f6f7f9; border-bottom: 1px solid #d8dde3; }
.soa-lines tr.soa-group + tr td { padding-top: 6px; }

/* ---------- a newer version is ready (js/version.js) ---------- */
.update-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; padding: 8px 16px; background: #fff8e1; border-bottom: 1px solid #f2d48a; color: #6b4f00; font-size: var(--fs-sm); }
.update-banner.hidden { display: none; }
.ub-actions { display: inline-flex; gap: 6px; align-items: center; }
.ub-notes { flex-basis: 100%; max-width: 760px; margin: 2px auto 4px; padding-left: 20px; }
.account-version { padding: 6px 14px 4px; font-size: 0.72rem; color: var(--text-subtle); border-top: 1px solid var(--border); margin-top: 4px; }
.guide-version { color: var(--text-muted); font-size: var(--fs-sm); }

/* A matter's own contact person (phase47a) */
.mh-contact-change { padding: 0 4px; min-height: 0; height: auto; font-size: var(--fs-sm); vertical-align: baseline; }
.mh-own-contact { margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--info-bg); color: var(--info); font-size: 10px; text-transform: none; letter-spacing: 0; }
.contact-picker { display: grid; gap: 4px; max-height: 60vh; overflow-y: auto; margin: 8px 0; }
.contact-group { margin-top: 10px; font-weight: 600; font-size: var(--fs-sm); }
.contact-opt { display: flex; align-items: flex-start; gap: 10px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.contact-opt:hover { background: var(--surface-hover); }
.contact-opt input { margin-top: 3px; }
.contact-opt > span { display: grid; }
.contact-none { margin: 2px 8px; }
.contact-new { padding: 8px 8px 0 32px; }
body.phone .mh-contact-change { display: none; }

/* ---------- Messages (js/messages.js) ---------- */
.inbox { position: relative; }
.inbox-count { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: var(--white);
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--navy); pointer-events: none; }
.inbox-panel { position: absolute; top: calc(100% + 8px); right: -90px; width: min(380px, calc(100vw - 24px)); max-height: min(520px, calc(100vh - 90px)); display: flex; flex-direction: column;
  background: var(--white); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); z-index: 80; overflow: hidden; }
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.inbox-list { overflow-y: auto; padding: 4px; }
.inbox-item { display: flex; gap: 10px; width: 100%; padding: 10px; border: none; border-radius: var(--radius); background: transparent; text-align: left; font: inherit; color: inherit; cursor: pointer; position: relative; }
.inbox-item:hover, .inbox-item:focus-visible { background: var(--surface-hover); outline: none; }
.inbox-item.unread { background: var(--amber-50); }
.inbox-item.unread::after { content: ""; position: absolute; top: 14px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.inbox-text { display: grid; gap: 2px; min-width: 0; padding-right: 12px; }
.inbox-line { font-size: var(--fs-sm); }
.inbox-preview { font-size: var(--fs-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.inbox-when { font-size: var(--fs-xs); color: var(--text-subtle); }
.inbox-empty { padding: 16px 10px; margin: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: 0.7rem; background: var(--amber-50); color: #8a5a00; box-shadow: inset 0 0 0 1px #f3d79f; }
.avatar-xs { width: 20px; height: 20px; font-size: 0.58rem; background: var(--amber-50); color: #8a5a00; box-shadow: inset 0 0 0 1px #f3d79f; }
.tab-btn.has-unread::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; vertical-align: 2px; border-radius: 50%; background: var(--amber); }

.chat-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 12px; align-items: stretch; height: calc(100vh - 170px); min-height: 460px; }
.chat-layout > .panel { margin: 0; min-height: 0; }
.chat-side { padding: 10px 8px; overflow-y: auto; }
.chat-main { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-section + .chat-section { margin-top: 14px; }
.chat-section-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.chat-add { border: none; background: transparent; color: var(--text-muted); font-size: 1.1rem; line-height: 1; width: 24px; height: 24px; border-radius: var(--radius-sm); cursor: pointer; }
.chat-add:hover { background: var(--surface-hover); color: var(--text); }
.chat-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); font: inherit; font-size: var(--fs-base); text-align: left; cursor: pointer; }
.chat-item:hover { background: var(--surface-hover); color: var(--text); }
.chat-item.active { background: var(--navy); color: var(--white); }
.chat-item.unread { color: var(--text); font-weight: 600; }
.chat-item.active.unread { color: var(--white); }
.chat-item-icon { width: 20px; flex: none; text-align: center; color: var(--text-subtle); font-weight: 600; }
.chat-item.active .chat-item-icon { color: rgba(255, 255, 255, 0.7); }
.chat-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-unread { flex: none; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--amber); color: var(--navy); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.chat-empty { margin: 0; padding: 2px 8px 4px; font-size: var(--fs-xs); color: var(--text-subtle); }
.chat-archived { margin-top: 14px; padding: 0 8px; font-size: var(--fs-sm); color: var(--text-muted); }
.chat-archived summary { cursor: pointer; padding: 4px 0; }

.chat-thread { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-thread.embedded { height: min(560px, 70vh); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-head-embedded { padding: 8px 12px; background: var(--surface-subtle); }
.chat-title { font-size: var(--fs-md); font-weight: 700; }
.chat-sub { font-size: var(--fs-sm); color: var(--text-muted); }
.chat-head-actions { display: flex; gap: 6px; flex: none; }
#chat-follow[aria-pressed="true"] { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.chat-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; }
.chat-empty-state { color: var(--text-subtle); font-size: var(--fs-sm); text-align: center; padding: 40px 0; }
.chat-older { text-align: center; }
.chat-day { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; color: var(--text-subtle); font-size: var(--fs-xs); font-weight: 600; }
.chat-day::before, .chat-day::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.chat-msg { position: relative; display: flex; gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: var(--radius-sm); }
.chat-msg.grouped { padding-top: 1px; padding-bottom: 1px; }
.chat-msg:hover { background: var(--surface-subtle); }
.chat-msg-gutter { width: 30px; flex: none; font-size: 10px; color: transparent; text-align: right; padding-top: 3px; }
.chat-msg:hover .chat-msg-gutter { color: var(--text-subtle); }
.chat-msg-main { min-width: 0; flex: 1; }
.chat-msg-meta { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-sm); }
.chat-msg-meta span { color: var(--text-subtle); font-size: var(--fs-xs); }
.chat-msg-body { font-size: var(--fs-base); line-height: 1.5; overflow-wrap: anywhere; }
.chat-msg-body a { color: var(--info); }
.chat-msg.removed .chat-msg-body { color: var(--text-subtle); }
.chat-edited { color: var(--text-subtle); font-size: var(--fs-xs); }
.chat-mention { background: var(--info-bg); color: var(--info); border-radius: 4px; padding: 0 2px; font-weight: 600; }
.chat-mention.me { background: var(--amber-50); color: #8a5a00; box-shadow: inset 0 0 0 1px #f3d79f; }
.chat-msg-actions { position: absolute; top: 2px; right: 6px; display: none; gap: 2px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); }
.chat-msg:hover .chat-msg-actions, .chat-msg:focus-within .chat-msg-actions { display: flex; }
.chat-edit-input { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); resize: vertical; }
.chat-edit-actions { display: flex; gap: 6px; margin-top: 4px; }
.chat-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 16px 4px; border-top: 1px solid var(--border); }
.chat-compose-box { position: relative; flex: 1; }
.chat-input { display: block; width: 100%; min-height: 38px; max-height: 180px; padding: 8px 10px; font: inherit; font-size: var(--fs-base); border: 1px solid var(--border-strong); border-radius: var(--radius); resize: none; background: var(--white); }
.chat-input:focus { outline: none; border-color: var(--amber); box-shadow: var(--focus-ring); }
.chat-send { height: 38px; }
.chat-hint { margin: 0; padding: 2px 16px 10px; font-size: var(--fs-xs); color: var(--text-subtle); }
.chat-archived-note { padding: 10px 16px; margin: 0; border-top: 1px solid var(--border); }
.mention-pop { position: absolute; bottom: calc(100% + 6px); left: 0; width: min(320px, 100%); max-height: 260px; overflow-y: auto; padding: 4px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); z-index: 30; }
.mention-opt { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: none; border-radius: var(--radius-sm); background: transparent; font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; }
.mention-opt .cell-sub { margin-left: auto; }
.mention-opt.active, .mention-opt:hover { background: var(--surface-hover); }
.chat-hash-input { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--white); }
.chat-hash-input span { padding: 0 4px 0 10px; color: var(--text-subtle); font-weight: 600; }
.chat-hash-input input { border: none !important; box-shadow: none !important; flex: 1; }
.chat-people { display: grid; gap: 2px; max-height: 340px; overflow-y: auto; }
.chat-person { display: flex; align-items: center; gap: 10px; padding: 8px; border: none; border-radius: var(--radius-sm); background: transparent; font: inherit; text-align: left; cursor: pointer; }
.chat-person > span:last-child { display: grid; }
.chat-person:hover { background: var(--surface-hover); }
#client-discussion .chat-thread.embedded { height: min(440px, 60vh); }
@media (max-width: 820px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-side { max-height: 220px; }
  .chat-main { height: 70vh; }
  .inbox-panel { right: -40px; }
}
.chat-compose .chat-compose-box { flex: 1 1 auto; min-width: 0; }
.chat-compose .chat-send { flex: 0 0 auto; width: auto; padding-left: 16px; padding-right: 16px; }
header.topbar .topbar-icon-btn[aria-expanded="true"]::after { display: none; }
.be-follow-matter { margin-left: auto; font-size: 13px; color: var(--text-muted); }
/* Who a bill was for, when addressed to another company (phase49a) */
.be-for { margin: 4px 0 0; font-size: var(--fs-sm); }
.be-for .btn { padding: 0 4px; min-height: 0; height: auto; }
.obo-btn { padding: 0; min-height: 0; height: auto; font-size: var(--fs-xs); }
/* Contact persons on a matter, To / CC (phase50a) */
.mh-people { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.mh-person a { margin-left: 4px; }
.mh-cc { margin-top: 2px; font-size: var(--fs-sm); }
.mh-contact-actions { display: flex; gap: 4px; margin-top: 2px; }
.contact-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: var(--radius-sm); }
.contact-row:hover { background: var(--surface-hover); }
.contact-row > span { display: grid; }
.contact-row .list-filter-select { height: 32px; min-width: 76px; }
.mc-main { font-size: var(--fs-sm); color: var(--text-muted); display: flex; gap: 4px; align-items: center; }
body.phone .mh-contact-actions #mh-contact-change { display: none; }
/* IP-type tabs with nothing in them: count shown, a little quieter */
.subtabs button.tab-empty:not(.active) { color: var(--text-subtle); }
/* Email chip + its copy button */
.ch-item { display: inline-flex; align-items: center; gap: 2px; }
.ch-item .copy-btn { padding: 4px; }

/* ---------- Inquiries board layout (js/inquiries.js) ---------- */
/* The intro now sits in the slim "due now" bar. */
#view-inquiries > .panel:first-child > .hint-text { display: none; }
#view-inquiries > .panel:first-child { margin-bottom: 12px; }

/* Slim bar: "1 due now · 0 overdue", opens to the Due now list. */
.inq-duebar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 6px 10px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.inq-duebar-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px; border: none; border-radius: var(--radius-sm);
  background: none; font: inherit; font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.inq-duebar-btn:hover:not(:disabled) { background: var(--surface-hover); }
.inq-duebar-btn:disabled { cursor: default; color: var(--text-muted); }
.inq-duebar-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.inq-duebar-sep { color: var(--text-subtle); }
.inq-duebar-late { color: var(--danger); font-weight: 600; }
.inq-duebar-chev { display: inline-flex; color: var(--text-muted); transition: transform var(--ease); }
.inq-duebar.open .inq-duebar-chev { transform: rotate(180deg); }
.inq-duebar-intro { flex: 1 1 280px; min-width: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.inq-duebar-list { flex: 1 1 100%; max-height: 40vh; overflow-y: auto; border-top: 1px solid var(--border); margin: 4px -10px -6px; padding: 0 10px; }
.inq-duebar-list[hidden] { display: none; }

/* Compact cards: two lines. */
.inq-card { padding: 6px 10px; margin-bottom: 6px; }
.inq-card-top { align-items: baseline; min-width: 0; }
.inq-card-top strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inq-card-top .cell-sub { flex: none; }
.inq-card-line2 { display: flex; align-items: center; gap: 6px; margin-top: 2px; min-width: 0; font-size: var(--fs-xs); color: var(--text-muted); }
.inq-card-who { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inq-initials { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 3px; border-radius: 999px;
  background: var(--white); border: 1px solid var(--border); font-size: 10px; font-weight: 700; color: var(--text-muted); }
.inq-card-line2 .inq-card-contact { margin: 0; flex: none; gap: 4px; flex-wrap: nowrap; }
.inq-nocontact, .inq-lastcontact, .inq-pref { display: inline-flex; }
.inq-nocontact { color: var(--text-subtle); opacity: 0.8; }
.inq-lastcontact { color: var(--text-muted); }
.inq-pref { color: var(--info); }
.inq-card-line2 .inq-card-due { margin: 0 0 0 auto; flex: none; }
.inq-card-line2 .inq-card-due .badge { white-space: nowrap; }
.inq-card-overdue { border-left: 3px solid var(--danger); padding-left: 8px; }

/* Wide screens: full width, the board fills the window, each column scrolls. */
@media (min-width: 768px) {
  main.content:has(> #view-inquiries:not(.hidden)) { max-width: none; }
  .inq-board { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: stretch;
    height: calc(100vh - var(--inq-top, 280px) - 24px); min-height: 360px; }
  .inq-col { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 0 10px 10px; }
  .inq-col-top { position: sticky; top: 0; z-index: 1; margin: 0 -10px 6px; padding: 10px 10px 2px; background: var(--white);
    border-bottom: 1px solid var(--border); }
  .inq-col-top .inq-col-head { margin-bottom: 4px; }
  .inq-col-top .inq-col-hint { margin: 0 0 6px; }
}
/* the header panel: slim now the intro has moved to the bar */
#view-inquiries > .panel:first-child { padding-top: 14px; padding-bottom: 14px; }
#view-inquiries > .panel:first-child > .panel-header { margin-bottom: 0; }
/* Under 768px: the stacked layout as before (2 columns, then 1), with columns
   that can shrink now card lines don't wrap. */
@media (max-width: 767px) { .inq-board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .inq-board { grid-template-columns: minmax(0, 1fr); } }

/* ---------- emailing a letter (phase51a) ---------- */
.lt-email { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.lt-email h4 { margin: 0 0 8px; font-size: var(--fs-md); }
.lt-email textarea { width: 100%; font: inherit; }
.lt-email-preview { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-subtle); font-size: var(--fs-sm); }
.lt-email-subj { font-weight: 600; margin-bottom: 6px; }
.lt-email-msg { white-space: pre-wrap; margin-bottom: 6px; }
.lt-written { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.lt-written summary { cursor: pointer; font-weight: 600; }
.lt-written-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.le-history { margin: 0 0 10px; padding: 8px 12px 8px 28px; border-radius: 8px; background: var(--surface-subtle); font-size: var(--fs-sm); }
.le-history .le-failed { color: var(--red, #b42318); }
.le-warn { background: #fff8e1; border: 1px solid #f2d48a; color: #7a5a00; border-radius: 8px; padding: 6px 10px; font-size: var(--fs-sm); }
.le-attach { display: inline-block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: var(--fs-sm); background: var(--white); }
#le-message { width: 100%; font: inherit; }
@media (max-width: 560px) { .lt-written-row { grid-template-columns: 1fr; } }
