/* ── Therapist Portal Base Layout ────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { background: #f4f6fa; font-family: 'Inter', 'Segoe UI', sans-serif; }

.th-portal {
    display: flex;
    min-height: 100vh;
}

/* ── Left Sidebar ─────────────────────────────────────────────── */
.th-sidebar {
    width: 80px;
    background: #fff;
    border-right: 1px solid #e5e8ef;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.th-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 28px;
    padding: 4px 8px;
}

.th-sidebar-logo {
    width: 100%;
    max-width: 96px;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
}

.th-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 0 8px;
}

.th-sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border-radius: 10px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 9px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}

.th-sidebar-item:hover { background: #f0f4ff; color: #185FA5; }
.th-sidebar-item.active { background: #e6f1fb; color: #185FA5; }
.th-sidebar-item.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.th-sidebar-odoo-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: auto 12px 16px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.th-sidebar-odoo-btn:hover { background: #f0f4ff; color: #185FA5; }

/* ── Main Area ────────────────────────────────────────────────── */
.th-main {
    margin-left: 80px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Top Navigation ───────────────────────────────────────────── */
.th-topnav {
    background: #fff;
    border-bottom: 1px solid #e5e8ef;
    display: flex;
    align-items: center;
    padding: 0 28px;
    height: 52px;
    gap: 4px;
    position: sticky;
    top: 0;
    z-index: 1000;
    overflow: visible;
}

.th-nav-btn {
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.th-nav-btn:hover { background: #f0f4ff; color: #185FA5; }
.th-nav-btn.active { background: #185FA5; color: #fff; }
.th-nav-btn.disabled { color: #cbd5e1; cursor: not-allowed; pointer-events: none; }

/* ── Nav Dropdown ─────────────────────────────────────────────── */
.th-nav-group {
    position: relative;
    display: flex;
    align-items: center;
}
.th-nav-group .th-nav-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    user-select: none;
}
.th-nav-group .th-nav-btn svg { flex-shrink: 0; transition: transform 0.15s; }
.th-nav-group.open .th-nav-btn svg { transform: rotate(180deg); }
.th-nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    padding-top: 6px;
    z-index: 200;
    min-width: 175px;
}
.th-nav-dropdown-inner {
    background: #fff;
    border: 1px solid #e5e8ef;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.10);
    overflow: hidden;
}
.th-nav-group.open .th-nav-dropdown { display: block; }
.th-dropdown-item {
    display: block;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}
.th-dropdown-item:hover { background: #f0f4ff; color: #185FA5; }
.th-dropdown-item.active { background: #EEF4FF; color: #185FA5; font-weight: 600; }

/* ── Content Area ─────────────────────────────────────────────── */
.th-content {
    padding: 28px;
    flex: 1;
}

/* ── Page Header ──────────────────────────────────────────────── */
.th-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.th-page-title {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
}

.th-page-subtitle {
    font-size: 13px;
    color: #94a3b8;
    margin-top: 2px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.th-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
    text-decoration: none;
}

.th-btn:hover { opacity: 0.85; }
.th-btn-primary { background: #185FA5; color: #fff; }
.th-btn-secondary { background: #f1f5f9; color: #475569; }
.th-btn-danger { background: #fee2e2; color: #dc2626; }
.th-btn-sm { padding: 5px 12px; font-size: 12px; }
.th-btn-icon { padding: 6px; }

/* ── Cards ────────────────────────────────────────────────────── */
.th-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e8ef;
    padding: 20px;
    margin-bottom: 16px;
}

/* ── Patient List ─────────────────────────────────────────────── */
.th-search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.th-search-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.th-search-input:focus { border-color: #185FA5; }

.th-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.th-table th {
    text-align: left;
    padding: 10px 14px;
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid #e5e8ef;
}

.th-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.th-table tr:hover td { background: #f8fafc; cursor: pointer; }

.th-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.th-badge-active { background: #dcfce7; color: #166534; }
.th-badge-inactive { background: #fef3c7; color: #92400e; }
.th-badge-discharged { background: #f1f5f9; color: #64748b; }

/* ── Patient Detail Tabs ──────────────────────────────────────── */
.th-sub-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid #e5e8ef;
    padding-bottom: 0;
}

.th-sub-tab {
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
}

.th-sub-tab:hover { color: #185FA5; }
.th-sub-tab.active { color: #185FA5; border-bottom-color: #185FA5; font-weight: 600; }

/* ── Dept Tabs ────────────────────────────────────────────────── */
.th-dept-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.th-dept-tab {
    padding: 7px 20px;
    border-radius: 20px;
    border: 1.5px solid #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: #64748b;
    transition: all 0.15s;
}

.th-dept-tab:hover { border-color: #185FA5; color: #185FA5; }
.th-dept-tab.active { background: #185FA5; color: #fff; border-color: #185FA5; }

/* ── Visit Accordion ──────────────────────────────────────────── */
.th-visit-list { display: flex; flex-direction: column; gap: 12px; }

.th-visit-card {
    background: #fff;
    border: 1px solid #e5e8ef;
    border-radius: 12px;
    overflow: hidden;
}

.th-visit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    background: #f8fafc;
}

.th-visit-header:hover { background: #f0f4ff; }

.th-visit-title {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
}

.th-visit-date { font-size: 12px; color: #94a3b8; font-weight: 400; }

.th-visit-chevron {
    transition: transform 0.2s;
    color: #94a3b8;
}

.th-visit-card.open .th-visit-chevron { transform: rotate(180deg); }

.th-visit-body {
    display: none;
    padding: 20px;
    border-top: 1px solid #e5e8ef;
}

.th-visit-card.open .th-visit-body { display: block; }

/* ── Section Blocks inside a visit ───────────────────────────── */
.th-section {
    margin-bottom: 20px;
}

.th-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.th-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.th-rows { display: flex; flex-direction: column; gap: 8px; }

.th-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: #f8fafc;
    border: 1px solid #e5e8ef;
    border-radius: 8px;
    padding: 10px 12px;
}

.th-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.th-field label {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.th-field input,
.th-field textarea,
.th-field select {
    padding: 7px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #1e293b;
    background: #fff;
    resize: vertical;
    outline: none;
}

.th-field input:focus,
.th-field textarea:focus { border-color: #185FA5; }

.th-field-pct { max-width: 90px; }

.th-row-actions {
    display: flex;
    align-items: flex-start;
    padding-top: 22px;
}

.th-remove-btn {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
}

.th-remove-btn:hover { color: #ef4444; background: #fee2e2; }

/* ── Clinical item cards ── */
.th-concern-card {
    background: #fff;
    border: 1px solid #fecdd3;
    border-left: 4px solid #f87171;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.th-goal-card {
    background: #fff;
    border: 1px solid #dbeafe;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.th-act-card {
    background: #fff;
    border: 1px solid #ede9fe;
    border-left: 4px solid #8b5cf6;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.th-home-plan-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.th-goal-group {
    background: #f8faff;
    border: 1px solid #dbeafe;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    padding: 12px 14px;
}

.th-card-sublabel {
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

/* Goal progress slider */
.th-goal-slider { flex: 1; accent-color: #3b82f6; cursor: pointer; }
.th-goal-pct-val { font-size: 18px; font-weight: 700; color: #1e293b; min-width: 46px; text-align: right; }
.th-goal-bar-bg { height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.th-goal-bar-fill { height: 100%; background: #3b82f6; border-radius: 3px; transition: width 0.15s; }

/* Day pills + per-day time selects */
.th-day-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.th-day-time-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.th-day-col { display: flex; flex-direction: column; align-items: center; min-width: 44px; }
.th-day-pill {
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    user-select: none;
    width: 100%;
    text-align: center;
}
.th-day-pill.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.th-day-time-sel { font-size: 10px; width: 100%; border-radius: 4px; border: 1px solid #cbd5e1; padding: 2px; color: #334155; background: #f8fafc; }

/* Activity video grid */
.th-act-vid-wrap { position: relative; display: inline-block; }
.th-act-vid-thumb { display: block; }
.th-act-vid-remove {
    position: absolute; top: -5px; right: -5px;
    width: 18px; height: 18px;
    border-radius: 50%; background: #ef4444; color: #fff;
    border: none; font-size: 12px; line-height: 18px; text-align: center;
    cursor: pointer; padding: 0;
}

/* Activity image grid */
.th-act-img-grid { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
.th-act-img-wrap { position: relative; display: inline-block; }
.th-act-img-thumb {
    width: 60px; height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    display: block;
}
.th-act-img-remove {
    position: absolute; top: -5px; right: -5px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #ef4444; color: #fff;
    border: none; font-size: 12px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.th-act-img-upload-label {
    width: 60px; height: 60px;
    border: 2px dashed #cbd5e1;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8; font-size: 24px;
    cursor: pointer; transition: border-color 0.12s, color 0.12s;
}
.th-act-img-upload-label:hover { border-color: #8b5cf6; color: #8b5cf6; }

/* Scale nested components */
.th-scale-block {
    background: #f8fafc;
    border: 1px solid #e5e8ef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
}

.th-scale-name-row { margin-bottom: 8px; }

.th-components { display: flex; flex-direction: column; gap: 6px; margin-left: 12px; }

.th-comp-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* PDF section */
.th-pdf-upload-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.th-pdf-list { display: flex; flex-direction: column; gap: 6px; }

.th-pdf-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e5e8ef;
    border-radius: 8px;
    font-size: 13px;
}

.th-pdf-item a { color: #185FA5; text-decoration: none; font-weight: 500; }

/* Save bar at bottom of visit */
.th-save-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e8ef;
}

/* ── Profile Fields ───────────────────────────────────────────── */
.th-profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.th-profile-field { display: flex; flex-direction: column; gap: 4px; }

.th-profile-label {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.th-profile-value {
    font-size: 14px;
    color: #1e293b;
    font-weight: 500;
}

/* ── Holiday / Leave ──────────────────────────────────────────── */
.th-leave-table { width: 100%; }

.th-status-badge {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.th-status-pending { background: #fef3c7; color: #92400e; }
.th-status-approved { background: #dcfce7; color: #166534; }
.th-status-cancelled { background: #fee2e2; color: #991b1b; }
.th-reject-note { font-size: 0.72rem; color: #991b1b; margin-top: 4px; font-style: italic; max-width: 200px; word-break: break-word; }

.th-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.th-modal-backdrop.open { display: flex; }

.th-modal {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    width: 480px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
}

.th-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
}

.th-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

.th-form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.th-form-control {
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    color: #1e293b;
    outline: none;
    width: 100%;
}

.th-form-control:focus { border-color: #185FA5; }

.th-slot-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 6px;
}

.th-slot-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
}

.th-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e5e8ef;
}

/* ── Analytics ────────────────────────────────────────────────── */
.th-analytics-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.th-goals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.th-goals-table th {
    padding: 10px 14px;
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid #e5e8ef;
    text-align: left;
}

.th-goals-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.th-pct-cell {
    font-weight: 700;
    color: #185FA5;
}

.th-chart-container { position: relative; height: 240px; }

.th-remark-item {
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e5e8ef;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #334155;
}

.th-remark-meta {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}

/* ── Activity Tracker ─────────────────────────────────────────── */
.th-at-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}
.th-at-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
#th-at-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.th-at-summary-pill {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
}
.th-at-summary-pill.done    { background: #dcfce7; color: #166534; }
.th-at-summary-pill.pending { background: #f1f5f9; color: #64748b; }
.th-at-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 7px;
    border: 1px solid #e2e8f0;
    background: #fff;
    margin-bottom: 6px;
}
.th-at-row.done {
    border-color: #bbf7d0;
    background: #f0fdf4;
}
.th-at-dept-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}
.th-at-info { flex: 1; min-width: 0; }
.th-at-goal {
    font-size: 11px;
    font-weight: 600;
    color: #1e3a5f;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.th-at-title { font-size: 13px; font-weight: 600; color: #1e293b; }
.th-at-desc  { font-size: 12px; color: #64748b; margin-top: 2px; }
.th-at-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}
.th-at-badge.done    { background: #dcfce7; color: #166534; }
.th-at-badge.pending { background: #f1f5f9; color: #94a3b8; }

/* ── Notifications ────────────────────────────────────────────── */
.th-coord-filter {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.th-coord-chip {
    padding: 5px 16px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.th-coord-chip.active, .th-coord-chip:hover {
    background: #1e3a5f;
    color: #fff;
    border-color: #1e3a5f;
}
.th-coord-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    white-space: nowrap;
    vertical-align: middle;
}

.th-notif-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    height: calc(100vh - 160px);
}

.th-thread-list {
    background: #fff;
    border: 1px solid #e5e8ef;
    border-radius: 12px;
    overflow-y: auto;
}

/* WhatsApp-style patient row */
.th-thread-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.1s;
}
.th-thread-item:hover  { background: #f8fafc; }
.th-thread-item.active { background: #eff6ff; border-left: 3px solid #3b82f6; padding-left: 11px; }

.th-thread-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1e3a5f;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}
.th-thread-info { flex: 1; min-width: 0; }
.th-thread-top  { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.th-thread-mid  { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.th-thread-patient { font-size: 14px; font-weight: 600; color: #1e293b; }
.th-thread-time    { font-size: 11px; color: #94a3b8; white-space: nowrap; flex-shrink: 0; }
.th-thread-code    { font-size: 11px; color: #94a3b8; }
.th-thread-preview {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Channel tabs inside chat panel */
.th-chat-channel-tabs {
    display: flex;
    border-bottom: 1px solid #e5e8ef;
    background: #f8fafc;
    flex-shrink: 0;
}
.th-channel-tab {
    padding: 9px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.12s;
}
.th-channel-tab.active {
    color: #1e3a5f;
    border-bottom-color: #1e3a5f;
    font-weight: 700;
}
.th-channel-tab:hover:not(.active) { color: #1e293b; }

/* Chat header avatar */
.th-chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1e3a5f;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Bubble alignment wrapper */
.th-bubble-wrap          { display: flex; flex-direction: column; }
.th-bubble-wrap.outgoing { align-items: flex-end; }
.th-bubble-wrap.incoming { align-items: flex-start; }

.th-chat-panel {
    background: #fff;
    border: 1px solid #e5e8ef;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.th-chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid #e5e8ef;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}

.th-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.th-chat-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.th-bubble-therapist {
    background: #185FA5;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.th-bubble-other {
    background: #f1f5f9;
    color: #334155;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.th-bubble-meta {
    font-size: 10px;
    opacity: 0.65;
    margin-top: 3px;
}

.th-chat-input-bar {
    padding: 12px 16px;
    border-top: 1px solid #e5e8ef;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.th-chat-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    resize: none;
    outline: none;
    max-height: 80px;
}

.th-chat-input:focus { border-color: #185FA5; }

.th-chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: #94a3b8;
    font-size: 13px;
}

/* ── Misc ─────────────────────────────────────────────────────── */
.th-empty {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
    font-size: 14px;
}

.th-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: #185FA5;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.th-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.th-toast.show { opacity: 1; }

/* ── Print-style inline doctor report layout ─────────────────────────────── */

.rp-inline-wrap {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #111;
}
.rp-inline-wrap .rp-page-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ddd;
    margin-bottom: 6px;
}
.rp-inline-wrap .rp-logo { height: 52px; object-fit: contain; flex-shrink: 0; }
.rp-inline-wrap .rp-org  { font-size: 16px; font-weight: bold; color: #1a1a1a; flex: 1; }
.rp-inline-wrap .rp-title {
    text-align: center;
    font-size: 19px;
    font-weight: bold;
    color: #1565C0;
    letter-spacing: 1px;
    margin: 8px 0 4px;
}
.rp-meta-edit-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #333;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 6px;
}
.rp-meta-input {
    border: 1px dashed #94a3b8;
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 12px;
    color: #111;
    background: transparent;
    font-family: inherit;
}
.rp-meta-input:focus {
    border-color: #1565C0;
    border-style: solid;
    outline: none;
    background: #f0f7ff;
}
.rp-inline-wrap .rp-box { border: 1px solid #bbb; margin-bottom: 7px; }
.rp-inline-wrap .rp-patient-box { min-height: 55px; }
.rp-inline-wrap .rp-label {
    font-weight: bold;
    font-size: 12px;
    padding: 6px 11px 4px;
    border-bottom: 1px solid #e2e2e2;
    background: #fafafa;
}
.rp-inline-wrap .rp-sub-label {
    padding-left: 22px;
    font-weight: 600;
    font-style: italic;
    color: #444;
    background: #f5f8ff;
}
.rp-inline-wrap .rp-assess        { display: flex; flex-direction: column; gap: 1px; background: #f0f0f0; }
.rp-inline-wrap .rp-assess-main   { font-weight: bold; font-size: 12.5px; color: #111; }
.rp-inline-wrap .rp-assess-sub    { font-size: 10.5px; font-weight: 600; text-transform: uppercase; color: #333; letter-spacing: .04em; }
.rp-inline-wrap .rp-content       { padding: 9px 11px; min-height: 36px; font-size: 12px; line-height: 1.55; }

.rp-content-edit {
    display: block;
    width: 100%;
    min-height: 48px;
    resize: vertical;
    border: none;
    border-top: 1px solid #ececec;
    outline: none;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    padding: 9px 11px;
    background: transparent;
    box-sizing: border-box;
    line-height: 1.6;
    color: #111;
}
.rp-content-edit:focus {
    background: #fffff8;
    outline: 2px solid #bfdbfe;
    outline-offset: -2px;
}
