/* ===== Variables y Reset ===== */
:root {
    /* Paleta dental moderna */
    --primary: #0ea5b7;          /* Turquesa dental */
    --primary-dark: #087985;     /* Turquesa oscuro */
    --primary-light: #5ec5d4;    /* Turquesa claro */
    --primary-soft: #e0f5f8;     /* Fondo turquesa muy claro */

    --secondary: #1e88e5;        /* Azul clínico */
    --secondary-dark: #1565c0;

    --accent: #10b981;           /* Verde menta */
    --accent-dark: #059669;

    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --bg-body: #f1f5f9;          /* Gris muy claro */
    --bg-card: #ffffff;
    --bg-sidebar: #0f2942;       /* Azul marino oscuro */
    --bg-sidebar-hover: rgba(255, 255, 255, 0.08);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-inverse: #ffffff;

    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    --shadow-sm: 0 1px 2px rgba(15, 41, 66, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 41, 66, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 41, 66, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Poppins', 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Layout Dashboard ===== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    box-shadow: 2px 0 16px rgba(15, 41, 66, 0.1);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.logo-icon {
    width: 22px;
    height: 22px;
}

.brand {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    transition: all 0.18s ease;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(14, 165, 183, 0.4);
}

.nav-item.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-info p { line-height: 1.25; }
.user-name { color: #fff; font-size: 13px; font-weight: 600; }
.user-role { color: var(--text-tertiary); font-size: 11px; }

/* ===== Main Content ===== */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 24px 32px;
    min-width: 0;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.header-left h2 {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.header-sub {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

.header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    position: relative;
    transition: all 0.18s ease;
}

.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:hover { background: var(--primary-soft); border-color: var(--primary-light); color: var(--primary-dark); }
.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Views ===== */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Search Bar ===== */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.search-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input-wrap input {
    width: 100%;
    padding: 11px 14px 11px 44px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.18s ease;
    background: #fbfdfe;
    font-family: inherit;
}

.search-input-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(14, 165, 183, 0.1);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
    white-space: nowrap;
}

.btn svg { width: 18px; height: 18px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(14, 165, 183, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(14, 165, 183, 0.4); }

.btn-outline {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1.5px solid var(--border-color);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }

.btn-success {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    padding: 6px 10px;
    font-size: 12px;
}
.btn-danger:hover { background: #dc2626; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #fcfcfd 0%, #f8fafc 100%);
}

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.badge-info {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

/* ===== Tables ===== */
.table-container { overflow-x: auto; }

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

.data-table th, .data-table td {
    padding: 12px 20px;
    text-align: left;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
}

.data-table tbody tr {
    transition: background 0.15s ease;
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: var(--primary-soft);
}

.data-table .text-center { text-align: center; }
.data-table .empty-row td {
    text-align: center;
    color: var(--text-tertiary);
    padding: 32px;
    font-style: italic;
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}
.status-activo { background: #d1fae5; color: #065f46; }
.status-inactivo { background: #fee2e2; color: #991b1b; }
.status-pendiente { background: #fef3c7; color: #92400e; }

.btn-select {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border: 1px solid var(--primary-light);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-select:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-select svg { width: 14px; height: 14px; }

/* ===== Patient Banner ===== */
.patient-banner {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--primary-soft) 0%, #fff 100%);
    border-left: 4px solid var(--primary);
}

.patient-banner-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(14, 165, 183, 0.35);
}

.patient-banner-info { flex: 1; }

.patient-banner-info h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.patient-banner-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 24px;
    font-size: 13px;
}

.patient-banner-grid div span {
    color: var(--text-tertiary);
    margin-right: 4px;
}
.patient-banner-grid strong { color: var(--text-primary); font-weight: 600; }

.patient-banner-actions { display: flex; align-items: flex-start; }

/* ===== Tabs Container ===== */
.tabs-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 20px;
}

.tabs-header {
    display: flex;
    background: linear-gradient(135deg, #fcfcfd 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab-btn {
    flex: 0 0 auto;
    min-width: 130px;
    padding: 14px 18px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.18s ease;
    font-family: inherit;
    position: relative;
}

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

.tab-btn.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
    background: #fff;
}

.tabs-body { padding: 24px; min-height: 400px; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.25s ease; }

/* ===== Form ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }

.form-group { display: flex; flex-direction: column; }
.form-group-full { grid-column: 1 / -1; }
.form-group-action { display: flex; align-items: flex-end; }

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 10px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: #fbfdfe;
    transition: all 0.18s ease;
    width: 100%;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(14, 165, 183, 0.1);
}

.form-group input[readonly] {
    background: #f1f5f9;
    color: var(--text-secondary);
    cursor: not-allowed;
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-grid-treatment {
    grid-template-columns: 1fr 1.5fr auto auto;
    align-items: flex-end;
}

.treatment-form {
    background: #f8fafc;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 1.5px dashed var(--border-color);
}

/* ===== Section Divider ===== */
.section-divider {
    margin: 20px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-light);
}
.section-divider h4 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 2px;
}
.section-divider-sub { font-size: 12px; color: var(--text-tertiary); }

/* ===== Checkbox Grid ===== */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fbfdfe;
    cursor: pointer;
    transition: all 0.18s ease;
    font-size: 13px;
    font-weight: 500;
}

.check-item:hover { border-color: var(--primary-light); background: var(--primary-soft); }

.check-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.check-item input[type="checkbox"]:checked + span {
    color: var(--primary-dark);
    font-weight: 600;
}

.check-item:has(input:checked) {
    background: var(--primary-soft);
    border-color: var(--primary);
    box-shadow: 0 1px 3px rgba(14, 165, 183, 0.15);
}

/* ===== Panels ===== */
.panel {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
}

.panel-header {
    padding: 12px 18px;
    background: linear-gradient(135deg, var(--primary-soft) 0%, #fff 100%);
    border-bottom: 1px solid var(--border-color);
}
.panel-header h4 {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-dark);
}

.panel-body { padding: 16px; }

/* ===== Odontogram ===== */
.odontogram-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid var(--border-light);
    flex-wrap: wrap;
    gap: 12px;
}

.odontogram-toolbar h4 {
    font-family: var(--font-heading);
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toolbar-right { display: flex; gap: 8px; }

.toolbar-center {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.patient-type-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
}

.patient-type-selector label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.patient-type-selector select {
    padding: 6px 10px;
    border: 1.5px solid var(--primary-light);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s ease;
}

.patient-type-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 183, 0.15);
}

.patient-type-selector select:hover {
    border-color: var(--primary);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

.odontogram-wrap {
    background: #fff;
    padding: 24px 16px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow-x: auto;
}

.odontogram-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 14px;
    min-width: max-content;
    padding: 0 8px;
}

.odontogram-quadrant-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 10px;
    min-width: 70px;
    text-align: center;
}

.odontogram-divider {
    width: 2px;
    height: 84px;
    background: var(--border-color);
    margin: 0 10px;
}

.tooth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.tooth-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-top: 3px;
}

.tooth-wrapper > svg,
.tooth-svg {
    width: 68px;
    height: 68px;
    display: block;
    flex-shrink: 0;
    overflow: visible;
}

.tooth-face {
    cursor: pointer;
    transition: opacity 0.18s ease, stroke 0.18s ease;
    stroke: #cbd5e1;
    stroke-width: 1.2;
}

.tooth-face:hover {
    opacity: 0.75;
    stroke: var(--primary-dark);
    stroke-width: 2;
}

.tooth-center-text {
    font-size: 9px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.18s ease;
}

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

.stat-card-highlight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary-dark);
    color: #fff;
}

.stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-card-highlight .stat-label { color: rgba(255, 255, 255, 0.85); }

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

.stat-card-highlight .stat-value { color: #fff; }

/* ===== CIE Grid ===== */
.cie-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 12px 16px;
    align-items: stretch;
}

/* ===== Form Actions ===== */
.form-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.form-actions-wrap {
    align-items: center;
}

.actions-left, .actions-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Botones adicionales */
.btn-info {
    background: linear-gradient(135deg, var(--info) 0%, var(--secondary) 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-info:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4); }

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4); }

/* Modal footer */
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: linear-gradient(135deg, #fcfcfd 0%, #f8fafc 100%);
}

/* Bloque paciente en recetarios/incapacidad */
.recetario-paciente {
    background: linear-gradient(135deg, var(--primary-soft) 0%, #fff 100%);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.recetario-paciente h4 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.recetario-paciente .paciente-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px 24px;
    font-size: 13px;
    margin-top: 8px;
}

.recetario-paciente .paciente-grid div span {
    color: var(--text-tertiary);
    margin-right: 4px;
}
.recetario-paciente .paciente-grid strong { color: var(--text-primary); font-weight: 600; }

/* Grid de medicamentos */
.form-grid-meds {
    grid-template-columns: repeat(3, 1fr);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 41, 66, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: modalFade 0.2s ease;
}

.modal.active { display: flex; }

@keyframes modalFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlide 0.25s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-large { width: min(1400px, 96vw); }

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-soft) 0%, #fff 100%);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}

.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

/* ===== Context Menu ===== */
.context-menu {
    display: none;
    position: fixed;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 2000;
    min-width: 240px;
    overflow: hidden;
    animation: menuFade 0.15s ease;
}

.context-menu.active { display: block; }

@keyframes menuFade {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.context-menu-header {
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

/* Por defecto: una sola columna */
.context-menu-list {
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Cuando el menú tiene muchas opciones (oclusal en modo tratamiento), usar 2 columnas */
.context-menu-list.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px 6px;
    padding: 6px;
    max-height: 280px;
    overflow-y: auto;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12.5px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.12s ease;
    white-space: nowrap;
}

.context-menu-item:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.context-menu-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
    display: inline-block;
}

/* Cuando es un <svg>, asegurarse de que el símbolo interno se vea */
svg.context-menu-color {
    display: inline-block;
    vertical-align: middle;
}

.context-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 8px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: var(--text-primary);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    font-size: 13px;
    font-weight: 500;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show { transform: translateX(0); }
.toast.success { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%); }
.toast.error { background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%); }
.toast.info { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar { width: 220px; }
    .main-content { margin-left: 220px; padding: 20px; }
    .patient-banner-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .cie-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s ease; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 16px; }
    .form-grid, .form-grid-2, .form-grid-3, .form-grid-4 {
        grid-template-columns: 1fr;
    }
    .patient-banner { flex-direction: column; align-items: flex-start; }
    .tabs-header { overflow-x: scroll; }
    .tab-btn { font-size: 12px; padding: 10px 12px; }
    .form-grid-treatment { grid-template-columns: 1fr 1fr; }
    .modal-large { width: 96vw; }
}
