:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, .10);
    --accent: #0d9488;
    --accent-soft: rgba(13, 148, 136, .12);
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #0f1b2d;
    --muted: #64748b;
    --border: #e9edf4;
    --sidebar-bg: #0f172a;
    --sidebar-muted: #97a3ba;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 8px 24px rgba(15, 27, 45, .05);
    --shadow-hover: 0 2px 6px rgba(15, 27, 45, .08), 0 14px 34px rgba(15, 27, 45, .08);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

/* Sidebar */
.sidebar {
    width: 252px;
    background: linear-gradient(180deg, #111c31 0%, #0b1220 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 22px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -.01em;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: grid;
    place-items: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}
.nav { display: flex; flex-direction: column; padding: 16px 12px; gap: 3px; 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;
    position: relative;
    transition: background .15s ease, color .15s ease;
}
.nav-item i { font-size: 20px; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active {
    background: rgba(37, 99, 235, .18);
    color: #fff;
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, var(--primary), var(--accent));
}
.nav-item.active i { color: #7ab0ff; }
.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: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(1.6) blur(8px);
    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-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h1 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.hamburger {
    display: none;
    border: none;
    background: var(--bg);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text);
    font-size: 22px;
    place-items: center;
    flex-shrink: 0;
}
.hamburger:hover { color: var(--primary); }
/* Backdrop del drawer movil (oculto en escritorio) */
.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 27, 45, .5);
    z-index: 55;
}
.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);
    transition: transform .16s ease, box-shadow .16s ease;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 26px;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(15, 27, 45, .18);
}
.kpi-blue { background: #3b82f6; }
.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[hidden] { display: none; }
.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;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
    transition: background .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 18px rgba(37, 99, 235, .32); }
.btn-primary:active { transform: translateY(1px); }
.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(37, 99, 235, .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, #0b1220 0%, #143a8c 55%, #0d9488 130%);
    padding: 20px;
}
.auth-card {
    background: var(--surface);
    border-radius: 18px;
    padding: 40px;
    width: 390px;
    max-width: 100%;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-mark {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: inline-grid;
    place-items: center;
    font-size: 28px;
    color: #fff;
    box-shadow: 0 10px 26px rgba(37, 99, 235, .4);
}
.auth-brand h1 { font-size: 21px; margin: 14px 0 4px; letter-spacing: -.01em; }
.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, #3b82f6, #2563eb);
    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(37, 99, 235, .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; }
/* Aviso dentro de un formulario (paciente provisional del bot, por ejemplo).
   Lleva display:flex, asi que necesita su propio [hidden] o se sigue viendo. */
.form-note {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 13px; line-height: 1.45; color: #8a6116;
    background: #fdf6e3; border: 1px solid #f2e3bd; border-radius: 8px;
    padding: 10px 12px; margin-bottom: 16px;
}
.form-note[hidden] { display: none; }
.form-note i { font-size: 16px; flex-shrink: 0; }
.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(37, 99, 235, .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); }
/* Subtitulo dentro del panel de antecedentes (madre / nacimiento) */
.hx-sub {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text);
    margin: 4px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}
.hx-sub i { color: var(--primary); }
.hx-block + .hx-sub { margin-top: 22px; }
/* Separador de secciones dentro de un modal largo */
.form-section {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin: 10px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.form-hint { font-size: 12px; color: var(--muted); margin-top: -4px; }
.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(37, 99, 235, .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(37, 99, 235,.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(37, 99, 235, .08); }
.conv-empty { padding: 20px; }
.avatar-sm {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(37, 99, 235,.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; word-break: break-word; overflow-wrap: anywhere; }
.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: 260px; max-height: 320px; width: 100%; object-fit: cover;
    border-radius: 8px; display: block; margin-bottom: 6px; cursor: zoom-in;
}
.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; }
    /* Bandeja en movil: se muestra la lista O el chat, nunca los dos apilados.
       Con `height: auto` el hilo quedaba tras la lista y habia que scrollear
       toda la pagina para llegar al chat y al campo de respuesta. */
    .inbox {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        /* 64px topbar + el padding vertical de .content (20px arriba y abajo) */
        height: calc(100dvh - 64px - 40px);
        min-height: 0;
    }
    .inbox > .inbox-list,
    .inbox > .inbox-thread,
    .inbox > .inbox-empty { grid-area: 1 / 1; min-width: 0; }
    .inbox-list { border-right: none; }
    .inbox.thread-open .inbox-list { display: none; }
    .inbox:not(.thread-open) .inbox-thread { display: none; }
    .inbox-empty { display: none; }

    .thread-back { display: inline-grid; }
    .thread-head { position: sticky; top: 0; z-index: 2; background: var(--surface); }
    .thread-messages { -webkit-overflow-scrolling: touch; }
    /* El teclado del celular no debe tapar el campo de respuesta. */
    .thread-reply { position: sticky; bottom: 0; background: var(--surface); }
    .thread-reply input { font-size: 16px; }  /* <16px hace que iOS haga zoom */
    .thread-note { display: none; }
    .panel-grid { grid-template-columns: 1fr; }
    .panel-wide { grid-column: span 1; }

    /* Sidebar como drawer deslizable */
    .hamburger { display: grid; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        width: 260px;
        max-width: 82vw;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, .35);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .nav-backdrop { display: block; }
    body.nav-open { overflow: hidden; }

    .topbar { padding: 0 20px; }
    .content { padding: 20px; }
    .user-name { display: none; }

    /* Aire dentro de la bandeja: en pantalla chica el contenido quedaba
       pegado a los bordes de la tarjeta. */
    .conv-item { padding: 14px 16px; }
    .thread-head { padding: 12px 14px; }
    .thread-messages { padding: 16px 14px; gap: 12px; }
    .msg { max-width: 82%; padding: 10px 14px; }
    .thread-reply { padding: 12px 14px; gap: 8px; }
    .reply-attach { padding: 8px 14px 0; }
}

@media (max-width: 560px) {
    .page-actions { flex-direction: column; align-items: stretch; }
    .search-box input, .input-icon input { width: 100%; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .module-grid { grid-template-columns: 1fr; }
    .data-table { display: block; overflow-x: auto; white-space: nowrap; }
    .modal-overlay { padding: 20px 12px; }

    /* En telefonos angostos el margen lateral se achica un poco para que la
       tarjeta no quede demasiado estrecha, pero sin pegarse al borde. */
    .topbar { padding: 0 16px; }
    .content { padding: 16px; }
    .inbox { height: calc(100dvh - 64px - 32px); }
}

/* Boton de estado del bot en la bandeja de conversaciones */
[data-thread-bot].bot-on { color: #16a34a; }
[data-thread-bot].bot-off { color: #d97706; }

/* "Volver a la lista": solo en movil, donde lista y chat se alternan. */
.thread-back { display: none; margin-right: 2px; }

/* Burbuja optimista: se ve apenas se toca enviar, atenuada hasta que el
   servidor confirma. Si el envio falla, queda marcada en rojo. */
.msg.is-pending { opacity: .6; }
.msg.is-failed { opacity: 1; background: #ef4444; }
.msg.is-failed .msg-meta { opacity: .95; font-weight: 600; }
.thread-reply button[type="submit"][disabled] { opacity: .5; cursor: default; }

/* Consulta medica: signos vitales y recetas */
.vitals-grid { grid-template-columns: repeat(3, 1fr); }
.vitals-timeline { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.vs-item {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
    padding: 12px 14px;
}
.vs-head { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.vs-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.vs-chip {
    display: inline-flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: 8px;
    padding: 5px 11px;
    min-width: 64px;
}
.vs-chip small { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.vs-chip b { font-size: 14px; font-variant-numeric: tabular-nums; }
.vs-notes { margin-top: 8px; font-size: 13px; color: var(--muted); }
.rx-list { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.rx-meds { list-style: none; margin: 8px 0; display: flex; flex-direction: column; gap: 4px; }
.rx-meds li { font-size: 14px; padding-left: 14px; position: relative; }
.rx-meds li::before { content: "Rp/"; position: absolute; left: -18px; color: var(--primary); font-weight: 700; font-size: 11px; }
.rx-ind { font-size: 13px; color: var(--muted); margin-top: 6px; }

@media (max-width: 900px) {
    .vitals-grid { grid-template-columns: 1fr 1fr; }
}
.rx-indications {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    margin-top: 14px;
}
.rx-indications textarea {
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    resize: vertical;
    outline: none;
}
.rx-indications textarea:focus { border-color: var(--primary); }

/* Configuracion: modulos */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.module-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: box-shadow .15s ease, opacity .15s ease;
}
.module-card:hover { box-shadow: var(--shadow); }
.module-card.is-off { opacity: .6; }
.module-ico {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 24px;
    color: var(--primary);
    background: var(--primary-soft);
    flex-shrink: 0;
}
.module-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.module-info strong { font-size: 14px; }
.module-info .muted { font-size: 12px; word-break: break-all; }
.module-info .chip { align-self: flex-start; margin-top: 4px; }
.module-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute;
    inset: 0;
    background: #cbd3e0;
    border-radius: 24px;
    transition: background .18s ease;
}
.switch .slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .18s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: .6; cursor: default; }

/* Modal expediente en la bandeja de conversaciones */
.exp-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.exp-head .patient-avatar { width: 52px; height: 52px; font-size: 28px; }
.exp-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 20px;
    background: var(--bg);
    border-radius: 10px;
    padding: 14px 16px;
}
.exp-grid > div { display: flex; flex-direction: column; font-size: 14px; font-weight: 600; }
.exp-lbl { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 500; letter-spacing: .03em; }
#expediente-modal .note-item { margin-bottom: 8px; }
#expediente-modal .tag-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }

/* ============ Agenda: calendario mes / semana / dia ============ */
.cal-actions { align-items: center; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.01em;
    margin-left: 6px;
    text-transform: capitalize;
}
.cal-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.cal-select {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 10px;
    padding: 9px 12px;
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    min-width: 190px;
}
.seg-group {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}
.seg-group .seg {
    border: 0;
    background: transparent;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.seg-group .seg:hover { color: var(--text); }
.seg-group .seg.is-active { background: var(--primary); color: #fff; }

.cal-panel { padding: 0; overflow: hidden; }
.cal-loading { padding: 40px; text-align: center; color: var(--muted); }
.cal-loading[hidden] { display: none; }
.cal-month[hidden], .cal-time[hidden], .cal-list[hidden] { display: none; }
.cal-list { padding: 4px 0; }

/* Vista mes */
.cal-dow {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.cal-dow div {
    /* Centrado sobre su columna. El padding lateral de 12px lo empujaba a la
       izquierda, asi que el nombre del dia no caia sobre su columna sino
       pegado al borde. */
    padding: 10px 0;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
    min-height: 118px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 6px 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    transition: background .12s ease;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--primary-soft); }
.cal-cell.is-out { background: #fbfcfe; }
.cal-cell.is-out .cal-daynum { color: #b6c0d0; }
.cal-daynum {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    width: 24px;
    height: 24px;
    /* La celda es un flex column: sin align-self la pastilla de 24px se pega a
       la izquierda. Centrada queda bajo el nombre del dia que encabeza. */
    align-self: center;
    display: grid;
    place-items: center;
    border-radius: 50%;
    pointer-events: none;
}
.cal-cell.is-today .cal-daynum { background: var(--primary); color: #fff; }
/* Dia con turno de hospital, vacaciones o ausencia: no se agenda nada ahi. */
.cal-cell.is-blocked { background: repeating-linear-gradient(
    135deg, #fff7ed, #fff7ed 8px, #fdf0e0 8px, #fdf0e0 16px); }
.cal-cell.is-blocked:hover { background: #fdebd6; }
.cal-block {
    display: flex; align-items: center; gap: 4px;
    padding: 2px 6px; border-radius: 5px;
    background: #f7dcbb; color: #8a5a16;
    font-size: 11px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-block i { font-size: 12px; flex-shrink: 0; }
.cal-cell-items { display: flex; flex-direction: column; gap: 3px; }
.cal-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    border: 0;
    border-left: 3px solid var(--primary);
    background: var(--primary-soft);
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
    text-align: left;
    padding: 3px 6px;
    border-radius: 5px;
    cursor: pointer;
    overflow: hidden;
}
.cal-chip:hover { filter: brightness(.96); }
.chip-time { font-weight: 700; font-size: 11px; flex-shrink: 0; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-more {
    border: 0;
    background: transparent;
    color: var(--primary);
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    text-align: left;
    padding: 1px 6px;
    cursor: pointer;
}

/* Vista semana / dia */
.cal-time { display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.cal-time-head { display: flex; border-bottom: 1px solid var(--border); background: var(--bg); }
.cal-gutter { width: 62px; flex-shrink: 0; }
.cal-time-days { display: grid; grid-template-columns: repeat(var(--cols, 7), 1fr); flex: 1; }
.cal-dayhead {
    padding: 8px 6px;
    text-align: center;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cal-dayhead span {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
}
.cal-dayhead strong { font-size: 17px; }
.cal-dayhead.is-today strong { color: var(--primary); }
.cal-time-body { display: flex; overflow-y: auto; flex: 1; }
.cal-hour {
    font-size: 11px;
    color: var(--muted);
    text-align: right;
    padding: 2px 8px 0 0;
    border-top: 1px solid var(--border);
}
.cal-time-cols {
    display: grid;
    grid-template-columns: repeat(var(--cols, 7), 1fr);
    flex: 1;
}
.cal-col { position: relative; border-left: 1px solid var(--border); }
.cal-slot { border-top: 1px solid var(--border); cursor: pointer; }
.cal-slot:hover { background: var(--primary-soft); }
.cal-event {
    position: absolute;
    border: 0;
    border-left: 3px solid var(--primary);
    background: var(--primary-soft);
    color: var(--text);
    font-family: var(--font);
    text-align: left;
    padding: 3px 6px;
    border-radius: 6px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1px;
    box-shadow: 0 1px 3px rgba(15, 27, 45, .10);
}
.cal-event:hover { filter: brightness(.96); z-index: 3; }
.cal-event.is-short { flex-direction: row; align-items: baseline; gap: 6px; padding: 2px 6px; }
.cal-event.is-short .ev-meta { display: none; }
.ev-time { font-size: 10px; font-weight: 700; }
.ev-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-meta { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Color por estado */
.cal-chip.st-confirmed, .cal-event.st-confirmed { border-left-color: var(--accent); background: var(--accent-soft); }
.cal-chip.st-completed, .cal-event.st-completed { border-left-color: #16a34a; background: rgba(22, 163, 74, .12); }
.cal-chip.st-checked_in, .cal-event.st-checked_in,
.cal-chip.st-in_progress, .cal-event.st-in_progress { border-left-color: #f59e0b; background: rgba(245, 158, 11, .14); }
.cal-chip.st-cancelled, .cal-event.st-cancelled,
.cal-chip.st-no_show, .cal-event.st-no_show {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, .10);
    opacity: .72;
}
.cal-chip.st-cancelled .chip-name, .cal-event.st-cancelled .ev-name { text-decoration: line-through; }

/* Reprogramada: se distingue de una cita normal y avisa el horario anterior. */
.cal-chip.st-rescheduled, .cal-event.st-rescheduled {
    border-left-color: #d97706;
    background: rgba(217, 119, 6, .14);
    border-left-style: dashed;
}
.cal-chip.st-rescheduled .chip-name, .cal-event.st-rescheduled .ev-name { font-style: italic; }
.ev-moved, .chip-moved {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    color: #b45309;
}
.ev-moved i, .chip-moved i { font-size: 12px; }
.detail-moved { color: #b45309; font-weight: 600; }

/* Detalle de cita */
.detail-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px 16px;
    margin-bottom: 18px;
}
.detail-list dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.detail-list dd { font-size: 14px; font-weight: 600; text-transform: capitalize; }
.muted-text { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
    .cal-tools { margin-left: 0; width: 100%; }
    .cal-select { flex: 1; min-width: 0; }
    .cal-cell { min-height: 84px; }
    .chip-name { display: none; }
    .cal-gutter { width: 44px; }
}

/* --- Configuracion: horarios de la clinica y de cada profesional --- */
/* Consultas frecuentes: pregunta corta, respuesta larga y boton de quitar. */
.faq-row { grid-template-columns: 1fr 2fr auto; }
@media (max-width: 720px) {
    .faq-row { grid-template-columns: 1fr auto; }
    .faq-row input[name="respuesta"] { grid-column: 1 / -1; }
}

.sched-block { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 16px; }
.sched-label { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 8px; }
.hour-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.hour-chip {
    border: 1px solid var(--border); background: var(--surface); color: var(--muted);
    border-radius: 999px; padding: 5px 12px; font-size: 12px; font-family: var(--font);
    cursor: pointer; transition: all .15s ease;
}
.hour-chip:hover { border-color: var(--primary); color: var(--primary); }
.hour-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.sched-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.sched-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.sched-head strong { font-size: 15px; }
.sched-own { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.sched-head .btn-ghost { margin-left: auto; }
.sched-day { display: grid; grid-template-columns: 92px 1fr; align-items: start; gap: 10px; }
.sched-day > span { font-size: 13px; color: var(--muted); padding-top: 6px; }
.sched-days[hidden] { display: none; }
@media (max-width: 720px) {
    .sched-day { grid-template-columns: 1fr; }
    .sched-head .btn-ghost { margin-left: 0; }
}

/* --- Revision de expedientes creados por el bot --- */
.review-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.review-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.review-head strong { font-size: 15px; }
.review-head .review-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.review-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.review-motivos { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.review-motivos li {
    font-size: 13px; background: var(--bg); border-left: 3px solid #d97706;
    border-radius: 6px; padding: 7px 11px;
}
.review-appts { width: 100%; margin-top: 12px; font-size: 13px; border-collapse: collapse; }
.review-appts th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 6px 8px; }
.review-appts td { padding: 7px 8px; border-top: 1px solid var(--border); }
.review-thread {
    height: 55vh; overflow-y: auto; padding: 16px; background: var(--bg);
    display: flex; flex-direction: column; gap: 10px;
}
@media (max-width: 720px) {
    .review-head .review-actions { margin-left: 0; width: 100%; }
    .review-appts thead { display: none; }
    .review-appts td { display: block; border-top: 0; padding: 2px 0; }
    .review-appts tr { display: block; border-top: 1px solid var(--border); padding: 8px 0; }
}
