/* Page patterns — UI enhancement step 3 (2026-10-08), the approved
   templates: list (erp/_list_page.html), record (erp/_record_header.html,
   _kv_section, _timeline), form (erp/_form_layout.html), empty states
   (erp/_empty_state.html) and the side-panel editor (data-modal-form=
   "drawer"). Tokens only, so light/dark follow tokens.css. */

/* ---------------------------------------------------------------- pills */
.erp-pill { display: inline-flex; align-items: center; font-size: var(--text-xs); font-weight: 600; border-radius: var(--radius-pill); padding: 2px 9px; white-space: nowrap; }
.erp-pill--ok { color: var(--ok-fg); background: var(--ok-bg); }
.erp-pill--warn { color: var(--warn-fg); background: var(--warn-bg); }
.erp-pill--crit { color: var(--crit-fg); background: var(--crit-bg); }
.erp-pill--info { color: var(--info-fg); background: var(--info-bg); }
.erp-pill--muted { color: var(--text-muted); background: var(--neutral-bg); }

/* ----------------------------------------------------------------- list */
.erp-list { display: flex; flex-direction: column; gap: var(--space-4); }
.erp-list__head { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; justify-content: space-between; }
.erp-list__eyebrow { font-size: var(--text-sm); color: var(--text-subtle); }
.erp-list__title { margin: 2px 0 0; font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 700; letter-spacing: -0.01em; }
.erp-list__count { font-family: var(--font-mono); font-size: var(--text-md); font-weight: 500; color: var(--text-subtle); }
.erp-list__subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: var(--text-base); }
.erp-list__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.erp-list__views { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.erp-list__view { padding: 9px 12px; font-size: var(--text-base); color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.erp-list__view:hover { color: var(--text); }
.erp-list__view.is-active { color: var(--text); font-weight: 600; border-bottom-color: var(--brand); }
.erp-list__view-count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); }
.erp-list .erp-filter-bar-wrap { margin: 0; }
.erp-list__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: calc(-1 * var(--space-2)); }
.erp-list__chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); padding: 5px 10px; border-radius: var(--radius-pill); border: 1px solid var(--brand); background: var(--brand-tint); color: var(--brand-strong); text-decoration: none; }
.erp-list__chip:hover { background: var(--brand-tint-strong); }
.erp-list__clear { font-size: var(--text-sm); color: var(--text-muted); }
.erp-list__foot { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; font-size: var(--text-sm); color: var(--text-muted); margin-top: calc(-1 * var(--space-2)); }
.erp-list__paging { display: flex; gap: var(--space-2); }

@media (max-width: 720px) {
  .erp-list__title { font-size: var(--text-2xl); }
  /* views become a scrollable chip row, like the phone template */
  .erp-list__views { border-bottom: 0; gap: var(--space-2); }
  .erp-list__view { border: 1px solid var(--line-strong); border-radius: var(--radius-pill); padding: 0 14px; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; background: var(--surface); }
  .erp-list__view.is-active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
  .erp-list__view.is-active .erp-list__view-count { color: var(--on-brand); }
  .erp-list__foot { justify-content: center; }
}

/* ---------------------------------------------------------- empty state */
.erp-empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-7) var(--space-6); display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); max-width: 640px; }
.erp-empty__icon { width: 52px; height: 52px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-tint); color: var(--brand); }
.erp-empty--no_results .erp-empty__icon { background: var(--surface-sunken); color: var(--text-muted); }
.erp-empty--module_required .erp-empty__icon { background: var(--warn-bg); color: var(--warn-fg); }
.erp-empty__title { margin: 0; font-family: var(--font-display); font-size: var(--text-xl); }
.erp-empty__text { margin: 0; color: var(--text-muted); line-height: 1.5; }
.erp-empty__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-1); }
.erp-empty__note { margin: 0; font-size: var(--text-xs); color: var(--text-subtle); }

/* --------------------------------------------------------------- record */
.erp-record { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-5) var(--space-5) 0; display: flex; flex-direction: column; gap: var(--space-4); }
.erp-record__top { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-start; justify-content: space-between; }
.erp-record__id { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.erp-record__line { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.erp-record__code { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-muted); }
.erp-record__title { margin: 0; font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 700; line-height: 1.15; }
.erp-record__subtitle { margin: 0; color: var(--text-muted); }
.erp-record__actions.obj-header { border: 0; padding: 0; margin: 0; background: none; }
.erp-record__figures { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.erp-record__figure { background: var(--surface-sunken); border-radius: var(--radius-md); padding: var(--space-3); }
.erp-record__figure dt { font-size: var(--text-xs); color: var(--text-muted); }
.erp-record__figure-value { margin: 4px 0 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-xl); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.erp-record__figure-note { margin: 0; font-size: var(--text-xs); color: var(--text-subtle); }
.erp-record__figure-note.is-ok { color: var(--ok-fg); font-weight: 600; }
.erp-record__figure-note.is-warn { color: var(--warn-fg); font-weight: 600; }
.erp-record__figure-note.is-crit { color: var(--crit-fg); font-weight: 600; }
.erp-record__tabs { display: flex; gap: 2px; border-top: 1px solid var(--line); margin: 0 calc(-1 * var(--space-5)); padding: 0 var(--space-4); overflow-x: auto; scrollbar-width: none; }
.erp-record__tab { padding: 11px 12px; font-size: var(--text-base); color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.erp-record__tab:hover { color: var(--text); }
.erp-record__tab.is-active { color: var(--text); font-weight: 600; border-bottom-color: var(--brand); }
.erp-record__tab-count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-subtle); }

.erp-record-body { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; margin-top: var(--space-4); }
.erp-record-body__main { flex: 3 1 520px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.erp-record-body__side { flex: 2 1 300px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }

.erp-kv, .erp-timeline { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.erp-kv__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); font-size: var(--text-sm); }
.erp-kv__title { margin: 0; font-family: var(--font-display); font-size: var(--text-lg); }
.erp-kv__rows { margin: 0; }
.erp-kv__row { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: var(--space-3); padding: 9px 0; border-bottom: 1px solid var(--line); }
.erp-kv__row:last-child { border-bottom: 0; }
.erp-kv__row dt { font-size: var(--text-sm); color: var(--text-subtle); }
.erp-kv__row dd { margin: 0; font-size: var(--text-base); min-width: 0; overflow-wrap: anywhere; }
.erp-kv__row dd.is-muted { color: var(--text-subtle); }
.erp-timeline__items { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-3); }
.erp-timeline__item { display: flex; gap: 10px; font-size: var(--text-sm); }
.erp-timeline__item::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--text-disabled); }
.erp-timeline__item--brand::before { background: var(--brand); }
.erp-timeline__item--info::before { background: var(--info); }
.erp-timeline__meta { color: var(--text-subtle); }
.erp-timeline__empty { margin: 0; font-size: var(--text-sm); color: var(--text-subtle); }

@media (max-width: 720px) {
  .erp-record { padding: var(--space-4) var(--space-4) 0; }
  .erp-record__title { font-size: var(--text-2xl); }
  .erp-record__figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .erp-record__tabs { margin: 0 calc(-1 * var(--space-4)); }
  .erp-kv { padding: var(--space-3) var(--space-4); }
  .erp-kv__row { grid-template-columns: 1fr; gap: 2px; }
}

/* ----------------------------------------------------------------- form */
.erp-form { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: flex-start; }
.erp-form__nav { flex: 1 1 180px; max-width: 210px; position: sticky; top: var(--space-4); display: flex; flex-direction: column; gap: 2px; }
.erp-form__nav-link { padding: 8px 12px; border-radius: var(--radius-sm); font-size: var(--text-base); color: var(--text-muted); text-decoration: none; }
.erp-form__nav-link:hover { background: var(--surface-hover); color: var(--text); }
.erp-form__nav-link.is-active { background: var(--brand-tint); color: var(--brand-strong); font-weight: 600; }
.erp-form__nav-link--extra { margin-top: var(--space-2); border-top: 1px solid var(--line); border-radius: 0; padding-top: 12px; }
.erp-form__nav-err { color: var(--crit-fg); }
.erp-form__body { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
/* a sentence of context above a form (what saving does), and the same box
   holding a one-click alternative (e.g. "Raise from the failed lot") */
.erp-form__notice { margin-bottom: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--text-muted); font-size: var(--text-sm); line-height: 1.5; }
.erp-form__notice strong { color: var(--text); }
.erp-form__notice--action { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); background: var(--brand-tint); }
/* a document's lines inside a form (erp/_formset_table.html) */
.erp-lines td { vertical-align: top; }
.erp-lines input, .erp-lines select { width: 100%; min-width: 0; padding: 7px 10px; border: 1px solid var(--line-strong, var(--line)); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; }
.erp-lines td.num input { text-align: end; font-family: var(--font-mono); min-width: 96px; }
.erp-lines tr.has-error input, .erp-lines tr.has-error select { border-color: var(--crit); }
.erp-lines .erp-field__error { display: block; margin-top: 4px; }
.erp-form__section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.erp-form__remove { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--text-muted); }
/* short forms (password, one or two fields): no side menu, one column */
.erp-form-narrow { max-width: 560px; }
.erp-form-narrow .erp-form__grid { grid-template-columns: minmax(0, 1fr); }
/* a wrapper a script needs around one field (designer conditions) — the
   grid still sees the field itself */
.erp-field-slot { display: contents; }
.erp-inline-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.erp-profile-id { display: flex; align-items: center; gap: var(--space-4); }
.erp-avatar--lg { width: 64px; height: 64px; font-size: var(--text-lg); }
/* one-field action forms (verification code + button) and their bits */
.erp-inline-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; }
.erp-inline-form .erp-field { flex: 1 1 180px; max-width: 260px; }
.erp-codes { columns: 2; list-style: none; padding: 0; font-size: var(--text-md); }
.erp-steps { padding-inline-start: 18px; line-height: 1.6; }
.erp-secret { letter-spacing: .05em; }
.erp-form-medium { max-width: 760px; }
.erp-form-medium .erp-form__body > .panel, .erp-fieldset { margin: 0; }
.erp-fieldset { border: none; padding: 0; min-width: 0; }
.erp-check-label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.erp-check-label input { width: auto; }
.erp-field--narrow { max-width: 280px; }
.erp-pre { white-space: pre-wrap; margin: 0; }
.erp-total-row td { font-weight: 600; border-top: 2px solid var(--line); }
.erp-total-row td:first-child { text-align: end; }
.erp-record__tabs--flat { margin: var(--space-4) 0 var(--space-3); border-bottom: 1px solid var(--line); }
/* a short list of people/items with inline actions (recruitment pipeline) */
.erp-cardlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.erp-cardlist__item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); }
.erp-article { font-size: var(--text-md); line-height: 1.65; max-width: 72ch; }
/* sections placed straight under a record header (no record body) */
.erp-record ~ .erp-kv, .erp-record ~ form > .erp-kv { margin-top: var(--space-4); }
.erp-gap { margin-top: var(--space-4); }
/* the plain page header with actions on the right (reports, consoles) */
.page-header--split { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.page-header__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.erp-gap-sm { margin-top: var(--space-2); }
.erp-gap-bottom { margin-bottom: var(--space-4); }
.erp-panel--crit { border-color: var(--crit); }
.erp-text-crit { color: var(--crit-fg); }
.erp-w20 { width: 20%; } .erp-w25 { width: 25%; } .erp-w30 { width: 30%; }
.erp-empty--compact { padding: var(--space-5) var(--space-4); }
.erp-empty--compact .erp-empty__text { margin: 0; }
/* read by screen readers only (labels of self-explanatory pickers) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* ---------------------------------------------------- customer portal shop */
.erp-shop { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); }
.erp-shop__card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.erp-shop__head { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.erp-shop__name { margin: 0; font-family: var(--font-display); font-size: var(--text-md); }
.erp-shop__price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: var(--text-lg); }
.erp-shop__add { display: flex; gap: var(--space-2); }
.erp-shop__add input { width: 72px; padding: 8px 10px; border: 1px solid var(--line-strong, var(--line)); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; text-align: end; }
.erp-shop__add .btn { flex: 1; justify-content: center; }
.erp-shop__search { flex: 1 1 260px; max-width: 420px; }
@media (max-width: 720px) { .erp-shop { grid-template-columns: 1fr; } }
.erp-form__errors { background: var(--crit-bg); color: var(--crit-fg); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); font-size: var(--text-base); }
.erp-form__errors a { color: var(--crit-fg); text-decoration: underline; }
.erp-form__section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); scroll-margin-top: var(--space-4); }
.erp-form__section-title { margin: 0; font-family: var(--font-display); font-size: var(--text-lg); }
.erp-form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-4); }
.erp-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.erp-field--wide { grid-column: 1 / -1; }
.erp-field > label { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.erp-field__req { color: var(--crit-fg); }
.erp-field > input:not([type=checkbox]):not([type=radio]), .erp-field > select, .erp-field > textarea {
  width: 100%; box-sizing: border-box; padding: 9px var(--space-3); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 16px; font-family: var(--font-body);
  color: var(--text); outline: none; transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.erp-field > textarea { resize: vertical; min-height: 96px; font-size: var(--text-md); }
.erp-field > input:focus, .erp-field > select:focus, .erp-field > textarea:focus { border-color: var(--brand); box-shadow: var(--focus-ring); }
.erp-field > input::placeholder, .erp-field > textarea::placeholder { color: var(--text-subtle); }
@media (max-width: 720px) { .erp-field > input:not([type=checkbox]):not([type=radio]), .erp-field > select { min-height: 44px; } }
.erp-field__hint { font-size: var(--text-xs); color: var(--text-subtle); }
.erp-field__error { font-size: var(--text-xs); font-weight: 600; color: var(--crit-fg); }
.erp-field.has-error > input, .erp-field.has-error > select, .erp-field.has-error > textarea { border-color: var(--crit); }
.erp-field--check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--space-2); grid-column: 1 / -1; }
.erp-field--check > label { font-weight: 500; }
.erp-form__bar { position: sticky; bottom: 0; z-index: 5; margin: var(--space-5) calc(-1 * var(--space-7)) 0; padding: var(--space-3) var(--space-7); background: var(--surface); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: flex-end; }
.erp-form__dirty { margin-inline-end: auto; font-size: var(--text-sm); color: var(--text-subtle); }
.erp-form__bar .btn-ghost { background: none; border-color: transparent; color: var(--text-muted); }
.erp-form__bar .btn-ghost:hover { color: var(--text); }
/* inside the modal dialog: no side menu, the bar sticks to the dialog's bottom */
.erp-modal .erp-form__nav { display: none; }
.erp-modal .erp-form__bar { margin: var(--space-4) calc(-1 * var(--space-6)) calc(-1 * var(--space-6)); padding: var(--space-3) var(--space-6); }

@media (max-width: 720px) {
  .erp-form__nav { position: static; max-width: none; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .erp-form__nav-link { white-space: nowrap; }
  .erp-form__nav-link--extra { margin: 0; border: 0; padding-top: 8px; }
  .erp-form__grid { grid-template-columns: 1fr; }
  .erp-form__section { padding: var(--space-4); }
  .erp-form__bar { bottom: calc(var(--bottom-nav-h, 64px) + env(safe-area-inset-bottom)); margin: var(--space-4) calc(-1 * var(--space-4)) 0; padding: var(--space-3) var(--space-4); }
  .erp-modal .erp-form__bar { bottom: 0; }
}

/* --------------------------------------------- side-panel editor (drawer) */
.erp-modal--drawer { width: min(460px, 100vw); min-width: 0; height: 100vh; max-height: 100vh; margin-block: 0 0; margin-inline: auto 0; border-radius: 0; border-width: 0 0 0 1px; }
.erp-modal--drawer .erp-modal__resize-grip { display: none; }

/* ------------------------------------------- phone gate (redesigned) */
.m-phone-gate__actions form { margin: 0; }
.m-phone-gate__actions form .btn { width: 100%; justify-content: center; }
.m-phone-gate__continue { background: none; border-color: transparent; color: var(--brand); font-weight: 600; }
.m-phone-gate__elsewhere { width: 100%; margin-top: var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-4); display: flex; flex-direction: column; text-align: start; }
.m-phone-gate__elsewhere-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); padding: var(--space-2) 0; }
.m-phone-gate__elsewhere a { min-height: 44px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }

/* table cells: tone + inline POST buttons (step 4) */
.erp-cell--crit { color: var(--crit-fg); font-weight: 600; }
.erp-cell--warn { color: var(--warn-fg); font-weight: 600; }
.erp-cell--strong { font-weight: 600; }
.erp-cell--muted { color: var(--text-subtle); }
.erp-cell__sub { display: block; margin-top: 2px; font-family: var(--font-body); font-size: var(--text-xs); font-weight: 400; color: var(--text-subtle); white-space: nowrap; }
.erp-cell__sub.erp-cell--crit { color: var(--crit-fg); font-weight: 600; }
.erp-cell__sub.erp-cell--warn { color: var(--warn-fg); font-weight: 600; }
.erp-inline-form { display: inline; margin: 0; }
.data-table tr.is-dimmed td { opacity: .55; }
