/* ── STATISTIK GUNATANAH — dashboard-specific layout (reuses index.css tokens) ── */

.section { padding-bottom: 56px; }
.stat-section { padding-bottom: 8px; }

.stat-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
  min-height: 14px;
}
.stat-item-text .stat-num-text {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--amber);
}

.metric-toggle { flex-shrink: 0; }

.dash-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.dash-panel:last-child { margin-bottom: 0; }

.chart-box { position: relative; height: 320px; }
.chart-box-tall { height: 380px; }
.stacked-box { height: 380px; }

/* Komposisi row: donut + legend card share ONE fixed height so neither panel
   stretches oddly taller/shorter than the other (was the main layout bug). */
.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  align-items: stretch;
  gap: 18px;
  margin-bottom: 18px;
}
.dash-grid-2 .dash-panel { margin-bottom: 0; }

.donut-box {
  height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.donut-box canvas { max-width: 100%; max-height: 100%; }

.legend-card {
  height: 380px;
  display: flex;
  flex-direction: column;
}
.legend-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  margin-bottom: 12px;
  gap: 10px;
}
.legend-card-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.legend-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
}

.table-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dash-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text-sec);
  font-family: 'DM Sans', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}
.dash-download-btn svg { width: 12px; height: 12px; }
.dash-download-btn:hover { color: var(--gold); border-color: var(--gold-border); background: var(--gold-bg); }
.legend-card-head-actions .dash-download-btn { padding: 5px 8px; }

.dash-select select {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 9px 14px;
  outline: none;
  cursor: pointer;
}

.legend-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}
.legend-panel::-webkit-scrollbar { width: 6px; }
.legend-panel::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
.legend-panel::-webkit-scrollbar-track { background: transparent; }

.legend-row {
  display: grid;
  grid-template-columns: 12px 1fr auto 48px;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  border-radius: 6px;
  transition: background 0.15s;
}
.legend-row:hover { background: var(--surface-2); }
.legend-row:last-child { border-bottom: none; }
.legend-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-value { color: var(--text-sec); font-family: 'IBM Plex Mono', monospace; font-size: 11px; white-space: nowrap; }
.legend-percent { color: var(--text); font-weight: 600; font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; text-align: right; }

.dash-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}

.table-panel { overflow-x: auto; }
.table-title { font-size: 13.5px; font-weight: 700; color: var(--text); margin-bottom: 14px; }

.dash-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dash-table th, .dash-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dash-table th {
  color: var(--text-sec);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  user-select: none;
}
.dash-table th.num, .dash-table td.num { text-align: right; }
.dash-table th[data-key]:hover { color: var(--text); }
.dash-table th.sorted-asc::after { content: ' \2191'; color: var(--gold); }
.dash-table th.sorted-desc::after { content: ' \2193'; color: var(--gold); }
.dash-table tbody tr:hover { background: var(--surface-2); }
.dash-table td span.dash-swatch { margin-right: 8px; vertical-align: middle; }

.dash-loading { color: var(--text-muted); font-size: 12.5px; padding: 12px 4px; }

.cta-section .cta-grid {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 860px) {
  .dash-grid-2 { grid-template-columns: 1fr; }
  .donut-box, .legend-card { height: 300px; }
  .chart-box-tall, .stacked-box { height: 300px; }
  .stats-strip { grid-template-columns: repeat(2, 1fr) !important; }
  .stat-item { border-right: none !important; border-bottom: 1px solid var(--border); }
  .cta-section .cta-grid { grid-template-columns: 1fr; }
}
