/* ═══════════════════════════════════════════════════════════
   APJ (PJU) — Panel UI
   Dark theme = default; light overrides at the bottom.
   ═══════════════════════════════════════════════════════════ */

/* ── Panel Toggle (mobile) ────────────────────────────────── */
.panel-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-base);
}
.panel-toggle-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* ── Panel Body ────────────────────────────────────────────── */
#panel-body {
  padding: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}
#panel-body::-webkit-scrollbar { width: 5px; }
#panel-body::-webkit-scrollbar-track { background: transparent; }
#panel-body::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 999px; }
#panel-body::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── Header ───────────────────────────────────────────────── */
#panel-header .panel-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: #7C3AED;
  color: #FFFFFF;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}
#panel-header h1 { font-size: 14px; font-weight: 600; }

.badge {
  margin-left: auto;
  background: rgba(124, 58, 237, 0.15);
  color: #C4B5FD;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: 'Fira Code', 'Fira Sans', monospace;
  min-width: 32px;
  text-align: center;
  border: 1px solid rgba(124, 58, 237, 0.2);
}

/* ── Section Spacing ───────────────────────────────────────── */
.panel-section { margin-bottom: 16px; }
.panel-section:last-child { margin-bottom: 0; }

/* ── Stats: single cohesive section ───────────────────────── */
.stats-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stats-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 16px 12px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(37, 99, 235, 0.1));
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: var(--radius-lg);
  text-align: center;
}
.stats-hero-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #C4B5FD;
}
.stats-hero-value {
  font-size: 30px;
  font-weight: 800;
  color: #F8FAFC;
  font-variant-numeric: tabular-nums;
  font-family: 'Fira Code', 'Fira Sans', monospace;
  line-height: 1.1;
}
body.light .stats-hero-value { color: #0F172A; }

.stats-kpi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.kpi-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  text-align: center;
}
.kpi-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}
.kpi-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-family: 'Fira Code', 'Fira Sans', monospace;
}
.kpi-ok .kpi-value { color: #86EFAC; }
.kpi-bad .kpi-value { color: #FCA5A5; }
body.light .kpi-ok .kpi-value { color: #15803D; }
body.light .kpi-bad .kpi-value { color: #DC2626; }

.stats-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

/* ── Section headers (collapsible) ─────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0 8px;
}
.section-chevron {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.panel-section.open .section-chevron { transform: rotate(90deg); }
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0;
}
.section-content { overflow: hidden; }

/* ── Progress bars (condition + UPTD distribution) ───────── */
#kond-bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; flex-direction: column; gap: 4px; }
.bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}
.bar-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
}
.bar-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.bar-count {
  font-variant-numeric: tabular-nums;
  font-family: 'Fira Code', 'Fira Sans', monospace;
  font-size: 12px;
  color: var(--text-primary);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.bar-count em {
  font-style: normal;
  font-size: 10px;
  color: var(--text-muted);
}
.bar-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
body.light .bar-track { background: rgba(15, 23, 42, 0.07); }
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 300ms ease;
}

/* ── Filter grid (multi-attribute chips) ──────────────────── */
.filter-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.filter-field select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px 30px 8px 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.filter-field select:hover { border-color: var(--border-strong); }
.filter-field select:focus {
  outline: none;
  border-color: #7C3AED;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: inherit;
  line-height: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 150ms ease;
}
.chip-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.chip-btn.active {
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.55);
  color: #C4B5FD;
  font-weight: 600;
}
body.light .chip-btn.active {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.45);
  color: #6D28D9;
}

/* UPTD list reuses the shared .uptd-item styles from the other modes —
   no local overrides here, so switching modes never changes the look. */

/* ── Legend ───────────────────────────────────────────────── */
#legend {
  position: absolute;
  bottom: 45px;
  right: 12px;
  left: auto;
  z-index: 10;
  background: var(--panel-bg, #0F172A);
  color: var(--text-primary, #F8FAFC);
  font-family: 'Fira Sans', system-ui, -apple-system, sans-serif;
  border: 1px solid var(--border-default, rgba(255,255,255,0.08));
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(2, 8, 23, 0.5);
  min-width: 140px;
}
.legend-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted, #94A3B8);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px 0;
}
.legend-content { display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; }
.legend-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.legend-label { font-size: 11px; color: var(--text-secondary, #CBD5E1); }

/* ═══ LIGHT THEME ═══ */
body.light .badge {
  background: rgba(124, 58, 237, 0.1);
  color: #6D28D9;
  border-color: rgba(124, 58, 237, 0.25);
}
body.light .stats-hero {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(37, 99, 235, 0.05));
  border-color: rgba(124, 58, 237, 0.2);
}
body.light #legend {
  background: #FFFFFF;
  border-color: #E2E8F0;
}

/* ═══ MOBILE ═══ */
@media (max-width: 600px) {
  .panel-toggle-btn { display: flex; }
  #legend { display: none; }
}
