:root {
--primary: #2196F3;
--primary-dark: #1976D2;
--table-bg-day: #f9ef92;
--table-bg-night: #e0e0e0;
--card-border-day: #fdd835;
--card-border-night: #455a64;
--text: #333;
--border: #ddd;
--header-bg: #FFF44F;
--filter-height: 36px;
--filter-width-base: 180px;
--sticky-offset: 165px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
margin: 0;
background: #f5f5f5;
color: var(--text);
padding-bottom: 70px;
}

/* ===== ТЕХНИЧЕСКИЕ РАБОТЫ - БАННЕР ===== */
.maintenance-banner {
    display: none;
    background: #fff3e0;
    border: 2px solid #ff9800;
    border-radius: 12px;
    padding: 15px 25px;
    margin: 0 auto 15px auto;
    max-width: 500px;
    text-align: center;
}
.maintenance-banner.active {
    display: block;
}
.maintenance-banner .icon {
    font-size: 32px;
    display: block;
    margin-bottom: 6px;
}
.maintenance-banner h2 {
    color: #e65100;
    margin: 0 0 5px 0;
    font-size: 18px;
}
.maintenance-banner p {
    color: #bf360c;
    margin: 0;
    font-size: 14px;
}

.login-overlay {
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
background: #ffffff !important;
display: flex; align-items: center; justify-content: center;
z-index: 999999;
}
.login-overlay.hidden { display: none; }
.login-box {
background: white; padding: 30px; border-radius: 12px;
box-shadow: 0 10px 40px rgba(0,0,0,0.15);
width: 100%; max-width: 380px; border: 1px solid #eee;
}
.login-title { text-align: center; font-size: 24px; font-weight: bold; color: #333; margin-bottom: 8px; }
.login-subtitle { text-align: center; color: #666; font-size: 14px; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-input {
padding: 12px 14px; border: 1px solid #ddd; border-radius: 8px;
font-size: 15px; outline: none; transition: border-color 0.2s;
}
.login-input:focus { border-color: var(--primary); }
.login-btn {
padding: 12px; background: var(--primary); color: white; border: none;
border-radius: 8px; font-size: 16px; font-weight: 600; cursor: pointer;
}
.login-btn:hover { background: #1976D2; }
.login-btn:disabled { background: #ccc; cursor: not-allowed; }
.login-error { color: #d32f2f; font-size: 13px; text-align: center; min-height: 18px; }

/* ===== СТИЛИ ШАПКИ ===== */
.header {
    background: white;
    padding: 6px 14px;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 10000;
    width: 100%;
    flex-shrink: 0;
    min-height: 44px;
}

.header-left-block {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.header-buttons {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-shrink: 0;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    user-select: none;
    color: #333;
    flex-shrink: 0;
    padding: 0 12px;
    font-weight: 500;
}

.icon-btn:hover { background: #f0f0f0; }
.icon-btn:active { transform: scale(0.97); }

.icon-btn.refresh {
    font-size: 18px;
    padding: 0 8px;
    transition: all 0.3s ease;
    position: relative;
}

.icon-btn.refresh svg {
    transition: stroke 0.3s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn.refresh:hover svg {
    stroke: #2196F3;
    transform: rotate(180deg);
}

.icon-btn.refresh:active svg {
    transform: rotate(360deg);
}

.icon-btn.fuel { color: #333; }
.icon-btn.fuel:hover { background: #f0f0f0; }

.icon-btn.accounting { color: #333; }
.icon-btn.accounting:hover { background: #f0f0f0; }

.user-info-block {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.user-display {
    font-size: 12px;
    color: #555;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #f5f5f5;
    transition: all 0.15s;
    height: 32px;
    display: flex;
    align-items: center;
}

.user-display:hover { background: #e8e8e8; border-color: #bbb; }
.user-display:active { transform: scale(0.97); }

/* ===== МЕНЮ ПОЛЬЗОВАТЕЛЯ (как в tabel_view) ===== */
.user-menu {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    min-width: 140px;
    padding: 4px 0;
    z-index: 999999;
}
.user-menu .menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.user-menu .menu-item:hover {
    background: #f0f0f0;
}
.user-menu .menu-item.logout {
    color: #d32f2f;
}
.user-menu .menu-item.logout:hover {
    background: #ffebee;
}
.user-menu .menu-divider {
    height: 1px;
    background: #eee;
    margin: 4px 8px;
}

/* ===== ФИЛЬТРЫ ===== */
.controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
    overflow-x: auto;
    padding-bottom: 2px;
    padding-left: 4px;
}

.filter-container {
    position: relative;
    width: var(--filter-width-base);
    min-width: var(--filter-width-base);
    height: var(--filter-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    z-index: 10;
    transition: all 0.3s ease;
}
.filter-container.hidden-filter { display: none !important; }
.filter-container.active-filter { z-index: 1000000 !important; }
.filter-input-wrapper { position: relative; width: 100%; height: 100%; z-index: 1; }
.filter-input {
width: 100%; height: 100%; padding: 0 30px 0 10px;
border: 1px solid #ccc; border-radius: 6px; background: #fff;
font-size: 13px; color: #333; outline: none; cursor: pointer;
appearance: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.15); }
.filter-arrow { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 10px; color: #888; pointer-events: none; }
.clear-btn, .date-clear-btn {
position: absolute; right: 28px; top: 50%; transform: translateY(-50%);
width: 20px; height: 20px; border-radius: 50%; text-align: center;
line-height: 18px; font-size: 18px; font-weight: 300; color: #999;
cursor: pointer; display: none; z-index: 1000002 !important; background: transparent; border: none; padding: 0;
}
.clear-btn.visible, .date-clear-btn.visible { display: block; }
.clear-btn:hover, .date-clear-btn:hover { color: #d00; }

.custom-select { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; }
.custom-options {
position: fixed; border: 1px solid #ccc; border-top: 0; background: white;
opacity: 0; visibility: hidden; transform: translateY(-10px); pointer-events: none;
z-index: 1000001 !important; box-shadow: 0 8px 16px rgba(0,0,0,0.2);
border-radius: 0 0 6px 6px; max-height: 300px; overflow-y: auto; min-width: 220px;
left: 0; top: 0; display: flex; flex-direction: column; transition: all 0.2s;
}
.custom-select.open .custom-options { opacity: 1; visibility: visible; pointer-events: all; transform: translateY(0); }
.group-header {
padding: 8px 12px; font-weight: bold; font-size: 13px; background: #f9f9f9; cursor: pointer;
display: flex; justify-content: space-between; align-items: center;
border-bottom: 1px solid #eee; user-select: none;
}
.group-header:hover { background: #f0f0f0; }
.group-header::after { content: '+'; font-weight: bold; color: #888; font-size: 18px; margin-left: 8px; }
.group-header.expanded::after { content: '−'; }
.month-check-wrapper, .year-check-wrapper { display: flex; align-items: center; gap: 8px; flex: 1; pointer-events: none; }
.month-check-wrapper input, .year-check-wrapper input { pointer-events: auto; transform: scale(1.2); margin: 0; }
.options-list { display: none; padding: 0; margin: 0; list-style: none; background: white; width: 100%; }
.options-list.show { display: block !important; }
.option-item {
padding: 6px 12px 6px 25px; cursor: pointer; font-size: 13px;
display: flex; align-items: center; border-bottom: 1px solid #f5f5f5;
}
.option-item:hover { background-color: #e6f0ff; }
.option-item input[type="checkbox"], .option-item input[type="radio"] { margin-right: 10px; transform: scale(1.2); }
.select-actions {
padding: 8px; border-top: 1px solid #ddd; display: flex; gap: 5px; background: #fff;
position: sticky; bottom: 0; z-index: 10;
}
.action-btn { flex: 1; padding: 6px; font-size: 12px; border: 1px solid #ccc; background: #f0f0f0; border-radius: 4px; cursor: pointer; }
.action-btn:active { background: #e0e0e0; }
.action-btn.clear { background: #ffe6e6; color: #d00; border-color: #fcc; }

.desktop-view {
    display: block;
    padding: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrapper {
    display: flex;
    flex-direction: column;
    max-height: 600px;
    overflow: auto;
    border-radius: 8px;
    border: 1px solid #ddd;
    position: relative;
}

.table-wrapper thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

.table-wrapper thead th {
    background: var(--header-bg);
    color: #333;
    padding: 10px 8px;
    border: 1px solid #ddd;
    text-align: center;
    font-weight: 700;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 20;
}

.table-wrapper tbody {
    overflow-y: auto;
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 800px;
    font-size: 13px;
}

.table-wrapper tbody td {
    padding: 8px;
    border: 1px solid #eee;
    text-align: center;
}

.row-day { background-color: var(--table-bg-day); }
.row-night { background-color: var(--table-bg-night); }
.mobile-view { display: none; padding: 12px; }

.date-group { margin-bottom: 20px; padding-top: 50px; margin-top: -30px; }
.date-header {
font-size: 16px; font-weight: bold; color: #444; margin: 0 0 10px 0; padding: 8px 12px;
border-left: 4px solid var(--primary); background: white; border-radius: 0 4px 4px 0;
box-shadow: 0 4px 6px rgba(0,0,0,0.1); position: sticky; top: var(--sticky-offset);
z-index: 900; width: 100%; box-sizing: border-box;
}
.shift-label {
font-size: 13px; text-transform: uppercase; font-weight: 800;
margin: 12px 0 6px; padding-left: 8px; display: flex; align-items: center; gap: 6px;
}
.shift-label.day { color: #f57f17; }
.shift-label.night { color: #37474f; }
.card {
background: white; border-radius: 8px; padding: 12px; margin-bottom: 10px;
box-shadow: 0 2px 4px rgba(0,0,0,0.06); border-left: 8px solid #ccc;
}
.card.day { border-left-color: var(--card-border-day) !important; }
.card.night { border-left-color: var(--card-border-night) !important; }
.c-row {
display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px;
border-bottom: 1px dashed rgba(0,0,0,0.1); padding-bottom: 4px;
}
.c-row:last-child { border-bottom: none; margin-bottom: 0; }
.c-label { color: #555; font-size: 12px; font-weight: 500; }
.c-val { font-weight: 600; text-align: right; max-width: 65%; word-break: break-word; }
.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: bold; }
.badge-work { background: #e8f5e9; color: #2e7d32; }
.badge-no { background: #ffebee; color: #c62828; }
.totals-footer {
position: fixed; bottom: 0; left: 0; right: 0; background: white; border-top: 1px solid #ccc;
padding: 10px; display: none; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
text-align: center; box-shadow: 0 -2px 10px rgba(0,0,0,0.1); z-index: 90;
}
.t-item { display: flex; flex-direction: column; }
.t-val { font-weight: bold; color: var(--primary); font-size: 16px; }
.t-lbl { font-size: 11px; color: #666; }

/* ================================================================ */
/* === ДЕСКТОПНАЯ ВЕРСИЯ (ширина > 768px) === */
/* ================================================================ */
@media (min-width: 769px) {
    .header {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        padding: 6px 16px;
        min-height: 44px;
        align-items: center;
        gap: 10px;
        justify-content: space-between;
    }

    .header-left-block {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 0 0 auto;
        flex-wrap: nowrap;
    }

    .header-buttons {
        display: flex;
        gap: 6px;
        align-items: center;
        flex-shrink: 0;
    }

    .controls {
        display: flex;
        gap: 8px;
        align-items: center;
        flex: 1 1 auto;
        overflow-x: auto;
        padding: 0 4px;
        min-width: 0;
        justify-content: flex-start;
    }

    body.employee-mode .controls .filter-container:not(#container-date) {
        display: none !important;
    }

    body.employee-mode .controls #container-date {
        width: var(--filter-width-base);
        min-width: var(--filter-width-base);
        max-width: var(--filter-width-base);
        flex: 0 0 auto;
    }

    .filter-container {
        width: var(--filter-width-base);
        min-width: var(--filter-width-base);
        height: var(--filter-height);
        flex-shrink: 0;
    }

    .user-info-block.desktop-only {
        display: flex !important;
        align-items: center;
        gap: 6px;
        flex: 0 0 auto;
        margin-left: auto;
        max-width: 350px;
    }
    
    .user-info-block.mobile-only {
        display: none !important;
    }

    .user-display {
        font-size: 13px;
        height: auto;
        min-height: 32px;
        padding: 4px 14px;
        max-width: 100%;
        white-space: normal;
        word-break: break-word;
        line-height: 1.3;
        text-align: right;
        overflow: visible;
        text-overflow: clip;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .icon-btn {
        height: 32px;
        padding: 0 12px;
        font-size: 13px;
    }

    .icon-btn.refresh {
        font-size: 18px;
        padding: 0 8px;
    }
}

@media (max-width: 768px) {
    body { padding-bottom: 140px; }
    
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 8px 10px;
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
        min-height: 38px;
        background: #ffffff;
        border-bottom: 2px solid #2196F3;
        border-radius: 0 0 12px 12px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.08);
        margin-bottom: 2px;
    }
    
    .header-left-block {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 4px;
        flex-wrap: nowrap;
        order: 0;
        border-bottom: none;
        padding-bottom: 0;
    }
    
    .header-buttons {
        display: flex;
        gap: 3px;
        align-items: center;
        flex-shrink: 0;
        flex-wrap: nowrap;
    }
    
    .user-info-block.mobile-only {
        display: flex !important;
        align-items: center;
        gap: 4px;
        flex: 0 0 auto;
        margin-left: auto;
        order: 1;
        max-width: 80%;
    }
    
    .user-info-block.desktop-only {
        display: none !important;
    }
    
    .icon-btn {
        height: 28px;
        padding: 0 8px;
        font-size: 11px;
    }
    .icon-btn.refresh {
        font-size: 15px;
        padding: 0 6px;
    }
    .icon-btn.fuel { font-size: 13px; padding: 0 8px; }
    .icon-btn.accounting { font-size: 13px; padding: 0 8px; }
    
    .user-display {
        font-size: 12px;
        height: auto;
        min-height: 32px;
        padding: 4px 12px;
        width: auto;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.4;
        text-align: right;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        border: 2px solid #2196F3;
        border-radius: 8px;
        background: #ffffff;
        cursor: pointer;
        font-weight: 600;
        color: #333;
        flex-shrink: 1;
        min-width: 0;
        box-sizing: border-box;
        box-shadow: 0 2px 8px rgba(33, 150, 243, 0.15);
        -webkit-tap-highlight-color: rgba(33, 150, 243, 0.2);
        transition: all 0.2s ease;
    }
    
    .user-display:active {
        transform: scale(0.97);
        background: #e3f2fd;
        border-color: #1976D2;
        box-shadow: 0 2px 12px rgba(33, 150, 243, 0.3);
    }
    
    .controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        padding: 6px 4px 2px 4px;
        order: 1;
        width: 100%;
        border-top: 1px solid #e0e0e0;
        margin-top: 2px;
    }
    
    .filter-container {
        width: calc(50% - 4px);
        min-width: calc(50% - 4px);
        flex-grow: 1;
        height: 32px;
    }
    
    .desktop-view { display: none; }
    .mobile-view { display: block; padding-bottom: 20px; }
    
    .totals-footer {
        position: fixed; bottom: 0; left: 0; right: 0; background: white; border-top: 1px solid #ccc;
        padding: 10px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
        text-align: center; box-shadow: 0 -4px 15px rgba(0,0,0,0.15); z-index: 9999; 
    }
    .date-header { top: var(--sticky-offset); z-index: 800; }
    .date-group { padding-top: 60px; margin-top: -40px; }
    
    /* Мобильные стили для меню профиля — такие же как в tabel_view */
    .user-menu {
        position: fixed !important;
        top: auto !important;
        bottom: auto !important;
        right: auto !important;
        left: auto !important;
        width: auto !important;
        min-width: 180px;
        border-radius: 12px;
        max-width: 280px;
        margin: 0;
        box-shadow: 0 4px 20px rgba(0,0,0,0.25);
        z-index: 999999;
        background: white;
        border: 1px solid #ddd;
        padding: 4px 0;
    }
    .user-menu .menu-item {
        padding: 12px 16px;
        font-size: 15px;
        display: block;
        width: 100%;
        text-align: left;
        border: none;
        background: none;
        cursor: pointer;
        color: #333;
        font-family: inherit;
    }
    .user-menu .menu-item:hover {
        background: #f0f0f0;
    }
    .user-menu .menu-item.logout {
        color: #d32f2f;
    }
    .user-menu .menu-item.logout:hover {
        background: #ffebee;
    }
    .user-menu .menu-divider {
        height: 1px;
        background: #eee;
        margin: 4px 8px;
    }
}

@media (max-width: 400px) {
    .filter-container { width: 100%; min-width: 100%; }
    .header-buttons .icon-btn { font-size: 10px; padding: 0 6px; height: 26px; }
    
    .user-info-block.mobile-only { 
        max-width: 70%;
    }
    .user-display { 
        font-size: 11px;
        padding: 3px 10px; 
        min-height: 28px;
        border-width: 1.5px;
    }
    
    .header {
        padding: 6px 8px;
        border-bottom-width: 1.5px;
    }
}

/* Баннер на странице входа */
.login-banner {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 2px solid #ddd;
    transition: all 0.3s;
    background: #f5f5f5;
    display: none;
}

.login-banner.info {
    background: #e3f2fd;
    border-color: #2196F3;
}
.login-banner.info #login-banner-title { color: #0d47a1; }
.login-banner.info #login-banner-text { color: #0d47a1; }

.login-banner.warning {
    background: #fff3e0;
    border-color: #FF9800;
}
.login-banner.warning #login-banner-title { color: #e65100; }
.login-banner.warning #login-banner-text { color: #e65100; }

.login-banner.danger {
    background: #ffebee;
    border-color: #f44336;
}
.login-banner.danger #login-banner-title { color: #b71c1c; }
.login-banner.danger #login-banner-text { color: #b71c1c; }

.login-banner.success {
    background: #e8f5e9;
    border-color: #4CAF50;
}
.login-banner.success #login-banner-title { color: #1b5e20; }
.login-banner.success #login-banner-text { color: #1b5e20; }