/* ========== Kalkulator Progressive Interest – layout dua lajur & komponen ========== */
/* Rujukan: tasks/task-progressive-interest.mdc */

:root {
  --pi-primary: #2C3E7C;
  --pi-bg: #F8F9FA;
  --pi-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --pi-radius: 10px;
}

/* Main: dua lajur – kiri form, kanan keputusan */
.pi-main {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}
@media (min-width: 1024px) {
  .pi-main {
    grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.2fr);
    gap: 2rem;
  }
}

.pi-col-left,
.pi-col-right {
  min-width: 0;
}

.pi-card {
  background: #fff;
  border-radius: var(--pi-radius);
  box-shadow: var(--pi-card-shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.pi-card:last-child {
  margin-bottom: 0;
}

.pi-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pi-card-header .pi-card-title {
  margin: 0;
  flex: 0 0 auto;
}

.pi-card-header .info-icon-wrap {
  flex-shrink: 0;
}

.pi-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-sans);
}
@media (min-width: 768px) {
  .pi-card-title { font-size: 1.5rem; }
}

/* Form */
.pi-form-group {
  margin-bottom: 1.25rem;
}
@media (min-width: 768px) {
  .pi-form-group { margin-bottom: 1.5rem; }
}

.pi-form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  font-family: var(--font-sans);
}

.pi-input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  box-sizing: border-box;
}
.pi-input:focus {
  outline: 2px solid var(--pi-primary);
  outline-offset: 0;
  background: #fff;
}
.pi-input:disabled {
  background: #e5e7eb;
  color: #6b7280;
  cursor: not-allowed;
}

/* Mod Pengiraan: Anggaran | Tracker tabs */
.pi-mod-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.25rem;
  background: #f1f5f9;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}
.pi-mod-tab {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  font-family: inherit;
}
.pi-mod-tab:hover {
  color: #334155;
}
.pi-mod-tab.active {
  background: #fff;
  color: var(--pi-primary);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.pi-mod-tab-help {
  font-size: 0.75rem;
  font-style: italic;
  color: #94a3b8;
  margin: 0 0 1rem 0;
  line-height: 1.4;
}
.pi-mod-panel {
  margin-top: 0;
}

/* Tracker panel */
.pi-tracker-header {
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  margin: 0 0 0.75rem 0;
}
.pi-tracker-help {
  font-size: 0.75rem;
  font-style: italic;
  color: #94a3b8;
  margin: 0 0 1rem 0;
}
.pi-tracker-list {
  margin-bottom: 0.5rem;
}
.pi-tracker-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.2s;
}
.pi-tracker-row:last-child {
  border-bottom: 0;
}
.pi-tracker-row.ticked {
  background: rgba(34, 197, 94, 0.08);
}
.pi-tracker-row.ticked .pi-tracker-title-wrap {
  text-decoration: line-through;
  color: #94a3b8;
}
.pi-tracker-row .pi-tracker-cb {
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.125rem;
  flex-shrink: 0;
  accent-color: #16a34a;
  cursor: pointer;
}
.pi-tracker-row .pi-tracker-label {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
.pi-tracker-row .pi-tracker-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.125rem;
}
.pi-tracker-row .pi-tracker-stage-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
}
.pi-tracker-row .pi-tracker-desc {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.4;
  margin: 0;
}
.pi-tracker-done-badge {
  display: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: #16a34a;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  flex-shrink: 0;
  margin-top: 0.125rem;
}
.pi-tracker-row.ticked .pi-tracker-done-badge {
  display: block;
}
.pi-tracker-summary {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
}
.pi-tracker-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.pi-tracker-summary-row:last-child {
  margin-bottom: 0;
}
.pi-tracker-summary-label {
  font-size: 0.75rem;
  color: #64748b;
}
.pi-tracker-summary-value {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--pi-primary);
}
.pi-tracker-paid {
  color: #16a34a;
}
.pi-tracker-note {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 0.5rem;
}
.pi-tracker-note p {
  font-size: 0.75rem;
  color: #b45309;
  line-height: 1.5;
  margin: 0;
}

/* Stage selector: grid (desktop) + slider (mobile) */
.pi-stage-help {
  font-size: 0.75rem;
  font-style: italic;
  color: #94a3b8;
  margin: 0 0 0.75rem 0;
  line-height: 1.4;
}
.pi-peringkat-select {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.9375rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%236b7280'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  font-family: inherit;
}
.pi-peringkat-select:hover {
  border-color: #d1d5db;
}
.pi-peringkat-select:focus {
  outline: none;
  border-color: var(--pi-primary);
  box-shadow: 0 0 0 2px rgba(44, 62, 124, 0.2);
  background-color: #fff;
}
@media (max-width: 480px) {
  .pi-peringkat-select {
    min-height: 48px;
    font-size: 1rem;
  }
}
.pi-stage-grid {
  display: none;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
@media (min-width: 640px) {
  .pi-stage-grid { display: grid; }
}
.pi-stage-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  text-align: center;
  font-family: inherit;
}
.pi-stage-btn:hover {
  border-color: var(--pi-primary);
  background: rgba(44, 62, 124, 0.05);
}
.pi-stage-btn-active {
  border-width: 2px;
  border-color: var(--pi-primary);
  background: rgba(44, 62, 124, 0.1);
}
.pi-stage-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--pi-primary);
  background: rgba(44, 62, 124, 0.1);
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
}
.pi-stage-short {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  margin-top: 0.25rem;
}
.pi-stage-slider-wrap {
  margin-bottom: 0.5rem;
}
@media (min-width: 640px) {
  .pi-stage-slider-wrap { display: none; }
}
.pi-stage-slider {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 0.75rem;
  margin: 0 -0.25rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  scrollbar-width: none;
}
.pi-stage-slider::-webkit-scrollbar {
  display: none;
}
.pi-stage-card {
  flex: 0 0 auto;
  width: 7rem;
  scroll-snap-align: start;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  font-family: inherit;
}
.pi-stage-card:hover {
  border-color: var(--pi-primary);
  background: rgba(44, 62, 124, 0.05);
}
.pi-stage-card-active {
  border-width: 2px;
  border-color: var(--pi-primary);
  background: rgba(44, 62, 124, 0.1);
}
.pi-stage-card .pi-stage-badge { font-size: 0.75rem; }
.pi-stage-card .pi-stage-short { font-size: 0.8125rem; margin-top: 0.25rem; }
.pi-stage-dots {
  display: flex;
  gap: 0.375rem;
  justify-content: center;
  margin-top: 0.5rem;
}
.pi-stage-dot {
  height: 6px;
  width: 6px;
  border-radius: 9999px;
  background: #cbd5e1;
  transition: width 0.2s, background-color 0.2s;
}
.pi-stage-dot.active {
  width: 16px;
  background: var(--pi-primary);
}
.pi-stage-desc {
  background: rgba(44, 62, 124, 0.05);
  border: 1px solid rgba(44, 62, 124, 0.2);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-top: 0.75rem;
}
.pi-stage-desc-code {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--pi-primary);
}
.pi-stage-desc-full {
  font-size: 0.875rem;
  color: #475569;
  margin: 0.25rem 0 0 0;
  line-height: 1.45;
}
.pi-stage-desc-info {
  font-size: 0.75rem;
  font-style: italic;
  color: #94a3b8;
  margin: 0.25rem 0 0 0;
}
.pi-stage-note {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.pi-stage-note span {
  flex-shrink: 0;
  color: #b45309;
  font-size: 1rem;
}
.pi-stage-note p {
  font-size: 0.75rem;
  color: #b45309;
  line-height: 1.5;
  margin: 0;
}

/* Bila jangkaan siap — kemas & device-friendly */
.pi-jangkaan-wrap {
  margin-bottom: 0;
}
.pi-jangkaan-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  font-family: var(--font-sans);
}
.pi-jangkaan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.pi-jangkaan-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.pi-jangkaan-sublabel {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  font-family: var(--font-sans);
}
.pi-jangkaan-select {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.9375rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%236b7280'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.pi-jangkaan-select:hover {
  border-color: #d1d5db;
}
.pi-jangkaan-select:focus {
  outline: none;
  border-color: var(--pi-primary);
  box-shadow: 0 0 0 2px rgba(19, 127, 236, 0.2);
  background-color: #fff;
}
.pi-tempoh-info {
  font-size: 0.75rem;
  font-weight: 500;
  color: #137fec;
  margin: 0.5rem 0 1.25rem 0;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(19, 127, 236, 0.08);
  border-radius: 6px;
  border-left: 3px solid #137fec;
  font-family: var(--font-sans);
  line-height: 1.4;
}
.pi-jangkaan-wrap .pi-tempoh-info {
  margin-bottom: 2rem; /* nafas antara tempoh pembinaan dan tab Anggaran/Tracker */
}
@media (min-width: 768px) {
  .pi-jangkaan-grid {
    gap: 1rem;
  }
  .pi-jangkaan-select {
    min-height: 44px;
    padding: 0.625rem 2.25rem 0.625rem 0.75rem;
  }
}
@media (max-width: 480px) {
  .pi-jangkaan-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .pi-jangkaan-select {
    min-height: 48px;
    font-size: 1rem;
  }
}
.pi-toggle-option:focus {
  outline: 2px solid var(--pi-primary);
  outline-offset: 2px;
}
.pi-input,
.pi-toggle-option,
.pi-btn-kira {
  border-radius: 8px;
}

/* Checkbox 0% Downpayment Upon Signing */
.pi-zero-down-wrap {
  margin-top: 0.75rem;
}
.pi-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-family: var(--font-sans);
}
.pi-custom-checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 2px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  background: #fff;
  vertical-align: middle;
}
.pi-custom-checkbox:checked {
  background-color: #137fec;
  border-color: #137fec;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13.707 4.293a1 1 0 0 1 0 1.414l-6 6a1 1 0 0 1-1.414 0l-3-3a1 1 0 1 1 1.414-1.414L7 9.586l5.293-5.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E");
  background-size: contain;
}
.pi-checkbox-text {
  font-size: 0.9375rem;
  font-weight: 500;
  color: #334155;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
}
.pi-pinjaman-tooltip {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  font-style: italic;
  color: #64748b;
  font-family: var(--font-sans);
}
.pi-input-hint {
  color: #94a3b8 !important;
  font-style: italic;
}
.pi-field-hint {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  font-style: italic;
  color: #94a3b8;
  font-family: var(--font-sans);
}
.pi-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.pi-toast.pi-toast-visible {
  opacity: 1;
}

/* Toggle Jadual H / Jadual G */
.pi-toggle-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pi-toggle-option {
  flex: 1;
  min-width: 120px;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #374151;
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.pi-toggle-option:hover {
  background: #e5e7eb;
}
.pi-toggle-option[aria-pressed="true"],
.pi-toggle-option.active {
  background: var(--pi-primary);
  border-color: var(--pi-primary);
  color: #fff;
}

/* Butang Kira Semula */
.pi-btn-kira {
  width: 100%;
  padding: 0.875rem 1.5rem;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #fff;
  background: var(--pi-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
@media (min-width: 768px) {
  .pi-btn-kira { min-height: 44px; }
}
.pi-btn-kira:hover {
  background: #243366;
}
.pi-btn-kira:focus {
  outline: 2px solid var(--pi-primary);
  outline-offset: 2px;
}

/* Wrap dua butang: Kira Progresif Interest + Set Semula */
.pi-buttons-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Butang Set Semula (merah) — saiz/padding/rounding sama seperti pi-btn-kira */
.pi-btn-reset {
  width: 100%;
  padding: 0.875rem 1.5rem;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: #fff;
  background: #dc2626;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
@media (min-width: 768px) {
  .pi-btn-reset { min-height: 44px; }
}
.pi-btn-reset:hover {
  background: #b91c1c;
}
.pi-btn-reset:focus {
  outline: 2px solid #dc2626;
  outline-offset: 2px;
}

/* Kotak info Tahukah Anda / Info Pantas */
.pi-info-box {
  background: #eef2ff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.9375rem;
  color: #374151;
  font-family: var(--font-sans);
  line-height: 1.5;
}
.pi-info-box-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: var(--pi-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
}

/* Kad ringkasan kanan */
.pi-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
  .pi-summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pi-summary-card {
  background: #fff;
  border-radius: var(--pi-radius);
  box-shadow: var(--pi-card-shadow);
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pi-summary-value-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
}

/* Highlight animation selepas scroll ke results (biru primary #137fec, sekali 1.5s) */
@keyframes highlightCard {
  0%   { box-shadow: 0 0 0 0 rgba(19, 127, 236, 0.4); }
  50%  { box-shadow: 0 0 0 12px rgba(19, 127, 236, 0.2); }
  100% { box-shadow: 0 0 0 0 rgba(19, 127, 236, 0); }
}
.card-highlight {
  animation: highlightCard 1.5s ease forwards;
}

.pi-summary-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #6b7280;
  font-family: var(--font-sans);
  display: block;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pi-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--pi-primary);
  font-family: var(--font-sans);
  display: block;
  margin-bottom: 0.25rem;
}
.pi-summary-value-wrap .pi-summary-value {
  margin-bottom: 0;
}
@media (min-width: 768px) {
  .pi-summary-value { font-size: 1.75rem; }
}
.pi-summary-label {
  font-size: 0.8125rem;
  color: #6b7280;
  font-family: var(--font-sans);
}

/* ========== Graf: Bar Chart – Ramalan Bayaran Bulanan ========== */
/* Label nombor atas bar (tiada RM, tiada perpuluhan); hover bar + tooltip; responsif 320px+ */

:root {
  --pi-chart-blue: #137fec;
  --pi-chart-blue-hover: #0a5abf;
  --pi-chart-faedah: #1E6FD9;
  --pi-chart-principal: #A8C8F0;
}

.pi-chart-section {
  background: #fff;
  border-radius: var(--pi-radius);
  box-shadow: var(--pi-card-shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.pi-chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.pi-chart-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #374151;
  margin: 0;
  font-family: var(--font-sans);
}

.pi-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8125rem;
  color: #6b7280;
  font-family: var(--font-sans);
}

.pi-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pi-chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pi-chart-dot-progressive { background: var(--pi-chart-blue); }
.pi-chart-dot-principal { background: #A8C8F0; }

.pi-chart-area {
  min-height: 260px;
  overflow-x: auto;
  padding: 1.75rem 0 0.5rem 0;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.pi-stacked-chart {
  position: relative;
  font-family: var(--font-sans);
}

/* Bar row: ref line at top, badge, then bars */
.pi-chart-bars-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 4px;
  height: 180px;
  padding: 0 0.25rem;
  min-width: min-content;
}

.pi-chart-ref-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  border-top: 2px dashed var(--pi-chart-blue);
  pointer-events: none;
}

.pi-chart-ref-badge {
  position: absolute;
  right: 0;
  top: 0;
  transform: translateY(-50%);
  font-size: clamp(0.65rem, 1.5vw, 0.75rem);
  font-weight: 600;
  color: var(--pi-chart-blue);
  background: #fff;
  border: 1px solid var(--pi-chart-blue);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
  font-family: var(--font-sans);
}

/* Each bar cell: value label above, bar, tooltip on hover, STG below */
.pi-bar-cell {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  position: relative;
  cursor: pointer;
}

.pi-bar-cell:focus {
  outline: none;
}

.pi-bar-cell:focus-visible {
  outline: 2px solid var(--pi-chart-blue);
  outline-offset: 2px;
}

.pi-bar-value-label {
  font-size: clamp(0.6rem, 1.8vw, 0.7rem);
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  order: -1;
  margin-bottom: 0.2rem;
  font-family: var(--font-sans);
  text-align: center;
}

.pi-bar-track {
  width: 100%;
  max-width: 36px;
  height: 180px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 20px;
}

.pi-bar-animate {
  width: 100%;
  background: var(--pi-chart-blue);
  border-radius: 4px 4px 0 0;
  transition: height 0.4s ease-out, background-color 0.2s ease;
}

.pi-bar-cell:hover .pi-bar-animate,
.pi-bar-cell:focus-within .pi-bar-animate {
  background: var(--pi-chart-blue-hover);
}
.pi-bar-tracker-done {
  background: #16a34a;
}
.pi-bar-cell:hover .pi-bar-tracker-done,
.pi-bar-cell:focus-within .pi-bar-tracker-done {
  background: #15803d;
}

.pi-bar-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 0.5rem 0.65rem;
  max-width: min(240px, 88vw);
  font-size: 0.7rem;
  line-height: 1.4;
  color: #1f2937;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  white-space: normal;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.15s ease, opacity 0.15s ease;
  z-index: 100;
  pointer-events: none;
  text-align: left;
  font-family: var(--font-sans);
}
.pi-bar-tooltip-title {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.72rem;
}
.pi-bar-tooltip-body {
  margin-top: 0.2rem;
}
.pi-bar-tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
}
.pi-bar-tooltip-label {
  color: #6b7280;
  flex-shrink: 0;
}
.pi-bar-tooltip-value {
  font-weight: 600;
  color: #1f2937;
  text-align: right;
}
.pi-bar-tooltip-tip {
  margin-top: 0.35rem;
  padding-top: 0.3rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.65rem;
  color: #6b7280;
}
.pi-bar-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
}

.pi-bar-cell:hover .pi-bar-tooltip,
.pi-bar-cell:focus-within .pi-bar-tooltip,
.pi-bar-cell.pi-bar-tooltip-visible .pi-bar-tooltip {
  visibility: visible;
  opacity: 1;
}

.pi-bar-x-label {
  font-size: clamp(0.55rem, 1.5vw, 0.7rem);
  color: #6b7280;
  text-align: center;
  white-space: nowrap;
  font-family: var(--font-sans);
}

/* Responsive: tighter bars on small screens */
@media (max-width: 767px) {
  .pi-chart-bars-row {
    gap: 2px;
    padding: 0 0.125rem;
  }
  .pi-bar-track {
    max-width: 24px;
  }
}

@media (min-width: 1024px) {
  .pi-bar-track {
    max-width: 40px;
  }
}

.pi-chart-empty {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 0.9375rem;
  font-family: var(--font-sans);
}

/* Jadual Drawdown */
.pi-table-section {
  background: #fff;
  border-radius: var(--pi-radius);
  box-shadow: var(--pi-card-shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.pi-table-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #374151;
  margin: 0 0 0.5rem;
  font-family: var(--font-sans);
}
.pi-table-subtitle {
  font-size: 0.8125rem;
  color: #6b7280;
  margin-bottom: 1rem;
  font-family: var(--font-sans);
}
.pi-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.pi-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-family: var(--font-sans);
}
.pi-table th,
.pi-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}
.pi-table th {
  font-weight: 600;
  color: #374151;
  background: #f9fafb;
}
.pi-table td {
  color: #374151;
}
.pi-table tr:last-child td {
  border-bottom: none;
}
.pi-table .pi-table-num {
  text-align: right;
  white-space: nowrap;
}
.pi-peringkat-cell {
  vertical-align: top;
}
.pi-peringkat-num {
  display: inline-block;
  font-weight: 700;
  color: #137fec;
  margin-right: 0.35rem;
  font-family: var(--font-sans);
}

/* Mobile: kad drawdown (gantikan jadual) */
.pi-drawdown-cards {
  display: none;
}
@media (max-width: 767px) {
  .pi-table-wrapper {
    display: none;
  }
  .pi-drawdown-cards {
    display: block;
  }
  .pi-drawdown-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    font-family: var(--font-sans);
  }
  .pi-drawdown-card:last-child {
    margin-bottom: 0;
  }
  .pi-drawdown-card-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--pi-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #e2e8f0;
  }
  .pi-drawdown-card-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.8125rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid #f1f5f9;
  }
  .pi-drawdown-card-row:last-child {
    border-bottom: none;
  }
  .pi-drawdown-card-label {
    color: #64748b;
    flex-shrink: 0;
    min-width: 8rem;
  }
  .pi-drawdown-card-value {
    color: #334155;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
  }
  .pi-drawdown-card-faedah {
    color: #137fec;
    font-weight: 600;
  }
  .pi-drawdown-card-faedah .pi-faedah-badge {
    display: block;
    margin-top: 0.25rem;
    font-weight: 400;
  }
}
@media (min-width: 768px) {
  .pi-drawdown-cards {
    display: none !important;
  }
}

/* Kolum Bayaran Faedah (Est) — cascade animation selepas graf */
.pi-faedah-cell {
  opacity: 0;
}
@keyframes boldIn {
  0%   { opacity: 0; transform: scale(0.7); font-weight: 400; color: inherit; }
  60%  { opacity: 1; transform: scale(1.1); font-weight: 700; color: #137fec; }
  100% { opacity: 1; transform: scale(1); font-weight: 700; color: #137fec; }
}
.faedah-animate {
  animation: boldIn 0.4s ease forwards;
}
.pi-faedah-badge {
  font-size: 0.75rem;
  font-style: italic;
  color: #94a3b8;
  font-weight: 400;
}
.pi-faedah-badge-vp {
  color: #94a3b8;
}
.pi-faedah-badge-siap {
  color: #16a34a;
  font-weight: 700;
  font-style: normal;
}
.pi-faedah-zero {
  font-size: 0.875rem;
  color: #94a3b8;
  font-weight: 500;
}
.pi-faedah-value {
  font-weight: 700;
  color: #137fec;
  font-family: var(--font-sans);
}

/* Bahagian bantuan pakar */
.pi-help-card {
  background: var(--pi-primary);
  color: #fff;
  border-radius: var(--pi-radius);
  padding: 1.5rem;
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.pi-help-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  font-family: var(--font-sans);
}
.pi-help-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.pi-help-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--pi-primary);
  background: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}
.pi-help-btn:hover {
  opacity: 0.9;
}
.pi-help-btn:focus {
  outline: 2px solid var(--pi-primary);
  outline-offset: 2px;
}

/* Footer – logo, Pautan Pantas, Hubungi Kami */
.pi-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.875rem;
  color: #6b7280;
  font-family: var(--font-sans);
}
.pi-footer-inner {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
  .pi-footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}
@media (min-width: 900px) {
  .pi-footer-inner {
    grid-template-columns: 2fr 1fr 1fr;
  }
}
.pi-footer-brand { min-width: 0; }
.pi-footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #374151;
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.pi-footer-logo img { display: block; }
.pi-footer-logo-light { font-weight: 300; }
.pi-footer-logo-bold { font-weight: 700; }
.pi-footer-desc {
  margin: 0;
  font-size: 0.8125rem;
  color: #6b7280;
  line-height: 1.4;
}
.pi-footer-heading {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pi-footer-links ul,
.pi-footer-contact p {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
}
.pi-footer-links a,
.pi-footer-contact a {
  color: var(--pi-primary);
  text-decoration: none;
}
.pi-footer-links a:hover,
.pi-footer-contact a:hover { text-decoration: underline; }
.pi-footer-bottom {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}
.pi-footer-bottom p { margin: 0 0 0.35rem; }
