/* ──────────────────────────────────────────────────────────────────────────
   Hospital case page (merged hospital + application detail).
   GLOBAL (not scoped) so the page and every extracted tab component under
   Pages/Hospitals/Tabs/ share one visual system. Class prefix: hp-.
   ────────────────────────────────────────────────────────────────────────── */

/* Hero header */
.hp-hero {
    background: linear-gradient(135deg, var(--app-navy) 0%, var(--app-navy-700) 55%, var(--app-navy-600) 100%);
    border-radius: var(--app-r-lg);
    padding: 1.5rem 1.75rem 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--app-shadow);
    position: relative;
    overflow: hidden;
}

.hp-hero::after {
    /* subtle teal glow accent that gently drifts */
    content: "";
    position: absolute;
    right: -60px;
    top: -60px;
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, var(--app-teal-glow) 0%, transparent 70%);
    pointer-events: none;
    animation: hp-float 9s ease-in-out infinite;
    will-change: transform;
}

@keyframes hp-float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-14px, 12px); }
}

.hp-hero h1 {
    color: #fff;
    margin: 0.35rem 0 0.25rem;
}

.hp-hero-sub {
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.9rem;
    margin: 0;
}

.hp-hero-sub code {
    color: var(--app-teal);
    background: rgba(0, 197, 168, 0.12);
    padding: 0.05rem 0.4rem;
    border-radius: var(--app-r-sm);
}

.hp-hero-sub a { color: rgba(255, 255, 255, 0.92); text-decoration: underline; }
.hp-hero-sub a:hover { color: var(--app-teal); }

/* a slim status chip in the hero */
.hp-hero-stage {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
}
.hp-hero-stage .bi { color: var(--app-teal); }

.hp-back.btn-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 0;
    font-size: 0.85rem;
}

.hp-back.btn-link:hover { color: var(--app-teal); }

/* KPI tiles */
.hp-kpi {
    background: var(--app-white);
    border: 1px solid var(--app-border);
    border-radius: var(--app-r);
    padding: 1rem 1.1rem;
    height: 100%;
    box-shadow: var(--app-shadow-xs);
    transition: box-shadow var(--app-mid) var(--app-ease), transform var(--app-mid) var(--app-ease);
}

.hp-kpi:hover {
    box-shadow: var(--app-shadow-sm);
    transform: translateY(-2px);
}

/* Staggered reveal for the KPI row */
.hp-kpis > [class*="col"] .hp-kpi {
    animation: hp-rise var(--app-slow) var(--app-ease) both;
}
.hp-kpis > [class*="col"]:nth-child(1) .hp-kpi { animation-delay: 0.04s; }
.hp-kpis > [class*="col"]:nth-child(2) .hp-kpi { animation-delay: 0.10s; }
.hp-kpis > [class*="col"]:nth-child(3) .hp-kpi { animation-delay: 0.16s; }
.hp-kpis > [class*="col"]:nth-child(4) .hp-kpi { animation-delay: 0.22s; }

@keyframes hp-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.hp-kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--app-text-3);
    margin-bottom: 0.35rem;
}

.hp-kpi-value {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: 1.9rem;
    line-height: 1.05;
    color: var(--app-navy);
}

.hp-kpi-value.hp-kpi-sm {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
}

.hp-kpi-of {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    color: var(--app-text-3);
    margin-left: 0.25rem;
}

.hp-kpi-foot {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--app-text-3);
}

.hp-kpi-ok { border-color: var(--app-teal); }
.hp-kpi-ok .hp-kpi-foot { color: var(--app-teal-600); }
.hp-kpi-warn { border-color: #F0C674; }
.hp-kpi-warn .hp-kpi-foot { color: #92400E; }

/* Skeleton loaders (shimmer) */
.hp-skel {
    position: relative;
    overflow: hidden;
    background: var(--app-surface-2);
    border-radius: var(--app-r);
}

.hp-skel::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    animation: hp-shimmer 1.3s var(--app-ease) infinite;
}

.hp-skel-hero { height: 116px; border-radius: var(--app-r-lg); }
.hp-skel-tile { height: 92px; }

@keyframes hp-shimmer {
    to { transform: translateX(100%); }
}

/* Tab bar + panel */
.hp-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    border-bottom: 1px solid var(--app-border);
}

.hp-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 0.95rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--app-text-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color var(--app-fast) ease, border-color var(--app-fast) ease;
}

.hp-tab:hover { color: var(--app-navy); }
.hp-tab.is-active { color: var(--app-navy); border-bottom-color: var(--app-teal); }

.hp-tab-count {
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--app-surface-2);
    color: var(--app-text-2);
    border-radius: 999px;
    padding: 0.03rem 0.4rem;
    min-width: 1.2rem;
    text-align: center;
}

.hp-tab.is-active .hp-tab-count { background: var(--app-teal-50); color: var(--app-teal-600); }

.hp-panel {
    background: var(--app-white);
    border: 1px solid var(--app-border);
    border-radius: 0 var(--app-r) var(--app-r) var(--app-r);
    padding: 1.5rem;
    margin-top: -1px;
    box-shadow: var(--app-shadow-xs);
    animation: hp-fade var(--app-mid) var(--app-ease);
}

@keyframes hp-fade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

.hp-subhead {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--app-text-3);
    margin-bottom: 0.5rem;
}

.hp-assignee { max-width: 11rem; }

/* ── Overview hub ─────────────────────────────────────────────────────────── */

/* status + advance header band */
.hp-ov-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem 1.25rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--app-border);
    border-left: 4px solid var(--app-teal);
    border-radius: var(--app-r);
    background: var(--app-white);
    box-shadow: var(--app-shadow-xs);
    margin-bottom: 1.25rem;
}
.hp-ov-head-main { min-width: 0; }
.hp-ov-stagelabel {
    font-size: 0.66rem; font-weight: 600; letter-spacing: 0.05em;
    text-transform: uppercase; color: var(--app-text-3);
}
.hp-ov-stagename { font-size: 1.35rem; font-weight: 600; color: var(--app-navy); line-height: 1.1; }
.hp-ov-next { font-size: 0.82rem; color: var(--app-text-3); margin-top: 0.1rem; }
.hp-ov-next strong { color: var(--app-teal-600); }
.hp-ov-advance { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

/* phase stepper — where in the lifecycle the case sits */
.hp-steps { display: flex; gap: 0.4rem; flex-basis: 100%; }
.hp-step { flex: 1 1 0; min-width: 0; }
.hp-step-bar {
    height: 6px; border-radius: 999px; background: var(--app-surface-2);
    transition: background var(--app-mid) var(--app-ease);
}
.hp-step.is-done .hp-step-bar { background: var(--app-teal); }
.hp-step.is-active .hp-step-bar { background: var(--app-teal); box-shadow: 0 0 0 3px var(--app-teal-50); }
.hp-step-label {
    font-size: 0.66rem; margin-top: 0.3rem; color: var(--app-text-3);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hp-step.is-active .hp-step-label { color: var(--app-navy); font-weight: 600; }

/* section label */
.hp-section-label {
    font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--app-text-3); margin: 0 0 0.4rem;
}

/* needs-attention — outstanding items as slim, clickable rows (no metric cards; the hero already
   carries the headline numbers, so this stays about what's *left to do*) */
.hp-needs { display: flex; flex-direction: column; border-top: 1px solid var(--app-border); margin-bottom: 1.5rem; }
.hp-need {
    display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left;
    padding: 0.7rem 0.4rem; border: none; border-bottom: 1px solid var(--app-border);
    background: transparent; cursor: pointer;
    transition: background var(--app-fast) ease, padding-left var(--app-fast) ease;
}
.hp-need:hover { background: var(--app-surface-2); padding-left: 0.7rem; }
.hp-need:active { background: var(--app-surface-2); }
.hp-need-ico {
    width: 1.7rem; height: 1.7rem; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 7px; font-size: 0.9rem; background: #FEF3C7; color: #92400E;
}
.hp-need-text { flex: 1 1 auto; min-width: 0; color: var(--app-navy); font-size: 0.9rem; }
.hp-need-go { flex: none; color: var(--app-text-3); }
.hp-need:hover .hp-need-go { color: var(--app-teal-600); }

.hp-allclear {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.85rem 1rem; border: 1px solid var(--app-teal); border-radius: var(--app-r);
    background: var(--app-teal-50); color: var(--app-teal-600); font-weight: 600; margin-bottom: 1.5rem;
}
.hp-allclear .bi { font-size: 1.15rem; }

/* overview two-column (tasks + activity) */
.hp-ov-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
@media (max-width: 768px) { .hp-ov-cols { grid-template-columns: 1fr; } }

.hp-ov-card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.6rem;
}
.hp-ov-card-head .btn-link { padding: 0; font-size: 0.8rem; }

.hp-ov-line {
    display: flex; align-items: baseline; gap: 0.5rem;
    padding: 0.5rem 0; border-top: 1px solid var(--app-border);
}
.hp-ov-line:first-of-type { border-top: none; }
.hp-ov-line .bi { color: var(--app-text-3); font-size: 0.85rem; }
.hp-ov-line-main { min-width: 0; flex: 1 1 auto; }
.hp-ov-line-sub { font-size: 0.76rem; color: var(--app-text-3); }
.hp-ov-line.is-overdue .hp-ov-line-sub { color: #DC2626; font-weight: 600; }
.hp-ov-line.is-status .bi { color: var(--app-teal-600); }

/* ── Consolidated files — icon grid ───────────────────────────────────────── */
.hp-files {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.5rem;
}

.hp-file {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-r);
    background: var(--app-white);
    text-decoration: none;
    color: var(--app-navy);
    transition: border-color var(--app-fast) ease, box-shadow var(--app-fast) ease, transform var(--app-fast) ease;
}

.hp-file:hover {
    border-color: var(--app-teal);
    box-shadow: var(--app-shadow-sm);
    transform: translateY(-1px);
}

.hp-file-icon { font-size: 1.5rem; flex: none; }

.hp-file-meta { display: flex; flex-direction: column; min-width: 0; }

.hp-file-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hp-file-type {
    font-size: 0.68rem;
    color: var(--app-text-3);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.hp-file-go { margin-left: auto; flex: none; color: var(--app-text-3); font-size: 0.8rem; }
.hp-file:hover .hp-file-go { color: var(--app-teal-600); }

/* ── Submissions — contact cards with prominent link-buttons ───────────────── */
.hp-subs { display: flex; flex-direction: column; gap: 0.75rem; }

.hp-sub-card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-r);
    padding: 0.85rem 1rem;
    background: var(--app-white);
    box-shadow: var(--app-shadow-xs);
}

.hp-sub-head { display: flex; align-items: center; gap: 0.65rem; }
.hp-sub-avatar { font-size: 1.6rem; color: var(--app-navy-400); flex: none; }
.hp-sub-id { min-width: 0; }
.hp-sub-name { font-weight: 600; color: var(--app-navy); line-height: 1.2; }
.hp-sub-email { font-size: 0.8rem; color: var(--app-text-3); text-decoration: none; }
.hp-sub-email:hover { color: var(--app-teal-600); }

.hp-sub-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.75rem; }

.hp-linkbtn {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex: 1 1 14rem;
    max-width: 22rem;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-r);
    background: var(--app-white);
    color: var(--app-navy);
    text-decoration: none;
    transition: border-color var(--app-fast) ease, box-shadow var(--app-fast) ease, transform var(--app-fast) ease;
}

.hp-linkbtn:hover {
    border-color: var(--app-teal);
    box-shadow: var(--app-shadow-sm);
    transform: translateY(-1px);
    color: var(--app-navy);
}

.hp-linkbtn > .bi:first-child { font-size: 1.45rem; flex: none; color: var(--app-teal-600); }
.hp-linkbtn.hp-linkbtn-sp > .bi:first-child { color: #2563EB; }

.hp-linkbtn > span { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.hp-linkbtn-title { font-weight: 600; font-size: 0.9rem; }
.hp-linkbtn-sub { font-size: 0.72rem; color: var(--app-text-3); }
.hp-linkbtn-go { margin-left: auto; flex: none; color: var(--app-text-3); font-size: 0.85rem; }
.hp-linkbtn:hover .hp-linkbtn-go { color: var(--app-teal-600); }

/* Per-document "open submitted file" link + intake marker (merged Documents tab) */
.hp-doclink {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-size: 0.82rem; color: var(--app-navy); text-decoration: none;
    padding: 0.15rem 0.45rem; border: 1px solid var(--app-border); border-radius: var(--app-r-sm);
    transition: border-color var(--app-fast) ease, background var(--app-fast) ease;
}
.hp-doclink:hover { border-color: var(--app-teal); background: var(--app-surface-2); color: var(--app-navy); }
.hp-doclink-ico { font-size: 1rem; }
.hp-doclink .bi-box-arrow-up-right { font-size: 0.7rem; color: var(--app-text-3); }

.hp-intake-badge {
    display: inline-flex; align-items: center; gap: 0.2rem;
    font-size: 0.66rem; font-weight: 600; margin-left: 0.4rem;
    color: var(--app-teal-600); background: var(--app-teal-50);
    border-radius: 999px; padding: 0.05rem 0.4rem; vertical-align: middle;
}

/* Pre-fund readiness checklist (Contract tab) */
.hp-readout { display: flex; align-items: baseline; gap: 0.5rem; }
.hp-readout-count { font-family: 'Instrument Serif', Georgia, serif; font-size: 1.6rem; color: var(--app-navy); line-height: 1; }

.hp-gates { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--app-border); }
.hp-gate {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.6rem 0.3rem; border-bottom: 1px solid var(--app-border);
}
.hp-gate-check { width: 1rem; text-align: center; color: var(--app-text-3); }
.hp-gate-label { flex: 1 1 auto; min-width: 0; color: var(--app-navy); }
.hp-gate.done .hp-gate-label { color: var(--app-text-3); }

.hp-gate-sig {
    font-size: 0.72rem; font-weight: 600; border-radius: 999px;
    padding: 0.1rem 0.5rem; display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap;
}
.hp-gate-sig.is-met { color: var(--app-teal-600); background: var(--app-teal-50); }
.hp-gate-sig.is-unmet { color: var(--app-text-2); background: var(--app-surface-2); }
.hp-gate-sig.is-manual { color: var(--app-text-3); background: var(--app-surface-2); }
.hp-gate-mismatch { font-size: 0.72rem; font-weight: 600; color: #DC2626; display: inline-flex; align-items: center; gap: 0.2rem; white-space: nowrap; }
.hp-gate-when { font-size: 0.72rem; color: var(--app-text-3); white-space: nowrap; }

/* ACH verification milestone timeline */
.hp-ach-steps { list-style: none; margin: 0; padding: 0; position: relative; max-width: 32rem; }
.hp-ach-steps > li { display: flex; gap: 0.65rem; align-items: flex-start; padding: 0 0 0.9rem 0; position: relative; }
.hp-ach-steps > li:not(:last-child)::before {
    content: ""; position: absolute; left: 0.47rem; top: 1.25rem; bottom: 0.1rem;
    width: 2px; background: var(--app-border);
}
.hp-ach-steps > li > .bi { font-size: 1rem; line-height: 1.15; flex: none; color: var(--app-text-3); z-index: 1; background: var(--app-white); }
.hp-ach-steps > li.is-done > .bi { color: var(--app-teal-600); }
.hp-ach-steps > li.is-error > .bi { color: #DC2626; }
.hp-ach-step-label { font-size: 0.85rem; font-weight: 600; color: var(--app-text-3); line-height: 1.2; }
.hp-ach-steps > li.is-done .hp-ach-step-label { color: var(--app-navy); }
.hp-ach-steps > li.is-error .hp-ach-step-label { color: #DC2626; }
.hp-ach-step-meta { font-size: 0.75rem; color: var(--app-text-3); }

/* Funding summary + cap meters */
.hp-fund-stats { display: flex; flex-wrap: wrap; gap: 1.75rem; margin-bottom: 0.65rem; }
.hp-fund-stat-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--app-text-3); }
.hp-fund-stat-value { font-family: 'Instrument Serif', Georgia, serif; font-size: 1.5rem; line-height: 1.05; color: var(--app-navy); }

.hp-meter { margin-bottom: 0.85rem; }
.hp-meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; font-size: 0.8rem; margin-bottom: 0.25rem; }
.hp-meter-label { font-weight: 600; color: var(--app-navy); }
.hp-meter-sub { color: var(--app-text-3); font-size: 0.75rem; white-space: nowrap; }
.hp-meter-sub.is-over { color: #DC2626; font-weight: 700; }
.hp-meter-track { height: 8px; border-radius: 999px; background: var(--app-surface-2); overflow: hidden; }
.hp-meter-fill { height: 100%; border-radius: 999px; background: var(--app-teal); transition: width var(--app-mid) var(--app-ease); }
.hp-meter-fill.is-warn { background: #F0C674; }
.hp-meter-fill.is-over { background: #DC2626; }

/* Searchable assignee picker (typeahead) */
.hp-typeahead { position: relative; }
.hp-typeahead-menu {
    position: absolute; z-index: 30; top: calc(100% + 2px); left: 0; min-width: 100%;
    background: var(--app-white); border: 1px solid var(--app-border); border-radius: var(--app-r);
    box-shadow: var(--app-shadow-sm); max-height: 15rem; overflow-y: auto; padding: 0.25rem;
}
.hp-typeahead-item {
    display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left;
    border: none; background: transparent; padding: 0.3rem 0.5rem; border-radius: var(--app-r-sm);
    cursor: pointer; line-height: 1.2;
}
.hp-typeahead-item:hover { background: var(--app-surface-2); }
.hp-typeahead-name { font-size: 0.85rem; color: var(--app-navy); }
.hp-typeahead-email { font-size: 0.72rem; color: var(--app-text-3); }
.hp-typeahead-empty { padding: 0.4rem 0.5rem; color: var(--app-text-3); font-size: 0.8rem; }

/* Refresh spin */
.hp-spin { animation: hp-spin 0.9s linear infinite; display: inline-block; }

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