/* --- KPI Cards --- */
.kpi-row {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
/* DUSD and PSM tabs pack 6 KPIs in one row (tighter min-width so all fit) */
#dusdKpis .kpi-card, #revenueKpis .kpi-card { min-width: 140px; }
.kpi-card {
  flex: 1;
  min-width: 180px;
  background: rgba(27, 29, 30, 0.7);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  position: relative;
  box-shadow: rgba(0,0,0,0.2) 0px 2px 1px -1px, rgba(0,0,0,0.14) 0px 1px 1px 0px, rgba(0,0,0,0.12) 0px 1px 3px 0px;
}
.kpi-info {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #CCCCCC;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  font-style: italic;
  font-weight: 600;
}
.kpi-info:hover { background: rgba(255,255,255,0.2); color: #FFFFFF; }
/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #1B1D1E;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 24px 24px 20px;
  width: min(520px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  color: #DDDDDD;
  font-size: 13px;
  line-height: 1.55;
}
.modal-title {
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 600;
  margin: 0 32px 12px 0;
}
.modal-x {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: #CCCCCC;
  font-size: 15px;
  line-height: 26px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  border: none;
}
.modal-x:hover { background: rgba(255,255,255,0.18); color: #FFFFFF; }
.modal-close-btn {
  margin-top: 18px;
  background: rgba(255,255,255,0.08);
  color: #FFFFFF;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.modal-close-btn:hover { background: rgba(255,255,255,0.15); }
.modal-metrics {
  margin: 12px 0 0;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  font-size: 13px;
  color: #CCCCCC;
}
.modal-metrics > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.modal-metrics > div:last-child { border-bottom: none; }
.modal-metrics span:last-child {
  color: #FFFFFF;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.kpi-value {
  font-size: 34px;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 4px;
}
.kpi-value.green { color: #66BB6A; }
.kpi-label {
  font-size: 14px;
  color: #CCCCCC;
  font-weight: 400;
}
.kpi-sub {
  font-size: 12px;
  margin-top: 6px;
  color: #999999;
  font-weight: 500;
}
.kpi-sub.up { color: #66BB6A; }
.kpi-sub.down { color: #EF5350; }
/* --- Chart containers --- */
.chart-row {
  display: flex;
  gap: 20px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.chart-card {
  flex: 1;
  min-width: 400px;
  background: rgba(27, 29, 30, 0.7);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 16px;
  box-shadow: rgba(0,0,0,0.2) 0px 2px 1px -1px, rgba(0,0,0,0.14) 0px 1px 1px 0px, rgba(0,0,0,0.12) 0px 1px 3px 0px;
}
.chart-card.full { min-width: 100%; flex-basis: 100%; }
.chart-card.three-quarter { flex: 3 1 0; min-width: 0; }
.chart-card.quarter { flex: 1 1 0; min-width: 0; }
.chart-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #FFFFFF;
}
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 350px;
}
.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: none;
}
.chart-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(66, 165, 245, 0.15);
  border-top-color: #42A5F5;
  animation: chart-spin 0.9s linear infinite;
}
.chart-loading-text {
  font-size: 12px;
  color: #999999;
  letter-spacing: 0.02em;
}
@keyframes chart-spin { to { transform: rotate(360deg); } }

/* --- PSM status card --- */
.psm-status-card .chart-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.psm-status-card .chart-title-row .chart-title { margin-bottom: 0; }
.psm-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  color: #CCCCCC;
  background: rgba(255,255,255,0.04);
}
.psm-status-badge::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #888;
}
.psm-status-badge.active { color: #66BB6A; border-color: rgba(102,187,106,0.35); background: rgba(102,187,106,0.08); }
.psm-status-badge.active::before { background: #66BB6A; box-shadow: 0 0 6px #66BB6A; }
.psm-status-badge.bad { color: #EF5350; border-color: rgba(239,83,80,0.35); background: rgba(239,83,80,0.08); }
.psm-status-badge.bad::before { background: #EF5350; }

.psm-pair-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 12px;
}
.psm-pair-side .psm-pair-label {
  font-size: 13px;
  color: #CCCCCC;
  margin-bottom: 4px;
}
.psm-pair-side.right { text-align: right; }
.psm-pair-value {
  font-size: 28px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.1;
}
.psm-util-bar {
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.psm-util-fill {
  height: 100%;
  background: linear-gradient(90deg, #AB47BC, #FF7043);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.psm-util-meta {
  text-align: center;
  margin-top: 8px;
  font-size: 13px;
  color: #CCCCCC;
}
.psm-util-meta strong { color: #FFFFFF; font-weight: 600; }
.psm-status-col {
  flex: 1;
  min-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.psm-status-col > .chart-card { flex: 0 0 auto; min-width: 0; }

/* --- Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: #CCCCCC;
  font-weight: 500;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #FFFFFF;
}
.data-table tr:hover td {
  background: rgba(255,255,255,0.03);
}
.data-table.sortable th[data-sort-key] {
  cursor: pointer;
  user-select: none;
}
.data-table.sortable th[data-sort-key]::after {
  content: '';
  display: inline-block;
  width: 0.9em;
  margin-left: 4px;
  color: rgba(255,255,255,0.35);
}
.data-table.sortable th[data-sort-key]:hover::after { content: '↕'; }
.data-table.sortable th[data-sort-active="asc"]::after  { content: '↑'; color: #FFFFFF; }
.data-table.sortable th[data-sort-active="desc"]::after { content: '↓'; color: #FFFFFF; }

/* --- Table filter bar --- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 0 4px 14px;
  font-size: 13px;
}
.filter-bar label {
  color: rgba(255,255,255,0.6);
  margin-right: 4px;
}
.filter-bar select, .filter-bar input[type="text"], .filter-bar input[type="number"] {
  background: rgba(255,255,255,0.06);
  color: #FFFFFF;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.filter-bar select:focus, .filter-bar input:focus {
  border-color: rgba(255,255,255,0.3);
}
.filter-bar input::placeholder { color: rgba(255,255,255,0.35); }
.filter-bar .filter-reset {
  background: transparent;
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
.filter-bar .filter-reset:hover { color: #FFFFFF; border-color: rgba(255,255,255,0.3); }

.chart-card > .chart-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}
.chart-card > .chart-title-row > .chart-title { margin-bottom: 0; }

/* --- Range pill group --- */
.pill-group {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
}
.pill-group button {
  background: transparent;
  color: rgba(255,255,255,0.6);
  border: none;
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pill-group button:hover { color: #FFFFFF; }
.pill-group button.active {
  background: rgba(66,165,245,0.18);
  color: #FFFFFF;
}
