* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    margin: 0;
    background: #f5f5f5;
    color: #222;
    font-size: 14px;
}

.header {
    background: #1a73e8;
    color: white;
    padding: 12px 20px;
}
.header-inner {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 30px;
}
.logo {
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 18px;
}
.nav a {
    color: white;
    text-decoration: none;
    margin-right: 16px;
    padding: 4px 8px;
}
.nav a:hover {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.main {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 20px 0 12px; }

.card {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 16px;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
}
.btn:hover { background: #1557b0; }
.btn-secondary { background: #666; }
.btn-secondary:hover { background: #444; }
.btn-danger { background: #c00; }
.btn-danger:hover { background: #900; }

table.data {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
table.data th, table.data td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
table.data th {
    background: #fafafa;
    font-weight: 600;
    font-size: 12px;
    color: #555;
    text-transform: uppercase;
}
table.data tr:hover { background: #f9fbff; }
table.data a { color: #1a73e8; text-decoration: none; }
table.data a:hover { text-decoration: underline; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-danger { background: #fce4e4; color: #c00; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-success { background: #d4edda; color: #155724; }

.filters {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.filters input, .filters select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
}

/* Форма — две колонки */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}
@media (max-width: 800px) {
    .grid-2col { grid-template-columns: 1fr; }
}

.field {
    margin-bottom: 12px;
    position: relative;
}
.field label {
    display: block;
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
    font-weight: 600;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
.field .has-error, .field input.has-error {
    border-color: #c00;
}
.field .error {
    color: #c00;
    font-size: 12px;
    margin-top: 4px;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.suggestion-item {
    display: block;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    color: #222;
    text-decoration: none;
    font-size: 13px;
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: #f0f7ff; }

.view-row {
    display: flex;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}
.view-row:last-child { border-bottom: none; }
.view-label {
    color: #888;
    font-size: 12px;
    width: 170px;
    flex-shrink: 0;
    padding-top: 1px;
}

/* Модалка */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}
.modal-content {
    background: white;
    border-radius: 8px;
    padding: 20px 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-content h2 {
    margin: 0 0 16px;
    font-size: 18px;
}

.card-blacklisted {
    background: #fff5f5;
    border-left: 4px solid #c00;
}

/* ===== Таблица смен ===== */
.shifts-wrap {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* Форма-конвейер ввода */
.shift-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 16px;
    background: #f0f7ff;
    border-bottom: 2px solid #d0e2ff;
    flex-wrap: wrap;
}
.shift-form .ff {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.shift-form label {
    font-size: 11px;
    color: #555;
    font-weight: 600;
}
.shift-form input, .shift-form select {
    padding: 7px 9px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    height: 34px;
    box-sizing: border-box;
}
.shift-form .ff-worker { position: relative; }
.shift-form .ff-worker input { width: 200px; }
#worker-suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    z-index: 30;
    max-height: 280px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
}
#worker-suggest a {
    display: block;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    color: #222;
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
}
#worker-suggest a:hover { background: #f0f7ff; }

.shift-form-msg {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
}
.shift-form-msg.ok { color: #155724; background: #d4edda; }
.shift-form-msg.err { color: #c00; background: #fce4e4; }

/* Сама таблица */
.shifts-scroll {
    overflow-x: auto;
    max-height: calc(100vh - 260px);
    overflow-y: auto;
}
table.shifts {
    border-collapse: collapse;
    table-layout: fixed;
    width: max-content;
    font-size: 11px;
}
table.shifts th, table.shifts td {
    border: 1px solid #e5e5e5;
    padding: 0;
    height: 36px;
    box-sizing: border-box;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
table.shifts thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fafafa;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    padding: 0 8px;
    text-align: left;
}
table.shifts td { padding: 0 8px; }
table.shifts tbody tr:hover { background: #f9fbff; }
table.shifts tbody tr.row-new { background: #fff0f5; }
table.shifts tbody tr.row-new:hover { background: #ffe6ef; }

/* Строка над красным лимитом */
.net-over { color: #c00; font-weight: 600; }

/* Ячейка получателя */
.payee-cell { position: relative; overflow: visible !important; }
.payee-view { cursor: pointer; padding: 0 6px; line-height: 34px; min-height: 34px; }
.payee-view:hover { background: #f0f7ff; }
.payee-suggest {
    position: absolute; top: 100%; left: 0; min-width: 220px;
    background: white; border: 1px solid #ccc; border-radius: 4px;
    z-index: 40; max-height: 260px; overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: none;
}
.payee-suggest a {
    display: block; padding: 8px 10px; border-bottom: 1px solid #eee;
    color: #222; text-decoration: none; font-size: 13px; cursor: pointer;
}
.payee-suggest a:hover { background: #f0f7ff; }

/* Нет реквизита у получателя */
table.shifts td.no-req { background: #fce4e4 !important; }
table.shifts td.no-req, table.shifts td.no-req .payee-view { color: #c00; font-weight: 600; }

/* Бейдж вахты в таблице смен */
.badge-vahta {
    display: inline-block;
    background: #1a73e8;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 5px;
    vertical-align: middle;
}

/* Панель фильтров смен */
.shift-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    background: #f7f7f7;
    border-bottom: 1px solid #e0e0e0;
    align-items: center;
}
.shift-filters input, .shift-filters select {
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    height: 30px;
    box-sizing: border-box;
}
.shift-filters input[type="text"] { width: 130px; }

/* Блок пользователя в шапке */
.header-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; color: #fff; font-size: 14px; }
.user-role { font-size: 12px; color: rgba(255,255,255,0.75); }
.logout-link {
    color: #fff; background: rgba(255,255,255,0.15); padding: 5px 12px;
    border-radius: 5px; font-size: 13px; text-decoration: none; margin-left: 6px;
}
.logout-link:hover { background: rgba(255,255,255,0.28); }

/* Отменённая смена — серая, зачёркнутая */
tr.row-cancelled td {
    color: #aaa;
    text-decoration: line-through;
}
tr.row-cancelled a { color: #aaa; }

/* Черновик — жёлтая полоска слева */
table.shifts tbody tr.row-draft { background: #fff8e8; }
table.shifts tbody tr.row-draft:hover { background: #fff2d6; }
table.shifts tbody tr.row-draft td:first-child { border-left: 4px solid #f5a623; }

/* Пагинация смен */
.shifts-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    flex-wrap: wrap;
    gap: 10px;
}
.pagination-info { font-size: 13px; color: #555; }
.pagination-controls { display: flex; gap: 6px; align-items: center; }
.page-btn {
    padding: 5px 12px; border: 1px solid #ccc; border-radius: 5px;
    text-decoration: none; color: #1a73e8; font-size: 13px; background: #fff;
}
.page-btn:hover { background: #f0f4ff; }
.page-current {
    padding: 5px 12px; background: #1a73e8; color: #fff;
    border-radius: 5px; font-size: 13px; font-weight: 600;
}

.show-more {
    display: inline-block; padding: 8px 20px; background: #1a73e8; color: #fff !important;
    border-radius: 6px; font-weight: 600; text-decoration: none;
}
.show-more:hover { background: #1557b0; }
