:root {
    --primary: #1f3a6d;
    --bg: #f4f7fa;
    --white: #ffffff;
    --text-gray: #777;
}

/* I-update ang body settings */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f8fafc; /* Mas hayag nga background */
    color: #1e293b;
    line-height: 1.5;
}

/* Dugangi og padding ang main container area */
.dual-container {
    margin: 20px 30px; /* Mas lapad nga margin sa kilid */
    gap: 24px;
}

/* --- HEADER --- */
/* I-replace ang tibuok header block nimo ani */
.header {
    background: #ffffff; /* Puti ang background */
    color: #1f3a6d;    /* Blue ang text */
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0; /* Nipis nga linya sa ubos */
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: #1f3a6d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header small {
    display: block;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 2px;
}

/* Mao ni ang total count box sa tuo */
.header .total-employees-badge {
    background: #eff6ff;
    color: #1e40af;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid #dbeafe;
}

.hidden { display: none; }

/* --- CARDS --- */
.cards {
    display: flex;
    gap: 20px;
    padding: 25px;
}
/* I-replace ang .card style nimo ani */
.card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-top: 5px solid #ccc; 
    border-left: none;
    border-radius: 12px;
    padding: 24px;
    flex: 1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.card i { position: absolute; top: 20px; right: 20px; font-size: 1.5rem; opacity: 0.2; }
.card h1 { margin: 5px 0; font-size: 2.2rem; color: #1f3a6d; }
.card p  { margin: 0; color: var(--text-gray); font-weight: 500; }
.card .class-names { display: block; font-size: 0.72rem; color: #888; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

.card.blue   { border-top-color: #1e40af; }
.card.green  { border-top-color: #15803d; }
.card.yellow { border-top-color: #b45309; }
.card.red    { border-top-color: #b91c1c; }

.card h1 { 
    margin: 10px 0; 
    font-size: 2.2rem; 
    font-weight: 800;
    color: #0f172a; 
    letter-spacing: -1px;
}

/* --- TABLE WRAPPER --- */
.dual-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 0 10px 25px 10px;
}
/* I-replace o i-update kini nga mga table styles */
.table-container {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0; /* Nipis nga border sa tibuok table */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

th {
    background: #f1f5f9; /* Light gray header para dili sakit sa mata */
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 16px 20px;
    border-bottom: 2px solid #e2e8f0;
}

tr td {
    padding: 16px 20px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

/* Hover effect para sa tibuok row */
tr:hover td {
    background-color: #f8fafc !important;
    transition: background-color 0.2s ease;
}

/* --- CONSULTATION PANEL (inside modal) --- */
.consultation-form .consult-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.consultation-form .consult-grid.full-width { grid-template-columns: 1fr; }
.consultation-form .input-group { display: flex; flex-direction: column; gap: 4px; }
.consultation-form .input-group.full-width { grid-column: 1 / -1; }
.consultation-form .select-search-group { display: grid; gap: 8px; }
.consultation-form .select-search-group input,
.consultation-form .select-search-group select {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-size: 0.9rem;
}
.consultation-form .select-search-group input {
    min-height: 38px;
}
.consultation-form .search-results {
    position: relative;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    margin-top: 4px;
    box-shadow: 0 8px 18px rgba(0,0,0,0.08);
    z-index: 20;
}
.consultation-form .search-results.hidden {
    display: none;
}
.consultation-form .search-results .result-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.88rem;
    border-bottom: 1px solid #f0f0f0;
}
.consultation-form .search-results .result-item:last-child {
    border-bottom: none;
}
.consultation-form .search-results .result-item:hover {
    background: #f5f8ff;
}

.consult-list {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 10px;
    background: #fbfbfb;
}
.consult-item {
    border-bottom: 1px solid #ddd;
    padding: 8px 0;
    font-size: 0.85rem;
}
.consult-item:last-child { border-bottom: none; }

/* --- TOOLBAR --- */
.toolbar {
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}
.search-box { position: relative; flex: 0 1 380px; min-width: 250px; }
.search-box i { position: absolute; left: 9px; top: 9px; color: #aaa; font-size: 0.75rem; }
/* I-replace ang .search-box input block nimo ani */
.search-box input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    background-color: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    box-sizing: border-box;
    font-size: 0.85rem;
    color: #334155;
    transition: all 0.2s ease;
}

.search-box input:focus {
    background-color: #ffffff;
    border-color: #1f3a6d;
    box-shadow: 0 0 0 4px rgba(31, 58, 109, 0.1);
}

.search-box i {
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: #94a3b8;
}

select {
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    font-size: 0.75rem;
    min-width: 70px;
}

/* Filter Search Container */
.filter-search {
    position: relative;
    display: flex;
    align-items: center;
}

/* I-replace ang .add-btn block nimo ani */
.add-btn {
    background: linear-gradient(135deg, #1f3a6d 0%, #3b82f6 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.8rem;
    box-shadow: 0 4px 10px rgba(31, 58, 109, 0.2);
    transition: all 0.2s ease;
}

.add-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 15px rgba(31, 58, 109, 0.3);
    filter: brightness(1.1);
}


table { width: 100%; min-width: 1200px; border-collapse: collapse; }
/* I-replace ang imong karaan nga 'th' ani nga block */
/* I-replace ang imong 'th' ani */
th {
    background-color: #f1f5f9;
    color: #475569;
    text-align: left;
    padding: 14px 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 12px 12px;
    border-bottom: 1px solid #eee;
    font-size: 0.88rem;
    white-space: nowrap;
}
tr:hover td { background: #f5f8ff; }
tbody tr { background: transparent !important; }

/* I-update ang Gender ug Class tags */
.gender-tag, .class-tag {
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.7rem;
}

.Male { 
    background: #e3f2fd; 
    color: #1565c0; 
    border: 1px solid #bbdefb;
}

.Female { 
    background: #fdf2f8; 
    color: #be185d; 
    border: 1px solid #fce7f3;
}

.classA { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.classB { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.classC { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* --- PAGINATION --- */
.pagination {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #eee;
}
.page-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    margin: 0 2px;
}
.page-btn.active { background: #1f3a6d; color: white; border-color: #1f3a6d; }

/* --- ACTION BUTTONS --- */
/* I-replace ang .action-btn, .edit-btn, .view-btn, .delete-btn blocks nimo ani */
.action-btn {
    border: 1px solid transparent;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    height: auto;
}

.edit-btn { 
    background: #eff6ff; 
    color: #1d4ed8; 
}
.edit-btn:hover { background: #dbeafe; }

.view-btn { 
    background: #f0fdf4; 
    color: #15803d; 
}
.view-btn:hover { background: #dcfce7; }

.delete-btn { 
    background: #fef2f2; 
    color: #b91c1c; 
}
.delete-btn:hover { background: #fee2e2; }

/* --- UNDO BAR --- */
.undo-bar {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff9e6;
    border: 1px solid #ffcc80;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 10px 14px;
    border-radius: 10px;
    z-index: 10000;
}

/* --- MODAL --- */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    overflow-y: auto;
    overflow-x: hidden;
    align-items: center;
    justify-content: center;
}
.modal .modal-content:not(.wide-modal) {
    margin: 0;
    width: 100%;
    max-width: 520px;
    background: white;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.wide-modal {
    background: white;
    margin: 20px auto;
    width: 90%;
    max-width: 960px;
    height: auto;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.select-search-group { display: grid; gap: 8px; }
.select-search-group input,
.select-search-group select {
    background: #fff;
    color: #1f3a6d;
    border: 1px solid #c4cdd9;
    border-radius: 8px;
    width: 100%;
    padding: 12px 14px;
    font-size: 0.95rem;
    outline: none;
}
.select-search-group input:focus,
.select-search-group select:focus { border-color: #1f3a6d; }
.search-results { display: none; border-radius: 8px; background: #fff; border: 1px solid #c4cdd9; max-height: 240px; overflow-y: auto; }
.search-results.hidden { display: none; }
.search-results .result-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #eef2f7; }
.search-results .result-item:last-child { border-bottom: none; }
.search-results .result-item:hover { background: #f4f7fb; }
.search-results .result-item span { color: #556476; font-size: 0.82rem; }


.step-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px 0;
    background: #f0f4fa;
    flex-wrap: wrap;
}
.step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #d0d8e8;
    color: #555;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    transition: all 0.2s;
}
.step-dot.active { background: #1f3a6d; color: #fff; border-color: #1f3a6d; transform: scale(1.15); }
.step-dot.done   { background: #4caf50; color: #fff; border-color: #4caf50; }

/* --- MODAL HEADER --- */
.modal-header {
    background: #1f3a6d;
    color: white;
    padding: 18px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-radius: 12px 12px 0 0;
}
.form-container { padding: 25px; background: #ffffff; }

#consultDetailContent {
    padding: 0;
}

/* --- VIEW CONTENT --- */
#viewContent {
    display: block;
    background: #f7f9fb;
    border: 1px solid #dde5f1;
    border-radius: 10px;
    padding: 15px;
}
.profile-card {
    background: #ffffff;
    border: 1px solid #dee4ef;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(20,40,70,0.06);
    font-size: 0.9rem;
}
.profile-card strong {
    display: block;
    font-size: 0.78rem;
    color: #1f3a6d;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.consult-history-row {
    border: 1px solid #d5e0f3;
    background: #f3f7ff;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    color: #1f3a6d;
    width: 100%;
}
.consult-history-row:hover { background: #e7edff; }

/* --- MODAL FOOTER --- */
.modal-footer {
    padding: 15px 25px;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 2px solid #eee;
    flex-shrink: 0;
    border-radius: 0 0 12px 12px;
    flex-wrap: wrap;
}

/* --- FORM COMPONENTS --- */
.section-title {
    color: #1f3a6d;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
    margin-bottom: 20px;
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: bold;
}
.section-subtitle {
    color: #1f3a6d;
    font-size: 0.88rem;
    font-weight: 700;
    margin: 20px 0 10px;
    text-transform: uppercase;
}
.subsection-title {
    display: block;
    margin: 22px 0 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1f3a6d;
    text-transform: uppercase;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px;
}

.form-section { margin-bottom: 10px; }
.step { display: none; }
.step.active { display: block; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(150px,1fr)); gap: 15px; margin-bottom: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(180px,1fr)); gap: 15px; margin-bottom: 15px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(180px,1fr)); gap: 15px; margin-bottom: 15px; }
.grid-1 { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 15px; }

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.input-group.full-width { grid-column: 1 / -1; }

.input-group label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #444;
    flex-wrap: wrap;
}
.input-group label input[type="checkbox"] {
    margin: 0;
    width: 18px;
    height: 18px;
    accent-color: #1f3a6d;
    transform: none;
}
.input-group label input[type="checkbox"] + * {
    white-space: normal;
}

.req { color: #d32f2f; }

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccd0d5;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 0.88rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    border-color: #1f3a6d;
    outline: none;
    box-shadow: 0 0 0 2px rgba(31,58,109,0.12);
}

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

.save-btn {
    background: #1f3a6d;
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95rem;
    transition: background 0.2s;
}
.save-btn:hover { background: #162d56; }

.cancel-btn {
    background: #e0e0e0;
    color: #333;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
}
.cancel-btn:hover { background: #ccc; }

.close { cursor: pointer; font-size: 24px; color: white; line-height: 1; }

/* --- CONSULTATION DETAIL MODAL --- */
.consult-detail-wrapper {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.consult-header-section {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e8ecf1;
}

.consult-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1f3a6d, #2d5aa8);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    flex-shrink: 0;
}

.consult-info {
    flex: 1;
}

.consult-name-row {
    margin-bottom: 8px;
}

.consult-patient-name {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1f3a6d;
}

.consult-badges {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.emp-id-badge,
.consult-type-badge {
    display: inline-block;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 500;
}

.emp-id-badge {
    background: #e8f0ff;
    color: #1f3a6d;
}

.consult-type-badge {
    background: #d4f1d4;
    color: #2e7d32;
}

.consult-datetime {
    text-align: right;
}

.consult-datetime-label {
    font-size: 0.8rem;
    color: #667085;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    font-weight: 600;
}

.consult-datetime-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f3a6d;
}

/* Vital Signs Section */
.vital-signs-section {
    padding-bottom: 20px;
    border-bottom: 1px solid #e8ecf1;
}

.section-title {
    margin: 0 0 16px 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: #1f3a6d;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

.vital-card {
    background: #f8fafb;
    border: 1px solid #e8ecf1;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.vital-label {
    font-size: 0.8rem;
    color: #667085;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    font-weight: 600;
}

.vital-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f3a6d;
}

.vital-unit {
    font-size: 0.85rem;
    font-weight: 500;
    color: #667085;
    margin-left: 4px;
}

/* Complaint and Plan Section */
.complaint-plan-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.complaint-box,
.plan-box {
    border-left: 4px solid #1f3a6d;
    padding: 16px;
    background: #f8fafb;
    border-radius: 0 8px 8px 0;
}

.complaint-box {
    border-left-color: #e74c3c;
    background: #fdf3f3;
}

.plan-box {
    border-left-color: #27ae60;
    background: #f3fdf7;
}

.complaint-content,
.plan-content {
    font-size: 0.95rem;
    color: #333;
    line-height: 1.5;
    margin-top: 8px;
}

/* Prescriptions Section */
.prescriptions-section {
    padding-top: 20px;
    border-top: 1px solid #e8ecf1;
}

.prescriptions-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.prescription-item-view {
    background: #f8fafb;
    border: 1px solid #e8ecf1;
    border-radius: 8px;
    padding: 14px;
}

.prescription-header-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

.prescription-date-mini {
    font-size: 0.85rem;
    color: #1f3a6d;
    font-weight: 600;
}

.prescription-count {
    background: #1f3a6d;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.prescription-medicines {
    margin-bottom: 10px;
}

.medicine-item {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.medicine-item strong {
    color: #1f3a6d;
    display: block;
    margin-bottom: 2px;
}

.medicine-details {
    font-size: 0.85rem;
    color: #666;
    margin-left: 0;
    font-style: italic;
}

.prescription-note-mini {
    font-size: 0.85rem;
    color: #666;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
}

.prescription-note-mini strong {
    color: #1f3a6d;
}

/* Responsive */
@media (max-width: 768px) {
    .consult-header-section {
        flex-direction: column;
        gap: 12px;
    }
    
    .consult-datetime {
        text-align: left;
    }
    
    .vital-signs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .complaint-plan-section {
        grid-template-columns: 1fr;
    }
}

/* --- PRINT --- */
@media print {
    @page { size: portrait; margin: 20mm; }
    html, body { width: 100%; height: 100%; margin: 0; padding: 0; }
    body * { visibility: hidden; }
    #rxPrintArea.print-active, #rxPrintArea.print-active * { visibility: visible; }
    #viewModal, #viewModal * { visibility: visible; }
    #consultDetailModal, #consultDetailModal * { visibility: visible; }
    #rxPrintArea.print-active {
        display: block;
        position: absolute;
        top: 0; left: 0;
        width: 100%;
        min-height: 100%;
        padding: 0;
        margin: 0;
        background: white;
    }
    #consultDetailModal {
        position: static;
        display: block !important;
        background: white;
        width: 100%;
        height: auto;
        padding: 20mm;
        box-shadow: none;
    }
    #consultDetailModal .modal-header {
        display: none;
    }
    #rxModal, #importModal, #addModal, #consultModal { visibility: hidden; }
    #viewModal .modal-header, #viewModal .modal-footer { display: none; }
    .step-indicator { display: none; }
}

.prescription-print-area {
    display: none;
}

.prescription-page {
    width: calc(210mm - 24mm);
    max-width: 840px;
    margin: 0 auto;
    padding: 16mm 14mm;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
    color: #111;
    background: #fff;
    height: calc(297mm - 24mm);
    position: relative;
    border: 1px solid #111;
}

.prescription-page::before {
    display: none;
}

.prescription-header {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 28px;
}

.prescription-doctor {
    display: inline-block;
    text-align: center;
    line-height: 1.35;
}

.doctor-name {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.4px;
}

.doctor-title,
.doctor-location {
    font-size: 0.86rem;
    color: #333;
}

.prescription-date {
    margin-top: 26px;
    text-align: right;
    font-size: 0.9rem;
    color: #111;
}

.prescription-patient {
    margin-top: 30px;
    display: grid;
    gap: 10 px;
}

.patient-field {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.96rem;
    min-height: 42px;
}

.patient-field span:first-child {
    width: 90px;
    font-weight: 700;
}

.patient-line {
    flex: 1;
    border-bottom: 1px solid #111;
    padding-bottom: 4px;
    min-height: 30px;
}

.rx-logo {
    margin: 28px 0 10px;
    text-align: left;
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: -4px;
    color: #111;
    padding-left: 4px;
}

.prescription-items {
    margin-top: 20px;
}

.prescription-item {
    margin-bottom: 10px;
    font-size: 0.92rem;
    color: #111;
}

.prescription-item .rx-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.prescription-item .rx-details {
    margin-left: 10px;
    color: #333;
}

.prescription-line {
    border-bottom: 1px dotted #444;
    margin: 12px 0;
    min-height: 18px;
}

.prescription-note-section {
    margin-top: 26px;
}

.prescription-note-label {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.prescription-note-lines,
.prescription-note-text {
    display: grid;
    gap: 10px;
}

.note-line {
    height: 18px;
    border-bottom: 1px solid #111;
}

.prescription-note-text {
    font-size: 0.92rem;
    line-height: 1.5;
    min-height: 90px;
}

.prescription-signature {
    margin-top: 42px;
    display: flex;
    justify-content: flex-end;
}

.signature-block {
    text-align: right;
}

.signature-block .signature-line {
    width: 220px;
    height: 1px;
    background: #111;
    margin-bottom: 8px;
    margin-left: auto;
}

.signature-text {
    font-size: 0.9rem;
    line-height: 1.35;
    text-align:  right;
}



.prescription-footer div {
    display: inline-block;
}

.footer-phone {
    letter-spacing: 0.4px;
}

@page {
    size: A4 portrait;
    margin: 12mm;
}

@media print {
    body * { visibility: hidden; }
    #viewModal, #viewModal * { visibility: visible; }
    .prescription-print-area {
        display: block !important;
        visibility: visible;
        position: relative;
        width: 100%;
        height: auto;
    }
    .prescription-print-area.print-active,
    .prescription-print-area.print-active * {
        visibility: visible;
    }
    .prescription-page {
        width: calc(210mm - 30mm);
        max-width: none;
        margin: 0;
        padding: 14mm 12mm;
        box-sizing: border-box;
        border: 1px solid #111;
        box-shadow: none;
        height: calc(297mm - 30mm);
        page-break-after: always;
        page-break-inside: avoid;
    }
    .prescription-page::before {
        display: none;
    }
    #rxModal, #viewModal, #importModal, #addModal, #consultModal, #consultDetailModal { visibility: hidden; }
}

.prescription-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.prescription-brand-left,
.prescription-brand-right {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.brand-box {
    width: 100px;
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 700;
    text-align: center;
    color: white;
    margin-bottom: 6px;
}
.brand-box-green { background: #1da06e; }
.brand-box-blue { background: #173d92; }
.brand-tag {
    font-size: 0.76rem;
    color: #404040;
    line-height: 1.35;
}
.prescription-doctor {
    margin-top: 22px;
    text-align: center;
    line-height: 1.35;
}
.doctor-name {
    font-size: 1rem;
    font-weight: 700;
}
.doctor-title,
.doctor-clinic,
.doctor-location {
    font-size: 0.82rem;
    color: #333;
}
.doctor-location {
    margin-top: 4px;
}
.prescription-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.prescription-left,
.prescription-right {
    flex: 1;
    min-width: 250px;
}
.prescription-right { text-align: right; }
.prescription-left div,
.prescription-right div {
    margin-bottom: 4px;
    font-size: 0.9rem;
}
.prescription-title {
    margin-top: 20px;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1px;
}
.prescription-items {
    margin-top: 18px;
}
.prescription-item {
    margin-bottom: 16px;
}
.rx-name {
    font-weight: 700;
    font-size: 1rem;
}
.rx-details {
    font-size: 0.88rem;
    color: #333;
    line-height: 1.4;
    margin-left: 8px;
}
.prescription-note {
    margin-top: 22px;
    font-size: 0.82rem;
    color: #333;
    line-height: 1.4;
}
.prescription-note span {
    font-weight: 700;
}
.prescription-signature {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 18px;
}
.signature-line {
    width: 180px;
    height: 1px;
    background: #000;
    margin-bottom: 4px;
}
.signature-text {
    font-size: 0.88rem;
    text-align: left;
    line-height: 1.35;
}
.prescription-footer {
    margin-top: 28px;
    border-top: 1px solid #bbb;
    padding-top: 14px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.footer-note {
    flex: 2;
    font-size: 0.7rem;
    line-height: 1.4;
    color: #444;
}
.footer-brand {
    flex: 1;
    text-align: right;
    font-size: 0.78rem;
    color: #1f3a6d;
    line-height: 1.4;
}
.footer-brand span {
    display: block;
    font-size: 0.65rem;
    color: #333;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .cards { flex-direction: column; padding: 15px; }
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { min-width: unset; }
}
@media (max-width: 480px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    table { font-size: 0.8rem; }
    th, td { padding: 8px; }
}

/* Toggle Buttons */
.toggle-btn {
    background: #e0e7ff;
    color: #1f3a6d;
    border: 2px solid #c3d6ff;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}
.toggle-btn.active {
    background: #1f3a6d;
    color: white;
    border-color: #1f3a6d;
    box-shadow: 0 4px 12px rgba(31,58,109,0.3);
}
.toggle-btn:hover:not(.active) {
    background: #c3d6ff;
    transform: translateY(-1px);
}

.view-content {
    animation: fadeIn 0.3s ease;
}
.view-content.active {
    display: block;
}
.view-content:not(.active) {
    display: none;
}

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

/* Full Profile View Styles */
.full-profile-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8faff;
    border: 1px solid #e1e8ff;
    border-radius: 12px;
}
.full-profile-section h4 {
    color: #1f3a6d;
    margin: 0 0 15px 0;
    font-size: 1rem;
    padding-bottom: 8px;
    border-bottom: 2px solid #1f3a6d;
    text-transform: uppercase;
    font-weight: 700;
}
.profile-field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.profile-field {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #1f3a6d;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.profile-field label {
    font-size: 0.8rem;
    color: #666;
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.profile-field-value {
    font-size: 0.9rem;
    color: #1f3a6d;
    font-weight: 500;
}
.profile-field.empty label { color: #999; }
.profile-field.empty .profile-field-value { 
    color: #999; 
    font-style: italic;
    font-weight: normal;
}
.checked { color: #2e7d32; font-weight: bold; }

/* I-add ni sa pinaka-ubos */
tbody tr td {
    transition: background-color 0.2s ease;
}

tr:hover td {
    background-color: #f1f5f9 !important;
}

/* Rounded corners sa table rows */
tr td:first-child { border-radius: 8px 0 0 8px; }
tr td:last-child { border-radius: 0 8px 8px 0; }


