:root {
    --primary-red: #ed1c24;
    --text-black: #000000;
    --text-grey: #666666;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #f4f4f4;
    font-family: 'AppRoboto Condensed', sans-serif;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.page-container {
    background-color: white;
    width: 100%;
    max-width: 900px;
    padding: 20px 30px 30px 30px;
    box-shadow: 0 0 20px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Header Section --- */
.main-header {
    text-align: center;
    width: 100%;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    min-height: 280px; 
    display: flex;
    flex-direction: column;
    justify-content: space-between; 
}

.header-top-row {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
    width: 100%;
    margin-bottom: -15px;
    min-height: 120px; 
}

.title-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100px; 
}

.main-title {
    position: absolute;
    top: var(--main-title-pos-y, 10%);
    left: 50%;
    transform: translateX(-50%) scaleY(1.2);
    width: 100%;
    text-align: center;
    font-family: 'AppNoto Serif', serif;
    font-size: var(--main-title-size, 8rem);
    color: var(--main-title-color, var(--primary-red));
    text-transform: uppercase;
    font-weight: 900;
    line-height: 0.8;
    margin: 0;
    -webkit-text-stroke: 1.5px var(--text-black);
    letter-spacing: -2px;
    z-index: 5;
    pointer-events: none;
}

.sub-title {
    position: absolute;
    top: var(--sub-title-pos-y, 50%);
    left: 50%;
    transform: translateX(-50%) scaleX(1.1);
    width: 100%;
    text-align: center;
    font-family: 'AppNoto Serif', serif;
    font-size: var(--sub-title-size, 3.5rem);
    text-transform: uppercase;
    color: var(--sub-title-color, var(--text-black));
    margin: 0;
    letter-spacing: 0.5px;
    font-weight: 900;
    z-index: 5;
    pointer-events: none;
}

.contact-info {
    position: absolute;
    top: var(--contact-info-pos-y, 75%);
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    text-align: center;
    font-family: 'AppRoboto', sans-serif;
    font-size: var(--contact-info-size, 1.1rem);
    font-weight: 700;
    line-height: 1.3;
    color: var(--contact-info-color, var(--text-black));
    margin: 0;
    z-index: 5;
    pointer-events: none;
}

/* --- Calendar Area --- */
.calendar-border {
    width: 100%;
    border: 3px solid var(--text-black);
    padding: 6px;
}

.month-section {
    width: 100%;
}

.month-header {
    background-color: var(--primary-red);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 30px;
    border-radius: 15px;
    margin-bottom: 5px;
    height: 70px;
    font-family: 'AppImpact', sans-serif;
}

.year { font-size: 3.5rem; letter-spacing: 1px; }
.month-name { font-size: 4rem; letter-spacing: 2px; transform: scaleY(1.1); }
.month-number { font-size: 3.5rem; }

/* Table Structure */
.calendar-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background-color: white;
}

.day-name, .date-cell {
    border: 1px solid var(--text-black);
    padding: 0;
    vertical-align: middle;
    text-align: center;
}

.day-name {
    font-family: 'AppRoboto Condensed', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    padding: 8px 0;
    text-transform: uppercase;
    background-color: var(--text-black);
    color: #fff;
}
.day-name.sunday { 
    background-color: var(--primary-red); 
    color: #fff;
}
.day-name.saturday { 
    background-color: #555; 
    color: #fff;
}
/* White dividers for headers */
th.day-name:not(.saturday):not(.sunday) {
    border-right: 1px solid white;
}

.date-cell {
    font-family: 'AppImpact', sans-serif;
    color: var(--text-black);
    overflow: hidden;
    vertical-align: top;
    padding: 0;
}

/* User Note in Empty Cells */
.empty-cell-note {
    font-family: 'AppRoboto', sans-serif;
    font-size: var(--note-size, 1.0rem);
    color: var(--note-color, #000000);
    font-weight: 400;
    text-align: center;
    width: 90%;
    word-wrap: break-word;
    line-height: 1.2;
}

/* Square Cell Container */
.cell-inner {
    width: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.date-number {
    font-size: 5rem;
    line-height: 1;
    z-index: 1;
}

/* Holiday Text Overlay */
.holiday-title {
    position: absolute;
    top: var(--holiday-pos-y, 50%);
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 85%; /* Margin from borders */
    text-align: center;
    font-family: 'AppRoboto Condensed', sans-serif;
    font-weight: var(--holiday-font-weight, 700); 
    font-size: var(--holiday-font-size, 0.55rem); 
    line-height: var(--holiday-line-height, 2.0); 
    white-space: pre-wrap; 
    text-transform: uppercase;
    color: var(--text-black); 
    z-index: 10; 
    pointer-events: none;
    text-shadow: var(--holiday-text-shadow, 1px 1px 0px white, -1px -1px 0px white, 1px -1px 0px white, -1px 1px 0px white, 0px 1px 0px white, 0px -1px 0px white, 1px 0px 0px white, -1px 0px 0px white);
}

/* Colors based on column/type */

/* 1. Base Column Colors (Lowest Priority) */
.calendar-table td:nth-child(6),
.mini-grid .mini-cell:nth-child(7n+6) { 
    color: var(--text-grey); 
}

.calendar-table td:nth-child(7),
.mini-grid .mini-cell:nth-child(7n) { 
    color: var(--primary-red); 
}

/* 2. Explicit Classes (High Priority - Overrides Columns) */
.grey-text { 
    color: var(--text-grey) !important; 
}

.red-text, 
.date-cell.sunday, 
.mini-cell.red-text, 
.mini-cell.sunday { 
    color: var(--primary-red) !important; 
}

.punkalasa-icon {
    width: 75%;
    height: 75%;
    display: block;
    fill: currentColor; 
}
.icon-cell .cell-inner {
    justify-content: center;
    align-items: center;
}

/* --- Footer --- */
.footer-legend-row {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 2px 0;
    border-top: 1px solid var(--text-black);
}

.legend {
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 0.8rem;
    font-family: 'AppRoboto', sans-serif;
    font-weight: 600;
    color: var(--text-black);
}
.legend-item { display: flex; align-items: center; gap: 4px; }
.red-dot { width: 8px; height: 8px; background-color: var(--primary-red); border-radius: 50%; display: inline-block; }
.cross { color: var(--primary-red); font-weight: bold; font-size: 1rem; line-height: 0.8; }
.diamond { color: var(--primary-red); font-size: 1rem; line-height: 0.8; }

.footer-grid {
    display: grid;
    grid-template-columns: 220px 1fr 220px; 
    gap: 8px;
    margin-top: 2px;
}

.mini-calendar { border: 1px solid var(--text-black); }

.mini-header {
    background-color: var(--primary-red);
    color: white;
    display: flex;
    justify-content: space-between;
    padding: 2px 8px;
    font-weight: 700;
    font-family: 'AppRoboto Condensed', sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 1.3rem;
    font-weight: 400; 
    font-family: 'AppImpact', sans-serif;
    background-color: #ccc;
    gap: 1px;
    border-top: 1px solid #ccc;
}

.mini-day-head {
    background-color: var(--text-black);
    color: white;
    font-size: 0.75rem;
    padding: 1px 0;
}
.mini-day-head.saturday { 
    background-color: #555; 
    color: white !important; /* Force white text */
}
.mini-day-head.sunday { background-color: var(--primary-red); }

.mini-cell {
    background-color: white;
    aspect-ratio: 1 / 1; 
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-black);
    line-height: 1;
    overflow: hidden;
    position: relative; 
}
.mini-icon {
    width: 70%;
    height: 70%;
    fill: currentColor;
}

.appointments-section {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--text-black); 
    background-color: white;
}

.appointment-header {
    background-color: var(--primary-red);
    color: white;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 2px 0;
    font-family: 'AppRoboto Condensed', sans-serif;
    letter-spacing: 3px;
    text-transform: uppercase;
    width: 100%;
}

.appt-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0; 
    padding: 2px 5px;
    flex-grow: 1;
    background-color: white;
}

.appt-col {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 4px;
}

.appt-row {
    display: flex;
    align-items: flex-end; 
    margin-bottom: 2px;
    width: 100%;
    height: 100%; 
}

.appt-num {
    min-width: 10px; 
    text-align: left;
    font-family: 'AppRoboto Condensed', sans-serif; 
    font-weight: 700;
    font-size: 0.6rem; 
    color: var(--text-black);
    margin-right: 2px;
    line-height: 1;
    margin-bottom: -1px; 
}

.appt-icon {
    width: 10px;
    height: 10px;
    color: var(--text-black);
    display: block;
}

.dotted-line {
    flex-grow: 1;
    border-bottom: 1px dotted var(--text-black); 
    height: 1px;
    margin-bottom: 2px;
}

/* Responsive styles removed to force PC look */

/* Force fixed width layout */
body {
    min-width: 1024px;
    overflow-x: auto;
}

.page-container {
    width: 900px; /* Fixed Desktop Width */
    max-width: 900px;
    flex-shrink: 0;
}

/* UI Controls - Fixed */
@media print {
    @page {
        size: A4 portrait;
        margin: 0; /* Zero margin to give us full control */
    }
    
    body {
        display: block !important;
        margin: 0;
        padding: 0;
        background-color: white;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        width: 210mm;
        height: 297mm;
        overflow: hidden;
        -webkit-text-size-adjust: 100% !important; /* Fix mobile font scaling */
    }

    .ui-controls { display: none !important; }
    
    /* 
       UNIFIED FIX: Works on Mobile AND PC
       Scale 0.88 fits 900px content exactly into A4 width (794px)
    */
    .page-container {
        width: 900px !important;
        max-width: 900px !important;
        margin: 0 auto !important; 
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        
        position: relative; 
        left: 0;
        top: 5%; /* Adjusted for new scale */
        bottom: 0;
        transform: scale(1.05); /* Fits A4 width perfectly */
        transform-origin: top center; /* Safer alignment for all devices */
        
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start; /* Align top for consistency */
        align-items: center;
        height: auto; /* Let content flow naturally */
        min-height: 290mm;
        padding-bottom: 0; 
        box-sizing: border-box;
        
        page-break-after: always;
    }

    /* Batch Print Mode */
    body.print-all-mode > .page-container {
        display: none !important;
    }
    
    body.print-all-mode #print-area {
        display: block !important;
        width: 100%;
        height: 100%;
    }
    
    #print-area .page-container {
        position: relative; 
        left: 0;
        top: 5%;
        bottom: 0;
        transform: scale(1.05); 
        transform-origin: top center;
        margin: 0 auto !important; 
        page-break-after: always;
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        height: auto;
        min-height: 290mm;
        padding-bottom: 0; 
        box-sizing: border-box;
    }
}

#print-area {
    display: none;
}

.ui-controls {
    position: fixed; top: 10px; right: 10px; background: #fff; border: 2px solid #000;
    padding: 15px; width: 300px; max-height: 90vh; overflow-y: auto; z-index: 1000;
    box-shadow: 0 0 10px rgba(0,0,0,0.5); font-family: sans-serif;
}
.control-group { margin-bottom: 15px; }
.control-group label { display: block; font-weight: bold; margin-bottom: 5px; font-size: 0.85rem; }
.control-group input, .control-group select, .control-group textarea { width: 100%; padding: 4px; }
.btn { background: #ed1c24; color: white; border: none; padding: 6px 12px; cursor: pointer; font-weight: bold; }