:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-warning: #d97706;
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  /* Sticky footer: page is at least one screen tall and <main> absorbs the spare space */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh; /* mobile browsers: ignores the collapsing address bar */
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

/* Header/footer keep their natural height; <main> grows to push the footer to the bottom.
   width:100% is required because margin:auto on a flex child would otherwise shrink it to its content. */
body > .topbar, body > .site-footer { flex: 0 0 auto; }
body > main.container { flex: 1 0 auto; width: 100%; }

/* ---- Top bar ---- */
.topbar { background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--color-primary); text-decoration: none; }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav a { color: var(--color-text); text-decoration: none; font-size: 0.92rem; }
.nav a:hover { color: var(--color-primary); }
.nav-user { color: var(--color-muted); font-size: 0.85rem; border-left: 1px solid var(--color-border); padding-left: 14px; }
.btn-link { color: var(--color-error) !important; }

/* ---- Cards / surfaces ---- */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--color-primary); }
.stat .label { color: var(--color-muted); font-size: 0.85rem; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; font-size: 0.88rem; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=datetime-local], input[type=tel], input[type=number],
select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--color-border);
  border-radius: 6px; font-size: 0.95rem; background: #fff; color: var(--color-text);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.form-hint { color: var(--color-muted); font-size: 0.8rem; margin-top: 4px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 200px; }
.checkbox-row, .radio-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-weight: normal; }
.checkbox-row input, .radio-row input { width: auto; }

/* ---- Buttons ---- */
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 6px; border: none;
  background: var(--color-primary); color: #fff; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: var(--color-primary-dark); }
.btn-secondary { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #f3f4f6; }
.btn-danger { background: var(--color-error); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
/* Queue console "My Session" card: green = finish the whole health screening, yellow = open the Vital page */
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: #facc15; color: #1f2937; border: 1px solid #eab308; }
.btn-warning:hover { background: #eab308; color: #111827; }
/* "Open Display Screen": bright green so it is obvious from across the desk */
.btn-open-display { background: #22c55e; color: #052e16; font-weight: 700; padding: 10px 22px; border-radius: 8px; border: 2px solid #16a34a; box-shadow: 0 2px 6px rgba(22, 163, 74, 0.35); text-decoration: none; letter-spacing: 0.2px; }
.btn-open-display:hover { background: #4ade80; color: #052e16; box-shadow: 0 4px 10px rgba(22, 163, 74, 0.45); }
.btn-open-display::after { content: " \2197"; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: 0.88rem; }
th { background: #f9fafb; font-weight: 600; color: var(--color-muted); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.03em; }
tr:hover td { background: #fafafa; }
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius); }
.table-wrap table { border: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge-booked { background: #dbeafe; color: #1e40af; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-draft { background: #f3f4f6; color: #4b5563; }
.badge-published { background: #dcfce7; color: #166534; }

/* ---- Auth pages ---- */
.auth-wrap { max-width: 420px; margin: 60px auto; }
.auth-wrap .card { }
.auth-wrap h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-sub { color: var(--color-muted); font-size: 0.88rem; margin-bottom: 20px; }

/* ---- Calendar ---- */
#calendar { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px; }
.fc-event { cursor: pointer; }

/* ---- Questionnaire builder ---- */
.field-row { border: 1px solid var(--color-border); border-radius: 6px; padding: 14px; margin-bottom: 12px; background: #fbfbfc; }
.field-row .field-row-head { display: flex; justify-content: space-between; align-items: center; }

.site-footer { background: var(--color-surface); border-top: 1px solid var(--color-border); padding: 18px 0; color: var(--color-muted); font-size: 0.8rem; text-align: left; margin-top: 40px; }
.site-footer .container { padding-top: 6px; padding-bottom: 6px; }

/* ---- Footer: group company logos + social icons (sizes: FOOTER_LOGO_HEIGHT_PX / FOOTER_ICON_SIZE_PX in config) ---- */
.footer-links { margin-bottom: 18px; }
.footer-links nav + nav { margin-top: 22px; }
.footer-brands, .footer-social { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; }
.footer-brands { gap: 16px 40px; }
.footer-social { gap: 12px 14px; }
.footer-brand-link, .footer-social-link { display: inline-flex; align-items: center; border-radius: 6px; opacity: 1; transition: opacity 0.15s ease; }
.footer-brand-link:hover, .footer-social-link:hover { opacity: 0.7; }
.footer-brand-link:focus-visible, .footer-social-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.footer-brand-img { display: block; width: auto; max-width: 100%; height: var(--footer-logo-h, 44px); object-fit: contain; }
.footer-social-img { display: block; width: var(--footer-icon-size, 40px); height: var(--footer-icon-size, 40px); }
.footer-links + .footer-copy { border-top: 1px solid var(--color-border); padding-top: 14px; }
.footer-copy { margin: 0; }
.footer-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 600px) {
  .footer-brands { gap: 14px 24px; }
  .footer-brand-img { height: calc(var(--footer-logo-h, 44px) * 0.8); }
}
@media print { .footer-links { display: none; } }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.muted { color: var(--color-muted); }
.text-right { text-align: right; }

/* ---- Portal logo (header, far left) ---- */
.portal-logo-link { display: flex; align-items: center; flex-shrink: 0; }
.portal-logo { display: block; width: auto; max-width: 100%; object-fit: contain; }

/* ---- Change password page ---- */
.pw-show { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 0.85rem; color: var(--color-muted); }
.pw-show input { width: auto; margin: 0; }
/* Live password checklist (assets/js/password_policy.js); uses the existing theme colours */
.pw-checklist { list-style: none; margin: 6px 0 0; padding: 0; font-size: 0.8rem; color: var(--color-muted); }
.pw-checklist li { margin: 2px 0; }
.pw-checklist li::before { content: '\25CB'; display: inline-block; width: 1.3em; }
.pw-checklist li.pw-ok { color: var(--color-success); }
.pw-checklist li.pw-ok::before { content: '\2713'; }

/* ---- Login announcement picture (overlay with Close button) ---- */
.login-popup { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, 0.75); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 56px 12px 24px; text-align: center; }
.login-popup-wrap { margin: 0 auto; }
.login-popup-link { display: block; cursor: pointer; }
.login-popup-img { display: block; width: 100%; height: auto; background: #fff; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,0.4); }
.login-popup-close { position: fixed; top: 10px; right: 12px; z-index: 1001; background: #fff; color: var(--color-text); border: 1px solid var(--color-border); border-radius: 999px; padding: 8px 18px; font-size: 1rem; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
.login-popup-close:hover, .login-popup-close:focus { background: var(--color-error); color: #fff; outline: none; }
@media print { .login-popup { display: none !important; } }
