:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-muted: #f3f5f7;
  --text: #18212b;
  --muted: #6b7682;
  --line: #dfe4ea;
  --line-soft: #edf0f3;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --danger: #b42318;
  --success: #147a45;
  --warning: #9a5b13;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(24, 33, 43, 0.04);
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  max-width: 100%;
}

.app-sidebar {
  width: 240px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.app-brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.app-brand strong,
.app-sidebar__footer strong {
  display: block;
  font-weight: 500;
}

.app-brand > div,
.app-sidebar__footer > div {
  min-width: 0;
}

.app-brand strong,
.app-brand small,
.app-sidebar__footer strong,
.app-sidebar__footer small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-brand small,
.app-sidebar__footer small,
.muted {
  color: var(--muted);
}

.app-nav {
  display: grid;
  gap: 2px;
}

.app-nav__group {
  display: grid;
  gap: 2px;
}

.app-nav__group + .app-nav__group {
  margin-top: 14px;
}

.app-nav__heading {
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.app-nav__link {
  color: var(--text);
  padding: 8px 9px;
  border-radius: 5px;
  font-weight: 500;
}

.app-nav__link:hover,
.app-nav__link--active {
  background: var(--panel-muted);
  text-decoration: none;
}

.app-sidebar__footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.app-main {
  width: calc(100% - 240px);
  padding: 24px;
}

.app-main > .grid,
.app-main > .panel,
.app-main > .toolbar,
.app-main > .selection-bar,
.app-main > form.panel {
  margin-bottom: var(--space-4);
}

.auth-main {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-header--compact {
  margin-bottom: 14px;
}

.page-header h1,
.page-header h2 {
  margin: 0 0 3px;
  font-weight: 500;
  letter-spacing: 0;
}

.page-header h1 {
  font-size: 24px;
}

.page-header h2 {
  font-size: 18px;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

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

.panel {
  padding: 16px;
}

.auth-card {
  width: min(400px, 100%);
  padding: 26px;
}

.auth-card h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
}

.auth-card p {
  margin: 8px 0 22px;
  color: var(--muted);
}

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-card__secondary-action {
  margin-top: 10px;
}

.auth-form {
  gap: 12px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.metric small {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.metric strong {
  font-size: 22px;
  font-weight: 500;
}

.metric__value {
  min-height: 32px;
  display: flex;
  align-items: center;
}

.table-wrap {
  overflow-x: auto;
}

.payment-plan {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.payment-plan__scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.payment-plan__table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}

.payment-plan__table th,
.payment-plan__table td {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.2;
  min-width: 88px;
  max-width: 88px;
  height: 38px;
  padding: 8px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  vertical-align: middle;
  scroll-snap-align: start;
}

.payment-plan__label {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 172px !important;
  max-width: 172px !important;
  text-align: left !important;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
  color: var(--muted);
  font-weight: 500;
}

.payment-plan__year {
  text-align: center !important;
  background: #f7f9fb;
  color: #4b5563;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.payment-plan__month {
  color: #5b6674;
  font-weight: 600;
}

.payment-plan__cell--paid {
  background: #eefaf3;
  color: #166534;
}

.payment-plan__cell--partial {
  background: #fff8e6;
  color: #8a5a00;
}

.payment-plan__cell--overdue {
  background: #fff1f2;
  color: #b42318;
}

.payment-plan__cell--future {
  background: #ffffff;
  color: var(--text);
}

.payment-plan__cell--advance {
  background: #eff6ff;
  color: #1d4ed8;
}

.payment-plan__cell--current {
  box-shadow: inset 0 3px 0 var(--primary);
}

.payment-plan__status-dot {
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.payment-plan__status-dot--paid {
  background: #16a34a;
}

.payment-plan__status-dot--partial {
  background: #d97706;
}

.payment-plan__status-dot--overdue {
  background: #dc2626;
}

.payment-plan__status-dot--future {
  background: #94a3b8;
}

.payment-plan__status-dot--advance {
  background: #2563eb;
}

/* Portfolio planning grid — every contract's plan in one table. Shares the
   payment-plan status palette so a cell means the same thing on both pages. */
.planning-grid__scroll {
  overflow-x: auto;
  scroll-snap-type: x proximity;
}

.planning-grid__table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
}

.planning-grid__table th,
.planning-grid__table td {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.25;
  min-width: 112px;
  max-width: 112px;
  height: 44px;
  padding: 5px 10px;
  white-space: nowrap;
  /* Cells are fixed-width: clip long figures instead of letting them run into
     the neighbouring column. */
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  vertical-align: middle;
  scroll-snap-align: start;
}

.planning-grid__label {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 240px !important;
  max-width: 240px !important;
  text-align: left !important;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planning-grid__period {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fb;
  color: #4b5563;
  font-weight: 600;
  text-align: center !important;
}

/* The value and total columns carry portfolio-wide sums, so they need room
   for figures an order of magnitude larger than a single period's. */
.planning-grid__value,
.planning-grid__total {
  min-width: 136px !important;
  max-width: 136px !important;
}

.planning-grid__zoom {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
}

.planning-grid__zoom:hover {
  color: var(--primary);
}

/* Location rows are the collapsed overview; contract rows open beneath them. */
.planning-grid__group {
  cursor: pointer;
  background: #fbfcfd;
  font-weight: 600;
}

.planning-grid__group:hover {
  background: #f2f6fa;
}

.planning-grid__caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 8px;
  border-left: 5px solid var(--muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.12s ease;
  vertical-align: middle;
}

.planning-grid__group.is-open .planning-grid__caret {
  transform: rotate(90deg);
}

.planning-grid__contract {
  display: none;
}

.planning-grid__contract.is-open {
  display: table-row;
}

.planning-grid__contract .planning-grid__label {
  padding-left: 26px;
  font-weight: 400;
}

.planning-grid__cell--paid {
  background: #eefaf3;
  color: #166534;
}

.planning-grid__cell--partial {
  background: #fff8e6;
  color: #8a5a00;
}

.planning-grid__cell--overdue {
  background: #fff1f2;
  color: #b42318;
}

.planning-grid__cell--future {
  background: #ffffff;
  color: var(--text);
}

.planning-grid__cell--advance {
  background: #eff6ff;
  color: #1d4ed8;
}

.planning-grid__cell--current {
  box-shadow: inset 0 3px 0 var(--primary);
}

/* Secondary "collected" figure stacked under the planned amount. */
.planning-grid__collected {
  color: #166534;
  font-size: 10px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planning-grid__totals {
  background: var(--panel);
  position: sticky;
  bottom: 0;
}

.planning-grid__note {
  padding: 10px 4px 0;
}

.planning-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.planning-legend__item {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 6px;
}

.panel--warning {
  border-color: #f1c96b;
  background: #fffaf0;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel > .page-header {
  margin-bottom: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.import-section {
  border-left-width: 3px;
}

.import-section--review {
  border-left-color: #d97706;
}

.import-section--ready {
  border-left-color: var(--success);
}

.import-section--excluded {
  border-left-color: #64748b;
}

.import-section--error {
  border-left-color: var(--danger);
}

.hidden-form-stack {
  display: none;
}

.review-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  background: #ffffff;
}

.review-table {
  min-width: 2000px;
  table-layout: fixed;
}

.review-table--summary {
  min-width: 1360px;
}

.review-table th,
.review-table td {
  vertical-align: middle;
}

.review-table th {
  white-space: normal;
}

.review-table td {
  height: 54px;
}

.review-table__col--id {
  width: 112px;
}

.review-table__col--row {
  width: 76px;
}

.review-table__col--transaction {
  width: 150px;
}

.review-table__col--date {
  width: 136px;
}

.review-table__col--reference {
  width: 190px;
}

.review-table__col--money {
  width: 116px;
}

.review-table__col--person {
  width: 180px;
}

.review-table__col--email {
  width: 220px;
}

.review-table__col--phone {
  width: 150px;
}

.review-table__col--code {
  width: 140px;
}

.review-table__col--status {
  width: 150px;
}

.review-table__col--status-text {
  width: 140px;
}

.review-table__col--reason {
  width: 220px;
}

.review-table__col--approve {
  width: 82px;
}

.review-table__sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line-soft);
}

.review-table__issues {
  color: var(--muted);
  font-size: 13px;
}

.review-table__changed td {
  background: #fffaf0;
}

.review-table__changed .review-table__sticky {
  background: #fffaf0;
}

.review-table__pending-save td,
.review-table__pending-save .review-table__sticky {
  background: #fffbeb;
}

.review-table__save-error td,
.review-table__save-error .review-table__sticky {
  background: #fff3f3;
}

.import-row--ready td,
.import-row--ready .review-table__sticky {
  background: #fbfefc;
}

.review-table .table-input {
  min-width: 0;
}

/* Rows that need approval render as cards instead of a wide table row, so the
   reason and the approve button stay visible without horizontal scrolling. */
.import-cards {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.import-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.import-card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: #fffbeb;
  border-bottom: 1px solid var(--line-soft);
}

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

.import-card__row-number {
  font-size: 12px;
  color: var(--muted);
}

.import-card__title {
  font-size: 15px;
}

.import-card__reason {
  margin: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: #92400e;
  font-size: 13px;
}

.import-card__reason::before {
  content: "⚠";
  margin-right: 6px;
}

.import-card__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
  padding: 14px;
}

.import-card__field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.import-card__field > label {
  font-size: 12px;
  color: var(--muted);
}

.import-card__field .table-input {
  min-width: 0;
  border-color: var(--line-soft);
  background: #ffffff;
}

.import-card__more {
  border-top: 1px solid var(--line-soft);
}

.import-card__more > summary {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}

.import-card__more > summary::-webkit-details-marker {
  display: none;
}

.import-card__more > summary::before {
  content: "▸";
  margin-right: 6px;
}

.import-card__more[open] > summary::before {
  content: "▾";
}

.import-card__more > .import-card__fields {
  padding-top: 0;
}

/* State classes are set by the shared import-row-autosave controller. */
.import-card.review-table__changed {
  border-color: #f0b429;
}

.import-card.review-table__pending-save {
  border-color: #f0b429;
}

.import-card.review-table__save-error {
  border-color: var(--danger);
}

.approve-toggle {
  display: inline-block;
  cursor: pointer;
}

.approve-toggle__input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.approve-toggle__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--success);
  border-radius: 999px;
  background: #ffffff;
  color: var(--success);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.approve-toggle__box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1.5px solid currentColor;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1;
}

.approve-toggle__box::after {
  content: "✓";
  opacity: 0;
}

.approve-toggle__text--on {
  display: none;
}

.approve-toggle__input:checked ~ .approve-toggle__pill .approve-toggle__text--off {
  display: none;
}

.approve-toggle__input:checked ~ .approve-toggle__pill .approve-toggle__text--on {
  display: inline;
}

.approve-toggle__input:checked ~ .approve-toggle__pill {
  border-color: var(--success);
  background: var(--success);
  color: #ffffff;
}

.approve-toggle__input:checked ~ .approve-toggle__pill .approve-toggle__box::after {
  opacity: 1;
}

.approve-toggle__input:focus-visible ~ .approve-toggle__pill {
  outline: 2px solid #7aa7d9;
  outline-offset: 2px;
}

.approve-toggle__input:disabled ~ .approve-toggle__pill {
  border-color: var(--line-soft);
  background: var(--line-soft);
  color: var(--muted);
  cursor: default;
}

.table-input {
  width: 100%;
  min-width: 150px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 7px 8px;
  background: transparent;
  font: inherit;
}

.table-input:focus {
  border-color: #7aa7d9;
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(34, 119, 199, 0.12);
}

.number-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.button--compact {
  padding: 7px 10px;
}

.center {
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

th {
  color: #56616d;
  font-size: 12px;
  font-weight: 500;
  background: #fafbfc;
}

tbody tr:hover {
  background: #fbfcfd;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.data-table {
  min-width: 980px;
}

.select-cell {
  width: 42px;
  text-align: center;
}

.table-link {
  color: var(--text);
  font-weight: 500;
}

.number-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.document-upload-cell {
  display: grid;
  gap: 8px;
  min-width: 260px;
}

.document-upload-cell--compact {
  min-width: 180px;
  gap: 5px;
}

.document-upload-cell__status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.document-upload-cell__status small {
  color: var(--muted);
}

.document-upload-cell__issue {
  flex-basis: 100%;
  color: var(--warning) !important;
}

.document-upload-cell--compact .document-upload-cell__issue {
  max-width: 220px;
}

.document-upload-cell__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.document-upload-cell__actions .hint {
  margin: 0;
}

.inline-upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: end;
}

.inline-upload-form__notice {
  flex-basis: 100%;
  text-align: right;
}

.inline-upload-form__progress {
  flex-basis: 100%;
  justify-content: center;
  padding-block: 12px;
  font-size: 1rem;
  cursor: progress;
}

.inline-upload-form__progress[disabled] {
  opacity: 1;
}

.document-upload-cell--compact .inline-upload-form {
  gap: 4px;
  justify-content: left;
}

.contract-batch-launcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.contract-batch-launcher h2,
.contract-batch-launcher p {
  margin: 0;
}

.contract-batch-launcher p {
  margin-top: 4px;
  color: var(--muted);
}

.contract-document-batch-workspace {
  display: grid;
  gap: 16px;
}

.contract-document-batch-workspace > .panel {
  margin: 0;
}

.contract-document-batch-summary {
  display: grid;
  gap: 14px;
}

.contract-document-batch-summary > .grid,
.contract-document-batch-summary > .import-progress {
  margin: 0;
}

.contract-document-review-list {
  margin: 0 -16px -16px;
  border-top: 1px solid var(--line-soft);
}

.contract-document-review-item {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.contract-document-review-item:last-child {
  border-bottom: 0;
}

.contract-document-review-item--excluded {
  background: #f7f8fa;
}

.contract-document-review-item__header,
.contract-document-review-item__candidate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.contract-document-review-item__file {
  min-width: 0;
}

.contract-document-review-item__statuses {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.contract-document-review-item__file .table-link {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-document-review-item__file small,
.contract-document-review-item__candidate small {
  display: block;
  color: var(--muted);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.status-chip--neutral {
  background: #f1f5f9;
  border-color: #d8e0ea;
  color: #475569;
}

.status-chip--warning {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #a75b11;
}

.status-chip--danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}

.status-chip--success {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #15803d;
}

.contract-document-review-item__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr);
  gap: 24px;
  align-items: start;
}

.contract-document-review-item__extraction,
.contract-document-review-item__match {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
}

.contract-document-review-item__label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.contract-document-review-item__candidate {
  justify-content: flex-start;
}

.contract-document-review-item__candidate strong {
  overflow-wrap: anywhere;
}

.contract-document-review-item__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  margin: 12px 0 0;
}

.contract-document-review-item__facts div,
.contract-document-review-item__details dl > div {
  min-width: 0;
}

.contract-document-review-item__facts dt,
.contract-document-review-item__details dt {
  color: var(--muted);
  font-size: 11px;
}

.contract-document-review-item__facts dd,
.contract-document-review-item__details dd {
  margin: 1px 0 0;
  overflow-wrap: anywhere;
}

/* Two facts stacked in one grid cell (contract value + matched balance). */
.contract-document-review-item__facts dd + dt {
  margin-top: 6px;
}

.contract-document-review-item__location-select {
  border-color: var(--line);
  background: #ffffff;
}

.contract-document-review-item__retry {
  display: flex;
  justify-content: flex-end;
}

.contract-document-review-item__details {
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.contract-document-review-item__details > summary {
  width: fit-content;
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  list-style: none;
}

.contract-document-review-item__details > summary::before {
  content: "+";
  display: inline-block;
  width: 16px;
  color: var(--muted);
}

.contract-document-review-item__details[open] > summary::before {
  content: "-";
}

.contract-document-review-item__details dl {
  display: grid;
  gap: 10px;
  margin: 10px 0 0;
  padding: 12px;
  background: var(--panel-muted);
}

.contract-document-review-item__details dd small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.contract-match {
  position: relative;
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 0;
}

.contract-match__trigger {
  position: relative;
  display: block;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 34px 8px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.contract-match__trigger::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
}

.contract-match__trigger:hover {
  border-color: #9eb9d7;
  background: #ffffff;
}

.contract-match__trigger:focus {
  border-color: #7aa7d9;
  outline: none;
  box-shadow: 0 0 0 2px rgba(34, 119, 199, 0.12);
}

.contract-match__menu {
  position: absolute;
  z-index: 20;
  top: 46px;
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(24, 33, 43, 0.14);
}

.contract-match__menu[hidden],
.contract-match__option[hidden],
.contract-match__empty[hidden] {
  display: none !important;
}

.contract-match__search {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px;
  border-bottom: 1px solid var(--line-soft);
  background: #ffffff;
}

.contract-match__search-input {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.contract-match__search-input:focus {
  border-color: #7aa7d9;
  outline: none;
  box-shadow: 0 0 0 2px rgba(34, 119, 199, 0.12);
}

.contract-match__option {
  display: grid;
  gap: 2px;
  justify-content: stretch;
  align-items: start;
  width: 100%;
  max-width: none;
  min-height: 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.contract-match__option:last-child {
  border-bottom: 0;
}

.contract-match__option:hover,
.contract-match__option--active {
  background: #eef6ff;
  color: var(--text);
}

.contract-match__option strong,
.contract-match__option small {
  display: block;
  width: 100%;
  text-align: left;
}

.contract-match__option small,
.contract-match__status {
  color: var(--muted);
}

.contract-match__option .contract-match__client {
  color: #46647f;
  font-size: 11px;
}

.contract-match__empty {
  padding: 14px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.contract-match__status {
  display: block;
  min-height: 0;
}

.contract-match__status:not(:empty) {
  margin-top: 2px;
}

.contract-match__actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 3px;
}

.contract-document-excluded,
.extraction-note {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid #d59b2b;
  background: #fff9ec;
  color: #5d4a21;
  font-size: 12px;
  line-height: 1.4;
}

.contract-document-excluded {
  border-left-color: #7b8794;
  background: #f1f3f5;
  color: var(--text);
}

.contract-document-excluded form {
  margin-top: 4px;
}

.extraction-note {
  border-left-color: #7aa7d9;
  background: #f2f7fd;
  color: #314b66;
}

.contract-document-review-item__extraction .modal-launcher {
  margin-top: 0;
}

.empty-row {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
}

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

.table-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
}

.table-actions-column {
  text-align: right;
}

.table-actions-column .table-actions {
  justify-content: flex-end;
}

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

.modal-launcher {
  display: inline-flex;
}

.actions > form {
  display: inline-flex;
  margin: 0;
}

.actions > .button,
.actions > button,
.actions > input[type="submit"],
.actions > form > button,
.actions > form > input[type="submit"] {
  flex: 0 0 auto;
  width: auto;
}

.button,
button,
input[type="submit"] {
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  width: auto;
  max-width: 100%;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
}

/* The display above outranks the browser's own rule for the hidden attribute,
   so a button marked hidden stays on screen without this. */
.button[hidden],
button[hidden],
input[type="submit"][hidden] {
  display: none;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
  background: var(--primary-strong);
  text-decoration: none;
}

.button:disabled,
button:disabled,
input[type="submit"]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button--warning {
  border-color: #dfa851;
  background: #f4cf92;
  color: #6f3f0b;
}

.button--warning:hover {
  border-color: #ce9237;
  background: #edbd6c;
  color: #5f3408;
}

.button--secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}

.button--secondary:hover {
  background: var(--panel-muted);
}

.button--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.button--ghost:hover {
  background: var(--panel-muted);
  color: var(--text);
}

.button--danger {
  background: var(--danger);
}

.button--full {
  width: 100%;
}

button.button--full,
input[type="submit"].button--full {
  width: 100%;
}

form.panel {
  display: grid;
  gap: 14px;
  max-width: 1040px;
}

form.panel > .actions {
  border-top: 1px solid var(--line-soft);
  margin-top: 2px;
  padding-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.field {
  display: grid;
  gap: 5px;
}

/* Attribute display must win over .field's display so type-based hiding works. */
.field[hidden] {
  display: none !important;
}

.field--full {
  grid-column: 1 / -1;
}

.field--checkbox {
  align-content: start;
}

.field--checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
}

label {
  color: #384451;
  font-size: 13px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

input[type="submit"] {
  width: auto;
}

input[type="file"] {
  padding: 6px 8px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--text);
  background: #f8fafc;
  cursor: not-allowed;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.readonly-field {
  min-height: 34px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
  color: var(--muted);
  background: #fafbfc;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  margin-bottom: 12px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
}

.filter-bar .field {
  flex: 0 1 160px;
  gap: 4px;
  min-width: 140px;
}

.filter-bar .filter-field--search {
  flex-basis: 260px;
}

.filter-bar .filter-field--wide {
  flex-basis: 230px;
}

.filter-bar label {
  color: var(--muted);
  font-size: 12px;
}

.filter-bar input,
.filter-bar select {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 13px;
}

.filter-bar input[type="submit"],
.filter-bar .button {
  min-height: 32px;
  padding: 6px 10px;
}

.filter-actions,
.toolbar-actions {
  display: flex;
  gap: 6px;
  align-items: end;
  flex: 0 0 auto;
  margin-left: auto;
}

.filter-actions .button--ghost,
.toolbar-actions .button--ghost {
  color: var(--muted);
}

.usage-filter-bar {
  display: grid;
  grid-template-columns:
    minmax(140px, 0.8fr)
    minmax(140px, 0.8fr)
    minmax(180px, 1.2fr)
    minmax(160px, 1fr)
    minmax(200px, 1.2fr)
    auto;
  gap: 10px 12px;
}

.usage-filter-bar .field {
  min-width: 0;
}

.usage-filter-bar .filter-actions {
  align-self: end;
  margin-left: 0;
}

.usage-date-shortcuts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  grid-column: 1 / -1;
  margin: 0 -10px -10px;
  padding: 8px 10px;
  border-top: 1px solid var(--line-soft);
  border-radius: 0 0 var(--radius) var(--radius);
  background: #fafbfc;
}

.usage-summary__header,
.usage-list-header,
.usage-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.usage-summary {
  margin-bottom: var(--space-4);
}

.usage-summary__header {
  margin-bottom: 10px;
}

.usage-summary__header h2,
.usage-list-header h2 {
  margin: 0;
  font-size: 16px;
}

.usage-summary__header p,
.usage-list-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.usage-list-header {
  margin-bottom: 10px;
}

.toolbar > .alert {
  margin-bottom: 8px;
}

.usage-summary .grid {
  gap: 10px;
}

.usage-pagination {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.usage-pagination > div {
  min-width: 96px;
}

.usage-pagination > div:last-child {
  text-align: right;
}

.usage-pagination > span {
  color: var(--muted);
  font-size: 12px;
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 10px;
}

.selection-bar [data-client-selection-target="count"] {
  font-weight: 500;
}

.flash-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 36px));
}

.flash,
.alert {
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.38;
  font-weight: 400;
}

.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.flash--leaving {
  opacity: 0;
  transform: translateY(6px);
}

.flash__close {
  border: none;
  background: none;
  color: inherit;
  opacity: 0.55;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.flash__close:hover {
  opacity: 1;
}

.flash--notice {
  background: #f3fbf6;
  border-color: #cdebd8;
  color: #17643a;
}

.flash--alert,
.alert--error {
  background: #fff3f3;
  border-color: #f2c9c9;
  color: #9f1d24;
}

.alert--warning {
  background: #fff7e8;
  color: var(--warning);
}

.alert ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f6;
  color: #394653;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  vertical-align: middle;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex: 0 0 auto;
}

.badge--active,
.badge--approved,
.badge--sent,
.badge--generated,
.badge--applied {
  background: #e9f7ef;
  color: var(--success);
}

.badge--failed,
.badge--canceled,
.badge--archived,
.badge--disabled {
  background: #fdecec;
  color: var(--danger);
}

.badge--scheduled,
.badge--pending-approval,
.badge--review-required,
.badge--needs-review,
.badge--processing-stalled {
  background: #fff3df;
  color: var(--warning);
}

.badge--uploaded,
.badge--queued,
.badge--processing {
  background: #eef6ff;
  color: #2277c7;
}

.badge--not-uploaded {
  background: #eef2f6;
  color: #64748b;
}

.badge--ready-for-import {
  background: #e9f7ef;
  color: var(--success);
}

.badge--match-ready {
  background: #e9f7ef;
  color: var(--success);
}

.detail-list {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 8px 16px;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.tabs a {
  color: var(--text);
  padding: 9px 10px;
  font-weight: 500;
}

.tabs a:hover {
  background: var(--panel-muted);
  text-decoration: none;
}

.modal {
  width: min(760px, calc(100vw - 32px));
  max-height: min(780px, calc(100vh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  text-align: left;
  box-shadow: 0 16px 40px rgba(24, 33, 43, 0.16);
}

.modal::backdrop {
  background: rgba(24, 33, 43, 0.28);
}

.modal--form {
  width: min(720px, calc(100vw - 32px));
}

.modal--wide {
  width: min(1040px, calc(100vw - 32px));
}

.usage-details-modal {
  width: min(500px, calc(100vw - 32px));
}

.usage-details-list {
  margin: 0;
  grid-template-columns: 150px minmax(0, 1fr);
}

.modal__header,
.modal__actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.modal__header {
  border-bottom: 1px solid var(--line-soft);
}

.modal__header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto;
}

.modal__header h2 {
  margin: 0 0 3px;
  font-size: 18px;
  font-weight: 500;
}

.modal__header p {
  margin: 0;
  color: var(--muted);
}

.modal__body {
  padding: 16px;
  overflow: auto;
}

.modal-form {
  display: grid;
  gap: 14px;
}

.modal-form .form-grid {
  grid-template-columns: 1fr;
}

.modal-form > .actions {
  border-top: 1px solid var(--line-soft);
  margin-top: 2px;
  padding-top: 14px;
}

.terms-modal {
  display: grid;
  gap: 12px;
}

.terms-modal__summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.terms-modal__summary > div {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
}

.terms-modal__summary small,
.quick-term-card small {
  display: block;
  color: var(--muted);
}

.terms-modal__summary strong {
  font-weight: 500;
}

.quick-term-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 12px;
}

.quick-term-card--new {
  background: #fbfcfd;
}

.quick-term-card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.quick-term-card__header small {
  margin-top: 3px;
  max-width: 560px;
}

.quick-term-form {
  display: grid;
  gap: 10px;
}

.quick-term-form__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quick-term-form__actions {
  grid-column: 1 / -1;
  width: 100%;
  justify-content: flex-end;
  align-self: stretch;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.modal__actions {
  padding: 14px 0 0;
  justify-content: flex-end;
}

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

.form-error {
  color: var(--danger);
  margin: 0 0 12px;
}

.review-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #ffffff;
}

.review-box h3 {
  margin: 14px 0 8px;
  font-size: 15px;
  font-weight: 500;
}

.review-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

@media (max-width: 1100px) {
  .contract-document-review-item__body {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .filter-actions,
  .toolbar-actions {
    margin-left: 0;
    align-items: center;
  }

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

  .usage-filter-bar .filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 900px) {
  .flash-stack {
    right: 12px;
    bottom: 12px;
    width: min(340px, calc(100vw - 24px));
  }

  .app-shell {
    display: block;
  }

  .app-sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    z-index: 30;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 2px rgba(24, 33, 43, 0.04);
    top: 0;
  }

  .app-brand {
    min-width: 0;
    border-bottom: 0;
    padding: 0;
  }

  .app-brand__mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 13px;
  }

  /* Horizontal scroll bar on mobile: flatten groups, drop headings. */
  .app-nav__group {
    display: contents;
  }

  .app-nav__group + .app-nav__group {
    margin-top: 0;
  }

  .app-nav__heading {
    display: none;
  }

  .app-nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 4px;
    max-width: 100%;
    margin: 0;
    padding: 2px 0 3px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .app-nav::-webkit-scrollbar {
    display: none;
  }

  .app-nav__link {
    flex: 0 0 auto;
    scroll-snap-align: start;
    scroll-margin-inline: 12px;
    padding: 7px 8px;
    text-align: center;
    white-space: nowrap;
    line-height: 1.2;
  }

  .app-sidebar__footer {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    padding: 0;
    border-top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .app-sidebar__footer strong {
    max-width: 140px;
  }

  .app-sidebar__footer small {
    display: none;
  }

  .app-sidebar__footer form {
    display: inline-flex;
    margin: 0;
  }

  .app-sidebar__footer .button,
  .app-sidebar__footer .button--full {
    width: auto;
    min-height: 30px;
    padding: 5px 10px;
  }

  .app-main {
    width: 100%;
    padding: 16px 14px 24px;
  }

  .grid--2,
  .grid--3,
  .grid--4,
  .form-grid,
  .terms-modal__summary,
  .quick-term-form__grid {
    grid-template-columns: 1fr;
  }

  .contract-document-batch-summary .grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .filter-bar .field,
  .filter-bar .filter-field--search,
  .filter-bar .filter-field--wide {
    min-width: 0;
  }

  .filter-actions,
  .toolbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .usage-summary__header,
  .usage-list-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .page-header,
  .selection-bar,
  .modal__header {
    display: grid;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }

  .contract-batch-launcher {
    align-items: flex-start;
    flex-direction: column;
  }

  .import-progress {
    align-items: stretch;
    flex-direction: column;
  }

  .import-progress__text {
    min-width: 0;
  }

  .import-progress__bar {
    flex: 0 0 auto;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .contract-document-batch-summary .grid--4 {
    grid-template-columns: minmax(0, 1fr);
  }

  .contract-document-review-list {
    margin: 0 -14px -14px;
  }

  .contract-document-review-item {
    padding: 14px;
  }

  .contract-document-review-item__facts {
    grid-template-columns: minmax(0, 1fr);
  }

  .contract-document-review-item__header {
    align-items: flex-start;
  }

  .app-sidebar {
    gap: 8px;
  }

  .app-sidebar__footer > div {
    display: none;
  }

  .app-main {
    padding: 14px 12px 22px;
  }

  .page-header {
    gap: 10px;
    margin-bottom: 14px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .panel,
  .metric,
  .review-box {
    padding: 14px;
  }

  .table-panel {
    padding: 0;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .filter-actions > *,
  .toolbar-actions > * {
    flex: 1 1 0;
  }

  .usage-filter-bar {
    grid-template-columns: 1fr;
  }

  .usage-filter-bar .filter-actions {
    justify-content: stretch;
  }

  .usage-pagination > div {
    min-width: 0;
  }
}

/* Contract review: what needs fixing + terms gap + guided term fields */
.review-issues__lead {
  margin: 0 0 6px;
}

.review-issues__list {
  margin: 0;
  padding-left: 18px;
  color: var(--warning);
}

.review-resolved {
  margin: 0;
  color: var(--success);
}

.terms-gap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
}

.terms-gap--mismatch {
  border-color: #f1c96b;
  background: #fffaf0;
}

.terms-gap--ok {
  border-color: #bfe6cf;
  background: #f2fbf6;
}

.terms-gap__item {
  display: flex;
  flex-direction: column;
}

.terms-gap__item small {
  color: var(--muted);
  font-size: 12px;
}

.terms-gap__item strong {
  font-variant-numeric: tabular-nums;
}

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

.terms-gap__item--diff strong {
  color: var(--warning);
}

.terms-gap--ok .terms-gap__item--diff strong {
  color: var(--success);
}

.field--error input,
.field--error select,
.field--error textarea {
  border-color: var(--danger);
}

.field-error {
  display: block;
  margin-top: 4px;
  color: var(--danger);
  font-size: 12px;
}

/* Month + year dropdowns standing in for the native month input. The fields
   sit in a grid, so the pair is pinned to the top instead of stretching to
   whatever the tallest field in the row happens to be. */
.month-picker {
  display: flex;
  align-items: start;
  gap: 6px;
}

.month-picker__month {
  flex: 1 1 60%;
  min-width: 0;
}

.month-picker__year {
  flex: 1 1 40%;
  min-width: 0;
}

.term-fields__advanced {
  margin-top: 10px;
}

.term-fields__advanced > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
}

.contract-terms-table th:first-child,
.contract-terms-table td:first-child {
  width: 64px;
}

.contract-terms-table__row--warning td {
  background: #fffaf0;
}

.contract-terms-table__row--warning td:first-child {
  box-shadow: inset 3px 0 0 #e7a23a;
}

.contract-terms-table__issue {
  color: var(--warning);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 3px;
}

.contract-terms-table__note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 3px;
  max-width: 320px;
}

.detail-list--split dd {
  font-variant-numeric: tabular-nums;
}

.terms-modal__instruction {
  margin: 0 0 10px;
  font-weight: 600;
}

.client-meta__row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: center;
  color: var(--muted);
}

.client-meta__row strong {
  color: var(--text);
  font-weight: 600;
}

.client-meta__notes {
  margin: 10px 0 0;
  color: var(--muted);
}

.wa-preview {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
  color: var(--text);
  min-height: 40px;
  font-size: 14px;
}
/* Only the message text honors its \n between sentences (matching how the
   reminder reads on the phone). Keeping pre-line off the container means the
   whitespace between the hidden preview variants collapses instead of showing
   as blank lines before and after the visible text. */
.wa-preview__text {
  white-space: pre-line;
}
.wa-preview:empty::before {
  content: "—";
  color: var(--muted);
}
.wa-preview__block + .wa-preview__block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.wa-preview__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.quick-term-add {
  margin-top: 4px;
}

.quick-term-add > summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 14px;
  padding: 6px 0;
  list-style: none;
}

.quick-term-add[open] > summary {
  margin-bottom: 8px;
}

/* Step indicator for multi-step flows (bulk messaging) */
.step-indicator {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0 0 20px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.step-indicator__step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.step-indicator__step:not(:last-child)::after {
  content: "→";
  margin-left: 16px;
  color: var(--line);
}

.step-indicator__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-muted);
  font-size: 12px;
  font-weight: 600;
}

.step-indicator__step--active {
  color: var(--text);
  font-weight: 600;
}

.step-indicator__step--active .step-indicator__number {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step-indicator__step--done {
  color: var(--success, #147a45);
}

.step-indicator__step--done .step-indicator__number {
  background: #e8f5ee;
  border-color: #b9e0ca;
  color: #147a45;
}

/* Bulk compose: recipients on the left, message form on the right */
.compose-layout {
  display: grid;
  grid-template-columns: minmax(300px, 2fr) 3fr;
  gap: 16px;
  align-items: start;
}

.compose-usable-count {
  font-weight: 600;
  margin: 8px 0 12px;
}

.recipient-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
}

.recipient-list__row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.recipient-list__row--warning {
  border-color: #e5c07b;
  background: #fdf6e7;
}

.recipient-list__main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

.recipient-list__contact {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  padding-left: 24px;
}

.recipient-list__reason {
  color: var(--warning, #9a5b13);
  font-size: 13px;
  padding-left: 24px;
}

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

/* Batch review page */
.batch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 14px;
  color: var(--muted);
  align-items: center;
}

.message-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
  padding: 14px 16px;
  margin-top: 10px;
}

.message-preview__subject {
  font-weight: 600;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.message-preview__body p:last-child {
  margin-bottom: 0;
}

.approval-callout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  margin: 16px 0;
  border: 1px solid #b9d2f5;
  border-radius: var(--radius);
  background: #eef4fd;
}

.approval-callout h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.approval-callout p {
  margin: 0;
  color: var(--muted);
}

.button--large {
  padding: 12px 24px;
  font-size: 15px;
}

.secondary-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--muted);
}

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

.breadcrumbs a:hover {
  color: var(--primary);
}

.breadcrumbs__current {
  color: var(--text);
  font-weight: 500;
}

/* Tab buttons (in-page tabs) */
.tabs__tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.tabs__tab:hover {
  background: var(--panel-muted);
  color: var(--text);
}

.tabs__tab--active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Empty states with a CTA */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.empty-state p {
  margin: 0;
}

.button--danger-ghost {
  color: var(--danger, #b42318);
}

.tabs a.tabs__link--active {
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.settings-card h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 500;
}

.settings-card p {
  margin: 0 0 14px;
}

/* Dashboard attention list + workflow shortcut cards */
.attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.attention-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px;
}

.attention-list__item + .attention-list__item {
  border-top: 1px solid var(--line-soft);
}

.shortcut-card h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 500;
}

.shortcut-card p {
  margin: 0 0 14px;
}

/* Contract review queue */
.review-progress {
  font-weight: 600;
  margin: 0 0 12px;
}

.review-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.review-card__header h2 {
  display: inline-block;
  margin: 0 8px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.review-card__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  color: var(--muted);
  font-size: 13px;
}

.review-card__issues {
  margin: 6px 0 0;
  padding-left: 18px;
}

.review-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.review-card__footer .field--checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

/* Import review: progress banner + collapsible sections */
.import-progress {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: var(--space-4);
  border: 1px solid #b9d2f5;
  border-radius: var(--radius);
  background: #eef4fd;
}

.import-progress--ready {
  border-color: #b9e0ca;
  background: #e8f5ee;
}

.import-progress__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
}

.import-progress__bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(24, 33, 43, 0.08);
  overflow: hidden;
}

.import-progress__bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
}

.import-progress--ready .import-progress__bar span {
  background: var(--success);
}

details.import-section {
  margin-bottom: var(--space-4);
}

.import-section__summary {
  cursor: pointer;
  padding: 14px 16px;
  list-style: none;
}

.import-section__summary::before {
  content: "▸";
  float: left;
  margin-right: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

details[open] > .import-section__summary::before {
  transform: rotate(90deg);
}

.import-section__summary h2 {
  display: inline;
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.import-section__summary p {
  margin: 4px 0 0 24px;
  color: var(--muted);
}

.review-card__task {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-muted);
}

.review-card__task h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.review-card__task .field--checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-weight: 500;
}

.review-card__note {
  background: #e8f5ee;
  border-color: #b9e0ca;
  color: #14532d;
}

.review-card__linked {
  margin: 10px 0 0;
  color: var(--muted);
}

.review-card__task--pointer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Compact quick-actions strip on the dashboard */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-4);
}

/* Client page: warning chips, situation banner, inline contact form */
.client-title-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.contact-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.contact-chip--warning {
  background: #fdf1df;
  border: 1px solid #eecf9b;
  color: var(--warning);
}

.situation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: var(--space-4);
}

.metric--warning {
  border-color: #eecf9b;
  background: #fffaf0;
}

.metric--warning strong {
  color: var(--warning);
}

.contact-inline-form__fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.contact-inline-form__submit {
  align-self: end;
}

.field-warning {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--warning);
}

.contact-chip--ok {
  background: #e8f5ee;
  border: 1px solid #b9e0ca;
  color: var(--success);
}

/* List pagination (kaminari) */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: var(--space-3);
}

.messaging-table-panel .pagination-bar {
  padding: 14px 16px;
  border-top: 1px solid var(--line-soft);
}

nav.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

nav.pagination a,
nav.pagination .current,
nav.pagination .gap {
  display: inline-block;
  min-width: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

nav.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

nav.pagination .current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

nav.pagination .gap {
  border: none;
  background: none;
  color: var(--muted);
}

/* Fields flagged for human review in the term modal: filled but highlighted */
.field--attention input,
.field--attention select,
.field--attention textarea {
  border-color: var(--warning);
  background: #fff8e9;
}

.field--attention > label {
  color: var(--warning);
  font-weight: 600;
}

/* Batch delivery: X/Y sent counters + failed note */
.sent-progress {
  font-variant-numeric: tabular-nums;
}

.sent-progress--complete {
  color: var(--success);
  font-weight: 600;
}

.import-progress__failed {
  color: var(--danger);
}

/* Per-term edit modal: source text next to the structured fields */
.term-modal {
  display: grid;
  gap: 14px;
}

.term-modal__source {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  background: var(--panel-muted);
}

.term-modal__source h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.term-modal__source-text {
  margin: 0;
  white-space: pre-wrap;
  font-size: 14px;
}

.term-modal__attention-note {
  margin: 0;
}

.terms-review-modal,
.terms-review-form,
.terms-review-list {
  display: grid;
  gap: 14px;
}

.terms-review-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.terms-review-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.terms-review-card__header h3 {
  margin: 0;
  font-size: 15px;
}

.term-review-instruction {
  margin: 0;
  color: #7c470e;
  font-size: 13px;
}

/* AI reading notes at the top of the review popup: substantive context for
   the values being confirmed, kept visually quiet. */
.term-review-notes {
  padding: 10px 12px;
  border: 1px solid #eecf9b;
  border-radius: var(--radius);
  background: #fdf6e9;
  font-size: 13px;
  color: #7c470e;
}

.term-review-notes__heading {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.term-review-notes__list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 3px;
}

.term-modal .term-review-notes {
  margin-top: 10px;
}

/* Term-scoped notes sit with the term's fields. They used to be toned down to
   grey-on-grey to avoid reading as a second contract-level banner, and reviewers
   simply skipped past them — these carry the reason a value needs checking, so
   they keep the amber treatment and lead with a coloured edge instead. */
.term-review-notes--term {
  margin: 8px 0 12px;
  border-left: 3px solid #d98b1f;
}

.term-review-notes--term .term-review-notes__heading {
  color: #8a4b00;
  font-weight: 700;
}

/* The page behind an open dialog holds still — see modal_controller for why the
   lock is counted rather than toggled. */
html.has-open-modal,
html.has-open-modal body {
  overflow: hidden;
}

.modal__header-main {
  min-width: 0;
}

/* A header carrying facts instead of a heading: it wraps onto its own line
   before it will squeeze the close button. */
.modal__header--meta {
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
}

.modal__header--meta .modal__header-main {
  flex: 1 1 320px;
}

/* The contract's own figures in the review popup's header — which contract,
   whose, when and for how much. A single quiet strip: it is reference material
   for the terms below, not the subject of the dialog. */
.terms-review-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 0;
}

.terms-review-meta__item {
  display: grid;
  gap: 2px;
}

.terms-review-meta dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.terms-review-meta dd {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

/* Where you left off: a save returns to its own row, and the highlight fades
   after a few seconds so the table settles back to normal. The class is put on
   by row_focus_controller — see there for why this is not :target. */
tr.row-settled > td {
  animation: row-settled 4s ease-out;
}

@keyframes row-settled {
  0%, 55% {
    background: #fdf1df;
  }
  100% {
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  tr.row-settled > td {
    animation: none;
    background: #fdf1df;
  }
}

/* Hand-added terms are marked off from the ones read out of the document, so
   it stays obvious which figures came from where. */
.terms-review-card--new {
  border-style: dashed;
  background: var(--panel-soft, #fafbfc);
}

/* "Add another term" sits left, away from the submit, so the button that saves
   stays the one on the end. */
.terms-review-modal__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

/* Read-only message quick-look modal (client page) */
.modal--message {
  width: min(640px, calc(100vw - 32px));
}

.modal--message .modal__body .actions {
  margin-top: 12px;
}

/* Contract page image panel: status on the left, actions on the right */
.contract-image-panel .document-upload-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Inline fix action under the contract review issues list */
.review-issues__fix {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.review-issues__fix .hint {
  margin: 0;
}

/* The terms-total mismatch is the main blocker in this section, so keep it
   visually distinct from ordinary instructional copy. */
.contract-terms-warning {
  margin-top: 9px;
  border-color: #e7b651;
  border-left: 4px solid #d97706;
  background: #fff4dd;
  color: #7c470e;
  box-shadow: none;
  font-weight: 500;
}

/* One vertical client-context component: contact data first, recent
   communication immediately after it. */
.contract-client-context {
  padding: 0;
  overflow: hidden;
}

.contract-client-context__section {
  min-width: 0;
  padding: 16px;
}

.contract-client-context__section + .contract-client-context__section {
  border-top: 1px solid var(--line);
}

/* Inline neighborhood picker in the contracts list — fill a blank location
   without leaving the page. */
.inline-location-form {
  margin: 0;
}

.inline-location-form__select {
  max-width: 180px;
  font-size: 13px;
  padding: 4px 8px;
}

/* Header variant on the contract page: label + picker on one quiet line. */
.contract-location-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.contract-location-picker__label {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

/* Persistent import outcome: remains visible after the transient flash leaves. */
.completion-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: var(--space-4);
  padding: 16px 18px;
  border: 1px solid #b9d2f5;
  border-radius: var(--radius);
  background: #eef4fd;
}

.completion-banner--complete {
  border-color: #b9e0ca;
  background: #e8f5ee;
}

.completion-banner__icon {
  display: inline-flex;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.completion-banner--complete .completion-banner__icon {
  background: var(--success);
}

.completion-banner h2,
.completion-banner p {
  margin: 0;
}

.completion-banner p {
  margin-top: 3px;
  color: var(--muted);
}

/* Contract-owned contact details reuse the same direct editor as the client
   page, avoiding a second modal-only interaction. */
.contact-inline-editors {
  display: grid;
  gap: 16px;
}

.contact-inline-editor + .contact-inline-editor {
  border-top: 1px solid var(--line-soft);
  padding-top: 16px;
}

.contact-inline-editor__name {
  margin: 0 0 8px;
  font-size: 14px;
}

/* Buyer name(s) directly under the kartela heading — whose contract this is. */
.contract-header-clients {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 600;
}

/* Contract date and ProData status, kept off the busy reference/location row. */
.contract-header-timeline {
  margin: 2px 0 0;
  font-size: 13px;
}

.modal__body form .actions {
  margin-top: 14px;
}

.button__icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.contact-chip--button {
  min-height: 0;
  padding: 2px 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: none;
}

.contact-chip--warning.contact-chip--button {
  border-color: #eecf9b;
  background: #fdf1df;
  color: var(--warning);
}

.contact-chip--warning.contact-chip--button:hover {
  border-color: #d9a556;
  background: #f8e2bd;
  color: #7c470e;
  filter: none;
  text-decoration: none;
}

.contact-chip--warning.contact-chip--button:focus-visible {
  outline: 2px solid rgba(217, 119, 6, 0.3);
  outline-offset: 2px;
}

.contact-chip--warning.contact-chip--button:active {
  background: #f2d39e;
}

.contact-chip--ok.contact-chip--button:hover {
  border-color: #8fc8a8;
  background: #d9eee2;
  color: #17643a;
  text-decoration: none;
}

.contact-chip--ok.contact-chip--button:focus-visible {
  outline: 2px solid rgba(22, 163, 74, 0.25);
  outline-offset: 2px;
}

/* Message variables stay available without dominating the composer. */
.placeholder-picker {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--panel-muted);
}

.placeholder-picker > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.placeholder-picker__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* Consistent rhythm between composer controls and an inline PDF checkbox. */
.compose-layout__form {
  display: grid;
  gap: 16px;
}

.compose-layout__form > h2,
.compose-layout__form > .batch-meta,
.compose-layout__form > .message-review-preview {
  margin: 0;
}

.compose-attachment-field {
  align-self: end;
  padding-bottom: 7px;
}

.compose-attachment-field label {
  min-height: 34px;
}

.recipient-list__contact {
  flex-wrap: wrap;
}

.approval-callout--inline {
  margin: 0;
  padding: 12px 14px;
}

.approval-callout--inline h3,
.approval-callout--inline p {
  margin: 0;
}

.approval-callout--inline p {
  margin-top: 3px;
}

.compose-actions--split {
  justify-content: space-between;
}

@media (max-width: 760px) {
  .contact-inline-form__fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .contact-inline-form__submit {
    align-self: auto;
  }
}
