* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", -apple-system, sans-serif;
    font-size: 14px;
    color: #1f2937;
    background: #f8f9fb;
    min-height: 100vh;
}

/* Header */
.header {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}
.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.logo {
    width: 32px; height: 32px;
    background: #1e3a5f;
    color: #ffffff;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
}
.brand { font-size: 16px; font-weight: 600; color: #1e3a5f; }
.version {
    font-size: 11px; color: #6b7280;
    background: #f3f4f6; padding: 2px 8px;
    border-radius: 10px; margin-left: 8px; font-weight: 400;
}
.spacer { flex: 1; }
.user-info { display: flex; align-items: center; gap: 12px; }
.logout-link {
    color: #6b7280; text-decoration: none; font-size: 13px;
    padding: 6px 12px; border: 1px solid #e5e7eb; border-radius: 6px;
}
.logout-link:hover { background: #f9fafb; color: #1f2937; }

/* Content */
.content { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page h1 { font-size: 22px; color: #1e3a5f; margin-bottom: 16px; }
.page p { margin-bottom: 12px; line-height: 1.5; }
.muted { color: #6b7280; font-size: 13px; }

/* Login */
.login-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: calc(100vh - 200px);
}
.login-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 32px;
    width: 100%; max-width: 380px;
}
.login-card h1 { font-size: 20px; color: #1e3a5f; margin-bottom: 20px; text-align: center; }
.login-card label {
    display: block; font-size: 12px; color: #6b7280;
    text-transform: uppercase; letter-spacing: 0.04em;
    font-weight: 600; margin-bottom: 6px;
}
.login-card input {
    width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid #d1d5db; border-radius: 8px;
    font-size: 14px; margin-bottom: 16px; outline: none;
    font-family: inherit;
}
.login-card input:focus { border-color: #1e3a5f; }
.login-card button {
    width: 100%; height: 42px;
    background: #1e3a5f; color: #ffffff;
    border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    font-family: inherit;
}
.login-card button:hover { background: #2c5282; }
.error {
    background: #fef2f2; color: #dc2626;
    padding: 10px 14px; border-radius: 6px;
    font-size: 13px; margin-bottom: 16px;
    border: 1px solid #fecaca;
}
/* Navigation */
/* Navigation */
.main-nav {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}
.nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 0 4px;
}
.nav-link {
    display: inline-block;
    padding: 12px 14px;
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover {
    color: #1e3a5f;
    border-bottom-color: #d1d5db;
}
.nav-link.active {
    color: #1e3a5f;
    border-bottom-color: #1e3a5f;
    font-weight: 600;
}

/* Бургер — скрыт на десктопе */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: #1e3a5f;
    padding: 10px 20px;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    text-align: left;
}
.nav-toggle:hover { background: #f9fafb; }

/* Мобильная навигация */
@media (max-width: 900px) {
    .nav-toggle { display: block; }
    .nav-inner {
        display: none;
        flex-direction: column;
        padding: 0;
        gap: 0;
        border-top: 1px solid #e5e7eb;
    }
    .nav-inner.nav-open { display: flex; }
    .nav-link {
        padding: 14px 20px;
        border-bottom: 1px solid #f3f4f6;
        border-left: 3px solid transparent;
    }
    .nav-link:hover {
        background: #f9fafb;
        border-bottom-color: #f3f4f6;
    }
    .nav-link.active {
        border-left-color: #1e3a5f;
        background: #eff6ff;
        border-bottom-color: #f3f4f6;
    }
}

/* Общий контент — отступы на мобильных */
@media (max-width: 720px) {
    .content {
        padding: 16px;
    }
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .page-header h1 {
        font-size: 20px;
    }
    .page-header .btn {
        width: 100%;
        text-align: center;
    }
    .dashboard-cards {
        grid-template-columns: 1fr !important;
    }
    .report-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .report-filters .field { width: 100%; }
    .report-filters #period-input { width: 100%; min-width: 0; }
    .report-buttons {
        flex-wrap: wrap;
    }
    .report-buttons .btn {
        flex: 1 1 45%;
    }
    .report-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .report-tab { white-space: nowrap; }
    .form-actions {
        flex-wrap: wrap;
    }
    .form-actions .btn {
        flex: 1 1 100%;
        margin-bottom: 6px;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .search-form {
        flex-wrap: wrap;
        max-width: none;
    }
    .search-form input {
        width: 100%;
    }
}/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
}
.page-header h1 {
    font-size: 22px;
    color: #1e3a5f;
    margin-bottom: 4px;
}
.page-subtitle {
    font-size: 13px;
    color: #6b7280;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
}
.search-form {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 600px;
}
.search-form input {
    flex: 1;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.search-form input:focus { border-color: #1e3a5f; }
.toolbar-info { font-size: 13px; color: #6b7280; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 16px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #1f2937;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.btn:hover { background: #f9fafb; }
.btn-primary {
    background: #1e3a5f;
    color: #ffffff;
    border-color: #1e3a5f;
}
.btn-primary:hover { background: #2c5282; border-color: #2c5282; }
.btn-danger { color: #dc2626; }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-link {
    border: none;
    background: transparent;
    color: #6b7280;
    text-decoration: underline;
}
.btn-link:hover { background: transparent; color: #1f2937; }
.inline { display: inline; }

/* Table */
.table-wrap {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;  /* ← важно: не сжимается меньше 600px */
}.data-table thead th {
    background: #f9fafb;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}
.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    color: #1f2937;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table .actions-col {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}
.data-table .actions-col .btn + .btn,
.data-table .actions-col form + .btn,
.data-table .actions-col .btn + form {
    margin-left: 6px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-person { background: #eef2f7; color: #4b5563; }
.badge-company { background: #eff6ff; color: #1e3a5f; }

/* Empty state */
.empty-state {
    background: #ffffff;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    padding: 48px 24px;
    text-align: center;
    color: #6b7280;
}
.empty-state p { margin-bottom: 16px; }

/* Form */
.form-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 24px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 20px; /* 18px по вертикали, 20px по горизонтали */
    margin-bottom: 24px;
}

.field {
    display: flex;
    flex-direction: column;
}

.field label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 6px; /* отступ от подписи до поля */
}

.field input,
.field select,
.field textarea {
    height: 40px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #1f2937;
    background: #ffffff;
    outline: none;
    box-sizing: border-box;
    width: 100%;
}.field input:focus, .field select:focus, .field textarea:focus {
    border-color: #1e3a5f;
}
.required { color: #dc2626; }
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f3f4f6;
}

/* Responsive */
@media (max-width: 720px) {
    .data-table {
        font-size: 13px;
    }
    .data-table thead th,
    .data-table tbody td {
        padding: 10px 8px;
        white-space: nowrap;
    }
    .table-wrap::after {
        content: '← прокрутите →';
        display: block;
        text-align: center;
        font-size: 11px;
        color: #9ca3af;
        padding: 6px;
        background: #f9fafb;
    }
}
.warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}
.warning a { color: #92400e; font-weight: 600; text-decoration: underline; }
.warning-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}
.section-title {
    font-size: 16px;
    color: #1e3a5f;
    margin: 24px 0 12px;
    font-weight: 600;
}
.form-card.compact {
    padding: 16px;
    margin-bottom: 0;
}
.form-card.compact .form-actions {
    margin-top: 12px;
    padding-top: 0;
    border-top: none;
}
.article-code {
    font-family: "Consolas", "Courier New", monospace;
    background: #f3f4f6;
    color: #1e3a5f;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
}
.vin-text {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 12px;
    color: #6b7280;
    letter-spacing: 0.03em;
}
.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}
.data-table thead th.sortable a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.data-table thead th.sortable a:hover {
    color: #1e3a5f;
}
.sort-arrow {
    font-size: 10px;
    color: #1e3a5f;
    font-weight: 700;
}
/* Receipts form */
.date-input {
    height: 38px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #ffffff;
    outline: none;
}
.date-input:focus { border-color: #1e3a5f; }
.status-select {
    height: 38px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: #ffffff;
    outline: none;
    cursor: pointer;
}

/* Items row in receipt form */
#items-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.item-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    box-sizing: border-box;
    width: 100%;
}

.item-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.item-field label {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 4px;
}

.item-field select,
.item-field input {
    height: 36px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #ffffff;
    outline: none;
    box-sizing: border-box;
}

.item-field select:focus,
.item-field input:focus {
    border-color: #1e3a5f;
}

/* Запчасть — самая широкая */
.item-field-part {
    flex: 1 1 280px;
    min-width: 180px;
}
.item-field-qty   { flex: 0 0 80px; }
.item-field-price { flex: 0 0 120px; }
.item-field-remove { flex: 0 0 auto; }

/* Обёртка select + кнопка «+ Новая» */
.part-select-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
}
.part-select-wrap .part-select {
    flex: 1 1 auto;
    min-width: 0;
}

.btn-quick-add {
    flex: 0 0 auto;
    white-space: nowrap;
    background: #f9fafb;
    color: #1e3a5f;
    border-color: #d1d5db;
    font-weight: 600;
    height: 36px;
    padding: 0 10px;
    font-size: 12px;
}

/* Адаптив */
@media (max-width: 720px) {
    .item-field-part,
    .item-field-qty,
    .item-field-price,
    .item-field-remove {
        flex: 1 1 100%;
    }
}

/* Info block */
.info-block {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #1f2937;
}

/* Badges for statuses */
.badge-active { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-sold { background: #dcfce7; color: #166534; }
.badge-partial { background: #dbeafe; color: #1e40af; }

/* Link strong */
.link-strong {
    color: #1e3a5f;
    font-weight: 600;
    text-decoration: none;
}
.link-strong:hover { text-decoration: underline; }

/* Responsive for item-row */
@media (max-width: 720px) {
    .item-row {
        grid-template-columns: 1fr;
    }
}
/* Quick add part */
.part-select-wrap {
    display: flex;
    gap: 6px;
    align-items: center;
    min-width: 0;
}
.part-select-wrap .part-select {
    flex: 1;
    min-width: 0;
}
.btn-quick-add {
    white-space: nowrap;
    background: #f9fafb;
    color: #1e3a5f;
    border-color: #d1d5db;
    font-weight: 600;
    flex-shrink: 0;
}.btn-quick-add:hover { background: #eef2f7; }

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal {
    background: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #e5e7eb;
}
.modal-header h2 {
    font-size: 17px;
    color: #1e3a5f;
    font-weight: 600;
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
    padding: 0 6px;
}
.modal-close:hover { color: #1f2937; }
.modal-body {
    padding: 20px 22px;
}
.modal-body .field {
    margin-bottom: 14px;
}
.modal-body .field label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}
.modal-body .field input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.modal-body .field input:focus { border-color: #1e3a5f; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid #e5e7eb;
    background: #fafbfc;
}
/* Realization row */
.realization-row {
    grid-template-columns: minmax(0, 2.5fr) 70px 100px 120px 90px;
}
.item-field-markup {
    flex: 0 0 100px;
}
@media (max-width: 900px) {
    .realization-row {
        grid-template-columns: 1fr 1fr;
    }
}
@media (max-width: 720px) {
    .realization-row {
        grid-template-columns: 1fr;
    }
}

/* Totals preview in form */
.totals-preview {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px 0;
    display: flex;
    gap: 24px;
    font-size: 14px;
}
.totals-preview span {
    font-weight: 600;
    color: #1e3a5f;
}

/* Totals block in detail */
.totals-block {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
}
.totals-block .totals-strong {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
    font-size: 16px;
    color: #1e3a5f;
}
/* Return row */
.return-row {
    grid-template-columns: minmax(0, 1fr) 90px 100px;
}
@media (max-width: 720px) {
    .return-row {
        grid-template-columns: 1fr;
    }
}
/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}
.settings-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 24px;
}
.settings-card h2 {
    font-size: 16px;
    color: #1e3a5f;
    font-weight: 600;
    margin-bottom: 8px;
}
.settings-card .muted {
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.settings-card .field {
    margin-bottom: 16px;
}
.settings-card .field label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 6px;
}
.settings-card select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #ffffff;
}

/* Success message */
.success {
    background: #dcfce7;
    color: #166534;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid #bbf7d0;
}

/* Permissions */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.perm-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}
.perm-check:hover { background: #f3f4f6; }
.perm-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.permissions-cell { font-size: 12px; }
.perm-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #eef2f7;
    color: #4b5563;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin: 1px;
}

@media (max-width: 720px) {
    .permissions-grid { grid-template-columns: 1fr; }
}
/* Dashboard */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.dash-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
}
.dash-card-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 8px;
}
.dash-card-value {
    font-size: 26px;
    font-weight: 700;
    color: #1e3a5f;
    line-height: 1.1;
}
.dash-card-value.dash-profit {
    color: #059669;
}
.dash-card-sub {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 6px;
}

.dashboard-section {
    margin-bottom: 28px;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.section-header .section-title {
    margin: 0;
}
.empty-state.small {
    padding: 24px;
}
.empty-state.small p {
    margin-bottom: 12px;
}

@media (max-width: 720px) {
    .dashboard-cards {
        grid-template-columns: 1fr 1fr;
    }
    .dash-card-value {
        font-size: 20px;
    }
}
/* Header icon + badge */
.header-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 8px;
    text-decoration: none;
    color: #6b7280;
    font-size: 18px;
    margin-right: 8px;
}
.header-icon:hover { background: #f9fafb; }
.header-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: #dc2626;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Messages page */
.messages-page { max-width: 1280px; margin: 0 auto; }
.messages-title { font-size: 22px; color: #1e3a5f; margin-bottom: 16px; }
.messages-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    height: calc(100vh - 240px);
    min-height: 400px;
}
.dialogs-list {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow-y: auto;
}
.dialog-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
}
.dialog-item:hover { background: #f9fafb; }
.dialog-item.active { background: #eff6ff; }
.dialog-avatar {
    width: 36px; height: 36px;
    background: #1e3a5f;
    color: #ffffff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; flex-shrink: 0;
}
.dialog-info { flex: 1; min-width: 0; }
.dialog-name { font-weight: 600; color: #1f2937; font-size: 14px; }
.dialog-preview { font-size: 12px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dialog-unread {
    background: #dc2626;
    color: #ffffff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    min-width: 18px;
    text-align: center;
}

.chat-panel {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-header {
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    color: #1e3a5f;
}
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
}
.msg {
    display: inline-block;
    max-width: 70%;
    padding: 9px 13px;
    border-radius: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.msg-mine { background: #1e3a5f; color: #ffffff; margin-left: auto; display: block; }
.msg-mine .msg-time { color: #cbd5e1; }
.msg-other { background: #ffffff; color: #1f2937; border: 1px solid #e5e7eb; display: block; }
.msg-time { font-size: 10px; opacity: 0.8; margin-top: 4px; text-align: right; }
.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}
.chat-input input {
    flex: 1;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.chat-input input:focus { border-color: #1e3a5f; }

/* Message previews on dashboard */
.messages-list { display: flex; flex-direction: column; gap: 8px; }
.message-preview {
    display: block;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 16px;
    text-decoration: none;
    color: #1f2937;
}
.message-preview:hover { background: #f9fafb; border-color: #d1d5db; }
.message-from { font-weight: 600; color: #1e3a5f; margin-bottom: 4px; font-size: 13px; }
.message-text { color: #4b5563; font-size: 13px; }

/* Popup */
.popup-container {
    position: fixed;
    bottom: 20px; right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}
.message-popup {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    width: 320px;
    overflow: hidden;
    animation: popupSlideIn 0.25s ease;
}
@keyframes popupSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #1e3a5f;
    color: #ffffff;
    font-size: 13px;
}
.popup-close {
    background: none; border: none;
    color: #ffffff; cursor: pointer;
    font-size: 18px; line-height: 1;
}
.popup-body {
    padding: 12px 14px;
    font-size: 14px;
    color: #1f2937;
    max-height: 100px;
    overflow-y: auto;
}
.popup-form {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    border-top: 1px solid #e5e7eb;
}
.popup-form input {
    flex: 1;
    height: 32px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
}
.popup-form input:focus { border-color: #1e3a5f; }

@media (max-width: 720px) {
    .messages-layout { grid-template-columns: 1fr; height: auto; }
    .dialogs-list { max-height: 300px; }
    .chat-panel { min-height: 400px; }
    .message-popup { width: calc(100vw - 40px); max-width: 320px; }
}
/* Report filters */
.report-filters {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.report-filters .field { margin: 0; }
.report-filters .field label {
    display: block;
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 6px;
}
.report-filters #period-input {
    height: 40px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    min-width: 260px;
    cursor: pointer;
    background: #ffffff;
}
.report-buttons { display: flex; gap: 6px; }
.report-chart-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}
.report-chart-card .section-title {
    margin-top: 0;
    margin-bottom: 16px;
}
/* Report tabs */
.report-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
}
.report-tab {
    padding: 10px 16px;
    font-size: 14px;
    color: #6b7280;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.report-tab:hover {
    color: #1e3a5f;
    border-bottom-color: #d1d5db;
}
.report-tab.active {
    color: #1e3a5f;
    border-bottom-color: #1e3a5f;
    font-weight: 600;
}
.data-table tfoot td {
    padding: 12px 16px;
    border-top: 2px solid #e5e7eb;
}