:root {
  --fp-primary: #4f46e5;
  --fp-primary-dark: #4338ca;
  --fp-primary-light: #eef2ff;
  --fp-due: #d97706;
  --fp-due-bg: #fffbeb;
  --fp-paid: #059669;
  --fp-paid-bg: #ecfdf5;
  --fp-bus: #0891b2;
  --fp-bus-bg: #ecfeff;
  --fp-special: #a21caf;
  --fp-special-bg: #fdf4ff;
  --fp-ink: #0f172a;
  --fp-muted: #64748b;
  --fp-border: #e5e7eb;
  --fp-surface: #ffffff;
  --fp-bg: #f1f3f9;
}

body {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(180deg, #eef1fb 0%, #f1f3f9 320px);
  color: var(--fp-ink);
}

.fp-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.25rem 1.25rem 7rem;
}

/* Header */
.fp-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.fp-header-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--fp-primary), #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.5);
}

.fp-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.fp-header-sub {
  margin: 0.15rem 0 0;
  color: var(--fp-muted);
  font-size: 0.9rem;
}

/* Loading / error state */
.fp-state {
  background: var(--fp-surface);
  border: 1px solid var(--fp-border);
  border-radius: 16px;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--fp-muted);
}

.fp-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 1rem;
  border: 3px solid var(--fp-primary-light);
  border-top-color: var(--fp-primary);
  border-radius: 50%;
  animation: fp-spin 0.8s linear infinite;
}

@keyframes fp-spin {
  to { transform: rotate(360deg); }
}

.fp-state-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
}

@keyframes fp-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.fp-notice {
  animation: fp-fade-in 0.4s ease-out;
}

.fp-notice-icon-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 1.1rem;
}

.fp-notice-icon-wrap::before,
.fp-notice-icon-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--fp-primary-light);
  animation: fp-ping 2.4s ease-out infinite;
}

.fp-notice-icon-wrap::after {
  animation-delay: 1.2s;
}

@keyframes fp-ping {
  0% { transform: scale(0.85); opacity: 0.8; }
  100% { transform: scale(1.7); opacity: 0; }
}

.fp-notice-icon {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fp-primary), #7c3aed);
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  animation: fp-float 2.6s ease-in-out infinite;
}

@keyframes fp-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.fp-notice-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fp-ink);
  margin: 0 0 0.4rem;
}

/* Stats bar */
.fp-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.fp-stat {
  background: var(--fp-surface);
  border: 1px solid var(--fp-border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.fp-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fp-muted);
  font-weight: 600;
}

.fp-stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}

.fp-stat-due { color: var(--fp-due); }
.fp-stat-paid { color: var(--fp-paid); }

/* Tabs */
.fp-tabs {
  display: inline-flex;
  background: #e5e7f0;
  border-radius: 999px;
  padding: 0.25rem;
  margin-bottom: 1.5rem;
  gap: 0.25rem;
}

.fp-tab {
  border: none;
  background: transparent;
  padding: 0.5rem 1.25rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--fp-muted);
  cursor: pointer;
  margin: 0;
  transition: background 0.15s, color 0.15s;
}

.fp-tab:hover {
  background: rgba(255, 255, 255, 0.6);
}

.fp-tab.active {
  background: var(--fp-surface);
  color: var(--fp-ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.fp-view.hidden {
  display: none;
}

/* Groups */
.fp-group {
  margin-bottom: 1.75rem;
}

.fp-group.hidden {
  display: none;
}

.fp-group-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--fp-ink);
}

.fp-group-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.fp-icon-regular { background: var(--fp-primary-light); }
.fp-icon-bus { background: var(--fp-bus-bg); }
.fp-icon-special { background: var(--fp-special-bg); }

.fp-cards {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

/* Fee card */
.fp-card {
  background: var(--fp-surface);
  border: 1px solid var(--fp-border);
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.fp-card:hover {
  box-shadow: 0 4px 16px -6px rgba(15, 23, 42, 0.12);
  border-color: #d6d9e6;
}

.fp-card.selected {
  border-color: var(--fp-primary);
  box-shadow: 0 0 0 3px var(--fp-primary-light);
}

.fp-card-main {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
}

.fp-checkbox {
  position: relative;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
}

.fp-checkbox input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.fp-checkbox-box {
  position: absolute;
  inset: 0;
  border: 2px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fp-checkbox input:checked + .fp-checkbox-box {
  background: var(--fp-primary);
  border-color: var(--fp-primary);
}

.fp-checkbox-box::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.12s;
  margin-top: -2px;
}

.fp-checkbox input:checked + .fp-checkbox-box::after {
  transform: rotate(45deg) scale(1);
}

.fp-lock-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  opacity: 0.55;
}

.fp-card.locked {
  background: #fafafa;
}

.fp-card.locked .fp-card-title {
  color: var(--fp-muted);
}

.fp-card-info {
  flex: 1;
  min-width: 0;
}

.fp-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--fp-ink);
}

.fp-card-sub {
  font-size: 0.78rem;
  color: var(--fp-muted);
  margin-top: 0.1rem;
}

.fp-card-sub .fp-late {
  color: var(--fp-due);
  font-weight: 600;
}

.fp-card-amount {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.fp-amount-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}

.fp-amount-value {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

.fp-amount-breakdown {
  font-size: 0.7rem;
  color: var(--fp-due);
  white-space: nowrap;
}

.fp-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.fp-badge.due { background: var(--fp-due-bg); color: var(--fp-due); }
.fp-badge.paid { background: var(--fp-paid-bg); color: var(--fp-paid); }
.fp-badge.locked { background: #f1f5f9; color: var(--fp-muted); }

.fp-expand-btn {
  background: none;
  border: none;
  margin: 0;
  padding: 0.3rem;
  cursor: pointer;
  color: var(--fp-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: transform 0.2s, background 0.15s;
}

.fp-expand-btn:hover {
  background: #f3f4f6;
}

.fp-expand-btn.open {
  transform: rotate(180deg);
}

.fp-card-details {
  border-top: 1px solid var(--fp-border);
  background: #fafbfc;
  padding: 0.75rem 1rem 0.9rem;
}

.fp-card-details.hidden {
  display: none;
}

.fp-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  font-size: 0.83rem;
  color: var(--fp-muted);
  border-bottom: 1px dashed #e5e7eb;
}

.fp-detail-row:last-child {
  border-bottom: none;
}

.fp-detail-row span:first-child {
  color: var(--fp-ink);
}

.fp-detail-row.fp-detail-late {
  color: var(--fp-due);
  font-weight: 600;
}

.fp-detail-row.fp-detail-late span:first-child {
  color: var(--fp-due);
}

/* Empty state */
.fp-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--fp-muted);
}

.fp-empty.hidden {
  display: none;
}

.fp-empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: var(--fp-paid-bg);
  color: var(--fp-paid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 800;
}

/* Sticky pay bar */
.fp-pay-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--fp-surface);
  border-top: 1px solid var(--fp-border);
  box-shadow: 0 -8px 24px -8px rgba(15, 23, 42, 0.12);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 760px;
  margin: 0 auto;
}

.fp-pay-bar.hidden {
  display: none;
}

.fp-pay-bar-total {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.fp-pay-bar-total span {
  font-size: 0.75rem;
  color: var(--fp-muted);
  font-weight: 600;
}

.fp-pay-bar-total strong {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--fp-ink);
}

.fp-pay-bar-total small {
  font-size: 0.72rem;
  color: var(--fp-due);
  font-weight: 600;
}

.fp-pay-bar-total small.hidden {
  display: none;
}

.fp-pay-bar button {
  margin: 0;
  padding: 0.75rem 1.75rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  background: linear-gradient(135deg, var(--fp-primary), #7c3aed);
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, 0.55);
}

.fp-pay-bar button:disabled {
  background: #cbd5e1;
  box-shadow: none;
  cursor: not-allowed;
}

.fp-pay-bar button:not(:disabled):hover {
  background: linear-gradient(135deg, var(--fp-primary-dark), #6d28d9);
}

/* Payment summary modal */
.fp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  animation: fp-fade-in 0.15s ease-out;
}

.fp-modal-overlay.hidden {
  display: none;
}

.fp-modal {
  background: var(--fp-surface);
  border-radius: 18px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.4);
}

.fp-modal h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--fp-ink);
}

.fp-summary-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
}

.fp-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--fp-border);
}

.fp-summary-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.fp-summary-row-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--fp-ink);
}

.fp-summary-row-sub {
  font-size: 0.75rem;
  color: var(--fp-due);
  margin-top: 0.15rem;
}

.fp-summary-row-amount {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

.fp-summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
  margin-bottom: 0.75rem;
  border-top: 2px solid var(--fp-border);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--fp-ink);
}

.fp-terms-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--fp-muted);
  cursor: pointer;
}

.fp-terms-check input {
  margin-top: 0.2rem;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.fp-terms-check a {
  color: var(--fp-primary);
  font-weight: 600;
  text-decoration: none;
}

.fp-terms-check a:hover {
  text-decoration: underline;
}

.fp-modal-actions {
  display: flex;
  gap: 0.75rem;
}

.fp-modal-actions button {
  flex: 1;
  margin: 0;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
}

.fp-btn-secondary {
  background: #f1f5f9;
  color: var(--fp-ink);
  box-shadow: none;
}

.fp-btn-secondary:hover {
  background: #e2e8f0;
}

#summary-confirm-btn {
  background: linear-gradient(135deg, var(--fp-primary), #7c3aed);
  color: #fff;
}

#summary-confirm-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

#summary-confirm-btn:not(:disabled):hover {
  background: linear-gradient(135deg, var(--fp-primary-dark), #6d28d9);
}

/* Reference number modal */
.fp-ref-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  background: var(--fp-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

#reference-modal h2 {
  text-align: center;
}

.fp-ref-note {
  font-size: 0.85rem;
  color: var(--fp-muted);
  text-align: center;
  margin: 0 0 1.1rem;
  line-height: 1.5;
}

.fp-ref-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--fp-primary-light);
  border: 1px dashed var(--fp-primary);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.5rem;
}

#reference-number {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--fp-ink);
  word-break: break-all;
}

#copy-ref-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--fp-primary);
  color: #fff;
}

#copy-ref-btn:hover {
  background: var(--fp-primary-dark);
}

.fp-copy-msg {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fp-paid);
  margin-bottom: 0.75rem;
}

.fp-copy-msg.hidden {
  display: none;
}

#reference-continue-btn {
  width: 100%;
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  background: linear-gradient(135deg, var(--fp-primary), #7c3aed);
  color: #fff;
}

#reference-continue-btn:hover {
  background: linear-gradient(135deg, var(--fp-primary-dark), #6d28d9);
}

/* Payment result page */
.fp-page-narrow {
  max-width: 480px;
}

.fp-result-card {
  background: var(--fp-surface);
  border: 1px solid var(--fp-border);
  border-radius: 20px;
  padding: 2.5rem 1.75rem 2rem;
  text-align: center;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  animation: fp-fade-in 0.3s ease-out;
}

.fp-result-icon-wrap {
  width: 76px;
  height: 76px;
  margin: 0 auto 1.25rem;
}

.fp-result-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
}

.fp-spinner-inline {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(79, 70, 229, 0.25);
  border-top-color: var(--fp-primary);
  border-radius: 50%;
  animation: fp-spin 0.8s linear infinite;
}

.fp-result-loading .fp-result-icon {
  background: var(--fp-primary-light);
}

.fp-result-success .fp-result-icon {
  background: linear-gradient(135deg, var(--fp-paid), #10b981);
  box-shadow: 0 10px 24px -8px rgba(5, 150, 105, 0.5);
  animation: fp-pop 0.35s ease-out;
}

.fp-result-error .fp-result-icon {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 10px 24px -8px rgba(220, 38, 38, 0.45);
  animation: fp-pop 0.35s ease-out;
}

@keyframes fp-pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.fp-result-title {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0 0 0.4rem;
  color: var(--fp-ink);
}

.fp-result-subtitle {
  font-size: 0.9rem;
  color: var(--fp-muted);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.fp-result-details {
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--fp-border);
  border-radius: 14px;
  padding: 0.25rem 1.1rem;
}

.fp-result-details.hidden {
  display: none;
}

.fp-result-details .fp-detail-row {
  font-size: 0.9rem;
  padding: 0.65rem 0;
  align-items: center;
}

.fp-detail-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.fp-detail-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--fp-muted);
}

.fp-detail-value-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.fp-detail-value {
  font-weight: 700;
  color: var(--fp-ink);
}

.fp-copy-btn {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  color: var(--fp-primary);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.fp-copy-btn:hover {
  color: var(--fp-primary-dark);
  text-decoration: underline;
}

.fp-print-btn {
  border: none;
  background: var(--fp-primary);
  color: #fff;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.fp-print-btn:hover {
  background: var(--fp-primary-dark);
}

.fp-receipt-group {
  margin-top: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.fp-receipt-group-title {
  padding-bottom: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--fp-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Reason banner (failed payments only) */
.fp-result-reason {
  text-align: left;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  color: #991b1b;
  line-height: 1.5;
}

.fp-result-reason.hidden {
  display: none;
}

.fp-result-reason strong {
  font-weight: 700;
}

/* Hero amount */
.fp-result-hero {
  padding: 0.15rem 0 1.1rem;
}

.fp-result-hero.hidden {
  display: none;
}

.fp-result-hero-label {
  font-size: 0.8rem;
  color: var(--fp-muted);
  margin-bottom: 0.2rem;
}

.fp-result-hero-amount {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--fp-ink);
  letter-spacing: -0.01em;
}

.fp-result-back {
  display: block;
  width: 100%;
  margin: 1.5rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  background: linear-gradient(135deg, var(--fp-primary), #7c3aed);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, 0.55);
}

.fp-result-back:hover {
  background: linear-gradient(135deg, var(--fp-primary-dark), #6d28d9);
}

@media (max-width: 560px) {
  .fp-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }
  .fp-stat {
    padding: 0.6rem 0.5rem;
  }
  .fp-stat-label {
    font-size: 0.62rem;
  }
  .fp-stat-value {
    font-size: 0.8rem;
  }
  .fp-card-main {
    flex-wrap: wrap;
  }
  .fp-amount-value {
    font-size: 0.9rem;
  }
}
