/* Operational partner controls: explicit actions, bounded analytics, mobile-safe layout. */
.ops-links-head {
  align-items: center;
  gap: 16px;
}

.ops-links-actions,
.ops-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.ops-links-actions .primary-btn,
.ops-links-actions .secondary-btn {
  width: auto;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 13px;
}

.ops-refresh svg,
.ops-create svg {
  width: 17px;
  height: 17px;
}

.ops-icon-action {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  color: var(--text, #f4f7fb);
}

.ops-icon-action svg {
  display: block;
  width: 19px;
  height: 19px;
  pointer-events: none;
}

.ops-icon-action.traffic-delete-btn {
  color: var(--danger, #ff6f91);
}

.ops-empty-link {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.ops-empty-link .primary-btn {
  width: auto;
  min-height: 42px;
  flex: 0 0 auto;
  padding-inline: 14px;
}

.traffic-analytics-section .analytics-state {
  min-height: 170px;
}

.traffic-analytics-section .analytics-scroll,
.ops-analytics-scroll {
  width: 100%;
  height: auto;
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  scrollbar-gutter: auto;
  border-radius: 14px;
}

.ops-analytics-table {
  min-width: 1040px;
  width: 100%;
  table-layout: auto;
}

.ops-analytics-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2, #111827);
  white-space: nowrap;
}

.ops-analytics-table th,
.ops-analytics-table td {
  padding: 13px 14px;
  white-space: nowrap;
  text-align: right;
}

.ops-analytics-table th:first-child,
.ops-analytics-table td:first-child,
.ops-analytics-table .ops-date-col {
  position: static !important;
  left: auto !important;
  min-width: 64px;
  width: 64px;
  max-width: 72px;
  text-align: left;
}

.ops-analytics-table .ops-money-col {
  font-weight: 700;
  color: #e6c46a;
}

.ops-analytics-table .ops-income-col {
  font-weight: 800;
  color: #ffd75a;
}

.ops-period button {
  min-height: 42px;
}

@media (max-width: 700px) {
  .ops-links-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ops-links-actions {
    width: 100%;
  }

  .ops-links-actions .ops-create {
    flex: 1 1 auto;
  }

  .ops-links-actions .ops-refresh {
    flex: 0 0 auto;
  }

  .ops-empty-link {
    align-items: stretch;
    flex-direction: column;
  }

  .ops-empty-link .primary-btn {
    width: 100%;
  }

  .traffic-analytics-section .analytics-scroll,
  .ops-analytics-scroll {
    height: 300px;
    max-height: 300px;
    margin-inline: -2px;
  }

  .traffic-analytics-section .analytics-state {
    min-height: 150px;
  }

  .ops-analytics-table {
    min-width: 930px;
    font-size: 13px;
  }

  .ops-analytics-table th,
  .ops-analytics-table td {
    padding: 11px 10px;
  }

  .ops-analytics-table th:first-child,
  .ops-analytics-table td:first-child,
  .ops-analytics-table .ops-date-col {
    min-width: 54px;
    width: 54px;
    max-width: 58px;
  }

  .analytics-heading select {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 390px) {
  .ops-links-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .ops-links-actions .secondary-btn span {
    display: none;
  }

  .ops-links-actions .secondary-btn {
    width: 44px;
    padding: 0;
  }

  .ops-analytics-table {
    min-width: 880px;
    font-size: 12px;
  }

  .ops-analytics-table th,
  .ops-analytics-table td {
    padding: 10px 8px;
  }
}


.ops-team-list {
  display: grid;
  gap: 12px;
}

.ops-team-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.ops-team-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}

.ops-team-card-head > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ops-team-card-head b {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-team-card-head > strong {
  flex: 0 0 auto;
  color: var(--success, #55d6a9);
  font-size: 15px;
  font-weight: 760;
  white-space: nowrap;
}

.ops-team-role {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 9px;
  font-weight: 730;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ops-team-role.lead {
  color: var(--cyan);
  border-color: color-mix(in srgb, var(--cyan) 28%, var(--line));
}

.ops-team-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ops-team-card-stats .compact-stat {
  min-width: 0;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ops-team-card-stats .compact-stat:nth-child(3n) {
  border-right: 0;
}

.ops-team-card-stats .compact-stat:nth-last-child(-n + 3) {
  border-bottom: 0;
}

@media (max-width: 700px) {
  .ops-team-card-head {
    align-items: flex-start;
  }

  .ops-team-card-head > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .ops-team-card-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ops-team-card-stats .compact-stat:nth-child(3n) {
    border-right: 1px solid var(--line);
  }

  .ops-team-card-stats .compact-stat:nth-child(2n) {
    border-right: 0;
  }

  .ops-team-card-stats .compact-stat:nth-last-child(-n + 3) {
    border-bottom: 1px solid var(--line);
  }

  .ops-team-card-stats .compact-stat:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}


.ops-team-card[role="button"] {
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease, transform .16s ease;
}

.ops-team-card[role="button"]:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--surface) 94%, var(--accent) 6%);
}

.ops-team-card[role="button"]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 72%, white 8%);
  outline-offset: 3px;
}

.ops-team-card-result {
  flex: 0 0 auto;
  display: grid;
  justify-items: end;
  gap: 3px;
}

.ops-team-card-result strong {
  color: var(--success, #55d6a9);
  font-size: 15px;
  font-weight: 760;
  white-space: nowrap;
}

.ops-team-card-result small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 620;
  white-space: nowrap;
}

.ops-team-detail {
  display: grid;
  gap: 16px;
}

.ops-team-detail-identity {
  display: grid;
  gap: 8px;
}

.ops-team-detail-identity p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.ops-team-detail-period {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.ops-team-detail-period button {
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 650;
}

.ops-team-detail-period button.active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent);
}

.ops-team-detail-kpis {
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.ops-team-detail-kpis .compact-stat {
  min-width: 0;
  padding: 12px 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ops-team-detail-kpis .compact-stat:nth-child(3n) {
  border-right: 0;
}

.ops-team-detail-kpis .compact-stat:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.ops-team-detail-block {
  display: grid;
  gap: 10px;
}

.ops-team-detail-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.ops-team-detail-title b {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.ops-team-detail-title span {
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.ops-team-detail-levels {
  overflow: hidden;
  display: grid;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.ops-team-detail-levels > div {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.ops-team-detail-levels > div:last-child {
  border-bottom: 0;
}

.ops-team-detail-levels span {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 760;
}

.ops-team-detail-levels small {
  color: var(--muted);
  font-size: 10px;
}

.ops-team-detail-levels strong {
  color: var(--success, #55d6a9);
  font-size: 12px;
  font-weight: 720;
}

.ops-team-detail-daily {
  overflow: hidden;
  display: grid;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.ops-team-detail-day {
  display: grid;
  grid-template-columns: 60px minmax(70px, .8fr) minmax(70px, .8fr) minmax(85px, 1fr) minmax(85px, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.ops-team-detail-day:last-child {
  border-bottom: 0;
}

.ops-team-detail-day strong {
  color: var(--success, #55d6a9);
  font-size: 11px;
  text-align: right;
}

.ops-team-detail-state {
  min-height: 220px;
}

@media (max-width: 700px) {
  .ops-team-card[role="button"]:active {
    transform: scale(.995);
  }

  .ops-team-card-result small {
    font-size: 9px;
  }

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

  .ops-team-detail-kpis .compact-stat:nth-child(3n) {
    border-right: 1px solid var(--line);
  }

  .ops-team-detail-kpis .compact-stat:nth-child(2n) {
    border-right: 0;
  }

  .ops-team-detail-kpis .compact-stat:nth-last-child(-n + 3) {
    border-bottom: 1px solid var(--line);
  }

  .ops-team-detail-kpis .compact-stat:last-child {
    border-bottom: 0;
  }

  .ops-team-detail-day {
    grid-template-columns: 52px 1fr 1fr;
    gap: 7px;
    padding: 9px 10px;
  }

  .ops-team-detail-day span:nth-child(4),
  .ops-team-detail-day strong {
    text-align: left;
  }

  .ops-team-detail-day span:nth-child(4)::before {
    content: "Оборот ";
    color: var(--faint);
  }

  .ops-team-detail-day strong::before {
    content: "Доход ";
    color: var(--faint);
    font-weight: 500;
  }
}

@media (max-width: 390px) {
  .ops-team-detail-period button {
    min-height: 36px;
    padding-inline: 3px;
    font-size: 10px;
  }

  .ops-team-detail-kpis .compact-stat {
    padding: 11px 10px;
  }
}


/* Simplified Team Lead member analytics */
.ops-team-detail-simple {
  gap: 14px;
}

.ops-team-detail-kpis-five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.ops-team-detail-kpis-five .compact-stat {
  border-bottom: 0;
}

.ops-team-detail-kpis-five .compact-stat:nth-child(3n) {
  border-right: 1px solid var(--line);
}

.ops-team-detail-kpis-five .compact-stat:last-child {
  border-right: 0;
}

.ops-team-detail-table-scroll {
  max-height: 360px;
  overflow: auto;
  border-radius: 14px;
}

.ops-team-detail-table {
  min-width: 650px;
}

.ops-team-detail-table th,
.ops-team-detail-table td {
  padding: 11px 12px;
}

@media (max-width: 700px) {
  .ops-team-detail-kpis-five {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ops-team-detail-kpis-five .compact-stat {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .ops-team-detail-kpis-five .compact-stat:nth-child(2n) {
    border-right: 0;
  }

  .ops-team-detail-kpis-five .compact-stat:nth-child(3n) {
    border-right: 1px solid var(--line);
  }

  .ops-team-detail-kpis-five .compact-stat:nth-child(4) {
    border-right: 0;
  }

  .ops-team-detail-kpis-five .compact-stat:last-child {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 0;
  }

  .ops-team-detail-table-scroll {
    max-height: 300px;
    margin-inline: -2px;
  }

  .ops-team-detail-table {
    min-width: 610px;
    font-size: 12px;
  }

  .ops-team-detail-table th,
  .ops-team-detail-table td {
    padding: 10px 9px;
  }
}


/* Mobile Team Lead detail: one vertical scroller (the sheet), table scrolls only sideways. */
@media (max-width: 700px) {
  .sheet:has(.ops-team-detail) {
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .sheet:has(.ops-team-detail) .sheet-body {
    overflow: visible;
    overscroll-behavior: auto;
    touch-action: pan-y;
  }

  .ops-team-detail-table-scroll {
    width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scrollbar-gutter: auto;
  }

  .ops-team-detail-table {
    min-width: 610px;
  }
}


/* Keep the Date header vertically pinned like every other table header. */
.ops-analytics-table thead th:first-child,
.ops-analytics-table thead th.ops-date-col {
  position: sticky !important;
  top: 0 !important;
  left: auto !important;
  z-index: 3;
  background: var(--surface-2, #111827);
}


.compact-traffic-stats.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 700px) {
  .compact-traffic-stats.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* Team Lead broadcasts entry: keep the CTA compact instead of stretching across the card. */
.ops-broadcasts-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.ops-broadcasts-entry > span {
  min-width: 0;
  flex: 1 1 auto;
}

.ops-broadcasts-entry [data-ops-action="broadcasts"] {
  width: auto;
  min-width: 0;
  min-height: 40px;
  padding: 0 14px;
  flex: 0 0 auto;
  border-radius: 12px;
}

@media (max-width: 700px) {
  .ops-broadcasts-entry {
    align-items: flex-start;
    flex-direction: column;
  }

  .ops-broadcasts-entry [data-ops-action="broadcasts"] {
    width: auto;
  }
}


/* Per-link analytics drilldown */
.ops-link-analytics-btn {
  width: auto;
  min-height: 36px;
  margin-top: 10px;
  padding: 0 12px;
  gap: 7px;
  align-self: flex-start;
  font-size: 12px;
}

.ops-link-analytics-btn svg {
  width: 16px;
  height: 16px;
}

.ops-link-detail {
  display: grid;
  gap: 14px;
}

.ops-link-detail .ops-team-detail-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 700px) {
  .ops-link-detail .ops-team-detail-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* Unified mobile scrolling: sheet/page owns Y; wide analytics regions own X only. */
@media (max-width: 700px) {
  .sheet:has(.ops-team-detail),
  .sheet:has(.ops-link-detail) {
    overflow: hidden;
    touch-action: auto;
  }

  .sheet:has(.ops-team-detail) .sheet-body,
  .sheet:has(.ops-link-detail) .sheet-body {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .traffic-analytics-section .analytics-scroll,
  .ops-analytics-scroll,
  .ops-team-detail-table-scroll {
    width: 100%;
    height: auto;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  .compact-traffic-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .compact-traffic-head > div:first-child {
    flex: 1 1 150px;
  }

  .ops-card-actions {
    margin-left: auto;
    gap: 6px;
  }

  .ops-icon-action {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .ops-link-analytics-btn {
    margin: 10px 12px 12px;
  }
}


/* General statistics owns horizontal movement; page/sheet owns vertical movement. */
.ops-analytics-frame {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.ops-analytics-frame .ops-analytics-scroll {
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow-x: auto !important;
  overflow-y: visible !important;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: auto !important;
  border-radius: 0;
}

.ops-analytics-frame .ops-analytics-table {
  margin: 0;
}

@media (max-width: 700px) {
  .ops-analytics-frame {
    max-width: 100%;
  }

  .ops-analytics-frame .ops-analytics-scroll {
    scrollbar-width: thin;
  }
}
