html,
body {
  min-height: 100%;
}

body {
  background: #f4f7f9;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 440px);
}

.login-card,
.partners-registry-card,
.payments-card {
  border-radius: 8px;
}

.registry-page {
  height: 100vh;
  overflow: hidden;
}

.app-menu {
  --bs-offcanvas-width: 300px;
}

.app-menu-list .list-group-item {
  display: grid;
  gap: 3px;
  padding: 12px 16px;
}

.app-menu-list .list-group-item span {
  font-weight: 600;
}

.app-menu-list .list-group-item small {
  color: var(--bs-secondary-color);
}

.app-menu-list .list-group-item.active small {
  color: rgba(255, 255, 255, 0.78);
}

.partners-fullscreen {
  height: calc(100vh - 57px);
  min-height: 0;
  padding: 6px;
}

.partners-workspace {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(310px, 1fr);
  gap: 6px;
  height: 100%;
  min-height: 0;
}

.partners-main,
.payments-rail {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.partners-registry-card,
.payments-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.partners-registry-card > .card-header,
.partners-registry-card > .card-footer,
.payments-card > .card-header,
.payments-card > .card-footer {
  position: relative;
  z-index: 2;
  background: var(--bs-card-cap-bg);
}

.partners-registry-card > .card-header {
  position: sticky;
  top: 0;
}

.partners-registry-card > .card-footer {
  position: sticky;
  bottom: 0;
}

.partners-registry-card > .card-body,
.payments-card > .card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.metrics-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}

.metrics-inline > div {
  min-height: 50px;
  padding: 6px 10px;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  background: #fff;
}

.metrics-inline span {
  display: block;
  color: var(--bs-secondary-color);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.metrics-inline strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1;
}

.registry-entry-panel {
  padding: 8px;
  background: #fff;
}

.registry-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 180px)) auto;
  gap: 8px;
  align-items: end;
  padding: 8px;
  background: #fff;
}

.registry-filters label {
  display: grid;
  gap: 3px;
  margin: 0;
}

.registry-filters span {
  color: var(--bs-secondary-color);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.registry-filter-popover {
  position: fixed;
  z-index: 1080;
  width: min(280px, calc(100vw - 24px));
  padding: 10px;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  background: #fff;
}

.registry-filter-popover label {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.registry-filter-popover .filter-label {
  color: var(--bs-secondary-color);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.table-filter-title {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  line-height: inherit;
  text-align: center;
}

.table-filter-title:hover,
.table-filter-title.is-open {
  color: var(--bs-primary);
}

.filter-marker {
  position: absolute;
  top: 1px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bs-primary);
  opacity: 0;
}

.table-filter-title.is-filtered .filter-marker {
  opacity: 1;
}

.partners-registry-scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.partners-table {
  width: 100%;
  min-width: 1320px;
  table-layout: fixed;
}

.partners-directory-table {
  min-width: 1180px;
}

.users-directory-table {
  min-width: 720px;
}

.partners-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: center !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.15;
  background: var(--bs-light);
}

.partners-table th,
.partners-table td {
  border-right: 1px solid var(--bs-border-color);
  vertical-align: middle;
}

.partners-table th:last-child,
.partners-table td:last-child {
  border-right: 0;
}

.col-order {
  width: 86px;
}

.col-date,
.col-ready-plan,
.col-ready-fact {
  width: 92px;
}

.col-partner {
  width: 180px;
}

.col-money {
  width: 130px;
}

.col-percent {
  width: 110px;
}

.col-sales-price,
.col-purchase-price,
.col-measurer-pay,
.col-ads-cost,
.col-tax-cost,
.col-profit {
  width: 104px;
}

.col-profit-percent {
  width: 86px;
}

.col-status {
  width: 150px;
}

.col-directory-name {
  width: 240px;
}

.col-directory-external {
  width: 120px;
}

.col-directory-contact {
  width: 190px;
}

.col-directory-users {
  width: 220px;
}

.col-actions {
  width: 112px;
}

.col-user-id {
  width: 90px;
}

.col-user-name {
  width: 260px;
}

.col-user-login {
  width: 320px;
}

.col-user-type {
  width: 160px;
}

.col-user-partner {
  width: 240px;
}

.registry-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
}

.registry-pagination,
.registry-page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.registry-page-size {
  color: var(--bs-secondary-color);
  font-size: 12px;
}

.registry-page-size .form-select {
  width: 72px;
}

.registry-page-size.justify-self-end {
  justify-self: end;
}

.registry-pagination .btn {
  width: 30px;
  height: 28px;
  padding: 0;
}

.payments-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.payments-footer .registry-pagination {
  justify-content: center;
}

.payments-footer .registry-page-size {
  justify-content: flex-end;
}

.payments-card > .card-body {
  flex: 0 0 auto;
}

.payments-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.payments-table-head,
.payment-row {
  display: grid;
  grid-template-columns: 72px 80px minmax(0, 1fr) 34px;
  align-items: stretch;
}

.payments-table-head {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--bs-border-color);
  background: var(--bs-light);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.payment-row {
  border-bottom: 1px solid var(--bs-border-color);
  background: #fff;
}

.payments-table-head > span,
.payment-row > span,
.payment-row strong,
.payment-row > button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 6px;
  border-right: 1px solid var(--bs-border-color);
}

.payment-row > button.delete {
  width: 100%;
  height: 100%;
  min-height: 32px;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
}

.payments-table-head > span:last-child,
.payment-row > :last-child {
  border-right: 0;
}

.payment-row > span,
.payment-row strong {
  min-width: 0;
}

.payment-partner > span,
.payment-partner small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payment-date {
  justify-content: center;
  color: var(--bs-secondary-color);
  font-size: 12px;
  text-align: center;
}

.payment-amount {
  justify-content: flex-end;
  text-align: right;
}

.payment-partner {
  display: block !important;
  line-height: 1.2;
}

.payment-partner small {
  margin-top: 2px;
  color: var(--bs-secondary-color);
  font-size: 12px;
}

body[data-partner-view="1"] .payments-table-head,
body[data-partner-view="1"] .payment-row {
  grid-template-columns: 72px 80px minmax(0, 1fr);
}

.num {
  text-align: right;
}

.table-money-input {
  width: 100%;
  height: 24px;
  padding: 1px 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  text-align: right;
  font: inherit;
  -moz-appearance: textfield;
  appearance: textfield;
}

.table-money-input::-webkit-outer-spin-button,
.table-money-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.table-money-input:focus {
  border-color: #66afe9;
  background: #fff;
  outline: 0;
  box-shadow: 0 0 0 0.12rem rgba(0, 123, 255, 0.18);
}

.table-money-input:disabled,
.table-money-input[data-saving="1"] {
  opacity: 0.65;
}

.table-money-input-readonly {
  color: var(--bs-body-color);
  cursor: default;
}

.table-money-input-readonly:focus {
  background: #f8fbfd;
}

.cell-center {
  text-align: center;
}

.cell-lines {
  white-space: pre-line;
}

.status-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 3px;
}

.status-action-btn {
  display: inline-grid;
  width: 24px;
  height: 24px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--bs-border-color);
  border-radius: 4px;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.status-action-primary {
  border-color: #b9d7f4;
  background: #f0f7ff;
  color: #2a6ea8;
}

.status-action-success {
  border-color: #a9d9bd;
  background: #effaf3;
  color: #2c7a4b;
}

.status-action-warning {
  border-color: #d9c7a2;
  background: #fff8e9;
  color: #9a6a00;
}

.status-action-info {
  border-color: #b9d7f4;
  background: #f0f7ff;
  color: #2a6ea8;
}

.status-action-danger {
  border-color: #f0c7c4;
  background: #fff4f3;
  color: #d9534f;
}

.batch-detail-layout {
  display: grid;
  gap: 18px;
}

.batch-detail-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 14px;
  align-items: start;
}

.batch-detail-content,
.detail-comments-panel {
  min-width: 0;
}

.detail-comments-panel {
  position: sticky;
  top: 0;
  max-height: min(62vh, 620px);
}

.detail-comments {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  max-height: min(62vh, 620px);
  min-height: 300px;
}

.detail-tabs {
  margin-bottom: 14px;
}

.detail-tab-content {
  min-height: 260px;
}

.detail-section-title {
  margin: 0 0 10px;
  color: var(--bs-secondary-color);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.detail-item {
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  background: #fff;
}

.detail-item span,
.comment-meta span {
  display: block;
  color: var(--bs-secondary-color);
  font-size: 12px;
}

.detail-item strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.comments-list {
  display: grid;
  gap: 8px;
}

.comments-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.comment-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 6px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--bs-border-color);
}

.comment-form input {
  height: 30px;
  border-radius: 999px;
}

.comment-send-btn {
  display: inline-grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  font-size: 14px;
  line-height: 1;
}

.comment-send-btn:disabled {
  opacity: 0.65;
}

.comment-error {
  grid-column: 1 / -1;
  min-height: 16px;
}

.comment-item {
  padding: 9px 10px;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  background: #fff;
}

.comment-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-meta strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-meta span {
  text-align: right;
  white-space: nowrap;
}

.detail-files-empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed var(--bs-border-color);
  border-radius: 6px;
  background: #fff;
  color: var(--bs-secondary-color);
}

.files-panel {
  display: grid;
  gap: 10px;
}

.file-upload-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.file-upload-form [data-file-error] {
  grid-column: 1 / -1;
}

.files-list {
  display: grid;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  overflow: hidden;
}

.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--bs-border-color);
  background: #fff;
}

.file-item-readonly {
  grid-template-columns: minmax(0, 1fr);
}

.file-item:last-child {
  border-bottom: 0;
}

.file-item a,
.file-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item small {
  color: var(--bs-secondary-color);
}

@media (max-width: 991.98px) {
  .batch-detail-shell {
    grid-template-columns: 1fr;
  }

  .detail-comments-panel {
    position: static;
    max-height: 300px;
  }

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

.status-action-secondary {
  border-color: #cfd4da;
  background: #f8f9fa;
  color: #5f6870;
}

.status-action-btn:hover {
  filter: brightness(0.97);
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.delete {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #f0c7c4;
  border-radius: 4px;
  background: #fff4f3;
  color: #d9534f;
  font-weight: 700;
}

.icon-edit,
.icon-activate,
.icon-deactivate,
.icon-reset,
.icon-delete {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 4px;
  line-height: 1;
}

.icon-edit {
  border: 1px solid #b9d7f4;
  background: #f0f7ff;
  color: #2a6ea8;
  font-size: 15px;
  font-weight: 700;
}

.icon-edit:hover {
  background: #e1efff;
}

.icon-deactivate {
  border: 1px solid #d9c7a2;
  background: #fff8e9;
  color: #9a6a00;
  font-size: 18px;
  font-weight: 700;
}

.icon-deactivate:hover {
  background: #ffefc7;
}

.icon-activate {
  border: 1px solid #a9d9bd;
  background: #effaf3;
  color: #2c7a4b;
  font-size: 15px;
  font-weight: 700;
}

.icon-activate:hover {
  background: #dcf5e6;
}

.icon-reset {
  border: 1px solid #c8c5f4;
  background: #f4f3ff;
  color: #5b55b7;
  font-size: 17px;
  font-weight: 700;
}

.icon-reset:hover {
  background: #e9e7ff;
}

.icon-delete {
  border: 1px solid #f0c7c4;
  background: #fff4f3;
  color: #d9534f;
  font-size: 18px;
  font-weight: 700;
}

.icon-delete:hover {
  background: #fde7e5;
}

.settings-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 16px;
}

.settings-form {
  max-width: 920px;
}

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

.settings-field {
  display: grid;
  gap: 6px;
  margin: 0;
}

.settings-field span {
  color: var(--bs-secondary-color);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

@media (max-width: 1199.98px) {
  .registry-page {
    height: auto;
    overflow: auto;
  }

  .partners-fullscreen {
    height: auto;
  }

  .partners-workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .partners-registry-card,
  .payments-card {
    height: auto;
  }

  .partners-registry-scroll,
  .payments-scroll {
    max-height: none;
  }
}

@media (max-width: 767.98px) {
  .registry-filters {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

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

  .registry-footer {
    grid-template-columns: 1fr;
  }

  .registry-footer > * {
    text-align: left !important;
  }
}
