.rams-page,
.rams-modal,
[data-rams-approve-modal],
[data-rams-delete-modal] {
  --rpi-blue: #2563a8;
  --rpi-blue-bg: rgba(37, 99, 168, 0.08);
  --rpi-amber: #c49510;
  --rpi-amber-bg: rgba(196, 149, 16, 0.08);
  --rpi-green: #1e7a45;
  --rpi-green-bg: rgba(30, 122, 69, 0.08);
  --rpi-red: #b03030;
  --rpi-red-bg: rgba(176, 48, 48, 0.08);
}

.rams-page.page-section {
  padding-top: 0;
  padding-bottom: 0;
}

.rams-proto {
  margin-inline: calc(var(--ipi-page-gutter) * -1);
}

.rams-page .ipi-stats-strip {
  padding-bottom: 18px;
}

.rams-page .ipi-result-meta {
  margin-top: 2px;
}

.rams-page .rpi-filter-bar {
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto auto;
}

.rams-page .rpi-filter-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.rams-page .rpi-filter-date {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 35px;
  padding: 0 12px;
  border: 1px solid var(--ipi-rule-h);
  border-radius: 7px;
  background: var(--ipi-bg);
}

.rams-page .rpi-filter-date span {
  flex-shrink: 0;
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rams-page .rpi-filter-date input {
  min-width: 0;
  width: 100%;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--ipi-ink);
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 18px;
  outline: none;
}

.rams-page .rpi-source-cell,
.rams-page .rpi-approved-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rams-page .rpi-title-link {
  color: var(--ipi-ink);
  text-decoration: none;
}

.rams-page .rpi-title-link:hover {
  text-decoration: underline;
}

.rams-page .rpi-action-btn--primary {
  min-width: 108px;
  justify-content: center;
}

.rams-page .rpi-action-btn--utility {
  min-width: 64px;
  padding-inline: 11px;
  border-color: var(--ipi-rule);
  background: var(--ipi-bg);
  color: var(--ipi-ink-3);
}

.rams-page .rpi-delete-btn {
  margin-left: 2px;
  color: var(--ipi-ink-4);
}

.rams-page .rpi-delete-btn:hover {
  color: var(--rpi-red);
}

.rams-page .rpi-empty-state {
  background: var(--ipi-bg-card);
  border-radius: 12px;
  box-shadow: var(--ipi-shadow-card);
}

.rams-page .rpi-empty-state__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 26px 24px;
}

.rams-page .rpi-empty-state__body h3 {
  margin: 0;
  color: var(--ipi-ink);
  font-family: var(--font-display);
  font-size: 20px;
}

.rams-page .rpi-empty-state__body p {
  margin: 0;
}

.rams-page .rpi-empty-state--filtered {
  margin-top: 14px;
}

.rams-page .ipi-table td:last-child,
.rams-page .ipi-table th:last-child {
  text-align: right;
}

.rams-create-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 16px;
}

.rams-create-panel {
  background: var(--ipi-bg-card);
  border-radius: 12px;
  box-shadow: var(--ipi-shadow-card);
  overflow: hidden;
}

.rams-create-panel__head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--ipi-rule);
}

.rams-create-panel__title {
  margin: 0;
  color: var(--ipi-ink);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rams-create-panel__copy {
  margin: 6px 0 0;
  color: var(--ipi-ink-4);
  font-size: 12.5px;
  line-height: 1.5;
}

.rams-create-page form {
  padding: 20px;
}

.rams-create-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.content--rams-edit {
  padding-bottom: 0;
}

/* Let the page grow with content; min-height:100% here forced a tall flex column and worsened mobile overlap */
.content--rams-edit .page-layout--rams-edit {
  flex: 1 1 auto;
  min-height: 0;
}

.content--rams-edit .page-main--rams-edit {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.rpi-modal-eyebrow {
  margin: 0 0 6px;
  color: var(--ipi-accent);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Create RAMs modal — aligned with guided-tour-picker (warm shell, compact steps) */
.modal.rams-create-picker-modal .rams-create-picker__dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  border-radius: 14px;
  border: 1px solid rgba(26, 24, 21, 0.08);
  background: #ffffff;
  box-shadow:
    0 4px 24px rgba(15, 23, 42, 0.1),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.modal.rams-create-picker-modal .rams-create-picker__header.modal__header {
  align-items: flex-start;
  padding: 18px 20px 14px;
  background: #ffffff;
  border-bottom: 1px solid rgba(26, 24, 21, 0.07);
  flex-shrink: 0;
}

.modal.rams-create-picker-modal .rams-create-picker__header-main {
  min-width: 0;
  flex: 1 1 auto;
  padding-right: 8px;
}

.modal.rams-create-picker-modal .rams-create-picker__eyebrow,
.modal.rams-create-picker-modal .rams-create-picker__header .eyebrow {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c49510;
}

.modal.rams-create-picker-modal .rams-create-picker__title {
  margin: 0 0 8px;
  font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #1a1815;
}

.modal.rams-create-picker-modal .rams-create-picker__lede {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  max-width: 54ch;
  color: #6b6458;
}

.modal.rams-create-picker-modal .rams-create-picker__body.modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #f7f5f0;
}

.modal.rams-create-picker-modal .rams-create-picker__form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal.rams-create-picker-modal .rams-create-picker__inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 16px 20px 0;
  gap: 12px;
}

.modal.rams-create-picker-modal .rams-create-picker__step-badge {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b6458;
  flex-shrink: 0;
}

.modal.rams-create-picker-modal .rams-create-picker__step {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  gap: 0;
}

.modal.rams-create-picker-modal .rams-create-picker__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 4px;
}

.modal.rams-create-picker-modal .rams-create-picker__section {
  border: 1px solid rgba(26, 24, 21, 0.08);
  border-radius: 10px;
  background: #ffffff;
  padding: 14px 16px;
  box-shadow: none;
}

.modal.rams-create-picker-modal .rams-create-picker__section-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.modal.rams-create-picker-modal .rams-create-picker__section-title {
  margin: 0;
  font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #1a1815;
}

.modal.rams-create-picker-modal .rams-create-picker__section-lede {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #6b6458;
  max-width: 52ch;
}

.modal.rams-create-picker-modal .rams-create-picker__section-lede strong {
  color: #1a1815;
  font-weight: 700;
}

.modal.rams-create-picker-modal .rams-create-picker__footer.modal__footer {
  flex-shrink: 0;
  margin: 12px -20px 0;
  padding: 12px 20px 16px;
  background: #ffffff;
  border-top: 1px solid rgba(26, 24, 21, 0.07);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.modal.rams-create-picker-modal .rpi-source-grid {
  gap: 10px;
}

.modal.rams-create-picker-modal .rpi-source-choice {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(26, 24, 21, 0.1);
  gap: 12px;
}

.modal.rams-create-picker-modal .rpi-source-choice__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.modal.rams-create-picker-modal .rpi-source-choice__title {
  font-size: 14px;
}

.modal.rams-create-picker-modal .rpi-source-choice__meta {
  font-size: 12px;
  max-width: none;
}

.modal.rams-create-picker-modal .rpi-source-choice__state {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 10px;
}

.modal.rams-create-picker-modal .rpi-source-detail {
  gap: 12px;
}

.modal.rams-create-picker-modal .rams-create-picker__field.rpi-select-field {
  gap: 6px;
}

.modal.rams-create-picker-modal .rpi-select-field__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b6458;
}

.modal.rams-create-picker-modal .rams-create-picker__select {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 9px 34px 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(26, 24, 21, 0.12);
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='none' stroke='%239A9188' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 10px;
  font-family: var(--font-sans, inherit);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: #1a1815;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 42px;
  box-sizing: border-box;
}

.modal.rams-create-picker-modal .rams-create-picker__select:hover:not(:disabled) {
  border-color: rgba(196, 149, 16, 0.35);
}

.modal.rams-create-picker-modal .rams-create-picker__select:focus-visible {
  border-color: rgba(196, 149, 16, 0.55);
  box-shadow: 0 0 0 3px rgba(196, 149, 16, 0.15);
}

.modal.rams-create-picker-modal .rpi-select-field__hint {
  font-size: 12px;
  color: #9a9188;
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__dialog {
  background: var(--card);
  border-color: var(--border);
  box-shadow: var(--panel-shadow);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__header.modal__header {
  background: var(--card);
  border-bottom-color: var(--border);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__eyebrow,
html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__header .eyebrow {
  color: #e3b008;
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__title {
  color: var(--text);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__lede,
html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__section-lede {
  color: var(--text-muted);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__body.modal__body {
  background: rgba(15, 23, 42, 0.65);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__step-badge {
  color: var(--text-muted);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__section {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__section-title {
  color: var(--text);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__section-lede strong {
  color: var(--text);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__footer.modal__footer {
  background: var(--card);
  border-top-color: var(--border);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rpi-source-choice {
  background: rgba(15, 23, 42, 0.4);
  border-color: rgba(148, 163, 184, 0.22);
  color: var(--text);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rpi-source-choice.is-active {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(196, 149, 16, 0.45);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rpi-source-choice[aria-checked="true"] {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(196, 149, 16, 0.45);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rpi-select-field__label {
  color: var(--text-muted);
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rams-create-picker__select {
  background-color: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
}

html[data-theme="dark"] .modal.rams-create-picker-modal .rpi-select-field__hint {
  color: var(--text-muted);
}

html[data-theme="dark"] .rpi-source-choice:focus-visible {
  box-shadow:
    0 0 0 3px rgba(227, 176, 8, 0.18),
    0 6px 18px rgba(26, 24, 21, 0.22);
}

.rpi-source-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rpi-source-choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 0;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  background: #fff;
  color: var(--ipi-ink);
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.rpi-source-choice:hover {
  border-color: rgba(196, 149, 16, 0.3);
  box-shadow: 0 6px 18px rgba(26, 24, 21, 0.05);
}

.rpi-source-choice.is-active,
.rpi-source-choice[aria-checked="true"] {
  border-color: rgba(196, 149, 16, 0.42);
  background: #fbf8ef;
  box-shadow: 0 6px 18px rgba(26, 24, 21, 0.05);
}

.rpi-source-choice:focus-visible {
  border-color: rgba(196, 149, 16, 0.58);
  box-shadow:
    0 0 0 3px rgba(196, 149, 16, 0.16),
    0 6px 18px rgba(26, 24, 21, 0.05);
}

.rpi-source-choice__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(196, 149, 16, 0.1);
  color: var(--ipi-accent);
  flex-shrink: 0;
}

.rpi-source-choice__icon svg {
  width: 18px;
  height: 18px;
}

.rpi-source-choice__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  text-align: left;
  flex: 1 1 auto;
}

.rpi-source-choice__title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.rpi-source-choice__meta {
  color: var(--ipi-ink-4);
  font-size: 12.5px;
  line-height: 1.45;
  max-width: 40ch;
}

.rpi-source-choice__state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f5f2ea;
  color: var(--ipi-ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.rpi-source-choice.is-active .rpi-source-choice__state,
.rpi-source-choice[aria-checked="true"] .rpi-source-choice__state {
  background: rgba(196, 149, 16, 0.14);
  color: var(--ipi-accent);
}

.rpi-source-detail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rpi-select-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rpi-select-field__label {
  color: var(--ipi-ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rpi-select-field select {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  background: var(--ipi-bg-card);
  color: var(--ipi-ink);
  font: inherit;
  box-shadow: none;
}

.rpi-select-field__hint {
  display: block;
  color: var(--ipi-ink-4);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .rams-page .rpi-filter-bar {
    grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(160px, 1fr)) repeat(2, auto);
  }
}

@media (max-width: 900px) {
  /* Match Schedule planner: bottom sheet + light blurred scrim (not full-height side drawer). */
  body.rams-mobile-filters-open {
    overflow: hidden;
  }

  /*
   * Scroll-lock the list behind the sheet, but filters + drawer live INSIDE .ipi-list-area
   * (see rams index). pointer-events:none on the list area alone would make the whole sheet dead.
   * Re-enable hits on the filter chrome; siblings (e.g. table) stay non-interactive via inherited none.
   */
  body.rams-mobile-filters-open .rams-page .ipi-list-area {
    pointer-events: none;
  }

  body.rams-mobile-filters-open .rams-page .ipi-filter-shell {
    pointer-events: auto;
  }

  /*
   * Hide the Need help? FAB while RAMs filters are open (and briefly after close).
   * IMPORTANT: `tenant-app-shell` is on <body>, not a wrapper — selectors like
   * `body.foo .tenant-app-shell .support-fab` never matched, so the FAB stayed clickable
   * under the bottom-sheet Done button and fired data-support-open (ghost tap).
   */
  body.rams-mobile-filters-open .support-fab,
  body.rams-mobile-filters-open button[data-support-open] {
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }

  body.rams-filter-fab-suppress .support-fab,
  body.rams-filter-fab-suppress button[data-support-open] {
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }

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

  .rams-page .rpi-filter-actions {
    justify-content: flex-start;
  }

  .rams-page .rpi-filter-date {
    min-height: 38px;
  }

  .rams-page .rpi-action-group {
    min-width: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .rams-page .ipi-table td:last-child,
  .rams-page .ipi-table th:last-child {
    text-align: left;
  }

  /* --- RAMs table: card-ify rows on mobile --- */
  .rams-page .ipi-table-wrap {
    overflow-x: visible;
  }

  .rams-page .ipi-table {
    min-width: 0;
  }

  .rams-page .ipi-table,
  .rams-page .ipi-table thead,
  .rams-page .ipi-table tbody,
  .rams-page .ipi-table tr,
  .rams-page .ipi-table th,
  .rams-page .ipi-table td {
    display: block;
    width: 100%;
  }

  .rams-page .ipi-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .rams-page .ipi-table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .rams-page .ipi-table tr {
    border: 1px solid rgba(26, 24, 21, 0.1);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    padding: 6px 0;
  }

  .rams-page .ipi-table td {
    position: relative;
    padding: 7px 14px 7px 110px;
    border-bottom: 1px solid rgba(26, 24, 21, 0.06);
    text-align: left !important;
    white-space: normal;
  }

  .rams-page .ipi-table td:last-child {
    border-bottom: none;
  }

  .rams-page .ipi-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 14px;
    top: 7px;
    width: 82px;
    color: #9a9188;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* RAMs name cell: remove left padding so it fills the card */
  .rams-page .ipi-table td[data-label="RAMs"] {
    padding-left: 14px;
  }

  .rams-page .ipi-table td[data-label="RAMs"]::before {
    display: none;
  }

  .rams-page .ipi-table td[data-label="RAMs"] .ipi-td-insp-name {
    font-size: 14px;
    font-weight: 600;
  }

  /* Actions cell: no pseudo-label, right-align buttons */
  .rams-page .ipi-table td.ipi-actions {
    padding-left: 14px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .rams-page .ipi-table td.ipi-actions::before {
    display: none;
  }

  .rams-page .ipi-table td.ipi-actions .btn {
    min-height: 44px;
  }

  /* Dialog chrome owned by canonical .modal--sheet rule in style.css:4847 */

  .modal.rams-create-picker-modal .rams-create-picker__header.modal__header {
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  }

  /* Mobile layout: move inner's side padding to the step-badge + scroll
     children so the footer (also a child of the step) can fill the full
     body width without needing negative margin (which gets clipped by
     parent overflow:hidden). The section card inside the scroll keeps
     its own padding, matching the invoice Step 1 pattern. */
  .modal.rams-create-picker-modal .rams-create-picker__inner {
    padding: 14px 0 0;
    gap: 10px;
  }

  .modal.rams-create-picker-modal .rams-create-picker__step-badge {
    padding: 0 16px;
  }

  .modal.rams-create-picker-modal .rams-create-picker__scroll {
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 4px;
  }

  /* Section card mobile padding — match Create Quote canonical
     (.qcm-modal__section: 12px 14px, border-radius 8px) so invoice,
     quotes and rams Step-1 workflow pickers all have identical card
     chrome on mobile. */
  .modal.rams-create-picker-modal .rams-create-picker__section {
    padding: 12px 14px;
    border-radius: 8px;
  }

  /* Step 1 source-choice cards drop their always-on border on mobile so
     they don't create a card-inside-card look inside the section card.
     They pick up border + background on hover and .is-active (matches
     the invoice .ivm-card--workflow-pick .ivm-source-choice pattern). */
  .modal.rams-create-picker-modal .rams-create-picker__section .rpi-source-choice {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    padding: 10px 8px;
  }

  .modal.rams-create-picker-modal .rams-create-picker__section .rpi-source-choice:hover {
    border-color: rgba(196, 149, 16, 0.2);
    background: rgba(196, 149, 16, 0.04);
    box-shadow: none;
  }

  .modal.rams-create-picker-modal .rams-create-picker__section .rpi-source-choice.is-active,
  .modal.rams-create-picker-modal .rams-create-picker__section .rpi-source-choice[aria-checked="true"] {
    border-color: rgba(196, 149, 16, 0.42);
    background: #fbf8ef;
    box-shadow: none;
  }

  .modal.rams-create-picker-modal .rams-create-picker__footer.modal__footer {
    margin: 10px 0 0;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  .modal.rams-create-picker-modal .rams-create-picker__footer .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* Keep source choice as a single row — icon | body | state pill */
  .modal.rams-create-picker-modal .rpi-source-choice {
    align-items: center;
    flex-wrap: nowrap;
  }

  .modal.rams-create-picker-modal .rpi-source-choice__state {
    min-width: 0;
    margin-left: 0;
  }

  /* Dialog must be full-screen on mobile — override the desktop
     width: min(640px, calc(100vw - 32px)) rule that would otherwise
     keep a 16px margin on each side. !important mirrors canonical
     .modal.modal--sheet .modal__dialog — without it some browsers
     render the dialog at calc(100vw - 32px) regardless. */
  .modal.modal--sheet.rams-create-picker-modal .rams-create-picker__dialog {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }
}

/* --- Dark mode: RAMs table cards on mobile --- */
@media (max-width: 900px) {
  html[data-theme="dark"] .rams-page .ipi-table tr {
    background: var(--card);
    border-color: var(--border);
    box-shadow: none;
  }

  html[data-theme="dark"] .rams-page .ipi-table td {
    border-bottom-color: rgba(71, 85, 105, 0.4);
    color: var(--text);
  }

  html[data-theme="dark"] .rams-page .ipi-table td::before {
    color: var(--text-muted);
  }
}

.rams-edit-page .rpe-flash {
  margin: 0 var(--ipi-page-gutter) 14px;
}

.rams-edit-page.page-section {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}

body.rams-edit-shell {
  height: auto;
  overflow: visible;
}

.app-shell--rams-edit .sidebar {
  scrollbar-width: none;
}

.app-shell--rams-edit .sidebar::-webkit-scrollbar {
  width: 0;
}

.rams-edit-page .rpe-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-inline: calc(var(--ipi-page-gutter) * -1);
  color: var(--ipi-ink);
}

.rams-edit-page [data-rams-form] {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  gap: 0;
  margin: 0;
  margin-top: 14px;
  padding: 0;
  background: var(--ipi-bg);
  border-radius: 0;
}

.rams-edit-page .rpe-edit-header {
  margin-bottom: 0;
}

/* Workflow title strip + job context: flush (no padding band between the two) */
.rams-edit-page .ipi-page-header.rpe-edit-header {
  padding-bottom: 0;
  border-bottom: none;
}

.rams-edit-page .rpe-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--ipi-bg);
}

.rams-edit-page .rpe-list-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  align-items: start;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px var(--ipi-page-gutter) 0;
  padding-bottom: 0;
  background: var(--ipi-bg);
}

.rams-edit-page .rams-editor-section,
.rams-edit-page .rpe-review-panel,
.rams-edit-page .rpe-progress-panel,
.rams-edit-page .rpe-step-tab {
  overflow: hidden;
  background: var(--ipi-bg-card);
  border: 1px solid var(--ipi-rule);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(26, 24, 21, 0.06);
}

.rams-edit-page .rpe-context-banner {
  margin: 0;
  overflow: visible;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  border-top: 1px solid var(--ipi-rule);
  background: var(--ipi-bg-card);
  border-bottom: 1px solid var(--ipi-rule);
  box-shadow: none;
}

.rams-edit-page .rpe-card-head {
  padding: 12px 20px 10px;
  border-bottom: 1px solid var(--ipi-rule);
}

.rams-edit-page .rpe-card-head--split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rams-edit-page .rpe-card-eyebrow,
.rams-edit-page .rpe-editor-card__eyebrow,
.rams-edit-page .rams-hazard-category__eyebrow,
.rams-edit-page .rpe-summary-meta__label,
.rams-edit-page .rpe-job-meta__label,
.rams-edit-page .rams-field__label,
.rams-edit-page .rpe-review-meta dt {
  margin: 0 0 4px;
  color: var(--ipi-accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rams-edit-page .rpe-card-title,
.rams-edit-page .rpe-review-panel__title,
.rams-edit-page .rams-editor-section__head h4 {
  margin: 0;
  color: var(--ipi-ink);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rams-edit-page .rpe-card-sub,
.rams-edit-page .rams-editor-section__subcopy,
.rams-edit-page .rpe-review-panel__sub {
  margin: 4px 0 0;
  color: var(--ipi-ink-4);
  font-size: 12.5px;
  line-height: 1.55;
}

.rams-edit-page .rpe-summary-card .rpe-card-sub {
  display: none;
}

.rams-edit-page .rpe-summary-card__body {
  padding: 10px 20px 12px;
}

.rams-edit-page .rpe-chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rams-edit-page .rpe-context-chip,
.rams-edit-page .rams-editor-section__count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--ipi-bg-inset);
  color: var(--ipi-ink-2);
  font-size: 12px;
  font-weight: 600;
}

.rams-edit-page .rpe-summary-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--ipi-rule);
  border-top: 1px solid var(--ipi-rule);
}

.rams-edit-page .rpe-summary-meta__cell {
  padding: 10px 20px;
  background: var(--ipi-bg-card);
}

.rams-edit-page .rpe-summary-meta__label,
.rams-edit-page .rpe-job-meta__label,
.rams-edit-page .rams-field__label,
.rams-edit-page .rpe-review-meta dt {
  color: var(--ipi-ink-4);
}

.rams-edit-page .rpe-summary-meta__value,
.rams-edit-page .rpe-job-meta__value,
.rams-edit-page .rpe-review-meta dd {
  margin: 0;
  color: var(--ipi-ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.rams-edit-page .rpe-summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.rams-edit-page .rpe-summary-pill--draft {
  background: var(--rpi-amber-bg);
  color: var(--rpi-amber);
}

.rams-edit-page .rpe-summary-pill--approved {
  background: var(--rpi-green-bg);
  color: var(--rpi-green);
}

.rams-edit-page .rpe-step-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rams-edit-page .rpe-step-tabs {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.rams-edit-page .rpe-step-tab {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 74px;
  padding: 14px 16px;
  border: 1px solid var(--ipi-rule);
  cursor: pointer;
  appearance: none;
  font: inherit;
  color: var(--ipi-ink-3);
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.rams-edit-page .rpe-step-tab__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--ipi-bg-inset);
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}

.rams-edit-page .rpe-step-tab__label {
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.rams-edit-page .rpe-step-tab__body {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.rams-edit-page .rpe-step-tab__state {
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.rams-edit-page .rpe-step-tab:hover {
  border-color: var(--ipi-rule-h);
  background: var(--ipi-bg-hover);
  color: var(--ipi-ink);
}

.rams-edit-page .rpe-step-tab.is-ready {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(26, 24, 21, 0.03);
}

.rams-edit-page .rpe-step-tab.is-ready .rpe-step-tab__num {
  background: rgba(26, 24, 21, 0.08);
  color: var(--ipi-ink);
}

.rams-edit-page .rpe-step-tab.is-ready .rpe-step-tab__state {
  color: var(--ipi-ink);
}

.rams-edit-page .rpe-step-tab.is-active {
  border-color: rgba(0, 0, 0, 0.18);
  background: #f7f5f0;
  color: var(--ipi-ink);
}

.rams-edit-page .rpe-step-tab.is-active.is-ready {
  border-color: rgba(0, 0, 0, 0.18);
  background: linear-gradient(180deg, #faf8f4 0%, #f2efe9 100%);
}

.rams-edit-page .rpe-step-tab.is-active .rpe-step-tab__num {
  background: rgba(26, 24, 21, 0.1);
  color: var(--ipi-ink);
}

.rams-edit-page .rpe-step-tab.is-active .rpe-step-tab__state {
  color: var(--ipi-ink);
}

.rams-edit-page .rpe-step-tab.is-active.is-ready .rpe-step-tab__num {
  background: rgba(26, 24, 21, 0.1);
  color: var(--ipi-ink);
}

.rams-edit-page .rpe-step-tab.is-active.is-ready .rpe-step-tab__state {
  color: var(--ipi-ink);
}

.rams-edit-page .rpe-step-tab:focus-visible {
  outline: 2px solid rgba(26, 24, 21, 0.32);
  outline-offset: 2px;
}

.rams-edit-page .rpe-step-panel[hidden] {
  display: none !important;
}

.rams-edit-page .rpe-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 16px;
  min-height: 0;
  min-width: 0;
}

.rams-edit-page .rpe-support-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  overflow: visible;
}

.rams-edit-page .rpe-progress-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rams-edit-page .rpe-progress-summary {
  padding: 16px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rams-edit-page .rpe-progress-summary__eyebrow {
  margin: 0 0 4px;
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rams-edit-page .rpe-progress-summary__title {
  color: var(--ipi-ink);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rams-edit-page .rpe-progress-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px 16px;
}

.rams-edit-page .rpe-progress-overview__metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 84px;
  padding: 12px 13px;
  border-radius: 12px;
  background: var(--ipi-bg);
  border: 1px solid var(--ipi-rule);
}

.rams-edit-page .rpe-progress-overview__metric span,
.rams-edit-page .rpe-progress-overview__metric small {
  color: var(--ipi-ink-4);
  font-size: 11px;
  line-height: 1.4;
}

.rams-edit-page .rpe-progress-overview__metric strong {
  color: var(--ipi-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.rams-edit-page .rpe-ready-list__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rams-edit-page .rpe-ready-list__hint {
  color: var(--ipi-ink-4);
  font-size: 11px;
  line-height: 1.4;
}

.rams-edit-page .rpe-progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 18px 18px;
  margin: 0;
  list-style: none;
}

.rams-edit-page .rpe-progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--ipi-rule);
  background: var(--ipi-bg-card);
  cursor: pointer;
  appearance: none;
  font: inherit;
  color: var(--ipi-ink-3);
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.rams-edit-page .rpe-progress-step__index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--ipi-bg-inset);
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}

.rams-edit-page .rpe-progress-step__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rams-edit-page .rpe-progress-step__label {
  color: var(--ipi-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.rams-edit-page .rpe-progress-step__state {
  color: var(--ipi-ink-4);
  font-size: 11px;
  line-height: 1.4;
}

.rams-edit-page .rpe-progress-step.is-ready .rpe-progress-step__index {
  background: var(--rpi-green-bg);
  color: var(--rpi-green);
}

.rams-edit-page .rpe-progress-step.is-active {
  border-color: var(--ipi-accent-border);
  background: #fbf8ef;
}

.rams-edit-page .rpe-progress-step.is-active .rpe-progress-step__index {
  background: var(--ipi-accent-bg);
  color: var(--ipi-accent);
}

.rams-edit-page .rpe-progress-step:hover {
  border-color: var(--ipi-rule-h);
  background: var(--ipi-bg-hover);
}

.rams-edit-page .rpe-progress-step:focus-visible {
  outline: 2px solid rgba(37, 99, 168, 0.32);
  outline-offset: 2px;
}

.rams-edit-page .rpe-support-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 18px 12px;
  margin: 0;
}

.rams-edit-page .rpe-support-metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--ipi-rule);
  background: linear-gradient(180deg, #fffdf8 0%, var(--ipi-bg) 100%);
}

.rams-edit-page .rpe-support-metric dt {
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rams-edit-page .rpe-support-metric dd {
  margin: 0;
  color: var(--ipi-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.rams-edit-page .rpe-ready-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 18px 18px;
  margin: 0;
  list-style: none;
}

.rams-edit-page .rpe-ready-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--ipi-rule);
  background: linear-gradient(180deg, #fffdf8 0%, var(--ipi-bg) 100%);
}

.rams-edit-page .rpe-ready-list__label {
  color: var(--ipi-ink-2);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
}

.rams-edit-page .rpe-ready-list__state {
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.rams-edit-page .rpe-ready-list__item.is-ready {
  border-color: rgba(30, 122, 69, 0.18);
  background: rgba(30, 122, 69, 0.04);
}

.rams-edit-page .rpe-ready-list__item.is-ready .rpe-ready-list__state {
  color: var(--rpi-green);
}

.rams-edit-page .rpe-step-panels {
  display: block;
}

.rams-edit-page .rpe-step-panel {
  min-height: auto;
}

.rams-edit-page .rpe-step-panel.is-active {
  overflow: visible;
}

.rams-edit-page .rpe-review-panel {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rams-edit-page .rams-editor-section--approval .rams-editor-section__body {
  gap: 14px;
}

.rams-edit-page .rpe-review-panel__header {
  padding: 16px 18px 14px;
}

.rams-edit-page .rpe-review-meta {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0 18px;
}

.rams-edit-page .rpe-review-meta > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rams-edit-page .rams-approve-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 12px 0 0;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--ipi-rule);
  background: transparent;
  box-shadow: none;
}

.rams-edit-page .rams-approve-checks__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rams-edit-page .rams-required-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--ipi-accent-bg);
  color: var(--ipi-accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rams-edit-page .rams-approve-intro {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rams-edit-page .rams-btn-spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: rgba(255, 255, 255, 0.95);
  display: none;
  animation: ramsSpin 0.8s linear infinite;
}

.rams-edit-page .btn.is-loading .rams-btn-spinner {
  display: inline-block;
}

@keyframes ramsSpin {
  to {
    transform: rotate(360deg);
  }
}

.rams-edit-page .btn.is-loading {
  cursor: not-allowed;
}

.rams-edit-page .rams-approve-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(176, 48, 48, 0.18);
  border-radius: 12px;
  background: var(--ipi-red-bg);
  color: var(--ipi-red);
}

.rams-edit-page .rams-approve-checks.is-invalid {
  box-shadow: 0 0 0 3px rgba(176, 48, 48, 0.14);
}

.rams-edit-page .rams-undo-toast__card {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.rams-edit-page .rams-undo-toast__text {
  flex: 1 1 auto;
  min-width: 0;
}

.rams-edit-page .rams-undo-toast__dismiss {
  flex: 0 0 auto;
  width: 36px;
  min-height: 36px;
  padding: 6px 10px;
}

.rams-edit-page .rams-editor-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rams-edit-page .rams-editor-section__header {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--ipi-rule);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rams-edit-page .rams-editor-section__head {
  min-width: 0;
}

.rams-edit-page .rams-editor-section__body {
  padding: 14px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rams-edit-page .rams-editor-section__footer {
  padding: 0 18px 16px;
  display: flex;
  justify-content: flex-start;
}

.rams-edit-page .rams-section-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.rams-edit-page .rpe-job-meta {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--ipi-rule);
  border-radius: 12px;
  background: var(--ipi-rule);
}

.rams-edit-page .rpe-job-meta__item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 68px;
  padding: 12px 14px;
  background: var(--ipi-bg-card);
}

.rams-edit-page .rams-step-rule {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--ipi-bg-inset);
  box-shadow: none;
}

.rams-edit-page .rams-step-rule__eyebrow {
  margin: 0 0 4px;
  color: var(--ipi-ink-4);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rams-edit-page .rams-step-rule__text {
  margin: 0;
  color: var(--ipi-ink-2);
  font-size: 12.5px;
  line-height: 1.45;
}

.rams-edit-page .rams-step-rule__state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--ipi-bg-inset);
  color: var(--ipi-ink-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.rams-edit-page .rams-step-note {
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ipi-ink-4);
  font-size: 12px;
  line-height: 1.45;
}

/* One outer card per step; inner “register” is a divider + flat list — not card-on-card */
.rams-edit-page .rams-editor-section__body > .rams-editor-surface {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  padding-top: 12px;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--ipi-rule);
  background: transparent;
  box-shadow: none;
}

.rams-edit-page .rams-editor-surface__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rams-edit-page .rams-editor-surface__head h5 {
  margin: 0;
  color: var(--ipi-ink);
  font-size: 15px;
  font-weight: 700;
}

.rams-edit-page .rams-editor-surface__empty {
  margin: 0;
}

.rams-edit-page .rams-collection,
.rams-edit-page .rpe-staff-editor {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rams-edit-page .rpe-staff-list,
.rams-edit-page .rams-hazard-category__items {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rams-edit-page .rams-hazard-category {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0 10px;
  margin: 0;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--ipi-rule);
  background: transparent;
  box-shadow: none;
}

.rams-edit-page .rams-hazard-category:first-of-type {
  border-top: none;
  padding-top: 0;
}

.rams-edit-page .rams-hazard-category__summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rams-edit-page .rams-hazard-category__meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rams-edit-page .rams-hazard-category__title {
  color: var(--ipi-ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.rams-edit-page .rams-hazard-category__count {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ipi-bg-inset);
  border: none;
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.rams-edit-page .rams-hazard-category__head {
  display: block;
}

.rams-edit-page .rams-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.rams-edit-page .rams-hazard-category__footer {
  display: flex;
  justify-content: flex-start;
}

.rams-edit-page :where(.rams-row, .rams-step-row) input[type="text"],
.rams-edit-page :where(.rams-row, .rams-step-row) textarea,
.rams-edit-page :where(.rams-row, .rams-staff-row, .rams-entry-card) select,
.rams-edit-page :where(.rams-entry-card) input[type="text"],
.rams-edit-page :where(.rams-entry-card) textarea {
  width: 100%;
  border-color: var(--ipi-rule-h);
  background: var(--ipi-bg-card);
}

.rams-edit-page .rams-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--ipi-rule);
  border-radius: 12px;
  background: var(--ipi-bg-card);
}

.rams-edit-page .rams-staff-row {
  grid-template-columns: minmax(0, 168px) minmax(0, 1fr) auto;
}

.rams-edit-page .rams-entry-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--ipi-rule);
  border-radius: 12px;
  background: var(--ipi-bg-card);
  box-shadow: 0 1px 2px rgba(18, 26, 33, 0.04);
}

/* List rows inside a step: divider lines only (controls, method, hazard lines, staff) */
.rams-edit-page .rams-collection > .rams-entry-card,
.rams-edit-page .rams-collection > .rams-step-row.rams-entry-card {
  padding: 10px 0 12px;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--ipi-rule-h);
  background: transparent;
  box-shadow: none;
  gap: 8px;
}

.rams-edit-page .rams-collection > .rams-entry-card:last-child,
.rams-edit-page .rams-collection > .rams-step-row.rams-entry-card:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

/* Hazard lines live under a category, not as direct .rams-collection children */
.rams-edit-page .rams-hazard-category__items > .rams-entry-card {
  padding: 10px 0 12px;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--ipi-rule-h);
  background: transparent;
  box-shadow: none;
  gap: 8px;
}

.rams-edit-page .rams-hazard-category__items > .rams-entry-card:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.rams-edit-page .rpe-staff-list > .rams-entry-card {
  padding: 12px 0;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid var(--ipi-rule-h);
  background: transparent;
  box-shadow: none;
  gap: 10px;
}

.rams-edit-page .rpe-staff-list > .rams-entry-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.rams-edit-page .rams-entry-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rams-edit-page .rams-entry-card__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.rams-edit-page .rams-entry-card__grid--staff {
  grid-template-columns: minmax(0, 180px) minmax(0, 1fr) auto;
}

.rams-edit-page .rams-entry-card__aside {
  display: flex;
  align-items: end;
  justify-content: flex-end;
}

.rams-edit-page .rams-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.rams-edit-page .rams-icon-btn {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ipi-ink-4);
}

.rams-edit-page .rams-icon-btn .btn__icon,
.rams-edit-page .rams-icon-btn .btn__icon svg {
  width: 18px;
  height: 18px;
}

.rams-edit-page .rams-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.rams-edit-page .rams-icon-btn--danger {
  color: var(--rpi-red);
}

.rams-edit-page .rams-row-actions .btn-ghost:hover,
.rams-edit-page .rams-row-actions .btn-ghost:focus-visible {
  transform: none;
  box-shadow: none;
}

.rams-edit-page .rams-icon-btn:hover {
  border-color: var(--ipi-rule-h);
  background: var(--ipi-bg-hover);
  color: var(--ipi-ink);
}

.rams-edit-page .rams-icon-btn--danger:hover {
  border-color: rgba(176, 48, 48, 0.22);
  background: var(--ipi-red-bg);
  color: var(--rpi-red);
}

.rams-edit-page .rams-icon-btn:focus-visible {
  outline: 2px solid rgba(37, 99, 168, 0.32);
  outline-offset: 2px;
}

.rams-edit-page .rams-step-row {
  align-items: stretch;
}

.rams-edit-page .rams-step-row__label {
  color: var(--ipi-ink-4);
}

.rams-edit-page .rams-step-row textarea {
  min-height: 72px;
  resize: vertical;
}

.rams-edit-page .rams-review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.rams-edit-page .rams-review-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--ipi-rule-h);
  border-radius: 10px;
  background: var(--ipi-bg-inset);
  box-shadow: none;
}

.rams-edit-page .rams-review-card__label {
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rams-edit-page .rams-review-card__value {
  color: var(--ipi-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.rams-edit-page .rams-review-card__state {
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rams-edit-page .rpe-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--ipi-rule);
  border-radius: 14px;
  background: var(--ipi-bg-card);
  box-shadow: 0 1px 3px rgba(26, 24, 21, 0.06);
}

.rams-edit-page .rpe-action-bar__meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.rams-edit-page .rpe-action-bar__eyebrow {
  margin: 0;
  color: var(--ipi-ink-4);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rams-edit-page .rpe-action-bar__title {
  color: var(--ipi-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.rams-edit-page .rpe-action-bar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 1180px) {
  .rams-edit-page .rpe-list-area,
  .rams-edit-page .rpe-support-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Single-column layout: keep the workflow column above the status rail and stop paint-order overlap */
  .rams-edit-page .rpe-list-area {
    isolation: isolate;
    gap: 18px;
    align-items: stretch;
  }

  .rams-edit-page .rpe-main {
    position: relative;
    z-index: 2;
  }

  .rams-edit-page .rpe-support-rail {
    position: relative;
    z-index: 1;
  }
}

@media (max-width: 1024px) {
  /* Horizontal step strip — keep inside the padded column (no negative margins: avoids overflow + clip fights with .content) */
  .rams-edit-page .rpe-step-tabs {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 0;
  }

  .rams-edit-page .rpe-step-tabs::-webkit-scrollbar {
    display: none;
  }

  .rams-edit-page .rpe-step-tab {
    flex: 0 0 auto;
    width: min(152px, 46vw);
    min-width: min(152px, 46vw);
    min-height: 62px;
    padding: 12px 12px;
    scroll-snap-align: start;
  }

  .rams-edit-page .rpe-step-tab__label {
    font-size: 12px;
  }

  .rams-edit-page .rpe-step-tab__state {
    font-size: 10px;
  }
}

@media (max-width: 900px) {
  .rams-edit-page .rpe-summary-meta,
  .rams-edit-page .rpe-job-meta,
  .rams-edit-page .rams-review-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  /*
   * Mobile RAMs edit: .tenant-app .content uses overflow-x:hidden, which breaks position:sticky for
   * descendants in WebKit/Blink and produced overlapping rails / footers. Keep the workflow footer in
   * normal document flow and optimize spacing + tap targets instead.
   */
  .rams-edit-page .ipi-page-header.rpe-edit-header {
    padding-left: 18px;
    padding-right: 18px;
  }

  .rams-edit-page .ipi-page-header.rpe-edit-header .ipi-ph-title {
    font-size: clamp(17px, 4.8vw, 22px);
  }

  .rams-edit-page .ipi-page-header.rpe-edit-header .ipi-ph-right {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .rams-edit-page .ipi-page-header.rpe-edit-header .ipi-ph-right .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .rams-edit-page .rpe-body {
    padding: 0;
  }

  .rams-edit-page .rpe-list-area {
    padding-top: 12px;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    gap: 16px;
  }

  .rams-edit-page .rpe-main {
    gap: 14px;
  }

  .rams-edit-page .rpe-support-metrics {
    grid-template-columns: 1fr;
  }

  /* Second rail card repeats every tab’s Complete/Incomplete — hide on phones to shorten the page */
  .rams-edit-page .rpe-support-rail > .rpe-progress-panel + .rpe-progress-panel {
    display: none;
  }

  .rams-edit-page .rpe-progress-panel .rpe-card-sub {
    display: none;
  }

  .rams-edit-page .rpe-card-head--split {
    flex-direction: column;
    align-items: flex-start;
  }

  .rams-edit-page .rams-row,
  .rams-edit-page .rams-staff-row,
  .rams-edit-page .rams-step-row,
  .rams-edit-page .rams-entry-card__grid,
  .rams-edit-page .rams-entry-card__grid--staff {
    grid-template-columns: 1fr;
  }

  .rams-edit-page .rams-row-actions {
    justify-content: flex-start;
  }

  .rams-edit-page .rams-entry-card__aside {
    justify-content: flex-start;
  }

  .rams-edit-page .rpe-action-bar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    margin-top: 4px;
    padding: 14px 14px 16px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(26, 24, 21, 0.06);
  }

  .rams-edit-page .rpe-action-bar__actions {
    justify-content: stretch;
  }

  .rams-edit-page .rpe-action-bar__actions .btn {
    flex: 1 1 auto;
    min-height: 46px;
    justify-content: center;
  }

  .rams-edit-page .rpe-summary-meta,
  .rams-edit-page .rpe-job-meta,
  .rams-edit-page .rams-review-grid {
    grid-template-columns: 1fr;
  }

  .rams-edit-page .rams-editor-section__header,
  .rams-edit-page .rams-editor-section__body,
  .rams-edit-page .rams-editor-section__footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .rams-edit-page .rams-editor-section__header,
  .rams-edit-page .rams-entry-card__header,
  .rams-edit-page .rams-hazard-category__summary,
  .rams-edit-page .rams-hazard-category__meta,
  .rams-edit-page .rams-step-rule,
  .rams-edit-page .rams-approve-checks__head {
    flex-direction: column;
    align-items: flex-start;
  }

  .rams-edit-page [data-rams-confirmations] .form-checkbox {
    padding: 10px 0;
    border-radius: 10px;
  }

  .rams-edit-page [data-rams-confirmations] .form-checkbox label {
    padding: 4px 0 4px 4px;
    line-height: 1.45;
  }

  .rams-edit-page .rams-approve-checks {
    padding-top: 12px;
  }

  .rams-edit-page .rams-editor-surface__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .content--rams-edit .page-main--rams-edit {
    justify-content: flex-start;
  }

  .rams-edit-page.page-section {
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
  }
}

/* Extracted from app/Views/rams/_styles.php. Keep only dynamic hero theme inline in the view. */
    .rams-workspace {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }
    .rams-hero {
        display: flex;
        gap: 24px;
        justify-content: space-between;
        align-items: center;
        padding: 28px;
        border-radius: 24px;
        background: linear-gradient(
            135deg,
            color-mix(
                in srgb,
                var(--hero-bg-start, #0f172a) calc(100% - var(--hero-softness, 0%)),
                #ffffff var(--hero-softness, 0%)
            ),
            color-mix(
                in srgb,
                var(--hero-bg-end, #2563eb) calc(100% - var(--hero-softness, 0%)),
                #ffffff var(--hero-softness, 0%)
            )
        );
        color: var(--hero-text, #ffffff);
    }
    .insp-eyebrow {
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.22em;
        color: var(--hero-eyebrow, #93c5fd);
        margin: 0 0 6px 0;
    }
	    .rams-hero__copy h2 {
	        margin: 0 0 10px 0;
	        font-size: 2.1rem;
	    }
	    .rams-hero__copy .text-muted {
	        color: #fff;
	    }
	    .rams-hero__actions {
	        margin-top: 16px;
	        display: flex;
	        flex-wrap: wrap;
        gap: 12px;
    }
    .rams-hero__actions .btn-icon {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-weight: 600;
        background: rgba(255, 255, 255, 0.96);
        border: 1px solid rgba(15, 23, 42, 0.14);
        color: #1a1815;
    }
    .rams-hero__actions .btn.btn-primary {
        background: #1a1815;
        color: #ffffff;
        border-color: transparent;
    }
    .rams-hero__actions .btn__icon {
        display: inline-flex;
        align-items: center;
    }
    .rams-hero__actions .btn__icon svg {
        width: 18px;
        height: 18px;
        display: block;
    }
    .rams-hero__stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 16px;
        margin: 0;
    }
    .rams-hero__stats div {
        background: var(--hero-stat-surface, rgba(255, 255, 255, 0.12));
        border-radius: 16px;
        padding: 12px;
        text-align: center;
    }
    .rams-hero__stats dt {
        margin: 0 0 6px 0;
        font-size: 0.7rem;
        letter-spacing: 0.15em;
        text-transform: uppercase;
        color: #0f172a;
    }
    .rams-hero__stats dd {
        margin: 0;
        font-size: 1.2rem;
        font-weight: 600;
        color: #0f172a;
    }
    :is([data-rams-delete-modal], [data-rams-approve-modal]) .modal__dialog--confirm {
        width: min(980px, 100%);
        max-height: 90vh;
    }
    :is([data-rams-delete-modal], [data-rams-approve-modal]) .modal-form-grid {
        display: flex;
        flex-direction: column;
        gap: 18px;
        align-items: stretch;
    }
    :is([data-rams-delete-modal], [data-rams-approve-modal]) .modal-form-panel {
        display: flex;
        flex-direction: column;
        gap: 20px;
        align-items: center;
        justify-content: center;
        min-height: 260px;
    }
    :is([data-rams-delete-modal], [data-rams-approve-modal]) .modal-form-panel .modal-form-card {
        max-width: 520px;
        width: 100%;
    }
    :is([data-rams-delete-modal], [data-rams-approve-modal]) .modal-form-card {
        border-radius: 20px;
        border: 1px solid #e2e8f0;
        padding: 18px 18px 16px;
        background: #f8fafc;
    }
    :is([data-rams-delete-modal], [data-rams-approve-modal]) .modal-form-card legend {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 6px;
    }
    .invoice-step1-card {
        padding: 22px 22px 18px;
    }
    .invoice-step1-card legend {
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .invoice-step1-card legend::before {
        content: 'Step 1';
        font-size: 0.7rem;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        padding: 2px 8px;
        border-radius: 999px;
        background: #e0f2fe;
        color: #0f172a;
    }
    .invoice-step2-card {
        padding: 22px 22px 18px;
    }
    .invoice-step2-card legend {
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .invoice-step2-card legend::before {
        content: 'Step 2';
        font-size: 0.7rem;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        padding: 2px 8px;
        border-radius: 999px;
        background: #e0f2fe;
        color: #0f172a;
    }
    .invoice-step1-card .text-muted.small-text {
        margin-top: 4px;
        margin-bottom: 10px;
    }
    .invoice-source-grid {
        display: grid;
        gap: 10px;
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        margin-top: 10px;
    }
    .invoice-source-tile {
        position: relative;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-radius: 999px;
        border: 1px solid #e2e8f0;
        background: #ffffff;
        color: #0f172a;
        text-decoration: none;
        font-size: 0.9rem;
        transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
    }
    .invoice-source-tile:hover {
        background: #eff6ff;
        border-color: #bfdbfe;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
        transform: translateY(-1px);
    }
    .invoice-source-tile--active {
        border-color: #4f46e5;
        background: linear-gradient(135deg, #eef2ff, #e0f2fe);
        box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
    }
    .invoice-source-tile__icon {
        width: 32px;
        height: 32px;
        border-radius: 999px;
        background: #eef2ff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #4338ca;
        flex-shrink: 0;
    }
    .invoice-source-tile__icon svg {
        width: 18px;
        height: 18px;
    }
    .invoice-source-tile__label {
        flex: 1 1 auto;
    }
    :is([data-rams-delete-modal], [data-rams-approve-modal]) .modal-form-actions {
        margin-top: 10px;
        display: flex;
        justify-content: flex-end;
        gap: 10px;
    }
    .quote-eyebrow {
        font-size: 0.72rem;
        letter-spacing: 0.22em;
        text-transform: uppercase;
        color: var(--hero-eyebrow, #93c5fd);
        margin: 0 0 6px 0;
    }
    .quote-step-card__header {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        flex-wrap: wrap;
        align-items: flex-start;
        margin-bottom: 18px;
    }
    .quote-section-title {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .quote-section-title__icon {
        width: 48px;
        height: 48px;
        border-radius: 16px;
        background: #eef2ff;
        color: #4338ca;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
        flex-shrink: 0;
    }
    .quote-section-title__icon svg {
        width: 26px;
        height: 26px;
    }
    .rams-filters {
        margin: 8px 0 14px 0;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: space-between;
        align-items: center;
    }
    .rams-filter-actions {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: flex-end;
        min-width: 0;
    }
    .rams-filter-pills {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        min-width: 0;
    }
    .rams-filter-pill {
        padding: 4px 10px;
        border-radius: 999px;
        border: 1px solid #e2e8f0;
        font-size: 0.8rem;
        text-decoration: none;
        color: #475569;
        background: #ffffff;
    }
    .rams-filter-pill--active {
        border-color: #0f172a;
        background: #0f172a;
        color: #f9fafb;
    }
    .rams-filter-search {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        align-items: center;
        min-width: 0;
    }
    .rams-filter-search input[type="date"],
    .rams-filter-search input[type="search"] {
        border-radius: 999px;
        border: 1px solid #d0d7e5;
        padding: 6px 10px;
        font: inherit;
        min-width: 0;
        width: auto;
        flex: 1 1 160px;
    }
    .rams-filter-search button {
        flex: 1 1 120px;
    }

	    @media (max-width: 768px) {
	        .rams-filters {
	            flex-direction: column;
	            align-items: stretch;
	        }

        .rams-filter-actions {
            align-items: stretch;
            width: 100%;
        }

        .rams-filter-pills {
            flex-wrap: nowrap;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
        }

        .rams-filter-pills::-webkit-scrollbar {
            display: none;
        }

        .rams-filter-pill {
            flex: 0 0 auto;
        }

	        .rams-filter-search button {
	            flex: 1 1 100%;
	        }
	    }

	    html[data-theme="dark"] .rams-filter-pill {
	        background: rgba(15, 23, 42, 0.65);
	        border-color: rgba(148, 163, 184, 0.22);
	        color: rgba(148, 163, 184, 0.95);
	    }

	    html[data-theme="dark"] .rams-filter-pill--active {
	        background: rgba(248, 250, 252, 0.96);
	        border-color: rgba(248, 250, 252, 0.96);
	        color: #1a1815;
	    }

	    html[data-theme="dark"] .quote-section-title__icon {
	        background: rgba(59, 130, 246, 0.16);
	        color: #93c5fd;
	        box-shadow: 0 10px 18px rgba(0, 0, 0, 0.45);
	    }

	    html[data-theme="dark"] :is([data-rams-delete-modal], [data-rams-approve-modal]) .modal-form-card {
	        background: rgba(15, 23, 42, 0.55);
	        border-color: rgba(148, 163, 184, 0.22);
	    }

	    html[data-theme="dark"] .invoice-step1-card legend::before,
	    html[data-theme="dark"] .invoice-step2-card legend::before {
	        background: rgba(59, 130, 246, 0.18);
	        color: #93c5fd;
	    }

	    html[data-theme="dark"] .invoice-source-tile {
	        background: rgba(2, 6, 23, 0.5);
	        border-color: rgba(148, 163, 184, 0.22);
	        color: rgba(248, 250, 252, 0.96);
	    }

	    html[data-theme="dark"] .invoice-source-tile:hover {
	        background: rgba(15, 23, 42, 0.75);
	        border-color: rgba(226, 232, 240, 0.32);
	        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
	    }

	    html[data-theme="dark"] .invoice-source-tile--active {
	        border-color: rgba(59, 130, 246, 0.55);
	        background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(2, 6, 23, 0.75));
	        box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5);
	    }

	    html[data-theme="dark"] .invoice-source-tile__icon {
	        background: rgba(59, 130, 246, 0.16);
	        color: #93c5fd;
	    }

/* ============================================================================
   RAMs canonical modal primitives — `.rams-modal*` (canonical chrome, additive
   over legacy `.rams-modal*` rules)
   Mirrors the .set-modal / .qbm-modal language used by settings/quotes/invoices
   so every global tenant modal (page-help, support, theme-picker, analytics-
   email, first-win pickers, guided-tour, import-pdf-loading) shares identical
   chrome, inputs, footer slots and mobile bottom-sheet behaviour.
   Values lifted from public/assets/css/settings-shell.css `.set-modal` block.

   Appended at end-of-file so these canonical rules win via source order against
   any earlier legacy .rams-modal chrome rules at equal specificity.
   ============================================================================ */

.rams-modal {
    --rams-accent: var(--accent, #c49510);
    --rams-accent-soft: var(--accent-soft, rgba(196, 149, 16, 0.1));
    --rams-accent-strong: rgba(196, 149, 16, 0.34);
    --rams-ink: var(--ink, #1a1815);
    --rams-ink-muted: var(--ink-3, #6b6458);
    --rams-ink-faint: var(--ink-4, #9a9188);
    --rams-border: var(--rule, rgba(26, 24, 21, 0.08));
    --rams-border-rule: rgba(26, 24, 21, 0.07);
    --rams-border-input: rgba(26, 24, 21, 0.14);
    --rams-bg-warm: #f7f5f0;
    --rams-surface: var(--surface-card, #ffffff);
    --rams-surface-soft: #fcfaf4;

    /* --ipi-* token aliases so canonical primitives (.ipi-tabs, .ipi-tab,
       .ipi-filter-search) render correctly inside the modal scope. */
    --ipi-bg: var(--canvas, #f7f5f0);
    --ipi-bg-inset: var(--surface-inset, #edeae3);
    --ipi-bg-card: var(--surface-card, #ffffff);
    --ipi-bg-hover: rgba(26, 24, 21, 0.04);
    --ipi-rule: var(--rule, rgba(26, 24, 21, 0.08));
    --ipi-rule-h: rgba(26, 24, 21, 0.11);
    --ipi-ink: var(--ink, #1a1815);
    --ipi-ink-2: #3d3a34;
    --ipi-ink-3: var(--ink-3, #6b6458);
    --ipi-ink-4: var(--ink-4, #9a9188);
    --ipi-accent: var(--accent, #c49510);
    --ipi-accent-bg: rgba(196, 149, 16, 0.08);
    --ipi-accent-border: rgba(196, 149, 16, 0.34);
    --ipi-shadow-sm: 0 1px 3px rgba(26, 24, 21, 0.06), 0 1px 2px rgba(26, 24, 21, 0.04);
    --ipi-shadow-card: 0 1px 4px rgba(26, 24, 21, 0.06), 0 0 0 1px rgba(26, 24, 21, 0.05);
}

/* Default dialog: content-driven height. Use --stable on tabbed/multi-state modals. */
.modal.rams-modal .rams-modal__dialog {
    width: min(880px, calc(100vw - 32px));
    max-height: min(90vh, 960px);
    border-radius: 16px;
    border: 1px solid var(--rams-border);
    background: var(--rams-surface);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.18),
        0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.modal.rams-modal .rams-modal__dialog--stable {
    height: min(85vh, 760px);
    min-height: min(60vh, 520px);
}

.modal.rams-modal .rams-modal__dialog--narrow {
    width: min(560px, calc(100vw - 32px));
}

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

/* Form wrapping body+footer must be flex so body's overflow-y:auto has a
   constrained parent. */
.modal.rams-modal form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    width: 100%;
}

.modal.rams-modal .rams-modal__header {
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--rams-border-rule);
    flex-shrink: 0;
    background: var(--rams-surface);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.modal.rams-modal .rams-modal__header > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
}

.modal.rams-modal .rams-modal__header-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.modal.rams-modal .rams-modal__header .eyebrow {
    margin: 0;
    color: var(--rams-accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* --danger modifier — red eyebrow + red primary button for destructive actions.
   `!important` required to override the canonical modal eyebrow color at
   `style.css:5003` which forces `color: var(--accent) !important` on every
   `.modal--sheet .modal__header .eyebrow`. */
.modal.rams-modal.rams-modal--danger .rams-modal__header .eyebrow {
    color: var(--danger, #b03030) !important;
}

.modal.rams-modal.rams-modal--danger .rams-modal__footer-actions .btn-danger {
    background: var(--danger, #b03030);
    color: #ffffff;
    border: none;
    font-weight: 600;
}

.modal.rams-modal.rams-modal--danger .rams-modal__footer-actions .btn-danger:hover {
    background: #952828;
}

html[data-theme="dark"] .modal.rams-modal.rams-modal--danger .rams-modal__header .eyebrow {
    color: #f87171 !important;
}

html[data-theme="dark"] .modal.rams-modal.rams-modal--danger .rams-modal__footer-actions .btn-danger {
    background: #dc2626;
}

html[data-theme="dark"] .modal.rams-modal.rams-modal--danger .rams-modal__footer-actions .btn-danger:hover {
    background: #b91c1c;
}

.modal.rams-modal .rams-modal__header .modal__title,
.modal.rams-modal .rams-modal__header h3 {
    margin: 0;
    font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
    font-size: 1.28rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--rams-ink);
}

.modal.rams-modal .rams-modal__header .text-muted,
.modal.rams-modal .rams-modal__header > div > p:not(.eyebrow) {
    margin: 4px 0 0;
    max-width: 60ch;
    color: var(--rams-ink-muted);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45;
}

.modal.rams-modal .modal__close {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--surface-inset, #edeae3);
    border: none;
    color: var(--rams-ink-muted);
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.modal.rams-modal .modal__close:hover {
    background: rgba(26, 24, 21, 0.1);
    color: var(--rams-ink);
}

.modal.rams-modal .rams-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 20px 22px 22px;
    background: var(--rams-bg-warm);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal.rams-modal .rams-modal__footer {
    padding: 13px 22px 14px;
    border-top: 1px solid var(--rams-border-rule);
    background: var(--rams-surface);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.modal.rams-modal .rams-modal__footer-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.modal.rams-modal .rams-modal__footer-copy strong {
    font-family: var(--font-display, 'Space Grotesk', system-ui, sans-serif);
    font-size: 13px;
    font-weight: 700;
    color: var(--rams-ink);
}

.modal.rams-modal .rams-modal__footer-copy p {
    margin: 0;
    font-size: 12px;
    color: var(--rams-ink-faint);
}

.modal.rams-modal .rams-modal__footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.modal.rams-modal .rams-modal__footer .btn {
    min-height: 40px;
    padding: 8px 18px;
}

/* Form controls */
.modal.rams-modal :where(input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"], input[type="url"], input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"], select, textarea) {
    min-height: 40px;
    padding: 10px 13px;
    border-radius: 9px;
    border: 1px solid var(--rams-border-input);
    background: var(--rams-surface);
    font-family: var(--font-sans, inherit);
    font-size: 13.5px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--rams-ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    width: 100%;
}

.modal.rams-modal :where(input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"], input[type="url"], input[type="search"], input[type="date"], input[type="datetime-local"], select, textarea):focus {
    border-color: var(--rams-accent-strong);
    box-shadow: 0 0 0 3px var(--rams-accent-soft);
    outline: none;
}

.modal.rams-modal textarea {
    min-height: 72px;
    resize: vertical;
    line-height: 1.5;
}

.modal.rams-modal select {
    padding-right: 34px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239a9188' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    cursor: pointer;
}

/* Dark mode */
html[data-theme="dark"] .modal.rams-modal {
    --rams-surface: #0f172a;
    --rams-surface-soft: rgba(15, 23, 42, 0.6);
    --rams-bg-warm: #0b1220;
    --rams-ink: #e2e8f0;
    --rams-ink-muted: #94a3b8;
    --rams-ink-faint: #94a3b8;
    --rams-border: rgba(148, 163, 184, 0.22);
    --rams-border-rule: rgba(148, 163, 184, 0.18);
    --rams-border-input: rgba(148, 163, 184, 0.28);
    --rams-accent: #e3b008;
    --rams-accent-soft: rgba(227, 176, 8, 0.18);
    --rams-accent-strong: rgba(244, 217, 139, 0.5);

    --ipi-bg: rgba(15, 23, 42, 0.55);
    --ipi-bg-inset: rgba(15, 23, 42, 0.62);
    --ipi-bg-card: rgba(15, 23, 42, 0.7);
    --ipi-bg-hover: rgba(148, 163, 184, 0.08);
    --ipi-rule: rgba(148, 163, 184, 0.22);
    --ipi-rule-h: rgba(148, 163, 184, 0.28);
    --ipi-ink: #e2e8f0;
    --ipi-ink-2: #cbd5e1;
    --ipi-ink-3: #94a3b8;
    --ipi-ink-4: #94a3b8;
    --ipi-accent: #e3b008;
    --ipi-accent-bg: rgba(227, 176, 8, 0.18);
    --ipi-accent-border: rgba(244, 217, 139, 0.5);
    --ipi-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --ipi-shadow-card: 0 1px 4px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(148, 163, 184, 0.1);
}

html[data-theme="dark"] .modal.rams-modal .rams-modal__dialog {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] .modal.rams-modal .modal__close {
    background: rgba(148, 163, 184, 0.16);
    color: rgba(226, 232, 240, 0.92);
}

html[data-theme="dark"] .modal.rams-modal .modal__close:hover {
    background: rgba(148, 163, 184, 0.28);
}

/* Mobile bottom-sheet behaviour (≤900px) — full-screen rules come from
   the canonical `.modal.modal--sheet` block in style.css. Only page/content
   overrides live here. */
@media (max-width: 900px) {
    /* Dialog chrome, header/body/footer padding, footer-copy visibility — all
       owned by canonical + gold-spec in style.css. Per-family base rule at
       ~line 2898 has equal specificity (0,3,0) to the canonical mobile rule,
       so we re-assert the canonical values here with !important to guarantee
       full-screen chrome. Matches the Invoices precedent at invoices.css:331. */
    .modal.modal--sheet.rams-modal .rams-modal__dialog,
    .modal.modal--sheet.rams-modal .rams-modal__dialog--stable,
    .modal.modal--sheet.rams-modal .rams-modal__dialog--narrow,
    .modal.modal--sheet.rams-modal .rams-modal__dialog--wide {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
    }

    .modal.rams-modal .rams-modal__body {
        gap: 12px;
    }

    /* RAMs Create Picker nests its own scroll + footer inside the body, each
       adding 16px side padding. Combined with the canonical 16px body padding
       (style.css:5063 !important) this produced a 32px inset — making the
       "What is this RAMs based on?" card 311px wide vs Invoices' 343px. Kill
       the canonical body padding for this modal only; scroll/step-badge/footer
       manage their own 16px insets inside. */
    .modal.modal--sheet.rams-create-picker-modal .rams-create-picker__body.modal__body {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Footer must stretch so the button grid can fill the full row. */
    .modal.rams-modal .rams-modal__footer {
        justify-content: stretch;
    }

    .modal.rams-modal .rams-modal__footer-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
        flex: 1 1 auto;
    }

    .modal.rams-modal .rams-modal__footer-actions > *:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .modal.rams-modal .rams-modal__footer-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
        font-size: 13px;
        padding-left: 6px;
        padding-right: 6px;
    }

    /* RAMs create-picker has its nested footer inside the body (one per
       step). On mobile the canonical .modal--sheet body padding-bottom
       (48px + safe-area) creates a visible gap BELOW the nested footer
       between it and the dialog bottom — that reads as a floating footer.
       Override body padding to 0 here and let the nested footer's own
       canonical 12px+safe-area padding handle viewport-edge breathing room. */
    .modal.modal--sheet.rams-create-picker-modal .rams-create-picker__body.modal__body {
        padding-bottom: 0 !important;
    }

    /* Sticky-pin the nested footer to the bottom of the step's scroll area
       so it never visually floats mid-modal when content is short. Inner
       no longer has side padding on mobile so footer fills the full body
       width naturally without needing negative margin. */
    .modal.rams-create-picker-modal .rams-create-picker__footer.modal__footer {
        position: sticky;
        bottom: 0;
        margin: 10px 0 0;
        padding: 12px 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        z-index: 2;
    }

    /* Footer buttons: 2-col grid matching canonical tenant-modal pattern.
       For 2 buttons = row of 2, for 3 buttons = 2 row + 1 full-width. */
    .modal.rams-create-picker-modal .rams-create-picker__footer {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        align-items: center;
    }

    .modal.rams-create-picker-modal .rams-create-picker__footer > *:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .modal.rams-create-picker-modal .rams-create-picker__footer .btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }
}
