/* =========================================================
   Funded Service Analysis — Modern Dashboard Styles
   Drop this file in /pro/ (or wherever dashboard.css lives)
   and link it AFTER the existing dashboard.css so it can
   override any legacy Bootstrap 4 alpha rules if needed.
   ========================================================= */

:root {
  --fsa-bg: #f5f6f8;
  --fsa-surface: #ffffff;
  --fsa-border: #e5e7eb;
  --fsa-text: #1f2430;
  --fsa-text-muted: #6b7280;
  --fsa-heading: #ab2e46;       /* maroon — page title, section labels, card titles */
  --fsa-accent: #0880b9;        /* blue — active-button only, matches .button1 in navtyp=163a_v3 */
  --fsa-accent-hover: #066a99;
  --fsa-green: #16a34a;         /* go */
  --fsa-amber: #ffc400;         /* caution — true yellow, not orange */
  --fsa-red: #dc2626;           /* stop */
  --fsa-blue: #2563eb;
  --fsa-radius-sm: 6px;
  --fsa-radius-md: 10px;
  --fsa-radius-lg: 14px;
  --fsa-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --fsa-shadow-md: 0 6px 16px rgba(16, 24, 40, 0.10);
  --fsa-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.fsa-page {
  font-family: var(--fsa-font);
  color: var(--fsa-text);
  background: var(--fsa-bg);
  padding: 24px 28px 60px;
  max-width: 1180px;
  margin: 0 auto;
}

/* ---------- Header / toolbar ---------- */
.fsa-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.fsa-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--fsa-heading);
  margin: 0;
}

.fsa-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--fsa-radius-sm);
  border: 1px solid var(--fsa-border);
  background: var(--fsa-surface);
  color: var(--fsa-text);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--fsa-font);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--fsa-shadow-sm);
  transition: background 0.15s ease, transform 0.1s ease;
  line-height: 1;
}
.btn:hover { background: #f3f4f6; text-decoration: none; color: var(--fsa-text); }
.btn:active { transform: translateY(1px); }
.btn i { font-size: 12px; }

.btn.btn-active,
.btn.btn-active:link,
.btn.btn-active:visited,
.btn.btn-active:hover,
.btn.btn-active:focus,
.btn.btn-active:active {
  background: var(--fsa-accent);
  border-color: var(--fsa-accent);
  color: #fff;
}

.fsa-meta {
  font-size: 12px;
  color: var(--fsa-text-muted);
  margin: 0 0 18px;
}

/* ---------- Summary strip (Year / Period / Proportion) ---------- */
.fsa-summary-bar {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  background: var(--fsa-surface);
  border: 1px solid var(--fsa-border);
  border-radius: var(--fsa-radius-md);
  box-shadow: var(--fsa-shadow-sm);
  padding: 14px 20px;
  margin-bottom: 22px;
}

.fsa-summary-item .label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fsa-heading);
  display: block;
  margin-bottom: 2px;
}

.fsa-summary-item .value {
  font-size: 17px;
  font-weight: 700;
  color: var(--fsa-text);
}

/* ---------- Section headers ---------- */
.fsa-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fsa-text-muted);
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--fsa-border);
}

.fsa-empty-state {
  background: var(--fsa-surface);
  border: 1px dashed var(--fsa-border);
  border-radius: var(--fsa-radius-md);
  padding: 24px;
  color: var(--fsa-text-muted);
  font-size: 14px;
}

/* ---------- Metric cards ---------- */
.fsa-card {
  background: var(--fsa-surface);
  border: 1px solid var(--fsa-border);
  border-radius: var(--fsa-radius-lg);
  box-shadow: var(--fsa-shadow-sm);
  padding: 18px 22px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  transition: box-shadow 0.15s ease;
}
.fsa-card:hover { box-shadow: var(--fsa-shadow-md); }

.fsa-card-info { flex: 1 1 280px; min-width: 220px; }
.fsa-card-info h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--fsa-heading);
}
.fsa-card-info p {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--fsa-text-muted);
  line-height: 1.45;
  max-width: 46ch;
}
.fsa-card-info .anticipated {
  font-size: 11px;
  color: var(--fsa-text-muted);
  font-style: italic;
}

.fsa-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fsa-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 10px 14px;
  border-radius: var(--fsa-radius-md);
  color: #fff;
  text-decoration: none;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.fsa-badge:hover { transform: translateY(-2px); filter: brightness(1.06); color: #fff; text-decoration: none; }
.fsa-badge .count { font-size: 22px; font-weight: 700; line-height: 1; }
.fsa-badge .range { font-size: 11px; font-weight: 600; opacity: 0.92; margin-top: 3px; white-space: nowrap; }

.fsa-badge.green { background: var(--fsa-green); }
.fsa-badge.amber { background: var(--fsa-amber); color: #3a2e00; }  /* dark text for contrast on yellow */
.fsa-badge.orange { background: var(--fsa-amber); color: #3a2e00; }  /* alias -- MaintServiceReportCard's classification uses "orange" as the string */
.fsa-badge.red   { background: var(--fsa-red); }
.fsa-badge.blue  { background: var(--fsa-blue); }
.fsa-badge.gray  { background: #9ca3af; }

/* ---------- Settings page ---------- */
.fsa-settings-note {
  background: var(--fsa-surface);
  border: 1px solid var(--fsa-border);
  border-radius: var(--fsa-radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--fsa-text-muted);
}
.fsa-settings-note b { color: var(--fsa-text); }

.fsa-settings-card {
  background: var(--fsa-surface);
  border: 1px solid var(--fsa-border);
  border-radius: var(--fsa-radius-lg);
  box-shadow: var(--fsa-shadow-sm);
  padding: 18px 22px;
  margin-bottom: 14px;
}

.fsa-settings-grid {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-top: 12px;
}

.fsa-settings-col { flex: 1 1 300px; }
.fsa-settings-col .col-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fsa-text-muted);
  margin-bottom: 8px;
}

.fsa-settings-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.fsa-badge-static {
  min-width: 96px;
  padding: 8px 10px;
  border-radius: var(--fsa-radius-md);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.fsa-badge-static.green { background: var(--fsa-green); }
.fsa-badge-static.amber { background: var(--fsa-amber); color: #3a2e00; }
.fsa-badge-static.red   { background: var(--fsa-red); }

.fsa-badge-input {
  min-width: 96px;
  padding: 8px 10px;
  border-radius: var(--fsa-radius-md);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.fsa-badge-input.green { background: var(--fsa-green); }
.fsa-badge-input.amber { background: var(--fsa-amber); color: #3a2e00; }
.fsa-badge-input.red   { background: var(--fsa-red); }

.fsa-badge-input input {
  width: 34px;
  border: none;
  border-radius: 4px;
  padding: 3px 2px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--fsa-text);
}
.fsa-badge-input input:focus { outline: 2px solid rgba(255,255,255,0.7); }

.fsa-icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.fsa-icon-btn:hover { background: #f3f4f6; }
.fsa-icon-btn img { width: 22px; height: 22px; display: block; }

/* ---------- Drill-down report pages (navtyp 343-348) ---------- */
.fsa-subject-header {
  background: var(--fsa-surface);
  border: 1px solid var(--fsa-border);
  border-radius: var(--fsa-radius-lg);
  box-shadow: var(--fsa-shadow-sm);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.fsa-subject-header h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--fsa-heading);
}
.fsa-subject-header p {
  margin: 0;
  font-size: 13px;
  color: var(--fsa-text-muted);
  max-width: 70ch;
}

.fsa-filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.fsa-filter-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 110px;
  padding: 12px 16px;
  border-radius: var(--fsa-radius-md);
  color: #fff;
}
.fsa-filter-chip .count { font-size: 22px; font-weight: 700; line-height: 1; }
.fsa-filter-chip .range { font-size: 11px; font-weight: 600; opacity: 0.92; }
.fsa-filter-chip .include {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}
.fsa-filter-chip.green  { background: var(--fsa-green); }
.fsa-filter-chip.amber  { background: var(--fsa-amber); color: #3a2e00; }
.fsa-filter-chip.red    { background: var(--fsa-red); }
.fsa-filter-chip.blue   { background: var(--fsa-blue); }

.fsa-table-wrap {
  background: var(--fsa-surface);
  border: 1px solid var(--fsa-border);
  border-radius: var(--fsa-radius-lg);
  box-shadow: var(--fsa-shadow-sm);
  padding: 4px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.fsa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: var(--fsa-font);
}
.fsa-table thead th,
.fsa-table thead td {
  background: var(--fsa-bg);
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--fsa-text-muted);
  border-bottom: 2px solid var(--fsa-border);
  white-space: nowrap;
}
.fsa-table thead a {
  color: var(--fsa-text-muted);
  text-decoration: none;
}
.fsa-table thead a:hover { color: var(--fsa-heading); text-decoration: underline; }
.fsa-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--fsa-border);
  color: var(--fsa-text);
  vertical-align: top;
}
.fsa-table tbody tr:nth-child(even) { background: #fafbfc; }
.fsa-table tbody tr:hover { background: #f0f4f8; }

/* color-coded percentage cell — class name kept as green/orange/red to match
   the existing VBScript variable values (orange now renders as the brand's
   caution-yellow, matching the badges elsewhere) */
.fsa-table td.green  { background: var(--fsa-green); color: #fff; font-weight: 700; }
.fsa-table td.orange { background: var(--fsa-amber); color: #3a2e00; font-weight: 700; }
.fsa-table td.red    { background: var(--fsa-red); color: #fff; font-weight: 700; }

.fsa-no-records {
  background: var(--fsa-surface);
  border: 1px dashed var(--fsa-border);
  border-radius: var(--fsa-radius-md);
  padding: 24px;
  color: var(--fsa-heading);
  font-style: italic;
}

/* ---------- Loading overlay (shown while Previous/Next Year rebuilds) ---------- */
.fsa-loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.fsa-spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--fsa-border);
  border-top-color: var(--fsa-accent);
  border-radius: 50%;
  animation: fsa-spin 0.8s linear infinite;
}
@keyframes fsa-spin {
  to { transform: rotate(360deg); }
}
.fsa-loading-text {
  margin-top: 14px;
  font-family: var(--fsa-font);
  color: var(--fsa-text);
  font-weight: 600;
  font-size: 14px;
}

/* ---------- Print ---------- */
@media print {
  .fsa-toolbar { display: none; }
  .fsa-card, .fsa-settings-card, .fsa-subject-header, .fsa-table-wrap { box-shadow: none; border: 1px solid #ccc; }
}

@media (max-width: 640px) {
  .fsa-page { padding: 16px; }
  .fsa-card { flex-direction: column; align-items: flex-start; }
  .fsa-badges { width: 100%; }
  .fsa-filter-row { width: 100%; }
}
