.kpi-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.kpi-tab {
  padding: 10px 24px;
  border: none;
  background: none;
  color: #777;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}
.kpi-tab:hover {
  color: #01649d;
}
.kpi-tab.active {
  color: #01649d;
}
.kpi-tab.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #01649d;
}

.kpi-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.kpi-period-buttons {
  display: flex;
  gap: 4px;
}

.kpi-period-btn {
  padding: 8px 20px;
  border: 2px solid #01649d;
  background: #fff;
  color: #01649d;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: all 0.15s ease;
}
.kpi-period-btn:hover {
  background: #e8f4fa;
}
.kpi-period-btn.active {
  background: #01649d;
  color: #fff;
}

.kpi-selector-btn {
  margin-left: auto;
  padding: 8px 16px;
  border: 2px solid #01649d;
  background: #fff;
  color: #01649d;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}
.kpi-selector-btn:hover {
  background: #e8f4fa;
}
.kpi-selector-btn i {
  font-size: 16px;
}

.kpi-year-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
}

.kpi-year-btn {
  padding: 6px 14px;
  border: 1px solid #ccc;
  background: #fff;
  color: #555;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.15s ease;
}
.kpi-year-btn:hover {
  border-color: #01649d;
  color: #01649d;
}
.kpi-year-btn.active {
  border-color: #01649d;
  background: #01649d;
  color: #fff;
}

#kpi-chart {
  margin-bottom: 16px;
}

.kpi-no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  font-size: 15px;
  color: #888;
  font-style: italic;
}

.kpi-unit-note {
  font-size: 12px;
  color: #888;
  font-style: italic;
  margin-bottom: 16px;
}

.kpi-table-wrapper {
  overflow-x: auto;
  margin-bottom: 24px;
  position: relative;
}

.kpi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.kpi-table thead th {
  background: #f5f7fa;
  color: #002138;
  font-weight: 600;
  text-align: center;
  padding: 10px 12px;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.kpi-table thead th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f5f7fa;
}
.kpi-table tbody td {
  padding: 8px 12px;
  text-align: center;
  border-bottom: 1px solid #eee;
}
.kpi-table tbody tr:hover {
  background: #f8fafe;
}
.kpi-table tbody tr:hover .kpi-table-label {
  background: #f8fafe;
}

.kpi-table-value {
  color: #111;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.kpi-table-label {
  text-align: left !important;
  font-weight: 500;
  color: #002138 !important;
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
}

.kpi-table-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 8px;
  flex-shrink: 0;
  vertical-align: middle;
}

.kpi-table-unit {
  text-align: center;
  color: #999 !important;
  font-size: 12px;
  white-space: nowrap;
  width: 60px;
}

.kpi-table-group td {
  background: #e8ecef;
  font-weight: 700;
  color: #002138;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-bottom: 1px solid #ddd;
}
.kpi-table-group .kpi-table-label {
  background: #e8ecef;
}

.kpi-table-child .kpi-table-label {
  padding-left: 24px;
}
.kpi-table-child .kpi-table-label.-child {
  padding-left: 48px !important;
}

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

.kpi-modal {
  background: #fff;
  border-radius: 4px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.kpi-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
}
.kpi-modal-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #002138;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kpi-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #888;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.kpi-modal-close:hover {
  color: #333;
}
.kpi-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-modal-group-header {
  font-size: 13px;
  font-weight: 700;
  color: #002138;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 0 4px;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 2px;
}
.kpi-modal-group-header:first-child {
  padding-top: 0;
}
.kpi-modal-separator {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 6px 0;
}
.kpi-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
}
.kpi-modal-item input[type=checkbox] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #01649d;
  flex-shrink: 0;
}
.kpi-modal-color {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}
.kpi-modal-footer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid #e0e0e0;
  justify-content: flex-end;
}
.kpi-modal-action {
  padding: 8px 16px;
  border: 1px solid #ccc;
  background: #fff;
  color: #555;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  transition: all 0.15s ease;
}
.kpi-modal-action:hover {
  border-color: #01649d;
  color: #01649d;
}
.kpi-modal-apply {
  padding: 8px 24px;
  border: none;
  background: #01649d;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: background 0.15s ease;
}
.kpi-modal-apply:hover {
  background: #004a71;
}

.kpi-options-wrapper {
  position: relative;
}

.kpi-options-btn {
  padding: 8px 16px;
  border: 2px solid #01649d;
  background: #fff;
  color: #01649d;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}
.kpi-options-btn:hover {
  background: #e8f4fa;
}
.kpi-options-btn.active {
  background: #01649d;
  color: #fff;
}
.kpi-options-btn .kpi-options-close {
  font-size: 16px;
  line-height: 1;
}

.kpi-options-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 100;
  min-width: 280px;
  padding: 16px 20px;
  display: none;
}
.kpi-options-panel.open {
  display: block;
}

.kpi-options-section {
  font-size: 11px;
  font-weight: 700;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.kpi-options-section:not(:first-child) {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e0e0e0;
}

.kpi-options-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 14px;
  color: #333;
}
.kpi-options-item input[type=radio] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #01649d;
  flex-shrink: 0;
}

.kpi-options-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  font-size: 14px;
  color: #01649d;
  text-decoration: none;
  border: none;
  background: none;
  font-family: inherit;
}
.kpi-options-link:hover {
  color: #004a71;
}
.kpi-options-link i {
  width: 18px;
  text-align: center;
  font-size: 16px;
}

@media (max-width: 768px) {
  .kpi-tabs {
    overflow-x: auto;
  }
  .kpi-tab {
    padding: 8px 16px;
    font-size: 12px;
  }
  .kpi-controls {
    flex-direction: column;
    align-items: flex-start;
  }
  .kpi-selector-btn {
    margin-left: 0;
  }
  .kpi-period-btn {
    padding: 6px 14px;
    font-size: 12px;
  }
  .kpi-year-btn {
    padding: 5px 10px;
    font-size: 11px;
  }
  .kpi-modal {
    width: 95%;
  }
}