/* ==========================================================================
   MyRentBook — PUBLIC STYLES (BEM-нейминг)
   Типографика: Roboto (лейблы 400, значения 200)
   База: 14px (десктоп), 13px (мобайл)
   Палитра: тёмный #506568, светлый #F2E1D6, доп. светлый #FBF4EF,
            границы #e3d2c6 / #d7e2dc, просрочка #fff3f3
   ========================================================================== */


/* ===========================
   DESKTOP (по умолчанию)
   =========================== */

/* База типографики */
.myrentbook-lease,
.myrentbook-lease-block,
.myrentbook-table,
.myrentbook-banner,
.myrentbook-grand-total {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  color: #2b2b2b;
}

/* Баннеры */
.myrentbook-banner {
  margin-top: 8px;
  margin-right: 0px;
  margin-bottom: 8px;
  margin-left: 0px;

  padding-top: 10px;
  padding-right: 12px;
  padding-bottom: 10px;
  padding-left: 12px;

  border-radius: 6px;
  font-size: 13px;
}
.myrentbook-ok {
  background-color: #eef9f0;
  border-style: solid;
  border-width: 1px;
  border-color: #bfe3c7;
}
.myrentbook-warn {
  background-color: #fff7e6;
  border-style: solid;
  border-width: 1px;
  border-color: #f5d7a5;
}

/* Блок договора */
.myrentbook-lease,
.myrentbook-lease-block {
  margin-top: 18px;
  margin-right: 0px;
  margin-bottom: 30px;
  margin-left: 0px;
}
.myrentbook-lease__title,
.myrentbook-lease-title {
  margin-top: 0px;
  margin-right: 0px;
  margin-bottom: 6px;
  margin-left: 0px;
  font-weight: 400;
}
.myrentbook-lease__meta,
.myrentbook-lease-meta {
  color: #555555;
  margin-top: 0px;
  margin-right: 0px;
  margin-bottom: 4px;
  margin-left: 0px;
  font-weight: 200;
}

/* Таблица: базовое оформление */
.myrentbook-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  margin-right: 0px;
  margin-bottom: 0px;
  margin-left: 0px;
  table-layout: auto;
}
.myrentbook-table thead th {
  background-color: #F2E1D6;
  border-bottom-style: solid;
  border-bottom-width: 1px;
  border-bottom-color: #e3d2c6;
  font-weight: 400;
}
.myrentbook-table th,
.myrentbook-table td {
  padding-top: 7px;
  padding-right: 9.6px;
  padding-bottom: 7px;
  padding-left: 9.6px;

  border-bottom-style: solid;
  border-bottom-width: 1px;
  border-bottom-color: #e7e7e7;

  vertical-align: top;
}
.myrentbook-table td {
  font-weight: 200; /* значения легче */
}
.myrentbook-table tbody tr:nth-child(even) {
  background-color: #FBF4EF; /* лёгкая зебра */
}
.myrentbook-row--overdue,
tr.myrentbook-overdue {
  background-color: #fff3f3;
}
.myrentbook-row--total,
.myrentbook-total-row {
  background-color: #f7f7f7;
}
.myrentbook-right {
  text-align: right;
}

/* Жёсткая раскладка колонок для таблиц с действиями */
.myrentbook-table:has(td.myrentbook-actions) {
  table-layout: fixed;
}
.myrentbook-table:has(td.myrentbook-actions) thead th:nth-child(-n+7),
.myrentbook-table:has(td.myrentbook-actions) tbody td:nth-child(-n+7):not(.myrentbook-actions) {
  width: 10%;
}
.myrentbook-table:has(td.myrentbook-actions) thead th:last-child,
.myrentbook-table:has(td.myrentbook-actions) tbody td.myrentbook-actions,
.myrentbook-table:has(td.myrentbook-actions) tbody td.myrentbook-cell--actions {
  width: 30%;
}

/* Колонка действий (ячейка) */
.myrentbook-cell--actions,
.myrentbook-actions {
  vertical-align: top;

  padding-top: 10px;
  padding-right: 10px;
  padding-bottom: 10px;
  padding-left: 10px;
}

/* Каждая форма внутри колонки действий — «полка» */
.myrentbook-cell--actions .myrentbook-form,
.myrentbook-actions .myrentbook-form,
.myrentbook-cell--actions .myrentbook-inline-form,
.myrentbook-actions .myrentbook-inline-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;

  row-gap: 10px;
  column-gap: 0px;

  width: 100%;

  margin-top: 0px;
  margin-right: 0px;
  margin-bottom: 12px;
  margin-left: 0px;
}
.myrentbook-cell--actions .myrentbook-form:last-child,
.myrentbook-actions .myrentbook-form:last-child,
.myrentbook-cell--actions .myrentbook-inline-form:last-child,
.myrentbook-actions .myrentbook-inline-form:last-child {
  margin-bottom: 0px;
}

/* Форма «Оплатить частично»: инпут + кнопка в строку */
.myrentbook-cell--actions .myrentbook-form--partial,
.myrentbook-actions .myrentbook-form--partial {
  flex-direction: row;
  align-items: center;
  row-gap: 0px;
  column-gap: 10px;
  flex-wrap: nowrap;
}

/* Инпуты */
.myrentbook-input,
.myrentbook-amount,
.myrentbook-input--amount {
  background-color: #ffffff;

  padding-top: 6px;
  padding-right: 9px;
  padding-bottom: 6px;
  padding-left: 9px;

  border-style: solid;
  border-width: 1px;
  border-color: #d7e2dc;
  border-radius: 10px;

  color: #506568;
  line-height: 1.2;
  font-weight: 200;

  appearance: textfield;
  font-variant-numeric: tabular-nums;
}
.myrentbook-input--amount,
.myrentbook-amount {
  width: 9ch;
  max-width: 100%;
  /* когда кнопка падает вниз — хотим отступ 10px */
  margin-top: 0px;
  margin-right: 0px;
  margin-bottom: 0px;
  margin-left: 0px;
}
/* спиннеры number */
.myrentbook-input--amount::-webkit-outer-spin-button,
.myrentbook-input--amount::-webkit-inner-spin-button,
.myrentbook-amount::-webkit-outer-spin-button,
.myrentbook-amount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Кнопки */
.myrentbook-btn,
.myrentbook-actions button,
.myrentbook-actions .button,
.myrentbook-actions .components-button,
.myrentbook-inline-form button,
.myrentbook-inline-form .button,
.myrentbook-inline-form .components-button {
  min-height: 36px;

  padding-top: 7px;
  padding-right: 12px;
  padding-bottom: 7px;
  padding-left: 12px;

  border-style: solid;
  border-width: 1px;
  border-color: #506568;
  border-radius: 10px;

  background-color: #506568;
  color: #ffffff;
  font-weight: 400;
  line-height: 1.2;

  text-align: center;
  white-space: normal;
}

/* Кнопка «Оплатить частично» в колонке действий — растягивается */
.myrentbook-cell--actions .myrentbook-form--partial .myrentbook-btn,
.myrentbook-actions .myrentbook-form--partial .myrentbook-btn {
  width: auto;
  min-width: 145px;

  flex-grow: 1;
  flex-shrink: 1;
  flex-basis: auto;
}

/* Чекбокс: выравнивание слева, компактная подпись */
.myrentbook-check {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;

  column-gap: 6px;
  row-gap: 0px;

  line-height: 1.3;
}
.myrentbook-check input {
  margin-top: 0px;
  margin-right: 0px;
  margin-bottom: 0px;
  margin-left: 0px;
}
.myrentbook-check__label {
  display: inline-block;
}

/* Инлайн-формы в других местах (вне .myrentbook-actions) */
.myrentbook-inline-form {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;

  column-gap: 8px;
  row-gap: 10px;

  margin-top: 0px;
  margin-right: 0px;
  margin-bottom: 4px;
  margin-left: 0px;
}
/* универсально: если есть .myrentbook-amount — держим отступы при переносе */
.myrentbook-inline-form:has(.myrentbook-amount),
.myrentbook-inline-form:has(.myrentbook-input--amount) {
  column-gap: 10px;
  row-gap: 10px;
  flex-wrap: wrap;
}

/* Итого (общий) */
.myrentbook-grand-total {
  margin-top: 14px;
  margin-right: 0px;
  margin-bottom: 6px;
  margin-left: 0px;

  font-size: 15px;
  font-weight: 400;
}

/* Страховка от переполнений */
.myrentbook-table td,
.myrentbook-table a {
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}



/* ===========================
   MOBILE (≤768px) — карточки
   =========================== */
@media (max-width: 768px) {

  /* Мелкая типографика */
  .myrentbook-lease,
  .myrentbook-lease-block,
  .myrentbook-table,
  .myrentbook-banner,
  .myrentbook-grand-total {
    font-size: 13px;
    line-height: 1.4;
  }

  /* Таблица как список карточек */
  .myrentbook-table thead {
    display: none !important;
  }
  .myrentbook-table {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
  }
  .myrentbook-table tbody {
    display: block !important;
    width: 100%;
    box-sizing: border-box;
  }
  .myrentbook-row,
  .myrentbook-table tr {
    display: block !important;
    width: 100%;
    box-sizing: border-box;

    background-color: #F2E1D6;
    border-style: solid;
    border-width: 1px;
    border-color: #e3d2c6;
    border-radius: 10px;

    margin-top: 10px;
    margin-right: 0px;
    margin-bottom: 10px;
    margin-left: 0px;

    overflow: hidden;
  }
  .myrentbook-row--total,
  .myrentbook-table tr.myrentbook-total-row {
    background-color: #FBF4EF;
  }

  /* Ячейка: слева лейбл, с середины — значения (влево) */
  .myrentbook-cell,
  .myrentbook-table td {
    display: block !important;
    width: 100%;
    box-sizing: border-box;

    position: relative;

    padding-top: 10px;
    padding-right: 12px;
    padding-bottom: 10px;
    padding-left: 50%;

    border-top-style: none;
    border-right-style: none;
    border-bottom-style: none;
    border-left-style: none;

    min-width: 0px;
    text-align: left;
    font-weight: 200;
    color: #2b2b2b;

    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  /* Псевдо-лейбл из data-label: слева, по центру строки по вертикали */
  .myrentbook-cell::before,
  .myrentbook-table td::before {
    content: attr(data-label);

    position: absolute;
    top: 50%;
    left: 12px;
    right: 50%;
    transform: translateY(-50%);

    text-align: left;

    overflow: hidden;
    text-overflow: ellipsis;

    font-weight: 400;
    color: #506568;
  }

  /* Внутренняя зебра по значениям */
  .myrentbook-row > .myrentbook-cell:nth-of-type(odd),
  .myrentbook-table tr > td:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.03);
  }
  .myrentbook-row--total > .myrentbook-cell,
  .myrentbook-table tr.myrentbook-total-row > td {
    background-color: transparent;
  }

  /* Числа тоже влево в своей половине */
  .myrentbook-cell.myrentbook-right,
  .myrentbook-table td.myrentbook-right {
    text-align: left;
  }

  /* Сообщения с colspan — по центру, без лейбла и деления */
  .myrentbook-cell[colspan],
  .myrentbook-table td[colspan] {
    padding-top: 10px !important;
    padding-right: 12px !important;
    padding-bottom: 10px !important;
    padding-left: 12px !important;

    text-align: center !important;
  }
  .myrentbook-cell[colspan]::before,
  .myrentbook-table td[colspan]::before {
    content: none !important;
  }

  /* Итоговая строка — центр, без деления пополам */
  .myrentbook-row--total,
  .myrentbook-table tr.myrentbook-total-row {
    text-align: center;
  }
  .myrentbook-row--total .myrentbook-cell,
  .myrentbook-table tr.myrentbook-total-row td {
    display: inline-block !important;
    width: auto !important;
    box-sizing: border-box;

    padding-top: 10px !important;
    padding-right: 8px !important;
    padding-bottom: 10px !important;
    padding-left: 8px !important;

    text-align: inherit !important;
    vertical-align: middle;
  }
  .myrentbook-row--total .myrentbook-cell::before,
  .myrentbook-table tr.myrentbook-total-row td::before {
    content: none !important;
  }

  /* Колонка действий: правая половина */
  .myrentbook-cell--actions,
  .myrentbook-table td.myrentbook-actions {
    padding-top: 10px;
    padding-right: 12px;
    padding-bottom: 10px;
    padding-left: 50%;

    text-align: left;
  }

  /* Формы в колонке действий: в столбик; между формами 10px */
  .myrentbook-cell--actions .myrentbook-form,
  .myrentbook-table td.myrentbook-actions .myrentbook-form,
  .myrentbook-cell--actions .myrentbook-inline-form,
  .myrentbook-table td.myrentbook-actions .myrentbook-inline-form {
    display: flex;
    flex-direction: column;

    row-gap: 10px;
    column-gap: 0px;

    width: 100%;
    max-width: 100%;

    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
  }
  .myrentbook-cell--actions .myrentbook-form + .myrentbook-form,
  .myrentbook-table td.myrentbook-actions .myrentbook-form + .myrentbook-form,
  .myrentbook-cell--actions .myrentbook-inline-form + .myrentbook-inline-form,
  .myrentbook-table td.myrentbook-actions .myrentbook-inline-form + .myrentbook-inline-form {
    margin-top: 10px;
  }

  /* Частичная оплата: инпут + кнопка; перенос — с зазором 10px */
  .myrentbook-cell--actions .myrentbook-form--partial,
  .myrentbook-table td.myrentbook-actions .myrentbook-form--partial,
  .myrentbook-cell--actions .myrentbook-inline-form.myrentbook-form--partial,
  .myrentbook-table td.myrentbook-actions .myrentbook-inline-form.myrentbook-form--partial {
    flex-direction: row;
    flex-wrap: wrap;

    column-gap: 10px;  /* между инпутом и кнопкой в одной строке */
    row-gap: 10px;     /* между ними при переносе */
    align-items: center;
    justify-content: flex-start;

    width: 100%;
    max-width: 100%;
  }

  .myrentbook-cell--actions .myrentbook-form--partial .myrentbook-input--amount,
  .myrentbook-table td.myrentbook-actions .myrentbook-form--partial .myrentbook-input--amount,
  .myrentbook-cell--actions .myrentbook-form--partial .myrentbook-amount,
  .myrentbook-table td.myrentbook-actions .myrentbook-form--partial .myrentbook-amount {
    width: 9ch;
    max-width: 100%;

    padding-top: 6px;
    padding-right: 9px;
    padding-bottom: 6px;
    padding-left: 9px;

    border-style: solid;
    border-width: 1px;
    border-color: #d7e2dc;
    border-radius: 10px;

    background-color: #ffffff;
    color: #506568;

    line-height: 1.2;
    font-weight: 200;

    appearance: textfield;
    font-variant-numeric: tabular-nums;

    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: auto;
  }

  /* Кнопка «Оплатить частично»:
     — растягивается до конца строки, min 145px;
     — если не помещается, падает вниз и становится на всю ширину правой половины. */
  .myrentbook-cell--actions .myrentbook-form--partial .myrentbook-btn,
  .myrentbook-table td.myrentbook-actions .myrentbook-form--partial .myrentbook-btn {
    width: auto;
    max-width: none;
    min-height: 36px;

    padding-top: 7px;
    padding-right: 12px;
    padding-bottom: 7px;
    padding-left: 12px;

    border-style: solid;
    border-width: 1px;
    border-color: #506568;
    border-radius: 10px;

    background-color: #506568;
    color: #ffffff;
    font-weight: 400;
    line-height: 1.2;
    text-align: center;

    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 100%;

    min-width: 145px;
  }

  /* Прочие кнопки — на всю ширину правой половины, между ними 10px (через отступ формы) */
  .myrentbook-cell--actions .myrentbook-btn,
  .myrentbook-table td.myrentbook-actions .myrentbook-btn,
  .myrentbook-cell--actions button,
  .myrentbook-table td.myrentbook-actions button {
    width: 100%;
    max-width: 100%;
    min-height: 36px;

    padding-top: 7px;
    padding-right: 12px;
    padding-bottom: 7px;
    padding-left: 12px;

    border-style: solid;
    border-width: 1px;
    border-color: #506568;
    border-radius: 10px;

    background-color: #506568;
    color: #ffffff;
    font-weight: 400;
    line-height: 1.2;

    white-space: normal;
    text-align: center;
  }

  /* Чекбокс в действиях — по левому краю */
  .myrentbook-cell--actions .myrentbook-check,
  .myrentbook-table td.myrentbook-actions .myrentbook-check {
    display: flex;
    flex-direction: row;
    align-items: flex-start;

    column-gap: 6px;
    row-gap: 0px;

    font-size: 12.5px;
    line-height: 1.3;
    color: #2b2b2b;

    white-space: normal;
    overflow-wrap: break-word;

    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    margin-left: 0px;
  }
}




/* =========================
   MOBILE HOTFIX (≤768px)
   Убить фикс-раскладку и проценты, починить переносы
   ========================= */
@media (max-width: 768px) {

  /* 1) Полностью отключаем фикс-раскладку и проценты колонок */
  .myrentbook-table { table-layout: auto !important; }
  .myrentbook-table thead th,
  .myrentbook-table tbody td,
  .myrentbook-table tbody td.myrentbook-actions,
  .myrentbook-table:has(td.myrentbook-actions) thead th,
  .myrentbook-table:has(td.myrentbook-actions) tbody td {
    width: auto !important;
  }

  /* 2) Запрещаем «буквенные столбики» (глобальные desktop-правила их включали) */
  .myrentbook-table td,
  .myrentbook-table td * {
    word-break: normal !important;
    overflow-wrap: normal !important;
    white-space: normal !important;
  }

  /* 3) Две «половины» строки: слева лейбл, справа данные */
  .myrentbook-table td {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;

    /* правая половина под данные */
    padding-left: 46% !important;   /* лейбл 54%, данные 46% */
    text-align: left !important;
  }
  .myrentbook-table td::before {
    content: attr(data-label);
    position: absolute;
    top: 50%;
    left: 12px;
    right: 54% !important;          /* ширина зоны лейбла */
    transform: translateY(-50%);
    font-weight: 400;
    color: #506568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* В "Действиях" даём ЕЩЁ больше места под контент */
  .myrentbook-table td.myrentbook-actions,
  .myrentbook-cell--actions {
    padding-left: 40% !important;   /* лейбл 40%, контент 60% */
  }
  .myrentbook-table td.myrentbook-actions::before,
  .myrentbook-cell--actions::before {
    right: 60% !important;
  }

  /* 4) Кнопки — нормальная ширина, без вертикального письма */
  .myrentbook-btn,
  .myrentbook-table td.myrentbook-actions button,
  .myrentbook-table td.myrentbook-actions .button,
  .myrentbook-table td.myrentbook-actions .components-button {
    writing-mode: horizontal-tb !important;
    display: block !important;
    max-width: 100% !important;
  }

  /* 5) Формы в "Действиях" */
  /* по умолчанию — столбиком, зазор 10px между формами */
  .myrentbook-table td.myrentbook-actions .myrentbook-inline-form,
  .myrentbook-cell--actions .myrentbook-inline-form {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    margin: 0 !important;
  }

  /* частичная оплата: инпут + кнопка в строку, при переносе — зазоры 10px */
  .myrentbook-table td.myrentbook-actions .myrentbook-form--partial,
  .myrentbook-cell--actions .myrentbook-form--partial {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    column-gap: 10px !important;  /* между инпутом и кнопкой в строке */
    row-gap: 10px !important;     /* между ними, когда кнопка упала вниз */
    align-items: center !important;
  }
  .myrentbook-table td.myrentbook-actions .myrentbook-form--partial .myrentbook-input--amount,
  .myrentbook-cell--actions .myrentbook-form--partial .myrentbook-input--amount,
  .myrentbook-table td.myrentbook-actions .myrentbook-form--partial .myrentbook-amount,
  .myrentbook-cell--actions .myrentbook-form--partial .myrentbook-amount {
    width: 9ch !important;
    flex: 0 0 auto !important;
  }
  .myrentbook-table td.myrentbook-actions .myrentbook-form--partial .myrentbook-btn,
  .myrentbook-cell--actions .myrentbook-form--partial .myrentbook-btn {
    flex: 1 1 100% !important;     /* занимает остаток; при переносе — 100% правой половины */
    min-width: 145px !important;
  }

  /* остальные кнопки в "Действиях" — на всю правую половину */
  .myrentbook-table td.myrentbook-actions .myrentbook-form:not(.myrentbook-form--partial) .myrentbook-btn,
  .myrentbook-cell--actions .myrentbook-form:not(.myrentbook-form--partial) .myrentbook-btn {
    width: 100% !important;
  }

  /* чекбокс — слева, не ломаем по буквам */
  .myrentbook-table td.myrentbook-actions .myrentbook-check,
  .myrentbook-cell--actions .myrentbook-check,
  .myrentbook-check__label {
    align-items: flex-start !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    white-space: normal !important;
  }
}