/* Glenna's Medicaid Bed Search -- Mobile-First Stylesheet */

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #16a34a;
    --green-bg: #dcfce7;
    --blue: #2563eb;
    --blue-bg: #dbeafe;
    --yellow: #ca8a04;
    --yellow-bg: #fef9c3;
    --red: #dc2626;
    --red-bg: #fee2e2;
    --purple: #7c3aed;
    --purple-bg: #ede9fe;
    --gray: #6b7280;
    --gray-bg: #f3f4f6;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --bg: #ffffff;
    --bg-page: #f9fafb;
    --nav-bg: #1e293b;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --radius: 8px;
}

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    background: var(--bg-page);
    line-height: 1.6;
    padding-bottom: 80px; /* space for bottom nav */
}

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

h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }

/* === TOP NAV === */
.top-nav {
    background: var(--nav-bg);
    color: white;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.nav-brand {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}
.nav-links-desktop { display: none; }
.nav-links-desktop a {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.nav-links-desktop a.active {
    color: white;
    background: rgba(255,255,255,0.18);
    font-weight: 700;
    font-size: 1.05rem;
}
.nav-secondary {
    font-size: 0.85rem !important;
    opacity: 0.7;
}
.nav-secondary.active {
    opacity: 1;
    font-size: 0.9rem !important;
}
.nav-logout { opacity: 0.6; font-size: 0.85rem; }

/* === SECONDARY BAR (Add Notes) === */
.secondary-bar {
    background: var(--green);
    text-align: center;
    position: sticky;
    top: 56px;
    z-index: 99;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.secondary-bar-link {
    display: block;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.6rem 1rem;
    text-decoration: none;
}
.secondary-bar-link:hover {
    background: rgba(255,255,255,0.1);
    text-decoration: none;
}

/* === BOTTOM NAV (mobile) === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    font-size: 0.7rem;
    color: var(--text-light);
    text-decoration: none;
    min-height: 56px;
    justify-content: center;
}
.bottom-nav-item.active { color: var(--blue); font-weight: 600; }
.bottom-nav-item .nav-icon { font-size: 1.3rem; line-height: 1; }
.bottom-nav-action { color: var(--green); font-weight: 600; }
.bottom-nav-action .nav-icon { font-size: 1.5rem; }

/* === MAIN CONTENT === */
.content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
}

/* === CARDS === */
.card {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}
.card p { margin-bottom: 0.5rem; }
.about-list { margin: 0.5rem 0 0.25rem 1.25rem; list-style: disc; }
.about-list li { margin-bottom: 0.35rem; }

.card-header {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-blue  { background: var(--blue-bg); color: var(--blue); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red   { background: var(--red-bg); color: var(--red); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-gray  { background: var(--gray-bg); color: var(--gray); }

/* === STATUS BANNER (legacy) === */
.status-banner {
    background: var(--blue-bg);
    color: var(--blue);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}


/* === PROGRESS TIMELINE === */
/* Hidden on mobile, shown on desktop */
.timeline-wrap {
    display: none;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1rem 0.5rem;
}
.timeline-track {
    display: flex;
    flex-direction: column;
}
.timeline-step {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.1rem 0;
}
.timeline-step.current {
    padding: 0.4rem 0;
}
.timeline-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    flex-shrink: 0;
}
.timeline-step.done .timeline-dot {
    width: 26px;
    height: 26px;
    background: var(--green);
    color: white;
    font-size: 0.75rem;
}
.timeline-step.current .timeline-dot {
    width: 36px;
    height: 36px;
    background: var(--blue);
    color: white;
    font-size: 1rem;
    box-shadow: 0 0 0 4px var(--blue-bg);
    animation: timeline-pulse 2s ease-in-out infinite;
}
.timeline-step.future .timeline-dot {
    width: 26px;
    height: 26px;
    background: var(--gray-bg);
    color: var(--gray);
    border: 2px solid var(--border);
    font-size: 0.75rem;
}
@keyframes timeline-pulse {
    0%, 100% { box-shadow: 0 0 0 4px var(--blue-bg); }
    50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.1); }
}
.timeline-text {
    flex: 1;
    min-width: 0;
}
.timeline-label {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-light);
}
.timeline-step.done .timeline-label {
    color: var(--green);
    font-size: 0.8rem;
}
.timeline-step.current .timeline-label {
    color: var(--blue);
    font-weight: 700;
    font-size: 0.95rem;
}
.timeline-step.future .timeline-label {
    font-size: 0.8rem;
    color: var(--gray);
}
.timeline-detail {
    font-size: 0.75rem;
    color: var(--blue);
    font-weight: 500;
}
.timeline-detail-muted {
    color: var(--text-light);
}
.timeline-connector {
    width: 3px;
    height: 12px;
    background: var(--border);
    margin-left: 12px;
    flex-shrink: 0;
}
.timeline-step.done + .timeline-connector,
.timeline-connector.active {
    background: var(--green);
}

/* Desktop: horizontal layout */
@media (min-width: 768px) {
    .timeline-wrap {
        display: block;
        padding: 1.25rem 1rem 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .timeline-wrap::-webkit-scrollbar { display: none; }
    .timeline-track {
        flex-direction: row;
        align-items: flex-start;
        min-width: 600px;
    }
    .timeline-step {
        flex-direction: column;
        align-items: center;
        width: 100px;
        text-align: center;
        gap: 0;
        padding: 0;
    }
    .timeline-step.current { padding: 0; }
    .timeline-dot { margin-bottom: 6px; }
    .timeline-step.done .timeline-dot { width: 32px; height: 32px; font-size: 0.85rem; }
    .timeline-step.current .timeline-dot { width: 36px; height: 36px; }
    .timeline-step.future .timeline-dot { width: 32px; height: 32px; }
    .timeline-label { font-size: 0.72rem; }
    .timeline-step.done .timeline-label { font-size: 0.72rem; }
    .timeline-step.current .timeline-label { font-size: 0.75rem; }
    .timeline-step.future .timeline-label { font-size: 0.72rem; }
    .timeline-detail {
        background: var(--blue-bg);
        padding: 1px 6px;
        border-radius: 4px;
        margin-top: 2px;
        font-size: 0.65rem;
        white-space: nowrap;
    }
    .timeline-detail-muted {
        background: var(--gray-bg);
        color: var(--text-light);
    }
    .timeline-connector {
        width: auto;
        height: 3px;
        flex: 1;
        margin-left: 0;
        margin-top: 17px;
        min-width: 16px;
    }
}

/* === INLINE SECTION EDITING === */
.card-header .btn-icon {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
    background: var(--gray-bg);
    color: var(--blue);
    border: 1px solid var(--border);
    border-radius: 6px;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.card-header .btn-icon:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.section-edit { padding-top: 0.25rem; }
.edit-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* === AI SUMMARY LOADING === */
.ai-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-lighter);
    font-style: italic;
}
.ai-loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin {
    to { transform: rotate(360deg); }
}
.ai-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--gray-bg);
    border-radius: var(--radius);
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-light);
    font-style: italic;
}
.ai-disclaimer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    font-style: normal;
    margin-top: 1px;
}

/* === FACILITY STATUS TIMELINE === */
.facility-timeline {
    display: flex;
    align-items: flex-start;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.facility-timeline::-webkit-scrollbar { display: none; }
.ft-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 52px;
    flex-shrink: 0;
    text-align: center;
}
.ft-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 4px;
    flex-shrink: 0;
}
.ft-step.done .ft-dot {
    background: var(--green);
    color: white;
}
.ft-step.current .ft-dot {
    background: var(--blue);
    color: white;
    box-shadow: 0 0 0 3px var(--blue-bg);
}
.ft-step.rejected .ft-dot {
    background: var(--red);
    color: white;
    box-shadow: 0 0 0 3px var(--red-bg);
}
.ft-step.future .ft-dot {
    background: var(--gray-bg);
    color: var(--gray);
    border: 2px solid var(--border);
}
.ft-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-light);
    line-height: 1.2;
    max-width: 60px;
}
.ft-step.current .ft-label { color: var(--blue); }
.ft-step.done .ft-label { color: var(--green); }
.ft-step.rejected .ft-label { color: var(--red); }
.ft-connector {
    height: 3px;
    flex: 1;
    min-width: 8px;
    background: var(--border);
    margin-top: 13px;
    flex-shrink: 0;
}
.ft-connector.active { background: var(--green); }
.ft-connector.rejected { background: var(--red); }

@media (min-width: 768px) {
    .ft-step { min-width: 80px; }
    .ft-dot { width: 32px; height: 32px; font-size: 0.8rem; }
    .ft-label { font-size: 0.7rem; max-width: 80px; }
    .ft-connector { margin-top: 15px; min-width: 16px; }
}

/* === QUICK STATS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.stat-box {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.75rem;
    text-align: center;
}
.stat-number { font-size: 1.5rem; font-weight: 700; color: var(--blue); }
.stat-label { font-size: 0.8rem; color: var(--text-light); }
a.stat-box { text-decoration: none; color: inherit; transition: transform 0.1s, box-shadow 0.1s; }
a.stat-box:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

/* === BUTTONS === */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    min-height: 44px;
    line-height: 1.4;
    text-align: center;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #1d4ed8; text-decoration: none; }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #15803d; text-decoration: none; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }
.btn-outline {
    background: white;
    color: var(--blue);
    border: 1px solid var(--blue);
}
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; min-height: 36px; }
.btn-block { display: block; width: 100%; }
.btn-call {
    background: var(--green);
    color: white;
    font-size: 1.1rem;
    padding: 0.75rem 1.5rem;
}
.btn-call:hover { background: #15803d; text-decoration: none; }

/* === FORMS === */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}
.form-control {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    min-height: 44px;
    background: white;
}
.form-control:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { appearance: auto; }

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.form-hint { font-size: 0.8rem; color: var(--text-light); margin-top: 0.2rem; }
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Checkbox/radio sizing for touch */
input[type="checkbox"], input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* === TABLES === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th, td {
    padding: 0.6rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th {
    background: var(--gray-bg);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
th:hover { background: #e5e7eb; }
tr:hover { background: #f9fafb; }
tr.row-green { background: var(--green-bg); }
tr.row-green:hover { background: #bbf7d0; }
tr.row-yellow { background: var(--yellow-bg); }
tr.row-gray { background: var(--gray-bg); opacity: 0.7; }
tr.row-closed { background: #f1f1f1; opacity: 0.5; text-decoration: line-through; }
tr.row-closed td { text-decoration: line-through; color: var(--gray); }
tr.row-closed .badge { text-decoration: none; }
.badge-closed { background: #1f2937; color: white; }
td.phone-col { white-space: nowrap; }

/* === FACILITY CARDS (Mobile) === */
.facility-cards { display: block; }
.facility-table-desktop { display: none; }

.fcard {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.fcard-green { border-left: 3px solid var(--green); }
.fcard-yellow { border-left: 3px solid var(--yellow); }
.fcard-closed { opacity: 0.5; }
.fcard-closed .fcard-name { text-decoration: line-through; color: var(--gray); }

.fcard-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.fcard-pri { flex-shrink: 0; }
.fcard-pri .badge { font-size: 0.65rem; padding: 0.1rem 0.35rem; min-width: 32px; text-align: center; }
.fcard-main { flex: 1; min-width: 0; }
.fcard-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fcard-sub {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.15rem;
}
.fcard-city {
    font-size: 0.8rem;
    color: var(--text-light);
}
.fcard-sub .badge { font-size: 0.65rem; padding: 0.1rem 0.35rem; }
.fcard-chevron {
    flex-shrink: 0;
    font-size: 1rem;
    color: var(--text-light);
    transition: transform 0.2s;
    width: 24px;
    text-align: center;
}
.fcard.expanded .fcard-chevron { transform: rotate(90deg); }

.fcard-details {
    display: none;
    padding: 0 0.75rem 0.75rem;
    border-top: 1px solid var(--border);
}
.fcard.expanded .fcard-details { display: block; }

.fcard-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1rem;
    padding: 0.6rem 0;
}
.fcard-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}
.fcard-detail-wide { grid-column: 1 / -1; }
.fcard-detail-label {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.fcard-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}
.fcard-actions .phone-link { font-size: 0.9rem; }
.fcard-actions .btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; min-height: 32px; }

/* === IN-PROGRESS NOTES EXCERPT === */
.ip-notes {
    font-size: 0.8rem;
    color: var(--text-light);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.4;
    white-space: pre-wrap;
}

/* === PHONE LINKS === */
.phone-link {
    color: var(--green);
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
}

/* === PRIORITY CALLS LIST === */
.priority-call {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}
.priority-call:last-child { border-bottom: none; }
.priority-call-info { flex: 1; min-width: 0; }
.priority-call-name { font-weight: 600; font-size: 0.95rem; }
.priority-call-detail { font-size: 0.8rem; color: var(--text-light); }
.priority-call .phone-link { font-size: 1.1rem; }

/* === QUICK LINKS === */
.quick-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}
.quick-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    min-height: 60px;
    text-align: center;
}
.quick-link:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); text-decoration: none; }

/* === NOTES === */
.note {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.note-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.note-author {
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
}
.author-josh { background: var(--blue-bg); color: var(--blue); }
.author-debbie { background: var(--green-bg); color: var(--green); }
.author-tom { background: #ffedd5; color: #c2410c; }
.author-jared { background: var(--purple-bg); color: var(--purple); }
.author-default { background: var(--gray-bg); color: var(--gray); }
.note-time { font-size: 0.8rem; color: var(--text-light); }
.note-title { font-weight: 600; margin-bottom: 0.25rem; }
.note-body { white-space: pre-wrap; }
.note-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; }
.note.pinned { border-left: 3px solid var(--blue); }
.note.resolved { opacity: 0.6; }

.reply {
    margin-left: 1.5rem;
    padding: 0.75rem;
    background: var(--bg-page);
    border-radius: var(--radius);
    margin-top: 0.5rem;
}

/* === CHECKLIST === */
.checklist-item {
    display: flex;
    align-items: flex-start;
    padding: 0.5rem 0;
    gap: 0.5rem;
}
.checklist-item.completed label { text-decoration: line-through; color: var(--text-light); }
.checklist-item label { flex: 1; line-height: 1.4; }

/* === DASHBOARD PHASE GROUPS === */
.dash-phase-group { margin-bottom: 0.5rem; }
.dash-phase-label {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.4rem 0 0.2rem;
    border-bottom: 1px solid var(--border);
    margin-top: 0.5rem;
}
.dash-phase-group:first-child .dash-phase-label { margin-top: 0; }

/* === ACTIONS PAGE === */
.progress-bar-wrap {
    background: var(--gray-bg);
    border-radius: 999px;
    height: 12px;
    overflow: hidden;
}
.progress-bar-wrap.progress-bar-sm { height: 6px; }
.progress-bar {
    height: 100%;
    background: var(--green);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.action-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.action-filter {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
}
.action-filter.active {
    border-color: var(--blue);
    background: var(--blue-bg);
    color: var(--blue);
}
.action-filter:hover { text-decoration: none; border-color: var(--blue); }

.phase-group .phase-header { margin-bottom: 0.75rem; }

.checklist-item-full {
    display: flex;
    align-items: flex-start;
    padding: 0.6rem 0;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.checklist-item-full:last-child { border-bottom: none; }
.checklist-item-full.completed .checklist-desc {
    text-decoration: line-through;
    color: var(--text-light);
}
.checklist-content { flex: 1; min-width: 0; }
.checklist-desc { line-height: 1.5; }
.checklist-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

/* === INLINE EDIT BUTTONS === */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-bg);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-light);
    text-decoration: none;
    flex-shrink: 0;
}
.btn-icon:hover { background: var(--border); color: var(--text); text-decoration: none; }
.btn-icon-danger:hover { background: var(--red-bg); color: var(--red); }

.checklist-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.checklist-item-full.edit-mode {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.note-edit-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

/* === MODE TOGGLE (Add Notes / Log Interaction) === */
.mode-toggle {
    display: flex;
    background: var(--gray-bg);
    border-radius: var(--radius);
    padding: 4px;
    gap: 4px;
}
.mode-toggle-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-light);
    transition: all 0.15s;
    font-family: inherit;
}
.mode-toggle-btn.active {
    background: var(--bg);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* === CALLING SCRIPT === */
.calling-script {
    background: var(--blue-bg);
    border: 1px solid var(--blue);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    font-style: italic;
}
.calling-script-toggle {
    cursor: pointer;
    font-weight: 600;
    color: var(--blue);
    font-style: normal;
}

/* === FACILITY DETAIL === */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}
.detail-label { font-weight: 600; font-size: 0.85rem; color: var(--text-light); }
.detail-value { text-align: right; }

/* Research section */
.research-ratings { margin-top: 0.5rem; }
.rating-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}
.rating-row:last-child { border-bottom: none; }
.rating-source { font-weight: 600; font-size: 0.85rem; color: var(--text-light); min-width: 80px; }
.research-section {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}
.research-section h3 { font-size: 0.95rem; margin-bottom: 0.4rem; color: var(--text); }

/* === FILTERS === */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}
.filters select, .filters input {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    min-height: 38px;
    background: white;
}
.filter-count { font-size: 0.85rem; color: var(--text-light); margin-left: auto; }

/* === PLAN PAGE === */

/* Quick Access Cards */
.plan-quick-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.plan-quick-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
    border-left: 3px solid var(--blue);
}
.plan-quick-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); text-decoration: none; }
.plan-quick-icon { font-size: 1.3rem; }

/* Tab Bar */
.plan-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    scrollbar-width: none;
}
.plan-tabs::-webkit-scrollbar { display: none; }
.plan-tab {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    min-width: 0;
}
.plan-tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
    background: var(--blue-bg);
}
.plan-tab:hover { text-decoration: none; color: var(--blue); }
.plan-tab-icon { font-size: 1.2rem; line-height: 1; margin-bottom: 2px; }
.plan-tab-label { font-size: 0.7rem; }
@media (min-width: 768px) {
    .plan-tab { flex: 1; padding: 0.75rem 1rem; }
    .plan-tab-label { font-size: 0.8rem; }
}

/* Section List (mini TOC for active tab) */
.plan-section-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}
.plan-section-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: border-color 0.15s;
}
.plan-section-link:hover { color: var(--blue); border-left-color: var(--blue); text-decoration: none; }
.section-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--blue-bg);
    color: var(--blue);
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.section-num-icon { font-size: 1rem; background: var(--gray-bg); color: var(--gray); }
@media (min-width: 768px) {
    .plan-section-list { grid-template-columns: 1fr 1fr; }
}

.plan-section {
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.plan-section h2 { color: var(--blue); margin-bottom: 0.75rem; }
.plan-section h3 { margin-top: 1rem; margin-bottom: 0.5rem; }
.plan-section table { margin: 0.75rem 0; }
.plan-section ul, .plan-section ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.plan-section li { margin-bottom: 0.3rem; }
.plan-section p { margin-bottom: 0.5rem; }
.plan-section blockquote {
    background: var(--blue-bg);
    border-left: 3px solid var(--blue);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    font-style: italic;
}
.plan-section code {
    background: var(--gray-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
}
.plan-section pre {
    background: var(--gray-bg);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.85rem;
    margin: 0.75rem 0;
}

.section-toggle {
    cursor: pointer;
    user-select: none;
}
.section-toggle::before {
    content: '\25BC  ';
    font-size: 0.8rem;
}
.section-toggle.collapsed::before {
    content: '\25B6  ';
}
.ruled-out-section {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

/* Plan sub-items (indented list items) */
.plan-section li.sub-item {
    margin-left: 1.5rem;
    font-size: 0.9rem;
}

/* Rating display */
.rating-inline { display: inline-flex; align-items: center; gap: 2px; }

/* === LOGIN PAGE === */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: url('bg-login.jpg') center/cover no-repeat fixed;
    position: relative;
}
.login-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}
.login-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 2.5rem 2rem 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    position: relative;
    backdrop-filter: blur(12px);
}
.login-card h1 { font-size: 1.4rem; margin-bottom: 0.3rem; }
.login-card .subtitle { color: var(--text-light); margin-bottom: 1.5rem; font-size: 0.95rem; }
.login-error {
    background: var(--red-bg);
    color: var(--red);
    padding: 0.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* === STAR RATING === */
.star { font-size: 1.2rem; color: #d1d5db; }
.star.filled { color: #f59e0b; }

/* === UTILITY === */
.text-muted { color: var(--text-light); }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.overdue { color: var(--red); font-weight: 600; }
.success-msg {
    background: var(--green-bg);
    color: var(--green);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

/* === RESPONSIVE === */
@media (min-width: 768px) {
    body { padding-bottom: 0; }
    .bottom-nav { display: none; }
    .nav-links-desktop { display: flex; align-items: center; gap: 0.25rem; }
    .stats-grid { grid-template-columns: repeat(5, 1fr); }
    .quick-links { grid-template-columns: repeat(3, 1fr); }
    .form-row { grid-template-columns: 1fr 1fr; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
    .facility-cards { display: none; }
    .facility-table-desktop { display: block; }
}

@media (min-width: 1024px) {
    .content { padding: 1.5rem 2rem; }
}

/* === CONVERSATION SCRIPT === */
.script-section {
    padding: 1.25rem;
}
.script-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.script-section-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.script-section-title {
    flex: 1;
    font-size: 1.15rem;
    color: var(--text);
    margin-bottom: 0;
}
.script-items {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}
.script-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.script-item:last-child {
    border-bottom: none;
}
.script-item-view {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
}
.script-bullet {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--blue);
    flex-shrink: 0;
    margin-top: 0.55rem;
}
.script-item-text {
    flex: 1;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    cursor: pointer;
    padding: 0.1rem 0;
}
.script-item-text:hover {
    color: var(--blue);
}
.script-item-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.script-item:hover .script-item-actions {
    opacity: 1;
}
.script-item-edit textarea {
    min-height: 60px;
}
.script-add-item {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* === OPERATIONAL SUMMARY META === */
.summary-meta-row {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}
.summary-meta-row:last-child {
    border-bottom: none;
}
.summary-meta-view {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.summary-meta-key {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
}
.summary-meta-val {
    font-size: 0.95rem;
    color: var(--blue);
    font-weight: 600;
    cursor: pointer;
}
.summary-meta-val:hover {
    text-decoration: underline;
}
.summary-meta-edit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile: always show action buttons on script */
@media (max-width: 767px) {
    .script-item-actions {
        opacity: 1;
    }
}

/* === PRINT === */
@media print {
    .top-nav, .bottom-nav, .btn, .filters { display: none; }
    body { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
