.capacity-case {
  margin-top: 26px;
  padding: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-card);
}

.capacity-settings {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid #e7e0d8;
  border-radius: 18px;
  background: #f8f7f4;
}

.capacity-settings-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.capacity-settings-head strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.capacity-settings-head span,
.capacity-period {
  color: var(--text-muted);
  font-size: 11px;
}

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

.capacity-line-card {
  padding: 18px;
  border: 1px solid #e7e0d8;
  border-radius: 16px;
  background: #ffffff;
}

.capacity-line-name span {
  display: block;
  font-weight: 700;
}

.capacity-line-name small {
  color: var(--text-muted);
}

.capacity-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}

.capacity-minus,
.capacity-plus {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: #ffffff;
  cursor: pointer;
  font-size: 20px;
}

.capacity-value {
  text-align: center;
}

.capacity-value strong {
  display: block;
  color: var(--green);
  font-family: var(--font-tech);
  font-size: 24px;
}

.capacity-value span {
  color: var(--text-muted);
  font-size: 10px;
}

.capacity-orders-panel {
  margin-top: 20px;
  overflow: hidden;
  border: 1px solid #e7e0d8;
  border-radius: 18px;
}

.capacity-panel-head {
  display: flex;
  justify-content: space-between;
  padding: 18px;
  background: #f7f4ef;
}

.capacity-panel-head strong {
  display: block;
}

.capacity-panel-head span,
.capacity-orders-status {
  color: var(--text-muted);
  font-size: 10px;
}
.capacity-table-wrap {
  max-height: 420px;
  overflow: auto;
}

.capacity-orders-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: collapse;
}

.capacity-orders-table th,
.capacity-orders-table td {
  padding: 10px;
  border-bottom: 1px solid #eee8e0;
  white-space: nowrap;
  font-size: 10px;
}

.capacity-orders-table th {
  position: sticky;
  top: 0;
  background: var(--green);
  color: #ffffff;
}

.capacity-orders-table td {
  color: #57524d;
  font-family: var(--font-tech);
}

.capacity-orders-table tbody tr:hover td {
  background: #f7faf7;
}

.capacity-orders-table tbody tr[data-capacity-priority="urgent"] td {
  background: #fff8f0;
}

.capacity-status,
.capacity-priority {
  display: inline-flex;
  align-items: center;
  margin: 2px 4px 2px 0;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

.capacity-status-waiting {
  border: 1px solid #ded8cf;
  background: #f5f2ed;
  color: #777069;
}

.capacity-status-ok {
  border: 1px solid #cfe2d4;
  background: #edf7ef;
  color: #287047;
}

.capacity-status-warning {
  border: 1px solid #efd798;
  background: #fff5d9;
  color: #876400;
}

.capacity-status-error {
  border: 1px solid #efbaba;
  background: #ffeaea;
  color: #9b3434;
}

.capacity-priority-normal {
  border: 1px solid #dfe2e0;
  background: #f5f6f5;
  color: #6e716f;
}

.capacity-priority-high {
  border: 1px solid #d5d8ec;
  background: #f2f3fb;
  color: #585a91;
}

.capacity-priority-urgent {
  border: 1px solid #efbaba;
  background: #fff0f0;
  color: #a03434;
}

.capacity-mode-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
  padding: 17px 18px;
  border: 1px solid var(--border-green);
  border-radius: 16px;
  background: var(--surface-green);
}

.capacity-mode-panel strong {
  display: block;
  color: var(--green);
  font-size: 13px;
}

.capacity-mode-panel span {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10px;
}

.capacity-mode-switch {
  display: flex;
  gap: 7px;
  padding: 4px;
  border-radius: 12px;
  background: #e1ebe3;
}

.capacity-mode-button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #647168;
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
}

.capacity-mode-button.active {
  background: #ffffff;
  color: var(--green);
  box-shadow: 0 5px 14px rgba(53, 89, 75, 0.13);
}

.capacity-action {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.capacity-calculate-button {
  min-height: 50px;
  padding: 0 24px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.capacity-calculate-button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.capacity-loader {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.capacity-loader.active {
  display: flex;
}

.capacity-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d9e5ee;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: capacitySpin 0.8s linear infinite;
}

@keyframes capacitySpin {
  to {
    transform: rotate(360deg);
  }
}
.capacity-output {
  margin-top: 24px;
}

.capacity-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.capacity-summary-item {
  padding: 18px;
  border: 1px solid #e7e0d8;
  border-radius: 16px;
  background: #fcfbf9;
}

.capacity-summary-item span {
  display: block;
  font-size: 10px;
}

.capacity-summary-item strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.capacity-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.capacity-dashboard-card {
  padding: 18px;
  border: 1px solid #e7e0d8;
  border-radius: 18px;
}

.capacity-dashboard-head span {
  color: var(--text-muted);
  font-size: 10px;
}

.capacity-utilization-row {
  margin-top: 18px;
}

.capacity-utilization-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.capacity-utilization-track {
  height: 12px;
  border-radius: 999px;
  background: #ece8e3;
}

.capacity-utilization-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(
      90deg,
      #35594b,
      #70a588
    );
}

.capacity-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 20px;
}

.capacity-day {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  height: 38px;
  border-radius: 8px;
  color: #5c5751;
  font-family: var(--font-tech);
  font-size: 8px;
  font-weight: 600;
  cursor: default;
}

.capacity-free {
  background: #e6f3e9;
}

.capacity-medium {
  background: #ffe9ae;
}

.capacity-full {
  background: #ffc7c7;
}

.capacity-day::after {
  content: attr(data-load);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  z-index: 5;
  width: max-content;
  max-width: 180px;
  padding: 6px 8px;
  border-radius: 7px;
  background: #34322f;
  color: #ffffff;
  font-size: 8px;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 4px);
  transition:
    opacity 0.18s ease,
    visibility 0.18s ease,
    transform 0.18s ease;
  pointer-events: none;
}

.capacity-day:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.capacity-legend {
  display: flex;
  gap: 18px;
  margin-top: 18px;
}

.capacity-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
}

.capacity-legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.capacity-legend-free {
  background: #e6f3e9;
}

.capacity-legend-medium {
  background: #ffe9ae;
}

.capacity-legend-full {
  background: #ffc7c7;
}

.capacity-orders-table tbody tr.capacity-row-updated td {
  animation: capacityRowUpdate 0.55s ease;
}

@keyframes capacityRowUpdate {
  0% {
    background: #e9f4eb;
  }

  100% {
    background: transparent;
  }
}
@media (max-width: 760px) {
  .capacity-case {
    margin-top: 18px;
    padding: 26px 16px;
    border-radius: 18px;
  }

  .capacity-settings-head {
    display: block;
  }

  .capacity-period {
    margin-top: 10px;
  }

  .capacity-lines,
  .capacity-summary,
  .capacity-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .capacity-panel-head {
    display: block;
  }

  .capacity-orders-status {
    margin-top: 8px;
  }

  .capacity-mode-panel {
    display: block;
  }

  .capacity-mode-switch {
    margin-top: 14px;
  }

  .capacity-mode-button {
    flex: 1;
  }

  .capacity-legend {
    flex-direction: column;
    gap: 10px;
  }
}
