/* UIUX Pro Max System Styling - Premium, Glassmorphic & Minimal Grid System */
:root {
    /* DEFAULT: LIGHT THEME */
    --bg-dark: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.75);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-glow: rgba(99, 102, 241, 0.06);
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --text-inactive: #94a3b8;
    --bg-member-cell: #ffffff;
    --bg-modal: rgba(255, 255, 255, 0.96);
    --bg-popover: rgba(255, 255, 255, 0.98);
    --bg-header-row: rgba(241, 245, 249, 0.85);
    
    --primary: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1, #4f46e5);
    --primary-hover: #4338ca;
    
    --danger: #ef4444;
    --danger-gradient: linear-gradient(135deg, #f87171, #dc2626);
    --success: #10b981;
    --success-gradient: linear-gradient(135deg, #34d399, #059669);
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --sidebar-width: 240px;
    --header-height: 50px;
    --row-height: 48px;
    --col-width: 50px;
    
    --glass-blur: blur(16px);
    --shadow-premium: 0 4px 20px rgba(15, 23, 42, 0.06), 
                      0 1px 3px rgba(15, 23, 42, 0.02);
    --shadow-inset: inset 0 1px 1px rgba(255, 255, 255, 0.8);
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.08);
}

body.dark-theme {
    /* OVERRIDES FOR DARK THEME */
    --bg-dark: #070913;
    --bg-card: rgba(22, 28, 45, 0.65);
    --border-color: rgba(255, 255, 255, 0.05);
    --border-glow: rgba(99, 102, 241, 0.15);
    --text-primary: #f8fafc;
    --text-muted: #64748b;
    --text-inactive: #475569;
    --bg-member-cell: #121929;
    --bg-modal: rgba(19, 27, 46, 0.9);
    --bg-popover: rgba(19, 27, 46, 0.95);
    --bg-header-row: rgba(10, 16, 30, 0.4);
    
    --primary: #5f5af6;
    --primary-gradient: linear-gradient(135deg, #818cf8, #4f46e5);
    --primary-hover: #4f46e5;
    
    --shadow-premium: 0 4px 30px rgba(0, 0, 0, 0.4), 
                      0 1px 3px rgba(255, 255, 255, 0.05);
    --shadow-inset: inset 0 1px 1px rgba(255, 255, 255, 0.05);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes popoverIn {
    from { opacity: 0; transform: translateY(6px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.animate-fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.animate-zoom-in {
    animation: zoomIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.delay-1 {
    animation-delay: 0.08s;
}

/* Resets */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.04) 0, transparent 40%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.02) 0, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.5;
    overflow-x: hidden;
    padding-bottom: 50px;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body.dark-theme {
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0, transparent 40%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0, transparent 50%);
}

/* Premium Card / Glassmorphism */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-premium);
}

/* App Header Styling */
.app-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

body.dark-theme .app-header {
    background: rgba(15, 23, 42, 0.45);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 26px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
}

.header-logo h1 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 24px;
    letter-spacing: -0.8px;
    background: linear-gradient(135deg, #c7d2fe, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: rgba(99, 102, 241, 0.1);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.25);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 99px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Mode Switcher - Glassy pill */
.mode-switcher {
    display: flex;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-inset);
}

.mode-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--primary-gradient);
    color: var(--text-primary);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    transform: translateY(-0.5px);
}

/* App Container Layout */
.app-container {
    max-width: 100%;
    margin: 12px auto;
    padding: 0 20px;
}

/* Control Panel Layout */
.control-panel {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    gap: 16px;
    align-items: end;
}
.control-panel.card {
    padding: 12px 20px;
    margin-bottom: 12px;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-section label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Custom inputs & selects */
.form-control {
    background-color: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-inset);
}

.form-control:focus {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: var(--shadow-glow), var(--shadow-inset);
}

.date-input-group {
    display: flex;
    gap: 6px;
}

input[type="date"] {
    background-color: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    width: 170px;
    box-shadow: var(--shadow-inset);
    transition: border-color 0.2s ease;
}

input[type="date"]:focus {
    border-color: rgba(99, 102, 241, 0.5);
}

/* Buttons with tactile feedback */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: var(--shadow-inset);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25), var(--shadow-inset);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35), var(--shadow-inset);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger-gradient);
    color: #fff;
}
.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
}

.btn-icon {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

/* Total daily workhours box */
.total-hours-box {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(99, 102, 241, 0.03));
    border: 1px solid var(--border-color);
    border-radius: 10px;
    height: 44px;
    padding: 0 18px;
    box-shadow: var(--shadow-inset);
    min-width: 130px;
}

body.dark-theme .total-hours-box {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(79, 70, 229, 0.04));
}

#totalWorkhoursDisplay {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}

body.dark-theme #totalWorkhoursDisplay {
    color: #a5b4fc;
}

/* Freeze Controls UI */
.freeze-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.freeze-group .btn {
    white-space: nowrap;
}

#freezeRestoreSelect {
    min-width: 160px;
}

.filter-group, .action-btn-group {
    display: flex;
    gap: 10px;
}

/* Gantt Chart Grid System (Minimal Grid Spec) */
.timeline-container {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
    -webkit-overflow-scrolling: touch;
}

.timeline-grid {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Header Row & Cells sticky behavior */
.grid-header-row {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-header-row);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    transition: background-color 0.3s ease;
}

.member-header-cell {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    padding: 16px 24px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    left: 0;
    z-index: 12;
    background-color: var(--bg-member-cell);
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.member-header-cell .title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.2px;
}

.member-header-cell .sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}

.time-header-cells {
    display: flex;
    flex-grow: 1;
}

.time-cell {
    flex: 1 1 0%;
    min-width: 30px;
    border-right: 1px dashed rgba(15, 23, 42, 0.08);
    padding: 12px 0;
    text-align: center;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-inactive);
    transition: all 0.2s ease;
}

body.dark-theme .time-cell {
    border-right: 1px dashed rgba(255, 255, 255, 0.05);
}

.time-cell.col-highlight {
    color: #fff !important;
    background-color: rgba(99, 102, 241, 0.12);
    border-bottom: 2px solid var(--primary);
    text-shadow: 0 0 8px rgba(99, 102, 241, 0.6);
}

.time-cell.hour-label {
    color: var(--text-primary) !important;
    font-weight: 700;
    font-size: 11.5px;
}

.time-cell.hour-mark {
    border-right: 2px solid rgba(15, 23, 42, 0.18);
    color: var(--text-inactive);
    font-weight: 400;
    font-size: 10px;
    opacity: 0.6;
}

body.dark-theme .time-cell.hour-mark {
    border-right: 2px solid rgba(255, 255, 255, 0.18);
}

/* Grid Body Rows (Ultralight Minimal lines) */
.grid-body {
    max-height: calc(100vh - 200px); /* Expanded to fit space dynamically */
    min-height: 450px;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
}

.grid-body::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}


.grid-row {
    display: flex;
    height: var(--row-height);
    min-height: var(--row-height);
    max-height: var(--row-height);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
    overflow: hidden; /* Prevent vertical height growth */
}

.grid-row:hover {
    background-color: rgba(99, 102, 241, 0.015);
}

.member-cell {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%; /* Force fill grid-row height */
    padding: 4px 20px; /* Reduce padding to fit content nicely within 48px */
    border-right: 1px solid var(--border-color);
    background-color: var(--bg-member-cell);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    cursor: grab;
}

.member-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.member-workhours {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    background-color: rgba(99, 102, 241, 0.08);
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    transition: all 0.3s ease;
    white-space: nowrap; /* Prevent badge from breaking into lines */
    flex-shrink: 0; /* Keep badge size intact */
}

body.dark-theme .member-workhours {
    background-color: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

.workhours-main {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
}

body.dark-theme .workhours-main {
    color: #a5b4fc;
}

.workhours-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.member-cell:active {
    cursor: grabbing;
}

.grid-row.member-dragging {
    opacity: 0.4;
    background-color: rgba(99, 102, 241, 0.05);
}

.grid-row.member-drag-over {
    border-top: 2px solid var(--primary) !important;
}

body.dark-theme .member-cell {
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.25);
}

.member-cell .member-name {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.2px;
    white-space: nowrap; /* Prevent name from breaking into lines */
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px; /* Leave enough room for the workhours badge */
}

.member-cell .member-dept {
    font-size: 9px;
    padding: 2px 7px;
    border-radius: 4px;
    align-self: flex-start;
    margin-top: 5px;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Timeline slots (Alternating ultralight columns with visual grid) */
.timeline-slots {
    display: flex;
    flex-grow: 1;
    position: relative;
    height: var(--row-height);
    background-size: var(--grid-size-half, 50px) 100%, var(--grid-size-full, 100px) 100%;
    background-image: 
        linear-gradient(to right, rgba(15, 23, 42, 0.04) 1px, transparent 1px),
        linear-gradient(to right, rgba(15, 23, 42, 0.18) 2px, transparent 2px);
    border-right: 1px solid var(--border-color);
    transition: background-color 0.2s ease, outline 0.2s ease;
}

body.dark-theme .timeline-slots {
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(to right, rgba(255, 255, 255, 0.15) 2px, transparent 2px);
}

.timeline-slots.drag-over {
    background-color: rgba(99, 102, 241, 0.08) !important;
    outline: 2px dashed rgba(99, 102, 241, 0.45);
    outline-offset: -2px;
}

/* Shift Bar (Gantt element - premium microinteractions) */
.shift-bar {
    position: absolute;
    top: 6px;
    bottom: 6px;
    border-radius: 8px;
    padding: 4px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
    cursor: grab;
    user-select: none;
    transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), 
                box-shadow 0.2s cubic-bezier(0.25, 0.8, 0.25, 1),
                opacity 0.2s ease,
                left 0.1s ease,
                width 0.1s ease;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

body.dark-theme .shift-bar {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.shift-bar.selected {
    outline: 2.5px solid #4f46e5;
    outline-offset: 1px;
    box-shadow: 0 0 14px rgba(79, 70, 229, 0.5), 0 6px 20px rgba(0, 0, 0, 0.35);
    z-index: 50 !important;
}

body.dark-theme .shift-bar.selected {
    outline: 2.5px solid #818cf8;
    box-shadow: 0 0 14px rgba(129, 140, 248, 0.6), 0 6px 20px rgba(0, 0, 0, 0.45);
}

.shift-bar.dragging {
    opacity: 0.45 !important;
    transform: scale(0.96) rotate(-1deg) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
    z-index: 1000;
}

.shift-bar.resizing {
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.35);
    border: 1px solid rgba(99, 102, 241, 0.6) !important;
    filter: brightness(1.1);
    z-index: 99 !important;
}

.shift-bar-preview {
    position: absolute;
    top: 6px;
    bottom: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background-color: rgba(255, 255, 255, 0.02);
    pointer-events: none;
    transition: left 0.08s cubic-bezier(0.25, 0.8, 0.25, 1), 
                width 0.08s cubic-bezier(0.25, 0.8, 0.25, 1), 
                border-color 0.2s ease, 
                background-color 0.2s ease;
}

.shift-bar-preview .preview-text {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.timeline-slots:hover .shift-bar-preview {
    border-color: rgba(99, 102, 241, 0.4);
    background-color: rgba(99, 102, 241, 0.05);
}

.timeline-slots:hover .shift-bar-preview .preview-text {
    color: rgba(165, 180, 252, 0.8);
}

.shift-bar:hover {
    transform: translateY(-0.5px) scale(1.0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    filter: brightness(1.05);
}

.shift-bar:active {
    cursor: grabbing;
    transform: scale(0.99) translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
    z-index: 100;
}

.shift-bar .bar-title {
    font-weight: 700;
    font-size: 11px;
    line-height: 1.25;
    letter-spacing: -0.2px;
    word-break: break-all;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.shift-bar .bar-time {
    display: none !important; /* Always hide default time label */
}

.shift-time-preview {
    position: absolute;
    top: 50%; /* Center vertically */
    left: 50%; /* Center horizontally */
    transform: translate(-50%, -50%);
    color: #000000 !important;
    font-size: 16px;
    font-weight: 900;
    white-space: nowrap;
    z-index: 100;
    display: none; /* Hidden by default */
    pointer-events: none; /* Prevent blocking mouse actions */
    text-shadow: 
        -1px -1px 0 #ffffff,  
         1px -1px 0 #ffffff,
        -1px  1px 0 #ffffff,
         1px  1px 0 #ffffff,
         0 0 6px rgba(255, 255, 255, 0.85); /* White readable boundary for black text */
}

/* Show preview when resizing or dragging */
.shift-bar.resizing .shift-time-preview,
.shift-bar.dragging .shift-time-preview {
    display: block !important;
}

/* Shift Resizer handles (Minimal styling - expanded hit targets) */
.shift-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 14px;
    background-color: transparent;
    cursor: ew-resize;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.shift-bar:hover .shift-resizer {
    background-color: rgba(255, 255, 255, 0.15);
}

.shift-resizer:hover {
    background-color: rgba(255, 255, 255, 0.35) !important;
}

.resizer-left {
    left: 0;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.resizer-right {
    right: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Quick delete icon on bar */
.shift-delete-btn {
    position: absolute;
    top: 3px;
    right: 6px;
    font-size: 10px;
    color: #fff;
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.shift-bar:hover .shift-delete-btn {
    opacity: 0.5;
}
.shift-delete-btn:hover {
    opacity: 1.0 !important;
    transform: scale(1.1);
}

/* Drag handle at the top of shift bar */
.bar-drag-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 14px;
    background-color: rgba(0, 0, 0, 0.15);
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: rgba(255, 255, 255, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 5;
}

.shift-bar:hover .bar-drag-handle {
    opacity: 1.0;
}

.bar-drag-handle:active {
    cursor: grabbing;
}

/* Break draw area overlay in shift bar */
.break-draw-area {
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    cursor: crosshair;
}

/* Restructure shift content */
.shift-bar-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    pointer-events: none; /* Let drag events fall through to draw area */
    padding-top: 6px;
    z-index: 2;
}

/* Break Bar inside Shift Bar */
.break-bar {
    position: absolute;
    top: 0; /* Render using full vertical space */
    bottom: 0;
    border-radius: 8px;
    border: 1px dashed rgba(0, 0, 0, 0.25);
    background: repeating-linear-gradient(
        45deg,
        rgba(226, 232, 240, 0.85),
        rgba(226, 232, 240, 0.85) 6px,
        rgba(203, 213, 225, 0.85) 6px,
        rgba(203, 213, 225, 0.85) 12px
    );
    color: #1e293b;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3; /* Render above draw area and content */
    cursor: grab;
    user-select: none;
    transition: left 0.1s ease, width 0.1s ease, transform 0.2s ease;
}

body.dark-theme .break-bar {
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: repeating-linear-gradient(
        45deg,
        rgba(51, 65, 85, 0.85),
        rgba(51, 65, 85, 0.85) 6px,
        rgba(30, 41, 59, 0.85) 6px,
        rgba(30, 41, 59, 0.85) 12px
    );
    color: #f1f5f9;
}

.break-bar:active {
    cursor: grabbing;
}

.break-bar.dragging {
    opacity: 0.7;
    transform: scale(0.98);
}

.break-bar.resizing {
    border: 1px solid #6366f1 !important;
}

.break-bar-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.8;
    line-height: 1.1;
    pointer-events: none;
}

.break-bar-time {
    font-size: 9px;
    font-weight: 700;
    opacity: 0.9;
    pointer-events: none;
}

/* Resizers for break time boundaries */
.break-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    background-color: transparent;
    cursor: ew-resize;
    z-index: 10;
}

.break-resizer-left {
    left: 0;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.break-resizer-right {
    right: 0;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.break-bar:hover .break-resizer {
    background-color: rgba(0, 0, 0, 0.1);
}

body.dark-theme .break-bar:hover .break-resizer {
    background-color: rgba(255, 255, 255, 0.1);
}

.break-resizer:hover {
    background-color: rgba(99, 102, 241, 0.4) !important;
}

/* Delete button on break bar */
.break-delete-btn {
    position: absolute;
    top: 1px;
    right: 3px;
    font-size: 8px;
    color: currentColor;
    opacity: 0;
    cursor: pointer;
    z-index: 15;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.break-bar:hover .break-delete-btn {
    opacity: 0.6;
}

.break-delete-btn:hover {
    opacity: 1.0 !important;
    transform: scale(1.2);
}

/* Zebra warning stripes for overlap conflict (AI proposal 1 - visual polish) */
.shift-bar.overlap-conflict {
    border: 2px solid var(--danger);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.45);
    background: repeating-linear-gradient(
        45deg,
        rgba(239, 68, 68, 0.15),
        rgba(239, 68, 68, 0.15) 8px,
        transparent 8px,
        transparent 16px
    ) !important;
}

/* ========================================================
   GLOBAL POPOVER CARD - UIUX Pro Max detailed feedback
   ======================================================== */
.global-popover {
    position: absolute;
    background: var(--bg-popover);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    color: var(--text-primary);
    font-size: 12px;
    pointer-events: none; /* Make click-through */
    z-index: 300;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
    width: 240px;
}

body.dark-theme .global-popover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.global-popover.show {
    opacity: 1;
    transform: translateY(0);
    animation: popoverIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.popover-arrow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: var(--bg-popover);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.popover-tag {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.05);
}

.popover-time {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 10px;
}

.popover-detail {
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
}

.popover-conflict {
    color: #fca5a5;
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 6px;
    padding: 4px 8px;
    margin-top: 8px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.popover-workhours {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-color);
}

.popover-hours-split {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

.popover-hours-split strong {
    color: var(--text-primary);
}

/* Modals & Backdrop Blur */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-modal);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 480px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body.dark-theme .modal-card {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal-card.wide {
    width: 780px;
}

.modal-header {
    background-color: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body.dark-theme .modal-header {
    background-color: rgba(0, 0, 0, 0.2);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 26px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}
.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 28px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 20px 28px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.warning-banner {
    background-color: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    padding: 14px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    margin-top: 18px;
}

/* Modal split view for members management */
.flex-modal {
    display: flex;
    gap: 40px;
}

.modal-split-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.border-left {
    border-left: 1px solid var(--border-color);
    padding-left: 40px;
}

.member-list-scroll {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.member-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}
.member-list-item:last-child {
    border-bottom: none;
}

.member-list-item .name-dept {
    display: flex;
    flex-direction: column;
}

.member-list-item .m-name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.member-list-item .m-dept {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.delete-member-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    transition: all 0.2s ease;
}
.delete-member-btn:hover {
    color: var(--danger);
    transform: scale(1.08);
}

/* LINE Publish Styles */
.line-chat-preview {
    background-color: #8fa6c5;
    border-radius: 16px;
    padding: 20px;
    color: #2c2c2c;
}

.line-bubble-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    margin-bottom: 12px;
}

.line-green {
    color: #06c755;
    font-size: 20px;
}

.line-bubble {
    background-color: #fff;
    border-radius: 18px;
    border-top-left-radius: 2px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    position: relative;
    max-width: 95%;
}

.line-bubble-text {
    font-size: 12.5px;
    line-height: 1.6;
}

.preview-link {
    color: #06c755;
    text-decoration: underline;
}

.line-bubble-memo-label {
    font-size: 10px;
    font-weight: 800;
    color: #777;
}

.text-area-preview {
    margin-top: 8px;
    background-color: #f7f9fa !important;
    border: 1px solid #ddd !important;
    color: #2c2c2c !important;
    font-size: 12.5px !important;
    border-radius: 8px !important;
}

/* Toast System */
.toast-notification {
    position: fixed;
    bottom: 40px;
    right: 40px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    padding: 16px 28px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 1000;
    transform: translateX(130%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notification.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 20px;
}

.toast-message {
    font-size: 14px;
    font-weight: 600;
}

/* Empty states */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 40px;
    margin-bottom: 16px;
    opacity: 0.5;
}
.empty-state p {
    font-size: 14px;
    font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .control-panel {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    .action-wrapper {
        grid-column: span 2;
    }
    .action-btn-group {
        justify-content: flex-end;
    }
}

/* Mobile responsive view optimizations */
@media (max-width: 600px) {
    .app-header {
        padding: 0 20px;
        height: 70px;
    }
    
    .header-logo h1 {
        font-size: 20px;
    }
    
    .mode-switcher {
        display: none;
    }

    .app-container {
        margin: 20px auto;
        padding: 0 15px;
    }

    .control-panel {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .action-wrapper {
        grid-column: span 1;
    }

    .action-btn-group {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    
    #btnPublishLINE {
        grid-column: span 2;
    }

    .timeline-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .timeline-grid {
        width: max-content;
    }
    
    .member-cell {
        position: sticky;
        left: 0;
        box-shadow: 4px 0 10px rgba(0,0,0,0.35);
    }
    
    .modal-card.wide {
        width: 95vw;
    }
    
    .flex-modal {
        flex-direction: column;
        gap: 24px;
    }
    
    .border-left {
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding-left: 0;
        padding-top: 24px;
    }
}

/* Staff mode readonly styles overrides */
body.staff-readonly .shift-bar {
    cursor: default !important;
    pointer-events: none !important;
}

body.staff-readonly .shift-delete-btn,
body.staff-readonly .shift-resizer {
    display: none !important;
}

body.staff-readonly #adminActions,
body.staff-readonly #btnManageMembers,
body.staff-readonly #btnSaveShifts {
    display: none !important;
}

/* ========================================================
   THEME TOGGLE BUTTON STYLING
   ======================================================== */
.theme-toggle-btn {
    background-color: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
    font-size: 16px;
    box-shadow: var(--shadow-inset);
}

.theme-toggle-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
    transform: scale(1.04);
}

.theme-toggle-btn:active {
    transform: scale(0.96);
}

body.dark-theme .theme-toggle-btn {
    background-color: rgba(255, 255, 255, 0.05);
}

body.dark-theme .theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Light / Dark toggle icon control */
body.light-theme .theme-toggle-btn .icon-sun {
    display: none;
}
body.light-theme .theme-toggle-btn .icon-moon {
    display: block;
    color: #475569;
}
body.dark-theme .theme-toggle-btn .icon-sun {
    display: block;
    color: #f59e0b;
}
body.dark-theme .theme-toggle-btn .icon-moon {
    display: none;
}

/* Range Selection Box (Shift + Drag UIUX Pro Max) */
.selection-box {
    position: absolute;
    border: 1.5px solid rgba(99, 102, 241, 0.6);
    background-color: rgba(99, 102, 241, 0.15);
    border-radius: 4px;
    z-index: 10000;
    pointer-events: none; /* Pass mouse events through */
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}

/* Automated Gap Break Bar (中抜け休憩) */
.gap-break-bar {
    position: absolute;
    top: 6px;
    bottom: 6px;
    border-radius: 8px;
    border: 1.2px dashed rgba(15, 23, 42, 0.2);
    background: repeating-linear-gradient(
        45deg,
        rgba(241, 245, 249, 0.95),
        rgba(241, 245, 249, 0.95) 8px,
        rgba(226, 232, 240, 0.95) 8px,
        rgba(226, 232, 240, 0.95) 16px
    );
    color: #64748b;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1; /* Render underneath shift-bars (10+) */
    pointer-events: none; /* Make click-through */
    user-select: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 2px 4px;
}

body.dark-theme .gap-break-bar {
    border: 1.2px dashed rgba(255, 255, 255, 0.12);
    background: repeating-linear-gradient(
        45deg,
        rgba(30, 41, 59, 0.35),
        rgba(30, 41, 59, 0.35) 8px,
        rgba(15, 23, 42, 0.35) 8px,
        rgba(15, 23, 42, 0.35) 16px
    );
    color: #475569;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.gap-break-title {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.3px;
    opacity: 0.8;
    line-height: 1.2;
}

.gap-break-time {
    font-size: 9px;
    font-weight: 700;
    opacity: 0.9;
    line-height: 1.2;
    margin-top: 1px;
}

/* ========================================================
   最終完全版 新UI追加スタイル (ログイン、マスタ、統計)
   ======================================================== */

/* --- ログイン画面 (Glassmorphism) --- */
.login-card {
    background: rgba(30, 41, 59, 0.75) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 20px !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}
body.light-theme .login-card {
    background: rgba(255, 255, 255, 0.75) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
}
.login-logo-icon {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.login-manager-btn {
    width: 100%;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.25s ease;
}
body.light-theme .login-manager-btn {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}
.login-manager-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}
body.light-theme .login-manager-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}
.login-manager-btn .role-badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.12);
    color: #a5b4fc;
}
body.light-theme .login-manager-btn .role-badge {
    background: rgba(99, 102, 241, 0.08);
    color: #4f46e5;
}

/* --- タブレイアウト (マスタ・統計) --- */
.flex-modal-column {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.tab-btn {
    padding: 12px 18px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
}
.tab-btn:hover {
    color: var(--text-primary);
    opacity: 1;
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    opacity: 1;
}
.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-pane.active {
    display: block;
}

/* --- マスタ・統計用の綺麗なグリッドテーブル --- */
.master-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    background: rgba(255, 255, 255, 0.01);
    border-radius: 8px;
    overflow: hidden;
}
body.light-theme .master-table {
    background: rgba(0, 0, 0, 0.005);
}
.master-table th, .master-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
body.light-theme .master-table th, body.light-theme .master-table td {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}
.master-table th {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.5px;
}
body.light-theme .master-table th {
    background: rgba(0, 0, 0, 0.04);
}
.master-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}
body.light-theme .master-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.015);
}

.table-scroll {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.1);
    overflow: hidden;
}
body.light-theme .table-scroll {
    background: rgba(0, 0, 0, 0.01);
}

/* --- ピン留めバッジ（固定アサイン用） --- */
.pin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border-radius: 4px;
    width: 16px;
    height: 16px;
    font-size: 10px;
    margin-right: 4px;
    vertical-align: middle;
}

/* --- 視点切り替えスイッチ（Glassmorphic &Tactile） --- */
.view-switcher-group {
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.active-view-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.active-view-btn.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.active-view-btn.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #fff !important;
}

body.light-theme .view-switcher-group {
    background: rgba(15, 23, 42, 0.05) !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
}

body.light-theme .active-view-btn.btn-secondary {
    color: var(--text-muted) !important;
}

body.light-theme .active-view-btn.btn-secondary:hover {
    background: rgba(15, 23, 42, 0.03) !important;
    color: var(--text-primary) !important;
}

/* --- 月間シフト表 (Monthly Grid View) スタイリング --- */
.monthly-container {
    margin-top: 16px;
    transition: background-color 0.3s ease;
}

.monthly-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
}

.monthly-table th,
.monthly-table td {
    padding: 10px 8px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    transition: all 0.2s ease;
    text-align: center;
}

/* ヘッダーセルの固定 */
.monthly-table th {
    position: sticky;
    top: 0;
    background: var(--bg-header-row);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-primary);
    z-index: 20;
    box-shadow: 0 1px 0 var(--border-color);
    min-width: 60px;
}

/* 左端（スタッフ名）列の固定 */
.monthly-table th.sticky-col,
.monthly-table td.sticky-col {
    position: sticky;
    left: 0;
    z-index: 30;
    background: var(--bg-member-cell);
    border-right: 2px solid var(--border-color);
    text-align: left;
    font-weight: 600;
    min-width: 130px;
    max-width: 130px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.04);
}

.monthly-table th.sticky-col {
    z-index: 40;
    background: var(--bg-header-row);
}

/* 曜日別の配色 */
.monthly-table th.day-sat,
.monthly-table td.day-sat-cell {
    color: #3b82f6 !important;
}

.monthly-table th.day-sun,
.monthly-table td.day-sun-cell {
    color: #ef4444 !important;
}

.monthly-table td.day-sat-cell {
    background: rgba(59, 130, 246, 0.02);
}

.monthly-table td.day-sun-cell {
    background: rgba(239, 68, 68, 0.02);
}

/* 祝日セルの配色 */
.monthly-table td.day-holiday-cell {
    background: rgba(239, 68, 68, 0.04);
    color: #ef4444 !important;
}

.monthly-table th.day-holiday {
    color: #ef4444 !important;
}

/* 本日の列のハイライト */
.monthly-table th.cell-today {
    background: rgba(245, 158, 11, 0.15) !important;
    border-bottom: 2px solid var(--warning) !important;
}

.monthly-table td.cell-today {
    background: rgba(245, 158, 11, 0.04) !important;
    box-shadow: inset 1px 0 0 rgba(245, 158, 11, 0.2), inset -1px 0 0 rgba(245, 158, 11, 0.2);
}

/* ホバーエフェクト */
.monthly-table tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

body.light-theme .monthly-table tbody tr:hover td {
    background-color: rgba(0, 0, 0, 0.01);
}

.monthly-table td.shift-cell {
    cursor: pointer;
    font-weight: 500;
}

.monthly-table td.shift-cell:hover {
    background-color: rgba(99, 102, 241, 0.1) !important;
    box-shadow: inset 0 0 0 1.5px var(--primary) !important;
}

/* シフトが入っていない公休セルのデザイン */
.monthly-table td.shift-rest {
    color: var(--text-inactive);
    font-size: 11px;
}

/* 集計行のスタイリング */
.monthly-table tr.total-row td {
    background: rgba(0, 0, 0, 0.25) !important;
    font-weight: 600;
    color: var(--text-primary);
    border-top: 2px solid var(--border-color);
    cursor: default;
}

body.light-theme .monthly-table tr.total-row td {
    background: rgba(0, 0, 0, 0.04) !important;
}

/* ツールチップで表示しきれない文字用のellipsis */
.shift-text-container {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    line-height: 1.2;
}

/* ===== 料飲部・マルチ用 月間シフト表 (FAST形式) ===== */
.monthly-table td.fb-symbol-cell {
    font-weight: 700;
    padding: 4px 2px;
}

.monthly-table .fb-symbol {
    font-size: 13px;
    font-weight: 700;
}

.monthly-table th.fb-summary-col,
.monthly-table td.fb-summary-col {
    background: rgba(99, 102, 241, 0.07);
    border-left: 2px solid var(--border-color);
    min-width: 42px;
}

body.light-theme .monthly-table th.fb-summary-col,
body.light-theme .monthly-table td.fb-summary-col {
    background: rgba(99, 102, 241, 0.05);
}

.monthly-table td.fb-rest-negative strong {
    color: #ef4444;
}

.monthly-table tr.fb-required-row td {
    padding: 2px 1px;
}

.fb-required-input {
    width: 34px;
    height: 22px;
    text-align: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    -moz-appearance: textfield;
}

.fb-required-input::-webkit-outer-spin-button,
.fb-required-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fb-required-input:focus {
    outline: none;
    border-color: var(--primary);
}

.monthly-table td.fb-judge-ok,
.fb-judge-ok {
    color: #f59e0b;
    font-weight: 700;
}

.monthly-table td.fb-judge-over,
.fb-judge-over {
    color: #3b82f6;
    font-weight: 700;
}

.monthly-table td.fb-judge-short,
.fb-judge-short {
    color: #ef4444;
    font-weight: 700;
}

/* --- 半日2マス表示 (前半/後半) --- */
.monthly-table th.fb-half-head {
    font-size: 9px;
    padding: 2px 1px;
    min-width: 22px;
    color: var(--text-muted);
    font-weight: 500;
}

.monthly-table td.fb-half {
    min-width: 22px;
    padding: 3px 1px;
    font-size: 11px;
}

/* ベタ塗りマス: 原本Excelと同じく色でパターン認識させる (文字なし) */
.monthly-table td.fb-solid-cell {
    height: 26px;
    transition: filter 0.15s ease;
}

.monthly-table td.fb-solid-cell:hover {
    filter: brightness(1.25);
    transform: none;
}

.monthly-table td.fb-half .fb-required-input,
.fb-required-input {
    width: 24px;
    height: 22px;
    padding: 0;
}

/* --- 稼働状況(組数・宿泊者数)行 --- */
.monthly-table tr.occupancy-row td {
    background: rgba(16, 185, 129, 0.08) !important;
    border-top: 1px solid rgba(16, 185, 129, 0.2);
}

body.light-theme .monthly-table tr.occupancy-row td {
    background: rgba(16, 185, 129, 0.06) !important;
}

.monthly-table tr.occupancy-row .occupancy-val {
    font-weight: 700;
    color: #10b981;
}

#btnRefreshOccupancy:disabled {
    opacity: 0.6;
    cursor: wait;
}

.fa-spin {
    animation: fa-spin 0.8s linear infinite;
}
@keyframes fa-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

