/* =====================================================================
   FEE STRUCTURE MODAL — STYLES
   Uses the same CSS variables defined in css/style.css (--primary-green
   etc.) so it automatically matches the rest of the site's theme.
   ===================================================================== */

body.fm-lock-scroll {
  overflow: hidden;
}

.fm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 20, 10, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
}

.fm-overlay.fm-open {
  opacity: 1;
  visibility: visible;
}

.fm-modal {
  background: #fff;
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.25s ease;
}

.fm-overlay.fm-open .fm-modal {
  transform: translateY(0) scale(1);
}

.fm-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s ease;
}

.fm-close:hover {
  background: rgba(255, 255, 255, 0.32);
}

.fm-header {
  background: linear-gradient(135deg, var(--primary-green), var(--dark-green));
  color: #fff;
  padding: 22px 60px 22px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  flex-shrink: 0;
}

.fm-header-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.fm-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.fm-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.9;
}

.fm-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ---------------- Sidebar (categories) ---------------- */

.fm-sidebar {
  width: 230px;
  flex-shrink: 0;
  background: #f6faf7;
  border-right: 1px solid #e5efe7;
  padding: 16px 10px;
  overflow-y: auto;
}

.fm-cat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  color: #2c3e34;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.18s ease, color 0.18s ease;
}

.fm-cat-btn i {
  width: 18px;
  text-align: center;
  color: var(--primary-green);
  flex-shrink: 0;
}

.fm-cat-btn:hover {
  background: #e9f5ec;
}

.fm-cat-btn.active {
  background: var(--primary-green);
  color: #fff;
}

.fm-cat-btn.active i {
  color: #fff;
}

/* ---------------- Content area ---------------- */

.fm-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.fm-billlist {
  padding: 16px 22px 0;
  flex-shrink: 0;
}

.fm-billlist-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7d72;
  margin-bottom: 10px;
}

.fm-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid #eef3ef;
}

.fm-chip {
  border: 1px solid #d9e8dd;
  background: #fff;
  color: #2c3e34;
  border-radius: 999px;
  font-size: 12.5px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.fm-chip:hover {
  border-color: var(--primary-green);
  color: var(--primary-green);
}

.fm-chip.active {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #fff;
}

.fm-billview {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 26px;
}

.fm-bill-header h3 {
  margin: 0 0 4px;
  font-size: 17px;
  color: #1f3329;
}

.fm-bill-subtitle {
  margin: 0 0 14px;
  font-size: 13px;
  color: #6b7d72;
}

.fm-empty {
  color: #888;
  font-size: 14px;
}

/* ---------------- Table ---------------- */

.fm-table-wrap {
  overflow-x: auto;
  border: 1px solid #e6efe8;
  border-radius: 10px;
}

.fm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 360px;
}

.fm-table thead th {
  background: var(--primary-green);
  color: #fff;
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  white-space: nowrap;
}

.fm-th-amount {
  text-align: right !important;
}

.fm-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #eef3ef;
  color: #2c3e34;
}

.fm-table tbody tr:nth-child(even) {
  background: #fafdfb;
}

.fm-td-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fm-total-row td {
  background: #eaf6ee !important;
  font-weight: 700;
  border-top: 2px solid var(--primary-green);
  color: #1f3329;
}

/* ---------------- Materials checklist ---------------- */

.fm-materials {
  margin-top: 18px;
}

.fm-materials h4,
.fm-notes h4,
.fm-account h4 {
  font-size: 13.5px;
  margin: 0 0 10px;
  color: #1f3329;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fm-materials h4 { margin-top: 4px; }

.fm-materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.fm-material-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: #f6faf7;
  border: 1px solid #e6efe8;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: #2c3e34;
}

.fm-material-item i {
  color: var(--primary-green);
  flex-shrink: 0;
}

.fm-material-item em {
  margin-left: auto;
  font-style: normal;
  color: #6b7d72;
  font-size: 11.5px;
  white-space: nowrap;
}

/* ---------------- Notes ---------------- */

.fm-notes {
  margin-top: 18px;
  background: #fff8e8;
  border: 1px solid #f3e3b0;
  border-radius: 10px;
  padding: 14px 16px;
}

.fm-notes ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.8px;
  color: #5c4a1e;
  line-height: 1.6;
}

/* ---------------- Account box ---------------- */

.fm-account {
  margin-top: 16px;
  background: #f0f9f3;
  border: 1px solid #d6ecdd;
  border-radius: 10px;
  padding: 14px 16px;
}

.fm-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.fm-account-grid div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fm-account-grid span {
  font-size: 11px;
  color: #6b7d72;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fm-account-grid strong {
  font-size: 13.5px;
  color: #1f3329;
}

/* ---------------- Actions ---------------- */

.fm-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.fm-action-btn {
  background: var(--primary-green);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.18s ease;
}

.fm-action-btn:hover {
  background: var(--dark-green);
}

/* ---------------- "School Fees" trigger button ---------------- */

.fm-trigger-btn {
  background: linear-gradient(135deg, var(--primary-green), var(--accent-green));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 26px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(46, 139, 87, 0.25);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.fm-trigger-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(46, 139, 87, 0.3);
}

/* ---------------- Responsive ---------------- */

@media (max-width: 768px) {
  .fm-overlay {
    padding: 0;
  }

  .fm-modal {
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    max-width: 100%;
  }

  .fm-body {
    flex-direction: column;
  }

  .fm-sidebar {
    width: 100%;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid #e5efe7;
    padding: 10px;
    gap: 6px;
  }

  .fm-cat-btn {
    width: auto;
    flex-shrink: 0;
    margin-bottom: 0;
    white-space: nowrap;
  }

  .fm-cat-btn span {
    display: inline;
  }

  .fm-billlist,
  .fm-billview {
    padding-left: 16px;
    padding-right: 16px;
  }

  .fm-header {
    padding: 18px 50px 18px 16px;
  }

  .fm-title {
    font-size: 17px;
  }
}

@media (max-width: 480px) {
  .fm-materials-grid {
    grid-template-columns: 1fr;
  }

  .fm-account-grid {
    grid-template-columns: 1fr;
  }
}