/* Core Styling Variables & CSS Reset Elements */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.bg-slate-50 { background-color: #f8fafc; }
.text-slate-900 { color: #0f172a; }
.antialiased {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Master Grid Canvas Layout Elements Wrapper */
.main-wrapper {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 3rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    padding-top: 1rem;
}

@media (min-width: 640px) {
    .main-wrapper {
        max-width: 64rem; /* Expanded slightly for a clean asymmetric width distribution */
    }
}

/* Header & Meta Branding Styles Rules */
.main-header {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}

.header-logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e293b;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.badge-est {
    font-size: 0.65rem;
    font-weight: 700;
    background-color: #e2e8f0;
    color: #475569;
    padding: 0.125rem 0.375rem;
    border-radius: 0.375rem;
    text-transform: uppercase;
}

.user-ip {
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748b;
    margin-top: 0.125rem;
}

.ip-address {
    font-family: monospace;
    color: #475569;
}

.btn-setup {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 150ms ease;
}
.btn-setup:hover { background-color: #f8fafc; border-color: #cbd5e1; }

/* System Alert & Notification Components */
.alert-box {
    padding: 0.75rem 1rem; border-radius: 0.75rem; font-size: 0.85rem;
    font-weight: 500; margin-bottom: 1rem; border: 1px solid transparent;
}
.alert-success { background-color: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger { background-color: #fef2f2; border-color: #fca5a5; color: #991b1b; }

.banner {
    border-radius: 0.75rem; padding: 0.75rem; display: flex;
    align-items: flex-start; gap: 0.5rem; margin-bottom: 0.75rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.banner-overdue { background-color: #fffbeb; border: 1px solid #fef3c7; color: #92400e; }
.banner-upcoming { background-color: #f0fdf4; border: 1px solid #dcfce7; color: #166534; }
.banner-icon { font-size: 1rem; flex-shrink: 0; line-height: 1.25; }
.banner-body { font-size: 0.8rem; line-height: 1.4; }
.banner-title { font-weight: 700; margin-right: 0.25rem; }
.banner-text { font-weight: 500; }

/* Upcoming Formulation Badge Engine Elements */
.badge-container {
    display: flex;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.upcoming-badge {
    display: inline-flex !important;
    align-items: center !important;
    background-color: #fffbeb !important; /* Brighter cream contrast background */
    border: 1px solid #fde68a !important; /* Clear gold/amber outline border */
    color: #b45309 !important;            /* Rich dark brown text for maximum readability */
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    padding: 0.25rem 0.625rem !important;
    border-radius: 0.375rem !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
    margin-right: 0.375rem !important;
    margin-bottom: 0.375rem !important;
}

/* Content Card Foundations */
.content-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title { font-size: 0.95rem; font-weight: 700; color: #0f172a; letter-spacing: -0.01em; }
.lock-tag { font-size: 0.65rem; font-weight: 700; background-color: #fee2e2; color: #991b1b; padding: 0.25rem 0.5rem; border-radius: 0.375rem; }

/* ========================================================= */
/* GRID LAYOUT ENGINE CONTEXT DEFINITIONS                     */
/* ========================================================= */
/* Mobile Phone Layout Flow Matrix Order Stack Settings      */
.main-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.pane-quick-timeline { order: 1; }
.pane-tasks-meds      { order: 2; }
.pane-meds-issued     { order: 3; }

/* Tablet & Desktop Layout Realignment Engine Settings       */
@media (min-width: 640px) {
    .main-dashboard-grid {
        /* Configured to custom asymmetric 35% / 65% split proportions */
        grid-template-columns: calc(35% - 0.625rem) calc(65% - 0.625rem);
        align-items: start;
        gap: 1.25rem;
    }
    
    /* Left Structural Grid Column Mapping (Tasks & Meds List @ 35%) */
    .pane-tasks-meds {
        grid-column: 1;
        grid-row: 1 / span 2;
        order: unset;
    }
    
    /* Right Structural Grid Column Mapping (Forms & Timelines @ 65%) */
    .pane-quick-timeline {
        grid-column: 2;
        grid-row: 1;
        order: unset;
    }
    .pane-meds-issued {
        grid-column: 2;
        grid-row: 2;
        order: unset;
    }

    /* Inline Badge Realignment for Larger Viewports */
    .badge-container {
        display: inline-flex;
        margin-top: 0;
        vertical-align: middle;
    }

    /* Responsive Inline Core Matrix Layout Engine Rules */
    .responsive-timeline-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: baseline !important;
        gap: 12px !important;
    }
    .responsive-timeline-details {
        display: flex !important;
        flex-direction: row !important;
        align-items: baseline !important;
        gap: 4px !important;
        padding-top: 0 !important;
    }
    .responsive-timeline-comment {
        display: inline !important;
        margin-top: 0 !important;
        padding-left: 0 !important;
        border-left: none !important;
    }
}

/* Configuration Maintenance Subsidiary Panel Layout Block   */
.maintenance-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-top: 1rem;
}
@media (min-width: 640px) {
    .maintenance-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Setup Panel Controls & Layout Structural Internals */
.btn-close-panel { font-size: 0.75rem; font-weight: 600; color: #ef4444; background: none; border: none; cursor: pointer; }
.maintenance-subtitle { font-size: 0.85rem; font-weight: 700; color: #334155; margin-bottom: 0.75rem; border-bottom: 1px solid #f1f5f9; padding-bottom: 0.375rem; }
.maintenance-input-label { display: block; font-size: 0.75rem; font-weight: 600; color: #475569; margin-bottom: 0.25rem; }
.maintenance-field {
    display: block; width: 100%; background-color: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 0.5rem; padding: 0 0.75rem; font-size: 0.85rem; color: #1e293b; outline: none; height: 2.5rem;
}
.maintenance-field:focus { border-color: #3b82f6; background-color: #ffffff; }

/* Shared Global Typography, Forms and Spacing Utilities */
.form-spacing { display: flex; flex-direction: column; gap: 0.875rem; }
.form-spacing-tight { display: flex; flex-direction: column; gap: 0.625rem; }
.list-spacing { display: flex; flex-direction: column; gap: 0.5rem; }

.input-label { display: block; font-size: 0.75rem; font-weight: 600; color: #475569; margin-bottom: 0.375rem; }
.form-select, .form-input {
    display: block; width: 100%; background-color: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 0.75rem; padding: 0 0.75rem; font-size: 0.9rem;
    color: #1e293b; outline: none; transition: all 150ms ease;
}
.form-select { height: 2.75rem; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1rem; padding-right: 2rem; }
.form-input { height: 2.75rem; }
.form-select:focus, .form-input:focus { border-color: #3b82f6; background-color: #ffffff; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1); }

/* Timestamp Composite Component Subgrid */
.timestamp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.375rem; }
.timestamp-header { display: block; font-size: 0.6rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; margin-bottom: 0.25rem; text-align: center; }
.timestamp-field {
    display: block; width: 100%; background-color: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 0.5rem; height: 2.25rem; font-size: 0.85rem; font-weight: 600;
    color: #334155; text-align: center; outline: none; padding: 0;
}
.timestamp-field:focus { border-color: #3b82f6; background-color: #ffffff; }
.select-padding { padding-left: 0.25rem; padding-right: 0.25rem; font-size: 0.75rem; }

/* View & Action Lock States */
.view-locked .form-select,
.view-locked .form-input,
.view-locked .timestamp-field,
.view-locked .maintenance-field,
.view-locked .form-checkbox { background-color: #f1f5f9 !important; border-color: #e2e8f0 !important; color: #94a3b8 !important; cursor: not-allowed; }

/* Interactive Active List Item Rows */
.interactive-card {
    border: 1px solid #e2e8f0; border-radius: 0.75rem; padding: 0.75rem;
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; position: relative; transition: all 150ms ease;
    user-select: none; -webkit-tap-highlight-color: transparent;
}
.interactive-card:active { transform: scale(0.98); }
.interactive-card-med { background-color: #f8fafc; }
.interactive-card-med:hover { background-color: #f0fdfa; border-color: #99f6e4; }
.interactive-card-task { background-color: #f8fafc; }
.interactive-card-task:hover { background-color: #fff7ed; border-color: #ffedd5; }

.card-row-title { font-size: 0.85rem; font-weight: 700; color: #1e293b; display: flex; align-items: center; gap: 0.375rem; }
.tap-hint { font-size: 0.6rem; font-weight: 700; color: #3b82f6; text-transform: uppercase; opacity: 0; transition: opacity 150ms ease; }
.interactive-card:hover .tap-hint { opacity: 1; }
.card-row-subtitle { font-size: 0.7rem; font-weight: 600; color: #64748b; margin-top: 0.125rem; }
.card-row-dosage { font-size: 0.65rem; font-weight: 500; color: #94a3b8; margin-top: 0.125rem; }

/* Condition Pill Status Badges */
.status-badge { font-size: 0.65rem; font-weight: 700; padding: 0.25rem 0.5rem; border-radius: 0.5rem; text-align: center; display: inline-block; }
.status-badge-ready { background-color: #dcfce7; color: #15803d; }
.status-badge-locked { background-color: #f1f5f9; border: 1px dashed #cbd5e1; color: #64748b; font-variant-numeric: tabular-nums; }

/* Action Execution Button Engine Layouts */
.btn-submit {
    display: flex; width: 100%; height: 2.75rem; align-items: center; justify-content: center;
    border-radius: 0.75rem; font-size: 0.9rem; font-weight: 700; cursor: pointer; transition: all 150ms ease; border: none;
}
.btn-submit-active { background-color: #2563eb; color: #ffffff; box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2); }
.btn-submit-active:hover { background-color: #1d4ed8; }
.btn-submit-disabled { background-color: #cbd5e1; color: #94a3b8; cursor: not-allowed; }

.btn-save {
    display: flex; width: 100%; height: 2.25rem; align-items: center; justify-content: center;
    border-radius: 0.5rem; font-size: 0.8rem; font-weight: 700; cursor: pointer; border: none; margin-top: 0.25rem;
}
.btn-save-active { background-color: #0f172a; color: #ffffff; }
.btn-save-active:hover { background-color: #1e293b; }
.btn-save-disabled { background-color: #e2e8f0; color: #94a3b8; cursor: not-allowed; }

/* History Timeline Matrix View Rules */
.empty-history-box { border: 2px dashed #e2e8f0; border-radius: 0.75rem; padding: 1.5rem; text-align: center; }
.empty-italic-text { font-style: italic; color: #94a3b8; font-weight: 500; }
.timeline-divider-list { display: flex; flex-direction: column; }
.timeline-row {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 0.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid #f1f5f9;
}
.timeline-row:last-child { border-bottom: none; padding-bottom: 0; }
.timeline-row:first-child { padding-top: 0; }

/* Three Column Timeline Row Component:
   - Col 1 (Bullet Icon): Auto sizing
   - Col 2 (Date/Time Timestamp): Auto sizing
   - Col 3 (Combined Info Container): Allocated to exactly 40% of the available view track width
*/
.timeline-grid-content { 
    display: grid; 
    grid-template-columns: 5% 15% 80% ; 
    align-items: center; 
    column-gap: 20px; 
    row-gap: 0.375rem;
    min-width: 0; 
    width: 100%; 
}

/* Flex container wrapper inside column 3 to hold items horizontally and avoid vertical layout breaking */
.timeline-details-wrapper {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
    width: 100%;
}

.bullet-blue { color: #3b82f6; font-size: 1.25rem; line-height: 1; }
.bullet-amber { color: #f59e0b; font-size: 1.25rem; line-height: 1; }
.timeline-timestamp { color: #64748b; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.timeline-item-title { color: #1e293b; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 7.5rem; }
.timeline-master-dosage { color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 4rem; flex-shrink: 0; }
.timeline-custom-comment { color: #475569; font-weight: 400; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 0.25rem; border-left: 1px solid #e2e8f0; }
.timeline-system-badge { background-color: #f1f5f9; color: #64748b; font-size: 0.55rem; font-weight: 700; padding: 0.125rem 0.375rem; border-radius: 0.25rem; text-transform: uppercase; flex-shrink: 0; }
.timeline-standalone-comment { color: #334155; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.log-actions { display: flex; align-items: center; gap: 0.25rem; margin-left: 0.5rem; }
.btn-action-edit, .btn-action-delete { background: none; border: none; cursor: pointer; padding: 0.25rem; font-size: 0.75rem; filter: grayscale(0.2); transition: transform 100ms ease; }
.btn-action-edit:hover, .btn-action-delete:hover { transform: scale(1.15); filter: grayscale(0); }
.inline-form { display: inline; }

/* Maintenance Tabular Data Architecture Rules */
.table-border-wrapper { border: 1px solid #e2e8f0; border-radius: 0.5rem; overflow: hidden; background-color: #ffffff; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.table-th { padding: 0.5rem 0.75rem; font-weight: 700; letter-spacing: 0.05em; }
.table-td { padding: 0.5rem 0.75rem; vertical-align: middle; }
.cell-max-width { max-width: 10rem; }
.table-empty-cell { padding: 1rem; text-align: center; font-style: italic; color: #94a3b8; }
.btn-edit-action { font-size: 0.7 intercom; font-weight: 600; color: #2563eb; background: none; border: none; cursor: pointer; }
.btn-edit-action:hover { text-decoration: underline; }

/* Standard Checkbox Inline Layout System */
.checkbox-alignment { display: flex; align-items: center; gap: 0.375rem; }
.form-checkbox { width: 0.875rem; height: 0.875rem; accent-color: #2563eb; cursor: pointer; }
.checkbox-label { font-size: 0.75rem; font-weight: 500; color: #475569; }

/* Dynamic Modal Overlay Window Layers */
.modal-backdrop {
    position: fixed; inset: 0; background-color: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(4px); z-index: 50; display: flex;
    align-items: center; justify-content: center; padding: 1rem;
}

.modal-card { background-color: #ffffff; border-radius: 1rem; width: 100%; max-width: 24rem; padding: 1.25rem; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); }
.modal-title { font-size: 1rem; font-weight: 700; color: #0f172a; margin-bottom: 1rem; }
.modal-input-label { display: block; font-size: 0.75rem; font-weight: 600; color: #475569; margin-bottom: 0.25rem; }

.modal-field {
    display: block; width: 100%; background-color: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 0.75rem; padding: 0 0.75rem; font-size: 1rem;
    color: #1e293b; outline: none; height: 3rem; transition: all 150ms ease;
}
.modal-field:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }

.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.btn-cancel { background-color: #ffffff; border: 1px solid #e2e8f0; color: #475569; font-size: 0.85rem; font-weight: 600; padding: 0.5rem 0.875rem; border-radius: 0.5rem; cursor: pointer; }
.btn-cancel:hover { background-color: #f8fafc; }
.btn-modal-save { background-color: #2563eb; color: #ffffff; font-size: 0.85rem; font-weight: 600; padding: 0.5rem 0.875rem; border-radius: 0.5rem; border: none; cursor: pointer; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.btn-modal-save:hover { background-color: #1d4ed8; }

      
/* ==========================================
   AUTH PORTAL STYLES
   ========================================== */

.auth-container { 
    max-width: 420px; 
    margin: 3rem auto; 
    padding: 1.5rem; 
}

.auth-logo-header {
    text-align: center; 
    margin-bottom: 1.5rem;
}

.auth-logo-title {
    font-size: 1.75rem; 
    font-weight: 800; 
    color: #1e293b;
}

.auth-card { 
    background: #ffffff; 
    padding: 2rem; 
    border-radius: 0.75rem; 
    border: 1px solid #e2e8f0; 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); 
}

.auth-tab-container {
    display: flex; 
    gap: 1rem; 
    margin-bottom: 1.5rem; 
    border-bottom: 1px solid #e2e8f0; 
    padding-bottom: 0.5rem;
}

.tab-btn { 
    background: none; 
    border: none; 
    padding: 0.5rem 1rem; 
    cursor: pointer; 
    font-weight: 600; 
    color: #64748b; 
    border-bottom: 2px solid transparent; 
}

.tab-btn.active { 
    color: #0f172a; 
    border-bottom-color: #3b82f6; 
}

.hidden { 
    display: none !important; 
}

.form-group { 
    margin-bottom: 1.25rem; 
}

.form-group label {
    display: block; 
    margin-bottom: 0.375rem; 
    font-size: 0.85rem; 
    font-weight: 600;
}

.input-field { 
    width: 100%; 
    padding: 0.625rem; 
    border: 1px solid #cbd5e1; 
    border-radius: 0.375rem; 
    font-size: 0.95rem; 
    box-sizing: border-box; 
}

.btn-auth { 
    width: 100%; 
    padding: 0.75rem; 
    background: #2563eb; 
    color: #ffffff; 
    border: none; 
    border-radius: 0.375rem; 
    font-weight: 600; 
    cursor: pointer; 
    margin-top: 0.5rem; 
}

.btn-auth:hover { 
    background: #1d4ed8; 
}

.alert { 
    padding: 0.75rem 1rem; 
    border-radius: 0.375rem; 
    margin-bottom: 1.5rem; 
    font-size: 0.875rem; 
    font-weight: 500; 
}

.alert-danger { 
    background: #fef2f2; 
    color: #991b1b; 
    border: 1px solid #fee2e2; 
}

.alert-success { 
    background: #f0fdf4; 
    color: #166534; 
    border: 1px solid #bbf7d0; 
}

/* Password visibility toggle mechanics */
.password-wrapper { 
    position: relative; 
    width: 100%; 
}

.password-wrapper .input-field { 
    padding-right: 3rem; 
}

.toggle-password { 
    position: absolute; 
    right: 0.75rem; 
    top: 50%; 
    transform: translateY(-50%); 
    background: none; 
    border: none; 
    color: #64748b; 
    font-size: 0.8rem; 
    font-weight: 600; 
    cursor: pointer; 
    user-select: none; 
}

.toggle-password:hover { 
    color: #1e293b; 
}

/* Disclaimer panel styles */
.disclaimer-container {
    border: 1px solid #ccc; 
    padding: 15px; 
    background-color: #f9f9f9; 
    border-radius: 5px;
}

.hidden { display: none !important; }
.scroll-mt-4 { scroll-margin-top: 1rem; }