:root {
    --primary: #1366d6;
    --primary-dark: #0f4fa8;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --text: #1b2433;
    --muted: #6b7588;
    --border: #e6e9f0;
    --sidebar-bg: #0e1b33;
    --sidebar-muted: #93a0bd;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(18, 32, 64, .08), 0 6px 16px rgba(18, 32, 64, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

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

/* Sidebar */
.sidebar {
    width: 248px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px;
    font-weight: 600;
    font-size: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand i { color: var(--primary); }
.nav { display: flex; flex-direction: column; padding: 14px 12px; gap: 4px; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: var(--sidebar-muted);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    transition: all .15s ease;
}
.nav-item i { font-size: 20px; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-badge {
    margin-left: auto;
    background: #e0524f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 7px;
    min-width: 18px;
    text-align: center;
}
.nav-badge[hidden] { display: none; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn {
    border: none;
    background: var(--bg);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--muted);
    font-size: 20px;
    display: grid;
    place-items: center;
}
.icon-btn:hover { color: var(--primary); }
.avatar { font-size: 32px; color: var(--muted); display: grid; place-items: center; }
.content { padding: 28px; }

/* KPI cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
}
.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 26px;
    color: #fff;
    flex-shrink: 0;
}
.kpi-blue { background: #2f6bff; }
.kpi-green { background: #1fa971; }
.kpi-purple { background: #7b54e0; }
.kpi-teal { background: #0fa3a3; }
.kpi-orange { background: #ef8a2b; }
.kpi-red { background: #e0524f; }
.kpi-indigo { background: #4a55c4; }
.kpi-amber { background: #d6a514; }
.kpi-body { display: flex; flex-direction: column; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 22px; font-weight: 700; }

/* Panels */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-wide { grid-column: span 2; }
.panel-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.panel-head h2 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-head i { color: var(--primary); }
.panel-body { padding: 20px; }
.chart-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 200px;
    color: var(--muted);
}
.chart-placeholder i { font-size: 44px; opacity: .4; }

/* Page actions */
.page-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 12px;
}
.search-box, .input-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 14px;
    color: var(--muted);
}
.search-box input, .input-icon input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: var(--text);
    width: 220px;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 12px;
    cursor: pointer;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.btn-ghost:hover { color: var(--primary); border-color: var(--primary); }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: 14px 20px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.data-table td { padding: 14px 20px; border-bottom: 1px solid var(--border); }

/* Empty states */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    padding: 30px;
}
.empty-state i { font-size: 40px; opacity: .4; }
.empty-state-lg { padding: 70px 30px; }
.empty-state-lg i { font-size: 56px; }

/* Reports */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.report-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(19, 102, 214, .1);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 24px;
    margin-bottom: 14px;
}
.report-card h3 { font-size: 15px; margin-bottom: 14px; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report-pdf i { color: #e0524f; }
.report-filter {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: 12px; color: var(--muted); }
.filter-field input {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    outline: none;
}
.filter-note { margin-left: auto; font-size: 12px; }

/* Auth */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0e1b33, #1366d6);
}
.auth-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 38px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand i { color: var(--primary); }
.auth-brand h1 { font-size: 20px; margin: 8px 0 4px; }
.auth-brand p { color: var(--muted); font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.auth-form .input-icon input { width: 100%; }

/* User chip */
.user-name { font-size: 13px; color: var(--muted); font-weight: 500; }

/* Bar charts */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    height: 200px;
    padding-top: 10px;
}
.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    gap: 8px;
}
.bar {
    width: 100%;
    max-width: 46px;
    background: linear-gradient(180deg, #2f6bff, #1366d6);
    border-radius: 6px 6px 0 0;
    min-height: 4px;
}
.bar-label {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    word-break: break-word;
}
.chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 180px;
    color: var(--muted);
}
.chart-empty i { font-size: 36px; opacity: .4; }

/* Badges */
.badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-active { background: rgba(31, 169, 113, .15); color: #1fa971; }
.badge-inactive { background: rgba(214, 165, 20, .15); color: #b9890a; }
.badge-archived { background: rgba(107, 117, 136, .15); color: var(--muted); }
.badge-ok { background: rgba(31, 169, 113, .15); color: #1fa971; }
.badge-info { background: rgba(19, 102, 214, .12); color: var(--primary); }
.badge-warn { background: rgba(214, 165, 20, .15); color: #b9890a; }
.badge-bad { background: rgba(224, 82, 79, .15); color: #e0524f; }
.badge-muted { background: rgba(107, 117, 136, .15); color: var(--muted); }

/* Row action buttons */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions .btn-ghost { padding: 5px 9px; font-size: 12px; }
.text-right { text-align: right; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Dynamic line items (treatment / invoice) */
.line-items { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.line-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 8px;
    align-items: center;
}
.line-row input, .line-row select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    outline: none;
    font-size: 13px;
}
.line-row .btn-ghost { padding: 7px 9px; }
.add-line { margin-top: 4px; align-self: flex-start; }
.modal-total { text-align: right; font-weight: 700; margin-top: 10px; }
.section-mini {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin: 18px 0 6px;
}
.modal-sm { max-width: 460px; }
.modal-lg { max-width: 860px; }
.no-pad { padding: 0 !important; }
.admin-panel { margin-bottom: 20px; }
.check-inline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

/* Report modal */
.table-scroll { max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.report-totals { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.total-chip {
    background: var(--bg);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--muted);
}
.total-chip strong { color: var(--text); }

/* Integration banner + hints */
.integration-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(214, 165, 20, .12);
    border: 1px solid rgba(214, 165, 20, .35);
    color: #8a6d0a;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
}
.integration-banner i { font-size: 20px; }
.hint-amen { font-size: 12px; color: var(--muted); margin-top: 10px; }
.hint-amen code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 12px;
}
.modal-form textarea {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
}
.modal-form textarea:focus { border-color: var(--primary); }
.media-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}
.media-preview[hidden] { display: none; }
.integration-banner[hidden] { display: none; }
.media-preview img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border);
}

/* Auth extras */
.auth-error { color: #e0524f; font-size: 13px; min-height: 16px; text-align: center; }
.auth-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14, 27, 51, .5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 20px;
    z-index: 50;
    overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 640px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.modal-head i { color: var(--primary); }
.modal-form { padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label, .modal-form > label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}
.form-grid input, .form-grid select, .note-form input, .note-form select {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 14px;
    color: var(--text);
    outline: none;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--primary); }
.form-wide { grid-column: span 2; }
.form-error { color: #e0524f; font-size: 13px; min-height: 16px; margin-top: 10px; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* Detail page */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 16px;
    font-weight: 500;
}
.back-link:hover { color: var(--primary); }
.patient-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 22px;
    margin-bottom: 18px;
}
.patient-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(19, 102, 214, .12);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 34px;
}
.patient-id-block h2 { font-size: 20px; margin-bottom: 6px; }
.chip {
    background: var(--bg);
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 12px;
    color: var(--muted);
    margin-right: 6px;
}
.patient-meta {
    margin-left: auto;
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 10px 26px;
}
.patient-meta dt { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.patient-meta dd { font-size: 14px; font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.muted-note { font-size: 12px; color: var(--muted); }

.problem-list, .tag-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.tag-list { flex-direction: row; flex-wrap: wrap; }
.problem-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.problem-list .num { color: var(--primary); font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }
.tag { padding: 4px 10px; border-radius: 16px; font-size: 12px; background: var(--bg); }
.tag-severe { background: rgba(224, 82, 79, .15); color: #e0524f; }
.tag-moderate { background: rgba(214, 165, 20, .15); color: #b9890a; }
.tag-mild { background: rgba(31, 169, 113, .15); color: #1fa971; }

/* Antecedentes medicos */
.history-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.hx-chip {
    background: var(--bg);
    border-radius: 10px;
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 130px;
}
.hx-chip span { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
.hx-chip strong { font-size: 15px; }
.hx-block { margin-bottom: 16px; }
.hx-block h4 {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.hx-block h4 i { color: var(--primary); }
.check-row { display: flex; gap: 16px; align-items: center; padding-top: 6px; }

.inline-form { display: flex; gap: 8px; margin-top: 14px; }
.inline-form input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 9px 12px;
    outline: none;
}
.note-form { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 18px; }

.note-timeline { display: flex; flex-direction: column; gap: 12px; }
.note-item {
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 10px;
    padding: 14px 16px;
}
.note-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.note-meta .folio { font-weight: 700; font-size: 13px; }
.note-type {
    background: rgba(19, 102, 214, .1);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
}
.note-body { font-size: 14px; line-height: 1.5; }
.note-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}

.tooth-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.tooth {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 600;
}
.tooth-existing { background: rgba(107, 117, 136, .12); }
.tooth-required { background: rgba(224, 82, 79, .15); color: #e0524f; border-color: #e0524f; }
.tooth-executed { background: rgba(31, 169, 113, .15); color: #1fa971; border-color: #1fa971; }

/* Odontograma interactivo */
.odo-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.odo-layers { display: flex; gap: 6px; }
.layer-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.layer-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.odo-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.cond-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
}
.cond-btn.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(19,102,214,.15); }
.cond-btn .sw { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); }
.sw-healthy { background: repeating-linear-gradient(45deg,#fff,#fff 3px,#e6e9f0 3px,#e6e9f0 6px); }

.odo-chart {
    background: var(--bg);
    border-radius: 12px;
    padding: 18px 12px;
    overflow-x: auto;
}
.odo-row { display: flex; gap: 6px; justify-content: center; min-width: max-content; }
.odo-divider { height: 1px; background: var(--border); margin: 12px 24px; }
.odo-tooth { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.odo-num {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}
.odo-num:hover { color: var(--primary); }
.odo-fdi {
    display: grid;
    grid-template-columns: repeat(3, 12px);
    grid-template-rows: repeat(3, 12px);
    width: 36px;
    height: 36px;
    border: 1px solid #c7cdda;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}
.odo-fdi.odo-whole { outline: 2px solid var(--primary); }
.odo-surface { border: 0.5px solid #e6e9f0; cursor: pointer; }
.odo-surface:hover { outline: 1px solid var(--primary); outline-offset: -1px; }
.odo-buccal { grid-area: 1 / 2 / 2 / 3; }
.odo-mesial { grid-area: 2 / 1 / 3 / 2; }
.odo-occlusal { grid-area: 2 / 2 / 3 / 3; }
.odo-distal { grid-area: 2 / 3 / 3 / 4; }
.odo-lingual { grid-area: 3 / 2 / 4 / 3; }
.odo-hint { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* Inbox / conversaciones */
.inbox {
    display: grid;
    grid-template-columns: 320px 1fr;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    height: calc(100vh - 64px - 56px);
    min-height: 480px;
}
.inbox-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.inbox-search {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--muted);
}
.inbox-search input { flex: 1; border: none; outline: none; background: transparent; font-size: 14px; }
.conv-items { list-style: none; overflow-y: auto; flex: 1; }
.conv-item {
    display: flex; gap: 10px; padding: 12px 14px; cursor: pointer;
    border-bottom: 1px solid var(--border); align-items: center;
}
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: rgba(19, 102, 214, .08); }
.conv-empty { padding: 20px; }
.avatar-sm {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(19,102,214,.12); color: var(--primary);
    display: grid; place-items: center; font-size: 22px; flex-shrink: 0;
}
.conv-main { min-width: 0; flex: 1; }
.conv-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-top strong { font-size: 14px; }
.conv-prev { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread {
    background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
    border-radius: 10px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.inbox-thread { display: flex; flex-direction: column; min-height: 0; }
.inbox-thread[hidden] { display: none; }
.inbox-empty[hidden] { display: none; }
.thread-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.thread-contact { display: flex; align-items: center; gap: 10px; }
.thread-contact strong { display: block; font-size: 14px; }
.thread-messages {
    flex: 1; overflow-y: auto; padding: 18px;
    display: flex; flex-direction: column; gap: 10px; background: var(--bg);
}
.msg { max-width: 70%; padding: 9px 13px; border-radius: 12px; font-size: 14px; }
.msg-in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-out { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-media { max-width: 220px; border-radius: 8px; display: block; margin-bottom: 6px; }
.msg-meta { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; font-size: 10px; opacity: .7; }
.msg-author { font-weight: 600; }
.thread-reply { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.thread-reply input {
    flex: 1; border: 1px solid var(--border); border-radius: 22px;
    padding: 10px 16px; outline: none; font-size: 14px;
}
.thread-reply input:focus { border-color: var(--primary); }
.thread-note { padding: 0 18px 12px; font-size: 11px; }
.attach-btn { cursor: pointer; flex-shrink: 0; }
.reply-attach {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px 0;
}
.reply-attach[hidden] { display: none; }
.reply-attach img {
    width: 56px; height: 56px; object-fit: cover;
    border-radius: 8px; border: 1px solid var(--border);
}
.inbox-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; color: var(--muted);
}
.inbox-empty i { font-size: 56px; opacity: .35; }

@media (max-width: 900px) {
    .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .form-wide { grid-column: span 1; }
    .patient-header { flex-wrap: wrap; }
    .patient-meta { margin-left: 0; }
    .inbox { grid-template-columns: 1fr; height: auto; }
    .panel-grid { grid-template-columns: 1fr; }
    .panel-wide { grid-column: span 1; }
    .sidebar { width: 70px; }
    .brand span, .nav-item span { display: none; }
}
