/* NEW: Draw Selector Area */
.sd-public-controls {
    max-width: 1600px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.sd-public-controls label { 
    font-weight: bold; 
    color: #333; 
    font-size: 16px;
}
.sd-public-controls select {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    min-width: 300px;
    background: #fff;
    cursor: pointer;
}
.sd-public-controls select:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Wrapper */
.sd-public-wrapper {
    max-width: 1600px; 
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* Header */
.sd-public-header {
    background: #f8f9fa;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 15px;
}
.sd-ph-left h2 { margin: 0; color: #333; font-size: 42px; font-weight: bold;}
.sd-p-date { color: #666; font-size: 20px; margin-top: 4px; font-weight: 500; }

.sd-ph-right { display: flex; gap: 15px; align-items: center; }

/* Export Button */
.sd-btn-export {
    background: #fff;
    border: 1px solid #ccc;
    color: #555;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 5px;
}
.sd-btn-export:hover { background: #333; color: #fff; border-color: #333; }

/* Stats Boxes */
.sd-p-stat {
    background: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
    text-align: center;
    min-width: 70px;
    color: #666666;
}
.sd-p-stat.highlight { 
    background: #f0f6fc; 
    border-color: #2271b1; 
    color: #2271b1;
    box-shadow: 0 2px 5px rgba(34, 113, 177, 0.1);
}
.sd-p-stat small { display: block; font-weight: 500; font-size: 20px; text-transform: uppercase; color: #888; }
.sd-p-stat span { display: block; font-weight: bold; font-size: 36px; }

/* Header Meta */
.sd-p-meta { margin-top: 8px; font-size: 24px; display: flex; gap: 10px; font-weight: 500;}
.sd-meta-item.paid { color: #37BC7D; }
.sd-meta-item.unpaid { color: #c62828; }

/* Status Badge */
.sd-p-badge {
    font-size: 20px;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
}
.sd-p-badge.open { background: #e7f5fe; color: #2271b1; border: 1px solid #bce0fd; }
.sd-p-badge.closed { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

/* Legend */
.sd-legend { padding: 15px 20px 5px; display: flex; gap: 20px; font-size: 20px; color: #555; font-weight: 500;}
.sd-l-item { display: flex; align-items: center; gap: 6px; }
.sd-dot { width: 15px; height: 15px; border-radius: 50%; display: inline-block; }
.sd-dot.green { background: #2D9966; border: 1px solid #c8e6c9; }
.sd-dot.orange { background: #F0B13B; border: 1px solid #ffeeba; }
.sd-dot.red { background: #c62828; border: 1px solid #ffcdd2; }
.sd-dot.blue { background: #2271b1; border: 1px solid #cddfff; }
.sd-dot.purple { background: #9728c6; border: 1px solid #fdcdff; }

/* Grid System */
.sd-public-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    padding: 20px;
}
/* Center last row item if 97 items */
.sd-public-grid > :nth-child(97) { grid-column-start: 3; }

/* Grid Cell - Split Layout */
.sd-p-cell {
    min-height: 80px;
    display: flex;
    flex-direction: row; 
    align-items: stretch;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 6px;
    color: #444;
    transition: all 0.2s;
    overflow: hidden;
}

/* --- LEFT SIDE: Number + Avail Text --- */
.sd-cell-left {
    width: 40%;
    display: flex;
    flex-direction: column; /* Stack Number and Text */
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255,255,255,0.2); 
    background: #34495e; 
    color: #ffffff; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    padding: 5px;
    box-sizing: border-box;
}

.sd-num-main {
    font-size: 36px;
    font-weight: 600;
    line-height: 1;
}

.sd-avail-sub {
    font-size: 16px;
    font-weight: 500;
    margin-top: 4px;
    opacity: 0.9;
    text-align: center;
    line-height: 1.2;
}

/* --- RIGHT SIDE: Occupants --- */
.sd-cell-right {
    width: 60%;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    gap: 3px;
}

/* Occupant Row */
.sd-occ-row {
    background: rgba(255,255,255,0.8);
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sd-occ-row.paid { color: #2D9966; font-weight: bold; border-left: 2px solid #2D9966; }
.sd-occ-row.unpaid { color: #856404; border-left: 2px solid #856404; }

/* "More" Text */
.sd-more-text { font-size: 14px; color: #777; font-style: italic; text-align: right; margin-top: -2px; }

/* --- CELL STATES (Backgrounds for Left Side) --- */
/* Available = Green */
.sd-p-cell.available .sd-cell-left { background-color: #2D9966; color: #ffffff; }
.sd-p-cell.available .sd-cell-right { background-color: #e8f5e9; } /* Light green tint for right side */

/* Partial = Orange */
.sd-p-cell.partial .sd-cell-left { background-color: #F0B13B; color: #ffffff; }
.sd-p-cell.partial .sd-cell-right { background-color: #fff3cd; }

/* Full = Red */
.sd-p-cell.full .sd-cell-left { background-color: #c62828; color: #ffffff; }
.sd-p-cell.full .sd-cell-right { background-color: #ffebee; }

/* Winner = Blue */
.sd-p-cell.winner { 
    border-color: #2271b1 !important; 
    /* transform: scale(1.05);  */
    /* box-shadow: 0 4px 15px rgba(34, 113, 177, 0.4);  */
    z-index: 2; 
    border-width: 3px;
}
.sd-p-cell.winner .sd-cell-left { background-color: #2271b1; color: #fff; }
.sd-p-cell.winner .sd-cell-right { background-color: #f0f6fc; }

/* Loader */
.sd-loader { grid-column: span 8; text-align: center; padding: 40px; color: #888; }

/* Responsive */
@media (max-width: 1200px) { .sd-public-grid { grid-template-columns: repeat(5, 1fr); } .sd-public-grid > :nth-child(97) { grid-column-start: auto; } }
@media (max-width: 900px) { .sd-public-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { 
    .sd-public-grid { grid-template-columns: repeat(2, 1fr); } 
    .sd-cell-left { width: 35%; }
    .sd-cell-right { width: 65%; }
}

.sd-p-cell.sec-winner {
    border-color: #a24ac8 !important;
    /* box-shadow: 0 0 10px rgba(173, 15, 241, 0.4); */
    border-width: 3px;
    z-index: 1;
}
.sd-p-cell.sec-winner .sd-cell-left {
    background-color: #a24ac8; 
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}
/* Ensure text inside left is readable if yellow is too bright, 
   but white usually works on standard gold/yellow. 
   Adjust #f1c40f to #d4ac0d for better contrast if needed. */
.sd-p-cell.sec-winner .sd-cell-right {
    background-color: #ffeefe;
}

/* Override: If a cell is BOTH primary and secondary winner (unlikely but possible), 
   Primary Winner Blue takes precedence due to CSS order or specificity. 
   Currently .winner is defined later/same level. 
   Let's ensure Primary wins visually. */
.sd-p-cell.winner {
    z-index: 5 !important;
    border-color: #2271b1 !important;
}