/* =========================================================================
   Land & Sea Property Care — design system
   Palette from the LSPC Brand Guide v6: Depth (dark green-charcoal), Moss
   (primary green accent), Slate Teal (sea accent), Sea Foam (light sea
   accent), Bark (warm accent), Sand (paper background).
   Class names are unchanged from the original markup; this file restyles
   every view in place. Tokens live in :root so the whole app stays in sync.
   ========================================================================= */

@font-face {
  font-family: "Degular";
  src: url("/public/fonts/Degular-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Degular";
  src: url("/public/fonts/Degular-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Degular";
  src: url("/public/fonts/Degular-Semibold.otf") format("opentype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Degular";
  src: url("/public/fonts/Degular-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand + neutrals (LSPC Brand Guide v6) */
  --teal-900: #1c2b2a; /* Depth */
  --teal-800: #2b463c;
  --teal-700: #4a6b52; /* Moss */
  --teal-600: #5b8266;
  --teal-50: #e9efe9;
  --coastal: #3d9baf; /* Slate Teal */
  --seafoam: #72bfa8; /* Sea Foam */
  --bark: #7a6655; /* Bark */

  --ink: #1c1c1c;
  --ink-soft: #46504a;
  --ink-faint: #68716a;
  --ink-ghost: #9aa39b;

  --bg: #f5f2ed; /* Sand */
  --surface: #ffffff;
  --surface-sunken: #efece4;
  --border: #e3ddd1;
  --border-strong: #c9bfb0;

  /* Status hues */
  --red-bg: #fff4ed;
  --red-border: #f2c2b4;
  --red-ink: #9a2a16;
  --amber-bg: #fffaeb;
  --amber-border: #f3d18a;
  --amber-ink: #7a5300;
  --green-bg: #ecfdf3;
  --green-border: #aadcc6;
  --green-ink: #05663c;

  /* Shape + depth */
  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Surface spacing — every content panel/card variant uses these */
  --panel-padding: 1.2rem 1.25rem;
  --card-padding: 1.1rem 1.15rem;

  --shadow-xs: 0 1px 2px rgba(16, 33, 36, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 33, 36, 0.06), 0 1px 2px rgba(16, 33, 36, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 33, 36, 0.08), 0 2px 4px rgba(16, 33, 36, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 33, 36, 0.12);

  --focus: 0 0 0 3px rgba(74, 107, 82, 0.30);

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must win even on elements whose class sets a display
   (e.g. .stack's grid), otherwise toggled-away editors stay visible. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Degular", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv05", "ss01";
}

a {
  color: var(--teal-700);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}

a:hover {
  color: var(--teal-600);
  text-decoration: underline;
  text-underline-offset: 2px;
}

::selection {
  background: rgba(74, 107, 82, 0.16);
}

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

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

.shell.has-sidebar {
  flex-direction: row;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.brand::before {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 4px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--teal-600), var(--coastal));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.brand.has-badge::before {
  content: none;
}

.brand-badge {
  width: 2.4rem;
  height: 2.4rem;
  flex: 0 0 auto;
}

.mobile-bar .brand-badge {
  width: 1.6rem;
  height: 1.6rem;
}

.brand:hover {
  color: #fff;
  text-decoration: none;
}

.auth-bar {
  padding: 1.1rem 1.5rem;
}

.auth-bar .brand,
.auth-bar .brand:hover {
  color: var(--teal-900);
}

/* The badge art is white; give it the sea-green stamp disc on light pages. */
.auth-bar .brand-badge {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--teal-700), var(--teal-900) 70%);
  box-shadow: var(--shadow-sm);
}

/* ----------------------------------------------------------------- sidebar */

.sidebar {
  flex: 0 0 250px;
  width: 250px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.15rem 0.8rem 1rem;
  background: linear-gradient(180deg, var(--teal-800), var(--teal-900));
}

.sidebar-brand {
  padding: 0 0.6rem;
}

.side-nav {
  display: grid;
  gap: 0.15rem;
  align-content: start;
}

.side-link {
  display: flex;
  min-height: 2.25rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.65rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.side-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.side-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

summary.side-link {
  list-style: none;
  user-select: none;
}

summary.side-link::-webkit-details-marker {
  display: none;
}

.side-caret {
  display: inline-block;
  width: 0.42rem;
  height: 0.42rem;
  margin-right: 0.15rem;
  border-right: 2px solid rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid rgba(255, 255, 255, 0.55);
  transform: rotate(-45deg);
  transition: transform 0.18s var(--ease);
}

.side-group[open] > summary .side-caret {
  transform: translateY(-0.1rem) rotate(45deg);
}

.side-sublist {
  display: grid;
  gap: 1px;
  margin: 0.2rem 0 0.4rem 0.85rem;
  padding-left: 0.6rem;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.side-sublink {
  display: block;
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.55rem;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.86rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.side-sublink:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.side-sublink.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.side-sublink-more {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: 0.45rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.side-foot .inline-form {
  display: block;
}

.side-user {
  display: grid;
  gap: 0.1rem;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  transition: background 0.15s var(--ease);
}

.side-user:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.side-user.active {
  background: rgba(255, 255, 255, 0.16);
}

.side-user-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.side-user-meta {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.78rem;
  text-transform: capitalize;
}

/* Partner company affiliation shown under the user's name (issue #261). Not
   capitalized — company names carry their own casing. */
.side-user-org {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.8rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.side-signout,
.side-signout:hover {
  width: 100%;
  min-height: 2.15rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  font-size: 0.85rem;
  box-shadow: none;
}

.side-signout:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-toggle-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.mobile-bar {
  display: none;
}

/* ------------------------------------------------------------- page frame */

.page {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 2rem 2.5rem 4rem;
}

.auth-page {
  width: min(420px, calc(100% - 2rem));
  margin: 9vh auto;
  flex: 1;
}

/* --------------------------------------------------------- surfaces/cards */

.panel,
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: var(--panel-padding);
}

/* Top-level operational panels should read as distinct content areas. Any
   surface or layout grid that follows another at page level gets the same
   vertical rhythm — add new layout classes here rather than per-view
   margin overrides. */
.page > :is(.panel, .grid, .dashboard-layout, .chat-layout) + :is(.panel, .grid, .dashboard-layout, .chat-layout) {
  margin-top: 1rem;
}

.card {
  padding: var(--card-padding);
  transition: box-shadow 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

a.card:hover,
.card.interactive:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

/* --------------------------------------------------------------- layout */

.grid {
  display: grid;
  gap: 1rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Lead layout: the section that deserves attention takes the wide column. */
.grid.lead {
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stack {
  display: grid;
  gap: 0.85rem;
}

/* Grid items default to min-width:auto, which lets long nowrap rows blow the
   track out past the viewport on small screens. Let them shrink instead. */
.grid > *,
.stack > *,
.inbox-sections > *,
.inbox-section > * {
  min-width: 0;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* ------------------------------------------------------------ typography */

h1,
h2,
h3 {
  margin: 0 0 0.75rem;
  line-height: 1.2;
  letter-spacing: -0.018em;
  color: var(--ink);
}

h1 {
  font-size: 1.7rem;
  font-weight: 700;
}

h2 {
  font-size: 1.2rem;
  font-weight: 650;
}

h3 {
  font-size: 1rem;
  font-weight: 650;
}

p {
  margin: 0 0 0.75rem;
}

.muted {
  color: var(--ink-faint);
}

.muted-sm {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.checklist-link-note {
  margin-top: 1rem;
}

.fieldset-reset {
  border: 0;
  padding: 0;
  margin: 0;
}

.form-legend {
  color: #344054;
  font-weight: 600;
}

/* ---------------------------------------------------------------- metric */

.metric {
  display: grid;
  gap: 0.3rem;
}

.metric .muted,
.metric > span:first-child {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.metric strong {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--teal-800);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.filter-shell {
  margin: 0 0 1rem;
}

.filter-toggle-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.filter-disclosure {
  display: inline-flex;
  min-height: 2rem;
  width: auto;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.1rem;
  color: var(--teal-700);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.filter-disclosure:hover {
  color: var(--teal-800);
}

.filter-chevron {
  display: inline-block;
  width: 0.48rem;
  height: 0.48rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.1rem) rotate(45deg);
  transform-origin: center;
  transition: transform 0.18s var(--ease);
}

.filter-toggle-input:checked + .filter-actions .filter-chevron {
  transform: translateY(0.1rem) rotate(225deg);
}

.filter-toggle-input:focus-visible + .filter-actions .filter-disclosure {
  box-shadow: var(--focus);
}

.filter-panel {
  display: none;
  margin-top: 0.75rem;
}

.filter-toggle-input:checked ~ .filter-panel {
  display: block;
}

.filter-panel .toolbar {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.quick-filter.active {
  color: var(--teal-900);
  border-color: var(--teal-700);
  background: var(--teal-50);
  box-shadow: 0 0 0 2px rgba(74, 107, 82, 0.34), var(--shadow-sm);
}

.quick-filter.active:hover {
  color: var(--teal-900);
  border-color: var(--teal-800);
  background: #dcebe2;
  box-shadow: 0 0 0 2px rgba(23, 92, 64, 0.46), var(--shadow-sm);
}

/* Issue #595: the status breakdown and history toggle a record list opens
   with. The counts sit on the same line as the toggle on wide screens and
   stack above it when there is no room. */
.list-scope {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0 0 0.75rem;
}

.list-scope-counts {
  margin: 0;
}

.list-scope-counts strong {
  color: var(--ink);
}

/* ----------------------------------------------------------------- forms */

label {
  display: grid;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.88rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.55rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 400;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  min-height: 1rem;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--teal-700);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-ghost);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--teal-600);
  box-shadow: var(--focus);
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

select {
  appearance: none;
  background-image: 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='%23667085' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2.2rem;
}

.check-control {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  justify-content: flex-start;
  gap: 0.45rem;
  color: var(--ink-soft);
  font-weight: 400;
}

/* --------------------------------------------------------------- buttons */

.button,
button {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--teal-700);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.95rem;
  color: #fff;
  background: var(--teal-700);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    box-shadow 0.15s var(--ease), transform 0.05s var(--ease);
}

.button:hover,
button:hover {
  background: var(--teal-800);
  border-color: var(--teal-800);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.button:active,
button:active {
  transform: translateY(0.5px);
}

.button:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.button.secondary,
button.secondary {
  color: var(--ink);
  border-color: var(--border-strong);
  background: var(--surface);
}

.button.secondary:hover,
button.secondary:hover {
  background: var(--surface-sunken);
  border-color: var(--ink-ghost);
  color: var(--ink);
}

.button.danger,
button.danger {
  border-color: #b3402c;
  background: #b3402c;
}

.button.danger:hover,
button.danger:hover {
  border-color: #962f1d;
  background: #962f1d;
}

button:disabled,
button:disabled:hover {
  cursor: not-allowed;
  opacity: 0.72;
  transform: none;
}

button.is-loading::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: checklist-spin 0.75s linear infinite;
}

@keyframes checklist-spin {
  to {
    transform: rotate(360deg);
  }
}

.inline-form {
  display: inline;
}

/* ----------------------------------------------------------------- table */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  contain: paint;
}

.table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0.75rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table thead th {
  color: var(--ink-faint);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border-strong);
}

.table thead th:first-child {
  border-top-left-radius: var(--radius-sm);
}

.table thead th:last-child {
  border-top-right-radius: var(--radius-sm);
}

.table tbody tr {
  transition: background 0.12s var(--ease);
}

.table tbody tr:hover {
  background: var(--surface-sunken);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.column-identity { width: 32%; }
.column-meta { width: 16%; }
.column-status { width: 12%; }
.column-date { width: 10rem; }
.column-actions { width: 3.5rem; }
.column-actions.actions-2 { width: 5.95rem; }
.column-actions.actions-3 { width: 8.4rem; }
.column-user-status { width: 13.5rem; }

/* The asset register has three adjacent compact states. Give Coverage enough
   room for "Confirmed none" and scroll the table before badges overlap. */
.table-wrap .asset-register-table { min-width: 66.5rem; }
.asset-register-table .column-identity { width: 17rem; }
.asset-register-table .column-meta { width: 9rem; }
.asset-register-table .column-coverage { width: 10rem; }
.asset-register-table .column-status:not(.column-coverage) { width: 7rem; }
.asset-register-table .column-date { width: 8rem; }

/* AI run diagnostics combine related metadata so the scanning table stays
   readable without pushing secondary request composition out of its detail
   view. The table scrolls inside its wrapper before these fields collapse. */
.table-wrap .table.ai-runs-table { min-width: 64rem; }
.ai-runs-table .ai-run-when-column { width: 8.5rem; }
.ai-runs-table .ai-run-call-column { width: 21%; }
.ai-runs-table .ai-run-model-column { width: 14%; }
.ai-runs-table .ai-run-tokens-column { width: 15%; }
.ai-runs-table .ai-run-spend-column { width: 8.5rem; }
.ai-runs-table .ai-run-outcome-column { width: 13.5rem; }

.ai-run-sort-pair {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.ai-run-when-cell time,
.ai-run-spend-cell,
.ai-run-outcome-meta {
  display: grid;
  gap: 0.15rem;
}

.ai-run-when-cell,
.ai-run-spend-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ai-run-outcome-meta { margin-top: 0.3rem; }

.ai-run-error {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cell-identity {
  color: var(--ink);
  font-weight: 650;
}

/* Nested parent/child rows (e.g. sub-assets in the asset register). Depth
   caps at 3 so deep trees stay scannable. */
.tree-cell {
  display: inline-block;
}

/* Inside a truncating cell the ellipsis must render on the tree cell itself;
   an overflowing inline-block child clips without one. */
.cell-truncate .tree-cell {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.tree-cell-depth-1 { padding-left: 1.25rem; }
.tree-cell-depth-2 { padding-left: 2.5rem; }
.tree-cell-depth-3 { padding-left: 3.75rem; }

/* One-line ellipsis for variable-length table text; pair with a title
   attribute so the full value stays reachable. */
.table td.cell-truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

.table-actions,
.action-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.action-group {
  flex-wrap: wrap;
}

.table-actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
  white-space: nowrap;
}

.table-actions .inline-form {
  display: inline-flex;
}

.tree-toggle::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.16s var(--ease);
}

.tree-toggle[aria-expanded="true"]::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

/* Chevron disclosure controls: table detail rows and the panel-area collapse
   control (issue #444) both point down when collapsed and up when expanded. */
.row-disclosure .icon,
.section-collapse .icon {
  transform: rotate(90deg);
  transition: transform 0.16s var(--ease);
}

.row-disclosure[aria-expanded="true"] .icon,
.section-collapse[aria-expanded="true"] .icon {
  transform: rotate(-90deg);
}

/* The collapse control belongs to the panel heading, so it never absorbs the
   flexible space in .section-head. */
.icon-button.section-collapse {
  flex: 0 0 auto;
}

/* Issue #469: the source workbook's identifier for an asset, shown beside the
   name because it is identity. Monospaced so codes line up down the column and
   an transposed character is visible; quiet so it never outweighs the name. */
.asset-tag {
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--ink-faint);
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.74rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Divider rows that group records inside a list table: archived records at
   the bottom, and assetType groups in the asset register. */
.type-group-row td,
.archived-group-row td {
  background: var(--surface-sunken);
  color: var(--ink-soft);
  font-weight: 600;
}

/* Expand/collapse control on parent asset rows; sized down from .icon-button
   so it reads as part of the row identity, not a row action. */
.icon-button.tree-toggle {
  width: 1.5rem;
  min-width: 1.5rem;
  height: 1.5rem;
  min-height: 1.5rem;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.icon-button {
  display: inline-flex;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0;
  color: var(--ink-soft);
  background: var(--surface);
  box-shadow: none;
}

.icon-button:hover {
  color: var(--teal-800);
  border-color: var(--teal-600);
  background: var(--teal-50);
  text-decoration: none;
}

.icon-button.danger {
  border-color: var(--red-border);
  color: var(--red-ink);
  background: var(--red-bg);
}

.icon-button.danger:hover {
  border-color: #b3402c;
  color: #fff;
  background: #b3402c;
}

.icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.user-status-form {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.user-status-form select {
  width: auto;
  min-width: 9rem;
  min-height: 2rem;
  flex: 1 1 auto;
}

.user-status-meta {
  display: block;
  margin-top: 0.25rem;
}

.table-detail-row td {
  padding: 0;
  background: var(--surface-sunken);
}

.row-details,
.record-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.85rem 1.25rem;
  margin: 0;
}

.row-details {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.row-details dt,
.record-meta dt {
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.row-details dd,
.record-meta dd {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
}

.row-details-wide { grid-column: 1 / -1; }

.record-header { margin-bottom: 1rem; }
.record-summary { margin-bottom: 0; }
.record-summary > .muted { margin: 1rem 0 0; }
.eyebrow { margin: 0 0 0.25rem; color: var(--ink-faint); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.document-detail-summary { max-width: 70ch; margin: 0; white-space: pre-wrap; }
.document-proposal-list { display: grid; gap: 0.65rem; margin: 0; padding: 0; list-style: none; }
.document-proposal-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.document-proposal-list li span:nth-child(2) { flex: 1 1 20rem; }

.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;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link:hover {
  color: var(--teal-700);
  text-decoration: none;
}

.sort-link.active {
  color: var(--teal-700);
}

.sort-arrow {
  display: inline-flex;
  width: 0.8rem;
  justify-content: center;
  color: var(--ink-ghost);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.sort-link.active .sort-arrow {
  color: var(--teal-700);
}

.sort-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.35rem 0;
  color: var(--ink-faint);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sort-bar-label {
  color: var(--ink-ghost);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pagination-summary,
.pagination-page {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.86rem;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.button.disabled,
button.disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* ----------------------------------------------------------------- badge */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.6rem;
  color: var(--ink-soft);
  background: var(--surface-sunken);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.badge.high,
.badge.urgent {
  border-color: var(--red-border);
  color: var(--red-ink);
  background: var(--red-bg);
}

.badge.medium,
.badge.normal,
.badge.attention {
  border-color: var(--amber-border);
  color: var(--amber-ink);
  background: var(--amber-bg);
}

.badge.low,
.badge.good,
.badge.active,
.badge.stable {
  border-color: var(--green-border);
  color: var(--green-ink);
  background: var(--green-bg);
}

/* A count pill that links to the filtered set it summarizes. Wraps the badge
   span so the badge keeps its own colour; the anchor only adds the affordance. */
a.badge-link {
  display: inline-flex;
  text-decoration: none;
  border-radius: var(--radius-pill);
}

a.badge-link:hover {
  text-decoration: none;
}

a.badge-link .badge {
  cursor: pointer;
}

a.badge-link:hover .badge {
  border-color: var(--ink-soft);
}

a.badge-link:focus-visible {
  outline: 2px solid var(--teal-600);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- flash */

.flash {
  margin: 0 0 1.25rem;
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  color: var(--green-ink);
  background: var(--green-bg);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}

.flash .inline-form {
  margin-left: 0.5rem;
}

.flash.error {
  border-color: var(--red-border);
  color: var(--red-ink);
  background: var(--red-bg);
}

/* Issue #277: persistent "viewing as client" banner — amber so it cannot be
   mistaken for a success flash, with the exit action pinned on the right. */
.flash.client-preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-color: var(--amber-border);
  color: var(--amber-ink);
  background: var(--amber-bg);
}

/* ------------------------------------------------------------------ tabs */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0;
}

.tabs a {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.8rem;
  background: var(--surface);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}

.tabs a:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}

/* -------------------------------------------------------------- timeline */

.timeline {
  border-left: 2px solid var(--border-strong);
  padding-left: 1.25rem;
  margin-left: 0.35rem;
}

.timeline-item {
  display: block;
  position: relative;
  margin: 0 0 1.25rem;
}

.timeline-link {
  color: inherit;
  text-decoration: none;
}

.timeline-link:hover strong {
  color: var(--teal-700);
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: calc(-1.25rem - 1px);
  top: 0.45rem;
  width: 0.6rem;
  height: 0.6rem;
  margin-left: -0.3rem;
  border-radius: 50%;
  background: var(--teal-600);
  box-shadow: 0 0 0 3px var(--bg);
}

/* ----------------------------------------------------------- page header */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.5rem;
}

.page-header h1 {
  margin: 0;
}

.page-header p {
  margin: 0.25rem 0 0;
}

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

/* --------------------------------------------------------------- subnav */

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin: 1.25rem 0 1.75rem;
  border-bottom: 1px solid var(--border-strong);
}

.subnav a {
  padding: 0.6rem 0.9rem;
  border-bottom: 2px solid transparent;
  color: var(--ink-faint);
  font-weight: 600;
  font-size: 0.92rem;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.subnav a:hover {
  color: var(--teal-800);
  text-decoration: none;
}

.subnav a.active {
  color: var(--teal-800);
  border-bottom-color: var(--teal-700);
}

.subnav .count {
  margin-left: 0.4rem;
  color: var(--ink-ghost);
  font-weight: 700;
  font-size: 0.82rem;
}

.subnav .badge {
  margin-left: 0.4rem;
  min-height: auto;
  padding: 0.05rem 0.45rem;
  font-size: 0.7rem;
}

/* --------------------------------------------------------- section head */

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
}

.section-head h2 {
  margin: 0;
}

/* ----------------------------------------------------------------- empty */

.empty {
  padding: 2.5rem 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--ink-faint);
  text-align: center;
}

.empty p {
  margin: 0 0 0.85rem;
}

/* --------------------------------------------------------- definition list */

.dl {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 0.5rem 1.25rem;
  margin: 0;
}

.dl dt {
  color: var(--ink-faint);
  font-weight: 600;
  font-size: 0.88rem;
}

.dl dd {
  margin: 0;
}

/* AI Suggestions: card list that lets each suggestion use the full width
   instead of cramming everything into a single table cell. */
.proposals {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Issue #217: document-scoped bulk review panel above the suggestion list. */
.bulk-review {
  margin: 0 0 1rem;
}

.bulk-held-list {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
  padding: 0;
  list-style: none;
}

.proposal-bucket {
  margin: 0.75rem 0 0;
}

.proposal-bucket:first-child {
  margin-top: 0;
}

.proposal-bucket h2 {
  margin: 0;
}

.proposal-bucket p {
  margin: 0.1rem 0 0;
}

.proposal-card {
  padding: var(--card-padding);
}

.proposal-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
}

.proposal-headline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.proposal-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.proposal-property-chip span {
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.proposal-property-chip strong {
  color: var(--ink);
  font-weight: 700;
}

a.meta-chip:hover {
  color: var(--teal-700);
}

.proposal-title {
  margin: 0;
  font-size: 1rem;
}

.proposal-card-body {
  margin-top: 0.75rem;
}

.proposal-summary {
  margin: 0 0 0.6rem;
}

.proposal-source {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
}

.proposal-source .source-label {
  color: var(--ink-faint);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
}

.proposal-source .source-page {
  color: var(--ink-soft);
  font-weight: 600;
}

.proposal-fields {
  margin-top: 0.5rem;
  gap: 0.3rem 1rem;
  font-size: 0.9rem;
}

/* Inline auto-saving controls (asset link, approval target). */
.proposal-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.proposal-controls .control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.proposal-controls .control-label {
  color: var(--ink-faint);
  font-size: 0.84rem;
  font-weight: 600;
}

.proposal-controls select {
  min-width: 11rem;
}

.save-cue {
  min-width: 4.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-ghost);
}

.save-cue.saving {
  color: var(--ink-faint);
}

.save-cue.saved {
  color: var(--green-ink);
}

.save-cue.error {
  color: var(--red-ink);
}

.proposal-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-top: 1rem;
}

.recheck-link {
  min-height: auto;
  padding: 0;
  font-size: 0.85rem;
}

/* ----------------------------------------------------------------- forms */

.form-narrow {
  width: 100%;
}

/* Inline "add a managed option" disclosure beside a picker. Sits tight under
   the field it extends and stays visually secondary to it. */
.new-field-option {
  margin-top: -0.35rem;
}

.new-field-option > summary {
  width: fit-content;
  color: var(--teal-700);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.new-field-option > summary:hover {
  color: var(--teal-800);
}

.new-field-option > label {
  margin-top: 0.5rem;
}

.new-field-option > p {
  margin: 0.35rem 0 0;
}

.page:has(.form-narrow) .page-header {
  width: 100%;
  margin-inline: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.button.small,
button.small {
  min-height: 2rem;
  padding: 0.28rem 0.65rem;
  font-size: 0.82rem;
}

.button.link,
button.link {
  min-height: auto;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--teal-700);
  font-weight: 600;
}

.button.link:hover,
button.link:hover {
  background: none;
  color: var(--teal-600);
  text-decoration: underline;
  box-shadow: none;
}

/* -------------------------------------------- notification preferences */

.preference-group {
  margin-bottom: 1rem;
}

.preference-group select {
  min-width: 9.5rem;
}

.preference-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
}

/* -------------------------------------------------------------- settings */

.settings-layout {
  align-items: start;
}

.password-fields {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
}

.password-fields legend {
  padding: 0 0.3rem;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.88rem;
}

.g-recaptcha {
  margin: 0.25rem 0;
}

/* ---------------------------------------------------------------- health */

.health {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 650;
}

.health-dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--ink-ghost);
  box-shadow: 0 0 0 4px rgba(152, 162, 179, 0.15);
}

.health-dot.stable {
  background: #12b76a;
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.15);
}

.health-dot.attention {
  background: #f79009;
  box-shadow: 0 0 0 4px rgba(247, 144, 9, 0.15);
}

.health-dot.risk {
  background: #d92d20;
  box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.15);
}

/* ------------------------------------------------------------- list rows */

.list-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

a.list-row {
  color: inherit;
  text-decoration: none;
}

a.list-row:hover,
.list-row-main:hover {
  color: inherit;
  background: var(--surface-sunken);
  text-decoration: none;
}

.list-row-main {
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
}

.list-row-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.5rem;
}

.list-row:last-child {
  border-bottom: none;
}

.list-row .label {
  display: block;
  font-weight: 500;
}

/* ------------------------------------------------------------- dashboard */

.dashboard-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.dashboard-layout .panel,
.dashboard-secondary-grid .panel {
  align-content: start;
}

.dashboard-layout .section-head {
  align-items: flex-start;
}

.dashboard-layout .section-head p {
  margin: 0.2rem 0 0;
}

.inbox-sections {
  display: grid;
  gap: 1rem;
}

.inbox-section {
  display: grid;
  gap: 0.2rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.inbox-section:first-child {
  padding-top: 0;
  border-top: none;
}

.inbox-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.inbox-section-title {
  color: var(--ink);
  font-weight: 650;
}

.inbox-section-title:hover {
  color: var(--teal-700);
}

.dashboard-layout .list-row,
.dashboard-planning-panel .list-row,
.property-health-panel .list-row {
  align-items: flex-start;
}

.dashboard-layout .list-row > a:first-child,
.dashboard-layout .list-row > span:first-child,
.dashboard-layout .list-row-main,
.dashboard-planning-panel .list-row > span:first-child,
.property-health-panel .list-row > span:first-child {
  min-width: 0;
  flex: 1;
}

.dashboard-layout .list-row .label,
.dashboard-layout .list-row .muted-sm,
.dashboard-planning-panel .list-row .label,
.dashboard-planning-panel .list-row .muted-sm,
.property-health-panel .list-row .label,
.property-health-panel .list-row .muted-sm {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dashboard-layout .queue-foot,
.dashboard-planning-panel .queue-foot {
  justify-self: start;
  margin-top: 0.2rem;
  font-weight: 600;
}

.property-health-panel .health {
  align-items: flex-start;
}

.property-health-panel .health-dot {
  flex: 0 0 auto;
  margin-top: 0.22rem;
}

.dashboard-secondary-grid {
  align-items: start;
}

/* ------------------------------------------------------------ work items */

.work-item-layout {
  align-items: start;
}

.work-item-summary {
  align-content: start;
}

/* --------------------------------------------------------- notifications */

.notification-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--card-padding);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s var(--ease);
}

.notification-item:hover {
  box-shadow: var(--shadow-md);
}

.notification-item.unread {
  border-left: 3px solid var(--teal-600);
}

.notification-item h2 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.notification-recipients {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.2rem 0 0.45rem;
}

.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 18rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  color: var(--ink-soft);
  background: var(--surface-sunken);
  font-size: 0.78rem;
  font-weight: 600;
}

.recipient-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --------------------------------------------------------------- tasks */

.task-list {
  display: grid;
  gap: 0.85rem;
}

.task-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--card-padding);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}

.task-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.task-title {
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

/* ------------------------------------------------------ document progress */

.document-progress-panel {
  margin-bottom: 1rem;
}

.document-progress-meter {
  width: 100%;
  height: 0.75rem;
  margin: 0.2rem 0 0.95rem;
  accent-color: var(--teal-700);
}

.document-progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.75rem 1rem;
  margin: 0;
}

.document-progress-stats div {
  min-width: 0;
}

.document-progress-stats dt {
  color: var(--ink-faint);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.document-progress-stats dd {
  margin: 0.15rem 0 0;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
}

.table-documents .column-processing-status { width: 3.25rem; }
.table-documents .column-file { width: 42%; }
.table-documents .column-type { width: auto; }
.table-documents .column-actions { width: 5.95rem; }
.table-documents.documents-coordinator .column-file { width: 30%; }
.table-documents.documents-coordinator .column-type { width: 18%; }
.table-documents.documents-coordinator .column-visibility { width: 7rem; }
.table-documents.documents-coordinator .column-suggestions { width: 8.5rem; }
.table-documents.documents-coordinator .column-actions { width: 8.4rem; }

.table-documents .document-status-cell {
  text-align: center;
  vertical-align: middle;
}

.document-status-indicator {
  display: inline-flex;
  width: 1.75rem;
  height: 1.75rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--ink-faint);
  background: var(--surface-sunken);
}

.document-status-indicator:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.document-status-indicator.is-active {
  border-color: var(--teal-600);
  color: var(--teal-700);
  background: var(--teal-50);
}

.document-status-indicator.is-active .icon {
  animation: document-status-spin 0.9s linear infinite;
}

.document-status-indicator.is-success {
  border-color: var(--green-border);
  color: var(--green-ink);
  background: var(--green-bg);
}

.document-status-indicator.is-error {
  border-color: var(--red-border);
  color: var(--red-ink);
  background: var(--red-bg);
}

.document-status-indicator.is-review {
  border-color: var(--amber-border);
  color: var(--amber-ink);
  background: var(--amber-bg);
}

.table-documents .document-actions-cell {
  vertical-align: middle;
}

.document-actions-cell .table-actions {
  min-width: 0;
  flex-wrap: nowrap;
}

@keyframes document-status-spin {
  to {
    transform: rotate(360deg);
  }
}

.document-file {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.45rem;
}

.document-file-link {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-file .icon-button {
  flex: 0 0 auto;
}

.document-ai-output {
  min-width: 18rem;
}

.document-ai-output p {
  margin: 0;
  max-width: 42rem;
}

.document-ai-suggestion-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.document-ai-suggestions {
  display: grid;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.document-ai-suggestions li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

/* ------------------------------------------------------------------ chat */

.chat-layout {
  display: grid;
  grid-template-columns: minmax(12rem, 240px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.chat-sidebar h2 {
  margin-bottom: 0.7rem;
}

.chat-conversation-list {
  display: grid;
  gap: 0.35rem;
}

.chat-conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
}

.chat-conversation-link {
  display: grid;
  gap: 0.1rem;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  min-width: 0;
}

.chat-conversation-link:hover,
.chat-conversation-link.active {
  color: var(--ink);
  background: var(--surface-sunken);
  text-decoration: none;
}

.chat-conversation-link span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 650;
}

.chat-conversation-link small {
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.chat-thread {
  min-height: 680px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 0.8rem;
}

/* Issue #475: how much of a long chat still reaches the model. Quiet while
   everything is in view; it only takes on the warning tone once messages start
   dropping, because that is the point at which the number means something. */
.chat-memory {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--ink-faint);
  font-size: 0.78rem;
}

.chat-memory-label {
  font-weight: 600;
  white-space: nowrap;
}

.chat-memory-track {
  flex: 1;
  min-width: 3rem;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--border);
  overflow: hidden;
}

.chat-memory-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--teal-600);
}

.chat-memory-readout {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chat-memory-readout b {
  color: var(--ink-soft);
}

.chat-memory.is-strained {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber-ink);
}

.chat-memory.is-strained .chat-memory-fill {
  background: var(--amber-ink);
}

.chat-memory.is-strained .chat-memory-readout b {
  color: var(--amber-ink);
}

.chat-pending {
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  color: var(--amber-ink);
  background: var(--amber-bg);
  font-size: 0.9rem;
}

.chat-pending.hidden {
  display: none;
}

.chat-pending p {
  margin: 0 0 0.5rem;
}

.chat-pending ul {
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.chat-pending li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.chat-pending li.is-flagged {
  align-items: flex-start;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.5rem;
}

.chat-pending-warning {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
}

.chat-pending-item-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.chat-pending-actions {
  display: flex;
  gap: 0.5rem;
}

.chat-messages {
  min-height: 420px;
  max-height: 58vh;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 0.7rem;
  padding: 0.15rem;
}

.chat-message {
  display: flex;
}

.chat-message.is-user {
  justify-content: flex-end;
}

.chat-message.is-assistant {
  justify-content: flex-start;
}

.chat-bubble {
  width: fit-content;
  max-width: min(680px, 82%);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  background: var(--surface-sunken);
  box-shadow: var(--shadow-xs);
  overflow-wrap: anywhere;
}

.chat-message.is-user .chat-bubble {
  color: #fff;
  border-color: var(--teal-700);
  background: var(--teal-700);
}

.chat-bubble p {
  margin: 0;
  white-space: pre-wrap;
}

.chat-bubble p + p,
.chat-tools {
  margin-top: 0.55rem;
}

.chat-attachment {
  font-size: 0.86rem;
  opacity: 0.85;
}

.chat-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chat-tool-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0.08rem 0.5rem;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 0.76rem;
  font-weight: 650;
  text-transform: capitalize;
}

.chat-compose {
  display: grid;
  gap: 0.65rem;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.chat-compose textarea {
  min-height: 5rem;
}

.chat-compose-actions {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.75rem;
}

.chat-file {
  flex: 1;
  min-width: 0;
}

.chat-file input {
  min-height: 2.45rem;
  padding: 0.45rem 0.55rem;
}

.chat-status {
  min-height: 1.35rem;
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.88rem;
}

.chat-empty {
  margin: 0;
}

/* --------------------------------------------------------------- crumbs */

.crumbs {
  margin: 0 0 0.75rem;
  color: var(--ink-faint);
  font-size: 0.88rem;
}

.crumbs a {
  color: var(--ink-faint);
}

.crumbs a:hover {
  color: var(--teal-700);
}

/* ---------------------------------------------------------------- emails */

.email-body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}

.email-shell {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 24px;
  color: var(--ink);
  font-family: Arial, sans-serif;
}

/* -------------------------------------------- dashboard vitals + heat grid */

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

.stat-tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow-xs);
  color: var(--ink);
  transition: box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}

.stat-tile:hover {
  text-decoration: none;
  color: var(--ink);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

/* Label, value, and sub stack as blocks so long labels never wrap inline
   into the number. */
.stat-tile .stat-label,
.stat-tile .stat-value,
.stat-tile .stat-sub {
  display: block;
}

.stat-tile .stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stat-tile .stat-value {
  margin-top: 0.1rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-tile .stat-sub {
  margin-top: 0.05rem;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.stat-tile.urgent .stat-value {
  color: var(--red-ink);
}

.stat-tile.attention .stat-value {
  color: var(--amber-ink);
}

.heat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 0.6rem;
}

.heat-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  color: var(--ink);
  transition: box-shadow 0.15s var(--ease);
}

.heat-card:hover {
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

.heat-card .heat-name,
.heat-card .heat-why {
  display: block;
}

.heat-card .heat-name {
  font-weight: 700;
  font-size: 0.82rem;
}

.heat-card .heat-why {
  margin-top: 0.1rem;
  font-size: 0.74rem;
  color: var(--ink-faint);
}

.heat-card.stable {
  border-left-color: var(--green-border);
}

.heat-card.attention {
  border-left-color: var(--amber-border);
  background: var(--amber-bg);
}

.heat-card.risk {
  border-left-color: var(--red-border);
  background: var(--red-bg);
}

/* Care plan vitals (issue #295): a text-valued tile (e.g. health status) and
   the static, non-link variant keep the same anatomy. */
.stat-tile .stat-value.small {
  font-size: 1.02rem;
  padding-top: 0.28rem;
}

.stat-tile .stat-value .health-dot {
  margin-right: 0.35rem;
}

span.stat-tile {
  cursor: default;
}

.property-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: -0.4rem 0 1rem;
  font-size: 0.85rem;
}

/* Owner-care progress (issue #295) */
.progress-track {
  display: block;
  width: 100%;
  height: 0.55rem;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-track::-webkit-progress-bar {
  background: var(--surface-sunken);
  border-radius: var(--radius-pill);
}

.progress-track::-webkit-progress-value {
  background: var(--teal-600);
  border-radius: var(--radius-pill);
}

.progress-track::-moz-progress-bar {
  background: var(--teal-600);
  border-radius: var(--radius-pill);
}

.progress-label {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* Dashboard time horizons (issue #298) */
.hz-tabs {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.2rem;
  margin-bottom: 1.1rem;
}

.hz-tab {
  display: inline-block;
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.hz-tab:hover {
  text-decoration: none;
  color: var(--ink);
}

.hz-tab.active {
  background: var(--teal-900);
  color: #fff;
}

.hz-tab.active:hover {
  color: #fff;
}

.period-band {
  margin: -0.4rem 0 1rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.big-progress {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.big-progress .pct {
  font-size: 2.3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--teal-700);
}

.big-progress .bar {
  flex: 1;
  min-width: 200px;
}

.season-bars {
  display: grid;
  gap: 0.55rem;
}

.season-bar {
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr 3.5rem;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.82rem;
}

.season-bar .season-label {
  color: var(--ink-soft);
  font-weight: 600;
}

.season-bar .track {
  display: block;
  width: 100%;
  height: 0.7rem;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.season-bar .track::-webkit-progress-bar {
  background: var(--surface-sunken);
  border-radius: var(--radius-pill);
}

.season-bar .track::-webkit-progress-value {
  background: var(--coastal);
  border-radius: var(--radius-pill);
}

.season-bar .track::-moz-progress-bar {
  background: var(--coastal);
  border-radius: var(--radius-pill);
}

.season-bar .track.now::-webkit-progress-value {
  background: var(--teal-600);
}

.season-bar .track.now::-moz-progress-bar {
  background: var(--teal-600);
}

.season-bar .n {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Printable work sheets (issue #299) */
.worksheet {
  max-width: 52rem;
}

.worksheet-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--teal-900);
  padding-bottom: 0.8rem;
  margin-bottom: 1rem;
}

.worksheet-head h2 {
  margin: 0;
}

.worksheet-org {
  text-align: right;
}

.worksheet-org img {
  max-width: 150px;
  height: auto;
}

.worksheet-group {
  margin-top: 1.1rem;
  break-inside: avoid;
}

.worksheet-group h3 {
  margin: 0 0 0.15rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-700);
}

.worksheet-notes {
  margin: 0 0 0.4rem;
}

.worksheet-task {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  break-inside: avoid;
}

.worksheet-task-main {
  flex: 1;
  min-width: 0;
}

.worksheet-task-title {
  margin: 0;
  font-weight: 600;
}

.worksheet-line-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--ink-ghost);
  margin-right: 0.25rem;
}

.worksheet-box {
  flex-shrink: 0;
  width: 1.05rem;
  height: 1.05rem;
  border: 1.5px solid var(--ink-soft);
  border-radius: 3px;
  margin-top: 0.15rem;
  display: inline-block;
}

.worksheet-box.small {
  width: 0.8rem;
  height: 0.8rem;
  vertical-align: -0.1rem;
  margin-top: 0;
}

.worksheet-steps {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: grid;
  gap: 0.2rem;
}

.worksheet-due {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.worksheet-foot {
  margin-top: 1.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.worksheet-signature {
  border-bottom: 1px solid var(--ink-ghost);
  height: 2.2rem;
  margin-bottom: 0.25rem;
}

@media print {
  .sidebar,
  .mobile-bar,
  .flash,
  .client-preview-banner,
  .no-print {
    display: none !important;
  }

  body,
  .app,
  .page {
    background: #fff !important;
  }

  .page {
    padding: 0 !important;
  }

  .worksheet {
    max-width: none;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}

/* ----------------------------------------------------------- responsive */

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

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 60;
    padding: 0.7rem 1.1rem;
    background: linear-gradient(180deg, var(--teal-800), var(--teal-900));
    box-shadow: var(--shadow-md);
  }

  .menu-toggle {
    display: inline-flex;
    min-height: 2.1rem;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: var(--radius-sm);
    padding: 0.3rem 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.88rem;
    cursor: pointer;
  }

  .sidebar {
    display: none;
  }

  .sidebar-toggle-input:checked ~ .sidebar {
    display: flex;
    position: fixed;
    top: 3.55rem;
    bottom: 0;
    left: 0;
    z-index: 55;
    width: min(19rem, 86vw);
    height: auto;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-toggle-input:focus-visible ~ .mobile-bar .menu-toggle {
    box-shadow: var(--focus);
  }

  .page {
    padding: 1.5rem 1.1rem 3rem;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14.5px;
  }

  /* Wide operational tables scroll sideways instead of stretching the page. */
  .table-wrap {
    margin-inline: -0.25rem;
  }

  .table-wrap .table {
    min-width: 680px;
  }

  .split,
  .page-header,
  .task-card {
    align-items: stretch;
    flex-direction: column;
  }

  .task-meta {
    justify-content: flex-start;
  }

  .grid.lead,
  .grid.two,
  .grid.three,
  .grid.four,
  .chat-layout,
  .dashboard-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .chat-thread {
    min-height: 560px;
  }

  .chat-messages {
    max-height: 54vh;
  }

  .chat-bubble {
    max-width: 92%;
  }

  .chat-compose-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 1.45rem;
  }
}

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

  .document-status-indicator.is-active .icon {
    animation: none;
  }
}

.checklist-editor {
  border: 1px solid var(--line, #d8d8d8);
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.checklist-editor legend {
  font-weight: 600;
  padding: 0 0.3rem;
}

.checklist-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checklist-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.checklist-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

.checklist-row.completed input[type="text"] {
  color: var(--ink-soft);
  background: var(--surface-sunken);
}

.checklist-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.checklist-step {
  align-items: flex-start;
}

.checklist-step .muted-sm {
  display: block;
}

.checklist-step.done {
  color: var(--ink-soft);
}

.inline-form[data-checklist-suggestion-form] {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checklist-suggestion-status {
  min-height: 1.25rem;
}

.checklist-suggestion-status.success {
  color: var(--green-ink);
}

.checklist-suggestion-status.error {
  color: var(--red-ink);
}

/* Photos tab */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.photo-card {
  margin: 0;
  border: 1px solid var(--border, #e2e2e2);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel, #fff);
}

.photo-card img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #f2f2f2;
}

.photo-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
}

.photo-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-card .badge {
  align-self: flex-start;
}

.photo-card-note {
  font-size: 0.85rem;
  color: var(--muted-ink, #555);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* Issue #149: global document-status overlay. Stacks above the chat toggle
   in the bottom-right corner — bottom-left belongs to the sidebar's user
   block, which the first placement covered. */
.doc-status-overlay {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 90;
  max-width: min(22rem, calc(100vw - 2rem));
}
/* While its panel is open, the overlay rises above the chat toggle so the
   panel is fully clickable; closed, it sits beneath the chat surfaces. */
.doc-status-overlay:has(.doc-status-panel:not(.hidden)) { z-index: 96; }
.doc-status-overlay.hidden { display: none; }
.doc-status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.doc-status-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--color-urgent, #b3261e);
}
.doc-status-dot.hidden { display: none; }
.doc-status-panel {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  right: 0;
  width: min(22rem, calc(100vw - 2rem));
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #d7d2c7);
  border-radius: 0.75rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  max-height: min(24rem, 60vh);
  overflow-y: auto;
}
.doc-status-panel.hidden { display: none; }
.doc-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem 0;
}
.doc-status-header h2 { font-size: 0.95rem; margin: 0; }
.doc-status-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.doc-status-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0.9rem 0.7rem;
}
.doc-status-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--color-border, #eee);
}
.doc-status-item:first-child { border-top: none; }
.doc-status-item-body { flex: 1; min-width: 0; }
.doc-status-item-body a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-status-item-body p { margin: 0.1rem 0 0; }
.doc-status-progress {
  width: 100%;
  height: 0.4rem;
  margin: 0.25rem 0 0.1rem;
  accent-color: var(--teal-700);
}
@media (max-width: 640px) {
  .doc-status-overlay {
    right: 0.5rem;
    bottom: 0.75rem;
  }
  .doc-status-panel {
    width: calc(100vw - 1rem);
    max-height: 45vh;
  }
}


/* Issue #150: global chat widget (bottom-right) and the chromeless embed
   frame it hosts. */
/* Owner preference: chat pill on top of the bottom-right stack, the wider
   document pill at the bottom. */
.chat-widget {
  position: fixed;
  bottom: 4.4rem;
  right: 1rem;
  z-index: 95;
}
.chat-widget-toggle {
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.chat-widget-panel {
  position: fixed;
  bottom: 7.8rem;
  right: 1rem;
  width: min(31rem, calc(100vw - 2rem));
  height: min(44rem, calc(100vh - 9rem));
  display: flex;
  flex-direction: column;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #d7d2c7);
  border-radius: 0.75rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.chat-widget-panel.hidden { display: none; }
.chat-widget-panel.expanded {
  width: min(72rem, calc(100vw - 3rem));
  height: calc(100vh - 3rem);
  bottom: 1.5rem;
  right: 1.5rem;
}
.chat-widget-controls { display: flex; gap: 0.25rem; }
.chat-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--color-border, #eee);
}
.chat-widget-header h2 { font-size: 0.95rem; margin: 0; }
.chat-widget-close {
  width: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.chat-widget-close:hover {
  color: var(--ink);
  background: var(--surface-sunken);
  border-color: var(--border);
  box-shadow: none;
}
#chat-widget-frame {
  border: 0;
  width: 100%;
  flex: 1;
}
@media (max-width: 640px) {
  .chat-widget {
    right: 0.5rem;
    bottom: 4.1rem;
  }
  .chat-widget-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: min(80vh, 100vh - 3rem);
    border-radius: 0.75rem 0.75rem 0 0;
  }
}

/* Chromeless embed page inside the widget frame. */
.embed-shell { display: block; }
.embed-page { padding: 0.75rem; }
.embed-page .page-header { margin-bottom: 0.5rem; }
.embed-page .chat-layout {
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
.chat-history-disclosure summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.15rem 0;
}
.document-proposal-disclosure summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.15rem 0;
}
.document-proposal-disclosure[open] summary { margin-bottom: 0.5rem; }
.embed-page .chat-history-disclosure { padding: 0.5rem 0.75rem; }
.embed-page .chat-history-disclosure[open] .chat-conversation-list {
  max-height: 11rem;
  overflow-y: auto;
  margin-top: 0.35rem;
}
.embed-page .chat-thread { min-height: 24rem; }
.chat-context-chip { margin: 0.15rem 0 0; }
