* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f6fa;
  color: #2d3436;
}

header {
  background: #2d3436;
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

header h1 { font-size: 20px; white-space: nowrap; }

.filters {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.8;
}

.filter-group select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #636e72;
  background: #3d4447;
  color: white;
  font-size: 13px;
}

.btn {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #0984e3; color: white; }
.btn-secondary { background: #636e72; color: white; }

main { padding: 0 24px 24px; }

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

.tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: #636e72;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab.active { color: #0984e3; border-bottom-color: #0984e3; }
.tab:hover { color: #2d3436; }

.tab-content { display: none; margin-top: 16px; }
.tab-content.active { display: block; }

.tab-content h2 { font-size: 18px; margin-bottom: 4px; }
.description { font-size: 13px; color: #636e72; margin-bottom: 12px; }

.sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.sub-tab {
  padding: 6px 14px;
  border: 1px solid #dfe6e9;
  background: white;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #636e72;
  transition: all 0.2s;
}
.sub-tab.active { background: #0984e3; color: white; border-color: #0984e3; }
.sub-content { display: none; }
.sub-content.active { display: block; }

.stat-badge {
  display: inline-block;
  padding: 4px 12px;
  background: #dfe6e9;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.kpi-row {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.kpi-card {
  background: white;
  border-radius: 10px;
  padding: 14px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  min-width: 140px;
  flex: 1;
  max-width: 220px;
}
.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}
.kpi-card .kpi-label {
  font-size: 11px;
  color: #636e72;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}
.kpi-green .kpi-value { color: #1e8449; }
.kpi-yellow .kpi-value { color: #b7950b; }
.kpi-red .kpi-value { color: #c0392b; }
.kpi-blue .kpi-value { color: #0984e3; }
.kpi-neutral .kpi-value { color: #2d3436; }

.chart-container {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  max-height: 420px;
  position: relative;
}
.chart-container.chart-sm { max-width: 500px; max-height: 350px; }
.chart-container.chart-half { flex: 1; min-width: 300px; max-height: 400px; }

.charts-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.charts-row .chart-container { margin-bottom: 0; }

.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  font-size: 13px;
  table-layout: auto;
}

thead th {
  background: #f8f9fa;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: #636e72;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #dfe6e9;
  white-space: nowrap;
  position: relative;
  overflow: visible;
}

.th-content { pointer-events: none; }

.resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  z-index: 1;
}
.resize-handle:hover,
.resize-handle:active {
  background: #0984e3;
  opacity: 0.4;
}

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f2f6;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody td.wrap-cell { white-space: normal; word-break: break-word; }

tbody tr:hover { background: #f8f9fa; }

.pct-cell { text-align: center; font-weight: 600; border-radius: 4px; }
.pct-high { background: #d4efdf; color: #1e8449; }
.pct-mid { background: #fef9e7; color: #b7950b; }
.pct-low { background: #fadbd8; color: #c0392b; }

.loading {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.85);
  z-index: 999;
  font-size: 18px;
  font-weight: 600;
  justify-content: center;
  align-items: center;
}
.loading.visible { display: flex; }

/* Help button */
.btn-help {
  background: transparent;
  color: white;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-help:hover { border-color: white; }

/* Legend dots */
.legend {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 2px 0 6px;
  vertical-align: middle;
}
.legend-green { background: #1e8449; }
.legend-yellow { background: #b7950b; }
.legend-red { background: #c0392b; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding-top: 60px;
  overflow-y: auto;
}
.modal-overlay.visible { display: flex; }

.modal {
  background: white;
  border-radius: 12px;
  width: 95%;
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #dfe6e9;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.modal-header h2 { font-size: 17px; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #636e72;
  padding: 0 4px;
}
.modal-close:hover { color: #2d3436; }

.modal-body {
  padding: 20px 24px;
  font-size: 14px;
  line-height: 1.7;
}
.modal-body h3 {
  font-size: 15px;
  margin: 18px 0 6px;
  color: #0984e3;
}
.modal-body h3:first-child { margin-top: 0; }
.modal-body ul {
  padding-left: 20px;
  margin: 6px 0;
}
.modal-body li { margin-bottom: 4px; }
.modal-body p { margin-bottom: 8px; }
