.kpi-manager {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.kpi-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #1a1a2e;
}

.kpi-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}

.kpi-btn-primary {
  background: #007bff;
  color: #fff;
}

.kpi-btn-primary:hover {
  background: #0056b3;
}

.kpi-btn-outline {
  background: transparent;
  border: 1px solid #dee2e6;
  color: #495057;
}

.kpi-btn-outline:hover {
  background: #f8f9fa;
}

.kpi-btn-danger {
  background: transparent;
  border: 1px solid #dc3545;
  color: #dc3545;
}

.kpi-btn-danger:hover {
  background: #dc3545;
  color: #fff;
}

.kpi-btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.kpi-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-summary-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-left: 4px solid #007bff;
}

.kpi-summary-green {
  border-left-color: #28a745;
}

.kpi-summary-amber {
  border-left-color: #ffc107;
}

.kpi-summary-red {
  border-left-color: #dc3545;
}

.kpi-summary-number {
  font-size: 2rem;
  font-weight: 700;
  color: #1a1a2e;
}

.kpi-summary-label {
  font-size: 0.85rem;
  color: #6c757d;
  margin-top: 4px;
}

.kpi-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-input,
.kpi-select {
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}

.kpi-input:focus,
.kpi-select:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.kpi-filters .kpi-input {
  flex: 1;
}

.kpi-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s;
}

.kpi-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.kpi-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1a1a2e;
}

.kpi-status-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.kpi-card-desc {
  font-size: 0.85rem;
  color: #6c757d;
  margin-bottom: 12px;
}

.kpi-card-metrics {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}

.kpi-metric {
  display: flex;
  flex-direction: column;
}

.kpi-metric-label {
  font-size: 0.75rem;
  color: #6c757d;
  text-transform: uppercase;
}

.kpi-metric-value {
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a2e;
}

.kpi-progress-bar {
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.kpi-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.kpi-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.kpi-dept-tag {
  background: #e8f4fd;
  color: #0277bd;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.kpi-frequency {
  font-size: 0.75rem;
  color: #6c757d;
}

.kpi-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-empty {
  text-align: center;
  padding: 40px;
  color: #6c757d;
  grid-column: 1 / -1;
}

.kpi-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.kpi-modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.kpi-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
}

.kpi-modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.kpi-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  line-height: 1;
}

.kpi-modal-body {
  padding: 20px;
}

.kpi-form-group {
  margin-bottom: 16px;
}

.kpi-form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #495057;
}

.kpi-form-group .kpi-input,
.kpi-form-group .kpi-select {
  width: 100%;
  box-sizing: border-box;
}

.kpi-form-group textarea.kpi-input {
  resize: vertical;
}

.kpi-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kpi-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.kpi-detail-view {
  max-height: 60vh;
  overflow-y: auto;
}

.kpi-detail-header {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
}

.kpi-progress-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: conic-gradient(var(--color) calc(var(--pct) * 1%), #e9ecef 0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  position: relative;
  flex-shrink: 0;
}

.kpi-progress-circle::before {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #fff;
}

.kpi-progress-circle span {
  position: relative;
  z-index: 1;
}

.kpi-detail-info {
  font-size: 0.9rem;
  line-height: 1.8;
}

.kpi-detail-chart-container {
  height: 250px;
  margin-bottom: 20px;
}

.kpi-measurements-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.kpi-measurements-table th,
.kpi-measurements-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid #e9ecef;
}

.kpi-measurements-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #495057;
}

.kpi-measurements-table tr:hover {
  background: #f8f9fa;
}

@media (max-width: 768px) {
  .kpi-summary-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi-list {
    grid-template-columns: 1fr;
  }
  .kpi-filters {
    flex-direction: column;
  }
  .kpi-form-row {
    grid-template-columns: 1fr;
  }
  .kpi-modal {
    width: 95%;
    max-height: 90vh;
  }
  .kpi-detail-header {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .kpi-summary-row {
    grid-template-columns: 1fr 1fr;
  }
  .kpi-card-metrics {
    flex-wrap: wrap;
  }
}
