/* Recurring invoices, company texts and e-mail templates (lot 19b). Tokens only (tokens.css). */

/* ---------- List ---------- */
.yb-recurring-list {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-5);
}

.yb-recurring-empty__steps {
  display: grid;
  gap: var(--yb-space-2);
  max-width: 460px;
  margin: var(--yb-space-2) auto 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.yb-recurring-empty__steps li {
  display: flex;
  align-items: flex-start;
  gap: var(--yb-space-3);
  color: var(--yb-text-muted);
}

.yb-recurring-empty__steps .mud-icon-root {
  flex: none;
  margin-top: 1px;
  color: var(--yb-primary);
}

.yb-recurring-next {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.25;
}

.yb-recurring-next__relative {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-recurring-next--none {
  color: var(--yb-text-disabled);
}

.yb-recurring-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--yb-text-muted);
  white-space: nowrap;
}

.yb-recurring-mode[data-mode="autosend"] {
  color: var(--yb-text);
}

.yb-recurring-mode[data-mode="autosend"] .mud-icon-root {
  color: var(--yb-primary);
}

.yb-recurring-state {
  display: inline-flex;
  align-items: center;
  gap: var(--yb-space-2);
}

.yb-recurring-attention {
  display: inline-flex;
  color: var(--yb-warning);
}

.yb-recurring-card__who {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.yb-recurring-card__name {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

/* ---------- Editor ---------- */
.yb-recurring-dirty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-recurring-dirty__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yb-accent);
}

.yb-recurring-source {
  display: flex;
  align-items: center;
  gap: var(--yb-space-2);
  margin: 0;
  padding: var(--yb-space-3) var(--yb-space-4);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-primary-soft);
  color: var(--yb-on-primary-soft);
}

.yb-paper-static {
  display: inline-block;
  padding: 4px 6px;
  font-weight: var(--yb-weight-medium);
}

.yb-paper-input--short {
  width: 4.5em;
  text-align: right;
}

.yb-recurring-term {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: var(--yb-text-muted);
}

.yb-recurring-recipient--problem,
.yb-recurring-lines--problem {
  border-radius: var(--yb-radius-sm);
  box-shadow: 0 0 0 2px var(--yb-error-soft);
}

.yb-recurring-paper-end {
  margin: 0 calc(-1 * var(--yb-paper-pad));
  padding: var(--yb-space-2) 0 var(--yb-space-4);
}

/* ---------- Schedule panel ---------- */
.yb-schedule {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-4);
  padding: var(--yb-space-5);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-surface);
}

.yb-schedule__title {
  margin: 0;
  font-size: var(--yb-text-title-3);
  font-weight: var(--yb-weight-title-3);
  line-height: var(--yb-leading-title-3);
}

.yb-schedule__subtitle {
  margin: 0 0 var(--yb-space-2);
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-strong);
  color: var(--yb-text-muted);
}

.yb-schedule__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.yb-schedule__label {
  padding: 0;
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
  line-height: var(--yb-leading-caption);
  color: var(--yb-text);
}

.yb-schedule__input {
  width: 100%;
  min-width: 0;
  height: var(--yb-field-height);
  padding: 0 var(--yb-space-3);
  border: 1px solid var(--yb-border-input);
  border-radius: var(--yb-radius-sm);
  background: var(--yb-surface);
  color: var(--yb-text);
  font: inherit;
}

.yb-schedule__input:focus-visible {
  outline: 2px solid var(--yb-focus);
  outline-offset: 1px;
}

.yb-schedule__input:disabled {
  background: var(--yb-bg-sunken);
  color: var(--yb-text-muted);
}

.yb-schedule__input--short {
  width: 5.5em;
  text-align: right;
}

.yb-schedule__field--invalid .yb-schedule__input,
.yb-schedule__input[aria-invalid="true"] {
  border-color: var(--yb-error);
}

.yb-schedule__help,
.yb-schedule__note {
  margin: 0;
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  line-height: var(--yb-leading-caption);
}

.yb-schedule__error {
  color: var(--yb-error);
  font-size: var(--yb-text-caption);
  line-height: var(--yb-leading-caption);
}

.yb-schedule__row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: var(--yb-space-3);
}

.yb-schedule__inline {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--yb-space-2);
  margin-top: var(--yb-space-1);
  color: var(--yb-text-muted);
}

.yb-schedule__inline .yb-schedule__input {
  width: auto;
}

.yb-schedule__frequencies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.yb-schedule__frequency {
  height: 32px;
  padding: 0 var(--yb-space-3);
  border: 1px solid var(--yb-border-strong);
  border-radius: var(--yb-radius-pill);
  background: var(--yb-surface);
  color: var(--yb-text);
  font: inherit;
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
  cursor: pointer;
  transition: background-color var(--yb-duration-fast) var(--yb-ease), border-color var(--yb-duration-fast) var(--yb-ease);
}

.yb-schedule__frequency:hover:not(:disabled) {
  border-color: var(--yb-text-muted);
}

.yb-schedule__frequency--selected,
.yb-schedule__frequency--selected:hover:not(:disabled) {
  border-color: var(--yb-text);
  background: var(--yb-text);
  color: var(--yb-bg);
}

.yb-schedule__frequency:focus-visible {
  outline: 2px solid var(--yb-focus);
  outline-offset: 2px;
}

.yb-schedule__choices,
.yb-schedule__modes {
  display: grid;
  gap: var(--yb-space-2);
}

.yb-schedule__choice,
.yb-schedule__mode {
  display: flex;
  align-items: flex-start;
  gap: var(--yb-space-3);
  padding: var(--yb-space-3);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-sm);
  background: var(--yb-surface);
  cursor: pointer;
  transition: border-color var(--yb-duration-fast) var(--yb-ease), background-color var(--yb-duration-fast) var(--yb-ease);
}

.yb-schedule__choice input {
  margin: 3px 0 0;
  accent-color: var(--yb-primary);
}

.yb-schedule__choice:hover,
.yb-schedule__mode:hover {
  border-color: var(--yb-border-strong);
}

.yb-schedule__choice--selected,
.yb-schedule__mode--selected,
.yb-schedule__choice--selected:hover,
.yb-schedule__mode--selected:hover {
  border-color: var(--yb-primary);
  background: var(--yb-selected);
}

.yb-schedule__mode:has(input:focus-visible) {
  outline: 2px solid var(--yb-focus);
  outline-offset: 2px;
}

.yb-schedule__mode-icon.mud-icon-root {
  flex: none;
  margin-top: 1px;
  color: var(--yb-text-muted);
}

.yb-schedule__mode--selected .yb-schedule__mode-icon.mud-icon-root {
  color: var(--yb-primary);
}

.yb-schedule__choice-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.yb-schedule__choice-title {
  font-weight: var(--yb-weight-medium);
}

.yb-schedule__choice-help {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  line-height: var(--yb-leading-caption);
}

.yb-schedule__warnings {
  display: grid;
  gap: 6px;
  margin: var(--yb-space-1) 0 0;
  padding: var(--yb-space-3);
  border-radius: var(--yb-radius-sm);
  background: var(--yb-warning-soft);
  color: var(--yb-text);
  font-size: var(--yb-text-caption);
  line-height: var(--yb-leading-caption);
  list-style: none;
}

.yb-schedule__warnings li {
  display: flex;
  gap: var(--yb-space-2);
}

.yb-schedule__warnings .mud-icon-root {
  flex: none;
  color: var(--yb-warning);
  font-size: 16px;
}

.yb-schedule__upcoming {
  padding-top: var(--yb-space-4);
  border-top: 1px solid var(--yb-border);
}

.yb-schedule__dates {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.yb-schedule__date {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--yb-space-2);
  padding: 6px var(--yb-space-2);
  border-radius: var(--yb-radius-sm);
  color: var(--yb-text-muted);
}

.yb-schedule__date--next {
  background: var(--yb-accent-soft);
  color: var(--yb-on-accent-soft);
}

.yb-schedule__date-value {
  font-weight: var(--yb-weight-medium);
}

.yb-schedule__date-period {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yb-schedule__date-relative {
  font-size: var(--yb-text-caption);
  white-space: nowrap;
}

.yb-schedule__summary {
  margin: var(--yb-space-2) 0 0;
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

/* ---------- Period variables ---------- */
.yb-variables {
  padding: var(--yb-space-4) var(--yb-space-5);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-surface);
}

.yb-variables__title {
  margin: 0 0 4px;
  font-size: var(--yb-text-title-3);
  font-weight: var(--yb-weight-title-3);
}

.yb-variables__lead {
  margin: 0 0 var(--yb-space-3);
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  line-height: var(--yb-leading-caption);
}

.yb-variables__list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.yb-variables__item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--yb-space-3);
  width: 100%;
  padding: 6px var(--yb-space-2);
  border: 0;
  border-radius: var(--yb-radius-sm);
  background: transparent;
  color: var(--yb-text);
  font: inherit;
  text-align: left;
  cursor: copy;
}

.yb-variables__item:hover {
  background: var(--yb-hover);
}

.yb-variables__item:focus-visible {
  outline: 2px solid var(--yb-focus);
  outline-offset: 1px;
}

.yb-variables__token {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--yb-bg-sunken);
  color: var(--yb-primary);
  font-family: inherit;
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
}

.yb-variables__value {
  overflow: hidden;
  color: var(--yb-text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Detail page ---------- */
.yb-recurring-page {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-5);
}

.yb-recurring-client {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--yb-space-1) var(--yb-space-4);
  margin: calc(-1 * var(--yb-space-3)) 0 0;
  font-weight: var(--yb-weight-medium);
}

.yb-recurring-client a {
  color: var(--yb-primary);
  text-decoration: none;
}

.yb-recurring-client a:hover {
  text-decoration: underline;
}

.yb-recurring-client__rhythm {
  color: var(--yb-text-muted);
  font-weight: var(--yb-weight-regular);
}

.yb-recurring-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--yb-space-3);
  padding: var(--yb-space-4);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-bg-sunken);
}

.yb-recurring-banner p {
  margin: 0;
  color: var(--yb-text-muted);
}

.yb-recurring-banner .yb-recurring-banner__title {
  color: var(--yb-text);
  font-weight: var(--yb-weight-medium);
}

.yb-recurring-banner > .mud-icon-root {
  flex: none;
  color: var(--yb-text-muted);
}

.yb-recurring-banner--paused {
  border-color: var(--yb-status-amber-bg);
  background: var(--yb-status-amber-bg);
}

.yb-recurring-banner--paused > .mud-icon-root {
  color: var(--yb-status-amber-fg);
}

/* The rhythm of the subscription: stubs torn along the perforation of the QR-bill. */
.yb-cadence {
  margin: 0;
  padding: var(--yb-space-5) var(--yb-space-5) var(--yb-space-4);
  overflow-x: auto;
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-surface);
  scrollbar-width: thin;
}

.yb-cadence__track {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--yb-space-2);
  min-width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
}

.yb-cadence__track::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 8px;
  transform: translateY(-50%);
  background: radial-gradient(circle, var(--yb-border-strong) var(--yb-perforation-dot), transparent calc(var(--yb-perforation-dot) + 0.5px)) 0 50% / var(--yb-perforation-gap) 8px repeat-x;
}

.yb-cadence__stub {
  --yb-cadence-tone: var(--yb-status-neutral-fg);
  position: relative;
  z-index: 1;
}

.yb-cadence__stub--green { --yb-cadence-tone: var(--yb-status-green-fg); }
.yb-cadence__stub--blue { --yb-cadence-tone: var(--yb-status-blue-fg); }
.yb-cadence__stub--petrol { --yb-cadence-tone: var(--yb-status-petrol-fg); }
.yb-cadence__stub--red { --yb-cadence-tone: var(--yb-status-red-fg); }
.yb-cadence__stub--amber,
.yb-cadence__stub--attention { --yb-cadence-tone: var(--yb-status-amber-fg); }
.yb-cadence__stub--orange { --yb-cadence-tone: var(--yb-status-orange-fg); }
.yb-cadence__stub--bordeaux { --yb-cadence-tone: var(--yb-status-bordeaux-fg); }
.yb-cadence__stub--violet { --yb-cadence-tone: var(--yb-status-violet-fg); }
.yb-cadence__stub--planned { --yb-cadence-tone: var(--yb-text-disabled); }
.yb-cadence__stub--next { --yb-cadence-tone: var(--yb-primary); }

.yb-cadence__ticket {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 132px;
  padding: var(--yb-space-3) var(--yb-space-4) var(--yb-space-3) calc(var(--yb-space-4) + 2px);
  border: 1px solid var(--yb-border-strong);
  border-left: 3px solid var(--yb-cadence-tone);
  border-radius: var(--yb-radius-sm);
  background: var(--yb-surface);
  color: var(--yb-text);
  text-decoration: none;
  transition: border-color var(--yb-duration-fast) var(--yb-ease), box-shadow var(--yb-duration-fast) var(--yb-ease);
}

/* Notches of a torn stub on its right edge. */
.yb-cadence__ticket::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -6px;
  width: 10px;
  height: 10px;
  border: 1px solid var(--yb-border-strong);
  border-radius: 50%;
  background: var(--yb-surface);
  transform: translateY(-50%);
  clip-path: inset(0 50% 0 0);
}

/* A past stub is a button (it opens its invoice in a window, C3): no button look. */
button.yb-cadence__ticket {
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button.yb-cadence__ticket:hover {
  border-color: var(--yb-text-muted);
  border-left-color: var(--yb-cadence-tone);
  box-shadow: var(--yb-shadow-xs);
}

button.yb-cadence__ticket:focus-visible {
  outline: 2px solid var(--yb-focus);
  outline-offset: 2px;
}

.yb-cadence__stub--planned .yb-cadence__ticket,
.yb-cadence__stub--next .yb-cadence__ticket {
  border-style: dashed;
  border-left-style: solid;
  background: var(--yb-bg);
  color: var(--yb-text-muted);
}

.yb-cadence__stub--next .yb-cadence__ticket {
  border-color: var(--yb-primary);
  color: var(--yb-text);
}

.yb-cadence__stub--next .yb-cadence__ticket::after,
.yb-cadence__stub--planned .yb-cadence__ticket::after {
  border-style: dashed;
  background: var(--yb-bg);
}

.yb-cadence__period {
  font-weight: var(--yb-weight-strong);
  white-space: nowrap;
}

.yb-cadence__date {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-cadence__state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
  color: var(--yb-text);
  white-space: nowrap;
}

.yb-cadence__stub--planned .yb-cadence__state {
  color: var(--yb-text-muted);
}

.yb-cadence__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yb-cadence-tone);
}

.yb-cadence__stub--planned .yb-cadence__dot,
.yb-cadence__stub--next .yb-cadence__dot {
  border: 1.5px dashed var(--yb-cadence-tone);
  background: transparent;
}

.yb-cadence__today {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 var(--yb-space-2);
  background: var(--yb-surface);
}

.yb-cadence__today-pin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--yb-accent);
  box-shadow: 0 0 0 4px var(--yb-accent-soft);
}

.yb-cadence__today-label {
  color: var(--yb-on-accent-soft);
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
  white-space: nowrap;
}

.yb-recurring-layout {
  container: recurring / inline-size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: var(--yb-space-5);
}

.yb-recurring-layout__main {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-5);
  min-width: 0;
}

.yb-recurring-layout__aside {
  min-width: 0;
}

.yb-recurring-preview.yb-pdf {
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  overflow: hidden;
}

/* Tablets: the two latest invoices, today and what comes next. */
@media (max-width: 1179.98px) {
  .yb-cadence__stub[data-age="2"],
  .yb-cadence__stub[data-age="3"] {
    display: none;
  }
}

@media (min-width: 1180px) {
  .yb-recurring-layout {
    grid-template-columns: minmax(0, 1fr) clamp(320px, 34%, 440px);
  }

  .yb-recurring-layout__aside {
    position: sticky;
    top: calc(var(--yb-topbar-height) + var(--yb-space-4));
  }
}

.yb-recurring-nextcard {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--yb-space-4) var(--yb-space-8);
}

.yb-recurring-nextcard__when {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.yb-recurring-nextcard__label {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
}

.yb-recurring-nextcard__date {
  font-size: var(--yb-text-amount-hero);
  font-weight: var(--yb-weight-title-1);
  line-height: var(--yb-leading-amount-hero);
  letter-spacing: -0.02em;
}

.yb-recurring-nextcard__relative {
  color: var(--yb-on-accent-soft);
  font-weight: var(--yb-weight-medium);
}

.yb-recurring-facts {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: var(--yb-space-2) var(--yb-space-6);
  margin: 0;
}

.yb-recurring-facts div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.yb-recurring-facts dt,
.yb-recurring-details dt {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-recurring-facts dd,
.yb-recurring-details dd {
  margin: 0;
  font-weight: var(--yb-weight-medium);
}

.yb-recurring-mode-line {
  display: flex;
  align-items: flex-start;
  gap: var(--yb-space-2);
  margin: var(--yb-space-4) 0 0;
  padding-top: var(--yb-space-4);
  border-top: 1px solid var(--yb-border);
  color: var(--yb-text-muted);
}

.yb-recurring-mode-line .mud-icon-root {
  flex: none;
  color: var(--yb-primary);
}

.yb-recurring-history {
  margin: 0;
  padding: 0;
  list-style: none;
}

.yb-recurring-history__empty {
  margin: 0;
  padding: var(--yb-space-5);
  color: var(--yb-text-muted);
}

.yb-recurring-run {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto 110px;
  align-items: center;
  gap: var(--yb-space-3);
  min-height: 60px;
  padding: var(--yb-space-2) var(--yb-space-5);
  border-top: 1px solid var(--yb-border);
}

.yb-recurring-run:first-child {
  border-top: 0;
}

.yb-recurring-run__marker {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--yb-bg-sunken);
  color: var(--yb-text-muted);
}

.yb-recurring-run--sent .yb-recurring-run__marker {
  background: var(--yb-primary-soft);
  color: var(--yb-on-primary-soft);
}

.yb-recurring-run--fallbackdraft .yb-recurring-run__marker {
  background: var(--yb-status-amber-bg);
  color: var(--yb-status-amber-fg);
}

.yb-recurring-run__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.yb-recurring-run__period {
  font-weight: var(--yb-weight-medium);
}

.yb-recurring-run__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--yb-space-3);
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-recurring-run__problem {
  color: var(--yb-status-amber-fg);
  font-size: var(--yb-text-caption);
}

.yb-recurring-run__document {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--yb-space-2);
}

.yb-recurring-run__number {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  color: var(--yb-primary);
  font-weight: var(--yb-weight-medium);
  text-decoration: none;
  white-space: nowrap;
}

.yb-recurring-run__number:hover {
  text-decoration: underline;
}

.yb-recurring-run__number--gone {
  color: var(--yb-text-disabled);
  font-weight: var(--yb-weight-regular);
}

.yb-recurring-run__amount {
  text-align: right;
}

.yb-recurring-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--yb-space-4) var(--yb-space-6);
  margin: 0;
}

.yb-recurring-details div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@media (max-width: 767px) {
  .yb-recurring-run {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    padding: var(--yb-space-3) var(--yb-space-4);
  }

  .yb-recurring-run__document {
    grid-column: 2 / 4;
    justify-content: flex-start;
  }

  .yb-recurring-run__amount {
    grid-column: 3;
    grid-row: 1;
  }

  .yb-recurring-facts {
    grid-template-columns: 1fr 1fr;
  }

  .yb-recurring-nextcard__date {
    font-size: var(--yb-text-amount-compact);
    line-height: var(--yb-leading-amount-compact);
  }

  .yb-cadence {
    padding: var(--yb-space-4);
  }

  .yb-cadence__ticket {
    min-width: 116px;
  }

  /* Phones: the last invoice, today and what comes next fit without scrolling. */
  .yb-cadence__stub[data-age="1"],
  .yb-cadence__stub[data-age="2"],
  .yb-cadence__stub[data-age="3"] {
    display: none;
  }
}

/* ---------- Generated invoice: link back to its recurring invoice ---------- */
.yb-recurring-origin {
  display: flex;
  align-items: flex-start;
  gap: var(--yb-space-2);
  padding: var(--yb-space-3) var(--yb-space-4);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-surface);
  color: var(--yb-text-muted);
}

.yb-recurring-origin > .mud-icon-root {
  flex: none;
  margin-top: 2px;
  color: var(--yb-primary);
}

.yb-recurring-origin p {
  margin: 0;
}

.yb-recurring-origin a {
  margin-left: var(--yb-space-2);
  color: var(--yb-primary);
  font-weight: var(--yb-weight-medium);
}

.yb-recurring-origin__problem {
  display: block;
  margin-top: 4px;
  color: var(--yb-text);
}

.yb-recurring-origin--problem {
  border-color: var(--yb-status-amber-bg);
  background: var(--yb-status-amber-bg);
}

.yb-recurring-origin--problem > .mud-icon-root {
  color: var(--yb-status-amber-fg);
}

.yb-docview__header + .yb-issued-banner + .yb-recurring-origin {
  margin-top: calc(-1 * var(--yb-space-2));
}

.yb-send-copy {
  margin-top: calc(-1 * var(--yb-space-1));
}

/* ---------- Settings › Textes et e-mails ---------- */
.yb-texts {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-6);
}

.yb-texts__languages {
  position: sticky;
  top: calc(var(--yb-topbar-height) + var(--yb-space-2));
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--yb-space-2) var(--yb-space-3);
  padding: var(--yb-space-3) var(--yb-space-4);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-surface);
  box-shadow: var(--yb-shadow-xs);
}

.yb-texts__languages-label {
  font-weight: var(--yb-weight-medium);
}

.yb-texts__languages-help {
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-texts__group {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-4);
  padding-top: var(--yb-space-6);
  border-top: 1px solid var(--yb-border);
}

.yb-texts__group-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 640px;
}

.yb-texts__group-title {
  margin: 0;
  font-size: var(--yb-text-title-3);
  font-weight: var(--yb-weight-title-3);
  line-height: var(--yb-leading-title-3);
}

.yb-texts__group-head p {
  margin: 0;
  color: var(--yb-text-muted);
}

.yb-texts__group {
  container: textpair / inline-size;
}

.yb-texts__pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--yb-space-5);
}

@container textpair (min-width: 600px) {
  .yb-texts__pair {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  }
}

.yb-texts__fields {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-4);
  min-width: 0;
}

.yb-texts__note {
  margin: 0;
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-texts__letter,
.yb-texts__mail {
  margin: 0;
  min-width: 0;
}

.yb-texts__preview-caption {
  margin-bottom: var(--yb-space-2);
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
}

.yb-template-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.yb-template-field__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--yb-space-2);
}

.yb-template-field__label {
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
}

.yb-template-field__origin {
  padding: 1px 8px;
  border-radius: var(--yb-radius-pill);
  background: var(--yb-bg-sunken);
  color: var(--yb-text-muted);
  font-size: 11.5px;
  font-weight: var(--yb-weight-medium);
}

.yb-template-field--custom .yb-template-field__origin {
  background: var(--yb-accent-soft);
  color: var(--yb-on-accent-soft);
}

.yb-template-field__tools {
  display: inline-flex;
  gap: var(--yb-space-1);
  margin-left: auto;
}

.yb-template-field__tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 var(--yb-space-2);
  border: 0;
  border-radius: var(--yb-radius-sm);
  background: transparent;
  color: var(--yb-primary);
  font: inherit;
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-medium);
  cursor: pointer;
}

.yb-template-field__tool:hover {
  background: var(--yb-hover);
}

.yb-template-field__tool:focus-visible {
  outline: 2px solid var(--yb-focus);
  outline-offset: 1px;
}

.yb-template-field__variable {
  display: flex;
  justify-content: space-between;
  gap: var(--yb-space-4);
  width: 100%;
}

.yb-template-field__variable code {
  color: var(--yb-text-muted);
  font-family: inherit;
  font-size: var(--yb-text-caption);
}

.yb-template-field__input {
  width: 100%;
  min-height: var(--yb-field-height);
  padding: 9px var(--yb-space-3);
  border: 1px solid var(--yb-border-input);
  border-radius: var(--yb-radius-sm);
  background: var(--yb-surface);
  color: var(--yb-text);
  font: inherit;
  line-height: var(--yb-leading-body);
}

.yb-template-field__input--multi {
  resize: vertical;
  field-sizing: content;
  max-height: 480px;
}

.yb-template-field__input:focus-visible {
  outline: 2px solid var(--yb-focus);
  outline-offset: 1px;
}

.yb-template-field__input:disabled {
  background: var(--yb-bg-sunken);
  color: var(--yb-text-muted);
}

.yb-template-field__unknown {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  color: var(--yb-status-amber-fg);
  font-size: var(--yb-text-caption);
}

.yb-template-field__unknown .mud-icon-root {
  flex: none;
  font-size: 16px;
}

/* A sheet of the document, shrunk: where the intro and the footer land. */
.yb-texts-letter {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-3);
  padding: var(--yb-space-5) var(--yb-space-6);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-sm);
  background: var(--yb-illu-paper, var(--yb-surface));
  box-shadow: var(--yb-shadow-sm);
  font-size: 13px;
  line-height: 1.55;
}

.yb-texts-letter p {
  margin: 0;
  white-space: pre-line;
}

.yb-texts-letter__to {
  align-self: flex-end;
  min-width: 40%;
  color: var(--yb-text-muted);
}

.yb-texts-letter__title {
  padding-left: var(--yb-space-2);
  border-left: 3px solid var(--yb-primary);
  font-weight: var(--yb-weight-strong);
}

.yb-texts-letter__lines {
  display: grid;
  gap: 6px;
  padding: var(--yb-space-2) 0;
  border-top: 1px solid var(--yb-border);
  border-bottom: 1px solid var(--yb-border);
}

.yb-texts-letter__lines span {
  height: 6px;
  border-radius: 3px;
  background: var(--yb-bg-sunken);
}

.yb-texts-letter__lines span:nth-child(2) {
  width: 78%;
}

.yb-texts-letter__lines span:nth-child(3) {
  width: 56%;
}

.yb-texts-letter__total {
  display: flex;
  justify-content: flex-end;
  gap: var(--yb-space-4);
  font-weight: var(--yb-weight-strong);
}

/* The e-mail as the client receives it (subject, message, attachment). */
.yb-texts-mail {
  overflow: hidden;
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-md);
  background: var(--yb-surface);
  box-shadow: var(--yb-shadow-sm);
}

.yb-texts-mail__envelope {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: var(--yb-space-3) var(--yb-space-4);
  border-bottom: 1px solid var(--yb-border);
  background: var(--yb-bg-sunken);
  font-size: var(--yb-text-caption);
}

.yb-texts-mail__envelope div {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: var(--yb-space-2);
}

.yb-texts-mail__envelope dt {
  color: var(--yb-text-muted);
}

.yb-texts-mail__envelope dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.yb-texts-mail__subject dd {
  font-weight: var(--yb-weight-strong);
}

.yb-texts-mail__body {
  padding: var(--yb-space-4);
  font-size: 13.5px;
  line-height: 1.6;
}

.yb-texts-mail__body p {
  margin: 0 0 var(--yb-space-3);
  white-space: pre-line;
}

.yb-texts-mail__attachment {
  display: flex;
  align-items: center;
  gap: var(--yb-space-2);
  margin: 0 var(--yb-space-4) var(--yb-space-4);
  padding: var(--yb-space-2) var(--yb-space-3);
  border: 1px solid var(--yb-border);
  border-radius: var(--yb-radius-sm);
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-texts-mail__attachment .mud-icon-root {
  color: var(--yb-error);
}

.yb-texts-mail__mention {
  margin: 0;
  padding: var(--yb-space-2) var(--yb-space-4);
  border-top: 1px dashed var(--yb-border);
  color: var(--yb-text-muted); /* informative text: 4.5:1 (WCAG 1.4.3) */
  font-size: 11.5px;
  text-align: center;
}

.yb-texts__copy {
  display: grid;
  gap: var(--yb-space-2);
  margin: 0 0 var(--yb-space-4);
  padding: 0;
  border: 0;
}

.yb-texts__copy-legend {
  margin-bottom: var(--yb-space-2);
  padding: 0;
  font-weight: var(--yb-weight-medium);
}

.yb-texts__copy-choice {
  display: flex;
  align-items: center;
  gap: var(--yb-space-3);
  min-height: 36px;
  cursor: pointer;
}

.yb-texts__copy-choice input {
  accent-color: var(--yb-primary);
}

.yb-texts__copy-address {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 420px;
  margin-left: 28px;
}

.yb-texts__copy-address--invalid .yb-template-field__input {
  border-color: var(--yb-error);
}

/* Editor: the schedule comes first, above the paper; two columns once there is room. */
.yb-recurring-editor__doc {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-5);
}

.yb-recurring-editor__doc .yb-schedule {
  max-width: 920px;
}

.yb-schedule {
  container: schedule / inline-size;
}

.yb-schedule__grid,
.yb-schedule__col {
  display: flex;
  flex-direction: column;
  gap: var(--yb-space-4);
  min-width: 0;
}

@container schedule (min-width: 640px) {
  .yb-schedule__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--yb-space-4) var(--yb-space-6);
  }

  .yb-schedule__dates {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--yb-space-2);
  }

  .yb-schedule__date {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: var(--yb-space-2) var(--yb-space-3);
    border: 1px dashed var(--yb-border-strong);
  }

  .yb-schedule__date--next {
    border-style: solid;
    border-color: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .yb-cadence__ticket,
  .yb-schedule__frequency,
  .yb-schedule__choice,
  .yb-schedule__mode {
    transition: none;
  }
}

/* Audit UX, page 15: the subject as the next invoice prints it; the variables folded under their sentence. */
.yb-recurring-subject-preview {
  margin: -4px 0 var(--yb-space-2);
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

.yb-variables > summary {
  cursor: pointer;
  list-style: none;
}

.yb-variables > summary::-webkit-details-marker {
  display: none;
}

.yb-variables > summary::before {
  content: "›";
  display: inline-block;
  margin-right: 6px;
  transition: transform var(--yb-duration-fast) var(--yb-ease);
}

.yb-variables[open] > summary::before {
  transform: rotate(90deg);
}

.yb-variables:not([open]) > summary {
  margin: 0;
}

/* Audit UX, page 15: the preview waiting for a client and a line, in one line. */
.yb-editor__preview-wait {
  margin: 0;
  padding: var(--yb-space-3) var(--yb-space-4);
  border: 1px dashed var(--yb-border-strong);
  border-radius: var(--yb-radius-md);
  color: var(--yb-text-muted);
  font-size: var(--yb-text-caption);
}

/* Audit UX, page 15: « Jamais · À une date · Nombre de factures » across the column, each label whole. */
.yb-segmented.yb-schedule__end {
  display: flex;
  width: 100%;
}

.yb-schedule__end .yb-segmented__option {
  flex: 1 1 0;
  justify-content: center;
  height: auto;
  min-height: 30px;
  padding-block: 4px;
  text-align: center;
  white-space: normal;
}

/* Audit UX, page 14: the rhythm, the next date and the mode of a phone card on two lines rather than cut. */
.yb-recurring-card .yb-doc-card__meta {
  white-space: normal;
  overflow: visible;
}

/* ---------- D386–D388: a new recurring invoice in three steps ---------- */
.yb-recurring-steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--yb-space-2);
  margin: 0 0 var(--yb-space-4);
  padding: 0;
  list-style: none;
}

.yb-recurring-steps__button {
  display: inline-flex;
  align-items: center;
  gap: var(--yb-space-2);
  min-height: 36px;
  padding: 0 var(--yb-space-3) 0 var(--yb-space-2);
  border: 1px solid var(--yb-border);
  border-radius: 999px;
  background: var(--yb-surface);
  color: var(--yb-text-muted);
  font: inherit;
  cursor: pointer;
}

.yb-recurring-steps__number {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--yb-bg-sunken);
  font-size: var(--yb-text-caption);
  font-weight: var(--yb-weight-strong);
}

.yb-recurring-steps__item--current .yb-recurring-steps__button {
  border-color: var(--yb-primary);
  color: var(--yb-text);
  font-weight: var(--yb-weight-strong);
}

.yb-recurring-steps__item--current .yb-recurring-steps__number,
.yb-recurring-steps__item--done .yb-recurring-steps__number {
  background: var(--yb-primary);
  color: var(--yb-on-primary, #fff);
}

.yb-recurring-steps__button:focus-visible {
  outline: 2px solid var(--yb-focus);
  outline-offset: 2px;
}

/* « Options : langue, devise, référence et textes » on the paper of a new recurring invoice. */
.yb-recurring-options {
  display: inline-flex;
  align-items: center;
  gap: var(--yb-space-1);
  align-self: flex-start;
  margin: 0 0 var(--yb-space-2);
  font-size: var(--yb-text-caption);
}

/* D387: the subject and « + Mois » beside it. */
.yb-recurring-subject {
  display: flex;
  align-items: center;
  gap: var(--yb-space-2);
}

.yb-recurring-subject .yb-paper__subject {
  flex: 1 1 auto;
  min-width: 0;
}

.yb-recurring-subject__insert {
  flex: none;
  font-size: var(--yb-text-caption);
  white-space: nowrap;
}

/* D386: on a phone, while editing, the sheet comes first; the variables and the preview note live with « Aperçu ». */
@media (max-width: 767.98px) {
  .yb-recurring-editor .yb-editor[data-mode="edit"] .yb-editor__aside .yb-variables,
  .yb-recurring-editor .yb-editor[data-mode="edit"] .yb-editor__aside .yb-editor__preview-wait {
    display: none;
  }
}

/* D386: the lead of step 1, and « Recommandé » on « Oui, je vérifie ». */
.yb-recurring-step-lead {
  margin: 0 0 var(--yb-space-3);
  color: var(--yb-text-muted);
}

.yb-schedule__recommended {
  display: inline-block;
  margin-left: var(--yb-space-2);
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--yb-success-soft, #e5f4ec);
  color: var(--yb-success);
  font-size: 11.5px;
  font-weight: var(--yb-weight-strong);
  vertical-align: 1px;
}
