/* ===================================
   TURNAZIONE — Design System
   =================================== */

:root {
    /* Colors */
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #232733;
    --bg-card-hover: #2a2f3d;
    --bg-glass: rgba(35, 39, 51, 0.85);
    --bg-modal: rgba(0, 0, 0, 0.6);

    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #636b80;

    --border: #2d3344;
    --border-light: #3a4155;

    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-glow: rgba(108, 92, 231, 0.3);

    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --info: #74b9ff;

    /* Project Colors */
    --project-1: #6c5ce7;
    --project-2: #00b894;
    --project-3: #e17055;
    --project-4: #fdcb6e;
    --project-5: #74b9ff;
    --project-6: #fd79a8;
    --project-7: #55efc4;
    --project-8: #ffeaa7;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Fonts */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===================================
   APP CONTAINER
   =================================== */

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===================================
   HEADER
   =================================== */

.app-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: var(--space-md);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    justify-self: start;
}

.header-center {
    justify-self: center;
}

.app-title {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.title-icon {
    -webkit-text-fill-color: initial;
}

.month-selector {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--border);
}

.month-nav {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    line-height: 1;
}

.month-nav:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.month-label {
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 140px;
    text-align: center;
}

.header-right {
    display: flex;
    gap: var(--space-sm);
    justify-self: end;
}

/* Sidebar actions */
.sidebar-actions {
    margin-bottom: var(--space-md);
}

.sidebar-btn {
    width: 100%;
    justify-content: center;
    margin-bottom: var(--space-sm);
}

/* ===================================
   BUTTONS
   =================================== */

.btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-generate {
    background: linear-gradient(135deg, var(--accent), #5a4bd1);
    border-color: var(--accent);
}

.btn-generate:hover {
    box-shadow: var(--shadow-glow);
    border-color: var(--accent-light);
}

.btn-publish {
    background: linear-gradient(135deg, var(--success), #00a381);
    border-color: var(--success);
}

.btn-publish:hover {
    box-shadow: 0 0 20px rgba(0, 184, 148, 0.3);
}

.btn-operator-link {
    background: linear-gradient(135deg, var(--info), #0078d4);
    border-color: var(--info);
    text-decoration: none;
}

.btn-operator-link:hover {
    box-shadow: 0 0 20px rgba(116, 185, 255, 0.3);
}

.btn-toggle-view {
    background: linear-gradient(135deg, #00cec9, #00b894);
    border-color: #00cec9;
}

.btn-toggle-view:hover {
    box-shadow: 0 0 20px rgba(0, 206, 201, 0.3);
}

.btn-reset {
    background: linear-gradient(135deg, var(--danger), #c0392b);
    border-color: var(--danger);
}

.btn-reset:hover {
    box-shadow: 0 0 20px rgba(225, 112, 85, 0.3);
}

.btn-icon {
    font-size: 1rem;
}

/* ===================================
   AVAILABILITY VIEW CELLS
   =================================== */

.avail-cell {
    align-items: stretch;
    min-height: 160px;
}

.avail-count {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--success);
    line-height: 1;
    margin: 2px 0;
}

.avail-count.avail-zero {
    color: var(--danger);
    opacity: 0.6;
}

.avail-count.avail-low {
    color: var(--warning);
}

.avail-names {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 2px;
    overflow-y: auto;
    flex: 1;
}

.avail-name-tag {
    font-size: 0.6rem;
    color: var(--text-secondary);
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.avail-name-tag.avail-special {
    color: var(--warning);
    background: rgba(253, 203, 110, 0.1);
}

/* ===================================
   TAB NAVIGATION
   =================================== */

.tab-nav {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.tab-btn.active {
    color: var(--accent-light);
    background: var(--bg-card);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.tab-icon {
    font-size: 1rem;
}

/* ===================================
   MAIN CONTENT
   =================================== */

.main-content {
    flex: 1;
    padding: var(--space-lg);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================
   CALENDAR LAYOUT
   =================================== */

.calendar-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-lg);
    height: calc(100vh - 180px);
}

.calendar-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    margin-bottom: var(--space-sm);
}

.weekday {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: var(--space-sm);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

/* Availability view: fixed rows with scrollbar */
.calendar-grid.avail-mode {
    grid-auto-rows: minmax(140px, 1fr);
}

.avail-cell {
    height: 140px !important;
    /* Fixed height */
    overflow-y: auto !important;
    /* Enable scrollbar */
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    /* Custom Scrollbar for cell */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.avail-cell::-webkit-scrollbar {
    width: 4px;
}

.avail-cell::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 4px;
}

.avail-count {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--success);
    position: absolute;
    top: 4px;
    right: 8px;
    z-index: 2;
    /* Ensure above scroll content if needed */
    pointer-events: none;
    /* Let clicks pass through */
}

.avail-count.avail-zero {
    color: var(--text-muted);
}

.avail-count.avail-low {
    color: var(--warning);
}

.avail-cell {
    position: relative;
    padding-right: 4px;
    /* Space for scrollbar */
}

.avail-names {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
    padding-bottom: 8px;
    flex: 1 0 auto;
    /* Grow, don't shrink, base auto */
}

.avail-name-tag {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 1px 0;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    /* CRITICAL: Prevent squeezing */
    min-height: 1.25em;
    /* Ensure minimum height matching line-height */
}

.avail-name-tag.avail-special {
    color: var(--warning);
    font-weight: 600;
}

/* ===================================
   CALENDAR CELLS
   =================================== */

.calendar-cell {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
}

.calendar-cell:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.calendar-cell.other-month {
    opacity: 0.3;
}

.calendar-cell.today {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent-glow);
}

/* Uncovered slot highlighting */
.calendar-cell.has-uncovered {
    border-color: var(--danger);
    box-shadow: inset 0 0 0 1px rgba(225, 112, 85, 0.25), 0 0 12px rgba(225, 112, 85, 0.15);
    background: rgba(225, 112, 85, 0.05);
}

.calendar-cell.has-uncovered:hover {
    box-shadow: inset 0 0 0 1px rgba(225, 112, 85, 0.4), 0 0 16px rgba(225, 112, 85, 0.2);
}

.cell-date {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.today .cell-date {
    color: var(--accent-light);
}

.cell-events {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

.cell-event {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.15s;
}

.cell-event:hover {
    filter: brightness(1.2);
}

.event-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-slots {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 4px;
}

.event-slot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    transition: all 0.2s;
    cursor: pointer;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.event-slot.empty {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border-style: dashed;
}

.event-slot.assigned {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    border-style: solid;
}

/* Color-coded confirmation status */
.event-slot.slot-confirmed {
    background: rgba(0, 184, 148, 0.35);
    border-color: var(--success);
    color: #fff;
}

.event-slot.slot-pending {
    background: rgba(253, 203, 110, 0.3);
    border-color: var(--warning);
    color: #fff;
}

.event-slot.slot-rejected {
    background: rgba(225, 112, 85, 0.35);
    border-color: var(--danger);
    color: #fff;
}

.event-slot.drag-over {
    border-color: var(--accent-light);
    transform: scale(1.2);
    box-shadow: var(--shadow-glow);
}

/* More events indicator */
.cell-more {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2px;
    cursor: pointer;
}

.cell-more:hover {
    color: var(--accent-light);
}

/* ===================================
   STATS SIDEBAR
   =================================== */

.stats-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    overflow-y: auto;
    padding-right: var(--space-sm);
}

.sidebar-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid var(--border);
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Operator list in sidebar */
.operators-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 300px;
    overflow-y: auto;
}

.operator-item {
    display: flex;
    flex-direction: column;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: grab;
    transition: all 0.2s;
    border: 1px solid transparent;
    gap: 4px;
}

.operator-item:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

.operator-item.dragging {
    opacity: 0.5;
    border-color: var(--accent);
}

.operator-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.operator-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.operator-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.operator-name-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.operator-name {
    font-size: 0.8rem;
    font-weight: 500;
}

.operator-special-badge {
    font-size: 0.6rem;
    color: var(--warning);
    font-weight: 600;
}

.operator-count {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.count-number {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--accent-light);
    line-height: 1;
}

.count-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Operator breakdown mini bars */
.operator-breakdown {
    display: flex;
    height: 4px;
    width: 100%;
    border-radius: 2px;
    overflow: hidden;
    gap: 1px;
}

.breakdown-bar {
    height: 100%;
    border-radius: 2px;
    transition: flex 0.4s ease;
}

/* Summary Stats */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-light);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 2px;
}

/* Project Stats */
.project-stats {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.project-stat-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.project-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.project-stat-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-stat-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.project-stat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.project-stat-count {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 20px;
    text-align: right;
}

/* ===================================
   DATA TABLES (Preferences & Qualifications)
   =================================== */

.panel-header {
    margin-bottom: var(--space-lg);
}

.panel-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.panel-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.table-container {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.data-table th {
    padding: var(--space-sm) var(--space-md);
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 11;
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.data-table td:first-child {
    text-align: left;
    font-weight: 500;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 5;
}

.data-table tr:hover td {
    background: var(--bg-card-hover);
}

.data-table tr:hover td:first-child {
    background: var(--bg-card-hover);
}

/* Preference operator cell */
.pref-operator-cell {
    min-width: 200px;
    vertical-align: top;
    padding: var(--space-sm) var(--space-md) !important;
}

.pref-op-header {
    text-align: left !important;
    min-width: 200px;
}

.pref-op-name {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 6px;
}

/* Master priority slider */
.pref-priority-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.pref-priority-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    min-width: 42px;
}

.pref-master-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(90deg, var(--border) 0%, var(--accent) 100%);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.pref-master-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-light);
    border: 2px solid var(--accent);
    cursor: pointer;
    transition: transform 0.15s;
}

.pref-master-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.pref-priority-value {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-light);
    min-width: 24px;
    text-align: right;
}

/* Special availability checkbox */
.pref-special-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pref-special-checkbox {
    width: 14px;
    height: 14px;
    accent-color: var(--warning);
    cursor: pointer;
}

.pref-special-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* Preference sliders */
.pref-slider-cell {
    vertical-align: middle;
    min-width: 100px;
}

.pref-slider-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.pref-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.pref-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--slider-color, var(--accent));
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: transform 0.15s;
}

.pref-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

.pref-slider-value {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Number input alongside sliders */
.pref-number-input {
    width: 46px;
    padding: 2px 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.75rem;
    text-align: center;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
    appearance: textfield;
}

.pref-number-input::-webkit-outer-spin-button,
.pref-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pref-number-input:focus {
    outline: none;
    border-color: var(--accent);
}

.pref-priority-number {
    width: 40px;
}

.pref-input-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.pref-unit {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.pref-total {
    font-weight: 700;
}

.pref-total.valid {
    color: var(--success);
}

.pref-total.invalid {
    color: var(--danger);
}

/* Preferences sort controls */
.pref-sort-row td {
    padding: var(--space-sm) var(--space-md) !important;
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border) !important;
}

.pref-sort-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.pref-sort-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.pref-sort-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.pref-sort-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.pref-sort-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Qualification checkbox */
.qual-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ===================================
   MODAL
   =================================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.modal-body {
    padding: var(--space-lg);
}

/* Modal event card */
.modal-event {
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    border-left: 3px solid var(--accent);
}

.modal-event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.modal-event-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.modal-event-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modal-event-project {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.modal-slots {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.modal-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    border-left: 3px solid transparent;
}

.modal-slot-uncovered {
    border-left-color: var(--danger);
    background: rgba(225, 112, 85, 0.08);
}

.modal-slot-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.modal-slot-operator {
    font-weight: 600;
}

.modal-slot select {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
}

.modal-slot select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ===================================
   SCROLLBAR
   =================================== */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ===================================
   RESPONSIVE
   =================================== */

@media (max-width: 1200px) {
    .calendar-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .stats-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-section {
        flex: 1;
        min-width: 250px;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: var(--space-sm);
    }

    .header-left,
    .header-right {
        width: 100%;
        justify-content: center;
    }

    .calendar-cell {
        min-height: 70px;
        padding: 4px;
    }

    .cell-event {
        font-size: 0.6rem;
    }
}

/* ===================================
   OPERATOR FILTERING
   =================================== */

.highlight-availability {
    background-color: rgba(0, 184, 148, 0.15) !important;
    border: 2px solid var(--success) !important;
    box-shadow: inset 0 0 15px rgba(0, 184, 148, 0.1);
}

.dimmed-availability {
    opacity: 0.15;
    pointer-events: none;
    /* Optional: prevent clicking dimmed cells */
    filter: grayscale(100%);
}

.operator-item.selected {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
    z-index: 5;
}

.filter-reset-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--accent-light);
    font-weight: 600;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
}

.btn-text:hover {
    text-decoration: underline;
}