.courier-stats-root {
  padding: 20px;
}

.courier-stats {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.courier-stats-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.courier-stats-fieldset {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.courier-stats-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 190px;
}

.courier-stats-field label,
.courier-stats-chart-field label {
  font-size: 0.95rem;
  color: #d8e1ee;
  font-weight: 600;
}

.courier-stats-field select,
.courier-stats-field input,
.courier-stats-chart-field select,
.courier-stats-chart-field input,
.courier-stats-modal-input {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #3a4558;
  border-radius: 6px;
  background: #182131;
  color: #fff;
  box-sizing: border-box;
}

.courier-stats-chart-field select[multiple] {
  min-height: 120px;
}

.courier-stats-button {
  min-height: 40px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #2a3a5a;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.courier-stats-button:hover {
  background: #32486f;
}

.courier-stats-button-secondary {
  background: #5c6472;
}

.courier-stats-button-secondary:hover {
  background: #6d7686;
}

.courier-stats-button-primary {
  background: #4da6ff;
  color: #102033;
}

.courier-stats-button-primary:hover {
  background: #79bcff;
}

.courier-stats-toggle-row {
  display: flex;
  justify-content: flex-end;
}

.courier-stats-toggle-button {
  font-size: 1rem;
  padding-inline: 20px;
}

.courier-stats-empty {
  margin: 0;
  color: #cdd6e3;
}

.courier-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

.courier-stats-card {
  background: rgba(15, 20, 31, 0.86);
  border: 1px solid #31405a;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 100%;
}

.courier-stats-card-title {
  margin: 0 0 14px;
  font-size: 1.3rem;
}

.courier-stats-card-logo {
  width: 110px;
  height: 110px;
  margin-bottom: 12px;
  object-fit: cover;
}

.courier-stats-badge {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 700;
}

.courier-stats-badge-success {
  background: #2c9d4b;
  color: #fff;
}

.courier-stats-stats {
  width: 100%;
}

.courier-stats-stats p {
  margin: 8px 0;
}

.courier-stats-links {
  width: 100%;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #41506a;
}

.courier-stats-links p {
  margin: 8px 0;
}

.courier-stats-link {
  color: #7fc2ff;
  text-decoration: underline;
}

.courier-stats-edit-button {
  margin-top: 10px;
}

.courier-stats-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
}

.courier-stats-modal-content {
  width: min(500px, 100%);
  background: #1a1f2e;
  border: 1px solid #42506a;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.courier-stats-modal-title {
  margin: 0 0 20px;
}

.courier-stats-modal-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 15px;
}

.courier-stats-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.courier-stats-chart-panel {
  margin: 6px 0 0;
  padding: 20px;
  border: 1px solid #41506a;
  border-radius: 10px;
  background: rgba(15, 20, 31, 0.58);
}

.courier-stats-chart-title {
  margin-top: 0;
  margin-bottom: 16px;
}

.courier-stats-chart-controls {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.courier-stats-chart-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.courier-stats-chart-field-multi {
  min-width: 220px;
}

.courier-stats-chart-aggregation {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.courier-stats-aggregation-button {
  min-height: 36px;
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: #222b3a;
  color: #fff;
  cursor: pointer;
}

.courier-stats-aggregation-button.is-active {
  background: #2a3a5a;
  font-weight: 700;
}

.courier-stats-chart-shell {
  min-height: 300px;
}

.courier-stats-chart-error {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(140, 20, 20, 0.35);
  color: #ffd9d9;
}

.courier-stats-chart-canvas {
  width: 100%;
  max-width: 100%;
}

@media (max-width: 900px) {
  .courier-stats-root {
    padding: 14px;
  }

  .courier-stats-toolbar,
  .courier-stats-chart-controls {
    align-items: stretch;
  }

  .courier-stats-field,
  .courier-stats-chart-field {
    min-width: 100%;
  }

  .courier-stats-grid {
    grid-template-columns: 1fr;
  }

  .courier-stats-modal {
    padding: 12px;
  }
}