/* ============================================================================
   DESIGN SYSTEM — CSS Custom Properties
   ============================================================================ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

:root {
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', monospace;

    --bg: #F4F5F7;
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --surface-sunken: #EDEEF2;
    --border: #E2E4EA;
    --border-light: #EEEFF3;

    --text-primary: #1A1D26;
    --text-secondary: #5F6578;
    --text-tertiary: #9498A8;
    --text-muted: #B0B4C0;

    --accent: #3B5EE6;
    --accent-deep: #2D4AAF;
    --accent-hover: #2D4ED4;
    --accent-soft: #EBF0FF;

    --success: #16A34A;
    --success-dark: #0D6E31;
    --success-soft: #ECFDF5;
    --warning: #D97706;
    --warning-dark: #92400E;
    --warning-soft: #FFFBEB;
    --warning-badge: #F59E0B;
    --danger: #DC2626;
    --danger-dark: #991B1B;
    --danger-soft: #FEF2F2;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.04), 0 8px 32px rgba(0,0,0,0.08);
}

/* ============================================================================
   DARK MODE — Variable overrides only
   ============================================================================ */
body.dark-mode {
    --bg: #0F1117;
    --surface: #1A1D28;
    --surface-raised: #22252F;
    --surface-sunken: #13151C;
    --border: #2A2D3A;
    --border-light: #232636;

    --text-primary: #E8EAF0;
    --text-secondary: #9498A8;
    --text-tertiary: #6B6F80;
    --text-muted: #484C5C;

    --accent: #6B8AFF;
    --accent-deep: #4A68D6;
    --accent-hover: #8BA3FF;
    --accent-soft: #1C2444;

    --success: #34D399;
    --success-dark: #6EE7B7;
    --success-soft: #0D2818;
    --warning: #FBBF24;
    --warning-dark: #FCD34D;
    --warning-soft: #2A2008;
    --warning-badge: #F59E0B;
    --danger: #F87171;
    --danger-dark: #FCA5A5;
    --danger-soft: #2A0F0F;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.3);
}

/* ============================================================================
   BASE & RESET
   ============================================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   TOP NAVIGATION
   ============================================================================ */
.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.topnav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topnav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
    white-space: nowrap;
    line-height: 1;
}

.topnav-btn:hover {
    background: var(--surface-sunken);
    color: var(--text-primary);
}

/* Hide old header elements */
.app-header { display: none; }
.dark-mode-toggle { display: none; }

/* ============================================================================
   MAIN CONTAINER
   ============================================================================ */
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 20px;
}

h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

h2, h3 {
    color: var(--text-primary);
}

/* ============================================================================
   FORM CARD
   ============================================================================ */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="date"],
input[type="number"] {
    width: 100%;
    box-sizing: border-box;
    height: 44px;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="date"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 94, 230, 0.1);
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper input {
    padding-right: 40px;
    -moz-appearance: textfield;
}

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

.input-icon-right {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    pointer-events: none;
}

/* Hide number input spinners for cleaner look */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

/* ============================================================================
   RESULTS HEADER
   ============================================================================ */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.results-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-lg);
    background: var(--success-soft);
    color: var(--success);
    font-size: 13px;
    font-weight: 600;
}

/* ============================================================================
   STAT CARDS
   ============================================================================ */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    text-align: left;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }

/* ============================================================================
   VIEW TABS
   ============================================================================ */
.view-toggle {
    display: flex;
    gap: 2px;
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 20px;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.toggle-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    transition: all 0.15s;
    white-space: nowrap;
    flex: 0 0 auto;
}

.toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(0,0,0,0.03);
}

body.dark-mode .toggle-btn:hover {
    background: rgba(255,255,255,0.05);
}

.toggle-btn.active {
    background: var(--surface);
    color: var(--accent);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}



.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

input[type="date"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="date"]:focus {
    outline: none;
    border-color: var(--accent);
}

.file-upload {
    position: relative;
    display: block;
    width: 100%;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-label {
    display: block;
    padding: 32px 20px;
    background: var(--surface-sunken);
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload-label:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.file-upload-label.file-selected {
    background: var(--accent-soft);
    border-color: var(--accent);
    border-style: solid;
}

.file-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.file-text {
    color: var(--text-secondary);
    font-size: 14px;
}

.file-name {
    color: var(--accent);
    font-weight: 600;
    margin-top: 10px;
}

.btn {
    width: 100%;
    padding: 13px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    letter-spacing: -0.01em;
}

.btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn:active:not(:disabled) {
    transform: scale(0.99);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.results {
    margin-top: 28px;
    display: none;
}

.results.show {
    display: block;
}

.results h2 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 20px;
}

.alerts {
    background: var(--surface);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.alert-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-secondary);
}

.alert-item:last-child {
    border-bottom: none;
}

.download-btn {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    background: var(--success);
    color: #fff;
    text-align: center;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: opacity 0.15s;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
}

.download-btn:hover {
    opacity: 0.9;
}

.error {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: var(--radius-md);
    margin-top: 20px;
    display: none;
}

.error.show {
    display: block;
}

.info-box {
    background: var(--accent-soft);
    border-left: 4px solid var(--accent);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-box strong {
    display: block;
    margin-bottom: 4px;
    color: var(--accent);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Source toggle */
.source-toggle {
    display: flex;
    gap: 4px;
    background: var(--surface-sunken);
    padding: 3px;
    border-radius: var(--radius-sm);
    height: 44px;
    box-sizing: border-box;
}

.source-btn {
    flex: 1;
    padding: 0 14px;
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
}

.source-btn:hover {
    color: var(--text-primary);
}

.source-btn.active {
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Google Sheet input */
.sheet-input-wrapper {
    display: flex;
    align-items: center;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.3s;
    background: var(--surface);
}

.sheet-input-wrapper:focus-within {
    border-color: var(--accent);
}

.sheet-icon {
    padding: 0 12px;
    font-size: 20px;
}

.sheet-input {
    flex: 1;
    padding: 12px 8px;
    border: none;
    outline: none;
    font-size: 14px;
    min-width: 0;
}

.sheet-fetch-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #34a853, #2d8f47);
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.sheet-fetch-btn:hover {
    opacity: 0.9;
}

.sheet-fetch-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sheet-hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.sheet-status {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
}

.sheet-status.success {
    color: var(--success);
}

.sheet-status.error {
    color: var(--danger);
}

.sheet-status.loading {
    color: var(--accent);
}

.view-section {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.table-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-box {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.search-box:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-select {
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    cursor: pointer;
}

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

.table-container {
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    border: 2px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    background: var(--accent);
    color: #fff;
    z-index: 10;
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

tbody tr:hover {
    background: var(--surface-sunken);
}

.month-cell {
    max-width: 200px;
}

.specialty-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.oncall-badge {
    font-size: 11px;
    color: var(--primary);
    background: var(--primary-soft, rgba(99, 102, 241, 0.1));
    padding: 2px 7px;
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 4px;
    font-weight: 500;
}

.days-count {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status-success {
    background: var(--success-soft);
    color: var(--success-dark);
}

.status-partial {
    background: var(--warning-soft);
    color: var(--warning-dark);
}

.status-failed {
    background: var(--danger-soft);
    color: var(--danger-dark);
}

.status-na {
    background: var(--surface-sunken);
    color: #6c757d;
}

.table-footer {
    padding: 12px;
    background: var(--surface-sunken);
    border-top: 2px solid var(--border);
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: 0 0 10px 10px;
}

.dates-preview {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    font-family: monospace;
}

/* Clickable month cells with expandable date bubble */
.month-cell-clickable {
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
}

.month-cell-clickable:hover {
    background: #f0f4ff;
}

.click-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    transition: color 0.15s;
}

.month-cell-clickable:hover .click-hint {
    color: var(--accent);
}

.date-bubble {
    display: none;
    position: fixed;
    z-index: 50000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    min-width: 260px;
    max-width: 340px;
    max-height: 350px;
    overflow-y: auto;
    text-align: left;
    cursor: default;
}

.date-bubble.open {
    display: block;
    animation: bubblePop 0.15s ease-out;
}

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

.bubble-header {
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--surface-sunken);
}

.bubble-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.bubble-subtitle {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.bubble-dates {
    padding: 8px 14px 12px;
}

.bubble-week {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f5f5f5;
}

.bubble-week:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.bubble-date {
    display: inline-block;
    padding: 3px 8px;
    background: #e7f3ff;
    color: #2563eb;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* Calendar Styles */
.calendar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--surface-sunken);
    border-radius: var(--radius-md);
}

.calendar-controls h3 {
    flex: 1;
    text-align: center;
}

.calendar-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

.calendar-filter label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.calendar-filter select {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.nav-btn {
    padding: 10px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

#currentMonthLabel {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.calendar-container {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 2px solid var(--border);
    overflow-x: auto;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    min-width: 750px;
}

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    color: var(--accent);
    padding: 10px;
    font-size: 14px;
}

.calendar-day {
    min-height: 100px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.calendar-day:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.calendar-day.weekend {
    background: var(--surface-sunken);
    border-style: dashed;
}

.calendar-day.bank-holiday {
    background: #fff8e7;
    border-color: #e6a817;
    border-style: solid;
    border-width: 2px;
}

.calendar-day.bank-holiday .day-number {
    color: #b8860b;
}

.bank-holiday-badge {
    background: var(--warning-badge);
    color: #664d03;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 4px;
    text-align: center;
    line-height: 1.3;
}

.calendar-day.has-assignments {
    background: linear-gradient(135deg, #e7f3ff 0%, #f0e7ff 100%);
    border-color: var(--accent);
}

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

.day-number {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.day-assignments {
    font-size: 11px;
}

.assignment-item {
    background: var(--surface);
    padding: 4px 6px;
    margin: 3px 0;
    border-radius: 4px;
    border-left: 3px solid var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: box-shadow 0.15s, transform 0.15s, opacity 0.15s;
    cursor: grab;
}

.assignment-item:hover {
    box-shadow: 0 2px 8px rgba(102,126,234,0.25);
    transform: translateY(-1px);
}

.assignment-item:active {
    cursor: grabbing;
}

/* Dragging source fades out */
.assignment-item.dragging-source {
    opacity: 0.25;
    box-shadow: none;
    transform: none;
}

/* During drag, show dashed outline on all valid potential targets */
body.calendar-dragging .calendar-day:not(.weekend):not(.bank-holiday):not(.other-month) {
    outline: 2px dashed rgba(102,126,234,0.2);
    outline-offset: -2px;
}

/* Valid drop target — green glow */
.calendar-day.drag-over-valid {
    background: var(--success-soft) !important;
    outline: 3px solid var(--success) !important;
    outline-offset: -3px;
    box-shadow: 0 0 16px rgba(40,167,69,0.35) !important;
    transform: scale(1.03);
    z-index: 10;
}

/* Invalid drop target — red glow */
.calendar-day.drag-over-invalid {
    background: rgba(245,158,11,0.12) !important;
    outline: 3px solid #f59e0b !important;
    outline-offset: -3px;
    cursor: copy;
}

/* Hard blocked — cannot be overridden (weekend, bank holiday, already assigned) */
.calendar-day.drag-over-blocked {
    background: var(--danger-soft) !important;
    outline: 3px solid var(--danger) !important;
    outline-offset: -3px;
    cursor: not-allowed;
}

/* In edit mode, assignment items become clickable */
body.calendar-edit-mode .assignment-item {
    cursor: pointer;
    border-left-width: 4px;
}
body.calendar-edit-mode .assignment-item:hover {
    box-shadow: 0 2px 8px rgba(102,126,234,0.35);
    transform: translateY(-1px);
    background: #eef2ff;
}

/* Selected assignment item */
.assignment-item.edit-selected {
    background: var(--accent) !important;
    color: white !important;
    box-shadow: 0 2px 12px rgba(102,126,234,0.5);
    transform: scale(1.02);
}
.assignment-item.edit-selected .assignment-name,
.assignment-item.edit-selected .assignment-specialty {
    color: white !important;
}

/* Source day highlight */
.calendar-day.edit-source-day {
    outline: 3px solid var(--accent) !important;
    outline-offset: -3px;
    box-shadow: 0 0 12px rgba(102,126,234,0.3) !important;
}

/* Valid drop target */
.calendar-day.edit-valid-target {
    outline: 2px dashed var(--success);
    outline-offset: -2px;
    background: rgba(40,167,69,0.06) !important;
    cursor: pointer !important;
    transition: all 0.15s;
}
.calendar-day.edit-valid-target:hover {
    background: var(--success-soft) !important;
    outline: 3px solid var(--success);
    outline-offset: -3px;
    box-shadow: 0 0 14px rgba(40,167,69,0.35) !important;
    transform: scale(1.03);
    z-index: 10;
}

/* Invalid target — overrideable (amber) */
.calendar-day.edit-invalid-target {
    outline: 2px dashed #f59e0b;
    outline-offset: -2px;
    background: rgba(245,158,11,0.06) !important;
    cursor: pointer !important;
    opacity: 0.7;
    transition: all 0.15s;
}
.calendar-day.edit-invalid-target:hover {
    background: rgba(245,158,11,0.14) !important;
    outline: 3px solid #f59e0b;
    outline-offset: -3px;
    opacity: 1;
    box-shadow: 0 0 14px rgba(245,158,11,0.35) !important;
    transform: scale(1.03);
    z-index: 10;
}
.calendar-day.edit-invalid-target::after {
    content: '⚠️';
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 10px;
    line-height: 1;
    pointer-events: none;
}

/* Hard blocked in edit mode — dimmed, no override */
.calendar-day.edit-hard-blocked {
    opacity: 0.3;
    cursor: not-allowed !important;
}
.calendar-day.edit-hard-blocked::after {
    content: '🚫';
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 10px;
    line-height: 1;
    pointer-events: none;
    opacity: 1;
}

/* Edit mode button styling */
.edit-mode-btn {
    background: var(--surface-sunken);
    border: 2px solid var(--border);
    font-size: 13px;
    transition: all 0.2s;
    margin-left: auto;
}
.edit-mode-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.edit-mode-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}

/* Subtle pulse on edit mode body to indicate interactive state */
body.calendar-edit-mode .calendar-grid {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 12px;
}

.assignment-name {
    font-weight: 600;
    color: var(--text-primary);
}

.drag-grip {
    opacity: 0.3;
    font-size: 12px;
    cursor: grab;
    user-select: none;
    transition: opacity 0.15s;
}
.assignment-item:hover .drag-grip {
    opacity: 0.7;
}

.assignment-specialty {
    color: var(--accent);
    font-size: 10px;
}

.assignment-oncall {
    font-size: 9px;
    color: var(--primary);
    opacity: 0.8;
}

.oncall-item {
    background: #ede9fe !important;
    border-left: 3px solid #7c3aed !important;
}
.oncall-item .assignment-name {
    color: #7c3aed;
}
.oncall-item .assignment-specialty {
    color: #7c3aed;
    opacity: 0.7;
}

.postnightrest-item {
    background: #fef3c7 !important;
    border-left: 3px solid #f59e0b !important;
}
.postnightrest-item .assignment-name {
    color: #92400e;
}
.postnightrest-item .assignment-specialty {
    color: #b45309;
    opacity: 0.8;
}

.nwd-date {
    background: #eef2ff !important;
    border-color: #a5b4fc !important;
}

.day-oncall-entries {
    margin-top: 4px;
    border-top: 1px dashed rgba(99, 102, 241, 0.3);
    padding-top: 3px;
}

.oncall-entry {
    font-size: 9px;
    color: var(--primary);
    padding: 1px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.oncall-icon {
    font-size: 8px;
}

.oncall-name {
    font-weight: 500;
}

.assignment-count {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.calendar-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 15px;
    padding: 15px;
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Day detail modal */
.day-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.day-modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.modal-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-assignment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 6px 0;
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
    cursor: grab;
    transition: box-shadow 0.15s, transform 0.15s;
}
.modal-assignment:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}
.modal-assignment:active {
    cursor: grabbing;
}

.modal-assignment-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.modal-assignment-specialty {
    font-size: 14px;
    color: var(--accent);
}

.export-controls {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.export-controls .download-btn {
    background: var(--accent);
    flex: 1;
}

.export-controls .download-btn:hover {
    box-shadow: 0 10px 20px rgba(0, 123, 255, 0.4);
}

/* Analytics Styles */
.analytics-section {
    margin-top: 20px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.analytics-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 2px solid var(--border);
}

.analytics-card h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container {
    position: relative;
    min-height: 250px;
}

.specialty-list {
    max-height: 300px;
    overflow-y: auto;
}

.specialty-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.specialty-item:hover {
    background: var(--surface-sunken);
}

.specialty-item:last-child {
    border-bottom: none;
}

.specialty-item-name {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.specialty-item-stats {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 13px;
}

.specialty-item-count {
    background: var(--accent);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.specialty-item-trainees {
    color: var(--text-secondary);
}

.specialty-item-days {
    color: var(--success);
    font-weight: 600;
}

.analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.analytics-stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 2px solid var(--border);
}

.analytics-stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 8px;
}

.analytics-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.insights-list {
    list-style: none;
    padding: 0;
}

.insight-item {
    padding: 12px 15px;
    margin-bottom: 10px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent);
    font-size: 14px;
    color: var(--text-primary);
}

.insight-item strong {
    color: var(--accent);
}

.insight-icon {
    margin-right: 8px;
}

@media (max-width: 768px) {
    .calendar-grid {
        gap: 5px;
    }

    .calendar-day {
        min-height: 80px;
        padding: 5px;
    }

    .day-number {
        font-size: 14px;
    }

    .assignment-item {
        font-size: 10px;
        padding: 3px 4px;
    }

    .modal-content {
        margin: 20px;
        max-width: calc(100% - 40px);
    }

    .export-controls {
        flex-direction: column;
    }

    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .analytics-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    

    

    .calendar-filter {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-filter select {
        max-width: 100%;
    }
}
/* ============================================================================
   CAPACITY SETTINGS PANEL
   ============================================================================ */

.cap-settings-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 60000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.cap-settings-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.cap-settings-panel {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 620px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.2s;
}
.cap-settings-overlay.open .cap-settings-panel {
    transform: translateY(0);
}

.cap-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px 14px;
    border-bottom: 1px solid var(--border-light);
}

.cap-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s;
}
.cap-close-btn:hover { color: var(--text-primary); }

.cap-settings-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.cap-toolbar-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.cap-toolbar-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.cap-reset-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.cap-apply-all-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.cap-input-sm {
    width: 56px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
    font-size: 13px;
}

.cap-settings-table-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px;
}

.cap-settings-table {
    width: 100%;
    border-collapse: collapse;
}

.cap-settings-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    padding: 12px 8px 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 2px solid var(--border-light);
    z-index: 1;
}

.cap-settings-table tbody tr {
    border-bottom: 1px solid var(--surface-sunken);
    transition: background 0.1s;
}
.cap-settings-table tbody tr:hover {
    background: var(--surface-sunken);
}

.cap-settings-table td {
    padding: 10px 8px;
    vertical-align: middle;
}

.cap-specialty-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.cap-color-input {
    width: 32px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px;
    cursor: pointer;
    background: none;
}

.cap-input {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    transition: border-color 0.15s;
}
.cap-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}
/* Show up/down spinners on capacity setting inputs */
input[type="number"].cap-input::-webkit-outer-spin-button,
input[type="number"].cap-input::-webkit-inner-spin-button {
    -webkit-appearance: auto;
    opacity: 1;
    margin: 0;
    height: auto;
}
input[type="number"].cap-input {
    -moz-appearance: auto;
}
input[type="number"].cap-input-sm::-webkit-outer-spin-button,
input[type="number"].cap-input-sm::-webkit-inner-spin-button {
    -webkit-appearance: auto;
    opacity: 1;
    margin: 0;
    height: auto;
}
input[type="number"].cap-input-sm {
    -moz-appearance: auto;
}
.input-icon-wrapper input[type="number"]#alertThreshold::-webkit-outer-spin-button,
.input-icon-wrapper input[type="number"]#alertThreshold::-webkit-inner-spin-button {
    -webkit-appearance: auto;
    opacity: 1;
    margin: 0;
    height: auto;
}
.input-icon-wrapper input[type="number"]#alertThreshold {
    -moz-appearance: auto;
}

.cap-peak-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    min-width: 30px;
    text-align: center;
}
.cap-peak-ok {
    background: var(--success-soft);
    color: var(--success-dark);
}
.cap-peak-warn {
    background: var(--warning-soft);
    color: var(--warning-dark);
}
.cap-peak-over {
    background: var(--danger-soft);
    color: var(--danger-dark);
}

.cap-settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--border-light);
}

.cap-save-btn {
    padding: 10px 24px;
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}
.cap-save-btn:hover { background: #218838; }

.cap-cancel-btn {
    padding: 10px 20px;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.cap-cancel-btn:hover { background: #5a6268; }

/* Settings button in the toggle bar */
#capacitySettingsBtn {
    flex: 0 0 auto;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    transition: all 0.15s;
}
#capacitySettingsBtn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ============================================================================
   UNDO / REDO TOOLBAR
   ============================================================================ */

.undo-redo-toolbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 6px 10px;
    z-index: 50000;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s;
}
.undo-redo-toolbar.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}

.ur-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.ur-btn:hover:not(:disabled) {
    background: var(--accent);
    color: #fff;
}
.ur-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.ur-icon {
    font-size: 16px;
}

.ur-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--radius-md);
    background: var(--border-light);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
}
.ur-btn:hover:not(:disabled) .ur-count {
    background: rgba(255,255,255,0.3);
    color: #fff;
}

.ur-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.ur-description {
    padding: 0 8px;
    font-size: 12px;
    color: var(--text-tertiary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modal assignment items - move button */
.modal-move-btn {
    padding: 5px 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    flex-shrink: 0;
}
.modal-move-btn:hover {
    background: var(--accent-hover);
}

/* ============================================================================
   DAY HOVER TOOLTIP
   ============================================================================ */

.day-hover-tooltip {
    position: fixed;
    z-index: 55000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 28px rgba(0,0,0,0.18);
    padding: 10px 14px;
    min-width: 160px;
    max-width: 250px;
    max-height: 300px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
.day-hover-tooltip.visible {
    opacity: 1;
}

.dtt-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.dtt-count {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.dtt-name {
    font-size: 12px;
    color: var(--text-primary);
    padding: 2px 0;
}

/* ============================================================================
   SUMMARY TABLE
   ============================================================================ */

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.summary-table th {
    background: var(--accent);
    color: #fff;
    padding: 10px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.summary-table th.smt-name {
    text-align: left;
    min-width: 180px;
}

.summary-table th.smt-ltft {
    min-width: 50px;
}

.summary-table th.smt-month {
    min-width: 70px;
}

.summary-table th.smt-total {
    min-width: 60px;
    background: linear-gradient(135deg, #333 0%, #555 100%);
}

.summary-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    text-align: center;
}

.summary-table tr:hover {
    background: #f5f7ff;
}

.smt-name-cell {
    text-align: left !important;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.smt-ltft-cell {
    color: var(--text-tertiary);
    font-size: 12px;
}

.smt-day-cell {
    font-weight: 600;
    border-radius: 4px;
    font-size: 13px;
}

.smt-high {
    background: var(--success-soft);
    color: var(--success-dark);
}

.smt-mid {
    background: var(--warning-soft);
    color: var(--warning-dark);
}

.smt-low {
    background: var(--danger-soft);
    color: var(--danger-dark);
}

.smt-zero {
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 700;
}

.smt-na {
    color: var(--text-muted);
    font-weight: 400;
}

.smt-total-cell {
    font-weight: 700;
    color: var(--text-primary);
    background: var(--surface-sunken);
}

.smt-summary-row {
    background: #f8f9ff !important;
    border-top: 2px solid var(--accent);
}

.smt-summary-row:hover {
    background: #f8f9ff !important;
}

#summaryTableWrapper {
    max-height: 600px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

/* ============================================================================
   DARK MODE TOGGLE
   ============================================================================ */

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

.share-modal-content {
    max-width: 560px;
}

.share-preview {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.share-trainee-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.share-ltft {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}
.share-schedule {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.share-month {
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
    padding: 12px;
    border-left: 4px solid var(--accent);
}
.share-month-header {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.share-month-spec {
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 6px;
}
.share-month-dates {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.share-total {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px solid var(--border-light);
}

.share-actions {
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--border-light);
}

.btn-share {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--accent);
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-share:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.btn-share-copy {
    background: linear-gradient(135deg, var(--success), #20c997);
}
.btn-share-copy:hover {
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.btn-share-sm {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}
.btn-share-sm:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.1);
}

.share-copied {
    text-align: center;
    padding: 8px;
    color: var(--success);
    font-weight: 600;
    font-size: 13px;
}

.smt-share {
    min-width: 50px;
}
.smt-share-cell {
    text-align: center;
}

/* ============================================================================
   DARK MODE
   ============================================================================ */

/* Forms */

/* Toggle buttons / tabs */

/* Calendar */

/* Modals */

/* Share modal */
/* Tables */

/* Analytics */

/* Capacity panel */

/* Toasts */

/* Scrollbars */

/* Error / success boxes */
/* Day hover tooltip */
/* Edit mode overrides */
/* ============================================================================
   CLASH DETECTION DASHBOARD
   ============================================================================ */

.clash-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.clash-card {
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border-left: 5px solid;
}
.clash-card-over {
    background: #fff5f5;
    border-left-color: var(--danger);
}
.clash-card-warn {
    background: #fffdf0;
    border-left-color: var(--warning-badge);
}
.clash-card-empty {
    background: #f0f7ff;
    border-left-color: #0984e3;
}
.clash-card-ok {
    background: #f0fff4;
    border-left-color: var(--success);
}
.clash-card-num {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
}
.clash-card-over .clash-card-num { color: var(--danger); }
.clash-card-warn .clash-card-num { color: #e6a800; }
.clash-card-empty .clash-card-num { color: #0984e3; }
.clash-card-ok .clash-card-num { color: var(--success); }

.clash-card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Clash list items */
.clash-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    border-left: 5px solid;
    gap: 12px;
    flex-wrap: wrap;
}
.clash-item-over {
    background: #fff5f5;
    border-left-color: var(--danger);
}
.clash-item-warning {
    background: #fffdf0;
    border-left-color: var(--warning-badge);
}
.clash-item-empty {
    background: #f0f7ff;
    border-left-color: #0984e3;
}

.clash-item-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.clash-item-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.clash-item-info {
    min-width: 0;
}

.clash-item-date {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.clash-item-spec {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.clash-item-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.clash-item-over-badge {
    background: var(--danger);
    color: #fff;
}
.clash-item-warning-badge {
    background: var(--warning-badge);
    color: var(--text-primary);
}
.clash-item-empty-badge {
    background: #0984e3;
    color: #fff;
}

.clash-item-trainees {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
    line-height: 1.4;
}

.clash-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.clash-fix-btn {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    transition: all 0.2s;
    white-space: nowrap;
}
.clash-fix-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.clash-fix-fill {
    background: linear-gradient(135deg, #0984e3, #00b894);
}
.clash-fix-fill:hover {
    box-shadow: 0 4px 12px rgba(9, 132, 227, 0.4);
}

.clash-empty-msg {
    text-align: center;
    padding: 40px 20px;
    font-size: 18px;
    color: var(--success);
    font-weight: 600;
}

/* Dark mode for clashes */
/* Clash tab badge */
.clash-has-issues {
    position: relative;
    animation: clash-pulse 2s infinite;
}
@keyframes clash-pulse {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.3); }
}
@keyframes clash-pulse-dark {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.5); }
}

/* Capacity overview items */
.capacity-overview-item {
    background: var(--surface);
}

/* ============================================================================
   TRAINEE TIMELINE (GANTT VIEW)
   ============================================================================ */

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--surface-sunken);
    border-radius: var(--radius-md);
}
.timeline-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.timeline-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.timeline-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 650px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.tl-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--accent);
    border-bottom: 2px solid rgba(255,255,255,0.2);
}
.tl-header-label {
    font-weight: 700;
    color: white !important;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tl-label-col {
    min-width: 180px;
    max-width: 180px;
    padding: 8px 12px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-right: 1px solid var(--border);
    background: inherit;
}

.tl-bar-col {
    flex: 1;
    position: relative;
    min-height: 44px;
    min-width: 500px;
}

.tl-row {
    display: flex;
    border-bottom: 1px solid var(--surface-sunken);
    transition: background 0.15s;
}
.tl-row:hover {
    background: #f8f9ff;
}
.tl-row:nth-child(even) {
    background: #fafafa;
}
.tl-row:nth-child(even):hover {
    background: #f0f2ff;
}

.tl-trainee-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tl-trainee-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 1px;
}

/* Month headers */
.tl-month-header {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    border-right: 1px solid rgba(255,255,255,0.2);
    box-sizing: border-box;
}

.tl-month-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
    z-index: 0;
}

/* Today marker */
.tl-today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--danger);
    z-index: 1;
    opacity: 0.7;
}

/* Specialty bars */
.tl-bar {
    position: absolute;
    top: 6px;
    height: calc(100% - 12px);
    border-radius: 5px;
    display: flex;
    align-items: center;
    padding: 0 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    cursor: default;
    transition: filter 0.15s, transform 0.15s;
    z-index: 1;
    overflow: hidden;
}
.tl-bar:hover {
    filter: brightness(1.15);
    transform: scaleY(1.15);
    z-index: 2;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

.tl-bar-text {
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dark mode timeline */

/* ============================================================================
   TIMELINE RICH TOOLTIP
   ============================================================================ */

.tl-tooltip {
    display: none;
    position: fixed;
    z-index: 9999;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    padding: 14px 16px;
    max-width: 360px;
    min-width: 200px;
    pointer-events: none;
    border: 1px solid var(--border);
}

.tl-tip-header {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.tl-tip-spec {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.tl-tip-dates {
    max-height: 220px;
    overflow-y: auto;
}

.tl-tip-date-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 3px 12px;
}

.tl-tip-date {
    font-size: 11.5px;
    color: var(--text-secondary);
    padding: 2px 0;
    white-space: nowrap;
}
.tl-tip-date:nth-child(odd) {
    color: var(--text-primary);
}

/* Dark mode tooltip */

/* ============================================================================
   CAPACITY HEATMAP
   ============================================================================ */

.heatmap-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 650px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.heatmap-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 600px;
    font-size: 12px;
}

.heatmap-table th,
.heatmap-table td {
    text-align: center;
    padding: 0;
    border: 1px solid var(--border-light);
}

/* Corner cell */
.hm-corner {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 8px 12px;
    min-width: 160px;
    text-align: left;
}

/* Date column headers */
.hm-date-header {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 11px;
    padding: 6px 4px;
    min-width: 40px;
    line-height: 1.3;
    position: sticky;
    top: 0;
    z-index: 2;
}
.hm-date-header.hm-bh {
    background: linear-gradient(135deg, #a0a0c0, #8888aa);
}
.hm-today-header {
    box-shadow: inset 0 -3px 0 var(--danger);
}
.hm-summary-header {
    background: linear-gradient(135deg, #555, #333) !important;
    min-width: 50px;
}

/* Specialty name cells */
.hm-spec-cell {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
    text-align: left !important;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    min-width: 160px;
    border-right: 2px solid var(--border);
}

.hm-spec-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

/* Data cells */
.hm-cell {
    width: 40px;
    height: 36px;
    font-weight: 700;
    font-size: 13px;
    cursor: default;
    transition: transform 0.1s;
    vertical-align: middle;
}
.hm-cell:hover {
    transform: scale(1.15);
    z-index: 5;
    position: relative;
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
}

.hm-cell-empty {
    background: var(--surface-sunken);
    color: var(--text-muted);
}
.hm-cell-ok {
    background: var(--success-soft);
    color: var(--success-dark);
}
.hm-cell-warn {
    background: var(--warning-soft);
    color: var(--warning-dark);
}
.hm-cell-over {
    background: var(--danger-soft);
    color: var(--danger-dark);
    font-weight: 800;
}
.hm-cell-today {
    box-shadow: inset 0 0 0 2px var(--danger);
}

.hm-cell-summary {
    font-weight: 700;
    border-left: 2px solid var(--border);
}

.hm-cell-total {
    background: var(--surface-sunken);
    color: var(--text-primary);
    font-weight: 600;
}

.hm-bh-cell {
    background: var(--surface-sunken);
    color: var(--text-muted);
    font-style: italic;
}

.hm-totals-row td {
    border-top: 2px solid #999;
    font-weight: 700;
}
.hm-totals-row .hm-spec-cell {
    background: var(--surface-sunken);
}

/* Inline legend */
.hm-legend-inline {
    display: flex;
    gap: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}
.hm-leg-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.hm-leg-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}
.hm-leg-empty { background: var(--surface-sunken); border: 1px solid var(--border); }
.hm-leg-ok { background: var(--success-soft); }
.hm-leg-warn { background: var(--warning-soft); }
.hm-leg-over { background: var(--danger-soft); }

/* Dark mode heatmap */
/* ============================================================================
   HEATMAP RICH TOOLTIP
   ============================================================================ */

.hm-tooltip {
    display: none;
    position: fixed;
    z-index: 9999;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    padding: 12px 16px;
    min-width: 180px;
    max-width: 280px;
    pointer-events: none;
    border: 1px solid var(--border);
}

.hm-tip-header {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.hm-tip-date {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.hm-tip-status {
    font-size: 13px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: inline-block;
}
.hm-tip-ok { background: var(--success-soft); color: var(--success-dark); }
.hm-tip-warn { background: var(--warning-soft); color: var(--warning-dark); }
.hm-tip-over { background: var(--danger-soft); color: var(--danger-dark); }
.hm-tip-empty { background: var(--surface-sunken); color: var(--text-tertiary); }

.hm-tip-names {
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.hm-tip-name {
    font-size: 12px;
    color: var(--text-primary);
    padding: 3px 0;
}

/* ============================================================================
   TRAINEE PROFILE CARD
   ============================================================================ */

.profile-modal-content {
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
}

.trainee-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1.5px dashed var(--accent);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.trainee-link:hover {
    color: var(--accent);
    border-bottom-style: solid;
}

.prof-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.prof-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.prof-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
.prof-email {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.prof-stats {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.prof-stat {
    flex: 1;
    min-width: 70px;
    text-align: center;
    padding: 10px 6px;
    background: var(--surface-sunken);
    border-radius: var(--radius-md);
}
.prof-stat-val {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}
.prof-stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.prof-fair { color: var(--success); }
.prof-above { color: var(--accent); }
.prof-below { color: var(--danger); }

.prof-fill {
    margin-bottom: 20px;
}
.prof-fill-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.prof-fill-bar {
    height: 8px;
    background: var(--surface-sunken);
    border-radius: 4px;
    overflow: hidden;
}
.prof-fill-inner {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.prof-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.prof-months {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}
.prof-month {
    display: flex;
    align-items: stretch;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-sunken);
}
.prof-month-bar {
    width: 5px;
    flex-shrink: 0;
}
.prof-month-
.prof-month-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 80px;
}
.prof-month-spec {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}
.prof-month-oncall {
    font-size: 11px;
    color: var(--primary);
    margin-top: 2px;
}
.prof-month-days {
    font-size: 12px;
    color: var(--text-secondary);
}

.prof-avail {
    margin-bottom: 10px;
}
.prof-avail-item {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.prof-unavail-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 6px;
}
.prof-unavail-chip {
    font-size: 11px;
    background: var(--danger-soft);
    color: var(--danger-dark);
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
}

/* Dark mode profile */
/* ============================================================================
   PRINT STYLESHEET
   ============================================================================ */

@media print {
    /* Hide non-essential UI */
    .sidebar,
    .view-toggle,
    .filter-bar,
    .export-controls,
    .table-controls,
    .table-footer,
    .edit-mode-bar,
    .day-modal,
    .notification,
    #darkModeToggle,
    #capacitySettingsBtn,
    .btn-share-sm,
    .share-actions,
    .calendar-nav,
    .clash-fix-btn,
    .drag-grip,
    .click-hint,
    .toggle-btn,
    .download-btn,
    .search-box,
    .filter-select,
    button {
        display: none !important;
    }

    /* Reset backgrounds for printing */
    body, .main-content, .results-section {
        background: var(--surface) !important;
        color: black !important;
        margin: 0;
        padding: 0;
    }

    /* Force light mode for print regardless of dark mode setting */

    .results-section {
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
    }

    /* Show active view and analytics section */
    .view-section {
        box-shadow: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .header {
        position: static !important;
    }

    .analytics-section {
        padding: 0 !important;
    }

    .analytics-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        break-inside: avoid;
    }

    /* Results table print styling */
    #resultsTable {
        font-size: 10px;
        width: 100%;
    }
    #resultsTable th,
    #resultsTable td {
        padding: 4px 6px;
        border: 1px solid #ccc;
    }

    /* Calendar print */
    .calendar-grid {
        gap: 2px !important;
    }
    .calendar-day {
        min-height: 50px !important;
        font-size: 9px !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
    .assignment-item {
        font-size: 8px !important;
        padding: 1px 3px !important;
    }
    .assignment-count {
        font-size: 8px !important;
    }

    /* Summary table print */
    .summary-table th,
    .summary-table td {
        padding: 3px 5px !important;
        font-size: 10px !important;
        border: 1px solid #ccc !important;
    }

    /* Heatmap print */
    .heatmap-wrapper {
        max-height: none !important;
        overflow: visible !important;
    }
    .heatmap-table th,
    .heatmap-table td {
        font-size: 9px !important;
        padding: 2px 3px !important;
        border: 1px solid #ccc !important;
    }
    .hm-cell-ok { background: var(--success-soft) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .hm-cell-warn { background: var(--warning-soft) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .hm-cell-over { background: var(--danger-soft) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .hm-corner, .hm-date-header {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Timeline print */
    .timeline-wrapper {
        max-height: none !important;
        overflow: visible !important;
    }
    .tl-bar {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .tl-header {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Clash view print */
    .clash-item {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }

    /* Chart containers */
    .chart-container {
        break-inside: avoid;
    }
    canvas {
        max-width: 100% !important;
    }

    /* Summary stats cards */
    .stats-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Page setup */
    @page {
        margin: 1cm;
        size: landscape;
    }

    /* Trainee link - remove interactive styling */
    .trainee-link {
        border-bottom: none !important;
        color: black !important;
    }

    /* Info box */
    .info-box {
        display: none !important;
    }

    /* Print header */
    h2, h3 {
        break-after: avoid;
    }
}
/* ============================================================================
   DARK MODE — Specific overrides (beyond variable swaps)
   ============================================================================ */

/* Heatmap cells need explicit dark backgrounds */
body.dark-mode .hm-cell-empty { background: var(--surface-sunken); color: var(--text-muted); }
body.dark-mode .hm-cell-ok { background: #0D2818; color: #34D399; }
body.dark-mode .hm-cell-warn { background: #2A2008; color: #FBBF24; }
body.dark-mode .hm-cell-over { background: #2A0F0F; color: #F87171; }
body.dark-mode .hm-cell-total { background: var(--surface-sunken); color: var(--text-secondary); }
body.dark-mode .hm-bh-cell { background: var(--surface-sunken); color: var(--text-muted); }
body.dark-mode .hm-spec-cell { background: var(--surface); border-right-color: var(--border); }
body.dark-mode .hm-leg-empty { background: var(--surface-sunken); border-color: var(--border); }
body.dark-mode .hm-leg-ok { background: #0D2818; }
body.dark-mode .hm-leg-warn { background: #2A2008; }
body.dark-mode .hm-leg-over { background: #2A0F0F; }

/* Summary table semantic cells */
body.dark-mode .smt-high { background: #0D2818; color: #34D399; }
body.dark-mode .smt-mid { background: #2A2008; color: #FBBF24; }
body.dark-mode .smt-low { background: #2A0F0F; color: #F87171; }
body.dark-mode .smt-zero { background: #2A0F0F; color: #F87171; }
body.dark-mode .smt-total-cell { background: var(--surface-sunken); color: var(--text-primary); }
body.dark-mode .smt-summary-row { background: var(--surface-sunken) !important; }

/* Clash cards */
body.dark-mode .clash-card-over { background: #2A0F0F; }
body.dark-mode .clash-card-warn { background: #2A2008; }
body.dark-mode .clash-card-empty { background: #0F1A2E; }
body.dark-mode .clash-card-ok { background: #0D2818; }
body.dark-mode .clash-item-over { background: #2A0F0F; }
body.dark-mode .clash-item-warning { background: #2A2008; }
body.dark-mode .clash-item-empty { background: #0F1A2E; }

/* Profile card */
body.dark-mode .prof-stat { background: var(--surface-sunken); }
body.dark-mode .prof-month { background: var(--surface-sunken); }
body.dark-mode .prof-unavail-chip { background: #2A0F0F; color: #F87171; }

/* Capacity panel */
body.dark-mode .cap-settings-panel { background: var(--surface); }
body.dark-mode .cap-settings-toolbar { background: var(--surface-sunken); border-color: var(--border); }
body.dark-mode .cap-settings-table thead th { background: var(--surface); border-color: var(--border); }
body.dark-mode .cap-settings-table tbody tr:hover { background: var(--surface-sunken); }
body.dark-mode .cap-settings-header { border-color: var(--border); }
body.dark-mode .cap-settings-footer { border-color: var(--border); }
body.dark-mode .cap-input { background: var(--surface-sunken); border-color: var(--border); color: var(--text-primary); }
body.dark-mode .cap-toolbar-btn { background: var(--surface); border-color: var(--border); color: var(--text-secondary); }

/* Tooltips */
body.dark-mode .day-hover-tooltip,
body.dark-mode .tl-tooltip,
body.dark-mode .hm-tooltip { background: var(--surface-raised); border-color: var(--border); }

/* Undo toolbar */
body.dark-mode .undo-redo-toolbar { background: var(--surface-raised); border-color: var(--border); }
body.dark-mode .ur-btn { color: var(--text-primary); }
body.dark-mode .ur-count { background: var(--surface-sunken); color: var(--text-secondary); }
body.dark-mode .ur-divider { background: var(--border); }

/* Calendar bank holiday */
body.dark-mode .calendar-day.bank-holiday { background: #2A2008; border-color: var(--warning-badge); }

/* Timeline */
body.dark-mode .tl-row:nth-child(even) { background: var(--surface-sunken); }
body.dark-mode .tl-row:hover, body.dark-mode .tl-row:nth-child(even):hover { background: var(--accent-soft); }

/* Date bubble */
body.dark-mode .date-bubble { background: var(--surface-raised); border-color: var(--border); }
body.dark-mode .bubble-date { background: var(--accent-soft); color: var(--accent); }

/* Scrollbars */
body.dark-mode ::-webkit-scrollbar { width: 8px; height: 8px; }
body.dark-mode ::-webkit-scrollbar-track { background: var(--surface); }
body.dark-mode ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }


/* File hint */
.file-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Override calendar controls nav-btn (not topnav) */
.calendar-controls .nav-btn {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-secondary);
    font-family: var(--font);
}
.calendar-controls .nav-btn:hover {
    background: var(--surface-sunken);
    color: var(--text-primary);
}

/* Ensure form inputs use font */
input, select, button, textarea {
    font-family: var(--font);
}

/* Fix filter-select in new design */
.filter-select {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font);
}
.filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Fix search-box */
.search-box {
    flex: 1;
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--text-primary);
    font-family: var(--font);
}
.search-box:focus {
    outline: none;
    border-color: var(--accent);
}

/* Analytics cards in new style */
.analytics-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.analytics-stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.analytics-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
}

.analytics-stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Fix table header */
thead {
    position: sticky;
    top: 0;
    background: var(--accent);
    color: #fff;
    z-index: 10;
}

/* Fix modals */
.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.modal-header {
    border-bottom: 1px solid var(--border);
}

/* Fix calendar day header color */
.calendar-day-header {
    color: var(--accent);
}

/* Ensure calendar has-assignments uses accent */
.calendar-day.has-assignments {
    background: var(--accent-soft);
    border-color: var(--accent);
}

/* Fix assignment item border */
.assignment-item {
    border-left-color: var(--accent);
    background: var(--surface);
}

/* Fix assignment-specialty color */
.assignment-specialty {
    color: var(--accent);
}

/* Fix summary table header */
.summary-table th {
    background: var(--accent);
}

.summary-table th.smt-total {
    background: var(--text-primary);
}

/* Fix heatmap headers */
.hm-corner,
.hm-date-header {
    background: var(--accent);
}

.hm-date-header.hm-bh {
    background: var(--text-tertiary);
}

/* Timeline header */
.tl-header {
    background: var(--accent);
}

/* Calendar controls bar */
.calendar-controls {
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.calendar-filter {
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
}

/* Calendar legend */
.calendar-legend {
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
}

/* Timeline legend */
.timeline-legend {
    background: var(--surface-sunken);
    border-radius: var(--radius-sm);
}

/* Timeline wrapper */
.timeline-wrapper {
    border-color: var(--border);
    border-radius: var(--radius-md);
}

/* Heatmap wrapper */
.heatmap-wrapper {
    border-color: var(--border);
    border-radius: var(--radius-md);
}

/* Table container */
.table-container {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

/* Table footer */
.table-footer {
    background: var(--surface-sunken);
    border-top: 1px solid var(--border);
}

/* Alerts */
.alerts {
    background: var(--surface);
    border-radius: var(--radius-sm);
}

.alert-item {
    border-bottom-color: var(--border);
}

/* Error box */
.error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
}

/* Loading overlay */
.loading-overlay {
    display: none;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.loading-overlay.visible {
    display: block;
}

.loading-spinner-ring {
    border-color: var(--border);
    border-top-color: var(--accent);
}

/* Share month */
.share-month {
    background: var(--surface-sunken);
    border-left-color: var(--accent);
}

/* Insight item */
.insight-item {
    background: var(--surface);
    border-left-color: var(--accent);
}

/* Responsive */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .topnav { padding: 0 16px; }
    .container { padding: 20px 16px; }
}
/* ============================================================================
   Google Sheets Connection Status & Date Manager
   ============================================================================ */

.sheet-connection-status {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; background: var(--bg-secondary); border-radius: 8px; font-size: 14px;
}
.sheet-status-dot {
    width: 10px; height: 10px; border-radius: 50%; background: var(--text-tertiary); flex-shrink: 0;
}
.sheet-status-dot.connected { background: #22c55e; }
.sheet-status-dot.disconnected { background: #ef4444; }
.sheet-actions { margin-top: 10px; display: flex; gap: 8px; }
.btn-outline {
    background: transparent; border: 1.5px solid var(--border); color: var(--text-primary);
    padding: 8px 16px; border-radius: 8px; font-size: 13px; cursor: pointer; transition: all 0.15s;
}
.btn-outline:hover { background: var(--bg-secondary); border-color: var(--accent); color: var(--accent); }

/* Date Manager Panel */
.dm-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000;
    justify-content: center; align-items: flex-start; padding-top: 60px;
    backdrop-filter: blur(4px);
}
.dm-panel {
    background: #ffffff; border-radius: 12px; width: 660px; max-width: 95vw;
    max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.dm-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 20px 20px 16px; border-bottom: 1px solid #e2e8f0;
}
.dm-trainee-select { padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.dm-trainee-select label {
    display: block; font-size: 12px; font-weight: 600; color: #64748b;
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}
.dm-trainee-select select {
    width: 100%; padding: 10px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px;
    background: #ffffff; color: #1e293b; font-size: 14px;
}
.dm-info-row {
    display: flex; gap: 16px; padding: 12px 20px; background: #f1f5f9;
    font-size: 13px; color: #64748b; flex-wrap: wrap;
}
.dm-section { padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.dm-section h3 {
    font-size: 14px; font-weight: 600; margin: 0 0 12px 0; color: #1e293b;
    display: flex; align-items: center; gap: 8px;
}
.dm-count {
    background: var(--accent); color: white; font-size: 11px; padding: 2px 8px;
    border-radius: 10px; font-weight: 500;
}
.dm-add-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.dm-date-inputs { display: flex; align-items: center; gap: 8px; }
.dm-date-inputs label { font-size: 12px; color: #64748b; }
.dm-date-inputs input[type="date"] {
    padding: 7px 10px; border: 1.5px solid #e2e8f0; border-radius: 6px;
    background: #ffffff; color: #1e293b; font-size: 13px;
}
.btn-sm {
    width: auto; padding: 7px 14px; font-size: 13px; border-radius: 6px; border: none;
    background: #f1f5f9; color: #1e293b; cursor: pointer;
    font-weight: 500; transition: all 0.15s;
}
.btn-sm:hover { background: #e2e8f0; }
.btn-commit {
    background: var(--accent); color: white; margin-top: 12px;
}
.btn-commit:hover { opacity: 0.9; }
.dm-pending-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.dm-pending-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: #dbeafe; color: #1e40af; padding: 4px 10px; border-radius: 14px;
    font-size: 12px; font-weight: 500;
}
.dm-pending-chip .remove { cursor: pointer; font-size: 14px; line-height: 1; opacity: 0.6; }
.dm-pending-chip .remove:hover { opacity: 1; }
.dm-existing-dates {
    max-height: 280px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 5px;
}
.dm-date-tag {
    display: inline-flex; align-items: center; gap: 4px;
    background: #f1f5f9; color: #64748b; padding: 4px 10px;
    border-radius: 14px; font-size: 12px; font-family: monospace;
}
.dm-date-tag .remove {
    cursor: pointer; color: #ef4444; font-size: 14px; line-height: 1; opacity: 0.5; margin-left: 2px;
}
.dm-date-tag .remove:hover { opacity: 1; }
.dm-empty { color: #94a3b8; font-style: italic; font-size: 13px; padding: 8px 0; }
.dm-loading {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 40px 20px; color: #64748b; font-size: 14px;
}
.dm-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: #1e293b; color: white; padding: 10px 20px; border-radius: 8px;
    font-size: 14px; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: toastIn 0.3s ease;
}
@keyframes toastIn { from { opacity:0; transform:translateX(-50%) translateY(10px); } }

/* Dark mode overrides for Date Manager */
body.dark-mode .dm-panel { background: #1e293b; }
body.dark-mode .dm-header { border-bottom-color: #334155; }
body.dark-mode .dm-section { border-bottom-color: #334155; }
body.dark-mode .dm-section h3 { color: #f1f5f9; }
body.dark-mode .dm-trainee-select { border-bottom-color: #334155; }
body.dark-mode .dm-trainee-select label { color: #94a3b8; }
body.dark-mode .dm-trainee-select select { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.dark-mode .dm-info-row { background: #0f172a; color: #94a3b8; }
body.dark-mode .dm-date-inputs label { color: #94a3b8; }
body.dark-mode .dm-date-inputs input[type="date"] { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.dark-mode .btn-sm { background: #334155; color: #f1f5f9; }
body.dark-mode .btn-sm:hover { background: #475569; }
body.dark-mode .dm-date-tag { background: #334155; color: #94a3b8; }
body.dark-mode .dm-empty { color: #64748b; }
body.dark-mode .dm-loading { color: #94a3b8; }
body.dark-mode .dm-pending-chip { background: #1e3a5f; color: #93c5fd; }

/* Add Trainee Form */
.at-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.at-field { flex: 1 1 100%; }
.at-field.at-half { flex: 1 1 calc(50% - 5px); min-width: 120px; }
.at-field label { display: block; font-size: 12px; font-weight: 500; color: #64748b; margin-bottom: 4px; }
.at-field input {
    width: 100%; padding: 8px 10px; border: 1.5px solid #e2e8f0; border-radius: 6px;
    background: #ffffff; color: #1e293b; font-size: 13px; box-sizing: border-box;
}
.at-field input:focus { border-color: #3b82f6; outline: none; }
.at-specialties { margin-top: 12px; }
.at-specialties summary {
    font-size: 13px; color: #64748b; cursor: pointer; user-select: none;
}
.at-specialties summary:hover { color: #3b82f6; }
.at-spec-select {
    width: 100%; padding: 8px 10px; border: 1.5px solid #e2e8f0; border-radius: 6px;
    background: #ffffff; color: #1e293b; font-size: 13px; box-sizing: border-box;
}
.at-spec-select:focus { border-color: #3b82f6; outline: none; }

/* Dark mode for Add Trainee */
body.dark-mode .at-field label { color: #94a3b8; }
body.dark-mode .at-field input { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.dark-mode .at-field input:focus { border-color: #3b82f6; }
body.dark-mode .at-specialties summary { color: #94a3b8; }
body.dark-mode .at-spec-select { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.dark-mode .at-spec-select:focus { border-color: #3b82f6; }

/* Specialty Manager */
.spec-manager {
    padding: 16px 20px; border-bottom: 1px solid #e2e8f0; background: #f8fafc;
}
.spec-manager-add {
    display: flex; gap: 8px; margin-bottom: 12px;
}
.spec-manager-input {
    flex: 1; padding: 8px 12px; border: 1.5px solid #e2e8f0; border-radius: 6px;
    font-size: 13px; background: #ffffff; color: #1e293b;
}
.spec-manager-input:focus { border-color: #3b82f6; outline: none; }
.spec-manager-list {
    display: flex; flex-wrap: wrap; gap: 6px; max-height: 200px; overflow-y: auto;
}
.spec-tag {
    display: inline-flex; align-items: center; gap: 4px;
    background: #e0e7ff; color: #3730a3; padding: 5px 12px; border-radius: 14px;
    font-size: 13px; font-weight: 500;
}
.spec-tag .remove {
    cursor: pointer; font-size: 15px; line-height: 1; opacity: 0.5; margin-left: 2px;
    color: #ef4444;
}
.spec-tag .remove:hover { opacity: 1; }

/* Dark mode for Specialty Manager */
body.dark-mode .spec-manager { background: #0f172a; border-bottom-color: #334155; }
body.dark-mode .spec-manager-input { background: #1e293b; color: #f1f5f9; border-color: #334155; }
body.dark-mode .spec-tag { background: #1e3a5f; color: #93c5fd; }

/* Trainee action buttons */
.dm-trainee-actions {
    display: flex; gap: 8px; padding: 12px 20px; border-bottom: 1px solid #e2e8f0;
}
.btn-danger {
    background: #fef2f2; color: #dc2626; border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }
body.dark-mode .btn-danger { background: #2a0f0f; color: #f87171; border-color: #7f1d1d; }
body.dark-mode .btn-danger:hover { background: #3b1111; }
body.dark-mode .dm-trainee-actions { border-bottom-color: #334155; }

/* Bulk date paste */
.dm-bulk-toggle { margin-top: 10px; }
.dm-bulk-textarea {
    width: 100%; padding: 10px 12px; border: 1.5px solid #e2e8f0; border-radius: 6px;
    font-size: 13px; font-family: monospace; background: #ffffff; color: #1e293b;
    resize: vertical; margin-bottom: 8px; box-sizing: border-box;
}
.dm-bulk-textarea:focus { border-color: #3b82f6; outline: none; }
body.dark-mode .dm-bulk-textarea { background: #0f172a; color: #f1f5f9; border-color: #334155; }

/* Dashboard */
.dash-cards {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 20px;
}
@media (max-width: 600px) { .dash-cards { grid-template-columns: repeat(2, 1fr); } }
.dash-card {
    background: #f8fafc; border-radius: 10px; padding: 16px; text-align: center;
    border: 1px solid #e2e8f0;
}
.dash-card-num { font-size: 28px; font-weight: 700; color: #1e293b; line-height: 1.1; }
.dash-card-label { font-size: 12px; color: #64748b; margin-top: 4px; }
.dash-row { display: flex; gap: 12px; padding: 0 20px 16px; }
.dash-card-sub {
    flex: 1; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 10px 14px; font-size: 13px; color: #64748b;
}
.dash-section { padding: 16px 20px; border-top: 1px solid #e2e8f0; }
.dash-section h3 { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: #1e293b; }

/* Capacity alerts */
.dash-alert {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 6px;
}
.dash-alert-name { font-weight: 600; }
.dash-alert-warn { background: #fefce8; color: #854d0e; border: 1px solid #fef08a; }
.dash-alert-over { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Bar chart */
.dash-bars { display: flex; flex-direction: column; gap: 6px; }
.dash-bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dash-bar-label { width: 110px; text-align: right; color: #64748b; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-bar-track { flex: 1; height: 20px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.dash-bar-fill { height: 100%; background: #3b82f6; border-radius: 4px; transition: width 0.3s; min-width: 2px; }
.dash-bar-val { width: 30px; text-align: right; font-weight: 600; color: #1e293b; }

/* Upcoming dates */
.dash-upcoming { display: flex; flex-direction: column; gap: 4px; max-height: 250px; overflow-y: auto; }
.dash-upcoming-row {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: #f8fafc; border-radius: 6px; font-size: 13px;
}
.dash-upcoming-date { font-weight: 600; color: #1e293b; width: 90px; flex-shrink: 0; }
.dash-upcoming-count {
    background: #dbeafe; color: #1e40af; padding: 2px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.dash-upcoming-names { color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dark mode dashboard */
body.dark-mode .dash-card { background: #0f172a; border-color: #334155; }
body.dark-mode .dash-card-num { color: #f1f5f9; }
body.dark-mode .dash-card-label { color: #94a3b8; }
body.dark-mode .dash-card-sub { background: #0f172a; border-color: #334155; color: #94a3b8; }
body.dark-mode .dash-section { border-top-color: #334155; }
body.dark-mode .dash-section h3 { color: #f1f5f9; }
body.dark-mode .dash-alert-warn { background: #2a2008; color: #fbbf24; border-color: #854d0e; }
body.dark-mode .dash-alert-over { background: #2a0f0f; color: #f87171; border-color: #7f1d1d; }
body.dark-mode .dash-bar-label { color: #94a3b8; }
body.dark-mode .dash-bar-track { background: #1e293b; }
body.dark-mode .dash-bar-val { color: #f1f5f9; }
body.dark-mode .dash-upcoming-row { background: #0f172a; }
body.dark-mode .dash-upcoming-date { color: #f1f5f9; }
body.dark-mode .dash-upcoming-count { background: #1e3a5f; color: #93c5fd; }
body.dark-mode .dash-upcoming-names { color: #94a3b8; }

/* Trainee self-service view */
.hidden-trainee { display: none !important; }
.trainee-panel { max-width: 660px; margin: 0 auto; padding: 20px; }
.trainee-welcome { margin-bottom: 24px; }
.trainee-welcome h2 { font-size: 22px; margin: 0; color: #1e293b; }
.trainee-welcome p { font-size: 14px; color: #64748b; margin: 4px 0 0; }
.trainee-info-card {
    background: #ffffff; border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 20px; margin-bottom: 16px;
}
.trainee-info-card h3 {
    font-size: 15px; font-weight: 600; margin: 0 0 14px; color: #1e293b;
    display: flex; align-items: center; gap: 8px;
}
.trainee-info-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.trainee-info-grid > div { display: flex; flex-direction: column; gap: 2px; }
.trainee-info-label { font-size: 11px; text-transform: uppercase; font-weight: 600; color: #94a3b8; letter-spacing: 0.05em; }
.trainee-info-grid span:not(.trainee-info-label) { font-size: 14px; color: #1e293b; }
.trainee-spec-list { display: flex; flex-direction: column; gap: 6px; }
.trainee-spec-item { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.trainee-spec-month { font-weight: 600; color: #64748b; width: 70px; }

/* Dark mode trainee */
body.dark-mode .trainee-welcome h2 { color: #f1f5f9; }
body.dark-mode .trainee-welcome p { color: #94a3b8; }
body.dark-mode .trainee-info-card { background: #1e293b; border-color: #334155; }
body.dark-mode .trainee-info-card h3 { color: #f1f5f9; }
body.dark-mode .trainee-info-label { color: #64748b; }
body.dark-mode .trainee-info-grid span:not(.trainee-info-label) { color: #f1f5f9; }
body.dark-mode .trainee-spec-month { color: #94a3b8; }
/* ============================================================================
   ON-CALL ROTA STYLES
   ============================================================================ */

/* Day-level calendar grid */
.oc-day-grid {
    display: grid;
    grid-template-columns: 65px repeat(7, 1fr);
    gap: 1px;
    background: var(--border, #e2e8f0);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    overflow: hidden;
    font-size: 12px;
    max-height: 500px;
    overflow-y: auto;
}

@media (max-width: 700px) {
    .oc-day-grid {
        grid-template-columns: 50px repeat(7, 1fr);
        font-size: 10px;
    }
}

/* Calendar grid (block view) */
.oc-calendar-grid {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 1fr;
    gap: 1px;
    background: var(--border, #e2e8f0);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    overflow: hidden;
    font-size: 13px;
    max-height: 500px;
    overflow-y: auto;
}

.oc-cal-header {
    background: var(--bg-hover, #f1f5f9);
    padding: 8px 10px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary, #64748b);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 2;
}

.oc-cal-week-label {
    background: var(--bg-card, #fff);
    padding: 8px 10px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary, #64748b);
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--border, #e2e8f0);
}

.oc-cal-cell {
    background: var(--bg-card, #fff);
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 50px;
}

.oc-cal-entry {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.2;
    transition: transform 0.1s;
    cursor: default;
}

.oc-cal-entry:hover {
    transform: scale(1.02);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.oc-cal-shift {
    font-size: 10px;
    flex-shrink: 0;
}

.oc-cal-rota {
    flex-shrink: 0;
}

.oc-cal-trainee {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary, #1e293b);
    font-size: 11px;
}

.oc-own-shift {
    outline: 2px solid #3b82f6;
    outline-offset: -1px;
    font-weight: 600;
}

.oc-cal-night {
    font-weight: 500;
}

.oc-cal-night .oc-cal-trainee {
    color: var(--text-primary, #1e293b);
    font-weight: 500;
}

body.dark-mode .oc-cal-night {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Table styles */
.oc-unfilled-row {
    background: #fef2f2 !important;
}

.oc-unfilled-cell {
    color: #dc2626;
    font-weight: 600;
}

/* Toggle btn active */
.toggle-btn.active {
    background: var(--primary, #3b82f6);
    color: white;
    border-color: var(--primary, #3b82f6);
}

/* Admin controls visibility for trainees */
.hidden-trainee #ocControls .btn-commit,
.hidden-trainee #ocLoadSavedBtn {
    /* Keep visible — trainees can view saved */
}

/* Dark mode support */
body.dark-mode .oc-calendar-grid {
    background: #334155;
    border-color: #334155;
}

body.dark-mode .oc-cal-header {
    background: #1e293b;
    color: #94a3b8;
}

body.dark-mode .oc-cal-week-label {
    background: #0f172a;
    color: #94a3b8;
    border-color: #334155;
}

body.dark-mode .oc-cal-cell {
    background: #0f172a;
}

body.dark-mode .oc-cal-trainee {
    color: #f1f5f9;
}

body.dark-mode .oc-unfilled-row {
    background: #451a1a !important;
}

body.dark-mode .oc-unfilled-cell {
    color: #f87171;
}

/* Responsive */
@media (max-width: 700px) {
    .oc-calendar-grid {
        grid-template-columns: 60px 1fr 1fr 1fr;
        font-size: 11px;
    }

    .oc-cal-entry {
        padding: 2px 4px;
        font-size: 10px;
    }

    .oc-cal-rota {
        display: none;
    }
}

/* On-Call Trainee Chips */
.oc-trainee-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--border, #e2e8f0);
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #64748b);
    transition: all 0.15s;
    user-select: none;
}

.oc-trainee-chip input[type="checkbox"] {
    display: none;
}

.oc-trainee-chip-on {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
    font-weight: 500;
}

body.dark-mode .oc-trainee-chip {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

body.dark-mode .oc-trainee-chip-on {
    background: #1e3a5f;
    border-color: #3b82f6;
    color: #93c5fd;
}

.oc-add-more-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    border: 1px dashed var(--border, #cbd5e1);
    background: transparent;
    color: var(--text-secondary, #64748b);
    transition: all 0.15s;
}

.oc-add-more-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
}

/* Month Tabs */
.oc-month-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-hover, #f1f5f9);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    font-size: 13px;
}

.oc-month-tab-label {
    font-weight: 600;
}

.oc-month-tab-info {
    color: var(--text-secondary, #64748b);
    font-size: 12px;
}

.oc-month-tab-remove {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
    border-radius: 4px;
}

.oc-month-tab-remove:hover {
    color: #ef4444;
    background: #fef2f2;
}

body.dark-mode .oc-month-tab {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .oc-month-tab-remove:hover {
    background: #451a1a;
}

/* Calendar month separator */
.oc-cal-month-sep {
    background: var(--bg-hover, #f1f5f9);
    padding: 6px 12px;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary, #1e293b);
    border-top: 2px solid var(--border, #e2e8f0);
    letter-spacing: 0.02em;
}

body.dark-mode .oc-cal-month-sep {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
}

/* Trainee selector scrollbar */
#ocTraineeSelector::-webkit-scrollbar {
    width: 6px;
}
#ocTraineeSelector::-webkit-scrollbar-track {
    background: transparent;
}
#ocTraineeSelector::-webkit-scrollbar-thumb {
    background: var(--border, #cbd5e1);
    border-radius: 3px;
}

/* On-Call Month Cards */
.oc-month-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.oc-month-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 12px;
    transition: border-color 0.15s;
}

.oc-month-card:hover {
    border-color: #94a3b8;
}

.oc-month-card-done {
    border-color: #10b981;
    background: #f0fdf4;
}

.oc-month-card-warn {
    border-color: #f59e0b;
    background: #fffbeb;
}

body.dark-mode .oc-month-card {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .oc-month-card-done {
    background: #052e16;
    border-color: #10b981;
}

body.dark-mode .oc-month-card-warn {
    background: #451a03;
    border-color: #f59e0b;
}

.oc-month-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.oc-month-card-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-hover, #f1f5f9);
    color: var(--text-secondary, #64748b);
}

.oc-month-card-rotas {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.oc-month-rota-row {
    display: flex;
    gap: 6px;
    align-items: baseline;
    font-size: 12px;
}

.oc-month-rota-label {
    font-weight: 600;
    min-width: 50px;
    flex-shrink: 0;
}

.oc-month-rota-names {
    color: var(--text-secondary, #64748b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oc-month-card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border, #e2e8f0);
}

.oc-month-remove-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    margin-left: auto;
    border-radius: 4px;
    line-height: 1;
}

.oc-month-remove-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

.oc-code-example {
    background: var(--bg-code, #f1f5f9);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

body.dark-mode .oc-code-example {
    background: #334155;
}

body.dark-mode .oc-month-remove-btn:hover {
    background: #451a1a;
}

/* On-Call Rules */
.oc-rules-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.oc-rule-chip {
    padding: 5px 12px;
    background: var(--bg-hover, #f1f5f9);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    font-size: 12px;
}

.oc-rule-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-hover, #f1f5f9);
    border-radius: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

body.dark-mode .oc-rule-chip {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .oc-rule-row {
    background: #1e293b;
}

/* On-Call Constraints */
.oc-constraints-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.oc-constraint-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-hover, #f1f5f9);
    border-radius: 8px;
}

.oc-constraint-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.oc-constraint-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.oc-constraint-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.oc-constraint-desc {
    font-size: 11px;
    color: var(--text-secondary, #64748b);
}

/* Toggle switch */
.oc-constraint-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}

.oc-constraint-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.oc-constraint-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #cbd5e1;
    border-radius: 22px;
    transition: 0.2s;
}

.oc-constraint-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.oc-constraint-toggle input:checked + .oc-constraint-slider {
    background: #3b82f6;
}

.oc-constraint-toggle input:checked + .oc-constraint-slider::before {
    transform: translateX(18px);
}

body.dark-mode .oc-constraint-row {
    background: #1e293b;
}

body.dark-mode .oc-constraint-label {
    color: #f1f5f9;
}

body.dark-mode .oc-constraint-slider {
    background: #475569;
}

/* Change Log */
.cl-entries {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 60vh;
    overflow-y: auto;
}

.cl-entry {
    padding: 10px 14px;
    background: var(--bg-hover, #f8fafc);
    border-radius: 8px;
    border-left: 3px solid var(--border);
}

.cl-entry-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cl-action-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.cl-target {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.cl-meta {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    margin-left: auto;
    white-space: nowrap;
}

.cl-details {
    font-size: 12px;
    color: var(--text-secondary, #64748b);
    margin-top: 4px;
    line-height: 1.4;
    word-break: break-word;
}

.cl-fields {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    margin-top: 3px;
    font-style: italic;
}

body.dark-mode .cl-entry {
    background: #1e293b;
}

/* Backups */
.bk-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 50vh;
    overflow-y: auto;
}

.bk-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-hover, #f8fafc);
    border-radius: 8px;
    gap: 10px;
}

.bk-entry.bk-latest {
    border-left: 3px solid #22c55e;
}

.bk-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.bk-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.bk-date {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
}

.bk-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

body.dark-mode .bk-entry {
    background: #1e293b;
}

/* Conflict Checker */
.cf-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 60vh;
    overflow-y: auto;
}

.cf-entry {
    padding: 10px 14px;
    background: var(--bg-hover, #f8fafc);
    border-radius: 8px;
    border-left: 3px solid #ef4444;
}

.cf-entry-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cf-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.cf-type {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.cf-date {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    margin-left: auto;
    white-space: nowrap;
    font-family: monospace;
}

.cf-detail {
    font-size: 12px;
    color: var(--text-secondary, #64748b);
    margin-top: 4px;
    line-height: 1.4;
}

body.dark-mode .cf-entry {
    background: #1e293b;
}

/* Trainee dashboard responsive */
@media (max-width: 700px) {
    #traineeDashboard [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}
/* Drag & Drop rota editing */
.oc-cal-cell.dd-over {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    background: var(--accent)18 !important;
}
.oc-cal-entry[draggable="true"]:hover {
    box-shadow: 0 2px 8px #0003;
    transform: translateY(-1px);
}