/* ==========================================================================
   EXPEDIENTE CLÍNICO DIGITAL NOM-004 & NOM-024 (SIRES) - DESIGN SYSTEM
   ========================================================================== */

:root {
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: #f0fdfa;
    --primary-border: #99f6e4;
    
    --navy-900: #0f172a;
    --navy-800: #1e293b;
    --navy-700: #334155;
    
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    --danger: #ef4444;
    --danger-light: #fee2e2;
    --danger-text: #991b1b;
    
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-text: #92400e;

    --success: #10b981;
    --success-light: #ecfdf5;
    --success-text: #065f46;

    --info: #0284c7;
    --info-light: #e0f2fe;

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

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    background-color: #f1f5f9;
    color: var(--slate-800);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
}

img, svg, canvas, input, select, textarea, button {
    max-width: 100%;
}

/* ==========================================================================
   UI ICONS SYSTEM (CLINICAL SAAS / LUCIDE STYLE)
   ========================================================================== */
.ui-icon {
    display: inline-block;
    width: 15px;
    height: 15px;
    vertical-align: -2px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
    transition: color 0.15s ease, stroke 0.15s ease;
}
.ui-icon-xs { width: 11px; height: 11px; vertical-align: -1px; }
.ui-icon-sm { width: 13px; height: 13px; vertical-align: -1.5px; }
.ui-icon-md { width: 16px; height: 16px; vertical-align: -2px; }
.ui-icon-lg { width: 18px; height: 18px; vertical-align: -2.5px; }
.ui-icon-xl { width: 22px; height: 22px; vertical-align: middle; }
.ui-icon-brand { width: 22px; height: 22px; stroke-width: 2.2; }

/* TOP HEADER */
.top-navbar {
    background-color: var(--navy-900);
    color: #ffffff;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 2px solid var(--primary);
    box-shadow: var(--shadow-md);
    z-index: 50;
    flex-shrink: 0;
    gap: 16px;
}

.top-navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.mobile-menu-btn {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    width: 38px;
    height: 38px;
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.18s ease;
}

.mobile-menu-btn:hover, .mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-close-btn {
    display: none;
    background: var(--slate-100);
    border: 1px solid var(--slate-300);
    color: var(--slate-700);
    border-radius: 4px;
    width: 26px;
    height: 26px;
    font-size: 13px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-text-block {
    min-width: 0;
}

.brand-logo-badge {
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #ffffff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--slate-400);
    display: flex;
    gap: 8px;
    align-items: center;
}

.norm-badge {
    background: rgba(13, 148, 136, 0.25);
    color: #5eead4;
    border: 1px solid rgba(94, 234, 212, 0.3);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.search-box {
    position: relative;
    width: 320px;
}

.search-box input {
    width: 100%;
    background-color: var(--navy-800);
    border: 1px solid var(--slate-700);
    color: #ffffff;
    padding: 8px 12px 8px 36px;
    border-radius: var(--radius-md);
    font-size: 13px;
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.25);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slate-400);
    font-size: 14px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.3);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
    max-width: 100%;
    box-sizing: border-box;
    line-height: 1.35;
    text-align: center;
    user-select: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
}

.btn-secondary {
    background-color: var(--slate-100);
    color: var(--slate-700);
    border-color: var(--slate-300);
}
.btn-secondary:hover {
    background-color: var(--slate-200);
    color: var(--slate-900);
}

.btn-outline-primary {
    background-color: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline-primary:hover {
    background-color: var(--primary-light);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* MAIN LAYOUT WRAPPER */
.app-container {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 250px;
    background-color: #ffffff;
    border-right: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-500);
}

.nav-list {
    list-style: none;
    padding: 10px 8px;
    overflow-y: auto;
    flex: 1;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--slate-700);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.nav-link:hover {
    background-color: var(--slate-100);
    color: var(--slate-900);
}

.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    border-left: 3px solid var(--primary);
}

.nav-link-icon {
    font-size: 17px;
    width: 22px;
    text-align: center;
}

/* PATIENT SELECTOR DRAWER / MINI LIST */
.sidebar-patient-summary {
    padding: 14px;
    background-color: var(--slate-50);
    border-top: 1px solid var(--slate-200);
    font-size: 12px;
}

.dr-badge-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dr-avatar {
    width: 34px;
    height: 34px;
    background: var(--navy-800);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.dr-info-name {
    font-weight: 700;
    color: var(--slate-900);
    line-height: 1.2;
}

.dr-info-ced {
    font-size: 11px;
    color: var(--slate-500);
}

/* CONTENT VIEWPORT */
.content-viewport {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f8fafc;
}

/* ACTIVE PATIENT BANNER */
.patient-banner {
    background-color: #ffffff;
    border-bottom: 1px solid var(--slate-200);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.patient-profile-snippet {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1 1 auto;
}

.banner-quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.patient-avatar-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #0284c7 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.3);
}

.patient-details-text h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--slate-900);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-primary {
    background-color: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary-border);
}

.badge-blood {
    background-color: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.badge-info {
    background-color: var(--info-light);
    color: var(--info);
}

.patient-meta-row {
    font-size: 12px;
    color: var(--slate-600);
    display: flex;
    gap: 16px;
}

.allergy-warning-bar {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: flashAllergy 3s infinite;
}

@keyframes flashAllergy {
    0%, 100% { border-color: #fca5a5; }
    50% { border-color: #dc2626; background-color: #fee2e2; }
}

.banner-quick-actions {
    display: flex;
    gap: 8px;
}

/* SCROLLABLE TAB CONTENT BODY */
.tab-content-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 85px 24px;
    -webkit-overflow-scrolling: touch;
}

/* CLINICAL FORM STYLES */
.clinical-card {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.clinical-card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--slate-200);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.card-header > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.card-header-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--navy-900);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    word-break: break-word;
}

.card-header-badge {
    font-size: 11px;
    color: var(--slate-500);
    white-space: normal;
}

.card-body {
    padding: 20px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* FORM GRIDS */
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

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

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

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 14px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-700);
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.form-group .req {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-md);
    background-color: #ffffff;
    color: var(--slate-900);
    font-family: inherit;
    transition: all 0.18s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

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

/* VITALS MONITOR STRIP */
.vitals-monitor-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.vital-card {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
    position: relative;
    border-top: 3px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.vital-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--slate-500);
    text-transform: uppercase;
}

.vital-input-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    margin-top: 6px;
}

.vital-input-row input {
    width: 70px;
    text-align: center;
    font-size: 18px;
    font-weight: 800;
    border: none;
    border-bottom: 2px solid var(--slate-300);
    padding: 2px 0;
    color: var(--navy-900);
}

.vital-input-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.vital-unit {
    font-size: 11px;
    color: var(--slate-500);
    font-weight: 600;
}

.vital-sub {
    font-size: 11px;
    margin-top: 4px;
    font-weight: 600;
}

/* IMC BADGE COLORS */
.imc-normal { color: #059669; }
.imc-overweight { color: #d97706; }
.imc-obese { color: #dc2626; }

/* CIE-10 SEARCH AND TAGS */
.cie10-autocomplete-box {
    position: relative;
}

.cie10-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.cie10-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12.5px;
    border-bottom: 1px solid var(--slate-100);
    transition: background 0.1s ease;
}

.cie10-item:hover {
    background-color: var(--primary-light);
}

.cie10-code-tag {
    font-weight: 700;
    color: var(--primary);
    margin-right: 6px;
    font-family: monospace;
}

/* FLOATING SAVE BAR */
.floating-save-bar {
    position: fixed;
    bottom: 20px;
    right: 24px;
    background: var(--navy-900);
    color: white;
    padding: 10px 18px;
    border-radius: 30px;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 40;
    border: 1px solid var(--slate-700);
}

/* SIGNATURE PAD CANVAS */
.signature-canvas-wrapper {
    border: 2px dashed var(--slate-300);
    border-radius: var(--radius-md);
    background-color: #fafafa;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    margin-top: 8px;
}

.signature-canvas-wrapper canvas {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    cursor: crosshair;
    touch-action: none;
    max-width: 100%;
    height: auto;
}

.signature-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* MODAL STYLES */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 720px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    background: var(--slate-50);
    border-bottom: 1px solid var(--slate-200);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--navy-900);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--slate-400);
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close-btn:hover {
    background: var(--slate-200);
    color: var(--slate-700);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    background: var(--slate-50);
    border-top: 1px solid var(--slate-200);
    padding: 14px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* TABLES IN APP */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.app-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.app-table th {
    background: var(--slate-100);
    color: var(--slate-700);
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid var(--slate-200);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.app-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--slate-200);
    color: var(--slate-800);
}

.app-table tbody tr:hover {
    background-color: var(--slate-50);
}

/* TOAST NOTIFICATION */
#toast-container {
    position: fixed;
    top: 75px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--navy-900);
    color: white;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid var(--primary);
    animation: slideInToast 0.3s ease;
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-danger { border-left: 4px solid var(--danger); }
.toast-icon { display: flex; align-items: center; flex-shrink: 0; }
.toast-icon .ui-icon { width: 16px; height: 16px; }

@keyframes slideInToast {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* PRESCRIPTION MEDICINE ROW */
.med-row {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    position: relative;
}

.med-row-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 12px;
    color: var(--primary);
}

.remove-med-btn {
    color: var(--danger);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 11px;
}

/* TIMELINE FOR SOAP NOTES */
.timeline {
    position: relative;
    padding-left: 24px;
    border-left: 2px solid var(--slate-300);
    margin-left: 10px;
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-dot {
    position: absolute;
    left: -31px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-card {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    word-break: break-word;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--slate-100);
    padding-bottom: 8px;
}

/* TAB NAVIGATION HEADER */
.tabs-nav-bar {
    display: flex;
    gap: 4px;
    background: #ffffff;
    padding: 8px 20px 0 20px;
    border-bottom: 1px solid var(--slate-200);
    overflow-x: auto;
    align-items: flex-end;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--slate-600);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.tab-btn .ui-icon {
    color: var(--slate-400);
    transition: color 0.15s ease;
}

.tab-btn:hover {
    color: var(--slate-900);
    background: var(--slate-50);
}

.tab-btn:hover .ui-icon {
    color: var(--slate-700);
}

.tab-btn.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom-color: var(--primary);
    background: var(--primary-light);
}

.tab-btn.active .ui-icon {
    color: var(--primary);
}

/* SUB-TABS NAVIGATION */
.subtabs-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--slate-200);
    padding-bottom: 8px;
}

.subtab-btn {
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--slate-600);
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.subtab-btn:hover {
    background: var(--slate-200);
    color: var(--slate-800);
}

.subtab-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 1px 3px rgba(13, 148, 136, 0.3);
}

/* COMPLIANCE CHECKLIST & SIRES */
.compliance-scorecard {
    background: linear-gradient(135deg, #047857 0%, #0d9488 100%);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.2);
}

.score-number {
    font-size: 42px;
    font-weight: 800;
    line-height: 1;
}

.score-label {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 4px;
}

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

.compliance-table th {
    background: var(--slate-100);
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--slate-700);
    border-bottom: 2px solid var(--slate-200);
}

.compliance-table td {
    padding: 12px;
    border-bottom: 1px solid var(--slate-200);
    font-size: 12px;
}

.badge-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 11px;
}

.curp-validation-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    margin-top: 4px;
    font-weight: 600;
}

.sires-panel-box,
.sipres-panel-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================================
   RESPONSIVE DESIGN & MOBILE OPTIMIZATIONS (TABLETS & SMARTPHONES)
   ========================================================================== */

/* GENERAL RESPONSIVE UTILITIES */
.section-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
}

.section-title-bar > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.section-title-bar .btn {
    flex-shrink: 0;
}

.form-actions-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
    width: 100%;
}

.col-span-2-desktop {
    grid-column: span 2;
}

.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0;
}

.app-table,
.compliance-table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
}

.sires-compliance-banner {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.sires-compliance-banner > div {
    min-width: 0;
}

.consent-type-card {
    background: #f8fafc;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.consent-type-card label {
    line-height: 1.4;
    word-break: break-word;
}

.tabs-nav-bar {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-border) transparent;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.tabs-nav-bar::-webkit-scrollbar {
    height: 3px;
    display: block;
}

.tabs-nav-bar::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.floating-save-label {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   BREAKPOINTS: LAPTOPS & MID-SIZED WINDOWS (<= 1360px)
   ========================================================================== */
@media (max-width: 1360px) {
    .status-pill {
        display: none !important;
    }

    .search-box {
        max-width: 250px;
        min-width: 160px;
        flex: 1 1 auto;
    }

    .top-navbar {
        padding: 0 16px;
        gap: 10px;
    }

    .patient-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 18px;
    }

    .banner-quick-actions {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }

    .banner-quick-actions .btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ==========================================================================
   BREAKPOINTS: TABLETS & SMALL LAPTOPS (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

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

    .vitals-monitor-strip {
        grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
    }

    .modal-content {
        max-width: 90vw;
    }

    .modal-content .form-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ==========================================================================
   BREAKPOINTS: PHABLETS & TABLETS VERTICAL (<= 992px)
   ========================================================================== */
@media (max-width: 992px) {
    .mobile-menu-btn {
        display: inline-flex;
    }

    .sidebar-close-btn {
        display: inline-flex;
    }

    .sidebar-backdrop {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -320px;
        width: 280px;
        max-width: 85vw;
        background-color: #ffffff;
        z-index: 1050;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.25);
        transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        height: 100%;
    }

    .sidebar.active {
        left: 0;
    }

    .app-container {
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
    }

    .top-navbar {
        height: auto;
        min-height: 56px;
        padding: 8px 14px;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        column-gap: 12px;
        row-gap: 8px;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
    }

    .top-navbar-left {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        overflow: hidden;
    }

    .brand-subtitle {
        display: none;
    }

    .search-box {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        width: 100%;
        max-width: 100%;
        margin-top: 0;
    }

    .search-box input {
        padding: 7px 12px 7px 34px;
        font-size: 13.5px;
    }

    .top-actions {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 6px;
        flex-shrink: 0;
    }

    .top-actions .btn-text {
        display: none !important;
    }

    .top-actions .btn {
        padding: 0 !important;
        font-size: 14px;
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

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

    .modal-content {
        width: 92% !important;
        max-width: 92% !important;
    }

    .modal-content .form-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .compliance-scorecard {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 16px;
        padding: 16px;
    }

    .compliance-scorecard > div:last-child {
        text-align: center !important;
        width: 100%;
    }

    .compliance-scorecard > div:last-child > div {
        justify-content: center !important;
        width: 100%;
    }

    .compliance-scorecard .btn {
        flex: 1 1 auto;
        min-width: 140px;
    }

    .sires-panel-box,
    .sipres-panel-box {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 10px;
    }

    .card-header {
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* ==========================================================================
   BREAKPOINTS: MOBILE PHONES (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .form-control, input[type="text"], input[type="number"], input[type="date"], input[type="tel"], input[type="email"], select, textarea {
        font-size: 16px !important;
    }

    .btn {
        max-width: 100%;
        line-height: 1.35;
    }

    .top-navbar {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        overflow: hidden;
        padding: 8px 10px;
        height: auto;
        min-height: 54px;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        grid-template-rows: auto auto !important;
        column-gap: 8px !important;
        row-gap: 6px !important;
        align-items: center;
    }

    .top-navbar-left {
        grid-column: 1 / 2 !important;
        grid-row: 1 / 2 !important;
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 0 !important;
        overflow: hidden;
    }

    .mobile-menu-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
        flex-shrink: 0;
    }

    .brand-section {
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .brand-text-block {
        min-width: 0;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .brand-logo-badge {
        width: 28px;
        height: 28px;
        font-size: 14px;
        flex-shrink: 0;
    }

    .brand-title {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        max-width: 100%;
    }

    .top-actions {
        grid-column: 2 / 3 !important;
        grid-row: 1 / 2 !important;
        gap: 5px;
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        flex-shrink: 0;
    }

    .top-actions .btn-text {
        display: none !important;
    }

    .top-actions .btn {
        padding: 0 !important;
        font-size: 14px;
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .search-box {
        grid-column: 1 / 3 !important;
        grid-row: 2 / 3 !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* Active Patient Banner */
    .patient-banner {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 12px;
        gap: 8px;
    }

    .patient-profile-snippet {
        align-items: center;
        gap: 8px;
    }

    .patient-avatar-circle {
        width: 36px;
        height: 36px;
        font-size: 13px;
        flex-shrink: 0;
    }

    .patient-details-text h2 {
        font-size: 13.5px;
        flex-wrap: wrap;
        gap: 4px;
        word-break: break-word;
    }

    .patient-meta-row {
        flex-wrap: wrap;
        gap: 3px 8px;
        font-size: 10.5px;
    }

    .banner-quick-actions {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 4px;
        width: 100%;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .banner-quick-actions::-webkit-scrollbar {
        display: none;
    }

    .banner-quick-actions .btn {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 11px;
        padding: 5px 8px;
    }

    /* Horizontal scrollable Tabs Bar */
    .tabs-nav-bar {
        padding: 6px 8px;
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(13, 148, 136, 0.35) transparent;
        background: #ffffff;
    }

    .tabs-nav-bar::-webkit-scrollbar {
        height: 3px;
        display: block;
    }

    .tabs-nav-bar::-webkit-scrollbar-thumb {
        background: rgba(13, 148, 136, 0.4);
        border-radius: 3px;
    }

    .tab-btn {
        padding: 7px 10px;
        font-size: 11.5px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Content body */
    .tab-content-body {
        padding: 12px 10px 90px 10px;
        overflow-x: hidden;
    }

    /* Clinical Cards */
    .clinical-card {
        margin-bottom: 12px;
        border-radius: var(--radius-md);
        overflow: hidden;
    }

    .card-header {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .card-header-title {
        font-size: 13px;
        line-height: 1.35;
        flex-wrap: wrap;
    }

    .card-body {
        padding: 12px 10px;
        overflow-x: hidden;
    }

    /* Single column form grids on mobile */
    .form-grid-2,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .form-grid-2 > *,
    .form-grid-3 > *,
    .form-grid-4 > *,
    .col-span-2-desktop {
        grid-column: auto !important;
    }

    /* Form actions bar on mobile */
    .form-actions-bar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
        margin-top: 16px;
    }

    .form-actions-bar .btn,
    .form-actions-bar button {
        width: 100% !important;
        text-align: center;
        justify-content: center;
        white-space: normal;
        word-break: break-word;
        padding: 11px 14px;
    }

    .section-title-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .section-title-bar .btn {
        width: 100%;
        justify-content: center;
    }

    /* Vitals monitor */
    .vitals-monitor-strip {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
        margin-bottom: 12px;
    }

    .vital-card {
        padding: 8px 6px;
        min-width: 0;
        overflow: hidden;
    }

    .vital-label {
        font-size: 9.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .vital-input-row {
        gap: 2px;
    }

    .vital-input-row input {
        width: 48px;
        font-size: 16px;
    }

    .vital-unit {
        font-size: 9px;
    }

    .vital-sub {
        font-size: 9.5px;
    }

    /* Signature Canvas on mobile */
    .signature-canvas-wrapper {
        width: 100%;
        padding: 6px;
        box-sizing: border-box;
    }

    .signature-canvas-wrapper canvas {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        aspect-ratio: 500 / 150;
        touch-action: none;
    }

    .signature-actions {
        width: 100%;
        justify-content: center;
    }

    /* Floating Save Bar */
    .floating-save-bar {
        left: 10px;
        right: 10px;
        bottom: 10px;
        padding: 8px 12px;
        border-radius: var(--radius-lg);
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        max-width: calc(100vw - 20px);
        box-sizing: border-box;
    }

    .floating-save-label {
        font-size: 11px;
        max-width: calc(100% - 130px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .floating-save-label kbd {
        display: none;
    }

    .floating-save-bar .btn {
        padding: 6px 12px;
        font-size: 11.5px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Modals on mobile */
    .modal-content {
        width: 96% !important;
        max-width: 96% !important;
        max-height: 94vh;
        border-radius: 12px;
        margin: 8px auto;
    }

    .modal-header {
        padding: 12px 14px;
        gap: 8px;
    }

    .modal-title {
        font-size: 13.5px;
        line-height: 1.35;
        min-width: 0;
        flex: 1 1 auto;
        word-break: break-word;
    }

    .modal-close-btn {
        width: 32px;
        height: 32px;
        font-size: 20px;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .modal-body {
        padding: 14px 12px;
    }

    .modal-footer {
        padding: 10px 14px;
        flex-direction: column-reverse;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100% !important;
        padding: 10px;
        font-size: 13px;
    }

    /* Subtabs */
    .subtabs-bar {
        display: flex;
        flex-wrap: wrap;
        padding-bottom: 6px;
        gap: 6px;
        width: 100%;
        margin-bottom: 16px;
    }

    .subtab-btn {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 100px;
        white-space: normal;
        text-align: center;
        font-size: 11.5px;
        padding: 7px 6px;
        line-height: 1.25;
        border-radius: var(--radius-md);
    }

    /* Compliance scorecard */
    .compliance-scorecard {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 12px;
        padding: 14px;
    }

    .score-number {
        font-size: 32px;
    }

    .score-label {
        font-size: 12px;
    }

    .sires-panel-box,
    .sipres-panel-box {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 10px;
        padding: 12px;
    }

    /* Timeline in SOAP */
    .timeline {
        padding-left: 14px;
        margin-left: 6px;
    }

    .timeline-dot {
        left: -21px;
        width: 10px;
        height: 10px;
    }

    .timeline-card {
        padding: 12px;
        word-break: break-word;
        overflow: hidden;
    }

    .timeline-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .timeline-header > div:last-child {
        width: 100%;
        justify-content: space-between;
    }

    /* Tables */
    .app-table th,
    .app-table td,
    .compliance-table th,
    .compliance-table td {
        padding: 8px 10px;
        font-size: 11px;
    }
}

/* ==========================================================================
   BREAKPOINTS: VERY SMALL SCREENS (<= 380px, e.g. iPhone SE / Galaxy Mini)
   ========================================================================== */
@media (max-width: 380px) {
    .brand-title {
        font-size: 12px;
        max-width: 140px;
    }

    .brand-logo-badge {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }

    .mobile-menu-btn {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .top-actions .btn {
        padding: 0 !important;
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
    }

    .vitals-monitor-strip {
        grid-template-columns: 1fr 1fr !important;
        gap: 6px;
    }

    .vital-input-row input {
        width: 40px;
        font-size: 14px;
    }

    .floating-save-label {
        font-size: 10px;
        max-width: calc(100% - 115px);
    }

    .floating-save-bar .btn {
        padding: 5px 8px;
        font-size: 11px;
    }
}


