.weekly-cut {
  display: grid;
  gap: 18px;
}

.weekly-cut-head,
.weekly-cut-toolbar,
.weekly-cut-table-head,
.weekly-cut-import-footer,
.weekly-cut-import-footer > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.weekly-cut-head h2 {
  margin-top: 3px;
  font-size: clamp(24px, 3vw, 34px);
}

.weekly-cut-head p:last-child,
.weekly-cut-table-head p,
.weekly-cut-status,
.weekly-cut-import-footer p {
  color: var(--muted);
}

.weekly-cut-toolbar {
  justify-content: flex-start;
  min-height: 52px;
  border-block: 1px solid var(--line);
  padding-block: 10px;
}

.weekly-cut-view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.weekly-cut-view-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.weekly-cut-view-switch button + button {
  border-left: 1px solid var(--line);
}

.weekly-cut-view-switch button.active {
  background: var(--ink);
  color: #fff;
}

.weekly-cut-period-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.weekly-cut-period-field select {
  min-width: 270px;
  font-variant-numeric: tabular-nums;
}

.weekly-cut-status {
  margin-left: auto;
  font-size: 13px;
}

.weekly-cut-summary {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(130px, 1fr);
  border-block: 1px solid var(--line);
}

.weekly-cut-summary > div {
  display: grid;
  gap: 4px;
  padding: 13px 16px;
}

.weekly-cut-summary > div + div {
  border-left: 1px solid var(--line);
}

.weekly-cut-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.weekly-cut-summary strong {
  font-size: 18px;
}

.weekly-cut-table-shell {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.weekly-cut-table-head {
  padding: 16px 18px;
}

.weekly-cut-table-head h3 {
  font-size: 18px;
}

.weekly-cut-table-head p {
  margin-top: 3px;
  font-size: 13px;
}

.weekly-cut-table-wrap {
  max-height: min(66vh, 780px);
  border-top: 1px solid var(--line);
  overflow: auto;
}

#weeklyCutTable {
  width: max-content;
  min-width: 100%;
  font-variant-numeric: tabular-nums;
}

#weeklyCutTable th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-strong);
  white-space: nowrap;
}

#weeklyCutTable th:first-child,
#weeklyCutTable td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 230px;
  max-width: 330px;
  background: var(--surface);
}

#weeklyCutTable th:first-child {
  z-index: 3;
  background: var(--surface-strong);
}

#weeklyCutTable td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

#weeklyCutTable .is-positive {
  color: #15803d;
  font-weight: 800;
}

#weeklyCutTable .is-negative {
  color: var(--danger);
  font-weight: 800;
}

.weekly-cut-empty {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 250px;
  color: var(--muted);
  text-align: center;
}

.weekly-cut-empty[hidden] {
  display: none;
}

.weekly-cut-import-dialog {
  width: min(820px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100svh - 32px);
}

.weekly-cut-import-shell {
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  gap: 14px;
  max-height: calc(100svh - 32px);
  overflow: auto;
}

.weekly-cut-source-note {
  display: grid;
  gap: 4px;
  border-left: 3px solid var(--accent);
  background: var(--surface-strong);
  padding: 12px 14px;
  font-size: 13px;
}

.weekly-cut-source-note span,
.weekly-cut-source-fields small {
  color: var(--muted);
}

.weekly-cut-source-fields {
  display: grid;
  gap: 14px;
}

.weekly-cut-source-fields label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.weekly-cut-source-fields input {
  width: 100%;
  font-weight: 650;
}

.weekly-cut-import-alert {
  border-left: 3px solid var(--danger);
  background: #fff8f6;
  padding: 10px 12px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 750;
}

.weekly-cut-import-alert.success {
  border-left-color: #15803d;
  background: #f3fbf5;
  color: #15803d;
}

.weekly-cut-progress {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.weekly-cut-progress[hidden] {
  display: none;
}

.weekly-cut-progress::before {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  content: "";
  animation: weekly-cut-spin .8s linear infinite;
}

@keyframes weekly-cut-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
  .weekly-cut-head,
  .weekly-cut-toolbar,
  .weekly-cut-table-head,
  .weekly-cut-import-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .weekly-cut-head .primary-action,
  .weekly-cut-import-footer button {
    width: 100%;
  }

  .weekly-cut-toolbar {
    align-items: flex-start;
  }

  .weekly-cut-status {
    margin-left: 0;
  }

  .weekly-cut-summary {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .weekly-cut-summary > div + div {
    border-left: 0;
  }

  .weekly-cut-summary > div:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .weekly-cut-import-footer > div {
    display: grid;
  }
}

@media (max-width: 820px) {
  .period-filter-popover {
    width: min(460px, calc(100vw - 32px));
  }

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

  .operation-row {
    grid-template-columns: 130px minmax(120px, 0.8fr) minmax(170px, 1.2fr) 110px 100px;
    min-width: 720px;
  }

  .operations-timeline {
    overflow-x: auto;
  }

  .payroll-buyer-history-table-wrap {
    overflow-x: auto;
  }

  .payroll-buyer-history-table-wrap table {
    min-width: 920px;
  }
}
