/* === RESET === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
    background: #f3f4f6;
}
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 600; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
.hidden { display: none !important; }
.muted { color: #6b7280; }

/* === LOGIN === */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: white;
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 24px; color: #1f2937; margin: 0; }
.login-subtitle { font-size: 13px; color: #6b7280; margin: 4px 0 0; }

/* === FORM === */
.field {
    display: block;
    margin-bottom: 16px;
}
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}
.field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: white;
}
.field input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
    background: #667eea;
    color: white;
}
.btn-primary:hover:not(:disabled) { background: #5568d3; }
.btn-danger {
    background: #ef4444;
    color: white;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-block { width: 100%; }

/* === MESSAGES === */
.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
}
.success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
}
.message { margin: 8px 0; }
.message.error, .message.success { display: block; }

/* === APP LAYOUT === */
.app-screen {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: #1f2937;
    color: #e5e7eb;
    padding: 20px 0;
    overflow-y: auto;
}
.sidebar-header { padding: 0 20px 20px; border-bottom: 1px solid #374151; }
.brand { font-size: 18px; font-weight: 600; color: white; }
.brand-sub { font-size: 12px; color: #9ca3af; }

.sidebar-nav { padding: 12px 0; }
.nav-section {
    padding: 16px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: #d1d5db;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.1s;
}
.nav-item:hover:not(.disabled) { background: #374151; color: white; }
.nav-item.active { background: #4f46e5; color: white; }
.nav-item.disabled { opacity: 0.4; cursor: not-allowed; }
.nav-icon { width: 20px; text-align: center; }

/* === MAIN === */
.main {
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    background: white;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}
.topbar-title { font-size: 17px; font-weight: 600; color: #1f2937; }
.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #4b5563;
}
.user-role {
    background: #ede9fe;
    color: #5b21b6;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.section { padding: 24px; }

/* === DASHBOARD === */
.welcome h2 { font-size: 24px; margin-bottom: 4px; }
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 24px;
}
.card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.card-icon { font-size: 22px; line-height: 1; }
.card-title { font-weight: 600; color: #1f2937; }
.card-desc { color: #6b7280; font-size: 13px; }
.card-ok { border-left: 4px solid #10b981; }
.card-progress { border-left: 4px solid #f59e0b; }
.card-pending { border-left: 4px solid #9ca3af; opacity: 0.7; }

/* === ENTITY CARD (просмотр) === */
.entity-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 14px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 18px;
    color: #6b7280;
    font-size: 13px;
}
.entity-section {
    margin-bottom: 18px;
}
.entity-section h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin: 0 0 8px;
    font-weight: 600;
}
.entity-section dl {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 6px 16px;
    margin: 0;
}
.entity-section dt { color: #6b7280; font-size: 13px; }
.entity-section dd { margin: 0; color: #1f2937; }
.entity-section dd code { font-family: ui-monospace, monospace; font-size: 13px; }

.linked-accounts { display: flex; flex-direction: column; gap: 8px; }
.linked-account {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.linked-account-icon { font-size: 22px; line-height: 1; }
.linked-account-info { flex: 1; min-width: 0; }
.linked-account-name { font-weight: 600; color: #1f2937; }
.linked-account-details { color: #6b7280; font-size: 12px; }
.linked-account-balance { color: #1f2937; font-weight: 600; white-space: nowrap; }

.modal-window.wide { max-width: 720px; }
.modal-window.ultrawide { max-width: min(1300px, 95vw); width: min(1300px, 95vw); }

/* === SETTINGS === */
.settings-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 22px;
    margin-bottom: 16px;
    max-width: 680px;
}
.settings-card h3 { margin: 0 0 14px; font-size: 16px; color: #111827; }
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.settings-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.settings-row .field {
    flex: 1;
    min-width: 200px;
}
.settings-row .field .field-label {
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 500;
}
.settings-row .field input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    background: #fff;
    transition: border-color .15s;
}
.settings-row .field input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.profile-fields {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    margin: 0;
}
.profile-fields dt { color: #6b7280; font-size: 13px; }
.profile-fields dd { margin: 0; color: #1f2937; }

.placeholder { padding: 40px; text-align: center; color: #6b7280; }
.placeholder h2 { color: #9ca3af; }

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

/* === TABLES === */
.table-wrap {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    background: #f9fafb;
    color: #4b5563;
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
.data-table th.accounts-group-title {
    background: #1f2937;
    color: white;
    font-size: 13px;
    padding: 10px 16px;
    text-transform: none;
    letter-spacing: 0;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafb; }
.data-table tr.clickable td { cursor: pointer; }
.data-table tr.clickable:hover td { background: #eef2ff; }
.data-table .row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}
.data-table .row-actions button {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: white;
    cursor: pointer;
    color: #4b5563;
    transition: background 0.1s;
}
.data-table .row-actions button:hover { background: #f3f4f6; }
.data-table .row-actions button.danger { color: #dc2626; border-color: #fecaca; }
.data-table .row-actions button.danger:hover { background: #fef2f2; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    background: #f3f4f6;
    color: #4b5563;
}
.tag-active { background: #d1fae5; color: #065f46; }
.tag-inactive { background: #fee2e2; color: #991b1b; }
.tag-blue { background: #dbeafe; color: #1e40af; }
.tag-purple { background: #ede9fe; color: #5b21b6; }
.tag-orange { background: #ffedd5; color: #9a3412; }

.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
}
.loading {
    padding: 40px;
    text-align: center;
    color: #9ca3af;
}

/* === MODAL === */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}
.modal-window {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 25px 75px rgba(0, 0, 0, 0.25);
    z-index: 1;
}
.modal-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: #9ca3af;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
}
.modal-close:hover { background: #f3f4f6; color: #1f2937; }
.modal-body { padding: 24px; }
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}
.modal-actions .btn { padding: 8px 14px; }
.btn-secondary {
    background: white;
    color: #4b5563;
    border: 1px solid #d1d5db;
}
.btn-secondary:hover { background: #f3f4f6; }

/* === FORM === */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.field select, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
}
.field textarea { resize: vertical; min-height: 60px; }
.field select:focus, .field textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #6b7280;
}
.field-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}
.field-checkbox input { width: auto; }

/* === TOAST === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}
.toast {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #667eea;
    font-size: 14px;
    animation: slideIn 0.2s ease-out;
}
.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }
@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* === ALERT === */
.alert {
    background: #fef9c3;
    border: 1px solid #fde047;
    color: #713f12;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert code {
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
}

/* === DRIVER SCREEN (мобильный) === */
.driver-screen {
    min-height: 100vh;
    background: #f3f4f6;
    display: flex;
    flex-direction: column;
}
.driver-header {
    background: #1f2937;
    color: white;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.driver-greet { font-size: 16px; font-weight: 600; }
.driver-date { font-size: 13px; color: #9ca3af; margin-top: 2px; }
.driver-logout {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
}
.driver-logout:hover { background: rgba(255,255,255,0.2); }

.driver-main {
    flex: 1;
    padding: 16px;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
/* Desktop: шире */
@media (min-width: 860px) {
    .driver-main { max-width: 1280px; padding: 20px 28px; }
}

/* Таблица доставок (десктоп) */
.driver-delivery-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.driver-delivery-table th {
    background: #f3f4f6; padding: 6px 8px; text-align: left;
    font-weight: 600; color: #374151; white-space: nowrap;
    border-bottom: 2px solid #e5e7eb;
}
.driver-delivery-table td { padding: 6px 8px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.driver-delivery-table tbody tr:hover { background: #fafafa; }
.driver-delivery-table .tc { text-align: center; }
.driver-delivery-table .tar { text-align: right; white-space: nowrap; }
.driver-delivery-table .nowrap { white-space: nowrap; }
.driver-delivery-table .muted-addr { font-size: 11px; color: #9ca3af; }
.ddt-planned { background: #fffbeb !important; }
.ddt-actions { display: flex; gap: 4px; }

/* Горизонтальная строка статистики */
.driver-stats-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    padding: 14px 18px !important;
}
.driver-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 100px;
}
.driver-stat-label { font-size: 11px; color: #6b7280; white-space: nowrap; }
.driver-stat-value { font-size: 15px; font-weight: 700; color: #1f2937; white-space: nowrap; }
.driver-stat-handover .driver-stat-value { color: #7c3aed; font-size: 17px; }
.driver-stat-sep {
    width: 1px; height: 32px;
    background: #e5e7eb;
    flex-shrink: 0;
    align-self: center;
}
@media (max-width: 640px) {
    .driver-stats-bar { flex-direction: column; align-items: stretch; gap: 10px; }
    .driver-stats-bar .btn { width: 100%; }
    .driver-stat-sep { width: 100%; height: 1px; }
}

.driver-empty {
    background: white;
    border-radius: 14px;
    padding: 40px 24px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.driver-empty-icon { font-size: 56px; margin-bottom: 16px; }
.driver-empty h2 { font-size: 22px; margin-bottom: 8px; }

.driver-card {
    background: white;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.driver-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.driver-card h3 {
    font-size: 16px;
    margin: 0;
    color: #1f2937;
}
.driver-count {
    display: inline-block;
    background: #ede9fe;
    color: #5b21b6;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 6px;
}

.driver-meter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #6b7280;
    font-size: 14px;
}
.driver-meter-row strong {
    color: #1f2937;
    font-size: 16px;
}

.driver-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.driver-list-empty {
    padding: 16px 8px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

.driver-group {
    background: #f9fafb;
    border-radius: 10px;
    padding: 12px;
    border: 1px solid transparent;
}
.driver-group-planned {
    background: #fffbeb;
    border-color: #fde68a;
}
.driver-group-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}
.driver-group-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 15px;
}
.driver-group-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed #e5e7eb;
}
.driver-group-item:last-child { border-bottom: none; }
.driver-group-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.driver-group-actions .btn-sm { padding: 6px 10px; font-size: 12px; }

.status-planned   { background: #fef3c7; color: #92400e; }

.driver-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.1s;
}
.driver-item:hover, .driver-item:active { background: #f3f4f6; }
.driver-item-icon { font-size: 22px; line-height: 1; }
.driver-item-main { flex: 1; min-width: 0; }
.driver-item-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.driver-item-sub { color: #6b7280; font-size: 12px; margin-top: 2px; }
.driver-item-amount {
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
}
.driver-item-status {
    display: inline-block;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
    margin-left: 6px;
}
.status-delivered { background: #d1fae5; color: #065f46; }
.status-partial   { background: #fef3c7; color: #92400e; }
.status-returned  { background: #fee2e2; color: #991b1b; }
.status-failed    { background: #f3f4f6; color: #4b5563; }

.driver-totals { background: linear-gradient(135deg, #eef2ff, #faf5ff); }
.driver-total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    color: #4b5563;
    font-size: 14px;
}
.driver-total-row strong { color: #1f2937; font-size: 16px; }
.driver-total-final {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-size: 16px;
}
.driver-total-final span { font-weight: 600; color: #1f2937; }
.driver-total-final strong { font-size: 22px; color: #4f46e5; }

.btn-lg {
    padding: 14px 18px;
    font-size: 16px;
    border-radius: 12px;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 8px;
}

.driver-history {
    margin-top: 8px;
    background: white;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.driver-history h3 { font-size: 16px; margin-bottom: 12px; }

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
}
.history-item:last-child { border-bottom: none; }
.history-date { color: #1f2937; font-weight: 500; }
.history-meta { color: #6b7280; font-size: 12px; }

/* === REPORT DELIVERIES (в модале бухгалтера) === */
.client-group {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}
.client-group-header {
    display: flex;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 10px;
    font-size: 14px;
}
.invoice-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed #e5e7eb;
}
.invoice-row:last-child { border-bottom: none; }
.invoice-row-main { flex: 1; min-width: 0; }
.invoice-row-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
    margin-bottom: 6px;
    font-size: 14px;
}
.invoice-row-payments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.invoice-row-amount {
    font-weight: 700;
    font-size: 15px;
    color: #1f2937;
    white-space: nowrap;
    flex-shrink: 0;
}
.pay-pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}
.pay-cash { background: #d1fae5; color: #065f46; }
.pay-bank { background: #dbeafe; color: #1e40af; }
.pay-card { background: #ffedd5; color: #9a3412; }

/* === ROUTE DELIVERIES (внутри модала маршрутного листа) === */
.route-deliveries {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.route-delivery {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}
.route-delivery-main { flex: 1; min-width: 0; }
.route-delivery-client {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
    margin-bottom: 4px;
}
.route-delivery-address {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 4px;
}
.route-delivery-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    color: #6b7280;
    font-size: 13px;
}
.route-delivery-amount {
    margin-left: auto;
    color: #1f2937;
    font-weight: 600;
}
.route-delivery-notes { font-size: 12px; margin-top: 4px; }
.route-delivery-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}
.route-delivery-actions button {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: white;
    cursor: pointer;
    color: #4b5563;
    white-space: nowrap;
}
.route-delivery-actions button:hover { background: #f3f4f6; }
.route-delivery-actions button.danger {
    color: #dc2626;
    border-color: #fecaca;
    width: 32px;
    padding: 5px 0;
    font-size: 16px;
    line-height: 1;
}

/* === БЛОК ВЫБОРА МАГАЗИНА ДЛЯ СТАРШЕГО ПРОДАВЦА === */
.senior-shops {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.senior-shops .btn { width: 100%; padding: 12px 14px; }

/* === ВИДЖЕТ ТАБЕЛЯ В ШАПКЕ === */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.btn-topbar-logout {
    font-size: 12px;
    padding: 4px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    white-space: nowrap;
}
.btn-topbar-logout:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.timesheet-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    background: #f3f4f6;
    color: #4b5563;
}
.timesheet-widget.present {
    background: #d1fae5;
    color: #065f46;
}
.timesheet-widget .ts-status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #9ca3af;
}
.timesheet-widget.present .ts-status-dot { background: #10b981; }
.timesheet-widget button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0 0 0 6px;
    text-decoration: underline;
    font-size: 12px;
}
.timesheet-widget button:hover { color: #1f2937; }

/* === SELLER ACTIONS === */
.seller-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* === ФОРМА ПОДСЧЁТА ДЕНЕГ ПО НОМИНАЛАМ === */
.cash-count {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 60vh;
    overflow-y: auto;
}
.cash-count-row {
    display: grid;
    grid-template-columns: 90px 1fr 110px;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    background: #f9fafb;
    border-radius: 8px;
}
.cash-count-row.coin { background: #f3f4f6; }
.cash-count-denom { font-weight: 600; color: #1f2937; }
.cash-count-row input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
    font-size: 16px;
}
.cash-count-subtotal {
    text-align: right;
    font-weight: 500;
    color: #4b5563;
    font-size: 14px;
}
.cash-count-total {
    margin-top: 12px;
    padding: 14px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 17px;
}
.cash-count-total .value { font-size: 22px; font-weight: 700; }

/* === ТП BALANCES WIDGET === */
.tp-summary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    padding: 20px 24px;
    border-radius: 14px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.tp-summary-label { font-size: 13px; opacity: 0.85; }
.tp-summary-value { font-size: 28px; font-weight: 700; line-height: 1.2; }

.tp-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.tp-card-empty {
    opacity: 0.65;
    background: #f9fafb;
}
.tp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 12px;
}
.tp-card-name { font-weight: 600; font-size: 16px; color: #1f2937; }
.tp-card-total {
    font-size: 22px;
    font-weight: 700;
    color: #4f46e5;
}
.tp-card-empty .tp-card-total { color: #9ca3af; font-size: 16px; }
.tp-card-empty-msg {
    text-align: center;
    padding: 8px 0;
    font-size: 13px;
}
.tp-breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #f3f4f6;
}
.tp-breakdown-row:last-child { border-bottom: none; }
.tp-breakdown-le { font-size: 14px; }
.tp-breakdown-amount { font-weight: 600; color: #1f2937; }

.tag-green { background: #d1fae5; color: #065f46; }

/* «Надо забрать» внутри карточки ТП */
.tp-tocollect { margin-top: 10px; }
.tp-tocollect:empty { display: none; }
.tp-tocollect-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
}
.tp-collect-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed #f3f4f6;
}
.tp-collect-row:last-child { border-bottom: none; }
.tp-collect-main { min-width: 0; flex: 1; }
.tp-collect-client { font-size: 14px; font-weight: 600; color: #1f2937; }
.tp-collect-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* === БАНКОВСКИЕ ТРАНЗАКЦИИ === */
.stats-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.stat-card {
    flex: 1;
    min-width: 130px;
    background: white;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    border: 1px solid #e5e7eb;
}
.stat-card.stat-green { border-left: 4px solid #10b981; }
.stat-card.stat-red   { border-left: 4px solid #ef4444; }
.stat-card.stat-warn  { border-left: 4px solid #f59e0b; background: #fffbeb; }
.stat-label { font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 700; color: #1f2937; }

.filters-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    background: white;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}
.filters-bar label { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.filter-input {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    background: white;
}

.amount-credit   { color: #059669; font-weight: 600; }
.amount-debit    { color: #dc2626; font-weight: 600; }
.amount-transfer { color: #2563eb; font-weight: 600; }
.tag-red  { background: #fee2e2; color: #b91c1c; }
.stat-card.stat-red  { border-left: 4px solid #dc2626; }
.stat-card.stat-blue { border-left: 4px solid #2563eb; }
.row-voided { opacity: 0.5; text-decoration: line-through; }
.ops-table td { font-size: 13px; }

.tag-warn { background: #fef3c7; color: #92400e; }

.row-warn { background: #fffbeb; }
.row-warn:hover { background: #fef3c7 !important; }

.bank-table td { font-size: 13px; }
.bank-table .row-actions { display: flex; gap: 4px; white-space: nowrap; }

.btn-success {
    background: #10b981;
    color: white;
    border: none;
}
.btn-success:hover { background: #059669; }

.table-responsive { overflow-x: auto; }

.cp-result-row:hover { background: #f9fafb; }

/* modal-overlay (для банковских модалей) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: white;
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-box h3 { margin: 0 0 16px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; }

/* === Таблица доставок в маршрутном листе === */
.route-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.route-table th { background: #f3f4f6; padding: 6px 6px; text-align: left; font-weight: 600; color: #374151; white-space: nowrap; border-bottom: 2px solid #e5e7eb; }
.route-table td { padding: 3px 4px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.route-table tbody tr:hover { background: #fafafa; }
.rt-input { width: 100%; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; font-size: 13px; background: transparent; box-sizing: border-box; }
.rt-input:focus { border-color: #6366f1; background: #fff; outline: none; box-shadow: 0 0 0 2px #e0e7ff; }
.rt-input[type="number"] { text-align: right; }
.rt-num  { width: 28px; text-align: center; color: #9ca3af; font-size: 12px; }
.rt-client { min-width: 140px; }
.rt-addr   { min-width: 130px; }
.rt-le     { min-width: 120px; }
.rt-inv    { min-width: 80px; }
.rt-date   { min-width: 120px; }
.rt-sum    { min-width: 90px; }
.rt-pay    { min-width: 90px; }
.rt-note   { min-width: 120px; }
.rt-del    { width: 28px; }
.btn-row-del { background: none; border: none; color: #9ca3af; cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.btn-row-del:hover { color: #ef4444; background: #fee2e2; }
.btn-success { background: #10b981; color: white; border: none; }
.btn-success:hover { background: #059669; }

/* === Сводка сданного отчёта водителя (UX Gap 1) === */
.driver-submit-summary { background: #f0f9ff; border-radius: 8px; padding: 12px 14px; margin-top: 12px; text-align: left; }
.driver-submit-row { font-size: 14px; padding: 3px 0; color: #374151; }

/* === Сводка закрытия смены (Баг Е) === */
.shift-close-summary { display: flex; flex-direction: column; gap: 16px; }
.summary-block { background: #f9fafb; border-radius: 8px; padding: 12px 14px; }
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 14px; border-bottom: 1px solid #e5e7eb; }
.summary-row:last-child { border-bottom: none; }
.summary-row.summary-total { border-top: 2px solid #e5e7eb; margin-top: 4px; padding-top: 8px; font-weight: 600; font-size: 15px; }
.text-warning { color: #b45309; font-size: 13px; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .app-screen { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .form-row { grid-template-columns: 1fr; }
}

/* === ЗАРПЛАТА === */
.salary-table td { font-size: 13px; }
.salary-month-row td { background: #f0f4ff; font-size: 13px; padding: 6px 10px; }
.btn-salary { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.btn-salary:hover { background: #ddd6fe; }

/* === SHOW/HIDE PASSWORD === */
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 40px; }
.pw-toggle {
    position: absolute; right: 0; top: 0; bottom: 0;
    width: 38px; background: none; border: none;
    cursor: pointer; font-size: 16px; color: #888;
    display: flex; align-items: center; justify-content: center;
    border-radius: 0 8px 8px 0;
}
.pw-toggle:hover { color: #555; background: rgba(0,0,0,0.04); }

/* === ПУЛ ЗАКАЗОВ — группировка по клиенту === */
.pool-clients-table tr.pool-client-header td {
    background: #eff6ff;
    border-top: 2px solid #bfdbfe;
    padding: 6px 8px;
    font-size: 13px;
}
.pool-clients-table tr.pool-client-header + tr.pool-client-row td {
    border-top: none;
}
.pool-clients-table tr.pool-client-row td {
    background: #fafcff;
    padding-left: 16px;
}
.pool-clients-table tr.pool-client-row:last-of-type td,
.pool-clients-table tr.pool-client-row + tr:not(.pool-client-row) td {
    border-bottom: 2px solid #bfdbfe;
}
.pool-clients-table td.num-cell { text-align: center; color: #9ca3af; font-size: 12px; }

/* === AUTOCOMPLETE контрагент === */
.cp-ac-wrap { position: relative; }
.cp-ac-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    max-height: 220px;
    overflow-y: auto;
    z-index: 9999;
}
.cp-ac-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
}
.cp-ac-item:last-child { border-bottom: none; }
.cp-ac-item:hover, .cp-ac-item:focus { background: #f0f4ff; }
.cp-ac-item.cp-ac-create { color: #2563eb; }
.cp-ac-item.cp-ac-create:hover { background: #eff6ff; }

/* === ВОДИТЕЛЬ — две кнопки конца дня === */
.driver-end-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}
@media (min-width: 600px) {
    .driver-end-actions { flex-direction: row; }
}

/* === КНОПКА OUTLINE === */
.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}
.btn-outline:hover { background: #f3f4f6; }
