.admin-body {
  min-height: 100vh;
}

/* Адмінка на всю ширину екрана — таблиці без зайвої горизонтальної прокрутки */
.admin-body .container {
  width: calc(100% - 32px);
  max-width: none;
  margin: 0 auto;
}

@media (min-width: 1200px) {
  .admin-body .container {
    width: calc(100% - 48px);
  }
}

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

.admin-login-card {
  width: min(420px, 100%);
}

.admin-login-card h1 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.admin-login-card .field {
  margin-bottom: 14px;
}

.admin-login-back {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.92rem;
}

.admin-top {
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--k2-border);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
}

.admin-top-bar,
.admin-top-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-top-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.admin-logo {
  display: block;
  flex: 0 0 auto;
  line-height: 0;
  border-radius: 10px;
  text-decoration: none;
}

.admin-logo img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
  background: transparent;
}

.admin-logo:hover {
  opacity: 0.88;
}

.admin-top-titles {
  min-width: 0;
}

.admin-top h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
}

.admin-top p {
  margin: 0;
  color: var(--k2-muted);
}

.admin-top-nav,
.admin-top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-top-nav {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--k2-border);
}

.admin-lang,
.admin-login-lang {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-login-lang {
  margin-bottom: 10px;
}

.admin-main {
  padding: 24px 0 48px;
}

.admin-filters {
  margin-bottom: 16px;
}

.admin-filters-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr auto;
  gap: 14px;
  align-items: end;
}

.admin-filter-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 2px;
}

.admin-summary {
  margin-bottom: 12px;
  color: var(--k2-muted);
  font-size: 0.95rem;
}

.admin-table-card {
  overflow: hidden;
}

.admin-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

.admin-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--k2-border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-table th {
  background: #f9fafb;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--k2-muted);
  white-space: normal;
}

/* Список розрахунків: дата / id / клієнт / email / режим / партнер / сума / статус / дія / КП+видалити */
.admin-table-quotes th:nth-child(1),
.admin-table-quotes td:nth-child(1) { width: 8rem; }     /* дата */
.admin-table-quotes th:nth-child(2),
.admin-table-quotes td:nth-child(2) { width: 5.5rem; }   /* id */
.admin-table-quotes th:nth-child(3),
.admin-table-quotes td:nth-child(3) { width: 11%; }      /* клієнт */
.admin-table-quotes th:nth-child(4),
.admin-table-quotes td:nth-child(4) { width: 11%; }      /* email */
.admin-table-quotes th:nth-child(5),
.admin-table-quotes td:nth-child(5) { width: 5.5rem; }   /* режим */
.admin-table-quotes th:nth-child(6),
.admin-table-quotes td:nth-child(6) { width: 9%; }       /* партнер */
.admin-table-quotes th:nth-child(7),
.admin-table-quotes td:nth-child(7) { width: 9%; }       /* сума */
.admin-table-quotes th:nth-child(8),
.admin-table-quotes td:nth-child(8) { width: 7.5rem; }   /* статус */
.admin-table-quotes th:nth-child(9),
.admin-table-quotes td:nth-child(9) { width: 10.5rem; }  /* дія */
.admin-table-quotes th:nth-child(10),
.admin-table-quotes td:nth-child(10) { width: 9rem; }    /* КП + видалити */

.admin-table-quotes td:nth-child(1),
.admin-table-quotes td:nth-child(2),
.admin-table-quotes td:nth-child(5),
.admin-table-quotes td:nth-child(8),
.admin-table-quotes td:nth-child(9),
.admin-table-quotes td:nth-child(10) {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  overflow: visible;
}

.admin-table-quotes .admin-status-form {
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
  min-width: 0;
}

.admin-table-quotes .admin-status-select,
.admin-table-quotes .admin-amount-input {
  max-width: none;
  width: 100%;
}

.admin-table-quotes td.admin-actions {
  white-space: normal;
}

.admin-table-quotes .admin-actions-row {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.admin-cell-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  line-height: 1.35;
  max-height: calc(1.35em * 2);
}

.admin-table tbody tr:hover {
  background: rgba(60, 184, 120, 0.04);
}

.admin-empty {
  text-align: center !important;
  color: var(--k2-muted);
  padding: 32px 14px !important;
}

.admin-actions {
  text-align: right;
  white-space: nowrap;
}

.btn-small {
  padding: 7px 10px;
  font-size: 0.82rem;
  border-radius: 9px;
}

.admin-mode {
  display: inline-block;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
}

.admin-mode-saas {
  background: rgba(60, 184, 120, 0.14);
  color: var(--k2-green-dark);
}

.admin-mode-license {
  background: rgba(247, 148, 29, 0.16);
  color: var(--k2-orange-dark);
}

.admin-mode-free {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.admin-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.admin-pricing-note {
  margin: 0 0 16px;
  color: var(--k2-muted);
  font-size: 0.95rem;
}

.admin-flash {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.95rem;
}

.admin-flash-ok {
  background: rgba(60, 184, 120, 0.12);
  color: var(--k2-green-dark);
}

.admin-flash-err {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.admin-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.admin-tabs .btn {
  text-decoration: none;
}

.admin-section-title {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.admin-muted {
  margin: 0 0 8px;
  color: var(--k2-muted);
  font-size: 0.92rem;
}

.admin-settings-form .card {
  margin-bottom: 16px;
}

.admin-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.admin-settings-grid .admin-settings-span-2 {
  grid-column: 1 / -1;
}

.admin-settings-grid textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--k2-border);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
  min-height: 72px;
}

.admin-btn-danger {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}

.admin-btn-danger:hover {
  background: #fee2e2;
  color: #7f1d1d;
}

.admin-delete-order-form {
  display: inline-block;
  margin: 0;
}

/* Стилізоване підтвердження замість window.confirm */
.admin-confirm {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
}

.admin-confirm.hidden {
  display: none !important;
}

.admin-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}

.admin-confirm-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--k2-card);
  border: 1px solid var(--k2-border);
  border-radius: 16px;
  box-shadow: var(--k2-shadow);
  padding: 22px 22px 18px;
}

.admin-confirm-title {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.admin-confirm-text {
  margin: 0 0 18px;
  color: var(--k2-text);
  font-size: 0.98rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.admin-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-confirm-actions .btn-danger-solid {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  border: 0;
}

.admin-confirm-actions .btn-danger-solid:hover {
  filter: brightness(1.05);
}

.btn-tiny {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 7px;
  line-height: 1.2;
}

.admin-table-wrap-scroll {
  overflow-x: auto;
}

.admin-table-affiliates {
  min-width: 1080px;
  width: 100%;
}

.admin-table-affiliates th,
.admin-table-affiliates td {
  padding: 8px 10px;
  vertical-align: top;
  overflow: hidden;
}

.admin-table-affiliates th:nth-child(1),
.admin-table-affiliates td:nth-child(1) { width: 11.5rem; }
.admin-table-affiliates th:nth-child(2),
.admin-table-affiliates td:nth-child(2) { width: auto; min-width: 12rem; }
.admin-table-affiliates th:nth-child(3),
.admin-table-affiliates td:nth-child(3) { width: 3.6rem; white-space: nowrap; }
.admin-table-affiliates th:nth-child(4),
.admin-table-affiliates td:nth-child(4),
.admin-table-affiliates th:nth-child(5),
.admin-table-affiliates td:nth-child(5),
.admin-table-affiliates th:nth-child(6),
.admin-table-affiliates td:nth-child(6),
.admin-table-affiliates th:nth-child(7),
.admin-table-affiliates td:nth-child(7) { width: 5rem; white-space: nowrap; text-align: right; }
.admin-table-affiliates th:nth-child(8),
.admin-table-affiliates td:nth-child(8) { width: 16rem; }

.admin-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-partner-link {
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px dashed rgba(30, 64, 52, 0.35);
}

.admin-partner-link:hover {
  color: var(--k2-green-dark);
  border-bottom-color: var(--k2-green-dark);
}

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

.admin-balance-tile {
  background: #fff;
  border: 1px solid var(--k2-border);
  border-radius: 12px;
  padding: 12px 14px;
}

.admin-balance-tile strong {
  display: block;
  margin: 4px 0;
  font-size: 1.15rem;
}

.admin-balance-tile-accent {
  background: rgba(60, 184, 120, 0.08);
  border-color: rgba(60, 184, 120, 0.35);
}

.admin-partner-card-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 12px 18px;
}

.admin-partner-card-span {
  grid-column: 1 / -1;
}

.admin-inline-action {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  margin: 0;
}

.admin-comm-status-cell {
  min-width: 12rem;
}

.admin-comm-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
}

.admin-comm-badge-pending {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.admin-comm-badge-confirmed {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
}

.admin-comm-badge-rejected {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.admin-comm-badge-paid {
  background: rgba(60, 184, 120, 0.16);
  color: var(--k2-green-dark);
}

.admin-comm-status-hint {
  font-size: 0.72rem;
  margin-top: 3px;
  line-height: 1.3;
}

.admin-comm-change-label {
  display: block;
  width: 100%;
  font-size: 0.72rem;
  margin: 6px 0 2px;
}

.admin-status-under-badge {
  margin-top: 6px;
}

.admin-status-edit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.admin-status-form {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin: 0;
}

.admin-status-form.hidden {
  display: none !important;
}

.admin-status-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.admin-table-orders-journal {
  min-width: 0;
  width: 100%;
}

.admin-table-orders-journal th,
.admin-table-orders-journal td {
  padding: 7px 8px;
  vertical-align: top;
}

.admin-status-select {
  max-width: 9.5rem;
  padding: 4px 6px;
  border: 1px solid var(--k2-border);
  border-radius: 7px;
  font: inherit;
  font-size: 0.78rem;
  background: #fff;
}

.admin-amount-input {
  width: 5.5rem;
  padding: 4px 6px;
  border: 1px solid var(--k2-border);
  border-radius: 7px;
  font: inherit;
  font-size: 0.78rem;
}

.admin-table-partner-comms {
  min-width: 0;
  width: 100%;
}

.admin-table-partner-comms th,
.admin-table-partner-comms td {
  padding: 7px 8px;
  vertical-align: middle;
}

@media (max-width: 900px) {
  .admin-balance-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-partner-card-grid {
    grid-template-columns: 1fr;
  }
}

.admin-aff-code {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  white-space: normal;
  overflow: hidden;
}

.admin-aff-code code {
  font-size: 0.82rem;
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-aff-code .admin-actions-row {
  flex-wrap: wrap;
  justify-content: flex-start;
  max-width: 100%;
}

.admin-aff-meta {
  margin-top: 2px;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.admin-status {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.admin-status-on {
  background: rgba(60, 184, 120, 0.14);
  color: var(--k2-green-dark);
}

.admin-status-off {
  background: rgba(148, 163, 184, 0.2);
  color: #475569;
}

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

.admin-table-affiliates .admin-actions .admin-actions-row {
  justify-content: flex-start;
}

.admin-actions-row form {
  display: inline;
  margin: 0;
}

.admin-aff-url {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.admin-aff-url-code {
  max-width: min(100%, 28rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.admin-copy-url {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .admin-settings-grid {
    grid-template-columns: 1fr;
  }
}

.admin-rate-form {
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
  max-width: 640px;
}

.admin-rate-form .field {
  flex: 1;
  min-width: 140px;
  margin: 0;
}

.admin-edit-table input[type="text"],
.admin-edit-table input[type="number"] {
  width: 100%;
  min-width: 72px;
  padding: 7px 8px;
  border: 1px solid var(--k2-border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

.admin-edit-table .admin-input-sm {
  min-width: 48px;
  max-width: 72px;
}

.admin-edit-table td.admin-check {
  text-align: center;
}

.admin-form-actions {
  border-top: 1px solid var(--k2-border);
}

.admin-add-grid {
  display: grid;
  grid-template-columns: 0.45fr 1.4fr 0.7fr 0.7fr auto auto auto;
  gap: 12px;
  align-items: end;
}

.admin-add-grid-license {
  grid-template-columns: 0.45fr 1.2fr repeat(4, 0.7fr) auto auto auto;
}

.admin-check-field {
  padding-bottom: 10px;
}

.admin-i18n-fields {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--k2-border);
}

.admin-i18n-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.admin-check-field label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.9rem;
}

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

  .admin-filter-actions {
    flex-wrap: wrap;
  }

  .admin-filter-actions .btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .admin-add-grid,
  .admin-add-grid-license {
    grid-template-columns: 1fr;
  }

  .admin-body .container {
    width: calc(100% - 20px);
  }
}

/* Партнери на мобільному: картки без горизонтального скролу */
@media (max-width: 800px) {
  .admin-table-card {
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .admin-table-wrap-scroll {
    overflow: visible;
  }

  .admin-table-affiliates {
    min-width: 0;
    width: 100%;
  }

  .admin-table-affiliates thead {
    display: none;
  }

  .admin-table-affiliates tbody {
    display: block;
  }

  .admin-table-affiliates tr {
    display: block;
    margin: 0 0 12px;
    padding: 12px 14px;
    background: var(--k2-card);
    border: 1px solid var(--k2-border);
    border-radius: 14px;
    box-shadow: var(--k2-shadow);
  }

  .admin-table-affiliates td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100% !important;
    min-width: 0 !important;
    padding: 8px 0;
    border-bottom: 1px dashed var(--k2-border);
    text-align: left !important;
    overflow: visible;
    word-break: normal;
    overflow-wrap: anywhere;
  }

  .admin-table-affiliates td:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .admin-table-affiliates td::before {
    content: attr(data-label);
    flex: 0 0 5.2rem;
    max-width: 5.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--k2-muted);
    line-height: 1.4;
    padding-top: 2px;
  }

  .admin-table-affiliates td > * {
    flex: 1 1 auto;
    min-width: 0;
  }

  .admin-table-affiliates .admin-empty {
    display: block;
    border: 0;
    padding: 24px 8px !important;
  }

  .admin-table-affiliates .admin-empty::before {
    display: none;
  }

  .admin-table-affiliates .admin-actions .admin-actions-row,
  .admin-table-affiliates .admin-aff-code .admin-actions-row {
    justify-content: flex-start;
  }

  .admin-table-affiliates .admin-actions .admin-actions-row {
    width: 100%;
  }

  .admin-table-affiliates .admin-actions .btn-tiny {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
  }

  .admin-aff-meta {
    white-space: normal;
  }

  .admin-top-nav {
    margin-top: 10px;
  }

  .admin-top-nav .btn {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
    font-size: 0.85rem;
    padding: 8px 10px;
  }
}
