/* =========================================================
   CONTROL MÉDICO
   APP.CSS GLOBAL
   ========================================================= */


/* =========================================================
   VARIABLES
   ========================================================= */

:root {
    --primary: #334155;
    --primary-dark: #1e293b;
    --primary-light: #f1f5f9;

    --bg: #f8fafc;
    --bg-soft: #f1f5f9;
    --card-bg: #ffffff;

    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border: #e2e8f0;
    --border-color: #e2e8f0;

    --success: #18794e;
    --success-bg: #e4f7ed;

    --warning: #946200;
    --warning-bg: #fff4d6;

    --danger: #b42318;
    --danger-bg: #fde8e8;

    --info: #245a9c;
    --info-bg: #e5f0ff;

    --sidebar-width: 250px;
    --topbar-height: 68px;

    --radius: 10px;
    --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}


/* =========================================================
   RESET
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

table {
    border-collapse: collapse;
    width: 100%;
}


/* =========================================================
   APP
   ========================================================= */

.app {
    min-height: 100vh;
    width: 100%;
}


/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;

    width: var(--sidebar-width);

    background: #ffffff;
    border-right: 1px solid var(--border);

    z-index: 1000;

    display: flex;
    flex-direction: column;

    overflow-y: auto;

    transition: transform 0.25s ease;
}



/* Logo */

.sidebar-logo {
    height: var(--topbar-height);

    display: flex;
    align-items: center;

    padding: 0 22px;

    border-bottom: 1px solid var(--border);

    font-size: 19px;
    font-weight: 700;

    color: var(--primary-dark);
}


/* Navigation */

.sidebar-nav {
    flex: 1;

    padding: 18px 12px;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section-title {
    padding: 0 10px;
    margin-bottom: 8px;

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.7px;

    color: var(--text-muted);
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 11px;

    width: 100%;

    padding: 11px 12px;

    margin-bottom: 3px;

    border-radius: 8px;

    color: var(--text-secondary);

    font-size: 14px;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.sidebar a:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.sidebar a.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.sidebar a .nav-icon {
    width: 20px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 16px;
}


/* Sidebar footer */

.sidebar-footer {
    padding: 14px 12px;

    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 8px;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;

    flex-shrink: 0;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--primary);
    color: #ffffff;

    font-size: 13px;
    font-weight: 700;
}

.sidebar-user-info {
    min-width: 0;
}

.sidebar-user-info strong {
    display: block;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 13px;
}

.sidebar-user-info span {
    display: block;

    margin-top: 2px;

    color: var(--text-muted);

    font-size: 11px;
}


/* =========================================================
   MAIN
   ========================================================= */

.main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
    position: sticky;
    top: 0;

    height: var(--topbar-height);

    width: 100%;

    background: #ffffff;

    border-bottom: 1px solid var(--border);

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 28px;

    z-index: 900;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;

    min-width: 0;
}

.topbar-title {
    margin: 0;

    font-size: 18px;
    font-weight: 600;

    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}


/* User menu */

.user-menu {
    position: relative;
}

.user-menu-button {
    border: 0;
    background: transparent;

    display: flex;
    align-items: center;
    gap: 10px;

    padding: 5px 7px;

    border-radius: 8px;
}

.user-menu-button:hover {
    background: var(--bg-soft);
}

.user-avatar {
    width: 36px;
    height: 36px;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--primary);
    color: #ffffff;

    font-size: 13px;
    font-weight: 700;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.user-info strong {
    font-size: 13px;
}

.user-info span {
    margin-top: 2px;

    font-size: 11px;

    color: var(--text-muted);
}


/* User dropdown */

.user-menu-dropdown {
    position: absolute;

    top: calc(100% + 8px);
    right: 0;

    min-width: 180px;

    padding: 7px;

    background: #ffffff;

    border: 1px solid var(--border);
    border-radius: 9px;

    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);

    display: none;
}

.user-menu.open .user-menu-dropdown {
    display: block;
}

.user-menu-dropdown a {
    display: block;

    padding: 9px 10px;

    border-radius: 6px;

    color: var(--text-secondary);
}

.user-menu-dropdown a:hover {
    background: var(--bg-soft);
    color: var(--text);
}


.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

@media (max-width: 900px) {

    .main-content {
        margin-left: 0;
        width: 100%;
    }

}

.mobile-menu {
    display: none;

    width: 38px;
    height: 38px;

    align-items: center;
    justify-content: center;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #ffffff;
    color: var(--text);

    font-size: 18px;
    cursor: pointer;
}

.mobile-menu:hover {
    background: var(--bg-soft);
}

@media (max-width: 900px) {
    .mobile-menu {
        display: flex;
    }
}
/* =========================================================
   MOBILE MENU BUTTON
   ========================================================= */

.menu-toggle {
    width: 38px;
    height: 38px;

    border: 1px solid var(--border);
    border-radius: 8px;

    background: #ffffff;

    display: none;

    align-items: center;
    justify-content: center;

    color: var(--text);

    font-size: 18px;
}

.menu-toggle:hover {
    background: var(--bg-soft);
}

.sidebar-close {
    display: none;
}


/* Overlay */

.sidebar-overlay {
    position: fixed;

    inset: 0;

    background: rgba(15, 23, 42, 0.40);

    z-index: 950;

    display: none;
}

.sidebar-overlay.show {
    display: block;
}


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

.page-content {
    width: 100%;
    max-width: 100%;
    padding: 28px;
    box-sizing: border-box;
    overflow-x: hidden;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0;

    font-size: 24px;
    font-weight: 600;

    color: var(--text);
}

.page-header p {
    margin: 5px 0 0;

    color: var(--text-muted);

    font-size: 13px;
}


/* =========================================================
   CARD
   ========================================================= */

.card {
    background: var(--card-bg);

    border: 1px solid var(--border);

    border-radius: var(--radius);

    box-shadow: var(--shadow);

    padding: 22px;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
    border: 1px solid transparent;

    border-radius: 8px;

    padding: 9px 15px;

    font-size: 13px;
    font-weight: 600;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;

    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #ffffff;

    border-color: var(--border);

    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-soft);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}


/* =========================================================
   FILTERS
   ========================================================= */

.filters {
    display: flex;
    align-items: center;
    gap: 10px;

    margin-bottom: 20px;

    flex-wrap: wrap;
}

.search-input,
.filter-select {
    height: 38px;

    border: 1px solid var(--border);

    border-radius: 8px;

    background: #ffffff;

    padding: 0 11px;

    color: var(--text);

    outline: none;
}

.search-input {
    min-width: 220px;
}

.filter-select {
    min-width: 150px;
}

.search-input:focus,
.filter-select:focus,
.form-control:focus {
    border-color: #94a3b8;

    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.15);
}


/* =========================================================
   TABLE
   ========================================================= */

.table-wrapper {
    width: 100%;

    overflow-x: auto;

    border: 1px solid var(--border);

    border-radius: 9px;
}

.data-table {
    min-width: 700px;
}

.data-table th {
    padding: 12px 14px;

    background: var(--bg-soft);

    border-bottom: 1px solid var(--border);

    text-align: left;

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.4px;

    color: var(--text-muted);
}

.data-table td {
    padding: 13px 14px;

    border-bottom: 1px solid var(--border);

    color: var(--text-secondary);

    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: #fafafa;
}


/* =========================================================
   ACTIONS
   ========================================================= */

.action-btn {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 6px;
    background: #f1f5f9;
    cursor: pointer;
}

.action-btn:hover {
    background: #e2e8f0;
}
.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-icon {
    width: 32px;
    height: 32px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: #ffffff;

    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--bg-soft);
}


/* =========================================================
   STATUS
   ========================================================= */

.status-badge {
    display: inline-flex;
    align-items: center;

    padding: 4px 8px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 600;
}


/* FORM */

.form-section {
    padding: 25px;
}

.form-section h3 {
    margin: 0 0 20px;
    font-size: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    padding: 11px 12px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
}

.form-group textarea {
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #64748b;
}



/* =========================================================
   MODALS
   ========================================================= */

.modal {
    position: fixed;

    inset: 0;

    z-index: 2000;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(15, 23, 42, 0.45);
}

.modal.show {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 720px;

    max-height: calc(100vh - 40px);

    overflow-y: auto;

    background: #ffffff;

    border-radius: 12px;

    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 20px 22px;

    border-bottom: 1px solid var(--border);
}

.modal-header h2,
.modal-header h3 {
    margin: 0;

    font-size: 17px;
}

.modal-close {
    width: 32px;
    height: 32px;

    border: 0;

    border-radius: 7px;

    background: transparent;

    font-size: 20px;

    color: var(--text-muted);
}

.modal-close:hover {
    background: var(--bg-soft);
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;

    padding: 16px 22px;

    border-top: 1px solid var(--border);
}


/* =========================================================
   PAGINATION
   ========================================================= */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    margin-top: 18px;
}

.pagination-info {
    color: var(--text-muted);
    font-size: 12px;
}

.pagination-buttons {
    display: flex;
    gap: 5px;
}

.pagination button {
    min-width: 32px;
    height: 32px;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: #ffffff;

    color: var(--text-secondary);
}

.pagination button:hover {
    background: var(--bg-soft);
}

.pagination button.active {
    background: var(--primary);
    border-color: var(--primary);

    color: #ffffff;

}
.card,
.page-header,
.filters,
.table-wrapper {
    max-width: 100%;
}

.table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.data-table {
    min-width: 700px;
}

.quote-lines-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}


/* =========================================================
   PACIENTES
   ========================================================= */
.filters-card {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

.search-box {
    position: relative;
    flex: 1;
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 42px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    outline: none;
    background: var(--card-bg, #fff);
    font-size: 14px;
}

.search-box input:focus {
    border-color: #64748b;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: #94a3b8;
}

.filters-card select {
    min-width: 180px;
    padding: 12px 14px;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    background: #fff;
    outline: none;
}

.patient-name-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.patient-name-cell strong {
    color: var(--text);
}

.patient-name-cell small {
    color: var(--text-muted);
    font-size: 12px;
}

.patient-detail {
    padding: 4px 0;
}

.patient-summary {
    display: grid;

    grid-template-columns: repeat(4, 1fr);

    gap: 12px;

    margin-bottom: 25px;
}

.patient-summary-item {
    padding: 15px;

    background: var(--bg-soft);

    border-radius: 10px;
}

.patient-summary-item span {
    display: block;

    margin-bottom: 5px;

    color: var(--text-muted);

    font-size: 11px;
}

.patient-summary-item strong {
    font-size: 14px;
}

.patient-tabs {
    display: flex;

    gap: 5px;

    margin-bottom: 20px;

    border-bottom: 1px solid var(--border);
}

.patient-tab {
    border: 0;

    background: transparent;

    padding: 10px 13px;

    color: var(--text-muted);

    border-bottom: 2px solid transparent;
}

.patient-tab.active {
    color: var(--text);
    border-bottom-color: var(--primary);
}

.status-activo {
    background: var(--success-bg);
    color: var(--success);
}

.status-inactivo {
    background: var(--danger-bg);
    color: var(--danger);
}


/* =========================================================
   CITAS
   ========================================================= */

.appointment-date {
    display: block;

    margin-top: 3px;

    font-size: 12px;

    color: var(--text-muted);
}

.appointment-detail {
    padding: 4px 0;
}

.detail-label {
    display: block;

    margin-bottom: 6px;

    font-size: 12px;

    color: var(--text-muted);
}

.appointment-detail .detail-grid {
    margin-bottom: 24px;
}

.detail-observations {
    padding: 18px;

    border-radius: 10px;

    background: var(--bg-soft);
}

.detail-observations p {
    margin: 0;

    color: var(--text);

    line-height: 1.6;
}

.status-pendiente {
    background: #fff4d6;
    color: #946200;
}

.status-confirmada {
    background: #e5f0ff;
    color: #245a9c;
}

.status-atendida {
    background: #e4f7ed;
    color: #18794e;
}

.status-cancelada {
    background: #fde8e8;
    color: #b42318;
}

.status-no_asistio {
    background: #f1e8f8;
    color: #71368a;
}

#appointmentDate,
#appointmentDateForm {
    min-width: 150px;
}


/* =========================================================
   MÉDICOS
   ========================================================= */

.contact-cell {
    display: flex;

    flex-direction: column;

    gap: 3px;
}

.contact-cell small {
    color: var(--text-muted);

    font-size: 12px;
}

.doctor-detail {
    padding: 4px 0;
}

.doctor-profile {
    display: flex;
    align-items: center;

    gap: 15px;

    padding: 18px;

    margin-bottom: 24px;

    border-radius: 12px;

    background: var(--bg-soft);
}

.doctor-profile h3 {
    margin: 0 0 4px;
}

.doctor-profile p {
    margin: 0;

    color: var(--text-muted);
}

.doctor-profile-avatar {
    width: 58px;
    height: 58px;

    flex-shrink: 0;

    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--primary);

    color: #ffffff;

    font-weight: 700;
    font-size: 18px;
}


/* =========================================================
   SERVICIOS
   ========================================================= */

.service-name-cell {
    display: flex;

    flex-direction: column;

    gap: 4px;
}

.service-name-cell small {
    color: var(--text-muted);

    font-size: 12px;
}

.service-summary {
    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 16px;

    margin-bottom: 28px;
}

.service-summary-item {
    padding: 18px;

    border-radius: 12px;

    background: var(--bg-soft);
}

.service-summary-item span {
    display: block;

    margin-bottom: 7px;

    color: var(--text-muted);

    font-size: 12px;
}

.service-summary-item strong {
    font-size: 18px;
}

.service-detail {
    padding: 4px 0;
}

.detail-section {
    margin-top: 28px;
}

.detail-section h4 {
    margin: 0 0 16px;

    font-size: 15px;
}


/* =========================================================
   COTIZACIONES
   ========================================================= */

.quote-lines-section {
    margin-top: 28px;
}

.section-heading {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 16px;
}

.section-heading h4 {
    margin: 0 0 4px;
}

.section-heading p {
    margin: 0;

    color: var(--text-muted);

    font-size: 13px;
}

.quote-lines-table-wrapper {
    overflow-x: auto;
}

.quote-lines-table {
    min-width: 750px;
}

.quote-lines-table input,
.quote-lines-table select {
    min-width: 90px;
}

.quote-lines-table select {
    min-width: 220px;
}

.quote-total-box {
    display: flex;

    justify-content: flex-end;

    gap: 32px;

    margin-top: 20px;

    padding: 20px;

    border-radius: 12px;

    background: var(--bg-soft);
}

.quote-total-box > div {
    display: flex;

    flex-direction: column;

    gap: 5px;

    text-align: right;
}

.quote-total-box span {
    font-size: 12px;

    color: var(--text-muted);
}

.quote-total-box strong {
    font-size: 16px;
}

.quote-total-main {
    padding-left: 32px;

    border-left: 1px solid var(--border);
}

.quote-total-main strong {
    font-size: 22px;
}

.quote-summary {
    display: grid;

    grid-template-columns: repeat(5, 1fr);

    gap: 12px;

    margin-bottom: 28px;
}

.quote-summary-item {
    padding: 16px;

    border-radius: 10px;

    background: var(--bg-soft);
}

.quote-summary-item span {
    display: block;

    margin-bottom: 6px;

    color: var(--text-muted);

    font-size: 12px;
}

.quote-summary-item strong {
    font-size: 14px;
}

.quote-detail-total {
    display: flex;

    justify-content: flex-end;
    align-items: center;

    gap: 20px;

    margin-top: 20px;

    padding: 18px 20px;

    border-radius: 10px;

    background: var(--bg-soft);
}

.quote-detail-total span {
    color: var(--text-muted);
}

.quote-detail-total strong {
    font-size: 24px;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

/*
   TABLET / MÓVIL

   El sidebar deja de ocupar espacio físico.
   Se convierte en menú lateral deslizable.
*/

@media (max-width: 900px) {

 .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-close {
        display: flex;
    }

.main-content {
        margin-left: 0;
        width: 100%;
    }    

    .main {
        margin-left: 0;

        width: 100%;

        min-width: 0;
    }

    .topbar {
        width: 100%;

        padding: 0 18px;
    }

    .menu-toggle {
        display: flex;

        flex-shrink: 0;
    }

    .page-content {
        width: 100%;

        max-width: 100%;

        padding: 22px 18px;
    }

    .user-info {
        display: none;
    }

    .service-summary {
        grid-template-columns: 1fr;
    }

    .patient-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .quote-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* =========================================================
   MÓVIL
   ========================================================= */

@media (max-width: 600px) {

    :root {
        --topbar-height: 60px;
    }

    .sidebar {
        width: min(280px, 85vw);
    }

    .topbar {
        height: 60px;

        padding: 0 14px;
    }

    .topbar-title {
        font-size: 16px;
    }

    .page-content {
        padding: 18px 14px;
    }

    .page-header {
        align-items: flex-start;

        flex-direction: column;

        gap: 15px;
    }

    .page-header h1 {
        font-size: 21px;
    }

    .page-header .btn {
        width: 100%;
    }

    .card {
        padding: 16px;
    }

    .filters {
        align-items: stretch;

        flex-direction: column;
    }

    .search-input,
    .filter-select {
        width: 100%;

        min-width: 0;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group-full {
        grid-column: auto;
    }

    .patient-summary {
        grid-template-columns: 1fr;
    }

    .quote-summary {
        grid-template-columns: 1fr;
    }

    .quote-total-box {
        flex-direction: column;

        gap: 14px;
    }

    .quote-total-box > div {
        text-align: left;
    }

    .quote-total-main {
        padding-left: 0;

        padding-top: 14px;

        border-left: 0;

        border-top: 1px solid var(--border);
    }

    .section-heading {
        align-items: flex-start;

        flex-direction: column;
    }

    .doctor-profile {
        align-items: flex-start;
    }

    .pagination {
        align-items: flex-start;

        flex-direction: column;
    }

    .modal {
        padding: 10px;
    }

    .modal-content {
        max-height: calc(100vh - 20px);
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-footer {
        padding: 14px 16px;

        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
    }
}


/* =========================================================
   MODALES
   ========================================================= */


/* Contenido del modal */

.modal {
    width: 100%;
    max-width: 720px;

    max-height: calc(100vh - 40px);

    overflow-y: auto;

    background: #ffffff;

    border-radius: 12px;

    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}


/* Modal grande */

.modal-overlay {
    position: fixed;
    inset: 0;

    z-index: 2000;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(15, 23, 42, 0.45);
}

.modal-overlay.show,
.modal-overlay.active {
    display: flex;
}

.modal-overlay .modal {
    position: relative;
    z-index: 2001;

    width: 100%;
    max-width: 720px;
    max-height: calc(100vh - 40px);

    overflow-y: auto;

    background: #ffffff;

    border-radius: 12px;

    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

.modal-overlay .modal.modal-large {
    max-width: 1000px;
    display: flex;
}

/* Header */

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding: 20px 22px;

    border-bottom: 1px solid var(--border);
}

.modal-header h2,
.modal-header h3 {
    margin: 0;

    font-size: 17px;
}

.modal-header p {
    margin: 5px 0 0;

    color: var(--text-muted);

    font-size: 12px;
}


/* Cerrar */

.modal-close {
    width: 34px;
    height: 34px;

    flex-shrink: 0;

    border: 0;

    border-radius: 7px;

    background: transparent;

    color: var(--text-muted);

    font-size: 24px;

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
}

.modal-close:hover {
    background: var(--bg-soft);
    color: var(--text);
}


/* Formulario */

.modal form {
    width: 100%;
}

.form-section {
    padding: 22px;
}

.form-section h3 {
    margin: 0 0 18px;

    font-size: 15px;
    font-weight: 600;
}


/* Footer */

.modal-footer {
    display: flex;
    justify-content: flex-end;

    gap: 10px;

    padding: 16px 22px;

    border-top: 1px solid var(--border);

    background: #ffffff;
}


/* Responsive */

@media (max-width: 600px) {

    .modal-overlay {
        padding: 10px;
    }

    .modal {
        max-height: calc(100vh - 20px);

        border-radius: 10px;
    }

    .modal-header {
        padding: 16px;
    }

    .form-section {
        padding: 16px;
    }

    .modal-footer {
        padding: 14px 16px;

        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
    }
}


/* =====================================================
   USUARIOS Y ROLES
===================================================== */

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.permission-item {
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-soft);
}

.permission-item > strong {
    display: block;
    margin-bottom: 9px;
}

.permission-badge {
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 4px 8px;
    border-radius: 6px;
    background: #e5f0ff;
    color: #245a9c;
    font-size: 11px;
}

.permissions-editor {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.permission-editor-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: center;
    gap: 20px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.permission-editor-row:last-child {
    border-bottom: 0;
}

.permission-module {
    font-size: 14px;
}

.permission-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.permission-checks label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.form-help {
    margin: -8px 0 16px;
    color: var(--text-muted);
    font-size: 13px;
}

@media (max-width: 768px) {

    .permissions-grid {
        grid-template-columns: 1fr;
    }

    .permission-editor-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .permission-checks {
        gap: 12px;
    }

}

/* ============================================
   AUDITORÍA
   ============================================ */

.audit-stats {
    margin-bottom: 20px;
}

.audit-filters-card {
    margin-bottom: 20px;
}

.audit-filters {
    align-items: end;
}

.audit-filter-actions {
    display: flex;
    align-items: flex-end;
    height: 100%;
}

.audit-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.audit-user > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.audit-user small {
    color: var(--text-muted);
    font-size: 12px;
}

.avatar-small {
    width: 34px;
    height: 34px;
    min-width: 34px;
    font-size: 12px;
}

.audit-datetime {
    white-space: nowrap;
}

.audit-datetime strong {
    font-size: 13px;
}

.audit-module {
    font-weight: 500;
}

.audit-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    white-space: nowrap;
}

.audit-action-crear {
    background: #e8f7ee;
    color: #16834b;
}

.audit-action-editar {
    background: #eaf2ff;
    color: #2867c7;
}

.audit-action-eliminar {
    background: #fdecec;
    color: #c73737;
}

.audit-action-anular {
    background: #fff0e6;
    color: #c65d18;
}

.audit-action-pagar {
    background: #e8f7ee;
    color: #16834b;
}

.audit-action-recibir {
    background: #eaf7f7;
    color: #147777;
}

.audit-action-cerrar {
    background: #f0edf9;
    color: #6651a8;
}

.audit-action-abrir {
    background: #eef7ed;
    color: #4b7c35;
}

.audit-action-login {
    background: #edf3fb;
    color: #38679d;
}

.audit-action-logout {
    background: #f2f2f2;
    color: #666;
}

.audit-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.detail-item {
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-light);
}

.detail-item span,
.audit-detail-description > span {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.detail-item strong {
    font-size: 14px;
}

.audit-detail-description {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.audit-detail-description > div {
    line-height: 1.6;
    font-size: 14px;
}

@media (max-width: 900px) {

    .audit-detail-grid {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 768px) {

    .audit-filters {
        grid-template-columns: 1fr;
    }

    .audit-filter-actions {
        height: auto;
    }

    .audit-filter-actions .btn {
        width: 100%;
    }

}

/* ============================================
   REPORTES
   ============================================ */

.report-selector-card {
    margin-bottom: 20px;
}

.report-controls {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr auto;
    gap: 16px;
    align-items: end;
}

.report-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.report-stats {
    margin-bottom: 20px;
}

.report-result-card {
    margin-bottom: 20px;
}

.report-result-actions {
    display: flex;
    align-items: center;
}

.report-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 6px;
    background: var(--background-light);
    border: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 700;
}

.report-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

@media (max-width: 1000px) {

    .report-controls {
        grid-template-columns: repeat(2, 1fr);
    }

}

@media (max-width: 768px) {

    .report-controls {
        grid-template-columns: 1fr;
    }

    .report-actions {
        flex-direction: column;
        width: 100%;
    }

    .report-actions .btn {
        width: 100%;
    }

    .report-result-actions {
        margin-top: 12px;
    }

}


/* ============================================
   IMPRESIÓN
   ============================================ */

@media print {

    .sidebar,
    .topbar,
    .report-selector-card,
    .report-result-actions,
    .report-stats {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

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

    .card {
        box-shadow: none !important;
        border: none !important;
    }

    .report-result-card {
        display: block !important;
    }

}

/* ============================================
   HISTORIA CLÍNICA
   ============================================ */

.history-search-card {
    margin-bottom: 20px;
}

.history-search {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: end;
}

.patient-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-patient-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

.history-patient-avatar {
    width: 58px;
    height: 58px;
    min-width: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    background: var(--primary-color);
    color: white;
}

.history-patient-main h2 {
    margin: 0 0 5px;
}

.history-patient-main p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.history-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.history-info-content {
    min-height: 65px;
    line-height: 1.6;
    color: var(--text-color);
}

.history-consultations-card {
    margin-bottom: 20px;
}

.history-timeline {
    position: relative;
    padding-left: 20px;
}

.history-timeline-item {
    position: relative;
    display: flex;
    gap: 16px;
    padding-bottom: 24px;
}

.history-timeline-item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 17px;
    top: 38px;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.history-timeline-marker {
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-light);
    border: 1px solid var(--border-color);
}

.history-timeline-content {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
}

.history-consultation-top {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 16px;
}

.history-consultation-top > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-consultation-top strong {
    font-size: 14px;
}

.history-consultation-top span {
    color: var(--text-muted);
    font-size: 13px;
}

.history-consultation-body {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.history-consultation-body div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-consultation-body span {
    color: var(--text-muted);
    font-size: 11px;
}

.history-consultation-body strong {
    font-size: 13px;
}

.history-no-consultations {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
}

.history-empty {
    text-align: center;
    padding: 60px 20px;
}

.history-empty-icon {
    font-size: 45px;
    margin-bottom: 15px;
}

.history-empty h2 {
    margin-bottom: 8px;
}

.history-empty p {
    color: var(--text-muted);
}

.history-consultation-detail {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.history-clinical-section {
    margin-bottom: 20px;
}

.history-clinical-section h3 {
    margin: 0 0 8px;
    font-size: 14px;
}

.history-clinical-section > div {
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-light);
    line-height: 1.6;
    font-size: 14px;
}

@media (max-width: 800px) {

    .history-info-grid {
        grid-template-columns: 1fr;
    }

    .history-search {
        grid-template-columns: 1fr;
    }

    .history-search .btn {
        width: 100%;
    }

    .history-consultation-detail {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 600px) {

    .patient-history-header {
        align-items: flex-start;
        gap: 15px;
    }

    .history-patient-main {
        align-items: flex-start;
    }

    .history-patient-avatar {
        width: 48px;
        height: 48px;
        min-width: 48px;
        font-size: 15px;
    }

    .history-patient-main h2 {
        font-size: 17px;
    }

    .history-consultation-top {
        flex-direction: column;
    }

    .history-consultation-top .btn {
        align-self: flex-start;
    }

    .history-consultation-body {
        grid-template-columns: 1fr;
        gap: 12px;
    }

}

/* =========================================================
   CONSULTAS MÉDICAS
   ========================================================= */

.consultation-summary {
    margin-bottom: 24px;
}

.consultation-filters-card {
    margin-bottom: 24px;
}

.consultation-filters {
    display: grid;
    grid-template-columns: 2fr repeat(5, 1fr);
    gap: 16px;
    align-items: end;
}

.consultation-filters .form-group {
    margin-bottom: 0;
}

.consultation-reason {
    display: block;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* PERSONA EN TABLA */

.table-person {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.table-person > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.table-person strong {
    font-size: 13px;
}

.table-person span {
    font-size: 11px;
    opacity: .65;
}

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


/* =========================================================
   DETALLE DE CONSULTA
   ========================================================= */

.consultation-detail-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px;
    border-radius: 12px;
    background: var(--bg-secondary);
    margin-bottom: 24px;
}

.consultation-patient-avatar {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.consultation-detail-header h3 {
    margin: 0 0 4px;
}

.consultation-detail-header p {
    margin: 0;
    opacity: .65;
    font-size: 13px;
}

.consultation-detail-status {
    margin-left: auto;
}

.consultation-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.clinical-detail-section {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.clinical-detail-section:nth-child(4) {
    grid-column: 1 / -1;
}

.clinical-detail-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    opacity: .65;
    margin-bottom: 8px;
}

.clinical-detail-label i {
    margin-right: 5px;
}

.clinical-detail-section strong {
    font-size: 14px;
}

.clinical-detail-section p {
    margin: 0;
    line-height: 1.6;
    font-size: 14px;
}

.clinical-detail-block {
    padding: 18px;
    border-left: 3px solid var(--primary-color);
    background: var(--bg-secondary);
    border-radius: 0 10px 10px 0;
    margin-bottom: 16px;
}

.clinical-detail-block h4 {
    margin: 0 0 8px;
    font-size: 14px;
}

.clinical-detail-block p {
    margin: 0;
    line-height: 1.7;
    font-size: 14px;
    white-space: pre-line;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1200px) {

    .consultation-filters {
        grid-template-columns: repeat(3, 1fr);
    }

}


@media (max-width: 800px) {

    .consultation-filters {
        grid-template-columns: repeat(2, 1fr);
    }

    .consultation-detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .clinical-detail-section:nth-child(4) {
        grid-column: 1 / -1;
    }

}


@media (max-width: 600px) {

    .consultation-filters {
        grid-template-columns: 1fr;
    }

    .consultation-detail-header {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .consultation-detail-status {
        width: 100%;
        margin-left: 0;
        margin-top: 5px;
    }

    .consultation-detail-grid {
        grid-template-columns: 1fr;
    }

    .clinical-detail-section:nth-child(4) {
        grid-column: auto;
    }

    .consultation-patient-avatar {
        width: 48px;
        height: 48px;
        font-size: 15px;
    }

}