/* ============================================
   EBHAR Platform — app.wounded-shepherd.com
   ============================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    background-color: #f1f5f9;
    color: #333;
}

/* ---- Top bar ---- */
.topbar {
    background: #fff;
    color: #333;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem 0 0.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 110;
    border-bottom: 1px solid #e0e0e0;
}

.topbar-left { display: flex; align-items: center; gap: 0; }

.topbar-center { flex: 1; text-align: center; }
.topbar-center-title { color: #1e3a5f; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.3px; }

.topbar-brand { display: flex; align-items: flex-end; text-decoration: none; margin-left: 6px; margin-bottom: -6px; }
.topbar-brand img { height: 40px; width: auto; }

.topbar-menu-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.25rem 0 0.25rem 0.25rem;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background 0.2s;
}
.topbar-menu-btn:hover { background: #f0f0f0; }

.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-user { display: flex; align-items: center; gap: 0.6rem; }
.topbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #5b9bd5;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85em;
    flex-shrink: 0;
}
.topbar-user-name { color: #333; font-size: 0.85em; font-weight: 500; }
.topbar-user-role {
    background: #eef2f7;
    color: #5b7a9d;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7em;
    text-transform: capitalize;
    margin-left: 0.25rem;
}

.topbar-superadmin-badge {
    background: #eee8ff;
    color: #6b46c1;
    padding: 0.15rem 0.6rem;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.topbar-logout {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 0.8em;
    padding: 0.35rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.2s;
    border-radius: 4px;
}
.topbar-logout:hover { color: #dc3545; background: #fafafa; }

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 240px;
    background: #f1f5f9;
    color: #333;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    z-index: 100;
    overflow: hidden;
}
.sidebar.collapsed { width: 56px; }

.sidebar-nav { flex: 1; padding: 0.5rem 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    color: #666;
    text-decoration: none;
    font-size: 0.9em;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: #e8ecf1; color: #1e3a5f; }
.sidebar-nav a.active {
    background: #e1edf8;
    color: #2b7cb3;
    border-left-color: #2b7cb3;
    font-weight: 600;
}
.sidebar-nav a svg { flex-shrink: 0; }
.sidebar-nav a span { white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .sidebar-nav a span { display: none; }

.sidebar-nav .nav-section {
    padding: 1.25rem 1rem 0.4rem;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-nav .nav-section.nav-section-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    color: #555;
    font-weight: 700;
}
.sidebar-nav .nav-section.nav-section-toggle:hover { color: #1e3a5f; }
.sidebar-nav .nav-section.nav-section-toggle .nav-toggle-arrow { stroke: #444; stroke-width: 3; }
.sidebar-nav .nav-section.nav-section-toggle:hover .nav-toggle-arrow { stroke: #1e3a5f; }
.nav-toggle-arrow {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.nav-section-toggle.collapsed .nav-toggle-arrow {
    transform: rotate(-90deg);
}
.nav-group {
    overflow: hidden;
    transition: max-height 0.25s ease;
    max-height: 500px;
    padding-left: 0.5rem;
}
.nav-group.collapsed {
    max-height: 0;
}
.sidebar.collapsed .nav-section { display: none; }
.sidebar.collapsed .nav-group { max-height: none; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; padding: 0.6rem 0; border-left: none; }

/* ---- Main content ---- */
.app-main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease;
    padding-top: 56px;
}
.has-sidebar .app-main { margin-left: 240px; }
.has-sidebar .sidebar.collapsed ~ .app-main { margin-left: 56px; }

.app-container { max-width: 1200px; padding: 0.5rem 1.5rem; width: 100%; }

/* ---- Mobile ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 56px;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 240px !important; }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar-overlay.visible { display: block; }
    .has-sidebar .app-main { margin-left: 0 !important; }
    .topbar-user-name { display: none; }
    .topbar-user-role { display: none; }
    .topbar-superadmin-badge { display: none; }
    .topbar-center { display: none; }
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
}
.page-header h1 { margin: 0; font-size: 1.25rem; color: #6b7280; font-weight: 600; }

/* ---- Alerts ---- */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9em;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.btn-primary { background: #1e3a5f; color: white; }
.btn-primary:hover { background: #2a4f7f; }
.btn-gold { background: #d4af37; color: #1e3a5f; }
.btn-gold:hover { background: #c19b26; }
.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8em; }
.btn-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f0;
    color: #888;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-view:hover { background: #e0e0e0; color: #1e3a5f; }

/* ---- Tables ---- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
th, td { padding: 0.55rem 0.85rem; text-align: left; border-bottom: 1px solid #eee; }
th {
    font-weight: 600;
    color: #888;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f1f5f9;
}
tbody tr:hover { background: #fafafa; }

/* ---- Cards ---- */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e0e0e0;
    margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; color: #1e3a5f; }

/* ---- Auth pages ---- */
.auth-wrapper { max-width: 420px; margin: 2rem auto; }
.auth-card {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e0e0e0;
    margin-bottom: 1rem;
}
.auth-card h2 { margin-top: 0; color: #1e3a5f; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; font-weight: 500; color: #444; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95em;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2b7cb3;
    box-shadow: 0 0 0 2px rgba(43,124,179,0.15);
}
.form-error { color: #dc3545; font-size: 0.85em; margin-top: 0.25rem; }

/* ---- Status badges ---- */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.7em;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* ---- Sort headers ---- */
.sort-header {
    color: #888;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-size: inherit;
    font-weight: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
}
.sort-header:hover { color: #1e3a5f; }
.sort-header.active { color: #1e3a5f; }

/* ---- Search / Filters ---- */
.search-filters {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}
.search-filters .form-group { margin: 0; }
.search-filters input[type="text"] {
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    font-size: 0.9em;
    min-width: 240px;
}
.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: white;
    font-size: 0.9em;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-btn:hover { border-color: #2b7cb3; color: #2b7cb3; }
.filter-btn.active { border-color: #2b7cb3; background: #f0f7ff; color: #2b7cb3; }

/* ---- Pagination ---- */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid #eee;
}
.pagination-info { color: #888; font-size: 0.85em; }
.pagination-links { display: flex; gap: 0.5rem; }
.pagination-btn {
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85em;
    text-decoration: none;
    color: #555;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}
.pagination-btn:hover:not(.disabled) { border-color: #2b7cb3; color: #2b7cb3; }
.pagination-btn.disabled { color: #ccc; cursor: default; border-color: #e0e0e0; }

/* ---- Back office ---- */
.backoffice-area { background-color: #f1f5f9; }
.backoffice-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    background: #2d3748;
    color: #a0aec0;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: 8px;
    margin-bottom: 0;
}

/* ---- Footer ---- */
footer {
    margin-top: auto;
    color: #999;
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.85em;
    border-top: 1px solid #e0e0e0;
}
footer a { color: #1e3a5f; text-decoration: none; }

/* ---- Phase navigation ---- */
.sidebar-nav a.phase-current { font-weight: 600; background: #e8f5e9; border-left: 3px solid #28a745; }

/* ---- Phase sections grid ---- */
.phase-sections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.phase-section-card {
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, transform 0.15s;
    display: block;
}
.phase-section-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}
.phase-section-label {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #aaa;
    font-weight: 600;
}

/* ============================================
   Assessment Engine
   ============================================ */

/* ---- Assessment tabs ---- */
.assessment-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}
.assessment-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: #888;
    font-size: 0.9em;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.assessment-tab:hover { color: #1e3a5f; border-bottom-color: #ccc; }
.assessment-tab.active { color: #1e3a5f; border-bottom-color: #1e3a5f; font-weight: 600; }
.assessment-tab.complete .tab-number { background: #d4edda; color: #155724; }
.tab-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #f0f0f0;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
}
.assessment-tab.active .tab-number { background: #1e3a5f; color: white; }
.tab-check { color: #28a745; flex-shrink: 0; }

.assessment-section-header {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}
.assessment-section-header h2 { margin: 0 0 0.25rem; font-size: 1.1rem; color: #1e3a5f; }

/* ---- Question cards ---- */
.question-card {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.question-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.question-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1e3a5f;
    color: white;
    font-size: 0.8em;
    font-weight: 700;
    flex-shrink: 0;
}
.question-meta { display: flex; flex-direction: column; }
.question-title { font-weight: 600; color: #1e3a5f; font-size: 0.95em; }
.question-reference { font-size: 0.75em; color: #aaa; font-style: italic; }
.question-text { color: #555; font-size: 0.9em; line-height: 1.5; margin: 0 0 0.75rem; }

/* ---- Radio options ---- */
.question-options { display: flex; flex-direction: column; gap: 0.4rem; }
.option-label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.88em;
    line-height: 1.4;
}
.option-label:hover { border-color: #2b7cb3; background: #f7fafd; }
.option-label.selected { border-color: #2b7cb3; background: #e8f0fa; }
.option-label input[type="radio"] { margin-top: 2px; flex-shrink: 0; accent-color: #1e3a5f; }
.option-text { color: #444; }

/* Special options (Unknown/NA) */
.option-special {
    border-style: dashed;
    border-color: #ccc;
}
.option-special:hover { border-color: #999; background: #fafafa; }
.option-special.selected { border-color: #856404; background: #fff8e1; }

/* ---- Assessment navigation ---- */
.assessment-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* ---- Score bars ---- */
.score-bar { display: flex; align-items: center; gap: 0.5rem; flex: 1; }
.score-bar-track {
    flex: 1;
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
}
.score-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease;
}
.score-bar-value { font-size: 0.85em; font-weight: 600; color: #555; min-width: 36px; text-align: right; }
.score-bar-compact .score-bar-track { height: 6px; }
.score-bar-compact .score-bar-value { font-size: 0.75em; min-width: 30px; }

.score-bar-a { background: #28a745; }
.score-bar-b { background: #2b7cb3; }
.score-bar-c { background: #f0a030; }
.score-bar-d { background: #dc3545; }

/* ---- Category badges ---- */
.category-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.05em;
}
.cat-a { background: #fdf3d7; color: #8a6d0b; }
.cat-b { background: #d4edda; color: #155724; }
.cat-c { background: #d6eaf8; color: #1a5276; }
.cat-d { background: #ffeeba; color: #856404; }
.cat-e { background: #f8d7da; color: #721c24; }

.cat-a-text { color: #d4af37; }
.cat-b-text { color: #28a745; }
.cat-c-text { color: #2b7cb3; }
.cat-d-text { color: #f0a030; }
.cat-e-text { color: #dc3545; }

/* ---- Category assignment buttons ---- */
.category-btn {
    border: 2px solid transparent;
    transition: all 0.15s;
}
.category-btn-a { background: #fdf3d7; color: #8a6d0b; border-color: #e6c85c; }
.category-btn-a:hover, .category-btn-a.active { background: #d4af37; color: white; border-color: #d4af37; }
.category-btn-b { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.category-btn-b:hover, .category-btn-b.active { background: #28a745; color: white; border-color: #28a745; }
.category-btn-c { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }
.category-btn-c:hover, .category-btn-c.active { background: #2b7cb3; color: white; border-color: #2b7cb3; }
.category-btn-d { background: #fff8e1; color: #f57f17; border-color: #ffe082; }
.category-btn-d:hover, .category-btn-d.active { background: #f0a030; color: white; border-color: #f0a030; }
.category-btn-e { background: #fce4ec; color: #c62828; border-color: #f8bbd0; }
.category-btn-e:hover, .category-btn-e.active { background: #dc3545; color: white; border-color: #dc3545; }

/* ---- Score overview grid ---- */
.score-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.score-overview-item {
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #eee;
}
.score-overview-label { font-size: 0.75em; color: #888; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 0.25rem; }
.score-overview-value { font-size: 1.25rem; font-weight: 700; color: #1e3a5f; margin-bottom: 0.35rem; }

/* ---- Result questions ---- */
.result-question {
    padding: 0.6rem 0.6rem;
    margin: 0 -0.6rem;
    border-bottom: 1px solid #f0f0f0;
    border-radius: 4px;
}
.result-question:last-child { border-bottom: none; }
.result-question.score-1 { background: #fce4e4; }
.result-question.score-2 { background: #fff3e0; }
.result-question-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.result-score { margin-left: auto; font-size: 0.8em; color: #555; font-weight: 600; }
.result-answer { font-size: 0.85em; color: #666; padding-left: 2rem; }

/* ---- Compiled dashboard ---- */
.compiled-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.compiled-stat-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.compiled-stat-value { font-size: 1.5rem; font-weight: 700; color: #1e3a5f; }
.compiled-stat-label { font-size: 0.7em; color: #888; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.25rem; }

/* ---- Elder cards grid ---- */
.elder-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.elder-result-card {
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #f8f9fa;
}

/* ---- Assessment mobile ---- */
@media (max-width: 768px) {
    .assessment-tabs { gap: 0.25rem; }
    .tab-name { display: none; }
    .assessment-tab { padding: 0.5rem 0.6rem; }
    .score-overview-grid { grid-template-columns: 1fr 1fr; }
    .compiled-stats-grid { grid-template-columns: repeat(3, 1fr); }
    .elder-cards-grid { grid-template-columns: 1fr; }
    .option-label { font-size: 0.82em; padding: 0.4rem 0.6rem; }
}

/* ============================================
   TEMPLATE DECISION TREE
   ============================================ */

/* ---- Scenario cards grid ---- */
.scenario-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-top: 1rem;
}

.scenario-card {
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    padding: 1.25rem;
    transition: box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
}

.scenario-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.scenario-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.scenario-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.1em;
    color: #fff;
    flex-shrink: 0;
}

.scenario-letter-a { background: #d4af37; }
.scenario-letter-b { background: #28a745; }
.scenario-letter-c { background: #2b7cb3; }
.scenario-letter-d { background: #f0a030; }
.scenario-letter-e { background: #dc3545; }

.scenario-card .scenario-name {
    font-size: 1.1em;
    font-weight: 600;
    color: #1e3a5f;
    margin: 0 0 0.25rem;
}

.scenario-card .scenario-desc {
    font-size: 0.88em;
    color: #666;
    line-height: 1.5;
    flex: 1;
}

.scenario-urgency {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 600;
    padding: 0.15em 0.6em;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.urgency-low { background: #d4edda; color: #155724; }
.urgency-moderate { background: #d6eaf8; color: #1a5276; }
.urgency-high { background: #ffeeba; color: #856404; }
.urgency-critical { background: #f8d7da; color: #721c24; }

.scenario-meta {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.scenario-elder-count {
    font-size: 0.82em;
    color: #888;
}

.scenario-elder-count strong {
    color: #333;
}

/* ---- Template cards ---- */
.template-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e3a5f;
    margin: 1.5rem 0 0.75rem;
}

.template-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.template-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem 1.15rem;
    transition: box-shadow 0.2s, border-color 0.2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.template-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.07);
    border-color: #ccc;
}

.template-card.primary {
    border-left: 4px solid;
}

.template-card.primary.scenario-a { border-left-color: #d4af37; }
.template-card.primary.scenario-b { border-left-color: #28a745; }
.template-card.primary.scenario-c { border-left-color: #2b7cb3; }
.template-card.primary.scenario-d { border-left-color: #f0a030; }
.template-card.primary.scenario-e { border-left-color: #dc3545; }

.template-card .template-id {
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 0.25rem;
}

.template-card .template-title {
    font-size: 0.95em;
    font-weight: 600;
    color: #1e3a5f;
    margin-bottom: 0.35rem;
}

.template-card .template-desc {
    font-size: 0.82em;
    color: #666;
    line-height: 1.45;
    flex: 1;
}

.template-card .primary-badge {
    display: inline-block;
    font-size: 0.68em;
    font-weight: 600;
    padding: 0.1em 0.5em;
    border-radius: 3px;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    background: #e8f4fd;
    color: #1a5276;
}

/* ---- Additional templates list (non-primary) ---- */
.template-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.template-list li {
    border-bottom: 1px solid #f0f0f0;
}

.template-list li:last-child {
    border-bottom: none;
}

.template-list a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.template-list a:hover {
    background: #f8f9fa;
}

.template-list .tpl-id {
    font-size: 0.75em;
    font-weight: 700;
    color: #999;
    min-width: 2.5rem;
}

.template-list .tpl-title {
    font-size: 0.9em;
    font-weight: 500;
    color: #1e3a5f;
}

.template-list .tpl-desc {
    font-size: 0.8em;
    color: #888;
}

/* ---- Elder assignment sidebar ---- */
.elder-sidebar {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
}

.elder-sidebar h3 {
    font-size: 0.9em;
    color: #1e3a5f;
    margin: 0 0 0.75rem;
}

.elder-sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.elder-sidebar-list li {
    font-size: 0.85em;
    padding: 0.35rem 0;
    border-bottom: 1px solid #eee;
    color: #555;
}

.elder-sidebar-list li:last-child {
    border-bottom: none;
}

/* ---- Breadcrumb ---- */
.template-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85em;
    color: #888;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.template-breadcrumb a {
    color: #2b7cb3;
    text-decoration: none;
}

.template-breadcrumb a:hover {
    text-decoration: underline;
}

.template-breadcrumb .breadcrumb-sep {
    color: #ccc;
}

/* ---- Template show (content page) ---- */
.template-content {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 1.5rem 2rem;
    margin-top: 1rem;
}

.template-content h2 {
    font-size: 1.2em;
    color: #1e3a5f;
    margin: 1.5rem 0 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #f0f0f0;
}

.template-content h2:first-child {
    margin-top: 0;
}

.template-content h3 {
    font-size: 1.05em;
    color: #2b5a7f;
    margin: 1.25rem 0 0.4rem;
}

.template-content ul, .template-content ol {
    margin: 0.5rem 0 1rem;
    padding-left: 1.5rem;
}

.template-content li {
    margin-bottom: 0.3rem;
    line-height: 1.55;
}

.template-content blockquote {
    border-left: 3px solid #2b7cb3;
    background: #f0f6fb;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    border-radius: 0 6px 6px 0;
    font-style: italic;
    color: #444;
    line-height: 1.6;
}

.template-content p {
    line-height: 1.6;
    margin: 0.5rem 0;
}

.template-content strong {
    color: #1e3a5f;
}

/* ---- Print button ---- */
.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #f8f9fa;
    border: 1px solid #ddd;
    color: #555;
    padding: 0.4rem 0.9rem;
    border-radius: 5px;
    font-size: 0.82em;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-print:hover {
    background: #e9ecef;
}

/* ---- Scenario detail layout ---- */
.scenario-detail-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 1.5rem;
    align-items: start;
}

.scenario-detail-layout.no-sidebar {
    grid-template-columns: 1fr;
}

/* ---- Related templates (Phase 3 section) ---- */
.related-templates-section {
    margin-top: 1.5rem;
}

.related-templates-section h2 {
    font-size: 1rem;
    color: #1e3a5f;
    margin: 0 0 0.75rem;
}

.related-template-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    margin-bottom: 0.5rem;
    transition: background 0.15s, border-color 0.15s;
}

.related-template-link:hover {
    background: #f8f9fa;
    border-color: #ccc;
}

.related-template-link .rtl-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85em;
    color: #fff;
    flex-shrink: 0;
}

.related-template-link .rtl-text {
    font-size: 0.88em;
    color: #1e3a5f;
    font-weight: 500;
}

.related-template-link .rtl-desc {
    font-size: 0.78em;
    color: #888;
}

/* ---- Template mobile ---- */
@media (max-width: 768px) {
    .scenario-grid { grid-template-columns: 1fr; }
    .template-cards { grid-template-columns: 1fr; }
    .scenario-detail-layout { grid-template-columns: 1fr; }
    .template-content { padding: 1rem; }
}

/* ============================================
   QUARTERLY HEALTH CHECK
   ============================================ */

/* ---- Round selector ---- */
.round-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.round-selector label {
    font-size: 0.85em;
    font-weight: 600;
    color: #555;
}
.round-selector select {
    padding: 0.35rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.85em;
    background: white;
}

/* ---- Trend chart ---- */
.trend-chart { margin-bottom: 1.5rem; }
.trend-chart-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}
.trend-chart-label {
    min-width: 90px;
    font-size: 0.8em;
    font-weight: 600;
    color: #555;
    text-align: right;
}
.trend-chart-bars {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.trend-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.trend-bar-round {
    min-width: 50px;
    font-size: 0.7em;
    color: #888;
    text-align: right;
}
.trend-bar-track {
    flex: 1;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}
.trend-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.trend-bar-value {
    min-width: 36px;
    font-size: 0.75em;
    font-weight: 600;
    color: #555;
}

/* ---- Open text response card ---- */
.text-response-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.text-response-card .elder-name {
    font-weight: 600;
    font-size: 0.9em;
    color: #1e3a5f;
    margin-bottom: 0.35rem;
}
.text-response-card .elder-text {
    font-size: 0.88em;
    color: #555;
    line-height: 1.55;
    white-space: pre-wrap;
}

/* ---- Critical flags alert ---- */
.critical-flags-alert {
    background: #fff5f5;
    border: 1px solid #fc8181;
    border-left: 4px solid #dc3545;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.critical-flags-alert h3 {
    color: #dc3545;
    font-size: 0.95em;
    margin: 0 0 0.5rem;
}
.critical-flags-alert ul {
    margin: 0;
    padding-left: 1.25rem;
}
.critical-flags-alert li {
    font-size: 0.88em;
    color: #555;
    margin-bottom: 0.25rem;
}
.critical-flag-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #dc3545;
    font-size: 0.8em;
    font-weight: 600;
}

/* ---- Quarterly textarea ---- */
.quarterly-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9em;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
}
.quarterly-textarea:focus {
    outline: none;
    border-color: #2b7cb3;
    box-shadow: 0 0 0 2px rgba(43,124,179,0.15);
}

/* ---- Start new round ---- */
.new-round-card {
    border: 2px dashed #d4af37;
    background: #fffbeb;
}

/* ---- Quarterly mobile ---- */
@media (max-width: 768px) {
    .trend-chart-label { min-width: 60px; font-size: 0.7em; }
    .trend-bar-round { min-width: 36px; font-size: 0.65em; }
    .round-selector { flex-wrap: wrap; }
}

/* ---- Print styles ---- */
@media print {
    .topbar, .sidebar, .sidebar-overlay,
    .template-breadcrumb, .btn-print,
    .scenario-meta, footer,
    .related-templates-section,
    .impersonation-banner { display: none !important; }

    body { background: #fff; }
    .app-main { margin: 0; padding: 0; }
    .app-container { max-width: 100%; padding: 0; }

    .template-content {
        border: none;
        padding: 0;
        box-shadow: none;
    }

    .template-content blockquote {
        border-left: 2px solid #666;
        background: none;
    }
}
