:root {
  --primary: #0f766e;
  --primary-dark: #0b5750;
  --primary-light: #ccfbf1;
  --accent: #2563eb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --info: #7c3aed;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --radius: 2px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--primary);
  color: #fff;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
}

.topbar .brand small {
  font-weight: 400;
  opacity: 0.85;
  font-size: 0.75rem;
  display: block;
}

.topbar-logo {
  height: 36px;
  width: auto;
  max-width: 120px;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}

.topbar nav a {
  color: #fff;
  margin-left: 1.25rem;
  font-size: 0.92rem;
  opacity: 0.92;
}

.topbar nav a:hover { opacity: 1; }

.topbar nav { display: flex; align-items: center; }

.nav-dropdown { position: relative; display: inline-block; margin-left: 1.25rem; }

.nav-dropdown-toggle {
  color: #fff;
  font-size: 0.92rem;
  opacity: 0.92;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}

.nav-dropdown-toggle:hover { opacity: 1; }

.nav-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.85rem);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  min-width: 180px;
  padding: 0.4rem 0;
  z-index: 50;
}

.nav-dropdown.open .nav-dropdown-menu { display: block; }

.topbar .nav-dropdown-menu a {
  display: block;
  color: var(--text);
  opacity: 1;
  margin: 0;
  padding: 0.55rem 1rem;
  font-size: 0.92rem;
}

.topbar .nav-dropdown-menu a:hover { background: var(--bg); opacity: 1; text-decoration: none; }

.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
  flex: 1 0 auto;
  width: 100%;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  width: 100%;
  max-width: 420px;
  padding: 2rem;
  border: 1px solid var(--border);
}

.auth-card h1 {
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.auth-card-logo {
  display: block;
  max-height: 64px;
  max-width: 220px;
  margin: 0 auto 1rem;
}

.portal-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.card h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  background: #fff;
  color: var(--text);
}

input[type="file"] {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.65rem 1.1rem;
  border-radius: 2px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: center;
}

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

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-secondary:hover { background: var(--primary-light); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { width: auto; padding: 0.4rem 0.75rem; font-size: 0.85rem; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border-radius: 2px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-icon svg { width: 17px; height: 17px; }

.btn-icon:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.14);
}

.btn-icon[disabled],
.btn-icon.btn-icon--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

/* Bold solid-gradient icon-button variants - white icon on a vivid color
   fill, matching the same hue language as the vivid stat cards (Dashboard/
   Accounts) instead of the pale washed-out tints these used before, which
   read as barely-visible at small icon size. */
.btn-icon-blue { background: linear-gradient(135deg, #60a5fa, #3b82f6); color: #fff; box-shadow: 0 2px 6px rgba(59, 130, 246, 0.35); }
.btn-icon-blue:hover { box-shadow: 0 6px 14px rgba(59, 130, 246, 0.45); }

.btn-icon-teal { background: linear-gradient(135deg, #2dd4bf, #14b8a6); color: #fff; box-shadow: 0 2px 6px rgba(20, 184, 166, 0.35); }
.btn-icon-teal:hover { box-shadow: 0 6px 14px rgba(20, 184, 166, 0.45); }

.btn-icon-purple { background: linear-gradient(135deg, #a78bfa, #8b5cf6); color: #fff; box-shadow: 0 2px 6px rgba(139, 92, 246, 0.35); }
.btn-icon-purple:hover { box-shadow: 0 6px 14px rgba(139, 92, 246, 0.45); }

.btn-icon-amber { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35); }
.btn-icon-amber:hover { box-shadow: 0 6px 14px rgba(245, 158, 11, 0.45); }

.btn-icon-gray { background: linear-gradient(135deg, #9ca3af, #6b7280); color: #fff; box-shadow: 0 2px 6px rgba(107, 114, 128, 0.35); }
.btn-icon-gray:hover { box-shadow: 0 6px 14px rgba(107, 114, 128, 0.45); }

/* Labeled pill action - icon + short text in one solid-filled rounded
   control, used for the one action per row worth calling out by name and
   visual weight (it creates a real financial record) rather than blending
   in as just another icon square. */
.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 2.35rem;
  padding: 0 1rem;
  border-radius: 2px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-pill svg { width: 15px; height: 15px; }
.btn-pill:hover { text-decoration: none; transform: translateY(-2px); }
.btn-pill-green {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
}
.btn-pill-green:hover { background: #15803d; box-shadow: 0 6px 14px rgba(22, 163, 74, 0.4); }

.action-icons { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* Small inline icon inside a text button/tab/search box - a plain <span>
   wrapper around action_icon()'s raw SVG output, since that function
   returns unstyled markup meant to be sized by whatever wraps it. */
.btn-icon-inline { display: inline-flex; align-items: center; vertical-align: middle; }
.btn-icon-inline svg { width: 15px; height: 15px; margin-right: 0.4rem; flex-shrink: 0; }
.search-box-wrap { position: relative; flex: 1; }
.search-box-wrap svg { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search-box-wrap input { padding-left: 2.3rem; }

.links-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-top: 1rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.alert-notice { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }

.otp-display {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px dashed var(--primary);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.otp-display .otp-code {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  margin: 0.35rem 0;
}

.otp-display small { color: var(--primary-dark); opacity: 0.85; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

th { color: var(--text-muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; background: var(--bg); }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge-active { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.badge-inactive { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.badge-role { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }

.form-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
.form-actions .btn, .form-actions .btn-secondary { width: auto; flex: none; }

.field-error { color: var(--danger); font-size: 0.8rem; margin: -0.75rem 0 0.9rem; }

.helper-text { color: var(--text-muted); font-size: 0.8rem; margin: -0.7rem 0 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.print-letterhead { text-align: center; margin-bottom: 1rem; }
.print-letterhead-logo { max-height: 60px; max-width: 220px; margin-bottom: 0.5rem; }
.print-letterhead-name { font-size: 1.15rem; font-weight: 800; color: var(--primary-dark); }
.print-letterhead-address { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

/* Large in-page report viewer - opens an uploaded report full-size without
   leaving the page or spawning a new browser tab. */
.report-viewer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 2rem;
}
.report-viewer-overlay.open { display: flex; }
.report-viewer-box {
  position: relative;
  background: var(--surface);
  border-radius: 2px;
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.report-viewer-content { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.report-viewer-content img { max-width: 100%; max-height: 100%; object-fit: contain; }
.report-viewer-content iframe { width: 100%; height: 100%; border: none; }
.report-viewer-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  z-index: 1;
}
.report-viewer-close:hover { color: var(--text); }

footer.page-footer {
  margin-top: 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.page-footer-inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem 1.5rem;
  font-size: 0.8rem;
}

.page-footer-brand {
  font-weight: 700;
  color: var(--primary-dark);
}

.page-footer-address,
.page-footer-copy {
  color: var(--text-muted);
}

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.15rem 1.25rem;
  flex: 1;
  min-width: 170px;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-box:hover { transform: translateY(-3px); }
.stat-box .stat-icon {
  flex-shrink: 0;
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-box .stat-icon svg { width: 26px; height: 26px; }
.stat-box .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.stat-box .value { font-size: 1.7rem; font-weight: 800; line-height: 1.2; margin-top: 0.15rem; }

/* Bold solid-gradient stat cards - white icon/text on a vivid color fill,
   each with a soft glow shadow tinted to match, instead of a white card with
   a tinted icon badge. One hue per metric so a row of cards reads as
   colorful at a glance, not a wall of near-identical white boxes. */
.stat-box--vivid { border: none; color: #fff; }
.stat-box--vivid .label { color: rgba(255, 255, 255, 0.85); }
.stat-box--vivid .value { color: #fff; }
.stat-box--vivid .stat-icon { background: rgba(255, 255, 255, 0.24); color: #fff; }
.stat-box--blue { background: linear-gradient(135deg, #60a5fa, #3b82f6); box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35); }
.stat-box--blue:hover { box-shadow: 0 12px 28px rgba(59, 130, 246, 0.45); }
.stat-box--purple { background: linear-gradient(135deg, #a78bfa, #8b5cf6); box-shadow: 0 8px 20px rgba(139, 92, 246, 0.35); }
.stat-box--purple:hover { box-shadow: 0 12px 28px rgba(139, 92, 246, 0.45); }
.stat-box--teal { background: linear-gradient(135deg, #2dd4bf, #14b8a6); box-shadow: 0 8px 20px rgba(20, 184, 166, 0.35); }
.stat-box--teal:hover { box-shadow: 0 12px 28px rgba(20, 184, 166, 0.45); }
.stat-box--orange { background: linear-gradient(135deg, #fb923c, #f97316); box-shadow: 0 8px 20px rgba(249, 115, 22, 0.35); }
.stat-box--orange:hover { box-shadow: 0 12px 28px rgba(249, 115, 22, 0.45); }
.stat-box--green { background: linear-gradient(135deg, #34d399, #10b981); box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35); }
.stat-box--green:hover { box-shadow: 0 12px 28px rgba(16, 185, 129, 0.45); }
.stat-box--red { background: linear-gradient(135deg, #f87171, #ef4444); box-shadow: 0 8px 20px rgba(239, 68, 68, 0.35); }
.stat-box--red:hover { box-shadow: 0 12px 28px rgba(239, 68, 68, 0.45); }
.stat-box--cyan { background: linear-gradient(135deg, #22d3ee, #06b6d4); box-shadow: 0 8px 20px rgba(6, 182, 212, 0.35); }
.stat-box--cyan:hover { box-shadow: 0 12px 28px rgba(6, 182, 212, 0.45); }

.dash-section-label { font-size: 1rem; font-weight: 700; color: var(--text); margin: 1.5rem 0 0.75rem; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}
.dash-card {
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  border-radius: 2px;
}
.dash-card h2 { display: flex; align-items: center; gap: 0.6rem; }
.dash-card h2 .dash-icon {
  flex-shrink: 0;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary-dark);
}
.dash-card h2 .dash-icon svg { width: 18px; height: 18px; }
.dash-card h2 .dash-icon--purple { background: #ede9fe; color: #8b5cf6; }
.dash-card h2 .dash-icon--blue { background: #dbeafe; color: #3b82f6; }
.dash-card h2 .dash-icon--teal { background: var(--primary-light); color: var(--primary-dark); }
.dash-card h2 .dash-icon--orange { background: #ffedd5; color: #f97316; }
.legend-row { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; margin: 0.5rem 0; }
.legend-dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; flex-shrink: 0; }
.bar-row { display: flex; align-items: center; gap: 0.75rem; margin: 0.65rem 0; }
.bar-row .bar-label { width: 110px; flex-shrink: 0; font-size: 0.82rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; background: var(--bg); border-radius: 999px; height: 0.85rem; overflow: hidden; box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06); }
.bar-row .bar-fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }
.bar-row .bar-value { width: 60px; flex-shrink: 0; text-align: right; font-size: 0.82rem; font-weight: 700; color: var(--primary-dark); }
.trend-chart { display: flex; align-items: flex-end; gap: 0.6rem; height: 150px; padding-top: 1rem; }
.trend-chart .trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-chart .trend-bar { width: 60%; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%); min-height: 2px; transition: height 0.3s ease; }
.trend-chart .trend-count { font-size: 0.75rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 0.2rem; }
.trend-chart .trend-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.35rem; }

.portal-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: 720px;
  width: 100%;
}

.portal-choice .card { text-align: center; }
.portal-choice .card .icon { font-size: 2rem; margin-bottom: 0.5rem; }

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .portal-choice { grid-template-columns: 1fr; }
}

.visit-entry {
  border-left: 3px solid var(--primary);
  padding: 0.9rem 0 0.9rem 1rem;
  margin-bottom: 1rem;
}

.visit-entry:last-child { margin-bottom: 0; }

.visit-entry-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.visit-date-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
}

.visit-entry p { margin: 0.3rem 0; font-size: 0.92rem; }
