/* ══════════════════════════════════════════════════════════
   Evergrove Healthcare — QA Compliance
   Earth-tone theme: forest green + honey gold + warm neutrals
   ══════════════════════════════════════════════════════════ */

/* Fonts are the system stack (see body font-family) — no external font CDN,
   so pages containing PHI make zero third-party requests. */

:root {
    /* ── Evergrove Healthcare — earth tones (forest green + honey gold) ── */
    --bg: #f2eee2;              /* warm sand/cream */
    --bg-warm: #f8f4ea;
    --surface: #fffefb;         /* warm white */
    --surface-hover: #f4efe3;
    --border: #e5ddca;
    --border-light: #efe9da;
    --text: #2b2d24;            /* warm near-black (green-brown) */
    --text-secondary: #585c4b;
    --text-muted: #979683;      /* warm taupe */
    --accent: #1f6741;          /* forest green — exact Evergrove "Ever" */
    --accent-hover: #16502f;
    --accent-light: #e7f0e9;
    --accent-dim: rgba(31,103,65,0.09);
    --primary: #1f6741;         /* alias used by some templates */
    --primary-light: #e7f0e9;
    --gold: #f5c542;            /* honey gold — Evergrove "grove" */
    --gold-dark: #c48f27;
    --gold-light: #faf0d5;
    --teal-600: #2f6b43;
    --teal-500: #3d8456;
    --sky-500: #3f6f6b;
    --indigo-500: #6b4a6e;
    --success: #2f7d4f;
    --success-light: #eaf3ec;
    --success-bg: #d7ebdc;
    --success-text: #256b43;
    --warning: #c78a1e;
    --warning-light: #fbf3e0;
    --warning-bg: #f6e7c6;
    --warning-text: #916413;
    --danger: #bf5330;          /* terracotta (earthy red) */
    --danger-light: #f8ece5;
    --danger-bg: #f1ddd2;
    --danger-text: #a2412a;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
    background: linear-gradient(165deg, #e4e8d3 0%, #ebeddc 42%, #f1ede1 100%);
    background-attachment: fixed;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ── Navigation ─────────────────────────────────────────── */

.navbar {
    background: var(--surface) !important;
    padding: 0.5rem 1.5rem;
    border: none;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 1px 10px rgba(70,55,20,0.05);
}

/* Evergrove wordmark */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
}
/* Official Evergrove logo (static/img/evergrove-logo.png), shown prominently. */
.logo-img {
    height: 58px;
    width: auto;
    display: block;
    transition: transform var(--transition), filter var(--transition);
}
.navbar-brand:hover .logo-img {
    transform: scale(1.02);
    filter: drop-shadow(0 2px 6px rgba(31,103,65,0.22));
}
@media (max-width: 768px) { .logo-img { height: 42px; } }
/* Hide the CSS wordmark fallback whenever the real image loaded. On image
   error the <img> removes itself, this selector stops matching, and the
   wordmark shows. */
.logo-img + .logo-fallback { display: none; }
.logo-fallback { display: inline-flex; align-items: baseline; gap: 0.5rem; }
.logo-word {
    font-family: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1;
}
.logo-ever { color: var(--accent); }
.logo-grove { color: var(--gold); }
.logo-leaf { width: 15px; height: 15px; align-self: center; margin-left: -3px; transform: translateY(-7px) rotate(8deg); }
.logo-sub {
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.26em;
    text-transform: uppercase; color: var(--accent); align-self: center;
}
.brand-app {
    font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
    align-self: center; padding-left: 0.6rem; border-left: 1px solid var(--border);
    letter-spacing: 0.01em;
}

.nav-link-custom {
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    text-decoration: none;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.nav-link-custom:hover {
    color: var(--accent) !important;
    background: var(--accent-light);
}

.nav-link-custom.active {
    color: var(--accent) !important;
    background: var(--accent-light);
    border-color: var(--accent-dim);
}

/* ── Controls Bar ───────────────────────────────────────── */

.controls-bar {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.35rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: end;
    gap: 1rem;
    flex-wrap: wrap;
    border: 1px solid var(--border-light);
}

.controls-bar .form-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.controls-bar .form-select,
.controls-bar .form-control {
    background: var(--bg-warm);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.controls-bar .form-select:focus,
.controls-bar .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    background: white;
}

.btn-run {
    background: linear-gradient(135deg, #2f6b43 0%, #3d8456 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.4rem;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all var(--transition);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(47,107,67,0.2);
}

.btn-run:hover {
    background: linear-gradient(135deg, #245536 0%, #2f6b43 100%);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(47,107,67,0.3);
}

.btn-run:disabled {
    opacity: 0.5;
    transform: none;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-export {
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    background: transparent;
}

.btn-export:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ── Drill-Down Panel ───────────────────────────────────── */

#drill-down-panel {
    display: none;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: slideUp 0.25s ease-out;
}

#drill-down-panel.active {
    display: block;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#drill-down-panel .card-header {
    background: var(--danger-light);
    border-bottom: 1px solid var(--danger-bg);
    padding: 0.8rem 1.25rem;
    color: var(--danger-text);
}

#drill-down-panel .table {
    font-size: 0.85rem;
}

#drill-down-panel .table thead th {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

#drill-down-panel .btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border);
    border-radius: 6px;
}

#drill-down-panel .btn-outline-secondary:hover {
    color: var(--text);
    background: var(--surface-hover);
}

/* ── Navigation loading overlay ─────────────────────────── */

#nav-loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--surface) 55%, transparent);
    backdrop-filter: blur(1.5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.nav-loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: nav-spin 0.7s linear infinite;
}

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

/* ── Manual-Check Recording Panel ───────────────────────── */

#manual-panel {
    display: none;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: slideUp 0.25s ease-out;
}

#manual-panel.active { display: block; }

#manual-panel .card-header {
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.25rem;
    color: var(--text);
}

#manual-panel .table { font-size: 0.85rem; }

#manual-panel .table thead th {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

#manual-panel select.manual-result {
    font-size: 0.8rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

#manual-panel input.manual-note {
    font-size: 0.8rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 100%;
    min-width: 120px;
}

#manual-panel .manual-saved {
    font-size: 0.72rem;
    color: var(--success-text);
    white-space: nowrap;
}

/* ── Sync Page ──────────────────────────────────────────── */

.sync-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.sync-card .table {
    margin: 0;
}

.sync-card .table td,
.sync-card .table th {
    padding: 0.9rem 1.25rem;
    vertical-align: middle;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-light);
}

.sync-card .table thead th {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    background: var(--bg-warm);
}

.sync-btn {
    position: relative;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
    transition: all var(--transition);
    background: linear-gradient(135deg, #2f6b43 0%, #3d8456 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 6px rgba(47,107,67,0.15);
}

.sync-btn:hover {
    background: linear-gradient(135deg, #245536 0%, #2f6b43 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(47,107,67,0.25);
    transform: translateY(-1px);
}

.sync-btn.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.4);
    border-radius: inherit;
}

.status-ready { color: var(--success); font-weight: 600; font-size: 0.83rem; }
.status-running { color: var(--warning); font-weight: 600; font-size: 0.83rem; }
.status-failed { color: var(--danger); font-weight: 600; font-size: 0.83rem; }
.status-complete { color: var(--success); font-weight: 600; font-size: 0.83rem; }

.sync-log-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.sync-log-card .card-header {
    background: var(--bg-warm);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.25rem;
    font-weight: 600;
    font-size: 0.88rem;
}

/* ── Progress / Evaluation ──────────────────────────────── */

.eval-progress-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.eval-progress-card .card-header {
    background: linear-gradient(90deg, rgba(47,107,67,0.08), rgba(74,154,99,0.08));
    border-bottom: 1px solid rgba(47,107,67,0.1);
    padding: 0.9rem 1.25rem;
    font-weight: 600;
    color: var(--accent);
}

.eval-log {
    max-height: 250px;
    overflow-y: auto;
    font-size: 0.78rem;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    background: #26251f;
    color: #cbb26a;
    padding: 1rem;
    border-radius: 8px;
    margin: 0;
    line-height: 1.7;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.2);
}

/* ── Empty States ───────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(47,107,67,0.1), rgba(74,154,99,0.1));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(47,107,67,0.12);
}

.empty-state h4 {
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    max-width: 420px;
    margin: 0 auto;
}

.empty-state p + p {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Misc ───────────────────────────────────────────────── */

.container-fluid { max-width: 1400px; }

.alert {
    border-radius: var(--radius);
    font-size: 0.85rem;
    border: none;
}

.alert-success { background: var(--success-light); color: var(--success-text); }
.alert-danger { background: var(--danger-light); color: var(--danger-text); }

/* Bootstrap overrides */
.spinner-border { color: var(--accent); }
.btn-primary {
    background: linear-gradient(135deg, #2f6b43, #3d8456);
    border: none;
    color: white;
    box-shadow: 0 2px 6px rgba(47,107,67,0.15);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #245536, #2f6b43);
    color: white;
}
.btn-primary:disabled { opacity: 0.5; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d8cfbd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b6ab96; }

/* ── Manager dashboard additions ────────────────────────── */

/* Nav: current user + departments dropdown */
.nav-user {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    border-left: 1px solid var(--border);
    margin-left: 0.3rem;
}
.nav-logout-btn {
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-secondary) !important;
}
.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    font-size: 0.85rem;
    padding: 0.35rem;
}
.dropdown-item { border-radius: 6px; padding: 0.4rem 0.7rem; color: var(--text); }
.dropdown-item:hover { background: var(--accent-light); color: var(--accent-hover); }

/* Login */
.login-wrap { display: flex; justify-content: center; padding: 4rem 1rem; }
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    padding: 2.25rem 2rem;
    width: 100%;
    max-width: 380px;
}
.login-title { font-size: 1.25rem; font-weight: 800; color: var(--text); margin: 0 0 0.15rem; letter-spacing: -0.01em; }
.login-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.login-card .form-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.login-card .form-control { background: var(--bg-warm); border: 1px solid var(--border); border-radius: 8px; padding: 0.55rem 0.75rem; font-size: 0.9rem; }
.login-card .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); background: #fff; }

/* Unevaluated-weeks warning banner (Department / Staff pages) */
.uneval-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    background: var(--warning-light); border: 1px solid var(--warning-bg);
    border-left: 4px solid var(--warning); border-radius: var(--radius);
    padding: 0.7rem 1.1rem; margin-bottom: 1rem;
    font-size: 0.85rem; font-weight: 600; color: var(--warning-text);
}
.uneval-banner a { font-weight: 700; white-space: nowrap; }

/* Unassigned-clinician data-quality flag */
.unassigned-flag {
    background: var(--warning-light);
    border: 1px solid var(--warning-bg);
    border-left: 4px solid var(--warning);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.unassigned-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.8rem 1.1rem;
}
.unassigned-title { display: block; font-size: 0.88rem; font-weight: 700; color: var(--warning-text); }
.unassigned-sub { display: block; font-size: 0.76rem; color: var(--text-secondary); margin-top: 2px; }
.unassigned-toggle { flex-shrink: 0; }
.unassigned-list { border-top: 1px solid var(--warning-bg); background: var(--surface); padding: 0.25rem 0.5rem; }
.unassigned-list .table { font-size: 0.82rem; margin: 0; }
.unassigned-list thead th {
    font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
}

/* ── Story-first overview (redesign) ────────────────────── */

/* Narrative headline */
.headline { font-size: clamp(1.1rem, 2.1vw, 1.45rem); font-weight: 700; letter-spacing: -0.02em;
    text-wrap: balance; line-height: 1.34; color: var(--text); margin: 0.25rem 0.15rem 1.15rem; }
.headline strong { font-weight: 800; }
.headline .hl-up { color: var(--success-text); font-weight: 700; }
.headline .hl-down { color: var(--danger-text); font-weight: 700; }
.headline .hl-em { border-bottom: 2px solid var(--warning); padding-bottom: 1px; }

.score { display: flex; gap: 1.25rem; align-items: center; padding: 0.5rem 1.15rem 0.25rem; }
.score .big { font-size: 3.4rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--accent-hover); }
.score .meta { display: flex; flex-direction: column; gap: 0.2rem; }
.score .delta { font-size: 0.82rem; font-weight: 700; }
.score .delta.up { color: var(--success-text); }
.score .delta.down { color: var(--danger-text); }
.score .delta.flat { color: var(--text-muted); }
.score .passed { font-size: 0.8rem; color: var(--text-secondary); }

/* Needs attention list (in hero) */
.needs .needs-list { padding: 0.5rem 0.75rem 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; }
.need { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.7rem; border-radius: 11px;
    background: var(--bg-warm); border: 1px solid var(--border-light); cursor: pointer; transition: all var(--transition); }
.need:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.need .sev { width: 5px; align-self: stretch; border-radius: 4px; }
.need .sev.bad { background: var(--danger-text); }
.need .sev.warn { background: var(--warning-text); }
.need-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.need-lbl { font-size: 0.83rem; font-weight: 650; line-height: 1.25; }
.need-ctx { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.need-pct { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; min-width: 42px; text-align: right; }
.need-pct.bad { color: var(--danger-text); }
.need-pct.warn { color: var(--warning-text); }
.need-chg { font-size: 0.66rem; font-weight: 700; min-width: 30px; text-align: right; }
.need-chg.up { color: var(--success-text); }
.need-chg.down { color: var(--danger-text); }
.needs-empty { padding: 1rem 1.15rem 1.35rem; font-size: 0.85rem; color: var(--text-secondary); }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
    .score .big { font-size: 2.75rem; }
}

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