/* ==========================================================================
   UZHS PRO Business Command Center — brand stylesheet
   Royal blue · deep navy · metallic gold · white · architectural detailing
   ========================================================================== */

/* Self-hosted brand type. Both families are variable fonts under the SIL Open
   Font License; see OFL-*.txt in this folder. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter.woff2") format("woff2");
}

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/montserrat.woff2") format("woff2");
}

:root {
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
  --font-display: "Montserrat", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    sans-serif;

  color-scheme: light dark;

  /* Brand */
  --navy-900: #041d36;
  --navy-800: #062a55;
  --navy-700: #0a3a6b;
  --blue-700: #08498f;
  --blue-600: #0b5cb0;
  --blue-500: #146fc9;
  --gold: #d4a23c;
  --gold-bright: #f0cb77;
  --gold-ink: #8a6416;
  --silver: #9aa9bb;

  /* Surfaces + text */
  --paper: #eef3fa;
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --surface-3: #eef4fb;
  --border: #dfe7f1;
  --border-strong: #c9d6e5;
  --ink: #12253c;
  --heading: #0a2b4a;
  --label: #24364d;
  --muted: #5b6c82;
  --placeholder: #8b9ab0;

  /* Semantics */
  --danger: #b32626;
  --danger-soft: #fdf0f0;
  --ok: #0c6b45;
  --ok-soft: #e7f6ee;
  --warn: #8a5a00;
  --warn-soft: #fff4e0;
  --info: #0b4f9e;
  --info-soft: #e8f0fb;

  --ring: rgba(11, 92, 176, 0.18);
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(9, 32, 61, 0.06);
  --shadow: 0 1px 2px rgba(9, 32, 61, 0.06), 0 14px 32px -24px rgba(9, 32, 61, 0.45);
  --shadow-lg: 0 30px 70px -34px rgba(3, 20, 40, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #061524;
    --surface: #0c2236;
    --surface-2: #102a41;
    --surface-3: #122f48;
    --border: #1d3a56;
    --border-strong: #2b4c6c;
    --ink: #e8f1fa;
    --heading: #f2f7fd;
    --label: #c8d9e9;
    --muted: #9fb2c7;
    --placeholder: #7b90a8;
    --gold-ink: #e9c476;

    --danger: #ff9a9a;
    --danger-soft: #3a1c22;
    --ok: #7fe3b8;
    --ok-soft: #0d2c22;
    --warn: #f5c05a;
    --warn-soft: #322610;
    --info: #9dc4ff;
    --info-soft: #12263f;

    --ring: rgba(120, 176, 242, 0.25);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 38px -26px rgba(0, 0, 0, 0.85);
    --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, 0.85);
  }
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.page-title,
.stat__value,
.card__title,
.service__label,
.eyebrow,
.btn,
.tabs button,
.badge,
.pill,
.filter,
.divider,
.user-chip__role,
.auth-brand__values,
.auth-brand__markets {
  font-family: var(--font-display);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

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

.small {
  font-size: 0.82rem;
}

/* ==========================================================================
   Official brand assets
   The horizontal lockup is a single official image. It is never redrawn,
   recoloured, filtered or animated, and its intrinsic dimensions plus
   aspect-ratio reserve the exact space before the file decodes.
   ========================================================================== */

.brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  display: block;
  width: auto;
  height: auto;
  aspect-ratio: 1730 / 551;
  object-fit: contain;
}

.brand-logo--auth {
  width: min(342px, 100%);
}

.brand-logo--app {
  height: 28px;
}

/* White plate keeps the official blue/gold artwork at full fidelity on the
   navy bar instead of recolouring or filtering it. */
.brand-plate {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 20px -16px rgba(3, 20, 40, 0.95);
}

/* ==========================================================================
   Login screen
   ========================================================================== */

.auth {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
  background: var(--paper);
}

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

.auth-brand {
  /* The brand panel is always the light architectural surface, so it keeps
     light-mode text tokens even when the rest of the app is in dark mode. */
  --heading: #0a2b4a;
  --ink: #12253c;
  --muted: #5b6c82;
  --label: #24364d;
  --placeholder: #8b9ab0;
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 26px 18px 10px;
  background-color: #fbfdff;
  background-image: url("/assets/cityscape.svg"),
    repeating-linear-gradient(
      115deg,
      rgba(11, 92, 176, 0.055) 0 1px,
      transparent 1px 96px
    ),
    linear-gradient(155deg, #fdfeff 0%, #f3f8fe 52%, #e4eefa 100%);
  background-repeat: no-repeat, repeat, no-repeat;
  background-position: right -30px bottom -12px, 0 0, 0 0;
  background-size: 84% auto, auto, auto;
}

/* soft architectural light sweep */
.auth-brand::before {
  content: "";
  position: absolute;
  top: -30%;
  left: -18%;
  width: 62%;
  height: 130%;
  transform: rotate(16deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.auth-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    rgba(252, 254, 255, 0.92) 0%,
    rgba(252, 254, 255, 0.74) 44%,
    rgba(252, 254, 255, 0.16) 74%,
    rgba(252, 254, 255, 0) 94%
  );
  pointer-events: none;
}

.auth-brand__inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  width: 100%;
  max-width: 660px;
  margin-inline: auto;
}

.auth-brand__copy {
  display: none;
}

.auth-brand__line {
  display: block;
  margin-top: 2px;
  font-size: clamp(1.45rem, 2.8vw, 2.55rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.14;
  color: var(--heading);
  text-wrap: balance;
}

.auth-brand__title {
  margin: 0;
}

.auth-brand__sub {
  margin: 12px 0 0;
  font-size: clamp(0.95rem, 1.2vw, 1.12rem);
  color: var(--muted);
}

.service-list {
  display: none;
  list-style: none;
  gap: clamp(18px, 3vw, 46px);
  padding: 0;
  margin: 0;
}

.service {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 108px;
  text-align: center;
}

.service__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 24%, #1a63b8, #073d7f 72%);
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 4.5px var(--gold), 0 12px 22px -14px rgba(6, 42, 85, 0.9);
  color: #ffffff;
}

.service__icon svg {
  width: 30px;
  height: 30px;
}

.service__label {
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--heading);
}

.auth-brand__footer {
  display: none;
  margin-top: 4px;
  text-align: center;
}

.auth-brand__rule {
  display: block;
  width: 100%;
  max-width: 420px;
  height: 2px;
  margin: 0 auto 14px;
  background: linear-gradient(90deg, transparent, var(--gold) 18%, var(--gold) 82%, transparent);
}

.auth-brand__values,
.auth-brand__markets {
  margin: 0;
  text-transform: uppercase;
  color: var(--heading);
}

.auth-brand__values {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3em;
}

.auth-brand__markets {
  margin-top: 7px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--muted);
}

.auth-brand__values span,
.auth-brand__markets span {
  margin: 0 0.85em;
  color: var(--gold);
}

/* ---------- Navy login panel ---------- */

.auth-panel {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8px 16px 40px;
}

@media (max-width: 999px) {
  .auth {
    align-content: start;
    background-image: repeating-linear-gradient(
        115deg,
        rgba(11, 92, 176, 0.05) 0 1px,
        transparent 1px 88px
      ),
      linear-gradient(160deg, #fdfeff 0%, #f2f8fe 46%, #e7f0fb 100%);
  }

  .auth-brand {
    background: transparent;
    padding: 26px 18px 14px;
  }

  .auth-panel {
    background: transparent;
    padding: 4px 16px 40px;
  }
}

@media (max-width: 519px) {
  .auth-brand {
    padding: 22px 16px 12px;
  }

  .brand-logo--auth {
    width: min(276px, 100%);
  }

  .auth-brand__inner {
    gap: 12px;
  }
}

@media (min-width: 1000px) {
  .auth {
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  }

  .auth-brand {
    align-items: stretch;
    padding: clamp(28px, 3.4vw, 52px) clamp(22px, 3vw, 46px);
    background-size: min(90%, 640px) auto, auto, auto;
  }

  .auth-brand__inner {
    min-height: 100%;
  }

  .brand-logo--auth {
    width: clamp(300px, 27vw, 372px);
    max-width: 100%;
  }

  .auth-brand__inner {
    align-items: flex-start;
    text-align: left;
    gap: clamp(16px, 2.4vw, 30px);
  }

  .auth-brand__copy {
    display: block;
  }

  .service-list {
    display: flex;
  }

  .auth-brand__footer {
    display: block;
    width: 100%;
    margin-top: auto;
    padding-top: clamp(14px, 3vh, 36px);
    text-align: left;
  }

  .auth-brand__rule {
    margin-inline: 0;
  }

  .auth-panel {
    padding: clamp(18px, 2.2vw, 34px);
    background: radial-gradient(120% 90% at 78% 8%, #0c3d71 0%, #062a55 46%, #041d36 100%);
  }

  .auth-panel::before {
    content: "";
    position: absolute;
    top: -22%;
    right: -10%;
    width: 66%;
    height: 66%;
    transform: rotate(-24deg);
    background: linear-gradient(
        90deg,
        rgba(240, 203, 119, 0) 0 43%,
        rgba(240, 203, 119, 0.92) 43% 44.2%,
        rgba(240, 203, 119, 0) 44.2% 100%
      ),
      linear-gradient(
        90deg,
        rgba(212, 162, 60, 0) 0 53%,
        rgba(212, 162, 60, 0.6) 53% 53.7%,
        rgba(212, 162, 60, 0) 53.7% 100%
      ),
      linear-gradient(
        90deg,
        rgba(212, 162, 60, 0) 0 30%,
        rgba(212, 162, 60, 0.16) 40%,
        rgba(240, 203, 119, 0.22) 46%,
        rgba(212, 162, 60, 0.14) 52%,
        rgba(212, 162, 60, 0) 68%
      );
    pointer-events: none;
    z-index: -1;
  }

  .auth-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(
        115deg,
        rgba(212, 162, 60, 0.24) 0 1px,
        transparent 1px 74px
      ),
      linear-gradient(115deg, rgba(126, 180, 236, 0.16) 0 12%, transparent 12% 26%);
    pointer-events: none;
    z-index: -1;
  }

  .auth-card {
    box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.7);
  }
}

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

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px 20px;
  box-shadow: var(--shadow-lg);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright) 45%, var(--gold));
}

.auth-card__head {
  text-align: center;
  margin-bottom: 18px;
}

.auth-card__head h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.2vw, 1.95rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--heading);
}

.auth-card__sub {
  margin: 8px auto 0;
  max-width: 46ch;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- Fields ---------- */

.field {
  margin-top: 14px;
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--label);
}

.input {
  position: relative;
  display: flex;
  align-items: center;
}

.input input {
  width: 100%;
  height: 48px;
  padding: 0 14px 0 44px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#password {
  padding-right: 48px;
}

.input:has(.input__action) input {
  padding-right: 48px;
}

.input input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.input input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px var(--ring);
}

.input__icon {
  position: absolute;
  left: 14px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--placeholder);
  pointer-events: none;
}

.input__icon svg {
  width: 19px;
  height: 19px;
}

.input__action {
  position: absolute;
  right: 7px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--placeholder);
  cursor: pointer;
}

.input__action:hover {
  color: var(--blue-600);
  background: var(--surface-2);
}

.input__action svg {
  width: 19px;
  height: 19px;
}

.eye--off {
  display: none;
}

#toggle-password[aria-pressed="true"] .eye--open {
  display: none;
}

#toggle-password[aria-pressed="true"] .eye--off {
  display: block;
  color: var(--blue-600);
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

.checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue-600);
  cursor: pointer;
}

.auth-link {
  border: 0;
  background: none;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--blue-600);
  cursor: pointer;
}

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

.form-error,
.form-hint {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-radius: 7px;
  font-size: 0.83rem;
  line-height: 1.4;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
}

.form-hint {
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid color-mix(in srgb, var(--info) 22%, transparent);
}

.form-error:empty,
.form-hint:empty {
  display: none;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.1s ease;
}

.btn--block {
  width: 100%;
  margin-top: 16px;
  height: 52px;
  font-size: 1rem;
}

.btn--primary {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  color: #ffffff;
  letter-spacing: 0.01em;
  box-shadow: 0 14px 26px -16px rgba(11, 92, 176, 0.95);
}

.btn--primary svg {
  width: 20px;
  height: 20px;
}

.btn--primary:hover {
  background: linear-gradient(135deg, #0d68c4, #0a54a4);
}

.btn--primary:active {
  transform: translateY(1px);
}

.btn--primary[disabled] {
  opacity: 0.7;
  cursor: progress;
  box-shadow: none;
}

.btn--outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--heading);
  font-weight: 600;
  font-size: 0.95rem;
  height: 50px;
}

.btn--outline:hover {
  background: var(--surface-2);
  border-color: var(--blue-500);
}

.ms-mark {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn--ghost-light {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border-color: rgba(255, 255, 255, 0.34);
  background: transparent;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn--ghost-light:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.6);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--placeholder);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.secure {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.secure__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--heading);
}

.secure__icon svg {
  width: 27px;
  height: 27px;
}

.secure__title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--heading);
}

.secure__text {
  margin: 4px 0 0;
  font-size: 0.79rem;
  line-height: 1.45;
  color: var(--muted);
}

/* ---------- Demo accounts ---------- */

.demo {
  margin-top: 16px;
  border-top: 1px dashed var(--border-strong);
  padding-top: 12px;
}

.demo summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.demo p {
  margin: 10px 0 0;
}

.demo code {
  font-size: 0.76rem;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-3);
}

.demo-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.demo-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  text-align: left;
  font-size: 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.demo-account:hover {
  border-color: var(--gold);
  background: var(--surface-3);
}

.demo-account span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-account span:last-child {
  flex: none;
  color: var(--gold-ink);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app {
  min-height: 100dvh;
  background: var(--paper);
  background-image: repeating-linear-gradient(
    115deg,
    rgba(11, 92, 176, 0.035) 0 1px,
    transparent 1px 110px
  );
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(9px + env(safe-area-inset-top)) 16px 9px;
  background: linear-gradient(115deg, var(--navy-800), var(--navy-700) 52%, var(--navy-800));
  border-bottom: 3px solid var(--gold);
  color: #ffffff;
  box-shadow: 0 10px 26px -22px rgba(3, 20, 40, 0.9);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: #ffffff;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(212, 162, 60, 0.75);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.74rem;
  flex: none;
}

.user-chip__meta {
  display: grid;
  line-height: 1.2;
}

.user-chip__role {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.app-body {
  max-width: 1180px;
  margin-inline: auto;
  padding: 0 16px calc(92px + env(safe-area-inset-bottom));
}

.tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -14px 30px -26px rgba(6, 42, 85, 0.7);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-padding-inline: 8px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

/* Each tab is as wide as its own label: squeezing fixed-width items made
   longer labels paint over their neighbours on narrow phones. The strip stays
   scrollable, snaps, and keeps a 48px touch target. */
.tabs button {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 48px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: center;
}

.tabs button:hover {
  color: var(--blue-600);
}

.tabs button[aria-current="page"] {
  background: var(--surface-3);
  color: var(--navy-800);
  box-shadow: inset 0 2px 0 var(--gold);
}

@media (prefers-color-scheme: dark) {
  .tabs button[aria-current="page"] {
    color: var(--heading);
  }
}

/* ---------- Location bar: Back + breadcrumbs + context routes ---------- */

/* The location bar follows the page down, tucked under the navy top bar, so
   Back and Forward are always in reach and pressing Back never scrolls the
   screen the user is trying to keep. The offset is measured in nav.js because
   the top bar carries the device's safe-area inset. */
.navbar {
  position: sticky;
  top: var(--nav-sticky-top, 56px);
  z-index: 15;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 14px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.navbar:empty {
  display: none;
}

/* Back and Forward sit together like a browser's own pair. They are rendered on
   every screen and disabled when the history has nothing to offer. */
.navbar__history {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.navbar__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--navy-800);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.navbar__step:hover:not(:disabled) {
  border-color: var(--blue-500);
  color: var(--blue-600);
}

.navbar__step:disabled {
  opacity: 0.45;
  cursor: default;
}

.navbar__step:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

.navbar__trail {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  flex: 1 1 240px;
  min-width: 0;
}

.crumbs {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.crumbs ol {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 2px 0;
  list-style: none;
  white-space: nowrap;
}

.crumbs li {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 0.78rem;
  color: var(--muted);
}

.crumbs button {
  border: 0;
  background: transparent;
  padding: 6px 2px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  /* Uses the semantic link colour so the trail keeps AA contrast in both
     schemes (the brand blue is too dark on the dark surface). */
  color: var(--info);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

.crumbs button:hover {
  text-decoration-color: currentColor;
}

.crumbs__sep {
  color: var(--border-strong);
  font-size: 0.8rem;
}

.crumbs [aria-current="page"] {
  font-weight: 800;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.navbar__context {
  display: flex;
  gap: 6px;
  flex: none;
}

.navbar__chip {
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--navy-800);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.navbar__chip:hover {
  border-color: var(--gold);
  box-shadow: inset 0 -2px 0 var(--gold);
}

@media (max-width: 560px) {
  .navbar {
    gap: 6px;
    padding: 8px;
  }

  /* Phones get two full-width 48px targets: the primary way in and out of a
     record should never be a small link. */
  .navbar__history {
    flex: 1 1 100%;
  }

  .navbar__step {
    flex: 1 1 0;
    min-height: 48px;
    padding: 10px 12px;
    font-size: 0.86rem;
  }

  .navbar__trail {
    flex: 1 1 100%;
    gap: 6px;
  }

  .crumbs [aria-current="page"] {
    max-width: 60vw;
  }

  .navbar__context {
    flex: none;
    margin-left: 0;
  }

  .navbar__chip {
    min-height: 44px;
  }
}

@media (prefers-color-scheme: dark) {
  .navbar__step,
  .navbar__chip {
    color: var(--heading);
  }
}

@media print {
  .navbar {
    display: none;
  }
}

.content {
  padding-top: 24px;
  outline: none;
}

.content > header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-ink);
}

.page-title {
  margin: 8px 0 4px;
  font-size: clamp(1.4rem, 4.4vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--heading);
}

.page-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.stack {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

/* A card with one wide badge must never widen the whole column. */
.stack > * {
  min-width: 0;
}

/* ==========================================================================
   Stats + cards
   ========================================================================== */

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

.stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
}

.stat__label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 800;
}

/* Label, figure and note always stack: the team and access cards use plain
   spans, and inline spans let the large figure ride over the label. */
.stat__value {
  display: block;
  margin-top: 6px;
  /* Scales down on phones so a figure such as $9,050.00 never breaks mid-number
     when the stat grid uses two columns. */
  font-size: clamp(1.4rem, 1rem + 2.1vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--heading);
}

.stat__hint,
.stat__meta {
  display: block;
  margin-top: 2px;
  font-size: 0.74rem;
  color: var(--muted);
}

.stat--accent {
  background: linear-gradient(150deg, #0b4f9e 0%, #062a55 72%);
  border-color: transparent;
  color: #ffffff;
}

.stat--accent::before {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
}

.stat--accent .stat__label,
.stat--accent .stat__hint {
  color: rgba(255, 255, 255, 0.78);
}

.stat--accent .stat__value {
  color: #ffffff;
}

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

.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--heading);
}

.link-btn {
  background: none;
  border: 0;
  padding: 4px;
  color: var(--blue-600);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

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

.two-col {
  display: grid;
  gap: 18px;
}

/* ==========================================================================
   Tickets
   ========================================================================== */

.ticket {
  display: grid;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.ticket:first-child {
  border-top: 0;
  padding-top: 0;
}

.ticket:last-child {
  padding-bottom: 0;
}

.ticket__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ticket__title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--heading);
}

.ticket__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.ticket__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.status-select {
  appearance: none;
  padding: 7px 30px 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background-color: var(--surface-2);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.status-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.locked {
  font-size: 0.72rem;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pill--open {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill--progress {
  background: var(--info-soft);
  color: var(--info);
}

.pill--done {
  background: var(--ok-soft);
  color: var(--ok);
}

.priority {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: capitalize;
}

.priority::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.priority--high::before {
  background: #d64545;
}

.priority--medium::before {
  background: var(--gold);
}

.priority--low::before {
  background: var(--silver);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.filter {
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.filter:hover {
  border-color: var(--blue-500);
  color: var(--blue-600);
}

.filter[aria-pressed="true"] {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: #ffffff;
  box-shadow: inset 0 -2px 0 var(--gold);
}

/* ==========================================================================
   Activity + people
   ========================================================================== */

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.feed li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
  font-size: 0.84rem;
}

.feed li:first-child {
  border-top: 0;
  padding-top: 0;
}

.feed__dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.feed__detail {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.feed time {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.person-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.person-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.person-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--heading);
}

.person-email {
  color: var(--muted);
  font-size: 0.76rem;
  word-break: break-all;
}

.badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge--admin {
  background: var(--navy-800);
  color: var(--gold-bright);
}

.badge--manager {
  background: var(--info-soft);
  color: var(--info);
}

.badge--member {
  background: var(--surface-2);
  color: var(--muted);
}

.person-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workload {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

.empty {
  padding: 26px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ==========================================================================
   Loading + toast
   ========================================================================== */

.loading {
  display: grid;
  gap: 10px;
  padding: 28px 0;
}

.skeleton {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--navy-800);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
}

.toast--error {
  background: var(--danger);
  color: #ffffff;
}

/* ==========================================================================
   Breakpoints
   ========================================================================== */

@media (min-width: 520px) {
  .auth-card {
    padding: 30px 32px 24px;
  }
}

@media (min-width: 640px) {
  .user-chip {
    display: flex;
  }

  .brand-logo--app {
    height: 36px;
  }

  .brand-plate {
    padding: 6px 12px;
  }
}

@media (min-width: 720px) {
  .app-body {
    padding-bottom: 48px;
  }

  .tabs {
    position: static;
    padding: 14px 0 0;
    gap: 6px;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    /* Phase 3 added five sections: let the strip wrap instead of pushing the
       page wider than tablet and laptop viewports. */
    flex-wrap: wrap;
    row-gap: 2px;
    overflow: visible;
  }

  .tabs button {
    flex: 0 0 auto;
    min-width: 0;
    padding: 10px 16px 12px;
    border-radius: 8px 8px 0 0;
    font-size: 0.85rem;
  }

  .tabs button[aria-current="page"] {
    background: transparent;
    color: var(--heading);
    box-shadow: inset 0 -3px 0 var(--gold);
  }

  .toast {
    bottom: 28px;
  }

  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (min-width: 900px) {
  .two-col {
    grid-template-columns: 1.45fr 1fr;
    align-items: start;
  }

  .content {
    padding-top: 28px;
  }
}

/* ==========================================================================
   Phase 2 — construction management, payment schedules and portals
   ========================================================================== */

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

.stat__value {
  overflow-wrap: anywhere;
}

.stack-card {
  margin-top: 18px;
}

.subcard {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 14px;
  min-width: 0;
}

.card__note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.subhead {
  margin: 20px 0 10px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn--small {
  height: 38px;
  padding: 0 14px;
  font-size: 0.8rem;
  border-radius: 7px;
  margin-top: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--label);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag--code {
  border-color: color-mix(in srgb, var(--gold) 55%, transparent);
  color: var(--gold-ink);
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
}

/* Option C: project/job reference first, Command Center reference second. Both
   tokens open the same record; the pair wraps instead of widening a table. */
.record-refs {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-width: 100%;
  vertical-align: baseline;
}

.record-refs .record-ref {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.record-refs__sep {
  color: var(--muted);
  opacity: 0.65;
  font-weight: 500;
}

.record-refs .link-btn.record-ref {
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
}

.record-refs button.record-ref {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.record-refs button.record-ref:hover {
  text-decoration-style: solid;
}

.record-refs--tag {
  align-items: center;
  gap: 0.25rem;
}

.record-refs--tag .record-ref {
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  color: var(--gold-ink);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.mini-tag--void {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--danger-soft);
}

.mini-tag--paid {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
  background: var(--ok-soft);
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--heading);
  white-space: nowrap;
}

.amount--out {
  color: var(--danger);
}

/* Native <progress> styling keeps the CSP free of inline styles. */
progress.progress {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  border: 1px solid var(--border);
}

progress.progress::-webkit-progress-bar {
  background: var(--surface-3);
  border-radius: 999px;
}

progress.progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-600), var(--navy-700) 60%, var(--gold));
}

progress.progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-600), var(--navy-700) 60%, var(--gold));
}

.progress--thin {
  height: 6px;
  margin-top: 6px;
}

/* ---------- Office command center ---------- */

.pay-list,
.receipt-list,
.expense-list,
.budget-list,
.co-list,
.doc-list,
.assignment-list,
.change-list,
.stage-date-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.pay-list li,
.assignment-list li,
.change-list li,
.expense-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
  font-size: 0.84rem;
}

.pay-list li:first-child,
.assignment-list li:first-child,
.change-list li:first-child,
.expense-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.pay-list__title {
  font-weight: 700;
  color: var(--heading);
}

.pay-list__meta {
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 2px;
}

.pay-list__side,
.assignment-list__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  text-align: right;
}

.project-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.project-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.project-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-card__title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--heading);
}

.project-card__meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.project-card__figures {
  display: grid;
  gap: 5px;
  padding: 10px 0 2px;
  border-top: 1px solid var(--border);
}

.project-card__figures > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.project-card__figures span {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 800;
}

.project-card__figures strong {
  font-size: 0.82rem;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.project-card .btn {
  justify-self: start;
}

/* ---------- Project detail ---------- */

.detail-head {
  display: grid;
  gap: 14px;
}

.back-link {
  justify-self: start;
  padding-left: 0;
}

/* Arrow drawn with borders: the bundled display font has no arrow glyph. */
.back-link::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateX(1px);
}

.detail-head__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-head__value {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--border));
  background: linear-gradient(150deg, var(--surface), var(--surface-3));
  min-width: 190px;
}

.detail-head__label {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: var(--muted);
}

.detail-head__value strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.subnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.subnav button {
  flex: none;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.subnav button:hover {
  color: var(--blue-600);
  border-color: var(--blue-500);
}

.subnav button[aria-pressed="true"] {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: #ffffff;
  box-shadow: inset 0 -2px 0 var(--gold);
}

.schedule-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.76rem;
  color: var(--muted);
}

.schedule-summary strong {
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  margin-inline: -4px;
  padding-inline: 4px;
}

.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th,
.data-table td {
  padding: 10px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.data-table thead th {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 800;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-3) 60%, transparent);
}

.data-table tfoot th,
.data-table tfoot td {
  border-bottom: 0;
  border-top: 2px solid var(--border-strong);
  font-weight: 800;
  color: var(--heading);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table tr.is-overdue td {
  background: color-mix(in srgb, var(--danger-soft) 70%, transparent);
}

.cell-title {
  font-weight: 700;
  color: var(--heading);
}

.cell-meta {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.cell-meta__label {
  margin-right: 0.3rem;
  color: var(--ink);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* Long tokens — email addresses, references, invitation links — wrap instead
   of widening the layout viewport on a narrow phone. */
.feed__detail,
.feed__side,
.card__note,
.notice,
.empty,
.detail-list dd,
.data-table td {
  overflow-wrap: anywhere;
}

.row-actions {
  text-align: right;
  white-space: nowrap;
}

/* ---------- Status pills ---------- */

.pill--schedule,
.pill--scheduled,
.pill--upcoming,
.pill--waived,
.pill--reverted,
.pill--planned,
.pill--required {
  background: var(--surface-3);
  color: var(--muted);
}

.pill--due,
.pill--pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill--overdue,
.pill--rejected,
.pill--declined,
.pill--blocked {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill--partial {
  background: var(--info-soft);
  color: var(--info);
}

.pill--paid,
.pill--approved,
.pill--signed,
.pill--active,
.pill--complete,
.pill--signed_off,
.pill--ready,
.pill--accepted {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill--sent,
.pill--planning,
.pill--in_progress,
.pill--submitted {
  background: var(--info-soft);
  color: var(--info);
}

.pill--on_hold {
  background: var(--warn-soft);
  color: var(--warn);
}

/* ---------- Forms and drawers ---------- */

.drawer {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.drawer summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--blue-600);
  list-style-position: outside;
}

.drawer[open] summary {
  margin-bottom: 6px;
}

.drawer__note {
  margin: 8px 0 14px;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--label);
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  font-size: 0.86rem;
  font-weight: 400;
  color: var(--ink);
}

.form-grid textarea {
  resize: vertical;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px var(--ring);
}

.form-grid input[type="file"] {
  padding: 7px 8px;
  background: var(--surface);
}

.form-grid button[type="submit"] {
  justify-self: start;
}

.form-grid .form-hint,
.form-grid .form-error {
  margin: 0;
}

.form-grid__wide {
  grid-column: 1 / -1;
}

/* ---------- Schedule builder ---------- */

.sched-edit {
  display: grid;
  gap: 12px;
}

.sched-edit__row {
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px;
}

.sched-edit__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sched-edit__stage {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gold-ink);
}

.sched-edit__fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.sched-edit__fields label {
  display: grid;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--label);
}

.sched-edit__fields input,
.sched-edit__fields select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 400;
  color: var(--ink);
}

.sched-edit__fields input:disabled {
  background: var(--surface-3);
  color: var(--muted);
}

.sched-edit__preview {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sched-edit__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.sched-edit__totals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.76rem;
  color: var(--muted);
}

.sched-edit__totals strong {
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

/* ---------- Timelines ---------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.timeline__item:first-child {
  border-top: 0;
  padding-top: 0;
}

.timeline__item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 22px;
  bottom: -4px;
  width: 1px;
  background: var(--border-strong);
}

.timeline__item:last-child::before {
  display: none;
}

.timeline__dot {
  width: 11px;
  height: 11px;
  margin-top: 4px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
}

.timeline__item--complete .timeline__dot {
  border-color: var(--ok);
  background: var(--ok);
}

.timeline__item--in_progress .timeline__dot {
  border-color: var(--gold);
  background: var(--gold-bright);
}

.timeline__title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--heading);
}

.timeline__meta {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 2px;
}

.timeline__detail {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.timeline__amount {
  font-size: 0.78rem;
  color: var(--heading);
  white-space: nowrap;
}

.history-timeline .history-item--assign .timeline__dot {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.history-timeline .history-item--concern .timeline__dot {
  border-color: var(--gold);
  background: var(--gold-bright);
}

.history-timeline .history-item--handoff .timeline__dot {
  border-color: var(--heading);
  background: var(--heading);
}

.history-timeline .history-item--finish .timeline__dot {
  border-color: var(--ok);
  background: var(--ok);
}

.history-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.85rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.history-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.history-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  display: inline-block;
}

.history-dot--assign { background: var(--surface-3); }
.history-dot--concern { background: var(--gold-bright); border-color: var(--gold); }
.history-dot--handoff { background: var(--heading); border-color: var(--heading); }
.history-dot--finish { background: var(--ok); border-color: var(--ok); }

/* ---------- Details list ---------- */

.details {
  display: grid;
  gap: 8px;
  margin: 0;
}

.details > div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  font-size: 0.8rem;
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--border);
}

.details > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.details dt {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.details dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.details--compact {
  margin-top: 10px;
}

.details--compact > div {
  font-size: 0.76rem;
}

/* ---------- Change orders and documents ---------- */

.co-list,
.doc-list {
  gap: 12px;
}

.co-card,
.doc-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  background: var(--surface);
}

.co-card__top,
.doc-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.co-card__title,
.doc-card__title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--heading);
}

.co-card__amount {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.co-card__detail,
.doc-card__body {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Agreement review and demonstration signing ---------- */

.contract-paper,
.sign-panel {
  max-width: 900px;
  margin-inline: auto;
}

.contract-paper__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.contract-paper__title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--heading);
}

.contract-paper__parties {
  margin: 16px 0;
}

.contract-paper__body {
  padding: 18px 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink);
}

.contract-paper__body p {
  margin: 0 0 12px;
}

.contract-paper__body p:last-child {
  margin-bottom: 0;
}

.contract-paper__missing {
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.86rem;
}

.contract-paper__missing p {
  margin: 6px 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

.contract-paper__schedule {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.sign-panel {
  display: grid;
  gap: 14px;
}

.sign-panel .checkbox {
  align-items: flex-start;
  line-height: 1.5;
}

.sign-panel .checkbox input {
  flex: none;
  margin-top: 2px;
}

.sign-panel__notice {
  margin: 0;
}

.sign-name {
  display: grid;
  gap: 6px;
  max-width: 420px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--label);
}

.sign-name input {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

.sign-name input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px var(--ring);
}

.sign-panel .button-row {
  margin: 0;
}

@media (max-width: 640px) {
  .contract-paper__head {
    flex-direction: column;
  }
}

.co-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Costs / crew / photos ---------- */

.budget-list {
  gap: 12px;
}

.budget-list li {
  font-size: 0.8rem;
}

.budget-list__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}

.expense-list li {
  align-items: flex-start;
}

.crew-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.crew-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.crew-card__top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.crew-card__top > :last-child {
  margin-left: auto;
}

.crew-card__name {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--heading);
}

.crew-card__scope {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.avatar--soft {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--heading);
}

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

.photo {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}

.photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 800 / 560;
  object-fit: cover;
  background: var(--surface-3);
}

.photo figcaption {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  font-size: 0.76rem;
  color: var(--ink);
}

.photo figcaption .cell-meta {
  margin: 0;
}

/* ---------- Receipts ---------- */

.receipt-list {
  gap: 0;
}

.receipt {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

.receipt:first-child {
  border-top: 0;
  padding-top: 0;
}

.receipt__title {
  font-weight: 700;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.receipt__meta {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 2px;
}

.receipt__side {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.receipt--void {
  opacity: 0.62;
}

.receipt--void .receipt__title {
  text-decoration: line-through;
}

/* ---------- Customer invoices ---------- */

.invoice-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.invoice-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.invoice-card--overdue {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  box-shadow: inset 3px 0 0 var(--danger);
}

.invoice-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.invoice-card__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--heading);
}

.invoice-card__figures {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.74rem;
  color: var(--muted);
}

.invoice-card__figures strong {
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.invoice-card .btn {
  justify-self: start;
}

.next-payment {
  display: grid;
  gap: 10px;
}

.next-payment__stage {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--heading);
}

.next-payment__amount {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.next-payment__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.contract-block {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--label);
}

.inline-select select {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  font-size: 0.8rem;
}

.stage-date-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.stage-date-list li:first-child {
  border-top: 0;
}

.stage-date-list li > span:first-child {
  flex: 1;
  min-width: 0;
}

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

.person-row__identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.person-row__text {
  min-width: 0;
}

.badge--customer {
  background: var(--info-soft);
  color: var(--info);
}

.badge--subcontractor {
  background: var(--warn-soft);
  color: var(--warn);
}

.feed__side {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.feed--audit li {
  align-items: start;
}

/* ---------- Breakpoints ---------- */

@media (min-width: 560px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .sched-edit__title,
  .sched-edit__trigger {
    grid-column: 1 / -1;
  }

  .receipt {
    align-items: center;
  }
}

@media (min-width: 900px) {
  .sched-edit__fields {
    grid-template-columns: 1.6fr 0.9fr 0.7fr 1fr 1fr 0.8fr;
  }

  .sched-edit__title,
  .sched-edit__trigger {
    grid-column: auto;
  }

  .sched-edit__trigger {
    grid-column: span 2;
  }
}

/* Official identity on every printed document (receipt, invoice, estimate,
   statement, payment schedule). Hidden on screen; the logo is the owner's
   original artwork, never redrawn or recoloured. */
.print-brand {
  display: none;
}

@media print {
  .print-brand {
    display: block;
    border-bottom: 1px solid #cccccc;
    margin-bottom: 14px;
    padding-bottom: 10px;
  }

  .print-brand img {
    display: block;
    width: 260px;
    height: auto;
    aspect-ratio: 1730 / 551;
  }

  .print-brand p {
    margin: 6px 0 0;
    font-size: 9pt;
    color: #333333;
  }

  .topbar,
  .tabs,
  .subnav,
  .btn,
  .link-btn,
  .drawer,
  .filters,
  .back-link {
    display: none !important;
  }

  .app-body {
    padding: 0;
    max-width: none;
  }

  .card,
  .subcard {
    box-shadow: none;
    border-color: #cccccc;
    break-inside: avoid;
  }

  body {
    background: #ffffff;
    color: #000000;
  }
}

/* On phones a wide table becomes a stack of labelled rows. This also keeps the
   mobile layout viewport from being widened by a table's min-content width. */
@media (max-width: 719px) {
  .table-wrap {
    overflow: visible;
    margin-inline: 0;
    padding-inline: 0;
  }

  .data-table {
    display: block;
    min-width: 0;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody,
  .data-table tfoot {
    display: block;
  }

  .data-table tbody tr {
    display: grid;
    gap: 3px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }

  .data-table tbody tr:last-child {
    border-bottom: 0;
  }

  .data-table tbody tr.is-overdue {
    padding-left: 8px;
    border-left: 3px solid var(--danger);
    background: transparent;
  }

  .data-table tbody tr.is-overdue td {
    background: transparent;
  }

  .data-table tbody td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
    border: 0;
    padding: 1px 0;
    text-align: left;
    white-space: normal;
  }

  .data-table tbody td::before {
    content: attr(data-label);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .data-table tbody td > * {
    grid-column: 2;
  }

  .data-table tbody td > .pill,
  .data-table tbody td > .mini-tag,
  .data-table tbody td > .badge {
    justify-self: start;
  }

  .data-table tbody td:first-child {
    display: block;
    padding-bottom: 4px;
  }

  .data-table tbody td:first-child::before {
    display: none;
  }

  .data-table tbody td.row-actions {
    display: flex;
    justify-content: flex-end;
  }

  .data-table tbody td.row-actions::before {
    display: none;
  }

  .data-table tbody td.num {
    text-align: left;
    white-space: normal;
  }

  .data-table tfoot {
    display: none;
  }
}

/* ==========================================================================
   Phase 3 — customer and office operations
   CRM, leads, scheduling, estimates and work orders
   ========================================================================== */

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.filters--split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filters__group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ops-search {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ops-search input {
  min-width: min(260px, 100%);
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

.ops-search input:focus-visible {
  outline: 3px solid var(--ring);
  border-color: var(--blue-500);
}

.text-danger {
  color: var(--danger);
}

.badge--residential {
  background: var(--info-soft);
  color: var(--info);
}

.badge--commercial {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge--government {
  background: var(--ok-soft);
  color: var(--ok);
}

/* ----------------------------------------------------------------- calendar */

.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-toolbar__nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-toolbar__month {
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: var(--heading);
}

.cal-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.cal-nav::before {
  content: "";
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(1px, -1px);
}

.cal-nav--next::before {
  transform: rotate(225deg) translate(1px, -1px);
}

.calendar-card {
  padding: 0;
  overflow: hidden;
}

.calendar-head {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.calendar-head span {
  padding: 8px 4px;
  text-align: center;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-day {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 96px;
  padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day--outside {
  background: var(--surface-2);
  opacity: 0.55;
}

.calendar-day--selected {
  box-shadow: inset 0 0 0 2px var(--gold);
}

.calendar-day__num {
  align-self: flex-start;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--label);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.calendar-day__num:hover {
  border-color: var(--border-strong);
}

.calendar-day--today .calendar-day__num {
  background: var(--blue-600);
  color: #fff;
}

.calendar-day__events {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.calendar-event {
  display: block;
  min-width: 0;
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.64rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-event--milestone {
  background: var(--warn-soft);
  color: var(--warn);
}

.calendar-event--work_order {
  background: var(--ok-soft);
  color: var(--ok);
}

.calendar-event--cancelled {
  text-decoration: line-through;
  opacity: 0.65;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.week-day {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.week-day--selected {
  box-shadow: inset 0 0 0 2px var(--gold);
}

.week-day--today {
  border-color: var(--blue-500);
}

.week-day__head {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.week-day__events {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.week-event {
  padding: 3px 5px;
  border-radius: 6px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.66rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda,
.hours-list,
.checklist,
.simple-list,
.note-list,
.property-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agenda__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue-500);
  border-radius: 10px;
  background: var(--surface-2);
}

.agenda__item--milestone {
  border-left-color: var(--gold);
}

.agenda__item--work_order {
  border-left-color: var(--ok);
}

.agenda__time {
  min-width: 66px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.agenda__body {
  flex: 1;
  min-width: 0;
}

.hours-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.85rem;
}

.hours-list li:last-child {
  border-bottom: 0;
}

.hours {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px 16px;
}

.hours dt {
  font-weight: 700;
}

.simple-list li,
.note-list li,
.property-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

.checklist li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.checklist__item--done {
  border-color: transparent;
  background: var(--ok-soft);
}

/* ----------------------------------------------------------------- estimates */

.estimate-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.estimate-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 74px 68px 116px 92px auto;
  align-items: end;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.estimate-row label {
  font-size: 0.66rem;
}

.estimate-row__desc {
  min-width: 0;
}

.estimate-row__amount {
  align-self: center;
  text-align: right;
  font-weight: 800;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.estimate-total {
  display: inline-block;
  margin-left: 10px;
  font-size: 0.84rem;
  color: var(--muted);
}

.estimate-total strong {
  color: var(--heading);
  font-size: 1rem;
}

.proposal {
  margin: 0;
  padding: 14px;
  max-height: 430px;
  overflow: auto;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.74rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.completion-report {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--ok);
  border-radius: 10px;
  background: var(--surface-2);
}

.card--nested {
  background: var(--surface-2);
  box-shadow: none;
}

/* ----------------------------------------------------------- Zo preparation */

.zo-panel {
  padding: 0;
}

.zo-panel__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.zo-panel__summary::-webkit-details-marker {
  display: none;
}

.zo-workflows {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 16px;
}

@media (max-width: 899px) {
  .estimate-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  .estimate-row__desc,
  .estimate-row__amount {
    grid-column: 1 / -1;
  }

  .estimate-row__amount {
    text-align: left;
  }
}

@media (max-width: 719px) {
  .calendar-day {
    min-height: 74px;
    padding: 4px;
  }

  .calendar-head span {
    font-size: 0.56rem;
    letter-spacing: 0.04em;
  }

  .calendar-event {
    font-size: 0.58rem;
    padding: 1px 3px;
  }

  .agenda__time {
    min-width: 52px;
  }

  .ops-search,
  .ops-search input {
    width: 100%;
  }
}

@media (max-width: 519px) {
  .calendar-day {
    min-height: 62px;
  }

  .calendar-day__num {
    width: 22px;
    height: 22px;
    font-size: 0.72rem;
  }

  .calendar-event {
    display: block;
    font-size: 0;
    height: 6px;
    padding: 0;
    border-radius: 3px;
  }

  .stat {
    padding: 13px 14px;
  }

  /* Activity and audit entries: the time (and any amount) moves under the
     entry instead of squeezing the title into a narrow middle column. */
  .feed li {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .feed__side {
    display: flex;
    flex-wrap: wrap;
    grid-column: 2;
    align-items: baseline;
    justify-items: start;
    gap: 2px 10px;
  }
}

@media print {
  .calendar-grid,
  .estimate-rows,
  .ops-search,
  .filters--split {
    display: none;
  }
}

/* ------------------------------------------------ Team & Access Management */

.btn--ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0 1rem;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 10px;
  background: var(--surface);
  color: var(--navy-800);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn--ghost:hover {
  border-color: var(--blue-600);
  color: var(--blue-600);
}

.btn--ghost[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-btn--danger {
  color: #9d2235;
}

.access-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 1.15rem 0;
}

.access-toolbar .muted {
  flex: 1 1 260px;
}

.access-toolbar .btn[aria-pressed='true'] {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 65%, transparent);
}

.access-permission-note {
  margin: 0 0 1.1rem;
}

.access-permission-note strong {
  color: var(--navy-800);
}

.access-panel {
  margin: 1.15rem 0;
  border-top: 3px solid var(--gold);
}

.access-panel form {
  margin-top: 0.9rem;
}

.perm-groups {
  margin: 1.1rem 0;
  padding: 0;
  border: 0;
}

.perm-groups legend,
.project-picker legend {
  margin-bottom: 0.55rem;
  color: var(--navy-800);
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.perm-group {
  margin-bottom: 1.1rem;
}

.perm-group h3 {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 0.4rem;
}

.perm-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 88%, var(--navy-800) 3%);
  cursor: pointer;
}

.perm-option:hover {
  border-color: color-mix(in srgb, var(--blue-600) 45%, var(--border));
}

.perm-option input {
  margin-top: 0.2rem;
  accent-color: var(--navy-800);
}

.perm-option span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.83rem;
}

.perm-option strong {
  color: var(--navy-800);
  font-weight: 600;
}

.perm-option small {
  color: var(--muted);
  font-size: 0.69rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.project-picker {
  margin: 1rem 0;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.project-picker .perm-option {
  margin-bottom: 0.4rem;
}

.access-person {
  align-items: flex-start;
}

.access-person__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  min-width: 0;
}

.access-person__status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  min-width: 0;
  text-align: right;
}

/* The disclosure only exists at phone widths, where the action row moves into
   it; on tablet and desktop every action stays visible inline. */
.access-manage {
  display: none;
}

.access-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.2rem 0.75rem;
  margin-top: 0.2rem;
  min-width: 0;
}

.access-actions .link-btn {
  font-size: 0.76rem;
}

.access-check {
  align-self: end;
  min-height: 42px;
}

.invite-result {
  border-left: 4px solid var(--gold);
}

.invite-result__grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
  margin-top: 0.8rem;
}

.invite-link {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.invite-link input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--navy-800);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
}

.qr-card {
  margin: 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.qr-card img {
  display: block;
  width: 180px;
  height: 180px;
}

.qr-card figcaption {
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.invite-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}

.invite-card:first-of-type {
  border-top: 0;
}

.invite-card--quiet {
  opacity: 0.9;
}

.invite-card__title {
  color: var(--navy-800);
  font-weight: 600;
}

.invite-card__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  text-align: right;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.template-card {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, var(--navy-800) 4%);
}

.template-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.template-card h3 {
  margin: 0;
  color: var(--navy-800);
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 0.92rem;
}

.permission-matrix {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.permission-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.83rem;
}

.permission-line:last-child {
  border-bottom: 0;
}

.mfa-secret {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.7rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.mfa-secret code {
  color: var(--navy-800);
  font-size: 1rem;
  letter-spacing: 0.14em;
  word-break: break-all;
}

.mfa-uri {
  font-size: 0.68rem;
  word-break: break-all;
}

.mini-tag--gold {
  border-color: color-mix(in srgb, var(--gold) 50%, var(--border));
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold-ink);
}

.mini-tag--muted {
  color: var(--muted);
}

.notice {
  padding: 0.7rem 0.85rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
}

.notice--gold {
  border-color: color-mix(in srgb, var(--gold) 50%, var(--border));
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
  color: var(--gold-ink);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.detail-label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* --------------------------------------------------------- Enrollment page */

.enroll-body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(212, 162, 60, 0.16), transparent 60%),
    linear-gradient(145deg, var(--navy-900), var(--navy-800) 55%, var(--navy-700));
}

.enroll {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: clamp(1.2rem, 5vw, 3.5rem);
  display: grid;
  gap: 1.1rem;
}

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

.enroll__brand .brand-logo {
  width: min(360px, 72vw);
  height: auto;
}

.enroll__brand .auth-brand__values {
  color: var(--gold-bright);
  font-size: 0.7rem;
}

.enroll-card {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: clamp(1.1rem, 3.5vw, 2rem);
  border-radius: 18px;
  border-top: 4px solid var(--gold);
  background: var(--surface);
  box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.8);
}

.enroll-title {
  margin: 0.2rem 0 0.4rem;
  color: var(--navy-800);
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.enroll-sub {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.55;
}

.enroll-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.6rem;
  margin: 0 0 1.1rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.enroll-details dt {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.enroll-details dd {
  margin: 0.15rem 0 0;
  color: var(--navy-800);
  font-size: 0.85rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.enroll-card .field {
  margin-bottom: 0.8rem;
}

.enroll-card .form-error[hidden] {
  display: none;
}

.enroll-card .btn--block {
  margin-top: 0.7rem;
}

#mfa-form .auth-link {
  display: block;
  margin: 0.6rem auto 0;
}

@media (max-width: 719px) {
  .invite-result__grid {
    grid-template-columns: 1fr;
  }

  .invite-link {
    flex-wrap: wrap;
  }

  /* Phones: each person becomes a stacked card. The identity block gets the
     full width, the status sits under it, and the administrative actions move
     behind one Manage disclosure instead of squeezing the name column. */
  .person-row.access-person {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.65rem;
    padding: 16px 0;
  }

  .access-person .person-row__identity {
    align-items: flex-start;
    gap: 0.7rem;
  }

  .access-person .person-row__identity .avatar {
    width: 38px;
    height: 38px;
    font-size: 0.82rem;
  }

  .access-person .person-name,
  .access-person .person-email,
  .access-person .cell-meta {
    overflow-wrap: anywhere;
  }

  .access-person__side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem 0.65rem;
    width: 100%;
  }

  .access-person__status {
    align-items: flex-start;
    gap: 0.3rem;
    text-align: left;
  }

  .access-manage {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0 0.9rem;
    border: 1px solid var(--border-strong, var(--border));
    border-radius: 10px;
    background: var(--surface);
    color: var(--navy-800);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
  }

  /* Drawn with borders so no glyph or icon font is required. */
  .access-manage::after {
    content: "";
    width: 7px;
    height: 7px;
    margin-top: -3px;
    border-right: 2px solid var(--blue-600);
    border-bottom: 2px solid var(--blue-600);
    transform: rotate(45deg);
  }

  .access-manage[aria-expanded="true"] {
    border-color: var(--blue-600);
    color: var(--blue-600);
  }

  .access-manage[aria-expanded="true"]::after {
    margin-top: 3px;
    transform: rotate(225deg);
  }

  .access-actions {
    display: none;
    grid-column: 1 / -1;
    width: 100%;
    justify-content: flex-start;
    margin-top: 0;
    padding-top: 0.45rem;
    border-top: 1px dashed var(--border);
  }

  .access-actions.is-open {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 0.4rem;
  }

  .access-actions .link-btn {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    font-size: 0.8rem;
    text-align: left;
  }

  .access-actions .link-btn:hover {
    border-color: var(--blue-500);
  }

  .invite-card {
    flex-direction: column;
  }

  .invite-card__side {
    align-items: flex-start;
    text-align: left;
  }

  .perm-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Dark-scheme text contrast
   Dark mode turns the surfaces navy while these components keep the deep-blue
   ink they use on white. Only the words are lifted to the light text tokens
   already used elsewhere; backgrounds, borders, sizes and spacing are untouched
   and light mode is unaffected, because this block only applies when the
   operating system asks for a dark colour scheme.
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .link-btn,
  .auth-link,
  .drawer summary,
  .btn--ghost:hover,
  .tabs button:hover,
  .subnav button:hover,
  .filter:hover,
  .input__action:hover,
  #toggle-password[aria-pressed="true"] .eye--off,
  .access-manage[aria-expanded="true"],
  .mfa-secret code {
    color: var(--info);
  }

  /* Destructive links keep their red meaning, in the dark-scheme red. */
  .link-btn--danger {
    color: var(--danger);
  }

  .btn--ghost,
  .access-manage,
  .access-permission-note strong,
  .perm-groups legend,
  .project-picker legend,
  .perm-option strong,
  .invite-card__title,
  .template-card h3,
  .enroll-title,
  .enroll-details dd,
  .invite-link input {
    color: var(--heading);
  }

  /* The disclosure chevron is drawn with borders; without this it disappears
     into the surface along with the label it belongs to. */
  .access-manage::after {
    border-right-color: currentColor;
    border-bottom-color: currentColor;
  }
}

/* ==========================================================================
   Phase 4A — master project workstreams
   Additive components built from the existing tokens; no brand change.
   ========================================================================== */

.workstream-stack {
  display: grid;
  gap: 12px;
}

.workstream {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
}

.workstream[open] {
  background: var(--surface);
}

.workstream__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--gold);
  cursor: pointer;
  list-style: none;
}

.workstream__head::-webkit-details-marker {
  display: none;
}

.workstream__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.workstream__heading strong {
  font-size: 0.92rem;
  color: var(--heading);
  overflow-wrap: anywhere;
}

.workstream__meta {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.workstream__progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.workstream__progress progress {
  width: 100%;
  min-width: 80px;
}

.workstream__progress .cell-meta,
.work-item__progress .cell-meta {
  flex: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.workstream__body {
  display: grid;
  gap: 12px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
}

.workstream__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.service-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.workstream-overview {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.workstream-overview progress {
  width: 100%;
}

.work-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.work-item {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.work-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.work-item__head::-webkit-details-marker {
  display: none;
}

.work-item__title {
  min-width: 0;
  flex: 1 1 220px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--heading);
  overflow-wrap: anywhere;
}

.work-item__meta {
  flex: 1 1 100%;
  font-size: 0.73rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.work-item__progress {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 96px;
}

.work-item__progress progress {
  width: 72px;
}

.work-item__body {
  display: grid;
  gap: 12px;
  padding: 0 12px 12px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

.dependency-list,
.document-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dependency-list li,
.document-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}

.dependency-list li:last-child,
.document-list li:last-child {
  border-bottom: 0;
}

.dependency-list__label,
.document-list__label {
  min-width: 0;
  flex: 1 1 200px;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.workstream-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.workstream-actions .btn,
.workstream-actions .link-btn {
  flex: none;
}

.workstream-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.workstream-inline-form label {
  flex: 1 1 150px;
  min-width: 0;
}

.workstream-inline-form .btn {
  flex: none;
}

.workstream-note {
  font-size: 0.76rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.workstream-picker {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.workstream-picker legend {
  padding: 0 6px;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--heading);
}

.workstream-picker__hint {
  margin: 0;
  font-size: 0.73rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .workstream__head {
    grid-template-columns: minmax(0, 1fr);
  }

  .workstream__progress {
    min-width: 0;
  }

  .work-item__title {
    flex-basis: 100%;
  }

  .work-item__progress {
    min-width: 0;
    flex: 1 1 100%;
  }

  .work-item__progress progress {
    width: 100%;
  }

  .workstream-inline-form label,
  .workstream-inline-form .btn {
    flex: 1 1 100%;
  }
}

/* ---------- Phase 4B office tasks ---------- */

/* Blocked and on-hold work is amber, never a blame-red. Overdue stays red. */
.pill--waiting {
  background: var(--warn-soft);
  color: var(--warn);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 34%, transparent);
}

.pill--waiting::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.task-list {
  display: grid;
  gap: 14px;
}

.task-focus {
  max-width: 980px;
  margin: 0 auto;
}

.task-card--focus {
  padding: 24px;
  border-left-width: 5px;
}

.task-card--focus .task-card__head {
  gap: 24px;
}

.task-focus__title {
  margin: 4px 0 5px;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.task-card--focus .task-detail {
  margin-top: 20px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(12, 30, 55, 0.05));
}

.task-card--waiting {
  border-left-color: var(--warn);
  background: linear-gradient(90deg, color-mix(in srgb, var(--warn-soft) 55%, transparent), transparent 45%),
    var(--surface);
}

.task-card--overdue {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 24%, transparent);
}

.task-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.task-card__title h2 {
  margin: 2px 0 2px;
  font-size: 1.02rem;
  line-height: 1.3;
}

.task-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.task-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 18px;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.task-meta div {
  min-width: 0;
}

.task-meta dt {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.task-meta dd {
  margin: 3px 0 0;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.task-blocker-summary {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--warn) 34%, transparent);
  background: color-mix(in srgb, var(--warn-soft) 70%, var(--surface));
}

.task-blocker-summary strong {
  display: block;
  font-size: 0.82rem;
}

.task-blocker-summary p {
  margin: 4px 0 2px;
  font-size: 0.85rem;
}

.task-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.task-detail__links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.task-detail {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-strong);
}

.task-detail__detail {
  margin: 0 0 12px;
  color: var(--text-soft, var(--muted));
  font-size: 0.9rem;
}

.task-detail__section {
  margin-top: 16px;
}

.task-detail__section h3 {
  margin: 0 0 8px;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.task-detail__section h4 {
  margin: 0 0 6px;
  font-size: 0.8rem;
}

.task-detail__split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.blocker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.blocker {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

.blocker--open {
  border-color: color-mix(in srgb, var(--warn) 34%, transparent);
}

.blocker__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.blocker p {
  margin: 8px 0;
  font-size: 0.88rem;
}

.blocker__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 6px 16px;
  margin: 0;
}

.blocker__meta dt {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.blocker__meta dd {
  margin: 2px 0 0;
  font-size: 0.8rem;
}

.task-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.task-inline-form h4 {
  flex: 1 1 100%;
}

.task-inline-form label {
  flex: 1 1 190px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
}

.task-inline-form input,
.task-inline-form select {
  width: 100%;
  margin-top: 4px;
}

.task-subdrawer {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
  background: var(--surface-2);
}

.task-subdrawer summary {
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

.task-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.task-history li {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.task-history__action {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.task-history__detail {
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.task-attention {
  border-color: color-mix(in srgb, var(--warn) 38%, transparent);
}

.attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.attention-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface));
}

.attention-kind {
  display: inline-block;
  margin-bottom: 2px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--warn);
}

.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.suggestion {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

.suggestion__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.suggestion__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.task-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0 6px;
}

.filter-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--muted);
}

.filter-select select {
  font-size: 0.8rem;
  padding: 6px 8px;
}

.form-grid--compact {
  gap: 10px 14px;
}

.priority--urgent::before {
  background: var(--danger);
}

.calendar-event--task {
  border-left: 3px solid var(--warn);
  background: color-mix(in srgb, var(--warn-soft) 70%, var(--surface));
}

.agenda__item--task .agenda__time {
  color: var(--warn);
}

/* Prepared communications: the account-manager queue and project histories. */

.comms-providers,
.comms-queue__list,
.comms-projects ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.comms-provider {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.comms-provider strong {
  display: block;
  font-size: 0.82rem;
  color: var(--heading);
}

.comms-queue,
.comms-projects {
  margin-top: 14px;
}

.comms-queue h3,
.comms-projects h3 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  color: var(--heading);
}

.comms-message {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 9px;
  background: color-mix(in srgb, var(--warn-soft) 35%, var(--surface));
}

.comms-message__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.comms-message p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.comms-file {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.comms-file label {
  display: grid;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--muted);
}

.comms-projects li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.comms-projects li:last-child {
  border-bottom: 0;
}

@media (max-width: 640px) {
  .comms-message__head,
  .comms-projects li {
    flex-direction: column;
    gap: 4px;
  }

  .comms-file label {
    width: 100%;
  }

  .comms-file select {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .task-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .task-card {
    padding: 14px;
  }

  .task-card--focus {
    padding: 16px;
  }

  .task-focus__title {
    font-size: 1.3rem;
  }

  .task-card__head {
    flex-direction: column;
    gap: 8px;
  }

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

  .task-meta {
    grid-template-columns: 1fr;
  }

  .suggestion,
  .attention-item {
    flex-direction: column;
  }

  .suggestion__actions {
    align-items: flex-start;
    flex-direction: row;
  }

  .task-inline-form label {
    flex: 1 1 100%;
  }

  .task-inline-form .btn {
    flex: 1 1 100%;
  }
}

.task-hold-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
}

.task-hold-note strong {
  display: block;
  font-size: 0.8rem;
}

.task-hold-note p {
  margin: 4px 0 0;
  font-size: 0.85rem;
}

/* ==========================================================================
   Phase 4C — field operations
   Office board and crew portal share these pieces. The crew layout is built
   mobile-first: one column on a phone, two on a tablet and up.
   ========================================================================== */

.field-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.field-section__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--heading);
}

.field-muted {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-clear {
  border-left: 3px solid var(--ok);
}

.field-jobs {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-job {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.field-job__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.field-job__number {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--label);
}

.field-job__title {
  margin: 2px 0 4px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--heading);
}

.field-job__chips,
.field-job__meta .crew-row,
.status-actions,
.draft__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.field-job__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin: 14px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.field-flag {
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.82rem;
  font-weight: 600;
}

.field-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--label);
  white-space: nowrap;
}

.field-chip--field-idle { background: var(--surface-3); color: var(--muted); }
.field-chip--field-travel { background: var(--info-soft); color: var(--info); border-color: transparent; }
.field-chip--field-onsite { background: #f0ecff; color: #4b3a9a; border-color: transparent; }
.field-chip--field-working { background: var(--info-soft); color: var(--info); border-color: transparent; }
.field-chip--field-paused { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.field-chip--field-done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

@media (prefers-color-scheme: dark) {
  .field-chip--field-onsite { background: #241f45; color: #c3b6ff; }
}

.crew-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crew-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--label);
}

.crew-chip::first-letter { text-transform: uppercase; }

.crew-chip > span:first-child,
.crew-chip {
  font-weight: 600;
}

.crew-chip--lead {
  border-color: var(--gold);
  background: #fdf6e6;
  color: var(--gold-ink);
}

@media (prefers-color-scheme: dark) {
  .crew-chip--lead { background: #32281a; }
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-row .progress {
  flex: 1;
}

.field-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.field-panel > summary,
.field-inline-form > summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 650;
  font-size: 0.86rem;
  color: var(--label);
}

.field-panel > summary:focus-visible,
.field-inline-form > summary:focus-visible,
.field-job--crew > summary:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.field-panel[open] > summary {
  border-bottom: 1px solid var(--border);
}

.field-panel .form-grid,
.field-panel .material-list,
.field-panel .inspection {
  padding: 14px;
}

.crew-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.crew-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.85rem;
  cursor: pointer;
}

.crew-pick small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.crew-pick input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue-600);
}

.material-list,
.doc-list,
.punch-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.material {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.material p,
.doc p,
.punch p {
  margin: 0;
}

.material__form,
.inline-form,
.doc-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.material__form select,
.material__form input,
.inline-form select,
.inline-form input,
.doc-upload input {
  font-size: 0.82rem;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

.inline-form input {
  flex: 1 1 160px;
  min-width: 0;
}

.inspection {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inspection--accepted {
  border-color: var(--ok);
}

.inspection--correction_required {
  border-left: 3px solid var(--warn);
}

.inspection__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.inspection__notes {
  margin: 0;
  font-size: 0.88rem;
  color: var(--label);
}

.punch {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border-left: 3px solid var(--border-strong);
  font-size: 0.84rem;
}

.punch--open { border-left-color: var(--warn); }
.punch--corrected { border-left-color: var(--info); }
.punch--verified { border-left-color: var(--ok); opacity: 0.85; }

.draft-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.draft {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface-2);
}

.draft__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.draft__title {
  margin: 0;
  font-weight: 700;
  color: var(--heading);
}

.draft__body {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  font-size: 0.88rem;
  line-height: 1.5;
}

.draft__actions .field-muted {
  flex-basis: 100%;
}

.availability {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.availability__person {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-2);
}

.availability__name {
  margin: 0 0 4px;
  font-weight: 700;
  color: var(--heading);
}

.availability__slots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.availability__slots span {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 0.74rem;
  font-weight: 600;
}

/* --------------------------------------------------------------- crew portal */

.field-callout {
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.field-callout--warn {
  border-color: var(--gold);
  background: var(--warn-soft);
  color: var(--warn);
}

.field-callout ul {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 0.85rem;
}

.field-job--crew {
  padding: 0;
  overflow: hidden;
}

.field-job__summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.field-job__summary::-webkit-details-marker {
  display: none;
}

.field-job__summary-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field-job__summary .field-job__title {
  font-size: 1rem;
}

.field-job__body {
  border-top: 1px solid var(--border);
  padding: 14px 16px 18px;
}

.crew-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

@media (min-width: 900px) {
  .crew-layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr);
    align-items: start;
  }
}

.crew-main,
.crew-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.field-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
}

.field-block h4 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: var(--heading);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.field-block p {
  margin: 0 0 6px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.field-instructions {
  white-space: pre-wrap;
}

.field-next {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.88rem;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.check input {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  accent-color: var(--blue-600);
  flex: 0 0 auto;
}

.checklist li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.doc {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.86rem;
}

.doc__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.doc-upload input {
  max-width: 100%;
}

.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.photo {
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

.photo img {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
}

.photo figcaption {
  padding: 6px 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.form-grid--tight {
  gap: 10px;
}

.status-actions .btn {
  flex: 1 1 auto;
}

.field-inline-form {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.field-inline-form .form-grid {
  padding: 0 12px 12px;
}

.field-block--timeline summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 0.86rem;
}

.field-block .timeline {
  margin-top: 10px;
  font-size: 0.82rem;
}

.field-block .timeline li {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

.field-block .timeline li:last-child {
  border-bottom: 0;
}

.stat-grid--field .stat__value {
  font-size: 1.6rem;
}

@media (max-width: 640px) {
  .field-job {
    padding: 12px;
  }

  .field-job__summary,
  .field-job__body {
    padding: 12px;
  }

  .field-job__summary {
    flex-direction: column;
  }

  .field-job__summary .field-chip {
    align-self: flex-start;
  }

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

  .status-actions .btn,
  .material__form .btn,
  .inline-form .btn,
  .field-inline-form .btn,
  .doc-upload .btn {
    flex: 1 1 100%;
    min-height: 44px;
  }

  .check {
    padding: 6px 0;
  }

  .check input {
    width: 24px;
    height: 24px;
  }

  .field-actions .btn,
  .field-panel .btn {
    min-height: 44px;
  }
}

/* ------------------------------------------------------- Phase 4D finance */
/* The ledger rows, aging cards and closeout checklist share one visual
   language: money on the right, state beside it, actions underneath. */

.fin-list {
  display: grid;
  gap: 10px;
}

.fin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, auto) auto;
  grid-template-areas:
    'main money status'
    'main actions actions';
  gap: 8px 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.fin-row--late {
  border-left: 4px solid var(--danger, #b42318);
}

/* The invoice addressed by the URL: the trail names it, and the ledger row
   shows which one was opened from the receivables worklist. */
.fin-row.is-focus {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold), 0 12px 28px -24px rgba(6, 42, 85, 0.8);
}

.fin-row__main {
  grid-area: main;
  min-width: 0;
}

.fin-row__money {
  grid-area: money;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  text-align: right;
}

.fin-row__money strong {
  font-size: 1.05rem;
}

.fin-row__status {
  grid-area: status;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.fin-row__actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.fin-owner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.fin-owner select {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 0.82rem;
}

.row-drawer {
  flex: 1 1 240px;
}

.row-drawer > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--accent, #1f5f8b);
}

.row-drawer[open] {
  flex-basis: 100%;
}

.aging-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.aging-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.aging-card--late {
  border-color: color-mix(in srgb, var(--danger, #b42318) 35%, var(--line));
}

.aging-card__label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.aging-card strong {
  font-size: 1.05rem;
}

.money-bars {
  display: grid;
  gap: 14px;
}

.money-bar {
  display: grid;
  gap: 4px;
}

.money-bar__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
}

.approval-list,
.closeout-list,
.closeout-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.approval,
.closeout-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.approval:last-child,
.closeout-list li:last-child {
  border-bottom: 0;
}

.approval__actions,
.closeout-list__side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.approval__actions input {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.82rem;
  width: 180px;
}

.gov-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.gov-card__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.gov-card__side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.requirement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.requirement-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.requirement-list li span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
}

.requirement-list .is-met span {
  background: color-mix(in srgb, var(--ok, #1a7f37) 18%, transparent);
  color: var(--ok, #1a7f37);
}

.requirement-list .is-missing span {
  background: color-mix(in srgb, var(--danger, #b42318) 16%, transparent);
  color: var(--danger, #b42318);
}

.closeout-checklist {
  display: grid;
  gap: 18px;
  margin: 14px 0;
}

.closeout-group__title {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.closeout-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.closeout-item:last-child {
  border-bottom: 0;
}

.closeout-item__mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.closeout-item.is-done .closeout-item__mark {
  background: color-mix(in srgb, var(--ok, #1a7f37) 16%, transparent);
  border-color: transparent;
  color: var(--ok, #1a7f37);
}

.closeout-item.is-waived .closeout-item__mark {
  background: color-mix(in srgb, var(--warn, #9a6700) 16%, transparent);
  border-color: transparent;
  color: var(--warn, #9a6700);
}

.closeout-item__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calendar-event--finance {
  border-left-color: var(--accent, #1f5f8b);
}

@media (max-width: 720px) {
  .fin-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'main status'
      'money money'
      'actions actions';
  }

  .fin-row__money {
    align-items: flex-start;
    text-align: left;
  }

  .closeout-item {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .closeout-item__actions {
    grid-column: 2;
    flex-wrap: wrap;
  }

  .approval__actions input {
    width: 100%;
  }
}

/* Eight financial figures need room to stay readable. */
.stat-grid--finance {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
}

@media (max-width: 640px) {
  .stat-grid--finance {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Lead profile: sections, services and approvals (Phase 4H) ---------- */

.lead-editor {
  gap: 16px;
}

.lead-editor .form-section {
  margin: 0;
  min-width: 0;
  border: 0;
  padding: 16px 18px 18px;
}

.lead-editor .form-section > legend {
  display: block;
  width: 100%;
  padding: 0 0 12px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--heading);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.lead-editor .form-hint {
  margin: 0 0 10px;
}

.service-search {
  display: block;
  width: 100%;
  max-width: 340px;
  margin-bottom: 0.6rem;
}

/* Filtering hides options, so the multi-select keeps a stable height instead of
   collapsing to the few rows that are left. */
.service-search + select[multiple] {
  min-height: 9rem;
}

.lead-services {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.lead-service {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.lead-service__remove {
  justify-self: start;
  color: var(--danger);
}

@media (min-width: 760px) {
  .lead-service {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) auto;
    align-items: end;
  }
  .lead-service label {
    margin: 0;
  }
}

/* Budget and assignment controls that a manager will decide. */
.lead-editor .needs-approval > span.mini-tag {
  margin-left: 6px;
}

.lead-editor .needs-approval select,
.lead-editor .needs-approval input {
  border-color: color-mix(in srgb, var(--gold) 55%, var(--border-strong));
}

.form-success {
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--blue-600) 35%, var(--border));
  background: var(--surface-3);
  color: var(--body);
  font-size: 0.85rem;
}

.lead-pending {
  border-left: 4px solid var(--gold);
}

.lead-pending .form-actions {
  margin-top: 12px;
}

.lead-approvals__row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.lead-approvals__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lead-services__list li {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.lead-services__list li:last-child {
  border-bottom: 0;
}

.lead-history .feed__detail {
  font-size: 0.82rem;
  line-height: 1.45;
}

/* --------------------------------------------------------------- tickets */
/* Tickets and field issue reports. Urgent and emergency records carry a gold
   and red edge so they stand out in the queue without changing the palette. */

.ticket-notice {
  background: linear-gradient(180deg, var(--info-soft), var(--surface));
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 18px;
}

.ticket-notice p {
  margin: 0 0 4px;
}

.ticket-notice__note {
  color: var(--muted);
  font-size: 0.82rem;
}

.ticket-urgent {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  margin-bottom: 18px;
}

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

.ticket-urgent__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--heading);
}

.ticket-urgent__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.ticket-urgent__card {
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
}

.ticket-urgent__card--emergency {
  border-top-color: var(--danger);
  background: var(--danger-soft);
}

.ticket-urgent__number {
  margin: 0;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.ticket-urgent__title {
  margin: 4px 0 6px;
  font-weight: 650;
  color: var(--heading);
}

.ticket-urgent__meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.ticket-urgent__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ticket-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.ticket-card--urgent {
  border-left-color: var(--gold);
}

.ticket-card--emergency {
  border-left-color: var(--danger);
  background: linear-gradient(180deg, var(--danger-soft), var(--surface) 60%);
}

.ticket-card--settled {
  opacity: 0.86;
}

.ticket-card__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.ticket-card__number {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ticket-card__title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--heading);
}

.ticket-card__badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.ticket-card__description {
  margin: 10px 0;
  color: var(--ink);
  line-height: 1.5;
}

.ticket-card__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 16px;
  margin: 0 0 12px;
}

.ticket-card__meta div {
  display: grid;
  gap: 1px;
}

.ticket-card__meta dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.ticket-card__meta dd {
  margin: 0;
  font-size: 0.86rem;
  color: var(--label);
}

.ticket-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.ticket-card__counts {
  color: var(--muted);
  font-size: 0.8rem;
}

.ticket-priority {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  background: var(--surface-2);
}

.ticket-priority--urgent {
  color: var(--gold-ink);
  border-color: var(--gold);
  background: var(--warn-soft);
}

.ticket-priority--emergency {
  color: #fff;
  border-color: var(--danger);
  background: var(--danger);
}

.ticket-alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 16px;
  border: 1px solid var(--border-strong);
  background: var(--warn-soft);
  color: var(--warn);
}

.ticket-alert--emergency {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.ticket-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 18px;
  align-items: start;
}

.ticket-main,
.ticket-side {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.ticket-description {
  white-space: pre-wrap;
  line-height: 1.6;
}

.ticket-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 18px;
  margin: 14px 0 0;
}

.ticket-facts dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.ticket-facts dd {
  margin: 2px 0 0;
  font-size: 0.9rem;
  color: var(--label);
  overflow-wrap: anywhere;
}

.ticket-timeline {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.ticket-timeline__item {
  border-left: 3px solid var(--border-strong);
  padding: 6px 0 6px 12px;
}

.ticket-timeline__item--comment {
  border-left-color: var(--blue-500);
}

.ticket-timeline__head {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.ticket-timeline__item p {
  margin: 4px 0 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

.ticket-comment-form {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.ticket-links li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.ticket-photos {
  margin-top: 14px;
}

.ticket-photos figcaption small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.ticket-field-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.ticket-field-card__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.ticket-form .form-hint {
  margin: 0;
}

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

@media (max-width: 640px) {
  .ticket-card__head,
  .ticket-field-card__head {
    flex-direction: column;
  }

  .ticket-card__foot {
    align-items: stretch;
  }

  .ticket-facts {
    grid-template-columns: 1fr;
  }

  .ticket-urgent__grid {
    grid-template-columns: 1fr;
  }
}

/* A checkbox inside a form-grid label must stay a checkbox: the generic
   `.form-grid input` width rule would otherwise stretch it across the row. */
.form-grid .checkbox {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  font-size: 0.85rem;
  font-weight: 500;
}

.form-grid .checkbox input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  accent-color: var(--blue-600);
}

/* Phase 5B reminders: the alert tray, the per-task schedule and the tab badge.
   The tray is a plain card, so it inherits the desk's surface and spacing. */
.reminder-tray .card__head {
  flex-wrap: wrap;
  gap: 10px;
}

.reminder-group {
  margin: 16px 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.reminder-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reminder {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  border-radius: 9px;
  background: var(--surface);
}

.reminder--due {
  border-color: color-mix(in srgb, var(--warn) 34%, transparent);
  background: color-mix(in srgb, var(--warn-soft) 70%, var(--surface));
}

.reminder__body {
  flex: 1 1 260px;
  min-width: 0;
}

.reminder__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.reminder__note {
  margin: 4px 0 2px;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.reminder__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.reminder-list--compact .reminder {
  padding: 8px 10px;
}

.reminder-tray__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

/* A due reminder is visible from every other tab, not only the task desk. */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--warn);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

@media (max-width: 640px) {
  .reminder__actions {
    width: 100%;
  }
}

/* ------------------------------------------------------- Phase 5C: emergency maintenance */

.emg-mine {
  border: 1px solid var(--line, #d8dbe2);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
  background: rgba(201, 149, 43, 0.08);
}
.emg-mine__list { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; margin-top: 0.35rem; }

.emg-card {
  border: 1px solid var(--line, #d8dbe2);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 1rem 1.1rem;
  background: #fff;
}
.emg-card + .emg-card { margin-top: 0.9rem; }
.emg-card--emergency { border-left-color: #b91c1c; }
.emg-card--urgent { border-left-color: #ea580c; }
.emg-card--normal { border-left-color: #475569; }
.emg-card--settled { opacity: 0.72; }
.emg-card__head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: flex-start; justify-content: space-between; }
.emg-card__title h2 { margin: 0.15rem 0 0; font-size: 1.05rem; }
.emg-card__number { margin: 0; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: #64748b; }
.emg-card__pills, .emg-card__foot { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; }
.emg-card__meta { margin: 0.5rem 0 0; color: #475569; font-size: 0.9rem; }
.emg-card__foot { margin-top: 0.6rem; }
.emg-card__assignee { color: #475569; font-size: 0.85rem; }
.emg-card__links { margin: 0.5rem 0 0; font-size: 0.85rem; color: #475569; }

.emg-pill { border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.emg-pill--emergency { background: #7f1d1d; color: #fee2e2; }

/* Five-level priority. Colour carries urgency only; it never implies a grant. */
.emg-priority {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.emg-priority--critical { background: #450a0a; color: #fecaca; }
.emg-priority--emergency { background: #7f1d1d; color: #fee2e2; }
.emg-priority--urgent { background: #9a3412; color: #ffedd5; }
.emg-priority--high { background: #a16207; color: #fef9c3; }
.emg-priority--normal { background: #1e3a8a; color: #dbeafe; }

.emg-stage {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.emg-stage--blocked { border-color: #b91c1c; background: #fef2f2; color: #991b1b; }
.emg-stage--closed { border-color: #94a3b8; background: #f1f5f9; color: #475569; }
.emg-stage--cancelled { border-color: #cbd5e1; background: #f8fafc; color: #64748b; }

.emg-card--critical { border-left-color: #450a0a; }
.emg-card[data-blocked="true"] { border-left-color: #b91c1c; background: #fff7f7; }

@media (max-width: 640px) {
  .emg-priority,
  .emg-stage { font-size: 10px; padding: 2px 7px; }
}
.emg-pill--urgent { background: #9a3412; color: #ffedd5; }
.emg-pill--normal { background: #334155; color: #e2e8f0; }

.emg-status { border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.7rem; font-weight: 600; background: #e2e8f0; color: #1e293b; }
.emg-status--awaiting_approval { background: #fef3c7; color: #92400e; }
.emg-status--dispatched, .emg-status--acknowledged, .emg-status--en_route { background: #dbeafe; color: #1e40af; }
.emg-status--on_site, .emg-status--in_progress { background: #dcfce7; color: #166534; }
.emg-status--resolved, .emg-status--closed { background: #e5e7eb; color: #374151; }
.emg-status--cancelled { background: #fee2e2; color: #991b1b; }

.emg-badge { font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 6px; background: #eef2f7; color: #334155; }
.emg-badge--ok { background: #dcfce7; color: #166534; }
.emg-badge--wait { background: #fef3c7; color: #92400e; }
.emg-badge--bad { background: #fee2e2; color: #991b1b; }
.emg-flag { font-size: 0.78rem; color: #475569; }
.emg-flag--bad { color: #b91c1c; font-weight: 600; }

.emg-safety { margin: 0.5rem 0 0; padding: 0.5rem 0.7rem; border-radius: 8px; background: #fef2f2; color: #7f1d1d; font-size: 0.88rem; }
.emg-safety-block { border: 1px solid #fecaca; background: #fef2f2; border-radius: 12px; padding: 1rem 1.1rem; margin: 1rem 0; }
.emg-safety-block h2 { margin: 0 0 0.35rem; font-size: 1rem; }
.emg-escalated { border-left: 4px solid #b45309; background: #fffbeb; border-radius: 8px; padding: 0.7rem 0.9rem; margin: 1rem 0; }
.emg-note { color: #64748b; font-size: 0.82rem; margin: 0.35rem 0 0; }
.emg-body { margin: 0.6rem 0 0; white-space: pre-wrap; }
.emg-links { margin: 0.5rem 0 0; font-size: 0.88rem; color: #475569; }
.emg-wait { margin: 0.5rem 0 0; color: #92400e; font-size: 0.88rem; }

.emg-detail__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin: 1rem 0; }
.emg-panel { border: 1px solid var(--line, #d8dbe2); border-radius: 12px; padding: 1rem 1.1rem; background: #fff; min-width: 0; }
.emg-panel h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.emg-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.4rem 0.9rem; margin: 0 0 0.6rem; }
.emg-facts dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; }
.emg-facts dd { margin: 0.1rem 0 0; }
.emg-approvals, .emg-assignments, .emg-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.emg-approvals li, .emg-assignments li, .emg-timeline li { border-bottom: 1px dashed #e2e8f0; padding-bottom: 0.6rem; }
.emg-approvals li:last-child, .emg-assignments li:last-child, .emg-timeline li:last-child { border-bottom: 0; padding-bottom: 0; }
.emg-approval-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.emg-timeline__head { margin: 0; font-size: 0.9rem; }
.emg-attachments { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.7rem; }
.emg-attachments img { width: 100%; height: auto; border-radius: 8px; display: block; }
.emg-attachments figcaption { font-size: 0.78rem; color: #64748b; margin-top: 0.25rem; }
.emg-form textarea, .emg-panel textarea { width: 100%; }
.emg-detail__head { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: space-between; }

@media (max-width: 640px) {
  .emg-detail__grid { grid-template-columns: 1fr; }
  .emg-card__head { flex-direction: column; }
  .emg-facts { grid-template-columns: 1fr; }
}

/* Stage 1 Communications Center: conversations, drafts and templates. */
.comms-gate {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-left: 4px solid #8a5a00;
  background: #fff8e6;
  color: #3d2c08;
  border-radius: 4px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.comms-gate strong {
  color: #2b1e00;
}

.comms-head__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

.comms-head__summary strong {
  color: var(--heading);
}

.comms-filter {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.comms-filter .comms-filter__check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  font-weight: 600;
}

.comms-filter .comms-filter__check input {
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--blue-600);
}

form.comms-filter .comms-filter__apply {
  grid-column: 2;
  justify-self: end;
}

.comms-create {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.comms-create__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 2px;
}

.comms-create__actions .form-hint {
  flex: 1 1 220px;
  margin: 0;
}

.comms-thread__actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  align-items: flex-start;
}

.comms-linked-record {
  white-space: nowrap;
}

.comms-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.comms-thread__messages li {
  border-left: 2px solid #dbe6f3;
  padding: 4px 0 4px 12px;
}

.comms-message__head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.comms-drafts {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.comms-draft {
  border: 1px solid #dbe6f3;
  border-radius: 6px;
  padding: 12px;
  background: #f8fbff;
}

.comms-draft__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.comms-draft__body {
  white-space: pre-wrap;
  margin: 8px 0;
  font-size: 0.94rem;
}

.comms-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  background: #e8eef7;
  color: #0a2b4a;
}

.comms-pill--open { background: #e3f5ea; color: #1d6b3f; }
.comms-pill--waiting { background: #fdf1d6; color: #7a5a10; }
.comms-pill--closed { background: #eceff4; color: #4a5568; }
.comms-pill--draft { background: #fdf1d6; color: #7a5a10; }
.comms-pill--approved { background: #e3f5ea; color: #1d6b3f; }

.comms-members {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.comms-events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.comms-events li {
  display: grid;
  gap: 2px;
  border-left: 2px solid #dbe6f3;
  padding-left: 10px;
}

.comms-events__action {
  font-weight: 600;
  text-transform: capitalize;
}

.comms-events__detail {
  font-size: 0.92rem;
  color: #33455c;
}

.inline-form {
  display: inline;
}

@media (max-width: 720px) {
  .comms-grid {
    grid-template-columns: 1fr;
  }
  .comms-draft__head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Three-step email composer, review and send. */
.comms-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 12px 0 16px;
  padding: 0;
}

.comms-steps li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid #cfdbea;
  border-radius: 999px;
  color: #5b6c82;
  background: #f8fbff;
  font-size: 0.82rem;
  font-weight: 600;
}

.comms-steps li[aria-current="step"] {
  border-color: #1f5f99;
  background: #e8f2fb;
  color: #0a2b4a;
}

.comms-steps li.is-done {
  border-color: #b9ddc8;
  background: #edf8f1;
  color: #1d6b3f;
}

.comms-steps__number {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #e3ebf4;
  color: #33475c;
  font-size: 0.76rem;
  font-weight: 700;
}

.comms-steps li[aria-current="step"] .comms-steps__number {
  background: #1f5f99;
  color: #fff;
}

.comms-steps li.is-done .comms-steps__number {
  background: #2b7a4c;
  color: #fff;
}

.comms-review {
  margin: 12px 0 18px;
  border-color: #c9d9ea;
}

.comms-review__facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 20px;
  margin: 14px 0;
}

.comms-review__facts dt {
  margin: 0;
  color: #5b6c82;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.comms-review__facts dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.comms-review__body-wrap {
  margin-top: 12px;
}

.comms-review__body-wrap h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.comms-review__body {
  margin: 0;
  padding: 12px;
  border: 1px solid #dbe6f3;
  border-radius: 6px;
  background: #f8fbff;
  font: inherit;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comms-review__attachments {
  margin: 2px 0 0;
  padding-left: 18px;
}

.comms-review__actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #dbe6f3;
}

.comms-review__actions form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.comms-review__actions .form-hint {
  flex: 1 1 260px;
  margin: 0;
}

.comms-review__result {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid #2b7a4c;
  background: #edf8f1;
  border-radius: 4px;
}

.comms-secondary {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #dbe6f3;
}

.comms-secondary summary {
  cursor: pointer;
  color: #0a2b4a;
  font-weight: 600;
}

.comms-secondary[open] summary {
  margin-bottom: 12px;
}

@media (max-width: 640px) {
  .comms-review__facts {
    grid-template-columns: 1fr;
  }

  .comms-review__actions form .btn {
    width: 100%;
  }

  .comms-steps li {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Conversation cards: readable at 390px without squeezing table columns. */
.comms-thread-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.comms-thread-card {
  border: 1px solid #dbe6f3;
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.comms-thread-card__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.comms-thread-card__title {
  margin: 2px 0 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.comms-thread-card__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 16px;
  margin: 0;
}

.comms-thread-card__meta dt {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b6c82;
}

.comms-thread-card__meta dd {
  margin: 1px 0 0;
  font-size: 0.94rem;
}

.comms-thread-card__foot {
  display: flex;
  justify-content: flex-end;
}

.comms-template-list {
  list-style: none;
  margin: 10px 0 16px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.comms-template {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid #dbe6f3;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
}

.comms-template__name {
  margin: 0;
  font-weight: 600;
}

.comms-template__tail {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 560px) {
  .comms-thread-card__head,
  .comms-template {
    flex-direction: column;
    align-items: stretch;
  }
  .comms-thread-card__meta {
    grid-template-columns: 1fr 1fr;
  }
  .comms-thread-card__foot {
    justify-content: stretch;
  }
  .comms-thread-card__foot .btn {
    width: 100%;
  }
}

/* Conversation messages: a simple block list. The legacy `.feed` grid is
   two-column and crushes long message text in a narrow panel. */
.comms-messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.comms-messages li {
  border-left: 2px solid #dbe6f3;
  padding: 2px 0 2px 12px;
}

.comms-messages p {
  margin: 4px 0 0;
  line-height: 1.5;
}

.comms-grid {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  align-items: start;
}

@media (max-width: 640px) {
  .comms-filter,
  .comms-create {
    grid-template-columns: 1fr;
  }

  .comms-filter__check,
  form.comms-filter .comms-filter__apply {
    grid-column: 1;
    justify-self: stretch;
  }

  .comms-filter__apply,
  .comms-create__actions button {
    width: 100%;
  }

  .comms-thread__actions {
    justify-content: flex-start;
  }

  .comms-linked-record {
    white-space: normal;
  }
}

/* ------------------------------------------------- Stage 4: catalog & pricing */
.catalog-gate {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--gold, #c9a227);
  background: rgba(201, 162, 39, 0.08);
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.5;
}
.catalog-list { display: grid; gap: 12px; }
.catalog-card {
  border: 1px solid rgba(11, 42, 74, 0.12);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 6px;
}
.catalog-card__head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.catalog-card__title { margin: 2px 0 0; font-size: 1.02rem; }
.catalog-card__price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.catalog-card__foot { display: flex; justify-content: flex-end; }
.catalog-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.catalog-price--none { font-weight: 600; color: #8a5a00; }
.catalog-price__unit { font-size: 0.8rem; color: #5b6b7c; }
.catalog-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: #eef2f7;
  color: #33475c;
  white-space: nowrap;
}
.catalog-pill--active,
.catalog-pill--approved { background: #e4f5ea; color: #1c6b3c; }
.catalog-pill--draft { background: #eef2f7; color: #4a5b6d; }
.catalog-pill--pending { background: #fdf1d8; color: #8a5a00; }
.catalog-pill--superseded,
.catalog-pill--inactive { background: #f2ecec; color: #7a4a4a; }
.catalog-grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .catalog-grid { grid-template-columns: 1.1fr 0.9fr; } }
.catalog-meta { display: grid; gap: 8px; margin: 12px 0 0; }
.catalog-meta dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: #6a7a8b; }
.catalog-meta dd { margin: 2px 0 0; }
.catalog-quote {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f5f8fc;
  border: 1px solid rgba(11, 42, 74, 0.1);
}
.catalog-quote p { margin: 0 0 6px; }
.catalog-rates { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.catalog-rate { border: 1px solid rgba(11, 42, 74, 0.12); border-radius: 10px; padding: 12px; }
.catalog-rate__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.catalog-rate__price { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.catalog-rate .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.catalog-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.catalog-events li { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid rgba(11, 42, 74, 0.08); }
.catalog-events__action { font-weight: 600; text-transform: capitalize; }
.catalog-events__detail { font-size: 0.875rem; color: #33475c; }
.catalog-lookup { margin: 12px 0 0; padding-left: 18px; display: grid; gap: 8px; }
@media (max-width: 640px) {
  .catalog-card__head { flex-direction: column; }
  .catalog-card__foot { justify-content: stretch; }
  .catalog-card__foot .btn { width: 100%; }
  .catalog-rate__price { margin-left: 0; }
}

/* ------------------------------------------ Stage 2: acceptance & agreements */
.acceptance-list { display: grid; gap: 10px; }
.acceptance-row {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(11, 42, 74, 0.12);
  border-radius: 10px;
}
@media (min-width: 820px) {
  .acceptance-row { grid-template-columns: 1.6fr 1fr auto; align-items: center; }
}
.acceptance-row__evidence { display: grid; gap: 4px; }
.acceptance-row__actions { display: flex; justify-content: flex-end; }
.acceptance-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: #eef2f7;
  color: #33475c;
  white-space: nowrap;
}
.acceptance-pill--ok { background: #e4f5ea; color: #1c6b3c; }
.acceptance-pill--warn,
.acceptance-pill--warning { background: #fdf1d8; color: #8a5a00; }
.acceptance-pill--none { background: #f2ecec; color: #7a4a4a; }
.acceptance-pill--declined,
.acceptance-pill--withdrawn { background: #f7e6e6; color: #8a2b2b; }
.acceptance-records { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.acceptance-records li { border-bottom: 1px solid rgba(11, 42, 74, 0.08); padding-bottom: 10px; }
.acceptance-record__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agreement-grid { display: grid; gap: 12px; }

/* Stage 3 — the connected workflow. The seven stages read as a sequence in the
   list, and as a numbered trail on one customer. */
.pipeline-strip { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.pipeline-step__dot { width: 7px; height: 7px; border-radius: 50%; background: #c8d2dd; flex: none; }
.pipeline-step--ok .pipeline-step__dot { background: #1c8a4e; }
.pipeline-step--info .pipeline-step__dot { background: #1d4e89; }
.pipeline-step--bad .pipeline-step__dot { background: #b23b3b; }
.pipeline-step--warn .pipeline-step__dot { background: #b07a12; }
.pipeline-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: #eef2f7;
  color: #33475c;
  white-space: nowrap;
}
.pipeline-chip--ok { background: #e4f5ea; color: #1c6b3c; }
.pipeline-chip--info { background: #e6effa; color: #1d4e89; }
.pipeline-chip--bad { background: #f7e6e6; color: #8a2b2b; }
.pipeline-chip--warn { background: #fdf1d8; color: #8a5a00; }
.pipeline-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.pipeline-list__item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid rgba(11, 42, 74, 0.08);
}
.pipeline-list__item:last-child { border-bottom: 0; }
.pipeline-list__index { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-align: right; padding-top: 3px; }
.pipeline-list__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pipeline-list__body p { margin: 4px 0 0; }
.pipeline-blocked { margin-top: 4px; font-size: 0.74rem; color: #8a2b2b; }
.pipeline-table td { vertical-align: top; }
@media (max-width: 720px) {
  .pipeline-strip { gap: 4px 8px; }
  .pipeline-step { font-size: 0.68rem; }
}
@media (min-width: 900px) { .agreement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.agreement-card {
  border: 1px solid rgba(11, 42, 74, 0.12);
  border-radius: 10px;
  padding: 14px;
  display: grid;
  gap: 6px;
}
.agreement-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.agreement-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(11, 42, 74, 0.08);
}
.inline-check { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-check input[name="legal_note"],
.inline-check input[name="evidence_note"],
.inline-check input[name="reason"] { min-width: 180px; }

/* ---------- Stage 5: ZO AI assistant workspace ---------- */
.assistant-status { margin-bottom: 16px; padding: 14px 16px; border-left: 4px solid #b7791f; }
.assistant-status--bad { border-left-color: #c53030; }
.assistant-status__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.assistant-status__head strong { display: block; font-size: 1.02rem; }
.assistant-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; margin: 10px 0 0; }
.assistant-meta div { display: grid; gap: 2px; }
.assistant-meta dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6572; }
.assistant-meta dd { margin: 0; font-weight: 600; }
.assistant-toggle { margin-top: 10px; }

.assistant-layout { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.assistant-rail { padding: 12px 14px; }
.assistant-rail__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.assistant-rail__head h2 { font-size: .98rem; margin: 0; }
.assistant-threads { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; max-height: 46vh; overflow: auto; }
.assistant-thread { width: 100%; text-align: left; background: #f7f8fa; border: 1px solid #e2e6ec; border-radius: 10px;
  padding: 8px 10px; cursor: pointer; display: grid; gap: 2px; font: inherit; color: inherit; }
.assistant-thread:hover { background: #eef2f7; }
.assistant-thread.is-active { border-color: #2b6cb0; background: #ebf3fb; box-shadow: inset 0 0 0 1px #2b6cb0; }
.assistant-thread__title { font-weight: 600; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assistant-thread__meta { font-size: .72rem; color: #5b6572; }

.assistant-panel { padding: 16px; display: grid; gap: 14px; }
.assistant-panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.assistant-panel__head h2 { margin: 0; font-size: 1.05rem; }
.assistant-empty { padding: 14px; border: 1px dashed #d7dde5; border-radius: 12px; background: #fbfcfd; }
.assistant-empty p { margin: 0 0 6px; }

.assistant-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 52vh; overflow: auto; }
.assistant-message { max-width: 88%; padding: 10px 12px; border-radius: 12px; background: #f4f6f9; border: 1px solid #e4e8ee; }
.assistant-message--user { margin-left: auto; background: #eaf2fb; border-color: #cfe0f3; }
.assistant-message p { margin: 4px 0; white-space: pre-wrap; }
.assistant-message__who { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #5b6572; }
.assistant-message__time { display: block; font-size: .7rem; color: #7b8592; }

.assistant-draft { padding: 14px 16px; border-left: 4px solid #2b6cb0; }
.assistant-draft--ok { border-left-color: #2f855a; }
.assistant-draft--warn { border-left-color: #b7791f; }
.assistant-draft__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.assistant-draft__head h2 { margin: 2px 0 0; font-size: 1.02rem; }
.assistant-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 18px; margin: 12px 0; }
.assistant-fields div { display: grid; gap: 2px; min-width: 0; }
.assistant-fields dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: #5b6572; }
.assistant-fields dd { margin: 0; overflow-wrap: anywhere; }
.assistant-lines { margin: 8px 0; }
.assistant-warnings { margin: 10px 0; padding-left: 18px; display: grid; gap: 4px; color: #7c4a03; font-size: .88rem; }
.assistant-draft__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.assistant-handoff textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid #d7dde5; border-radius: 8px; background: #fbfcfd; }
/* Stage 5.1: the prepared message. A plain textarea takes its width from its
   columns attribute, so it is given the card width and a readable line height
   instead of the browser default. */
.assistant-preview { display: grid; gap: 6px; margin: 12px 0; }
.assistant-preview textarea { width: 100%; min-height: 170px; font: inherit; line-height: 1.55; padding: 10px 12px; border: 1px solid #d7dde5; border-radius: 8px; background: #fbfcfd; resize: vertical; }
.assistant-preview .cell-meta { margin: 0; }
.assistant-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }

.assistant-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }

.assistant-composer { display: grid; gap: 8px; border-top: 1px solid #e4e8ee; padding-top: 12px; }
.assistant-composer textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #d7dde5; border-radius: 10px; resize: vertical; }
.assistant-composer__actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.assistant-prompts { display: flex; flex-wrap: wrap; gap: 6px; }
.assistant-prompt { font: inherit; font-size: .8rem; padding: 5px 10px; border-radius: 999px; border: 1px solid #d7dde5;
  background: #fbfcfd; color: #2d3748; cursor: pointer; }
.assistant-prompt:hover { background: #eef2f7; }
.assistant-prompt:disabled { opacity: .55; cursor: not-allowed; }
.assistant-draft__actions .btn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 900px) {
  .assistant-layout { grid-template-columns: minmax(0, 1fr); }
  .assistant-threads { max-height: 30vh; }
  .assistant-message { max-width: 100%; }
  .assistant-log { max-height: none; }
}

/* The section tabs are sticky. Controls on the assistant screen scroll clear of
   them, so a click or a keyboard focus never lands underneath the strip. */
.assistant-panel .btn,
.assistant-panel button,
.assistant-panel textarea {
  scroll-margin-top: 140px;
  scroll-margin-bottom: 24px;
}

/* Stage 5: keep long titles and messages inside the card on every width. */
.assistant-layout,
.assistant-panel,
.assistant-rail,
.assistant-log { min-width: 0; }
.assistant-panel__head { flex-wrap: wrap; }
.assistant-panel__head h2 { overflow-wrap: anywhere; }
.assistant-message { min-width: 0; }
.assistant-message p { overflow-wrap: anywhere; }
.assistant-composer textarea { max-width: 100%; }
/* Stage 5: the phone tab strip is fixed, so draft actions must settle above it. */
.assistant-draft { scroll-margin-bottom: 84px; }


/* ---------- Nine-department navigation ---------- */
/* The bar carries nine destinations: four departments that open a panel of
   screens, three single screens reached in one click, and Emergency set apart.
   On phones the same structure is a slide-out drawer opened from the header. */

.tabs .nav__group {
  position: relative;
  display: inline-flex;
}

.tabs .nav__toggle,
.tabs .nav__direct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.tabs .nav__toggle[aria-expanded='true'] {
  color: var(--heading);
  background: var(--surface-3);
  box-shadow: inset 0 2px 0 var(--gold);
}

.nav__group--active > .nav__toggle {
  color: var(--heading);
}

.nav__caret {
  font-size: 0.68em;
  opacity: 0.7;
  transition: transform 120ms ease;
}

.nav__toggle[aria-expanded='true'] .nav__caret {
  transform: rotate(180deg);
}

.tabs .nav__direct[aria-current='page'] {
  background: var(--surface-3);
  color: var(--heading);
  box-shadow: inset 0 2px 0 var(--gold);
}

.nav__alarm {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c62828;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.18);
}

.tabs .nav__direct--emergency {
  color: #b3261e;
}

.tabs .nav__direct--emergency[aria-current='page'] {
  background: rgba(179, 38, 30, 0.1);
  box-shadow: inset 0 2px 0 #b3261e;
}

@media (prefers-color-scheme: dark) {
  .tabs .nav__direct--emergency {
    color: #ff9a90;
  }
}

.nav__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 45;
  width: 300px;
  min-width: 280px;
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 520px);
  overflow-y: auto;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 28px 50px -32px rgba(6, 42, 85, 0.65);
}

/* Set by the menu controller only when the panel would leave the viewport. */
.tabs .nav__group--edge > .nav__panel {
  left: auto;
  right: 0;
}

.nav__panel[hidden] {
  display: none;
}

.nav__panel-title {
  margin: 4px 10px 6px;
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.tabs .nav__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--heading);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  white-space: normal;
}

.tabs .nav__item:hover {
  background: var(--surface-3);
}

.tabs .nav__item[aria-current='page'] {
  background: var(--surface-3);
  box-shadow: inset 3px 0 0 var(--gold);
}

.tabs .nav__item--planned {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  color: var(--muted);
  cursor: default;
  font-weight: 500;
}

.tabs .nav__item--planned > span:first-child {
  width: 100%;
  overflow-wrap: anywhere;
}

.nav__tag {
  flex: none;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
}

.nav-toggle {
  display: none;
}

.nav-scrim {
  position: fixed;
  inset: var(--nav-sticky-top, 0px) 0 0 0;
  z-index: 30;
  background: rgba(4, 16, 32, 0.55);
  border: 0;
}

.nav-scrim[hidden] {
  display: none;
}

.emergency-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: #9b1c1c;
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.emergency-shortcut:hover {
  background: #b3261e;
}

@media (max-width: 719px) {
  .app-body {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }

  /* The header stays above the drawer so Menu, Emergency and Sign out remain
     usable while it is open, and the drawer begins under the header instead of
     covering the controls that opened it. */
  .topbar {
    z-index: 60;
  }

  .tabs {
    position: fixed;
    inset: var(--nav-sticky-top, 56px) auto 0 0;
    width: min(88vw, 340px);
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 2px;
    padding: calc(14px + env(safe-area-inset-top)) 10px calc(20px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 0;
    border-right: 1px solid var(--border);
    box-shadow: 24px 0 46px -30px rgba(6, 42, 85, 0.8);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-snap-type: none;
    transform: translateX(-104%);
    transition: transform 170ms ease;
    z-index: 40;
    /* Closed means gone: an off-screen fixed panel must not sit on top of a
       card, catch a stray tap or add scroll width to the page. */
    visibility: hidden;
    pointer-events: none;
  }

  body.nav-open .tabs {
    transform: none;
    visibility: visible;
    pointer-events: auto;
  }

  body.nav-open {
    overflow: hidden;
  }

  .nav-toggle {
    display: inline-flex;
    padding: 6px 10px;
  }

  .emergency-shortcut {
    padding: 5px 9px;
    font-size: 0.72rem;
  }

  .tabs .nav__group {
    display: block;
  }

  .tabs .nav__toggle,
  .tabs .nav__direct {
    display: flex;
    width: 100%;
    justify-content: space-between;
    min-height: 46px;
    padding: 11px 12px;
    border-radius: 9px;
    font-size: 0.92rem;
  }

  .tabs .nav__direct {
    justify-content: flex-start;
    gap: 8px;
  }

  .nav__panel {
    position: static;
    min-width: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 2px 0 8px 8px;
    background: transparent;
  }

  .tabs .nav__item {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.84rem;
  }

  .tabs .nav__item + .nav__item {
    border-top: 1px solid var(--border);
  }

  .tabs .nav__item--planned {
    flex-wrap: wrap;
    gap: 4px;
  }
}

@media (min-width: 720px) {
  .nav-toggle,
  .nav-scrim {
    display: none !important;
  }

  .tabs .nav__toggle[aria-expanded='true'] {
    border-radius: 8px 8px 0 0;
  }
}

/* On the narrowest phones the wordmark, the menu control, the emergency control
   and Sign out have to share one row. Both controls keep their glyph and their
   accessible name; only the words fold away. */
@media (max-width: 429px) {
  .topbar {
    gap: 8px;
    padding-inline: 10px;
  }

  .nav-toggle__text,
  .emergency-shortcut__text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}

/* Office Tasks search and creation controls. The create form is deliberately
   above the list so it is never hidden behind unrelated task cards. */
.task-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.task-header__actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding-top: 4px;
}

.task-create-panel {
  margin: 16px 0;
  border-left: 5px solid var(--blue-500);
}

.task-create-panel .card__head {
  align-items: flex-start;
  gap: 16px;
}

.task-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.task-search {
  margin: 16px 0;
  padding: 14px 16px;
  border-left: 5px solid var(--blue-500);
  scroll-margin-top: 96px;
}

.task-search__form {
  align-items: flex-end;
}

.task-search__form .ops-search {
  flex: 1 1 320px;
}

.task-search__form .ops-search input {
  width: 100%;
}

.task-search__form .btn {
  flex: 0 0 auto;
}

.task-search .search-status {
  margin: 10px 0 0;
}

.task-search-results {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 96px;
}

.task-search-results:focus {
  outline: none;
}

.task-search-results__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.task-search-results__title {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.task-search-results__list {
  margin-top: 10px;
}

.task-search-results__empty {
  margin: 4px 0 0;
}

.task-card--search-hit {
  border-left-color: var(--blue-500);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue-500) 34%, transparent);
}

.tag--exact {
  background: var(--info-soft);
  color: var(--blue-700, var(--blue-600));
}

.ops-search-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.ops-search-form .ops-search {
  flex: 1 1 220px;
}

.search-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.task-load-error {
  border-left: 5px solid var(--danger);
}

@media (max-width: 760px) {
  .task-header {
    flex-direction: column;
    gap: 10px;
  }

  .task-header__actions,
  .task-header__actions .btn {
    width: 100%;
  }

  .task-search {
    margin: 12px 0;
    padding: 12px;
    /* Clear the sticky top bar and the wrapping location bar, so a submitted
       search never parks its own input underneath the navigation. */
    scroll-margin-top: 174px;
  }

  .task-search-results {
    scroll-margin-top: 174px;
  }

  .task-search__form {
    align-items: stretch;
  }

  .task-search__form .ops-search {
    flex-basis: 100%;
  }

  .task-search__form .btn {
    flex: 1 1 140px;
  }

  .ops-search-form {
    width: 100%;
    align-items: stretch;
  }

  .ops-search-form .ops-search {
    flex-basis: 100%;
  }

  .ops-search-form .btn,
  .ops-search-form .link-btn {
    min-height: 38px;
  }
}

/* Clipboard fallback when the browser blocks programmatic copying. */
.copy-fallback {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(6, 42, 85, 0.55);
}
.copy-fallback__panel {
  width: 100%;
  max-width: 560px;
  padding: 20px;
  border-radius: 12px;
  background: #fff;
  color: #10233d;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}
.copy-fallback__panel h2 { margin: 0 0 8px; font-size: 18px; }
.copy-fallback__panel p { margin: 0 0 12px; font-size: 14px; }
.copy-fallback__panel input { width: 100%; margin-bottom: 12px; padding: 10px; border: 1px solid #9aa8b8; border-radius: 8px; font: inherit; }
.preview-copy { white-space: pre-wrap; font-family: inherit; }


/* Compact Communications workspace */
.comms-statusbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin: 14px 0; padding: 12px 14px; border: 1px solid #d8e0ea; border-left: 4px solid #1f5c99; border-radius: 12px; background: #f7f9fc; }
.comms-statusbar__copy { display: grid; gap: 3px; flex: 1 1 420px; font-size: 13px; color: #38495c; }
.comms-statusbar__copy strong { color: #10233d; }
.comms-statusbar__tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.comms-workspace { display: flex; gap: 4px; overflow-x: auto; padding: 4px 0 0; border-bottom: 1px solid #d8e0ea; }
.comms-workspace__tab { appearance: none; display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #4b5c6e; font: inherit; font-size: 14px; white-space: nowrap; cursor: pointer; }
.comms-workspace__tab:hover { color: #10233d; background: #f2f6fb; }
.comms-workspace__tab.is-active { color: #123e6b; border-bottom-color: #1f5c99; font-weight: 700; }
.comms-workspace__count { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: #e7edf5; color: #35485d; font-size: 11px; text-align: center; }
.comms-workspace__new { margin-left: auto; }
.comms-view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 12px 0 0; }
.comms-mailbox { padding: 0; overflow: hidden; }
.comms-mailbox .card__head { padding: 16px 18px 8px; margin: 0; }
.comms-filter-fold { padding: 0 18px 8px; }
.comms-filter-fold > summary { cursor: pointer; color: #35516f; font-size: 13px; font-weight: 600; padding: 4px 0; }
.comms-mail-list { border-top: 1px solid #e2e8ef; }
.comms-mail-row { display: flex; width: 100%; align-items: flex-start; gap: 12px; padding: 12px 18px; border: 0; border-bottom: 1px solid #edf1f5; background: #fff; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.comms-mail-row:hover, .comms-mail-row:focus-visible { background: #f5f8fc; outline: none; }
.comms-mail-row.is-unread { background: #f2f7ff; }
.comms-mail-row__main { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
.comms-mail-row__line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.comms-mail-row__line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comms-mail-row__subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: #17395f; }
.comms-mail-row__preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #5d6c7c; font-size: 13px; }
.comms-mail-row__tag { flex: 0 0 auto; padding: 1px 6px; border-radius: 999px; background: #eef3f8; color: #5d6c7c; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.comms-mail-row__side { display: grid; justify-items: end; gap: 5px; flex: 0 0 auto; color: #697887; font-size: 12px; }
.comms-unread { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #1f5c99; color: #fff; font-size: 11px; font-weight: 700; }
.comms-mail-row--record { cursor: default; display: block; }
.comms-fold { padding: 0; overflow: hidden; }
.comms-fold > summary { display: flex; align-items: center; gap: 8px; padding: 14px 18px; cursor: pointer; list-style: none; }
.comms-fold > summary::-webkit-details-marker { display: none; }
.comms-fold > summary::before { content: '▸'; flex: 0 0 auto; color: #66809c; font-size: 12px; }
.comms-fold[open] > summary::before { content: '▾'; }
.comms-fold__title { font-weight: 700; color: #17395f; }
.comms-count { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: #eef3f8; color: #42566c; font-size: 12px; font-weight: 600; white-space: nowrap; }
.comms-count--attention { background: #fff0e2; color: #9a3d00; }
.comms-fold__body { padding: 0 18px 16px; border-top: 1px solid #edf1f5; }
.comms-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 10px 0; }
.comms-facts div { min-width: 0; }
.comms-facts dt { margin: 0 0 1px; color: #697887; font-size: 11px; letter-spacing: .03em; text-transform: uppercase; }
.comms-facts dd { margin: 0; overflow-wrap: anywhere; }
.comms-approval { border: 1px solid #dce4ed; border-radius: 10px; margin: 8px 0; background: #fff; }
.comms-approval > summary { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 9px 11px; cursor: pointer; list-style: none; }
.comms-approval > summary::-webkit-details-marker { display: none; }
.comms-approval > summary strong { color: #17395f; }
.comms-approval > *:not(summary) { margin-left: 11px; margin-right: 11px; }
.comms-template-filter { margin: 10px 0; }
.comms-template-rows { display: grid; gap: 6px; }
.comms-template-row { border: 1px solid #dce4ed; border-radius: 9px; background: #fff; }
.comms-template-row > summary { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; list-style: none; }
.comms-template-row > summary::-webkit-details-marker { display: none; }
.comms-template-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #17395f; font-weight: 600; }
.comms-template-row__meta { margin-left: auto; color: #697887; font-size: 12px; white-space: nowrap; }
.comms-template-row__body { padding: 10px; border-top: 1px solid #edf1f5; }
.comms-template-create { margin-top: 12px; padding-top: 8px; border-top: 1px solid #edf1f5; }
.comms-template-create > summary { padding: 4px 0; cursor: pointer; font-weight: 600; color: #35516f; }
.comms-subfold { margin-top: 10px; padding-top: 8px; border-top: 1px solid #edf1f5; }
.comms-subfold > summary { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; font-weight: 600; color: #35516f; }
.comms-thread-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.comms-thread-toolbar__actions, .comms-thread__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.comms-messages { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0; }
.comms-message { max-width: min(100%, 820px); padding: 12px 14px; border: 1px solid #dce4ed; border-radius: 12px; }
.comms-message--inbound { background: #f7f9fc; border-left: 4px solid #aebdcd; }
.comms-message--outbound { margin-left: auto; background: #fff; border-left: 4px solid #1f5c99; }
.comms-message__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.comms-message__subject { margin: 6px 0 0; }
.comms-message__body { margin: 8px 0 0; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.comms-reply { margin-top: 16px; padding-top: 12px; border-top: 1px solid #edf1f5; }
.comms-reply__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.comms-review-lock { margin-top: 14px; padding: 10px 12px; border: 1px solid #ecd7a8; border-radius: 10px; background: #fff8e8; font-size: 13px; }
.comms-members { display: grid; gap: 4px; list-style: none; margin: 8px 0; padding: 0; }
.comms-members li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comms-events { display: grid; gap: 8px; list-style: none; margin: 8px 0; padding: 0; }
.comms-events li { display: grid; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid #edf1f5; }
.comms-events__action { font-weight: 600; text-transform: capitalize; }
.comms-events__detail { color: #5d6c7c; font-size: 13px; }
.comms-template-row__body .comms-review__body, .comms-approval .comms-review__body { max-height: 300px; overflow: auto; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
@media (max-width: 760px) {
  .comms-statusbar { flex-direction: column; align-items: stretch; }
  .comms-statusbar__copy { flex: 0 0 auto; }
  .comms-statusbar__tools { flex: 0 0 auto; justify-content: space-between; }
  .comms-facts { grid-template-columns: 1fr; }
  .comms-workspace { gap: 0; }
  .comms-workspace__tab { padding: 8px 10px; font-size: 13px; }
  .comms-workspace__new { margin-left: 0; }
  .comms-mailbox .card__head { padding: 14px 14px 6px; }
  .comms-filter-fold { padding: 0 14px 6px; }
  .comms-mail-row { gap: 8px; padding: 11px 12px; }
  .comms-mail-row__preview { display: -webkit-box; overflow: hidden; white-space: normal; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .comms-mail-row__side time { font-size: 11px; }
  .comms-message { max-width: 100%; }
  .comms-fold > summary { padding: 13px 14px; }
  .comms-fold__body { padding: 0 14px 14px; }
}
@media (max-width: 430px) {
  .comms-thread-toolbar__actions { width: 100%; }
  .comms-thread-toolbar__actions .btn { flex: 1 1 auto; }
  .comms-workspace { flex-wrap: wrap; border-bottom: 0; }
  .comms-workspace__tab { flex: 1 1 40%; justify-content: center; margin: 2px; border: 1px solid #d8e0ea; border-radius: 8px; }
  .comms-workspace__new { flex: 1 1 100%; margin: 4px 2px 0; }
  .comms-mail-row__side { max-width: 74px; }
  .comms-mail-row__side time { text-align: right; line-height: 1.3; }
  .comms-template-row > summary { align-items: flex-start; flex-direction: column; }
  .comms-template-row__meta { margin-left: 0; }
  .comms-filter .btn, .comms-template-filter .btn { width: 100%; }
}

/* ==========================================================================
   Communications mobile usability repair
   All Communications surfaces use semantic tokens so light text never lands on
   a hard-coded white panel in dark mode, and navy headings never disappear on a
   dark expandable panel. The rules below also give the compact workspace a
   readable, non-overlapping phone layout.
   ========================================================================== */

.comms-gate,
.comms-gate.comms-statusbar {
  background: var(--warn-soft);
  color: var(--label);
  border-color: color-mix(in srgb, var(--warn) 32%, var(--border));
}
.comms-gate strong,
.comms-gate.comms-statusbar strong { color: var(--heading); }
.comms-statusbar {
  background: var(--surface-2);
  color: var(--label);
  border-color: var(--border);
  border-left-color: var(--info);
}
.comms-statusbar__copy { color: var(--label); }
.comms-statusbar__copy strong { color: var(--heading); }
.comms-statusbar .cell-meta { color: var(--muted); }
.comms-workspace { border-color: var(--border); }
.comms-workspace__tab { color: var(--label); }
.comms-workspace__tab:hover { color: var(--heading); background: var(--surface-2); }
.comms-workspace__tab.is-active { color: var(--info); border-bottom-color: var(--info); }
.comms-workspace__count { background: var(--surface-3); color: var(--label); }
.comms-mail-row { background: var(--surface); color: var(--ink); border-bottom-color: var(--border); }
.comms-mail-row:hover,
.comms-mail-row:focus-visible { background: var(--surface-2); }
.comms-mail-row.is-unread { background: var(--info-soft); }
.comms-mail-row__subject { color: var(--heading); }
.comms-mail-row__preview,
.comms-mail-row__side { color: var(--muted); }
.comms-mail-row__tag { background: var(--surface-3); color: var(--label); }
.comms-mail-list { border-color: var(--border); }
.comms-filter-fold > summary,
.comms-template-create > summary,
.comms-subfold > summary { color: var(--info); }
.comms-fold > summary { color: var(--heading); }
.comms-fold__title { color: var(--heading); }
.comms-count { background: var(--surface-3); color: var(--label); }
.comms-count--attention { background: var(--warn-soft); color: var(--warn); }
.comms-fold__body,
.comms-subfold,
.comms-template-create { border-color: var(--border); }
.comms-facts dt { color: var(--muted); }
.comms-approval,
.comms-template-row { background: var(--surface); border-color: var(--border); }
.comms-approval > summary strong,
.comms-template-row__name { color: var(--heading); }
.comms-template-row__meta { color: var(--muted); }
.comms-template-row__body { border-color: var(--border); }
.comms-template-row > summary,
.comms-approval > summary { transition: background 0.15s ease; }
.comms-template-row > summary:hover,
.comms-template-row > summary:focus-visible,
.comms-approval > summary:hover,
.comms-approval > summary:focus-visible { background: var(--surface-2); }
.comms-template-row > summary::before,
.comms-approval > summary::before {
  content: '▸';
  flex: 0 0 auto;
  color: var(--info);
  font-size: 0.72rem;
}
.comms-template-row[open] > summary::before,
.comms-approval[open] > summary::before { content: '▾'; }
.comms-events__detail { color: var(--muted); }
.comms-draft { background: var(--surface-2); border-color: var(--border); }
.comms-pill { background: var(--surface-3); color: var(--label); }
.comms-pill--open,
.comms-pill--approved { background: var(--ok-soft); color: var(--ok); }
.comms-pill--waiting,
.comms-pill--draft { background: var(--warn-soft); color: var(--warn); }
.comms-pill--closed { background: var(--surface-3); color: var(--label); }
.comms-steps li { background: var(--surface-2); color: var(--label); border-color: var(--border-strong); }
.comms-steps li[aria-current="step"] { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.comms-steps li.is-done { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 42%, var(--border)); }
.comms-steps__number { background: var(--surface-3); color: var(--label); }
.comms-steps li[aria-current="step"] .comms-steps__number { background: var(--info); color: var(--surface); }
.comms-steps li.is-done .comms-steps__number { background: var(--ok); color: var(--surface); }
.comms-review { border-color: var(--border-strong); }
.comms-review__facts dt { color: var(--muted); }
.comms-review__body { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
.comms-review__actions { border-color: var(--border); }
.comms-review-lock { background: var(--warn-soft); color: var(--ink); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.comms-review__result { background: var(--ok-soft); color: var(--ink); border-left-color: var(--ok); }
.comms-message {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
  max-width: min(100%, 760px);
}
.comms-message--inbound { background: var(--surface-2); border-left-color: var(--muted); }
.comms-message--outbound { background: var(--surface); border-left-color: var(--info); }
.comms-message__head { gap: 8px 12px; }
.comms-message__who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.comms-message__who strong { color: var(--heading); overflow-wrap: anywhere; }
.comms-message__direction {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--label);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.comms-message--inbound .comms-message__direction { background: var(--info-soft); color: var(--info); }
.comms-message__status {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.72rem;
  font-weight: 700;
}
.comms-message__status.is-accepted { background: var(--ok-soft); color: var(--ok); }
.comms-message__status.is-draft { background: var(--warn-soft); color: var(--warn); }
.comms-message__route {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 9px 0 0;
  color: var(--label);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.comms-message__route b { color: var(--muted); font-weight: 700; }
.comms-message__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}
.comms-message__body {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comms-message__subject { color: var(--heading); }
.comms-conversation .card__head { align-items: flex-start; }
.comms-reply {
  margin: 12px 0 18px;
  padding: 16px 18px;
}
.comms-reply--launcher { border-left: 4px solid var(--info); }
.comms-reply__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.comms-reply__head .card__title { font-size: 1.02rem; }
.comms-reply__head .form-hint { margin-top: 8px; }
.comms-reply__choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.comms-reply__choices .btn { flex: 1 1 170px; }
.comms-reply__destination { margin: 11px 0 0; color: var(--muted); font-size: 0.78rem; overflow-wrap: anywhere; }
.comms-reply__context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 13px 0;
  padding: 12px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.comms-reply__context div { min-width: 0; }
.comms-reply__context dt { color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.comms-reply__context dd { margin: 2px 0 0; color: var(--ink); overflow-wrap: anywhere; }
.comms-reply form.form-grid { grid-template-columns: 1fr; }
.comms-reply form label { color: var(--label); font-weight: 700; }
.comms-reply form textarea { min-height: 132px; font-size: 1rem; }
.comms-reply__actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.comms-reply__actions .form-hint { flex: 1 1 260px; margin: 0; }
.comms-local-draft { margin: 9px 0 0; color: var(--info); font-size: 0.78rem; }
.comms-local-draft[hidden] { display: none !important; }
.comms-review--result { padding: 14px 18px; }
.comms-result { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.comms-result .form-hint { margin-top: 7px; }
.comms-result__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
}
.comms-result__facts p { margin: 0; overflow-wrap: anywhere; }
.comms-result__facts strong { color: var(--label); }
.comms-secondary,
.comms-approval > *:not(summary) { border-color: var(--border); }

/* The Communications location bar scrolls with the page. It must never sit over
   a message body or a form, and its controls stay compact on a phone. */
body.comms-active .navbar { position: static; }
body.comms-active .navbar__step,
body.comms-active .navbar__chip { color: var(--heading); }
body.comms-active .navbar__step:disabled { color: var(--muted); opacity: 1; }
body.comms-active .navbar__step:disabled span { opacity: 0.55; }

@media (max-width: 719px) {
  body.comms-active .topbar {
    position: static;
    padding-block: 5px;
    gap: 8px;
  }
  body.comms-active .brand-logo--app { height: 23px; }
  body.comms-active .topbar-right { gap: 6px; }
  body.comms-active .app-body { padding-inline: 12px; }
  body.comms-active .navbar {
    margin-top: 8px;
    padding: 5px 7px;
    gap: 5px;
    border-radius: 9px;
  }
  body.comms-active .navbar__history { flex: 0 1 auto; gap: 4px; }
  body.comms-active .navbar__step {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 6px 9px;
    font-size: 0.74rem;
  }
  body.comms-active .navbar__trail { flex: 1 1 90px; gap: 2px; }
  body.comms-active .crumbs ol { gap: 3px; }
  body.comms-active .crumbs li { min-height: 26px; font-size: 0.72rem; }
  body.comms-active .crumbs [aria-current="page"] { max-width: 34vw; font-size: 0.74rem; }
  body.comms-active .content { padding-top: 17px; }
  body.comms-active .comms-head .page-title { font-size: 1.7rem; }
  body.comms-active .comms-thread-toolbar { gap: 8px; }
  body.comms-active .comms-thread-toolbar__actions .btn { min-height: 38px; height: 38px; font-size: 0.76rem; }
  body.comms-active .comms-reply { padding: 14px; }
  body.comms-active .comms-reply__choices { display: grid; grid-template-columns: 1fr; }
  body.comms-active .comms-reply__choices .btn { width: 100%; height: 46px; }
  body.comms-active .comms-reply__context { grid-template-columns: 1fr; }
  body.comms-active .comms-reply__actions .btn { flex: 1 1 100%; }
  body.comms-active .comms-message { max-width: 100%; padding: 12px; }
  body.comms-active .comms-message__body { font-size: 1rem; }
  body.comms-active .comms-message__status { font-size: 0.7rem; }
  body.comms-active .comms-message__meta { font-size: 0.74rem; }
  body.comms-active .comms-messages { gap: 12px; }
  body.comms-active .comms-review { padding: 14px; }
  body.comms-active .comms-review--result { padding: 13px 14px; }
  body.comms-active .comms-result__facts { display: grid; gap: 3px; }
  body.comms-active .comms-mailbox .card__head { padding: 13px 12px 6px; }
  body.comms-active .comms-fold > summary { min-height: 48px; }
  body.comms-active .comms-fold__title { font-size: 1rem; }
}

@media (max-width: 430px) {
  body.comms-active .comms-thread-toolbar__actions { width: 100%; }
  body.comms-active .comms-thread-toolbar__actions .btn { flex: 1 1 0; min-width: 0; }
  body.comms-active .comms-workspace { flex-wrap: wrap; }
  body.comms-active .comms-workspace__tab { min-height: 42px; }
  body.comms-active .comms-message__head { display: grid; gap: 7px; }
  body.comms-active .comms-message__status { justify-self: start; }
}

/* Placeholder copy is text too: use the semantic muted token rather than the
   browser's low-contrast default on dark form fields. */
body.comms-active input::placeholder,
body.comms-active textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* New-message navigation, collapsible history and central Communications alerts. */
.comms-alert { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 44px; min-height: 38px; }
.comms-alert[hidden] { display: none !important; }
.comms-alert__count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: #d9a514; color: #10233d; font-size: 11px; font-weight: 800; }
.comms-tab-badge { margin-left: auto; }
.comms-sync-feedback { margin: 8px 0 0; padding: 9px 12px; border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: 9px; background: var(--surface-2); color: var(--ink); font-size: 0.82rem; }
.comms-sync-feedback--success { border-left-color: var(--ok); background: var(--ok-soft); }
.comms-sync-feedback--no-new { border-left-color: var(--info); }
.comms-sync-feedback--error,
.comms-sync-feedback--disconnected { border-left-color: var(--danger, #b42318); background: var(--warn-soft); }
.comms-conversation__tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.comms-unread-divider { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: var(--info); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.comms-unread-divider::before,
.comms-unread-divider::after { content: ''; height: 1px; flex: 1 1 auto; background: color-mix(in srgb, var(--info) 45%, var(--border)); }
.comms-message__newest { padding: 1px 7px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-size: 0.63rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.comms-message__details { margin-top: 8px; border-top: 1px solid var(--border); }
.comms-message__details > summary { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 0 0; cursor: pointer; list-style: none; color: var(--label); font-size: 0.88rem; line-height: 1.45; }
.comms-message__details > summary::-webkit-details-marker { display: none; }
.comms-message__details > summary > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.comms-message__expand-label { flex: 0 0 auto; color: var(--info); font-size: 0.72rem; font-weight: 700; }
.comms-message__details[open] > summary { color: var(--muted); }
.comms-message__details[open] .comms-message__expand-label { visibility: hidden; }
.comms-message__fold-note { margin: 8px 0 0; color: var(--muted); font-size: 0.72rem; }
.comms-notification-list { display: grid; gap: 6px; list-style: none; margin: 10px 0; padding: 0; }
.comms-notification { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; padding: 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.comms-notification.is-unread { border-left: 4px solid var(--info); background: var(--info-soft); }
.comms-notification__link { display: grid; gap: 2px; flex: 1 1 240px; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.comms-notification__link strong { color: var(--heading); overflow-wrap: anywhere; }
.comms-notification__link span { color: var(--label); font-size: 0.8rem; overflow-wrap: anywhere; }
.comms-notification__link time { color: var(--muted); font-size: 0.72rem; }
.comms-notification__link:disabled { cursor: default; opacity: 1; }
.comms-notification__state { padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--label); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.comms-notification.is-unread .comms-notification__state { background: var(--info); color: var(--surface); }
.comms-notification.is-acknowledged .comms-notification__state { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 719px) {
  body.comms-active .comms-conversation__tools { width: 100%; justify-content: space-between; }
  body.comms-active .comms-message__details > summary { flex-direction: column; gap: 3px; }
  body.comms-active .comms-alert { min-width: 40px; padding-inline: 7px; }
  body.comms-active .comms-alert__count { font-size: 10px; }
}

/* ==========================================================================
   Estimate presentation + formal proposal document
   ========================================================================== */

/* The shell's sticky bars are measured in nav.js. On an open estimate or
   customer proposal both the header and the location bar stay in normal flow:
   a signature block, scope paragraph or approval control is never covered. */
body.estimate-active .topbar,
body.estimate-active .navbar {
  position: static;
}

body.estimate-active .scope-section,
body.estimate-active #estimate-documents,
body.estimate-active #estimate-revision-history,
body.estimate-active #estimate-photos,
body.estimate-active #proposal-document,
body.estimate-active #estimate-scope,
body.estimate-active .proposal-preview-card {
  scroll-margin-top: 18px;
}

html {
  scroll-padding-top: calc(var(--topbar-height, 56px) + (var(--navbar-height, 0px) * 0) + 18px);
}

.topbar {
  z-index: 50;
}

.brand-link,
.brand-plate {
  min-width: 0;
}

.brand-plate {
  max-width: min(46vw, 260px);
}

.brand-logo--app {
  max-width: 100%;
}

.navbar {
  z-index: 40;
  background: var(--surface);
}

@media (min-width: 1024px) {
  html {
    scroll-padding-top: calc(var(--topbar-height, 56px) + var(--navbar-height, 64px) + 18px);
  }
}

@media (max-width: 1023px) {
  .navbar {
    position: static;
  }
}

.scope-section,
#estimate-documents,
#estimate-revision-history,
#estimate-photos,
#proposal-document,
#estimate-scope,
.proposal-preview-card {
  scroll-margin-top: calc(var(--topbar-height, 56px) + 18px);
}

@media (min-width: 1024px) {
  .scope-section,
  #estimate-documents,
  #estimate-revision-history,
  #estimate-photos,
  #proposal-document,
  #estimate-scope,
  .proposal-preview-card {
    scroll-margin-top: calc(var(--topbar-height, 56px) + var(--navbar-height, 64px) + 18px);
  }
}

.estimate-detail-stack {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.estimate-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 20px;
  margin: 0;
}

.estimate-facts div {
  min-width: 0;
}

.estimate-facts dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.estimate-facts dd {
  margin: 0;
  color: var(--heading);
  font-size: 0.91rem;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.estimate-facts dd span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.estimate-primary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.65fr);
  gap: 18px;
  align-items: start;
}

/* The price and its included scope read as one vertical unit. Approvals stay
   alongside the price on desktop, but their height cannot push the scope down. */
.estimate-main-stack,
.estimate-side-stack {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

@media (max-width: 900px) {
  .estimate-primary-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.estimate-pricing__project {
  margin: 0 0 12px;
  color: var(--heading);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.scope-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 4px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

.scope-tools p {
  flex: 1 1 260px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.scope-tools p strong {
  color: var(--heading);
}

.scope-tools__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.scope-tools__actions .btn {
  min-height: 40px;
}

.scope-section__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 6px;
}

.scope-section__heading .scope-section__title {
  flex: 1;
  margin-bottom: 0;
}

.scope-section__toggle {
  flex: none;
  min-height: 32px;
  color: var(--info);
  font-size: 0.73rem;
  white-space: nowrap;
}

.scope-section__detail[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .scope-tools {
    align-items: stretch;
  }

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

  .scope-section__heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .scope-section__toggle {
    padding-left: 0;
  }
}

.estimate-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 9px;
  margin-bottom: 18px;
}

.estimate-actions .btn {
  width: 100%;
  min-height: 44px;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

/* The generated link must remain readable next to its Copy Link action. The
   generic estimate action button is full-width, which otherwise squeezes the
   input down to a sliver inside the result notice. */
.estimate-actions .estimate-guest-result {
  grid-column: 1 / -1;
}

.estimate-actions .estimate-guest-result .invite-link .btn {
  width: auto;
  min-width: 96px;
  flex: 0 0 auto;
}

.estimate-actions .estimate-guest-result .invite-link input {
  width: 100%;
  flex: 1 1 12rem;
}

.estimate-admin-decisions {
  margin-bottom: 14px;
}

.estimate-history {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.estimate-history .subhead {
  margin-top: 0;
}

.scope-work {
  min-width: 0;
}

.scope-intro {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-left: 3px solid var(--gold);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}

.scope-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.scope-intro p + p {
  margin-top: 6px;
}

.scope-nav {
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.scope-nav__label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.scope-nav ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scope-nav a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 40px;
  padding: 8px 9px;
  border-radius: 7px;
  color: var(--info);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none;
}

.scope-nav a:hover {
  background: var(--surface-3);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.scope-nav a:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 1px;
}

.scope-nav a span {
  flex: none;
  color: var(--gold-ink);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.scope-sections {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scope-section {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  padding: 17px 0;
  border-top: 1px solid var(--border);
}

.scope-section:first-child {
  border-top: 0;
}

.scope-section__number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--border));
  border-radius: 50%;
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  color: var(--gold-ink);
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.scope-section__body {
  min-width: 0;
}

.scope-section__title {
  margin: 0 0 6px;
  color: var(--heading);
  font-size: 0.91rem;
  font-weight: 800;
  line-height: 1.35;
}

.scope-section__body p {
  margin: 0;
  color: var(--ink);
  font-size: 0.87rem;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.scope-section__body p + p {
  margin-top: 8px;
}

.scope-exclusions {
  margin-top: 18px;
  padding: 15px 17px;
  border: 1px solid color-mix(in srgb, var(--gold) 48%, var(--border));
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: color-mix(in srgb, var(--gold) 8%, var(--surface));
}

.scope-exclusions h3 {
  margin: 0 0 7px;
  color: var(--heading);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.scope-exclusions p {
  margin: 0;
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.6;
}

.scope-exclusions p + p {
  margin-top: 7px;
}

.proposal-empty {
  margin: 0;
}

/* ------------------------------------------------------------ pricing */
.price-complete {
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--gold) 42%, var(--border));
  border-radius: 10px;
  background: linear-gradient(145deg, var(--surface), var(--surface-3));
}

.price-complete__label {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.price-complete__amount {
  display: block;
  margin: 2px 0 8px;
  color: var(--heading);
  font-size: clamp(2rem, 6vw, 2.65rem);
  font-weight: 850;
  letter-spacing: -0.045em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.price-complete__description {
  margin: 0;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.price-complete__note,
.price-summary__basis {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.price-lines {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.price-lines__head,
.price-lines li,
.price-total {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.price-lines__head {
  padding: 9px 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.price-lines ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.price-lines li {
  padding: 11px 12px;
  border-top: 1px solid var(--border);
}

.price-line__description {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.price-line__description strong {
  color: var(--heading);
  font-size: 0.83rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.price-line__description span {
  color: var(--muted);
  font-size: 0.72rem;
}

.price-line__amount {
  color: var(--heading);
  font-size: 0.84rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.price-total {
  padding: 12px;
  border-top: 2px solid var(--gold);
  background: var(--surface-2);
  color: var(--heading);
  font-size: 0.85rem;
  font-weight: 800;
}

.price-total strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.price-optional {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
}

.price-optional h3 {
  margin: 0 0 4px;
  color: var(--heading);
  font-size: 0.82rem;
}

.price-optional p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.price-optional ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.price-optional li {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--ink);
  font-size: 0.8rem;
}

.price-optional li strong {
  color: var(--heading);
  white-space: nowrap;
}

.estimate-decision-card {
  margin-top: 18px;
}

.estimate-decision-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.estimate-decision-actions .btn {
  min-height: 48px;
  flex: 1 1 200px;
}

.estimate-optional-choice {
  margin-top: 16px;
}

/* --------------------------------------------------- proposal paper */
.proposal-preview-card {
  overflow: hidden;
}

.proposal-preview-card .card__note {
  margin: 4px 0 0;
}

.proposal-preview-frame {
  padding: 18px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(6, 42, 85, 0.06), rgba(212, 162, 60, 0.07)),
    var(--surface-2);
  overflow: hidden;
}

.proposal-sheet {
  box-sizing: border-box;
  width: min(100%, 210mm);
  margin-inline: auto;
  padding: 42px 48px 34px;
  border: 1px solid #d9dde3;
  border-top: 5px solid #062a55;
  background: #ffffff;
  color: #25303d;
  color-scheme: light;
  box-shadow: 0 18px 44px -28px rgba(6, 42, 85, 0.5);
  font-family: var(--font-body, Inter, system-ui, sans-serif);
  overflow-wrap: anywhere;
}

.proposal-sheet h2,
.proposal-sheet h3,
.proposal-sheet h4,
.proposal-sheet strong {
  color: #062a55;
}

.proposal-letterhead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}

.proposal-logo {
  display: block;
  width: 235px;
  max-width: 58%;
  height: auto;
  aspect-ratio: 1730 / 551;
}

.proposal-letterhead__right {
  flex: none;
  text-align: right;
  color: #556272;
  font-size: 0.7rem;
  line-height: 1.45;
}

.proposal-letterhead__right p {
  margin: 0;
}

.proposal-document-type {
  color: #8a6518 !important;
  font-size: 0.63rem !important;
  font-weight: 850;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.proposal-document-number {
  margin-top: 3px !important;
  color: #062a55 !important;
  font-family: var(--font-display, Montserrat, sans-serif);
  font-size: 1rem !important;
  font-weight: 850;
}

.proposal-gold-rule {
  height: 2px;
  margin: 18px 0 24px;
  background: linear-gradient(90deg, #d4a23c 0 25%, #062a55 25% 100%);
}

.proposal-cover {
  padding-bottom: 22px;
  border-bottom: 1px solid #dfe3e8;
}

.proposal-kicker {
  margin: 0 0 6px;
  color: #8a6518;
  font-size: 0.67rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.proposal-cover h2 {
  margin: 0;
  color: #062a55;
  font-family: var(--font-display, Montserrat, sans-serif);
  font-size: clamp(1.65rem, 3.4vw, 2.25rem);
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.16;
}

.proposal-cover__project {
  margin: 7px 0 0;
  color: #596675;
  font-size: 0.84rem;
  line-height: 1.5;
}

.proposal-cover__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 22px;
  margin-top: 20px;
}

.proposal-cover__meta div {
  min-width: 0;
  padding-left: 10px;
  border-left: 2px solid #d4a23c;
}

.proposal-cover__meta span {
  display: block;
  margin-bottom: 2px;
  color: #6b7684;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.proposal-cover__meta strong {
  display: block;
  color: #26313f;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.45;
}

.proposal-section {
  padding: 24px 0 0;
}

.proposal-section + .proposal-section {
  margin-top: 24px;
  border-top: 1px solid #dfe3e8;
}

.proposal-section__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.proposal-section__index {
  color: #b58a2e;
  font-family: var(--font-display, Montserrat, sans-serif);
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.proposal-section__head h3 {
  flex: 1;
  margin: 0;
  color: #062a55;
  font-family: var(--font-display, Montserrat, sans-serif);
  font-size: 1.03rem;
  font-weight: 850;
  letter-spacing: 0.01em;
}

.proposal-section__count {
  color: #6b7684;
  font-size: 0.68rem;
  font-weight: 700;
}

.proposal-sheet .scope-intro {
  border-left-color: #d4a23c;
  background: #f7f8fa;
}

.proposal-sheet .scope-intro p {
  color: #465362;
  font-size: 0.8rem;
}

.proposal-sheet .scope-section {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 13px 0;
  border-top-color: #e5e8ec;
  break-inside: avoid;
}

.proposal-sheet .scope-section__number {
  width: 29px;
  height: 29px;
  border-color: #d9c28e;
  background: #fbf7ed;
  color: #785616;
  font-size: 0.65rem;
}

.proposal-sheet .scope-section__title {
  margin-bottom: 4px;
  color: #062a55;
  font-size: 0.82rem;
}

.proposal-sheet .scope-section__body p {
  color: #374250;
  font-size: 0.79rem;
  line-height: 1.62;
}

.proposal-sheet .scope-exclusions {
  margin-top: 16px;
  padding: 13px 15px;
  border-color: #dfc88f;
  border-left-color: #c79a3b;
  background: #fbf7ed;
}

.proposal-sheet .scope-exclusions h3 {
  color: #6f5114;
  font-size: 0.69rem;
}

.proposal-sheet .scope-exclusions p {
  color: #3d4653;
  font-size: 0.77rem;
}

.proposal-sheet .price-complete {
  border-color: #dfc88f;
  background: linear-gradient(145deg, #fbfcfe, #f7f5ef);
}

.proposal-sheet .price-complete__label {
  color: #6b7684;
}

.proposal-sheet .price-complete__amount {
  color: #062a55;
}

.proposal-sheet .price-complete__description,
.proposal-sheet .price-complete__note,
.proposal-sheet .price-summary__basis {
  color: #465362;
}

.proposal-sheet .price-lines {
  border-color: #dfe3e8;
  background: #ffffff;
}

.proposal-sheet .price-lines__head {
  background: #f4f6f8;
  color: #596675;
}

.proposal-sheet .price-lines li {
  border-top-color: #e5e8ec;
}

.proposal-sheet .price-line__description strong,
.proposal-sheet .price-line__amount,
.proposal-sheet .price-total,
.proposal-sheet .price-total strong {
  color: #062a55;
}

.proposal-sheet .price-line__description span {
  color: #6b7684;
}

.proposal-sheet .price-total {
  border-top-color: #d4a23c;
  background: #f7f8fa;
}

.proposal-sheet .price-optional {
  border-color: #cfd5dc;
}

.proposal-sheet .price-optional h3,
.proposal-sheet .price-optional li strong {
  color: #062a55;
}

.proposal-sheet .price-optional p,
.proposal-sheet .price-optional li {
  color: #465362;
}

.proposal-terms p {
  margin: 0;
  color: #3c4754;
  font-size: 0.79rem;
  line-height: 1.65;
}

.proposal-terms p + p {
  margin-top: 7px;
}

.proposal-signatures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
  margin-top: 24px;
  break-inside: avoid;
}

.proposal-signature {
  min-width: 0;
}

.proposal-signature h4 {
  margin: 0 0 3px;
  color: #062a55;
  font-size: 0.76rem;
  font-weight: 850;
}

.proposal-signature p {
  margin: 0 0 24px;
  color: #657180;
  font-size: 0.69rem;
  line-height: 1.45;
}

.proposal-signature__line {
  display: block;
  border-bottom: 1px solid #556272;
}

.proposal-signature__labels {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  color: #6b7684;
  font-size: 0.58rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.proposal-signature__name {
  display: block;
  margin-top: 5px;
  color: #45515f;
  font-size: 0.68rem;
}

.proposal-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 30px;
  padding: 15px 17px;
  background: #062a55;
  color: #ffffff;
  font-size: 0.65rem;
  line-height: 1.55;
}

.proposal-footer div {
  display: grid;
  gap: 1px;
}

.proposal-footer div:last-child {
  text-align: right;
}

.proposal-footer strong {
  color: #ffffff;
  font-family: var(--font-display, Montserrat, sans-serif);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.proposal-footer span {
  color: rgba(255, 255, 255, 0.8);
}

@media (max-width: 760px) {
  .estimate-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .proposal-preview-frame {
    margin-inline: -8px;
    padding: 8px;
  }

  .proposal-sheet {
    padding: 25px 19px 22px;
    border-top-width: 4px;
  }

  .proposal-letterhead {
    flex-direction: column;
    gap: 12px;
  }

  .proposal-logo {
    width: 205px;
    max-width: 82%;
  }

  .proposal-letterhead__right {
    text-align: left;
  }

  .proposal-cover__meta,
  .proposal-signatures {
    grid-template-columns: minmax(0, 1fr);
  }

  .proposal-cover__meta {
    gap: 10px;
  }

  .proposal-cover h2 {
    font-size: 1.5rem;
  }

  .proposal-section__head {
    flex-wrap: wrap;
    gap: 4px 9px;
  }

  .proposal-section__head h3 {
    flex: 1 1 65%;
  }

  .proposal-section__count {
    margin-left: 25px;
  }

  .scope-section {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
  }

  .scope-nav ol {
    grid-template-columns: minmax(0, 1fr);
  }

  .price-lines__head,
  .price-lines li,
  .price-total {
    gap: 8px;
  }

  .proposal-sheet .price-lines__head,
  .proposal-sheet .price-lines li,
  .proposal-sheet .price-total {
    grid-template-columns: minmax(0, 1fr);
  }

  .proposal-sheet .price-lines__head span:last-child,
  .proposal-sheet .price-total strong {
    display: none;
  }

  .proposal-sheet .price-total strong {
    display: block;
    margin-top: 2px;
  }

  .proposal-sheet .price-line__amount {
    justify-self: start;
  }

  .proposal-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .proposal-footer div:last-child {
    text-align: left;
  }
}

@media (prefers-color-scheme: dark) {
  .proposal-preview-frame {
    background:
      linear-gradient(135deg, rgba(212, 162, 60, 0.08), rgba(11, 92, 176, 0.09)),
      var(--surface-2);
  }

  .proposal-sheet {
    background: #ffffff;
    color: #25303d;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  .print-brand,
  .topbar,
  .tabs,
  .navbar,
  .nav-scrim,
  .content > header,
  .estimate-detail-head,
  .estimate-actions,
  .estimate-decision-card,
  .estimate-detail-stack > *:not(.proposal-preview-card) {
    display: none !important;
  }

  .content > *:not(.estimate-detail-stack):not(.proposal-preview-card) {
    display: none !important;
  }

  .content > .estimate-detail-stack,
  .estimate-detail-stack > .proposal-preview-card,
  .content > .proposal-preview-card {
    display: block !important;
  }

  html,
  body,
  .app,
  .app-body,
  .content,
  .estimate-detail-stack {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
  }

  .proposal-preview-card {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    break-inside: auto !important;
  }

  .proposal-preview-card > .card__head,
  .proposal-preview-card .card__note {
    display: none !important;
  }

  .proposal-preview-frame {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: #ffffff !important;
  }

  .proposal-sheet {
    width: 186mm !important;
    max-width: 186mm !important;
    margin: 0 !important;
    padding: 0 0 8mm !important;
    border: 0 !important;
    box-shadow: none !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .proposal-letterhead,
  .proposal-cover,
  .proposal-signatures,
  .proposal-footer,
  .proposal-section__head {
    break-inside: avoid;
  }

  .proposal-section,
  .scope-section {
    break-inside: auto;
  }

  .proposal-footer {
    margin-top: 10mm;
  }

  .proposal-sheet a {
    color: inherit;
    text-decoration: none;
  }
}

/* ==========================================================================
   Material pickup
   The checklist is deliberately one-column and thumb-sized on a phone. Counts
   stay visible while the item rows remain calm enough for use inside a store.
   ========================================================================== */

.pickup-host {
  margin: 16px 0;
}

.pickup {
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  min-width: 0;
}

.pickup__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pickup__title {
  margin: 2px 0 4px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--heading);
  overflow-wrap: anywhere;
}

.pickup__head p {
  margin: 0;
}

.pickup-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--label);
}

.pickup-tag--needed { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pickup-tag--picked { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pickup-tag--aside { background: var(--surface-3); color: var(--muted); }
.pickup-tag--missing { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.pickup-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 10px;
}

.pickup-counts div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.pickup-counts strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--heading);
}

.pickup-counts span {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.pickup-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.pickup-progress progress {
  flex: 1;
  height: 8px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-3);
}

.pickup-progress progress::-webkit-progress-bar { background: var(--surface-3); }
.pickup-progress progress::-webkit-progress-value { background: var(--gold); border-radius: 999px; }
.pickup-progress progress::-moz-progress-bar { background: var(--gold); border-radius: 999px; }

.pickup-progress span {
  flex: 0 0 auto;
  font-size: 0.74rem;
  color: var(--muted);
}

.pickup-active,
.pickup-followup {
  margin-top: 8px;
}

.pickup-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pickup-section-head h5,
.pickup-followup > h5 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.94rem;
  color: var(--heading);
}

.pickup-group {
  margin-top: 10px;
}

.pickup-group__title {
  margin: 0 0 5px;
  padding: 0 2px;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--muted);
}

.pickup-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pickup-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

.pickup-item--purchased {
  border-left: 3px solid var(--ok);
}

.pickup-item--not_needed,
.pickup-item--not_found {
  border-left: 3px solid var(--warn);
}

.pickup-item__lead {
  min-width: 0;
}

.pickup-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  min-height: 42px;
  padding: 2px 0;
}

.pickup-check input {
  width: 24px;
  height: 24px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--ok);
}

.pickup-check--static {
  cursor: default;
}

.pickup-check__label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pickup-check__label strong {
  color: var(--heading);
  font-size: 0.9rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.pickup-check__label small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.pickup-item__reason {
  color: var(--warn);
}

.pickup-dot {
  width: 12px;
  height: 12px;
  margin: 7px 6px 0;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--border-strong);
}

.pickup-item--purchased .pickup-dot { background: var(--ok); }
.pickup-item--not_needed .pickup-dot,
.pickup-item--not_found .pickup-dot { background: var(--warn); }

.pickup-item__actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pickup-move {
  position: relative;
}

.pickup-move > summary {
  list-style: none;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--label);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.pickup-move > summary::-webkit-details-marker { display: none; }
.pickup-move > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.pickup-move__menu {
  position: absolute;
  z-index: 4;
  right: 0;
  top: calc(100% + 4px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 132px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.pickup-move__menu .btn {
  justify-content: flex-start;
  text-align: left;
  min-height: 36px;
}

.pickup-item__details {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--border);
  padding-top: 4px;
}

.pickup-item__details > summary {
  cursor: pointer;
  padding: 3px 0;
  font-size: 0.73rem;
  font-weight: 650;
  color: var(--muted);
}

.pickup-item__details > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.pickup-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.pickup-fields label {
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--label);
}

.pickup-fields input {
  margin-top: 3px;
  width: 100%;
}

.pickup-fields__wide {
  grid-column: 1 / -1;
}

.pickup-receipt {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

.pickup-receipt label {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--label);
}

.pickup-receipt input { margin-top: 3px; max-width: 100%; }

.pickup-receipts {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.78rem;
}

.pickup-receipts a {
  color: var(--blue-600);
  overflow-wrap: anywhere;
}

.pickup-aside {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 0 10px 10px;
}

.pickup-aside > summary {
  cursor: pointer;
  padding: 10px 2px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--label);
}

.pickup-aside > summary span {
  display: inline-flex;
  min-width: 22px;
  justify-content: center;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.72rem;
}

.pickup-aside__list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pickup-aside__item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.pickup-aside__item p {
  margin: 0;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.pickup-aside__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pickup-finish {
  margin-top: 16px;
  padding: 14px;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: var(--surface);
}

.pickup-finish__notes {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--label);
}

.pickup-finish__notes textarea {
  margin-top: 4px;
  width: 100%;
}

.pickup-finish .form-hint {
  margin: 8px 0 10px;
}

.pickup-finish__button {
  width: 100%;
  min-height: 52px;
  font-size: 1rem;
  font-weight: 800;
}

.pickup-foot {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

/* Internal report. It keeps a white-paper reading surface in both themes. */
.pickup-report {
  margin-top: 16px;
  padding: 18px;
  border-radius: 10px;
  border: 1px solid #d8dee8;
  background: #fff;
  color: #16243a;
  overflow-wrap: anywhere;
}

.pickup-report__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid #16243a;
}

.pickup-report__head > div {
  min-width: 0;
  flex: 1 1 190px;
}

.pickup-report__brand {
  margin: 0 0 2px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #796021;
}

.pickup-report__head h4 {
  margin: 0 0 3px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: #16243a;
  overflow-wrap: normal;
  word-break: normal;
}

.pickup-report__head p {
  margin: 0;
}

.pickup-report__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.pickup-report__meta div {
  min-width: 0;
}

.pickup-report__meta dt {
  margin-bottom: 2px;
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #657188;
}

.pickup-report__meta dd {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 650;
}

.pickup-report__sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pickup-report__section {
  border: 1px solid #d8dee8;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.pickup-report__section h6 {
  margin: 0 0 7px;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #16243a;
}

.pickup-report__section h6 span {
  color: #657188;
}

.pickup-report__section ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pickup-report__section li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 10px;
  border-left: 2px solid #d4a72c;
  font-size: 0.8rem;
}

.pickup-report__section li small {
  color: #657188;
  font-size: 0.7rem;
}

.pickup-report__notes {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: #f4f7fb;
}

.pickup-report__notes h6 {
  margin: 0 0 3px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pickup-report__notes p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.pickup-report__foot {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid #d8dee8;
  font-size: 0.72rem;
  line-height: 1.5;
  color: #657188;
}

@media (max-width: 640px) {
  .pickup {
    padding: 12px;
  }

  .pickup__head {
    gap: 8px;
  }

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

  .pickup-item {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
  }

  .pickup-item__actions {
    justify-content: flex-start;
    padding-left: 34px;
  }

  .pickup-check {
    min-height: 48px;
  }

  .pickup-check input {
    width: 28px;
    height: 28px;
  }

  .pickup-dot {
    margin-top: 9px;
  }

  .pickup-move__menu {
    right: auto;
    left: 0;
  }

  .pickup-receipt .btn,
  .pickup-fields .btn {
    flex: 1 1 100%;
    min-height: 44px;
  }

  .pickup-aside__actions {
    width: 100%;
    justify-content: space-between;
  }

  .pickup-aside__actions .btn {
    min-height: 44px;
  }

  .pickup-report {
    padding: 14px 12px;
  }

  .pickup-report__sections {
    grid-template-columns: minmax(0, 1fr);
  }
}

body.pickup-report-print .topbar,
body.pickup-report-print .navbar,
body.pickup-report-print .tabs,
body.pickup-report-print .pickup__head,
body.pickup-report-print .pickup-counts,
body.pickup-report-print .pickup-progress,
body.pickup-report-print .pickup-active,
body.pickup-report-print .pickup-aside,
body.pickup-report-print .pickup-finish,
body.pickup-report-print .pickup-followup,
body.pickup-report-print .pickup-foot {
  display: none !important;
}

@media print {
  body.pickup-report-print {
    background: #fff;
  }

  body.pickup-report-print .content {
    padding: 0;
    margin: 0;
  }

  body.pickup-report-print .pickup {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  body.pickup-report-print .pickup-report {
    border: 0;
    padding: 0;
    break-inside: avoid;
  }
}

.pickup-history {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

.pickup-history > summary {
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}

.pickup-history ol {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pickup-history li {
  display: grid;
  gap: 1px;
  padding-left: 10px;
  border-left: 2px solid var(--border-strong);
  font-size: 0.75rem;
}

.pickup-history__when {
  color: var(--muted);
  font-size: 0.68rem;
}

.pickup-history__who {
  font-weight: 700;
  color: var(--label);
}

.pickup-history__what {
  color: var(--text);
  overflow-wrap: anywhere;
}

.pickup-history__what small {
  color: var(--muted);
}

/* Standalone guest estimate page. Kept external so the Worker CSP allows it. */
      .guest-shell { min-height: 100vh; background: #f3f6fa; padding: 24px 16px 64px; }
      .guest-wrap { width: min(920px, 100%); margin: 0 auto; }
      .guest-brand { display: block; width: min(330px, 82vw); height: auto; margin: 8px 0 24px; }
      .guest-card { background: #fff; border: 1px solid #dbe3ee; border-radius: 18px; padding: clamp(20px, 4vw, 40px); box-shadow: 0 18px 50px rgba(6, 42, 85, .08); }
      .guest-kicker { color: #8b6a1f; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 8px; }
      .guest-title { color: #062a55; font-size: clamp(28px, 5vw, 44px); line-height: 1.05; margin: 0 0 8px; }
      .guest-sub { color: #5d6c80; margin: 0 0 24px; }
      .guest-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; padding: 18px 0; border-top: 1px solid #e4eaf2; border-bottom: 1px solid #e4eaf2; margin-bottom: 24px; }
      .guest-meta span { display: block; color: #728196; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
      .guest-meta strong { color: #062a55; font-size: 18px; }
      .guest-section { margin: 28px 0; }
      .guest-section h2 { color: #062a55; font-size: 19px; margin: 0 0 10px; }
      .guest-items { width: 100%; border-collapse: collapse; font-size: 14px; }
      .guest-items th, .guest-items td { padding: 10px 8px; border-bottom: 1px solid #e8edf4; text-align: left; }
      .guest-items th:last-child, .guest-items td:last-child { text-align: right; }
      .guest-total { display: flex; justify-content: space-between; gap: 16px; padding: 18px 0 0; font-size: 22px; font-weight: 800; color: #062a55; }
      .guest-note { background: #f7f2e4; border: 1px solid #e7d6a4; border-radius: 12px; padding: 14px 16px; color: #594718; font-size: 14px; }
      .guest-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
      .guest-field { display: block; margin: 14px 0; font-weight: 600; color: #25364d; }
      .guest-field input, .guest-field textarea { display: block; width: 100%; margin-top: 6px; padding: 12px; border: 1px solid #cbd6e4; border-radius: 10px; font: inherit; font-weight: 400; }
      .guest-check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; color: #33465f; font-size: 14px; }
      .guest-check input { margin-top: 3px; }
      .guest-btn { display: inline-block; box-sizing: border-box; max-width: 100%; border: 0; border-radius: 10px; padding: 13px 20px; font: inherit; font-weight: 700; line-height: 1.25; text-align: center; text-decoration: none; cursor: pointer; background: #062a55; color: #fff; }
      .guest-success .guest-btn { display: block; width: 100%; }
      .guest-btn--ghost { background: #fff; color: #062a55; border: 1px solid #b9c7d9; }
      .guest-btn--danger { background: #fff; color: #9b2c2c; border: 1px solid #e0b4b4; }
      .guest-btn[disabled] { opacity: .55; cursor: wait; }
      .guest-error { color: #9b2c2c; background: #fdf1f1; border: 1px solid #efcaca; border-radius: 10px; padding: 12px 14px; margin: 14px 0; }
      .guest-success { color: #14532d; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 14px 16px; margin: 14px 0; }
      .guest-foot { color: #728196; font-size: 12px; text-align: center; margin-top: 22px; }
      @media (max-width: 640px) { .guest-shell { padding: 14px 10px 40px; } .guest-card { border-radius: 14px; } }

/* Owner-only Investment Portal link: the anchor uses the same menu rhythm as
   the buttons, without borrowing button semantics. */
.tabs a.nav__item--external {
  text-decoration: none;
}

/* Project milestone type: staff-confirmed categories, never inferred. */
.plan-category-options {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.4rem;
}
.plan-category-options .check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line, #d8dde5);
  border-radius: 0.5rem;
}
.plan-category-options .check-row input {
  margin-top: 0.2rem;
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
}
.plan-category-options .check-row input {
  flex: 0 0 1rem;
  inline-size: 1rem;
  block-size: 1rem;
  width: 1rem;
  min-width: 1rem;
  padding: 0;
  margin-top: 0.2rem;
}
.plan-category-options .check-row > span {
  flex: 1 1 auto;
  min-width: 0;
}
@media (max-width: 720px) {
  .plan-card .stat-grid {
    grid-template-columns: 1fr;
  }
  .plan-card .card__head {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
}

/* Checklist settings stay out of the normal checklist: one collapsed control,
   compact category tiles and no oversized form taking over the milestone list. */
.plan-category-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.plan-settings__body {
  display: grid;
  gap: 1rem;
}
.plan-settings__body > .subhead {
  margin-bottom: 0;
}
.plan-settings__body > .subhead:not(:first-child) {
  border-top: 1px solid var(--line, #d8dde5);
  padding-top: 1rem;
}
@media (max-width: 900px) {
  .plan-category-options {
    grid-template-columns: 1fr;
  }
}

/* Project milestone tracker restored as a visible timeline, with task progress
   and review controls kept outside the collapsed configuration drawer. */
.plan-progress {
  display: grid;
  gap: 0.3rem;
  margin: 0.15rem 0 0.55rem;
}
.plan-progress__meta,
.plan-milestone__progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.74rem;
}
.plan-progress__meta strong,
.plan-milestone__progress-meta strong {
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}
.plan-progress progress,
.plan-milestone__progress progress {
  width: 100%;
}
.plan-timeline {
  margin-top: 0.2rem;
}
.plan-timeline .timeline__item {
  grid-template-columns: 18px minmax(0, 1fr);
  padding: 0.85rem 0;
}
.plan-timeline .timeline__body {
  min-width: 0;
}
.plan-milestone__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
}
.plan-milestone__heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.45rem;
  min-width: 0;
}
.plan-milestone__heading .timeline__title {
  flex: 0 1 auto;
  font-size: 0.9rem;
}
.plan-milestone__actions {
  flex: 0 0 auto;
}
.plan-milestone__progress {
  display: grid;
  gap: 0.2rem;
  margin-top: 0.45rem;
}
.plan-milestone__progress--empty {
  margin-top: 0.35rem;
}
.plan-milestone__detail {
  margin-top: 0.45rem;
}
.plan-milestone__detail > summary {
  color: var(--primary);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
}
.plan-milestone__detail[open] > summary {
  margin-bottom: 0.6rem;
}
.plan-source {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.plan-task {
  align-items: start;
}
.plan-task__form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  width: 100%;
}
.plan-task__check {
  display: flex;
  align-items: flex-start;
  flex: 1 1 16rem;
  gap: 0.45rem;
  min-width: 0;
}
.plan-task__check input {
  flex: 0 0 auto;
  margin-top: 0.2rem;
}
.plan-task__label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.plan-task__label--done {
  color: var(--muted);
  text-decoration: line-through;
}
.plan-task__form select {
  max-width: 10rem;
}
.plan-task__form input[name='note'] {
  flex: 1 1 10rem;
  min-width: 7rem;
  width: auto;
}
.plan-task--done {
  background: var(--surface-3, #f7f9fc);
}
.mini-tag--review {
  border-color: #e7d6a4;
  background: #fff7e6;
  color: #8b6a1f;
}
@media (max-width: 720px) {
  .plan-milestone__actions {
    width: 100%;
  }
  .plan-milestone__actions .link-btn {
    padding-left: 0;
  }
  .plan-task__form select,
  .plan-task__form input[name='note'] {
    max-width: none;
    width: 100%;
  }
}
.plan-milestone__actions .link-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ------------------------------------------------ referrals & customer wish list
   Customer-created future-project ideas and the office review queue. The photo
   thumbnails stay small so one idea cannot push the page wider than a phone. */
.wishlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 16px;
  align-items: start;
}
.wishlist-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.wishlist-code {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--navy-800);
  margin: 6px 0 14px;
  overflow-wrap: anywhere;
}
.wishlist-form { margin-top: 14px; }
.wishlist-review { margin: 14px 0; }
.wishlist-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.wishlist-photo {
  width: 108px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.button-row--tight { gap: 8px; }
.intake-page .auth-card { max-height: none; }
@media (max-width: 520px) {
  .wishlist-grid { grid-template-columns: 1fr; }
  .wishlist-code { font-size: 1.35rem; }
}
@media (max-width: 600px) {
  /* Keep currency figures on one line in the two-column stat grid. */
  .stat__value {
    font-size: clamp(1.2rem, 1rem + 1vw, 1.5rem);
    white-space: nowrap;
    overflow-wrap: normal;
  }
}
@media (max-width: 560px) {
  /* Give large currency amounts the full card width instead of forcing a
     second column that cannot fit them. */
  .stat-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  /* Prevent four very narrow stat columns from clipping large amounts. */
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* Simplified master work-order field view */
.field-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
  margin: 18px 0;
}
.field-summary__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--navy-800);
  border-radius: 12px;
  padding: 16px;
}
.field-summary__card span { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.field-summary__card strong { display: block; font-family: var(--font-display); font-size: 2rem; line-height: 1.1; margin: 4px 0 8px; }
.field-summary__card p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.field-summary__card--done { border-left-color: #2f7d4f; }
.field-summary__card--current { border-left-color: #c27a12; background: #fffaf0; }
.field-summary__card--remaining { border-left-color: #8a94a6; }
.field-task-groups { display: grid; gap: 18px; margin: 20px 0; }
.field-task-group { display: grid; gap: 10px; }
.field-task-group__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.field-task-group__head h2 { font-family: var(--font-display); font-size: 1.2rem; margin: 0; }
.field-task-group__head p { margin: 2px 0 0; }
.field-task-group__count { min-width: 32px; text-align: center; background: var(--surface-2); border-radius: 999px; padding: 4px 9px; font-weight: 700; }
.field-task {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #8a94a6;
  border-radius: 12px;
  padding: 14px 16px;
}
.field-task.is-complete { border-left-color: #2f7d4f; }
.field-task.is-current { border-left-color: #c27a12; }
.field-task__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.field-task__head h3 { margin: 0; font-size: 1rem; letter-spacing: 0.02em; }
.field-task__head p { margin: 3px 0 0; }
.field-task__update { margin-top: 12px; }
.field-task__update > summary { cursor: pointer; font-weight: 700; font-size: 0.88rem; color: var(--navy-800); }
.field-task__update form { margin-top: 10px; }
.field-task__photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.field-task__photos img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.field-admin { margin-top: 18px; }

/* ==========================================================================
   Communications Hub — compact business-record picker
   Replaces the native parent-record select with a searchable, filterable
   panel. Tokens keep the panel readable in light and dark mode; the selected
   record is repeated above the confirmation button so it is never ambiguous.
   ========================================================================== */

/* The Unmatched Mail card normally clips its rounded corners. The picker's
   confirmation footer must be able to stick to the viewport on a phone. */
#comms-unmatched,
#comms-unmatched .comms-fold__body { overflow: visible; }

.comms-link-picker {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: visible;
}

.comms-link-picker > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--info);
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.comms-link-picker > summary::-webkit-details-marker { display: none; }
.comms-link-picker > summary::before { content: '▸'; flex: 0 0 auto; font-size: 12px; }
.comms-link-picker[open] > summary::before { content: '▾'; }
.comms-link-picker > summary:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.comms-link-picker__title { flex: 1 1 auto; }
.comms-link-picker__hint { color: var(--muted); font-size: 12px; font-weight: 500; }

.comms-link-picker__body {
  border-top: 1px solid var(--border);
  padding: 12px;
}

.comms-link-picker--empty { padding: 10px 12px; border-style: dashed; }
.comms-link-picker--empty .form-hint { margin: 0; }

.comms-link-form { display: grid; gap: 10px; }
.comms-link-search-row { display: flex; align-items: flex-end; gap: 8px; }
.comms-link-search { display: grid; flex: 1 1 auto; gap: 4px; min-width: 0; font-size: 12px; font-weight: 650; color: var(--label); }
.comms-link-search input {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 9px 10px;
}
.comms-link-search input:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
.comms-link-count { padding-bottom: 12px; color: var(--muted); font-size: 12px; white-space: nowrap; }

.comms-link-filters { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 1px; }
.comms-link-filter {
  flex: 1 0 auto;
  min-height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--label);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
}
.comms-link-filter span { color: var(--muted); font-weight: 500; }
.comms-link-filter[aria-pressed="true"] { background: var(--info-soft); border-color: var(--info); color: var(--info); font-weight: 700; }
.comms-link-filter:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }

.comms-link-suggestions {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--info) 34%, var(--border));
  border-radius: 8px;
  background: var(--info-soft);
}
.comms-link-suggestions h4 { margin: 0; color: var(--info); font-size: 13px; }
.comms-link-suggestions .form-hint { margin: 0; color: var(--label); font-size: 12px; }
.comms-link-suggestions .comms-link-option { border-color: var(--border); }

.comms-link-result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--info);
  border-radius: 8px;
  background: var(--info-soft);
}
.comms-link-result[hidden] { display: none; }
.comms-link-result__label { grid-column: 1 / -1; color: var(--info); font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.comms-link-result strong { color: var(--heading); font-size: 14px; overflow-wrap: anywhere; }
.comms-link-result span:not(.comms-link-result__label) { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.comms-link-result .link-btn { grid-column: 2; grid-row: 2 / span 2; align-self: center; }

.comms-link-none, .comms-link-empty { margin: 0; color: var(--muted); font-size: 12px; }
.comms-link-empty[hidden], .comms-link-none[hidden] { display: none; }

.comms-link-list {
  display: grid;
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overscroll-behavior: contain;
}
.comms-link-option {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  box-sizing: border-box;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  padding: 9px 10px;
  cursor: pointer;
}
.comms-link-option:last-child { border-bottom: 0; }
.comms-link-option:hover { background: var(--surface-2); }
.comms-link-option:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.comms-link-option[aria-pressed="true"] { background: var(--info-soft); box-shadow: inset 3px 0 0 var(--info); }
.comms-link-option[hidden] { display: none; }
.comms-link-option__copy { display: grid; gap: 2px; min-width: 0; flex: 1 1 auto; }
.comms-link-option__name { color: var(--heading); font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.comms-link-option__meta { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.comms-link-option__reason { color: var(--info); font-size: 11px; line-height: 1.3; }
.comms-link-option__type {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--label);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.comms-link-footer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 calc(2px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.comms-link-footer .form-hint { margin: 0; font-size: 11px; }
.comms-link-footer__actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.comms-link-footer__actions .btn, .comms-link-footer__actions .link-btn { min-height: 44px; }
.comms-link-footer__actions .btn { white-space: nowrap; }
.comms-link-footer__actions .btn:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 640px) {
  .comms-link-picker__hint { display: none; }
  .comms-link-picker__body { padding: 10px; }
  .comms-link-search-row { display: grid; gap: 4px; }
  .comms-link-count { padding: 0; }
  .comms-link-result { grid-template-columns: 1fr; }
  .comms-link-result .link-btn { grid-column: 1; grid-row: auto; justify-self: start; min-height: 36px; }
  .comms-link-footer { flex-direction: column; align-items: stretch; gap: 8px; }
  .comms-link-footer__actions { display: grid; grid-template-columns: 1fr 1.4fr; }
  .comms-link-footer__actions .btn, .comms-link-footer__actions .link-btn { width: 100%; }
  .comms-link-list { max-height: 270px; }
}

@media (max-width: 360px) {
  .comms-link-filters { gap: 4px; }
  .comms-link-filter { padding: 7px 8px; font-size: 11px; }
  .comms-link-option { gap: 5px; }
  .comms-link-option__type { font-size: 9px; }
}


@media (max-width: 480px) {
  .comms-link-filters { flex-wrap: wrap; overflow: visible; }
  .comms-link-filter { flex: 1 1 calc(50% - 4px); }
}

/* ------------------------------------------------------ estimate workflow */
.estimate-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0 18px;
}
.estimate-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.estimate-step__number {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  background: var(--border);
  color: var(--heading);
  font-size: 11px;
}
.estimate-step.is-current {
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  color: var(--heading);
}
.estimate-step.is-current .estimate-step__number {
  background: var(--gold);
  color: var(--navy-900);
}
.estimate-step.is-done { color: var(--ok); }
.estimate-step.is-done .estimate-step__number { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--ok); }
.estimate-workflow__body {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.65fr);
  gap: 18px;
  align-items: start;
}
.estimate-workflow__facts {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.estimate-workflow__facts div { display: grid; gap: 2px; }
.estimate-workflow__facts dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.estimate-workflow__facts dd { margin: 0; color: var(--heading); font-weight: 600; font-size: 13px; }
.estimate-admin-tools > summary,
.estimate-attachments > summary {
  cursor: pointer;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.estimate-admin-tools[open] > summary,
.estimate-attachments[open] > summary { margin-bottom: 12px; }
.estimate-admin-tools > section,
.estimate-attachments > section { margin: 0; }
.deposit-summary {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  padding: 14px;
}
.deposit-summary__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.deposit-summary__label { font-family: var(--font-display); font-weight: 700; color: var(--heading); }
.deposit-summary__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.deposit-summary__grid div { display: grid; gap: 3px; padding: 8px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.deposit-summary__grid span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.deposit-summary__grid strong { color: var(--heading); font-size: 14px; overflow-wrap: anywhere; }
.deposit-summary__terms { margin: 12px 0 0; color: var(--label); font-size: 13px; }
.deposit-summary__note,
.deposit-summary__request { margin-top: 10px; padding: 10px; border-radius: 8px; background: var(--surface-3); font-size: 13px; }
.deposit-summary__request p { margin: 4px 0 0; }
.deposit-summary--compact .deposit-summary__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) {
  .estimate-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .estimate-step:last-child { grid-column: 1 / -1; }
  .estimate-workflow__body { grid-template-columns: 1fr; }
  .deposit-summary__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
