/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Heebo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.truck-icon {
    font-size: 3rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.logo-text h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 3px;
}

.logo-text span {
    font-size: 0.95rem;
    opacity: 0.9;
}

.current-time {
    text-align: left;
    font-size: 1.1rem;
}

.current-time span {
    display: block;
}

#currentTime {
    font-size: 2rem;
    font-weight: 700;
}

/* Tabs */
.tabs {
    display: flex;
    background: #f1f5f9;
    padding: 10px;
    gap: 10px;
}

.tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.tab:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Booking Form */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.booking-form h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.btn-link:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-dark);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="date"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Time Slots Grid */
.time-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.time-slot {
    padding: 12px 8px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    cursor: pointer;
    text-align: center;
    font-weight: 500;
    transition: all 0.3s ease;
}

.time-slot:hover:not(.booked):not(.selected) {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.time-slot.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.time-slot.booked {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
    cursor: not-allowed;
    opacity: 0.7;
}

.time-slot.past {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.time-slot.partial {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
    color: #92400e;
}

.time-slot.partial:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fbbf24 100%);
}

.slot-count {
    font-size: 0.7rem;
    display: block;
    opacity: 0.8;
}

.slot-full {
    font-size: 0.65rem;
    display: block;
    color: #991b1b;
}

.slot-ready {
    font-size: 0.75rem;
}

.time-slot.my-ready {
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

/* Night loading slots (23:00–05:00) */
.time-slots-night-header {
    grid-column: 1 / -1;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: #e0e7ff;
    font-weight: 700;
    font-size: 0.95rem;
    text-align: center;
    border: 2px solid #6366f1;
}

.time-slot.night-slot {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    border-color: #6366f1;
    color: #e0e7ff;
    font-size: 0.85rem;
}

.time-slot.night-slot:hover:not(.booked):not(.selected):not(.past) {
    border-color: #a5b4fc;
    background: linear-gradient(135deg, #312e81 0%, #4338ca 100%);
    color: white;
}

.time-slot.night-slot.selected {
    background: #6366f1;
    border-color: #c7d2fe;
    color: white;
}

.time-slot.night-slot.booked {
    background: #312e81;
    border-color: #818cf8;
    color: #fecaca;
    opacity: 0.85;
}

.time-slot.night-slot.past {
    background: #1e1b4b;
    color: #64748b;
    opacity: 0.6;
}

.time-slot.night-slot.partial {
    background: linear-gradient(135deg, #312e81 0%, #4c1d95 100%);
    border-color: #a78bfa;
    color: #fde68a;
}

.delivery-status-table tr.ds-night-row {
    background: rgba(99, 102, 241, 0.08);
}

.delivery-status-table tr.ds-night-row .ds-time {
    font-weight: 700;
    color: #4338ca;
}

.delivery-status-table tr.ds-night-next-day .ds-time {
    color: #5b21b6;
}

.delivery-status-table tr.ds-night-next-day {
    background: rgba(91, 33, 182, 0.06);
}

/* Night booking cards */
.booking-card.night-booking,
.all-booking-card.night-booking {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    border-color: #6366f1;
    color: white;
}

.booking-card.night-booking .booking-info p,
.all-booking-card.night-booking .driver-info p {
    color: rgba(255,255,255,0.9);
}

.booking-card.night-booking .time,
.all-booking-card.night-booking .time-header {
    color: #a5b4fc;
}

.time-subtext {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    width: 100%;
    justify-content: center;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Search Section */
.search-driver {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-driver input {
    flex: 1;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
}

/* Filter Date */
.filter-date {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
}

.filter-date input {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
}

/* Bookings List */
.bookings-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.booking-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.booking-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Driver-facing "route ready" feedback */
.driver-ready-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    margin: 8px 0 10px;
}

.driver-ready-badge.ready {
    background: #e7f7ee;
    color: #0f6a2f;
    border: 1px solid #bfe8cf;
}

.driver-ready-badge.waiting {
    background: #fff6df;
    color: #7a5a00;
    border: 1px solid #ffe2a3;
}

.driver-ready-badge.admin-cancelled-badge {
    background: #fdeaea;
    color: #8a1f1f;
    border: 1px solid #f0b4b4;
    border-radius: 8px;
    white-space: normal;
    max-width: 100%;
}

.booking-card.admin-cancelled-booking {
    opacity: 0.92;
    border: 2px dashed #c44;
}

.all-booking-card.admin-cancelled-booking {
    opacity: 0.92;
    border: 2px dashed #c44;
}

.admin-cancelled-note,
.ready-status.admin-cancelled-readonly {
    color: #8a1f1f;
    font-weight: 600;
}

.booking-info h4 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.booking-info p {
    color: var(--text-secondary);
    margin: 4px 0;
    font-size: 0.95rem;
}

.booking-time {
    background: var(--primary-color);
    color: white;
    padding: 15px 25px;
    border-radius: var(--radius-sm);
    text-align: center;
    min-width: 100px;
}

.booking-time .time {
    font-size: 1.5rem;
    font-weight: 700;
}

.booking-time .date {
    font-size: 0.85rem;
    opacity: 0.9;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
    font-size: 1.1rem;
}

/* All Bookings Grid */
.all-bookings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

/* Shift handover (admin) */
.shift-handover-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.shift-handover-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.shift-handover-form {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.shift-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.shift-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.shift-section h3 {
    font-size: 1.05rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.shift-subsection h4 {
    margin: 10px 0 6px;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.checkline {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin: 8px 0;
    background: #f8fafc;
}

.checkline input[type="checkbox"] {
    margin-top: 3px;
    transform: scale(1.1);
}

#shiftNotes {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
}

.shift-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.shift-saved {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #e7f7ee;
    border: 1px solid #bfe8cf;
    color: #0f6a2f;
    font-weight: 600;
}

@media (max-width: 700px) {
    .shift-row {
        grid-template-columns: 1fr;
    }
}

/* Delivery status table (admin) */
.delivery-status-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.delivery-status-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.delivery-status-table-wrap {
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overscroll-behavior: contain;
}

@media (max-width: 900px) {
    .delivery-status-table-wrap {
        max-height: min(72vh, 560px);
        -webkit-overflow-scrolling: touch;
    }
}

.delivery-status-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
    background: var(--card-bg);
}

.delivery-status-table th,
.delivery-status-table td {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 8px;
    text-align: right;
    vertical-align: middle;
    font-size: 0.95rem;
}

.delivery-status-table th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 2;
    font-weight: 700;
}

.delivery-status-table input[type="text"],
.delivery-status-table select {
    width: 100%;
    padding: 10px 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
}

.delivery-status-table input[type="checkbox"] {
    transform: scale(1.15);
}

.ds-reorder-th {
    width: 72px;
    min-width: 72px;
}

.ds-drag-cell {
    width: 72px;
    min-width: 72px;
    text-align: center;
    vertical-align: middle;
    padding: 6px 4px !important;
}

.ds-reorder-btns {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 6px;
}

.btn-ds-move {
    min-height: 40px;
    min-width: 44px;
    padding: 6px 4px;
    border-radius: 10px;
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    color: #312e81;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-ds-move:active {
    background: #e0e7ff;
}

.ds-drag-handle {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 8px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
    font-weight: 800;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

@media (min-width: 901px) {
    .ds-reorder-btns {
        flex-direction: row;
        justify-content: center;
        margin-bottom: 4px;
    }
    .btn-ds-move {
        min-width: 38px;
        min-height: 36px;
        padding: 4px 2px;
    }
}

tr.ds-dragging {
    opacity: 0.6;
}

/* Highlight manual priority changes */
.ds-manual-order {
    background: #fff7cc !important;
}

.btn-row-remove {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
    font-family: inherit;
}

.btn-row-remove:hover {
    background: #fecaca;
}

/* Admin: mark ready by delivery number */
.admin-ready-tools {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin: 14px 0 18px;
}

.admin-ready-title {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.admin-ready-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
}

#readyDeliveryNumber {
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
}

.admin-ready-hint {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.all-booking-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 15px;
    transition: all 0.3s ease;
}

.all-booking-card:hover {
    box-shadow: var(--shadow);
}

.all-booking-card .time-header {
    background: var(--primary-color);
    color: white;
    padding: 10px 15px;
    margin: -15px -15px 15px -15px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.all-booking-card .driver-info {
    font-size: 0.95rem;
}

.all-booking-card .driver-info p {
    margin: 5px 0;
    color: var(--text-secondary);
}

.all-booking-card .driver-info strong {
    color: var(--text-primary);
}

.all-booking-card .btn-cancel-admin {
    margin-top: 10px;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
}

.stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Admin Button */
.admin-stat {
    display: flex !important;
    align-items: center;
}

.admin-btn {
    background: rgba(255,255,255,0.3);
    border: 2px solid rgba(255,255,255,0.5);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.admin-btn:hover {
    background: rgba(255,255,255,0.3);
}

.admin-btn.admin-active {
    background: #22c55e;
    border-color: #16a34a;
}

.past-label {
    color: #94a3b8;
    font-size: 0.85rem;
    padding: 8px 16px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 16px 32px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    max-width: 400px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.booking-summary {
    background: #f8fafc;
    padding: 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.booking-summary p {
    margin: 8px 0;
    color: var(--text-secondary);
}

.booking-summary strong {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions button {
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .current-time {
        text-align: center;
    }

    .tabs {
        flex-direction: column;
    }

    .time-slots {
        grid-template-columns: repeat(4, 1fr);
    }

    .booking-card {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .status-bar {
        flex-direction: column;
        gap: 15px;
    }
    
    .admin-btn {
        width: 100%;
        padding: 12px;
    }

    .search-driver {
        flex-direction: column;
    }
}

/* =============================================
   Palette View - Weekly Schedule Grid
   ============================================= */

.palette-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: var(--radius-sm);
}

.palette-controls .btn-secondary {
    padding: 10px 20px;
    font-size: 0.9rem;
}

.week-label {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 200px;
    text-align: center;
}

.palette-legend {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 20px;
    padding: 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

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

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

.legend-color.available {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.legend-color.booked {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.legend-color.past {
    background: #cbd5e1;
}

.legend-color.current {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    animation: pulse 2s infinite;
}

.legend-color.night {
    background: linear-gradient(135deg, #1e1b4b 0%, #6366f1 100%);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

.palette-container {
    overflow-x: auto;
    padding-bottom: 10px;
}

.palette-grid {
    display: grid;
    grid-template-columns: 70px repeat(7, minmax(100px, 1fr));
    gap: 2px;
    min-width: 800px;
    background: var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.palette-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.palette-header.time-col {
    background: linear-gradient(135deg, #475569 0%, #64748b 100%);
}

.palette-header.today {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 0 0 2px #fbbf24;
}

.palette-header .day-name {
    font-size: 0.95rem;
    margin-bottom: 3px;
}

.palette-header .day-date {
    font-size: 0.75rem;
    opacity: 0.9;
}

.palette-time-label {
    background: #f1f5f9;
    padding: 6px 8px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.palette-night-section-header {
    grid-column: 1 / -1;
    padding: 10px 12px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: #e0e7ff;
    border-top: 2px solid #6366f1;
}

.palette-time-label-night {
    background: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
    color: #c7d2fe;
    font-size: 0.75rem;
}

.palette-cell-night.available {
    background: linear-gradient(135deg, #312e81 0%, #4338ca 100%);
    color: #e0e7ff;
}

.palette-cell-night.available:hover {
    background: linear-gradient(135deg, #4338ca 0%, #6366f1 100%);
    color: white;
}

.palette-cell-night.booked-night {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: #e0e7ff;
    border: 1px solid #818cf8;
}

.palette-cell-night.booked-night:hover {
    background: linear-gradient(135deg, #312e81 0%, #4338ca 100%);
    color: white;
}

.palette-cell-night.past {
    background: #1e293b;
    color: #64748b;
}

.palette-cell-night.current {
    background: linear-gradient(135deg, #4c1d95 0%, #6366f1 100%);
    color: white;
}

.palette-cell {
    background: white;
    padding: 4px;
    min-height: 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.palette-cell:hover {
    transform: scale(1.05);
    z-index: 5;
    box-shadow: var(--shadow);
}

.palette-cell.available {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
}

.palette-cell.available:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.palette-cell.booked {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    cursor: default;
}

.palette-cell.booked.ready {
    background: linear-gradient(135deg, #dcfce7 0%, #86efac 100%);
    border: 1px solid #22c55e;
}

.palette-cell.booked:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.palette-cell.booked.ready:hover {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.palette-cell.past {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.palette-cell.past:hover {
    transform: none;
    box-shadow: none;
}

.palette-cell.current {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    animation: currentPulse 2s infinite;
}

@keyframes currentPulse {
    0%, 100% { box-shadow: inset 0 0 0 2px #f59e0b; }
    50% { box-shadow: inset 0 0 0 3px #d97706; }
}

.palette-cell .cell-content {
    font-size: 0.7rem;
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.palette-cell.booked .cell-content {
    font-weight: 500;
}

.palette-info {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: var(--radius-sm);
    border-right: 4px solid var(--primary-color);
}

.palette-info p {
    color: var(--text-secondary);
    margin: 0;
}

.palette-info.has-selection {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-right-color: var(--success-color);
}

.palette-info h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.palette-info .info-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.palette-info .info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.palette-info .info-item strong {
    color: var(--text-primary);
}

/* Responsive for Palette */
@media (max-width: 768px) {
    .palette-grid {
        min-width: 600px;
        grid-template-columns: 50px repeat(7, minmax(70px, 1fr));
    }

    .palette-header {
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    .palette-header .day-date {
        display: none;
    }

    .palette-controls {
        flex-direction: column;
        gap: 10px;
    }

    .palette-legend {
        gap: 15px;
    }
}

/* =============================================
   Report View Styles
   ============================================= */

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.report-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin: 0;
}

.report-actions {
    display: flex;
    gap: 10px;
}

.report-filters {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-radius: var(--radius-sm);
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.filter-group input {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
}

.filter-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-filter {
    padding: 12px 24px !important;
    margin-top: 0;
}

/* Report Summary Cards */
.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 25px 20px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.summary-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.summary-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.summary-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Report Sections */
.report-section {
    margin-bottom: 30px;
}

.report-section h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

/* Report Tables */
.report-table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.95rem;
}

.report-table thead {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
}

.report-table th {
    padding: 15px 12px;
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

.report-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.report-table tbody tr:hover {
    background: #f8fafc;
}

.report-table tbody tr:last-child td {
    border-bottom: none;
}

.empty-row {
    text-align: center !important;
    color: var(--text-secondary);
    padding: 40px !important;
    font-size: 1.1rem;
}

/* Time Badge */
.time-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
}

.time-badge.night-badge {
    background: linear-gradient(135deg, #312e81, #4338ca);
}

.night-badge-small {
    background: linear-gradient(135deg, #312e81, #4338ca);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-right: 5px;
}

.night-row {
    background: rgba(99, 102, 241, 0.1);
}

/* Occupancy Bar */
.occupancy-bar {
    position: relative;
    width: 120px;
    height: 24px;
    background: #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.occupancy-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.5s ease;
}

.occupancy-fill.low {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.occupancy-fill.medium {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.occupancy-fill.high {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.occupancy-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: #1e293b;
}

/* Responsive for Report */
@media (max-width: 768px) {
    .report-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .report-actions {
        justify-content: center;
    }
    
    .report-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group input {
        width: 100%;
    }
    
    .btn-filter {
        width: 100%;
    }
    
    .summary-card {
        padding: 20px 15px;
    }
    
    .summary-value {
        font-size: 2rem;
    }
    
    .report-table {
        font-size: 0.85rem;
    }
    
    .report-table th,
    .report-table td {
        padding: 10px 8px;
    }
}

/* Print Styles */
/* =============================================
   Arrival Time Styles - שעת הגעה
   ============================================= */

.arrival-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #ddd;
}

.arrival-recorded {
    color: #27ae60;
    font-size: 0.9rem;
    margin: 0;
}

.btn-arrival {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-record-arrival {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-record-arrival:hover {
    background: linear-gradient(135deg, #2980b9, #1f5f89);
    transform: scale(1.02);
}

.btn-update-arrival {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.btn-update-arrival:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

.btn-edit-arrival {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 6px;
    margin-right: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-edit-arrival:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Cancellation limit info */
.cancellation-info {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 500;
    text-align: center;
}

.cancellation-info.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.cancellation-info.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Disabled cancel button */
.btn-danger:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Ready status indicator (admin only) */
.ready-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-right: 10px;
    transition: all 0.2s;
}

.ready-status.readonly {
    cursor: default;
}

.ready-status.readonly:hover {
    transform: none;
}

.ready-status:hover {
    transform: scale(1.05);
}

.ready-status.is-ready {
    background: #d4edda;
    color: #155724;
    border: 1px solid #28a745;
}

.ready-status.not-ready {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.time-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Delivery numbers input */
.delivery-numbers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.delivery-number-input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
}

.delivery-number-input:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

@media (max-width: 480px) {
    .delivery-numbers {
        grid-template-columns: 1fr;
    }
}

/* Admin can click on full slots */
.time-slot.booked.admin-clickable {
    cursor: pointer;
    opacity: 0.8;
    border: 2px dashed #f59e0b;
}

.time-slot.booked.admin-clickable:hover {
    opacity: 1;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

/* Required field indicator */
.required {
    color: #dc3545;
    font-weight: bold;
}

/* Checkbox group styling */
.checkbox-group {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    gap: 10px;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #28a745;
}

.checkbox-text {
    color: #856404;
}

/* Arrival time in report table */
.arrival-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.arrival-badge.arrived {
    background-color: #d4edda;
    color: #155724;
}

.arrival-badge.not-arrived {
    background-color: #f8f9fa;
    color: #6c757d;
}

/* Arrival time in all bookings view */
.arrival-time {
    font-size: 0.85rem;
    margin-top: 5px;
}

.arrival-time.arrived {
    color: #27ae60;
}

.arrival-time.not-arrived {
    color: #95a5a6;
}

/* Booking actions container */
.booking-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

@media print {
    body {
        background: white;
        padding: 0;
    }

    .tabs, .btn-primary, .btn-secondary, .btn-danger, .search-driver, .palette-controls, .report-actions, .report-filters, .status-bar {
        display: none !important;
    }

    .container {
        box-shadow: none;
        max-width: 100%;
    }

    .palette-grid {
        min-width: auto;
    }
    
    .tab-content {
        display: none !important;
    }
    
    .tab-content#report {
        display: block !important;
    }
    
    .report-summary {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .summary-card {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    .report-table-container {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .report-section {
        page-break-inside: avoid;
    }
    
    .header {
        background: #1e3a8a !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}


/* =============================================
   שיפורים (גרסת בטא) — מתווסף בסוף, לא משנה את העיצוב הקיים במחשב
   ============================================= */
.time-slots-group-header {
    grid-column: 1 / -1;
    font-weight: 700;
    color: #1e3a8a;
    background: #eff6ff;
    border-radius: 10px;
    padding: 8px 12px;
    margin-top: 6px;
}
.time-slots-group-header:first-child { margin-top: 0; }
.time-slots-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #64748b;
    padding: 24px 12px;
    background: #f8fafc;
    border-radius: 10px;
}
.btn-whatsapp {
    display: inline-block;
    background: #25d366;
    color: #fff !important;
    text-decoration: none;
    font-weight: 700;
    border-radius: 20px;
    padding: 6px 14px;
    margin-top: 4px;
}
.btn-whatsapp:hover { background: #1ebe5a; }
.beta-banner {
    max-width: 1200px;
    margin: 0 auto 12px;
    background: #ede9fe;
    color: #4c1d95;
    border-radius: 12px;
    padding: 10px 16px;
    text-align: center;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

@media (max-width: 768px) {
    /* כותרת קומפקטית: לוגו ושעון בשורה אחת */
    .header {
        flex-direction: row;
        text-align: right;
        gap: 10px;
        padding: 14px 16px;
    }
    .current-time { text-align: left; }
    /* לשוניות: פס אופקי נגלל במקום רשימה שתופסת מסך שלם */
    .tabs {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        padding: 8px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 0.92rem;
    }
    /* כפתור "שריין תור" צף בתחתית המסך (מופיע רק בלשונית שיבוץ תור) */
    #bookSlot {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        z-index: 50;
        box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
    }
    #schedule { padding-bottom: 90px; }
}
@media (max-width: 480px) {
    .header .logo-text h1 { font-size: 1.15rem; }
    .header .logo-text span { font-size: 0.72rem; }
    #currentTime { font-size: 1.35rem; }
    #currentDate { font-size: 0.7rem; }
}
