/* ==========================================================================
   CARESUITE — Tema base (identidade visual premium em tons de azul).
   ========================================================================== */

:root {
    /* Paleta principal — azul corporativo */
    --cs-primary: #1e40af;
    --cs-primary-600: #1d4ed8;
    --cs-primary-500: #2563eb;
    --cs-primary-100: #dbeafe;
    --cs-primary-50: #eff6ff;

    --cs-accent: #0ea5e9;
    --cs-success: #059669;
    --cs-warning: #d97706;
    --cs-danger: #dc2626;

    /* Neutros */
    --cs-bg: #f4f7fb;
    --cs-surface: #ffffff;
    --cs-border: #e2e8f0;
    --cs-muted: #64748b;
    --cs-text: #0f172a;
    --cs-text-soft: #334155;

    /* Elevação & raio */
    --cs-radius: 14px;
    --cs-radius-sm: 10px;
    --cs-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --cs-shadow: 0 6px 20px rgba(15, 23, 42, .08);
    --cs-shadow-lg: 0 20px 45px rgba(15, 23, 42, .12);

    /* Layout */
    --cs-sidebar-w: 264px;
    --cs-topbar-h: 68px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body.cs-admin,
body.cs-auth {
    margin: 0;
    background: var(--cs-bg);
    color: var(--cs-text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

/* Override Bootstrap primary */
.btn-primary {
    --bs-btn-bg: var(--cs-primary-600);
    --bs-btn-border-color: var(--cs-primary-600);
    --bs-btn-hover-bg: var(--cs-primary);
    --bs-btn-hover-border-color: var(--cs-primary);
    --bs-btn-focus-shadow-rgb: 37, 99, 235;
    --bs-btn-active-bg: var(--cs-primary);
    --bs-btn-active-border-color: var(--cs-primary);
}

.btn-outline-primary {
    --bs-btn-color: var(--cs-primary-600);
    --bs-btn-border-color: var(--cs-primary-600);
    --bs-btn-hover-bg: var(--cs-primary-600);
    --bs-btn-hover-border-color: var(--cs-primary-600);
}

a {
    color: var(--cs-primary-600);
}

a:hover {
    color: var(--cs-primary);
}

/* ==========================================================================
   Layout administrativo
   ========================================================================== */

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

.cs-sidebar {
    width: var(--cs-sidebar-w);
    background: linear-gradient(180deg, #0f1e4f 0%, #1e3a8a 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    transform: translateX(-100%);
    transition: transform .25s ease;
}

@media (min-width: 992px) {
    .cs-sidebar {
        transform: none;
    }
}

.cs-sidebar.is-open {
    transform: translateX(0);
}

.cs-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.cs-sidebar-brand i {
    font-size: 20px;
    color: #ffffff;
}

.cs-sidebar-brand strong {
    display: block;
    font-size: 17px;
    letter-spacing: .4px;
    color: #fff;
}

.cs-sidebar-brand small {
    display: block;
    color: #94a3b8;
    font-size: 11.5px;
    margin-top: 2px;
}

/* Logo customizado (uploaded) na sidebar */
.cs-sidebar-brand.has-custom-logo {
    justify-content: center;
    padding: 22px 18px;
}

.cs-sidebar-logo {
    display: block;
    max-width: 100%;
    max-height: 56px;
    object-fit: contain;
    /* Cor original por padrão. O filtro de branco vai só quando
       a clínica liga `sidebar_logo_white` em Configurações. */
}

body.cs-logo-white .cs-sidebar-logo {
    filter: brightness(0) invert(1);
}

.cs-sidebar-nav {
    flex: 1;
    padding: 14px 14px 20px;
    overflow-y: auto;
}

.cs-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    margin: 2px 0;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: background .15s, color .15s;
}

.cs-nav-link i {
    font-size: 17px;
    width: 20px;
    text-align: center;
}

.cs-nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.cs-nav-link.active {
    background: rgba(96, 165, 250, .18);
    color: #fff;
    box-shadow: inset 3px 0 0 #02BB6C;
}

.cs-nav-group {
    display: flex;
    flex-direction: column;
}

.cs-nav-toggle {
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.cs-nav-caret {
    font-size: 12px !important;
    width: auto !important;
    transition: transform .15s;
}

.cs-nav-group.open .cs-nav-caret {
    transform: rotate(180deg);
}

/* Grupo pai com página ativa dentro — destaca mesmo se o submenu estiver fechado. */
.cs-nav-group.has-active>.cs-nav-toggle {
    background: rgba(96, 165, 250, .10);
    color: #fff;
    font-weight: 600;
}

.cs-nav-group.has-active>.cs-nav-toggle>i:first-child {
    color: #60a5fa;
}

.cs-nav-submenu {
    display: none;
    flex-direction: column;
    padding-left: 14px;
    margin: 2px 0 4px;
    border-left: 1px solid rgba(255, 255, 255, .08);
}

.cs-nav-group.open .cs-nav-submenu {
    display: flex;
}

.cs-nav-group.has-active .cs-nav-submenu {
    border-left-color: #60a5fa;
}

.cs-nav-sublink {
    font-size: 13px;
    padding: 7px 10px;
}

.cs-nav-sublink i {
    font-size: 14px;
}

.cs-sidebar-footer {
    padding: 14px 22px 22px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #94a3b8;
    font-size: 12px;
}

.cs-env-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(16, 185, 129, .15);
    border: 1px solid rgba(16, 185, 129, .35);
    color: #6ee7b7;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: .5px;
}

/* ----- Main area ----- */

.cs-main {
    flex: 1;
    margin-left: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

@media (min-width: 992px) {
    .cs-main {
        margin-left: var(--cs-sidebar-w);
    }
}

.cs-topbar {
    height: var(--cs-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--cs-border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.cs-topbar-search {
    flex: 1;
    max-width: 520px;
    position: relative;
}

.cs-topbar-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cs-muted);
}

.cs-topbar-search input {
    padding-left: 40px;
    padding-right: 48px;
    background: #f1f5f9;
    border-color: transparent;
    border-radius: 10px;
    height: 42px;
}

.cs-topbar-search input:focus {
    background: #fff;
    border-color: var(--cs-primary-500);
    box-shadow: 0 0 0 4px var(--cs-primary-50);
}

.cs-topbar-search kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border: 1px solid var(--cs-border);
    color: var(--cs-muted);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
}

.cs-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.cs-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cs-primary-600);
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cs-user-btn {
    padding: 6px 12px;
    border-radius: 10px;
}

.cs-content {
    flex: 1;
    padding: 28px 32px;
    max-width: 100%;
}

.cs-footer {
    padding: 16px 32px;
    border-top: 1px solid var(--cs-border);
    background: #fff;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--cs-muted);
}

/* ==========================================================================
   Components: page header, cards, metrics, tables
   ========================================================================== */

.cs-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.cs-page-title {
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--cs-text);
}

.cs-page-subtitle {
    color: var(--cs-muted);
    margin: 0;
    font-size: 14px;
}

.cs-page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cs-card {
    background: var(--cs-surface);
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow-sm);
    overflow: hidden;
}

.cs-card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--cs-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.cs-card-header h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.cs-card-body {
    padding: 22px;
}

.cs-metric-card {
    background: var(--cs-surface);
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--cs-shadow-sm);
    transition: transform .15s, box-shadow .15s;
}

.cs-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--cs-shadow);
}

.cs-metric-icon {
    width: 52px;
    height: 52px;
    background: var(--cs-primary-50);
    color: var(--cs-primary-600);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.cs-metric-label {
    display: block;
    color: var(--cs-muted);
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 600;
}

.cs-metric-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--cs-text);
    margin: 2px 0 4px;
}

.cs-metric-delta {
    font-size: 12px;
    color: var(--cs-success);
    font-weight: 600;
}

.cs-table thead th {
    background: #f8fafc;
    color: var(--cs-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1px solid var(--cs-border);
}

.cs-table tbody td {
    vertical-align: middle;
    color: var(--cs-text-soft);
}

.cs-system-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cs-system-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--cs-border);
    color: var(--cs-muted);
}

.cs-system-list li:last-child {
    border-bottom: 0;
}

.cs-system-list strong {
    color: var(--cs-text);
    font-weight: 600;
}

.cs-log {
    background: #0f172a;
    color: #cbd5e1;
    padding: 14px;
    border-radius: 10px;
    font-size: 12px;
    max-height: 220px;
    overflow: auto;
}

/* ==========================================================================
   Error page
   ========================================================================== */

.cs-error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cs-bg);
    font-family: 'Inter', system-ui, sans-serif;
}

.cs-error-card {
    background: #fff;
    padding: 48px 56px;
    border-radius: 16px;
    box-shadow: var(--cs-shadow-lg);
    text-align: center;
    max-width: 480px;
}

/* ==========================================================================
   DataTable
   ========================================================================== */

.cs-datatable {
    background: var(--cs-surface);
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow-sm);
    overflow: hidden;
}

.cs-dt-toolbar {
    padding: 16px 20px;
    border-bottom: 1px solid var(--cs-border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.cs-dt-search {
    position: relative;
    flex: 1;
    min-width: 260px;
    max-width: 400px;
}

.cs-dt-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cs-muted);
    pointer-events: none;
}

.cs-dt-search input {
    padding-left: 40px;
    background: #f1f5f9;
    border-color: transparent;
    border-radius: 10px;
    height: 40px;
}

.cs-dt-search input:focus {
    background: #fff;
    border-color: var(--cs-primary-500);
    box-shadow: 0 0 0 4px var(--cs-primary-50);
}

.cs-dt-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-left: auto;
}

.cs-dt-filters .form-select,
.cs-dt-filters .form-control {
    height: 40px;
    min-width: 150px;
}

.cs-dt-wrap {
    max-height: calc(100vh - 340px);
}

.cs-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.cs-sortable:hover {
    background: #eef2ff !important;
    color: var(--cs-primary-600);
}

.cs-dt-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--cs-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: #f8fafc;
}

.cs-dt-pagination .page-link {
    color: var(--cs-primary-600);
    border-color: var(--cs-border);
}

.cs-dt-pagination .page-item.active .page-link {
    background: var(--cs-primary-600);
    border-color: var(--cs-primary-600);
    color: #fff;
}

/* ==========================================================================
   Modal / Form premium
   ========================================================================== */

.modal-content {
    border: 0;
    border-radius: 16px;
    box-shadow: var(--cs-shadow-lg);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--cs-border);
}

.modal-header .modal-title {
    font-weight: 700;
    color: var(--cs-text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header .modal-title i {
    color: var(--cs-primary-600);
    font-size: 20px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--cs-border);
    background: #f8fafc;
}

.cs-form-section {
    margin-bottom: 26px;
}

.cs-form-section:last-child {
    margin-bottom: 0;
}

.cs-form-section-title {
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 700;
    color: var(--cs-primary-600);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--cs-primary-50);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--cs-text-soft);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border-radius: 8px;
    border-color: var(--cs-border);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--cs-primary-500);
    box-shadow: 0 0 0 4px var(--cs-primary-50);
}

/* ==========================================================================
   Status badges
   ========================================================================== */

.cs-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .3px;
}

.cs-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.cs-badge-active {
    background: #dcfce7;
    color: #059669;
}

.cs-badge-inactive {
    background: #f1f5f9;
    color: #64748b;
}

.cs-badge-blocked {
    background: #fee2e2;
    color: #b91c1c;
}

.cs-badge-pending {
    background: #fef3c7;
    color: #b45309;
}

/* ==========================================================================
   Row actions
   ========================================================================== */

.cs-row-actions {
    display: inline-flex;
    gap: 4px;
}

.cs-row-actions .btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 8px;
}

/* ==========================================================================
   Empty sidebar nav
   ========================================================================== */

.cs-nav-empty {
    color: #94a3b8;
}

/* ==========================================================================
   Agenda
   ========================================================================== */

.cs-agenda-toolbar {
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    padding: 18px 20px;
    box-shadow: var(--cs-shadow-sm);
    display: grid;
    grid-template-columns: 2fr 1fr auto auto 1.2fr;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.cs-agenda-viewmode {
    min-width: 220px;
}

@media (max-width: 991.98px) {
    .cs-agenda-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .cs-agenda-toolbar>* {
        grid-column: span 1;
    }

    .cs-agenda-toolbar .cs-agenda-doctor {
        grid-column: span 2;
    }

    .cs-agenda-toolbar .cs-agenda-viewmode {
        grid-column: span 2;
    }
}

.cs-agenda-nav {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.cs-agenda-summary {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.cs-summary-pill {
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: 999px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--cs-text-soft);
}

.cs-summary-pill strong {
    font-size: 16px;
    color: var(--cs-text);
}

.cs-summary-pill.pill-available strong {
    color: var(--cs-success);
}

.cs-summary-pill.pill-booked strong {
    color: var(--cs-primary-600);
}

.cs-summary-pill.pill-blocked strong {
    color: var(--cs-warning);
}

.cs-doctor-card {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #fff;
    padding: 18px 22px;
    border-radius: var(--cs-radius);
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.cs-doctor-card .cs-avatar {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, .18);
    font-size: 22px;
}

.cs-doctor-card h3 {
    margin: 0 0 4px;
    font-size: 18px;
    color: #fff;
}

.cs-doctor-card small {
    color: #bfdbfe;
    font-size: 12.5px;
}

.cs-slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.cs-slot {
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s, border-color .12s;
    position: relative;
    overflow: hidden;
}

.cs-slot::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--cs-success);
}

.cs-slot:hover {
    transform: translateY(-2px);
    box-shadow: var(--cs-shadow);
    border-color: var(--cs-primary-500);
}

.cs-slot-time {
    font-size: 18px;
    font-weight: 700;
    color: var(--cs-text);
    margin-bottom: 4px;
}

.cs-slot-status {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 700;
    color: var(--cs-success);
}

.cs-slot-meta {
    font-size: 12.5px;
    color: var(--cs-muted);
    margin-top: 6px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Estados --- */
.cs-slot.is-available::before {
    background: var(--cs-success);
}

.cs-slot.is-available .cs-slot-status {
    color: var(--cs-success);
}

.cs-slot.is-booked {
    background: #eef2ff;
}

.cs-slot.is-booked::before {
    background: var(--cs-primary-600);
}

.cs-slot.is-booked .cs-slot-status {
    color: var(--cs-primary-600);
}

.cs-slot.is-blocked {
    background: #fef3c7;
    cursor: not-allowed;
}

.cs-slot.is-blocked::before {
    background: var(--cs-warning);
}

.cs-slot.is-blocked .cs-slot-status {
    color: var(--cs-warning);
}

.cs-slot.is-blocked:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--cs-border);
}

.cs-slot.is-past {
    opacity: .55;
}

/* Status do agendamento (no slot ocupado e no modal) */
.cs-apt-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .3px;
}

.cs-apt-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.cs-apt-agendado {
    background: #e0e7ff;
    color: #4338ca;
}

.cs-apt-confirmado {
    background: #dbeafe;
    color: #1d4ed8;
}

.cs-apt-aguardando {
    background: #fef3c7;
    color: #b45309;
}

.cs-apt-em_atendimento {
    background: #cffafe;
    color: #0e7490;
}

.cs-apt-finalizado {
    background: #dcfce7;
    color: #059669;
}

.cs-apt-cancelado {
    background: #fee2e2;
    color: #b91c1c;
}

.cs-apt-faltou {
    background: #fee2e2;
    color: #b91c1c;
}

/* Tabela semanal (horários recorrentes) */
.cs-weekday-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.cs-weekday-col {
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: 12px;
    padding: 12px;
    min-height: 140px;
}

.cs-weekday-col h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--cs-primary-600);
    font-weight: 700;
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--cs-primary-50);
}

.cs-weekday-entry {
    background: var(--cs-primary-50);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 12.5px;
    line-height: 1.4;
    cursor: pointer;
}

.cs-weekday-entry:hover {
    background: #dbeafe;
}

.cs-weekday-entry strong {
    display: block;
    color: var(--cs-primary-600);
}

/* ==========================================================================
   Consulta médica
   ========================================================================== */

.cs-consultation {
    margin: -28px -32px 0;
    padding: 0;
}

.cs-consultation-header {
    background: #fff;
    border-bottom: 1px solid var(--cs-border);
    padding: 18px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: var(--cs-topbar-h);
    z-index: 10;
}

.cs-consultation-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--cs-text);
}

.cs-consultation-header .cs-avatar {
    width: 56px;
    height: 56px;
    font-size: 22px;
}

.cs-consultation-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--cs-muted);
    font-size: 13px;
}

.cs-consultation-meta i {
    margin-right: 4px;
    color: var(--cs-primary-600);
}

.cs-consultation-allergies {
    background: #fee2e2;
    color: #b91c1c;
    padding: 4px 12px;
    border-radius: 8px;
    margin-top: 6px;
    display: inline-block;
    font-size: 12.5px;
    font-weight: 600;
}

.cs-autosave-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--cs-success);
    transition: color .2s;
}

.cs-autosave-indicator i {
    font-size: 16px;
}

.cs-consultation-body {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 18px;
    padding: 22px 32px;
}

@media (max-width: 1199.98px) {
    .cs-consultation-body {
        grid-template-columns: 1fr;
    }
}

.cs-consultation-main {
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: var(--cs-radius);
    box-shadow: var(--cs-shadow-sm);
    overflow: hidden;
}

.cs-tabs {
    background: #f8fafc;
    padding: 0 16px;
    border-bottom: 1px solid var(--cs-border);
    flex-wrap: nowrap;
    overflow-x: auto;
}

.cs-tabs .nav-link {
    border: 0;
    color: var(--cs-muted);
    font-weight: 600;
    font-size: 13px;
    padding: 14px 16px;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    white-space: nowrap;
}

.cs-tabs .nav-link.active {
    background: transparent;
    color: var(--cs-primary-600);
    border-bottom-color: var(--cs-primary-600);
}

.cs-tabs .nav-link:hover {
    color: var(--cs-primary-600);
}

.cs-tabs-body {
    padding: 22px 24px;
}

.cs-tabs-body .form-label {
    font-weight: 600;
    font-size: 13px;
}

.cs-readonly textarea,
.cs-readonly input,
.cs-readonly select {
    background: #f8fafc !important;
    cursor: not-allowed;
}

.cs-consultation-sidebar .cs-card {
    position: sticky;
    top: calc(var(--cs-topbar-h) + 100px);
}

.cs-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.cs-history-list li {
    padding: 14px 18px;
    border-bottom: 1px solid var(--cs-border);
    font-size: 13px;
    cursor: pointer;
    transition: background .12s;
}

.cs-history-list li:hover {
    background: #f8fafc;
}

.cs-history-list li:last-child {
    border-bottom: 0;
}

.cs-history-date {
    font-weight: 700;
    color: var(--cs-text);
}

.cs-history-doctor {
    color: var(--cs-muted);
    font-size: 11.5px;
}

.cs-history-cid {
    display: inline-block;
    background: var(--cs-primary-50);
    color: var(--cs-primary-600);
    padding: 1px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    margin-top: 4px;
}

.cs-history-diagnosis {
    color: var(--cs-text-soft);
    margin-top: 4px;
    line-height: 1.4;
}

.cs-exam-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--cs-border);
    border-radius: 10px;
    margin-bottom: 8px;
    background: #f8fafc;
}

/* ==========================================================================
   Prontuário
   ========================================================================== */

.cs-prontuario-header {
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: #fff;
    padding: 24px 28px;
    border-radius: var(--cs-radius);
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.cs-prontuario-header h2 {
    color: #fff;
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 700;
}

.cs-prontuario-header .cs-avatar {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, .2);
    font-size: 26px;
}

.cs-prontuario-header .cs-consultation-meta {
    color: #dbeafe;
}

.cs-prontuario-header .cs-consultation-meta i {
    color: #bfdbfe;
}

.cs-summary-list {
    margin: 0;
}

.cs-summary-list dt {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--cs-muted);
    font-weight: 700;
    margin-top: 14px;
}

.cs-summary-list dt:first-child {
    margin-top: 0;
}

.cs-summary-list dd {
    margin: 4px 0 0;
    color: var(--cs-text);
    font-size: 14px;
}

.cs-timeline {
    position: relative;
    padding-left: 24px;
}

.cs-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--cs-border);
}

.cs-timeline-item {
    position: relative;
    padding-bottom: 18px;
}

.cs-timeline-marker {
    position: absolute;
    left: -22px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--cs-primary-600);
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px var(--cs-primary-50);
}

.cs-timeline-content {
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: 12px;
    padding: 14px 16px;
}

@media print {

    .cs-sidebar,
    .cs-topbar,
    .cs-page-actions,
    .cs-footer {
        display: none !important;
    }

    .cs-main {
        margin-left: 0 !important;
    }

    .cs-content {
        padding: 0 !important;
    }

    .cs-prontuario-header {
        background: #1e40af !important;
        -webkit-print-color-adjust: exact;
    }
}

/* ==========================================================================
   Memed (prescrição eletrônica)
   ========================================================================== */

.cs-memed-banner {
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border: 1px solid #bbf7d0;
    border-radius: 14px;
    padding: 18px 20px;
}

/* ==========================================================================
   Assinatura digital
   ========================================================================== */

.cs-signature-card {
    border: 2px solid var(--cs-border);
    transition: all .15s;
}

.cs-signature-card.is-connected {
    border-color: var(--cs-success);
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 30%);
}

.cs-signature-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.cs-sig-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    background: #dcfce7;
    color: #059669;
}

.cs-sig-badge.is-pending {
    background: #fef3c7;
    color: #b45309;
}

.cs-sig-badge.is-failed {
    background: #fee2e2;
    color: #b91c1c;
}

.cs-sig-badge.is-required {
    background: #fef3c7;
    color: #b45309;
}

/* ==========================================================================
   Relatórios & auditoria (Fase 11)
   ========================================================================== */

.cs-report-card {
    color: var(--cs-text);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.cs-report-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--cs-shadow);
    border-color: var(--cs-primary-500);
}

.cs-report-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

/* ==========================================================================
   Personalização (Fase 10)
   ========================================================================== */

.cs-brand-preview {
    background: #f8fafc;
    border: 2px dashed var(--cs-border);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.cs-brand-preview img {
    max-width: 220px;
    max-height: 80px;
    object-fit: contain;
}

.cs-brand-preview-sm {
    background: #f8fafc;
    border: 2px dashed var(--cs-border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.cs-brand-preview-sm img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.cs-color-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cs-color-row .form-control-color {
    width: 50px;
    flex-shrink: 0;
    height: 38px;
    padding: 4px;
}

.cs-color-text {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
    font-size: 12px;
    text-transform: lowercase;
}

.cs-theme-preview {
    background: #f8fafc;
    border: 1px solid var(--cs-border);
    border-radius: 12px;
}

.cs-msg-template {
    background: #f8fafc;
    border: 1px solid var(--cs-border);
    border-radius: 10px;
    padding: 14px 16px;
}

/* ==========================================================================
   Financeiro (Fase 9)
   ========================================================================== */

.cs-cat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--cs-border);
}

.cs-cat-row:last-child {
    border-bottom: 0;
}

.cs-cat-bullet {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.cs-cat-label {
    flex: 1;
    color: var(--cs-text-soft);
    font-size: 14px;
}

.cs-cat-amount {
    font-size: 14px;
}

.cs-balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px dashed var(--cs-border);
}

.cs-balance-row:last-child {
    border-bottom: 0;
}

.cs-balance-row strong:first-child {
    color: var(--cs-text);
}

.cs-entries-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cs-entries-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--cs-border);
}

.cs-entries-list li:last-child {
    border-bottom: 0;
}

.cs-entry-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.cs-entry-icon.in {
    background: #dcfce7;
    color: #059669;
}

.cs-entry-icon.out {
    background: #fee2e2;
    color: #dc2626;
}

/* ==========================================================================
   Documentos & templates (Fase 8)
   ========================================================================== */

.cs-template-editor {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.55;
    background: #0f172a;
    color: #e2e8f0;
    border: 0;
    border-radius: 10px;
    padding: 16px 18px;
    resize: vertical;
}

.cs-template-editor:focus {
    background: #0b1229;
    color: #f1f5f9;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .35);
}

.cs-placeholders {
    background: #f8fafc;
    border: 1px solid var(--cs-border);
    border-radius: 12px;
    padding: 12px;
    max-height: 480px;
    overflow-y: auto;
}

.cs-placeholders-group {
    margin-bottom: 12px;
}

.cs-placeholders-group:last-child {
    margin-bottom: 0;
}

.cs-placeholders-group h6 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--cs-primary-600);
    font-weight: 700;
    margin: 0 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--cs-primary-50);
}

.cs-placeholder-btn {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all .12s;
}

.cs-placeholder-btn:hover {
    border-color: var(--cs-primary-500);
    background: var(--cs-primary-50);
    transform: translateX(2px);
}

.cs-placeholder-btn code {
    color: var(--cs-primary-600);
    font-size: 11.5px;
    font-weight: 700;
    background: none;
    padding: 0;
}

.cs-placeholder-btn small {
    display: block;
    color: var(--cs-muted);
    font-size: 11px;
    margin-top: 1px;
}

.cs-doc-preview,
.cs-doc-editor {
    background: #fff;
    border: 1px solid var(--cs-border);
    border-radius: 10px;
    padding: 32px 36px;
    min-height: 380px;
    line-height: 1.6;
    font-size: 14px;
    color: var(--cs-text);
}

.cs-doc-editor {
    outline: none;
}

.cs-doc-editor:focus {
    border-color: var(--cs-primary-500);
    box-shadow: 0 0 0 3px var(--cs-primary-50);
}

.cs-doc-preview h1,
.cs-doc-preview h2,
.cs-doc-preview h3,
.cs-doc-editor h1,
.cs-doc-editor h2,
.cs-doc-editor h3 {
    color: #1e3a8a;
}

.cs-doc-preview p,
.cs-doc-editor p {
    margin: 0 0 10px;
}

/* ==========================================================================
   Responsividade
   ========================================================================== */

@media (max-width: 991.98px) {
    .cs-content {
        padding: 20px 18px;
    }

    .cs-topbar {
        padding: 0 16px;
    }

    .cs-topbar-search {
        max-width: none;
    }
}

/* =====================================================================
   PERSONALIZAÇÃO DO CHROME (menu vertical/horizontal + cores customizadas)
   ===================================================================== */

/* --- Overrides do tema nas variáveis CSS existentes --- */
.cs-sidebar {
    background: var(--cs-menu-bg) !important;
    color: var(--cs-menu-text) !important;
}

.cs-sidebar-nav .cs-nav-link {
    color: var(--cs-menu-text);
}

.cs-sidebar-nav .cs-nav-link.active,
.cs-sidebar-nav .cs-nav-sublink.active {
    color: var(--cs-menu-active-color) !important;
}

.cs-topbar {
    background: var(--cs-topbar-bg) !important;
}

/* --- Menu horizontal --- */
body.cs-layout-horizontal {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.cs-hnav {
    background: var(--cs-menu-bg);
    color: var(--cs-menu-text);
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

.cs-hnav-inner {
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    min-height: 60px;
}

.cs-hnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--cs-menu-active-color);
    text-decoration: none;
    font-weight: 700;
    flex-shrink: 0;
}

.cs-hnav-brand i {
    font-size: 22px;
    color: var(--cs-primary);
}

.cs-hnav-logo {
    height: 32px;
    width: auto;
    max-width: 160px;
}

.cs-hnav-toggle {
    display: none;
    background: transparent;
    border: 0;
    color: var(--cs-menu-text);
    font-size: 24px;
    padding: 6px 10px;
    cursor: pointer;
    margin-left: auto;
}

.cs-hnav-list {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    margin: 0;
    padding: 0;
    /* Sem flex:1 — itens ficam compactos logo após o brand (alinhados à esquerda).
       Em mobile, o @media abaixo redefine pra full-width. */
}

.cs-hnav-item {
    position: relative;
}

.cs-hnav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--cs-menu-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.cs-hnav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: var(--cs-menu-active-color);
}

.cs-hnav-item.active>.cs-hnav-link,
.cs-hnav-item.active>.cs-hnav-link:hover {
    background: var(--cs-menu-active-bg);
    color: var(--cs-menu-active-color);
}

.cs-hnav-caret {
    font-size: 11px;
    opacity: .7;
    transition: transform .15s;
}

.cs-hnav-item.has-dropdown.open .cs-hnav-caret,
.cs-hnav-item.has-dropdown:hover .cs-hnav-caret {
    transform: rotate(180deg);
}

/* Dropdown — abre via hover (desktop) ou .open (click/mobile) */
.cs-hnav-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: #fff;
    color: #0f172a;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
    padding: 6px;
    list-style: none;
    margin: 8px 0 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity .15s, transform .15s, visibility .15s;
    z-index: 1040;
}

@media (hover: hover) {
    .cs-hnav-item.has-dropdown:hover>.cs-hnav-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

.cs-hnav-item.has-dropdown.open>.cs-hnav-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cs-hnav-sublink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: #475569;
    text-decoration: none;
    font-size: 14px;
    transition: background .15s, color .15s;
}

.cs-hnav-sublink i {
    font-size: 15px;
    opacity: .8;
}

.cs-hnav-sublink:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.cs-hnav-sublink.active {
    background: var(--cs-menu-active-bg);
    color: var(--cs-menu-active-color);
    font-weight: 600;
}

.cs-hnav-sublink.active i {
    opacity: 1;
}

/* Layout horizontal — desliga sidebar offset */
body.cs-layout-horizontal .cs-main--horizontal {
    margin-left: 0;
}

body.cs-layout-horizontal .cs-topbar {
    padding-left: 24px;
}

/* Mobile do menu horizontal */
@media (max-width: 991.98px) {
    .cs-hnav-toggle {
        display: inline-flex;
    }

    .cs-hnav-list {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--cs-menu-bg);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px;
        box-shadow: 0 12px 24px rgba(0, 0, 0, .15);
    }

    .cs-hnav-list.open {
        display: flex;
    }

    .cs-hnav-link {
        width: 100%;
    }

    .cs-hnav-dropdown {
        position: static;
        box-shadow: none;
        background: rgba(255, 255, 255, .06);
        opacity: 1;
        visibility: visible;
        transform: none;
        margin: 4px 0 4px 16px;
    }

    .cs-hnav-sublink {
        color: var(--cs-menu-text);
    }

    .cs-hnav-sublink:hover {
        background: rgba(255, 255, 255, .08);
        color: var(--cs-menu-active-color);
    }
}

/* =====================================================================
   SIDEBAR — modo colapsado (rail) com hover-expand + botão pin
   Estados:
     - default (sem .is-collapsed)        → full width (264px), labels visíveis
     - .is-collapsed                      → rail 72px, só ícones
     - Sem hover-expand — apertar o botão chevron é o único caminho.
   Persistência: localStorage 'cs.sidebar.collapsed'
   ===================================================================== */

/* Botão de pin no canto superior direito da sidebar */
.cs-sidebar-brand {
    position: relative;
}

#cs-sidebar-pin {

    position: absolute;
    right: -29px;
    top: 0px;
    height: 100vh;
    width: 30px;
    background: #0097fa;
    border: 0;
    color: #ffffff;
}

.cs-sidebar-pin {
    position: absolute;
    top: 117px;
    right: 11px;
    width: 0px;
    height: 0px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, .7);
    cursor: pointer;
    font-size: 6px;
    border-radius: 7px;
    transition: background .15s, color .15s, transform .15s, opacity .2s;
    z-index: 2;
}

.cs-sidebar-pin:hover {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    transform: scale(1.05);
}

.cs-sidebar-pin:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 1px;
}

/* Estado colapsado — width 72px, só ícones */
.cs-sidebar {
    transition: width .22s ease, transform .25s ease;
}

.cs-sidebar.is-collapsed {
    width: 72px;
}

/* Esconde tudo que não é ícone no estado colapsado */
.cs-sidebar.is-collapsed .cs-sidebar-brand strong,
.cs-sidebar.is-collapsed .cs-sidebar-brand small,
.cs-sidebar.is-collapsed .cs-sidebar-brand>div,
.cs-sidebar.is-collapsed .cs-nav-link span,
.cs-sidebar.is-collapsed .cs-nav-caret,
.cs-sidebar.is-collapsed .cs-sidebar-footer small {
    display: none;
}

.cs-sidebar.is-collapsed .cs-sidebar-brand {
    justify-content: center;
    padding: 22px 12px;
}

.cs-sidebar.is-collapsed .cs-sidebar-brand i:first-child {
    font-size: 26px;
}

.cs-sidebar.is-collapsed .cs-sidebar-logo {
    max-height: 32px;
}

.cs-sidebar.is-collapsed .cs-nav-link {
    justify-content: center;
    padding: 11px 0;
    margin: 2px 0px;

}

.cs-sidebar.is-collapsed .cs-nav-submenu {
    display: none !important;
}

.cs-sidebar.is-collapsed .cs-sidebar-footer {
    padding: 14px 6px 16px;
    justify-content: center;
}

.cs-sidebar.is-collapsed .cs-env-badge {
    padding: 4px 6px;
    font-size: 0;
    /* esconde label, mantém indicador como bolinha */
}

.cs-sidebar.is-collapsed .cs-env-badge i {
    font-size: 12px;
}

/* Pin button some no estado colapsado, reaparece no hover */
.cs-sidebar.is-collapsed .cs-sidebar-pin {
    opacity: 0;
    pointer-events: none;
}

/* Hover-expand: volta ao tamanho full, mostra tudo, pin reaparece.
   Z-index alto pra sobrepor o conteúdo principal. */
@media (min-width: 992px) {

    /* Quando colapsada, conteúdo principal acompanha o rail de 72px.
       Sem hover-expand: a sidebar só abre via click no botão chevron. */
    body.cs-sidebar-collapsed .cs-main {
        margin-left: 72px;
    }
}

/* Brand: alterna entre logo completo (default) e favicon (colapsado).
   O favicon não é redimensionado — fica no tamanho natural pequeno. */
.cs-sidebar-favicon {
    display: none;
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Modo colapsado: esconde logo full, mostra favicon */
.cs-sidebar.is-collapsed .cs-brand-full {
    display: none;
}

.cs-sidebar.is-collapsed .cs-brand-mini {
    display: block;
}

/* Hover-expand reverte: volta a mostrar o logo full */
@media (min-width: 992px) {
    .cs-sidebar.is-collapsed:hover .cs-brand-full {
        display: block;
    }

    .cs-sidebar.is-collapsed:hover .cs-brand-mini {
        display: none;
    }
}

/* Favicon NÃO precisa do filter brightness/invert do logo (já vem na cor certa). */
.cs-sidebar-favicon {
    filter: none;
}