* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --border: #d9e1ec;
    --text: #1f2a37;
    --muted: #6b7280;
    --primary: #1f6feb;
    --primary-dark: #1557b0;
    --success: #dff6e8;
    --success-text: #0f7a38;
    --warning: #fff3cd;
    --warning-text: #8a6d1f;
    --danger: #fde2e1;
    --danger-text: #b42318;
    --last-bg: #f7e7a7;
    --next-bg: #d7ebc4;
    --duplicate: #fff1d6;
    --deleted: #eef1f5;
    --hover: #eef6ff;
    --shadow: 0 10px 35px rgba(15, 23, 42, 0.08);
    --radius: 16px;

    --sticky-client-left: 0px;
    --table-header-height: 44px;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
}

.page {
    padding: 24px;
    max-width: 100%;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.brand {
    font-size: 28px;
    font-weight: 700;
}

.subtitle {
    color: var(--muted);
    margin-top: 4px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.month-arrow {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #eef4ff;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    transition: 0.2s ease;
}

.month-arrow:hover {
    background: #dce9ff;
}

.month-title {
    font-size: 22px;
    font-weight: 700;
    min-width: 180px;
    text-align: center;
}

.filters {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    text-decoration: none;
    color: var(--text);
    padding: 9px 14px;
    border-radius: 999px;
    background: #eef2f7;
    border: 1px solid transparent;
    font-size: 14px;
    transition: 0.2s ease;
}

.chip:hover {
    background: #e4ebf5;
}

.chip.active {
    background: #dce9ff;
    color: var(--primary);
    border-color: #bdd3ff;
    font-weight: 700;
}

.manager-filter select,
.per-page-form select,
.search-input,
.modal-body input,
.modal-body select,
.modal-body textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.manager-filter select:focus,
.per-page-form select:focus,
.search-input:focus,
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    border-color: #bdd3ff;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.search-input {
    min-width: 280px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    min-width: 0;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-card.warning {
    background: #fff8df;
}

.stat-card.danger {
    background: #fff0ef;
}

.stat-card.success {
    background: #ebfaf0;
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    color: var(--muted);
    font-size: 14px;
}

.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    max-width: 100%;
}

.table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 8px;
}

.table-head h2 {
    margin: 0;
    font-size: 22px;
}

.table-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.list-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 20px 14px;
}

.search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.per-page-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

.per-page-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}

.table-summary {
    padding: 0 20px 14px;
    color: var(--muted);
    font-size: 14px;
}

.table-scroll {
    overflow: auto;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    max-width: 100%;
    position: relative;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100vh - 240px);
}

.crm-table {
    width: 100%;
    min-width: 1800px;
    border-collapse: separate;
    border-spacing: 0;
}

.crm-table th,
.crm-table td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    vertical-align: top;
    background: #fff;
    font-size: 14px;
}

.crm-table th {
    position: sticky;
    z-index: 10;
    background: #f8fbff;
    text-align: left;
    font-weight: 700;
    white-space: nowrap;
}

.crm-table thead tr:first-child th {
    top: 0;
    z-index: 15;
}

.crm-table thead tr:nth-child(2) th {
    top: var(--table-header-height);
    z-index: 14;
}

.crm-table th.th-last,
.crm-table td[data-col-key^="last_contact_"] {
    background: #fffbea;
}

.crm-table th.th-next,
.crm-table td[data-col-key^="next_contact_"] {
    background: #f2fbef;
}

.crm-table tbody tr:hover td {
    background: var(--hover);
}

.crm-table tbody tr.row-duplicate td {
    background: var(--duplicate);
}

.crm-table tbody tr.row-deleted td {
    background: var(--deleted);
}

.empty-cell {
    text-align: center;
    padding: 30px 20px !important;
    color: var(--muted);
}

/* ЛИПКАЯ КОЛОНКА ТОЛЬКО КЛІЄНТ */
.crm-table td[data-col-key="client_name"],
.crm-table th[data-col-key="client_name"] {
    position: sticky;
    left: var(--sticky-client-left);
    z-index: 14;
    background: #fff;
    min-width: 220px;
    box-shadow: 1px 0 0 var(--border);
}

.crm-table thead th[data-col-key="client_name"] {
    background: #f8fbff;
    z-index: 20;
}

.crm-table thead tr:nth-child(2) th[data-col-key="client_name"] {
    z-index: 19;
}

.crm-table tbody tr:hover td[data-col-key="client_name"] {
    background: var(--hover);
}

.crm-table tbody tr.row-duplicate td[data-col-key="client_name"] {
    background: var(--duplicate);
}

.crm-table tbody tr.row-deleted td[data-col-key="client_name"] {
    background: var(--deleted);
}

.client-name-cell {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 190px;
}

.duplicate-badge {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 999px;
    background: #ffe3a8;
    color: #8a5a00;
    font-size: 12px;
    font-weight: 700;
}

.deleted-mark {
    display: inline-flex;
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 999px;
    background: #dbe1ea;
    color: #4b5563;
    font-size: 12px;
    font-weight: 700;
}

.result-cell {
    min-width: 180px;
    white-space: normal;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-light {
    background: #eef2f7;
    color: var(--text);
}

.btn-light:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #d94f45;
    color: #fff;
}

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

.btn-success {
    background: #1f9d55;
    color: #fff;
}

.btn-success:hover {
    background: #187a42;
}

.btn-sm {
    padding: 8px 10px;
    font-size: 13px;
}

.btn-calendar {
    background: #7c3aed;
    color: #fff;
}

.btn-calendar:hover {
    background: #6d28d9;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px 20px;
}

.page-btn,
.page-number {
    text-decoration: none;
    color: var(--text);
    background: #eef2f7;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
}

.page-btn.disabled {
    pointer-events: none;
    opacity: 0.5;
}

.page-numbers {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.page-number.active {
    background: var(--primary);
    color: #fff;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status-pill.done {
    background: var(--success);
    color: var(--success-text);
}

.status-pill.planned {
    background: var(--warning);
    color: var(--warning-text);
}

.status-pill.overdue {
    background: var(--danger);
    color: var(--danger-text);
}

.status-pill.empty {
    background: #edf2f7;
    color: #64748b;
}

.status-pill-inline {
    margin-top: 6px;
}

.badge-today {
    background: #fff3cd;
    color: #8a6d1f;
}

.badge-overdue {
    background: #fde2e1;
    color: #b42318;
}

.badge-planned {
    background: #dff6e8;
    color: #0f7a38;
}

.next-contact-cell {
    min-width: 130px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cooperation-status-pill {
    max-width: 100%;
    white-space: normal;
    line-height: 1.25;
    text-align: center;
}

.cooperation-status-pill.cooperation-working {
    background: #dff6e8;
    color: #0f7a38;
}

.cooperation-status-pill.cooperation-not_working {
    background: #e8eef7;
    color: #46556a;
}

.cooperation-status-pill.cooperation-closed_temp {
    background: #fff3cd;
    color: #8a6d1f;
}

.cooperation-status-pill.cooperation-closed_forever {
    background: #fde2e1;
    color: #b42318;
}

.cooperation-status-pill.cooperation-tenders_work {
    background: #efe8ff;
    color: #6b3fd6;
}

/* ТЕЛЕФОНЫ */
.phone-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 150px;
}

.phone-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.phone-text {
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.phone-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.phone-icon-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    transition: 0.2s ease;
}

.phone-icon-btn:hover {
    background: #f3f7fc;
    transform: translateY(-1px);
}

.copy-phone {
    font-size: 14px;
}

.tg-link i,
.viber-link i {
    font-size: 15px;
}

.tg-link:hover {
    border-color: #4697ce;
    background: rgba(70, 151, 206, 0.08);
}

.viber-link:hover {
    border-color: #7360f2;
    background: rgba(115, 96, 242, 0.08);
}

/* МОДАЛКА */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal.open {
    display: flex;
}

.modal-dialog {
    width: min(1100px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 3;
}

.modal-header h3 {
    margin: 0;
    font-size: 22px;
}

.modal-close {
    border: 0;
    background: #eef2f7;
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 24px;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 16px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-grid label span {
    font-size: 14px;
    font-weight: 700;
    color: #334155;
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
    margin-top: -2px;
}

.duplicate-warning {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff3cd;
    color: #8a6d1f;
    font-size: 14px;
    font-weight: 700;
}

.activity-editor {
    margin-top: 10px;
}

.activity-editor-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.activity-editor-status {
    font-size: 13px;
    color: var(--muted);
}

.activity-editor-status.is-error {
    color: #b42318;
}

.activity-editor-status.is-success {
    color: #0f7a38;
}

.activity-editor-panel {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fbff;
}

.activity-editor-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.activity-editor-row input[type="text"] {
    width: 100%;
}

.activity-editor-add-row,
.activity-editor-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.activity-editor-add-row input {
    flex: 1 1 260px;
}


.company-contacts-panel {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #f8fbff;
}

.company-contacts-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.company-contacts-head h4 {
    margin: 0;
    font-size: 18px;
}

.contacts-repeater {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 14px;
}

.contact-card {
    border: 1px solid #d7e3f3;
    border-radius: 16px;
    background: #fff;
    padding: 16px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.contact-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.contact-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2a37;
}

.contact-card-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.contact-primary-label {
    justify-content: flex-end;
}

.contact-primary-control {
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
    padding: 10px 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.contact-primary-control input {
    width: auto !important;
    margin: 0;
}

.contacts-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}

.contacts-box {
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border);
}

.last-box {
    background: #fffbea;
}

.next-box {
    background: #f2fbef;
}

.contacts-box h4 {
    margin: 0 0 12px;
    font-size: 18px;
}

.contacts-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.full-width {
    grid-column: 1 / -1;
}

.form-error {
    margin-top: 18px;
    color: #c62828;
    font-weight: 700;
    min-height: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* DROPDOWN */
.dropdown-checklist {
    position: relative;
    min-width: 220px;
}

.dropdown-checklist-toggle {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}

.dropdown-checklist-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-checklist-arrow {
    flex-shrink: 0;
    color: var(--muted);
}

.dropdown-checklist-menu {
    display: none;
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    min-width: 260px;
    max-height: 260px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    padding: 8px;
}

.dropdown-checklist.open .dropdown-checklist-menu {
    display: block;
}

.dropdown-checklist-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropdown-checklist-item {
    display: flex;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
}

.dropdown-checklist-item:hover {
    background: #f8fafc;
}

.dropdown-checklist-item input {
    width: 16px !important;
    min-width: 16px;
    height: 16px;
    margin: 0 !important;
    flex: 0 0 16px;
    display: block;
}

.dropdown-checklist-item span {
    display: block;
    margin: 0;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
}

/* DRAG COLUMNS */
.draggable-col {
    cursor: move;
    user-select: none;
}

.draggable-col.is-dragging {
    opacity: 0.45;
}

.draggable-col.drag-over-left {
    box-shadow: inset 3px 0 0 var(--primary);
}

.draggable-col.drag-over-right {
    box-shadow: inset -3px 0 0 var(--primary);
}

/* LOGIN */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #eef4ff, #f5f7fb);
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.15);
    padding: 32px;
    border: 1px solid #e7edf5;
}

.login-logo {
    font-size: 30px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-card h1 {
    margin: 0 0 18px;
    font-size: 26px;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fde2e1;
    color: #b42318;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form label span {
    font-size: 14px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 15px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input:focus {
    border-color: #bdd3ff;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.btn-full {
    width: 100%;
    min-height: 46px;
}

/* КАЛЕНДАРЬ */
.calendar-modal-dialog {
    width: min(1400px, 96vw);
    max-height: calc(100vh - 40px);
}

.calendar-modal-body {
    padding: 20px;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.calendar-weekdays div {
    background: #f3f7fc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    font-weight: 700;
    color: #334155;
    font-size: 14px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
}

.calendar-day {
    min-height: 150px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.calendar-day.empty {
    background: #f8fafc;
    border-style: dashed;
    box-shadow: none;
}

.calendar-day.has-events {
    background: #fafdff;
    border-color: #cfe0f7;
}

.calendar-day-number {
    font-size: 16px;
    font-weight: 700;
    color: #1f2a37;
    margin-bottom: 4px;
}

.calendar-event {
    background: #eef4ff;
    border-left: 4px solid var(--primary);
    border-radius: 10px;
    padding: 8px 9px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calendar-event-time {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.calendar-event-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    word-break: break-word;
}

.calendar-event-action {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.25;
    word-break: break-word;
}

/* TABLET */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .calendar-grid,
    .calendar-weekdays {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .crm-table {
        min-width: 1650px;
    }

    .crm-table td[data-col-key="client_name"],
    .crm-table th[data-col-key="client_name"] {
        min-width: 200px;
    }
}

@media (max-width: 1100px) {
    .contacts-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    :root {
        --table-header-height: 41px;
    }

    .form-grid,
    .contacts-grid {
        grid-template-columns: 1fr;
    }

    .toolbar,
    .list-toolbar,
    .topbar,
    .table-head,
    .pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form,
    .per-page-form {
        width: 100%;
    }

    .search-input,
    .dropdown-checklist,
    .manager-filter,
    .manager-filter select {
        width: 100%;
        min-width: 100%;
    }

    .table-head-actions {
        width: 100%;
    }

    .table-head-actions .btn {
        flex: 1 1 auto;
    }

    .page-numbers {
        justify-content: center;
    }

    .crm-table {
        min-width: 1500px;
    }

    .crm-table td,
    .crm-table th {
        padding: 9px 10px;
        font-size: 13px;
    }

    .crm-table td[data-col-key="client_name"],
    .crm-table th[data-col-key="client_name"] {
        min-width: 180px;
    }

    .phone-list {
        min-width: 170px;
    }

    .modal-dialog {
        width: min(100%, 100%);
        border-radius: 16px;
    }

    .calendar-grid,
    .calendar-weekdays {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .calendar-day {
        min-height: 130px;
    }
}

@media (max-width: 640px) {
    :root {
        --table-header-height: 39px;
    }

    .page {
        padding: 12px;
    }

    .toolbar,
    .table-wrap,
    .stat-card,
    .login-card {
        border-radius: 14px;
    }

    .topbar {
        gap: 12px;
    }

    .brand {
        font-size: 22px;
    }

    .subtitle {
        font-size: 13px;
    }

    .month-nav {
        justify-content: space-between;
        width: 100%;
    }

    .month-title {
        min-width: auto;
        font-size: 18px;
    }

    .table-head {
        padding: 14px 14px 8px;
    }

    .list-toolbar {
        padding: 12px 14px;
    }

    .table-summary {
        padding: 0 14px 12px;
    }

    .table-head h2 {
        font-size: 18px;
    }

    .search-input,
    .manager-filter select,
    .per-page-form select,
    .modal-body input,
    .modal-body select,
    .modal-body textarea,
    .dropdown-checklist-toggle {
        min-height: 42px;
        font-size: 16px;
    }

    .btn {
        min-height: 42px;
        font-size: 14px;
    }

    .btn-sm {
        min-height: 38px;
    }

    .crm-table {
        min-width: 1300px;
    }

    .crm-table td,
    .crm-table th {
        padding: 8px 9px;
        font-size: 12px;
    }

    .crm-table td[data-col-key="client_name"],
    .crm-table th[data-col-key="client_name"] {
        min-width: 160px;
    }

    .client-name-cell {
        min-width: 140px;
    }

    .phone-list {
        min-width: 150px;
        gap: 6px;
    }

    .phone-row {
        gap: 5px;
    }

    .phone-icon-btn {
        width: 28px;
        height: 28px;
        min-width: 28px;
        border-radius: 7px;
    }

    .status-pill {
        font-size: 11px;
        padding: 5px 8px;
    }

    .result-cell {
        min-width: 140px;
    }

    .row-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .modal {
        padding: 10px;
    }

    .modal-header {
        padding: 14px 14px;
    }

    .modal-header h3 {
        font-size: 18px;
    }

    .modal-body {
        padding: 14px;
    }

    .activity-editor-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
    }

    .activity-editor-row .btn {
        min-width: 44px;
        white-space: nowrap;
    }

    .activity-editor-add-row,
    .activity-editor-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .company-contacts-panel {
        padding: 12px;
    }

    .contact-card {
        padding: 12px;
    }

    .contact-card-grid {
        grid-template-columns: 1fr;
    }

    .contact-card-head {
        align-items: stretch;
    }

    .contact-card-head .btn {
        width: 100%;
    }

.contacts-box {
        padding: 12px;
    }

    .contacts-box h4 {
        font-size: 16px;
    }

    .modal-footer {
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .pagination {
        padding: 14px;
    }

    .calendar-grid,
    .calendar-weekdays {
        grid-template-columns: 1fr;
    }

    .calendar-day {
        min-height: auto;
    }

    .table-scroll {
        max-height: calc(100vh - 180px);
    }
}

@media (max-width: 420px) {
    .page {
        padding: 10px;
    }

    .brand {
        font-size: 20px;
    }

    .table-head h2 {
        font-size: 17px;
    }

    .crm-table {
        min-width: 1180px;
    }

    .crm-table td[data-col-key="client_name"],
    .crm-table th[data-col-key="client_name"] {
        min-width: 145px;
    }

    .phone-text {
        font-size: 12px;
    }

    .duplicate-badge,
    .deleted-mark {
        font-size: 11px;
    }
}
/* ===== ДОПОЛНИТЕЛЬНЫЕ КОНТАКТЫ В ТАБЛИЦЕ ===== */
.client-name-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 190px;
    z-index: 30;
    overflow: visible !important;
}

.extra-contacts-dropdown {
    position: relative;
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    z-index: 50;
    overflow: visible !important;
}

.extra-contacts-dropdown summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--primary);
    user-select: none;
}

.extra-contacts-dropdown summary::-webkit-details-marker {
    display: none;
}

.extra-contacts-dropdown summary:hover {
    text-decoration: underline;
}

.extra-contacts-arrow {
    transition: transform 0.2s ease;
    line-height: 1;
}

.extra-contacts-dropdown[open] .extra-contacts-arrow {
    transform: rotate(180deg);
}

.extra-contacts-panel {
    position: sticky;
    top: calc(100% + 8px);
    left: 0;
    z-index: 99999;
    min-width: 520px;
    max-width: min(760px, calc(100vw - 80px));
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.extra-contacts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.extra-contacts-table th {
    background: #f5f7fb;
    font-weight: 600;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
}

.extra-contacts-table td {
    padding: 8px;
    border-bottom: 1px solid #eef1f5;
    vertical-align: top;
    background: #fff;
}

.extra-contacts-table tr:last-child td {
    border-bottom: none;
}

.phone-list-compact {
    gap: 6px;
}

.phone-row-compact {
    align-items: center;
    gap: 8px;
}

.phone-row-compact .phone-text {
    font-size: 13px;
}

/* ВАЖНО: чтобы выпадашка не резалась таблицей */
.crm-table {
    overflow: visible !important;
}

.crm-table tbody tr,
.crm-table tbody td {
    overflow: visible !important;
}

.crm-table td[data-col-key="client_name"],
.crm-table th[data-col-key="client_name"] {
    overflow: visible !important;
}

@media (max-width: 900px) {
    .extra-contacts-panel {
        min-width: 420px;
        max-width: calc(100vw - 32px);
        left: 0;
    }
}

@media (max-width: 640px) {
    .extra-contacts-panel {
        min-width: 320px;
        max-width: calc(100vw - 24px);
        left: 0;
    }

    .extra-contacts-table {
        font-size: 12px;
    }

    .extra-contacts-table th,
    .extra-contacts-table td {
        padding: 6px;
    }
}

/* ===== МОДАЛКА РОЗСИЛКИ / СФЕРА ДІЯЛЬНОСТІ ===== */

.dropdown-checklist-menu-mailing {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.mailing-activity-search-wrap {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    padding: 10px 10px 8px;
    border-bottom: 1px solid var(--border);
}

.mailing-activity-search-input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
}

.mailing-activity-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.10);
}

.mailing-activity-dropdown .dropdown-checklist-menu {
    max-height: 320px;
    overflow: auto;
}

.mailing-activity-dropdown .dropdown-checklist-items {
    max-height: none;
    padding: 8px 10px 12px;
}

.mailing-field-help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.mailing-template-editor-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f9fbff;
    padding: 14px;
}

.mailing-template-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.mailing-template-editor-title {
    font-size: 16px;
    font-weight: 700;
}

.mailing-template-editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-danger-soft {
    border-color: #f3c7c5;
    color: #b42318;
    background: #fff5f5;
}

.mailing-template-editor-grid {
    display: grid;
    gap: 12px;
}

.mailing-template-editor-help {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.form-error.is-success {
    color: #0f7a38;
    background: #dff6e8;
    border: 1px solid #b7e8c8;
    border-radius: 10px;
    padding: 10px 12px;
}

@media (max-width: 1024px) {
    .mailing-modal-card {
        width: min(96vw, 860px);
        max-height: 92vh;
        overflow: auto;
    }
}

@media (max-width: 768px) {
    .mailing-modal-card {
        width: calc(100vw - 16px);
        max-width: none;
        padding: 14px;
        border-radius: 14px;
        max-height: calc(100vh - 16px);
    }

    .mailing-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .mailing-template-editor-head {
        align-items: stretch;
    }

    .mailing-template-editor-actions {
        width: 100%;
    }

    .mailing-template-editor-actions .btn {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 110px;
    }

    .modal-actions,
    .modal-footer {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .modal-actions .btn,
    .modal-footer .btn {
        width: 100%;
    }

    .mailing-activity-dropdown .dropdown-checklist-menu {
        max-height: 240px;
    }

    .mailing-activity-search-input,
    #mailingTemplateName,
    #mailingSubject,
    #mailingBody,
    #mailingTemplateSelect {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .mailing-template-editor-actions .btn {
        flex: 1 1 100%;
    }

    .mailing-template-editor-card {
        padding: 12px;
    }

    .mailing-activity-search-wrap {
        padding: 8px;
    }
}


/* Stream Telecom module */
.section-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.section-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 16px;
    border-radius: 999px;
    text-decoration: none;
    background: #eef2f7;
    color: var(--text);
    border: 1px solid transparent;
    font-weight: 700;
    transition: 0.2s ease;
}

.section-tab:hover {
    background: #e4ebf5;
}

.section-tab.active {
    background: #dce9ff;
    color: var(--primary);
    border-color: #bdd3ff;
}

.settings-wrap {
    max-width: 1180px;
    margin: 0 auto;
}

.settings-body {
    padding: 20px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.settings-form label span,
.manager-line-row span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 14px;
}

.settings-form input[type="text"],
.settings-form input[type="password"],
.settings-form select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    outline: none;
}

.settings-check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-check span {
    margin: 0;
    color: var(--text);
    font-weight: 700;
}

.form-grid.two {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 16px;
}

.stream-info-box {
    background: #f8fbff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.stream-info-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.stream-info-box code {
    display: block;
    white-space: normal;
    word-break: break-all;
    background: #fff;
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: 12px;
}

.manager-lines {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 14px;
}

.manager-line-row {
    display: block;
}

.settings-actions {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
}

.alert-success {
    background: var(--success);
    color: var(--success-text);
    border: 1px solid rgba(15, 122, 56, 0.2);
}

.muted {
    color: var(--muted);
}

.calls-scroll {
    max-height: calc(100vh - 230px);
}

.calls-table {
    min-width: 1200px;
}

.btn-sm {
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 10px;
    margin: 2px 0;
}

@media (max-width: 760px) {
    .form-grid.two,
    .manager-lines {
        grid-template-columns: 1fr;
    }

    .section-tabs {
        width: 100%;
    }

    .section-tab {
        flex: 1;
    }
}

.stat-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.stat-card-link:hover {
    transform: translateY(-1px);
}

.row-call-missed td {
    background: #fff0ef;
}

.call-status-missed {
    cursor: pointer;
    background: #fde2e1;
    color: #b42318;
}

.calls-table th,
.calls-table td {
    white-space: nowrap;
}
@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }

    .stat-card {
        padding: 12px 10px;
        border-radius: 12px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-label {
        font-size: 12px;
        line-height: 1.2;
    }
}

@media (max-width: 520px) {
    .stats-grid {
        gap: 6px;
    }

    .stat-card {
        padding: 10px 6px;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-label {
        font-size: 10px;
    }
}

/* Міні-плеєр запису дзвінка: винесений вниз, щоб не розсувати таблицю */
.call-mini-player {
    position: fixed;
    right: 24px;
    bottom: 18px;
    z-index: 9999;
    width: min(360px, calc(100vw - 32px));
    padding: 10px 42px 10px 12px;
    border: 1px solid #d7e2f0;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.call-mini-player[hidden] {
    display: none !important;
}

.call-mini-title {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
}

.call-mini-audio {
    display: block;
    width: 100%;
    height: 32px;
}

.call-mini-close {
    position: absolute;
    top: 7px;
    right: 9px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    background: #eef2f7;
    color: #0f172a;
    font-size: 20px;
    line-height: 24px;
    cursor: pointer;
}

.call-mini-close:hover {
    background: #dbeafe;
}

@media (max-width: 640px) {
    .call-mini-player {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
    }
}

.call-resolved-info {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.35;
    color: #64748b;
}

.duplicate-badge.merge-duplicates-btn {
    border: 0;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.merge-modal-content {
    width: min(1280px, 98vw);
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: #fff;
}

.merge-duplicates-table-wrap {
    margin-top: 14px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    max-height: 62vh;
}

.merge-duplicates-table {
    width: 100%;
    min-width: 900px;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 14px;
    background: #fff;
}

.merge-duplicates-table th,
.merge-duplicates-table td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 12px 14px;
    vertical-align: top;
    background: #fff;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.merge-duplicates-table th:first-child,
.merge-duplicates-table td:first-child {
    width: 210px;
    position: sticky;
    left: 0;
    z-index: 2;
}

.merge-duplicates-table th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f7f9fc;
}

.merge-duplicates-table th:first-child {
    z-index: 4;
}

.merge-duplicates-table th:last-child,
.merge-duplicates-table td:last-child {
    border-right: 0;
}

.merge-duplicates-table tbody tr:last-child td {
    border-bottom: 0;
}

.merge-main-choice,
.merge-value-choice {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 10px;
    align-items: flex-start;
    cursor: pointer;
    line-height: 1.35;
}

.merge-main-choice input,
.merge-value-choice input {
    margin-top: 2px;
}

.merge-value-choice span {
    display: block;
    min-width: 0;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.merge-value-choice em {
    color: #64748b;
}

@media (max-width: 900px) {
    .merge-modal-content {
        width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .merge-duplicates-table {
        min-width: 820px;
        font-size: 13px;
    }

    .merge-duplicates-table th:first-child,
    .merge-duplicates-table td:first-child {
        width: 170px;
    }
}


/* Users/Profile/CRM table settings */
.settings-page {
    padding: 0;
}

.settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.settings-header h1 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.15;
}

.settings-subtitle {
    color: var(--muted);
    font-size: 14px;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.settings-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.settings-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
    background: #fff;
}

.settings-table th,
.settings-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.settings-table th {
    background: #f8fafc;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.settings-table tr:last-child td {
    border-bottom: 0;
}

.settings-cell-center {
    width: 90px;
    text-align: center;
}

.settings-key {
    font-family: monospace;
    color: #475569;
    font-size: 13px;
}

.settings-input,
.settings-field input,
.settings-field select,
.settings-field textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    box-sizing: border-box;
}

.settings-input-small {
    max-width: 140px;
}

.settings-new-row td {
    background: #eff6ff;
}

.settings-form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.user-form-card {
    max-width: 1100px;
}

.user-form-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.user-form-avatar-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
}

.profile-avatar,
.profile-avatar-placeholder {
    width: 118px;
    height: 118px;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    color: var(--text);
    font-size: 42px;
    font-weight: 700;
}

.settings-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 16px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.settings-field span,
.settings-block-title {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}

.settings-field-file {
    width: 100%;
}

.settings-field-file input {
    font-size: 13px;
}

.settings-block {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fbfdff;
}

.settings-check-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 10px 16px;
    margin-top: 12px;
}

.settings-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
}

.settings-check-row input {
    width: auto;
    min-height: auto;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

@media (max-width: 900px) {
    .settings-header,
    .user-form-layout {
        display: block;
    }

    .settings-actions,
    .user-form-avatar-panel {
        margin-top: 12px;
    }

    .settings-form-grid,
    .settings-check-grid {
        grid-template-columns: 1fr;
    }
}

/* language active state */
.topbar-actions .btn.active,
.topbar-actions .btn-light.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* Settings index cards */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(220px, 1fr));
    gap: 14px;
    align-items: stretch;
    margin-top: 16px;
}

.settings-link-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 104px;
    text-decoration: none;
    color: var(--text);
}

.settings-link-card:hover {
    border-color: #bfdbfe;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.settings-card-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eef6ff;
    color: #1d4ed8;
    font-size: 20px;
    line-height: 1;
}

.settings-card-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.settings-card-text {
    font-size: 13px;
    line-height: 1.35;
    color: var(--muted);
}

@media (max-width: 1200px) {
    .settings-grid {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 640px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* Mail / Mailing module - перенос старой модели рассылки */
.mailing-old-card {
    padding: 16px;
}

.mailing-note-box {
    background: #f4f7fb;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    color: var(--text);
    line-height: 1.45;
}

.mailing-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.mailing-form-grid .full-width {
    grid-column: 1 / -1;
}

.dropdown-checklist {
    position: relative;
}

.dropdown-checklist-toggle {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    text-align: left;
}

.dropdown-checklist-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-checklist-arrow {
    color: var(--muted);
    flex: 0 0 auto;
}

.dropdown-checklist-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14);
    overflow: hidden;
}

.dropdown-checklist.open .dropdown-checklist-menu {
    display: block;
}

.dropdown-checklist-items {
    max-height: 260px;
    overflow: auto;
    padding: 8px;
}

.dropdown-checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
}

.dropdown-checklist-item:hover {
    background: #f4f7fb;
}

.mailing-activity-search-wrap {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    padding: 10px 10px 8px;
    border-bottom: 1px solid var(--border);
}

.mailing-activity-search-input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
}

.mailing-activity-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.10);
}

.mailing-activity-dropdown .dropdown-checklist-menu {
    max-height: 320px;
    overflow: auto;
}

.mailing-activity-dropdown .dropdown-checklist-items {
    max-height: none;
    padding: 8px 10px 12px;
}

.mailing-field-help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.mailing-template-editor-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f9fbff;
    padding: 14px;
}

.mailing-template-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.mailing-template-editor-title {
    font-size: 16px;
    font-weight: 700;
}

.mailing-template-editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-danger-soft {
    border-color: #f3c7c5;
    color: #b42318;
    background: #fff5f5;
}

.mailing-template-editor-grid {
    display: grid;
    gap: 12px;
}

.mailing-template-editor-help,
.mailing-preview-hint {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.mailing-preview-actions {
    margin-top: 12px;
}

.mailing-recipients-preview {
    margin-top: 14px;
}

.mailing-footer-actions {
    margin-top: 14px;
}

.form-error.is-success {
    color: #0f7a38;
    background: #dff6e8;
    border: 1px solid #b7e8c8;
    border-radius: 10px;
    padding: 10px 12px;
}

@media (max-width: 768px) {
    .mailing-form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .mailing-template-editor-head {
        align-items: stretch;
    }

    .mailing-template-editor-actions {
        width: 100%;
    }

    .mailing-template-editor-actions .btn {
        flex: 1 1 calc(33.333% - 6px);
        min-width: 110px;
    }

    .mailing-footer-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .mailing-footer-actions .btn {
        width: 100%;
    }

    .mailing-activity-dropdown .dropdown-checklist-menu {
        max-height: 240px;
    }

    .mailing-activity-search-input,
    #mailingTemplateName,
    #mailingSubject,
    #mailingBody,
    #mailingTemplateSelect {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .mailing-template-editor-actions .btn {
        flex: 1 1 100%;
    }

    .mailing-template-editor-card {
        padding: 12px;
    }

    .mailing-activity-search-wrap {
        padding: 8px;
    }
}

.app-footer{margin-top:28px;padding:14px 0 4px;color:#64748b;font-size:12px;text-align:center;}

.mail-pagination{display:flex;align-items:center;justify-content:center;gap:8px;padding:8px;border-top:1px solid #d8e1ee;background:#fbfdff}
.mail-pagination span{font-weight:700;color:#334155;min-width:34px;text-align:center}
.mail-pagination .is-disabled{opacity:.45;pointer-events:none}
.mail-search-form select.mail-sort-select{min-width:92px}

/* LOGIN BITRIX-LIKE */
.bitrix-login-body {
    background: radial-gradient(circle at 20% 20%, #4aa3ff 0, rgba(74, 163, 255, 0) 28%), linear-gradient(135deg, #1c5fd8 0%, #2e89ff 48%, #f5f8ff 48%, #eef3fb 100%);
}
.bitrix-login-shell {
    width: min(980px, 100%);
    min-height: 560px;
    display: grid;
    grid-template-columns: 1.1fr 430px;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 34px 90px rgba(15, 23, 42, 0.22);
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.55);
}
.bitrix-login-side {
    padding: 52px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(145deg, rgba(17, 86, 217, .95), rgba(59, 150, 255, .9));
}
.bitrix-login-brand {font-size: 38px;font-weight: 900;margin-bottom: 24px;letter-spacing: -.03em;}
.bitrix-login-title {font-size: 28px;font-weight: 800;margin-bottom: 12px;}
.bitrix-login-text {font-size: 16px;line-height: 1.5;max-width: 430px;color: rgba(255,255,255,.82);}
.bitrix-login-dots {display:flex;gap:10px;margin-top:34px}.bitrix-login-dots span{width:12px;height:12px;border-radius:50%;background:rgba(255,255,255,.55)}
.bitrix-login-card {width:100%;border-radius:0;box-shadow:none;border:0;padding:44px 38px;display:flex;flex-direction:column;justify-content:center;}
.bitrix-login-card .login-language-switch {position:absolute;right:24px;top:22px;display:flex;gap:6px;}
.bitrix-login-card .login-logo {color:#13243a;font-size:28px;}
@media(max-width:820px){.bitrix-login-shell{grid-template-columns:1fr;min-height:0}.bitrix-login-side{display:none}.bitrix-login-card{border-radius:22px}}

/* v17.1 footer fix */
.page{min-height:100vh;display:flex;flex-direction:column;}
.page > .app-footer{margin-top:auto;padding-top:18px;padding-bottom:10px;}
.bitrix-login-body{position:relative;flex-direction:column;}
.bitrix-login-body .app-footer{position:fixed;left:0;right:0;bottom:12px;margin:0;padding:0;text-align:center;color:#64748b;font-size:12px;z-index:5;}
@media(max-height:720px){.bitrix-login-body .app-footer{position:static;margin-top:12px;}}

/* DASHBOARD FEED V1 */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.feed-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.feed-main-column,
.feed-side-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.feed-composer {
    overflow: hidden;
}

.feed-composer-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 14px;
    background: linear-gradient(180deg, #fbfdff 0%, #f2f6fb 100%);
    border-bottom: 1px solid var(--border);
}

.feed-composer-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: #526171;
    font-size: 14px;
    font-weight: 700;
    padding: 14px 12px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.feed-composer-tab:hover,
.feed-composer-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.feed-composer-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px;
}

.feed-composer-placeholder {
    width: 100%;
    min-height: 54px;
    border: 1px solid #dbe5f0;
    border-radius: 14px;
    background: #f8fbff;
    color: #7b8794;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 15px;
}

.feed-title-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 4px 2px 2px;
}

.feed-title-panel h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.15;
}

.feed-title-panel p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.feed-filter-pill {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border-radius: 999px;
    color: #526171;
    background: #eef4fb;
    border: 1px solid #dbe5f0;
    font-weight: 700;
    white-space: nowrap;
}

.feed-post-card {
    padding: 18px;
}

.feed-post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.feed-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dce9ff;
    color: var(--primary-dark);
    font-weight: 800;
    flex: 0 0 auto;
}

.feed-avatar-user {
    background: #e8f0ff;
}

.feed-avatar-system {
    background: #eaf7ee;
    color: #177245;
}

.feed-avatar-news {
    background: #fff3cd;
    color: #8a6d1f;
}

.feed-post-author {
    font-weight: 800;
    color: #1f2a37;
}

.feed-post-date {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.feed-post-body h2 {
    margin: 10px 0 8px;
    font-size: 19px;
}

.feed-post-body p {
    margin: 0;
    color: #4b5563;
    line-height: 1.55;
}

.feed-post-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: #eef6ff;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
}

.feed-post-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #eef2f7;
}

.feed-post-actions button {
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: #f1f5f9;
    color: #526171;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.feed-post-actions button:hover {
    background: #e4ebf5;
    color: var(--primary-dark);
}

.feed-process-card {
    border-left: 4px solid #8bd59d;
}

.feed-widget {
    padding: 16px;
}

.feed-widget-title {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 12px;
}

.feed-widget-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid #eef2f7;
    color: #526171;
}

.feed-widget-row:first-of-type {
    border-top: 0;
}

.feed-widget-row strong {
    color: var(--text);
}

.feed-empty {
    color: var(--muted);
    background: #f8fbff;
    border: 1px dashed #dbe5f0;
    border-radius: 12px;
    padding: 14px;
    font-size: 14px;
}

.feed-timeline-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 14px;
}

.feed-timeline-row span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
}

@media (max-width: 1100px) {
    .feed-shell {
        grid-template-columns: 1fr;
    }

    .feed-side-column {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .feed-composer-tabs,
    .feed-title-panel,
    .feed-post-actions {
        align-items: stretch;
    }

    .feed-composer-tabs,
    .feed-post-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .feed-title-panel {
        flex-direction: column;
    }

    .feed-filter-pill {
        width: 100%;
    }

    .feed-side-column {
        display: flex;
    }
}

/* Mailing UI hotfix v1 - dropdown не перекрывает поля ниже */
.mailing-old-card {
    padding: 0;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid #dbe5f0;
    border-radius: 16px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
    overflow: visible;
}

.mailing-old-card > form,
.mailing-old-card > .mailing-note-box {
    margin-left: 0;
    margin-right: 0;
}

.mailing-note-box {
    margin: 0 0 14px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(248, 251, 255, 0.94), rgba(255, 255, 255, 0.94));
    border-color: #dbe5f0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.mailing-form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
}

.mailing-form-grid label > span {
    display: block;
    margin-bottom: 7px;
    font-weight: 800;
    color: #1f2a37;
}

.mailing-form-grid input[type="text"],
.mailing-form-grid input[type="file"],
.mailing-form-grid select,
.mailing-form-grid textarea,
.mailing-activity-search-input,
.dropdown-checklist-toggle {
    border-color: #d6e0ec;
    border-radius: 12px;
    background-color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.dropdown-checklist-toggle {
    min-height: 46px;
}

.mailing-activity-dropdown.open .dropdown-checklist-menu {
    position: static;
    display: block;
    margin-top: 6px;
    max-height: 360px;
    overflow: auto;
    border-radius: 14px;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.10);
}

.mailing-activity-dropdown .dropdown-checklist-items {
    padding: 8px 14px 14px;
}

.mailing-activity-dropdown .dropdown-checklist-item {
    min-height: 34px;
    padding: 7px 8px;
    color: #223044;
    font-weight: 700;
}

.mailing-activity-dropdown .dropdown-checklist-item input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.mailing-template-editor-card {
    background: linear-gradient(180deg, rgba(249, 251, 255, 0.98), rgba(255, 255, 255, 0.98));
    border-color: #dbe5f0;
    border-radius: 16px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.mailing-preview-actions,
.mailing-footer-actions {
    padding: 16px;
    border: 1px solid #e0e7f0;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.mailing-footer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.mailing-footer-actions .btn-primary {
    min-width: 190px;
}

.mailing-preview-hint {
    margin: 14px 0 0;
    padding: 10px 12px;
    border: 1px solid #e0e7f0;
    border-radius: 12px;
    background: #f8fbff;
}

@media (max-width: 768px) {
    .mailing-footer-actions {
        align-items: stretch;
    }

    .mailing-activity-dropdown.open .dropdown-checklist-menu {
        max-height: 280px;
    }
}

/* Mailing UI v2: centered Bitrix-like layout, no logic changes */
.mailing-page {
    max-width: 1680px;
    margin: 0 auto;
    padding-left: 22px;
    padding-right: 22px;
}

.mailing-page .crm-header {
    max-width: 100%;
}

.mailing-page .mailing-old-card {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding: 22px;
}

.mailing-page .mailing-note-box,
.mailing-page .mailing-template-editor-card,
.mailing-page .mailing-preview-hint,
.mailing-page .mailing-preview-actions,
.mailing-page .mailing-footer-actions {
    max-width: 100%;
}

.mailing-page .mailing-template-editor-card {
    padding: 18px;
}

.mailing-page .mailing-template-editor-head {
    align-items: center;
    gap: 14px;
    padding-bottom: 12px;
}

.mailing-page .mailing-template-editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mailing-variable-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mailing-variable-title {
    font-weight: 700;
    color: #475569;
}

.mailing-variable-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mailing-variable-chips code {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border: 1px solid #dbe5f0;
    border-radius: 999px;
    background: #ffffff;
    color: #2563eb;
    font-size: 12px;
    font-weight: 700;
}

@media (min-width: 1800px) {
    .mailing-page {
        max-width: 1760px;
    }
}

@media (max-width: 900px) {
    .mailing-page {
        padding-left: 12px;
        padding-right: 12px;
    }

    .mailing-page .mailing-old-card {
        padding: 14px;
    }
}

/* Mailing UI v3: full-width like CRM/Mail, без левого mail sidebar */
.mailing-page {
    width: 100%;
    max-width: none;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
}

.mailing-page .crm-header {
    width: 100%;
    max-width: none;
}

.mailing-page .mailing-old-card {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding: 18px;
}

.mailing-page .mailing-form-grid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.66fr);
    align-items: start;
}

.mailing-page .mailing-form-grid .full-width,
.mailing-page .mailing-template-editor-card {
    grid-column: 1 / -1;
}

.mailing-page .mailing-template-editor-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.mailing-page .mailing-template-editor-grid label.full-width:has(textarea) {
    grid-column: 1 / -1;
}

.mailing-page .mailing-preview-actions,
.mailing-page .mailing-footer-actions {
    width: 100%;
}

@media (max-width: 900px) {
    .mailing-page .mailing-form-grid,
    .mailing-page .mailing-template-editor-grid {
        grid-template-columns: 1fr;
    }

    .mailing-page .mailing-old-card {
        padding: 14px;
    }
}

/* Calls journal restore after v11 pagination */
.calls-page {
    width: 100%;
    max-width: 100%;
}

.calls-header,
.calls-header-compact {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 16px;
}

.calls-header h1,
.calls-header-compact h1 {
    margin: 0 0 6px;
    font-size: 28px;
    line-height: 1.15;
}

.calls-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.calls-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.calls-stat {
    min-width: 130px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.calls-stat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.calls-stat strong {
    font-size: 22px;
    line-height: 1;
}

.calls-filter-card,
.calls-table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.calls-filter-card {
    padding: 16px;
}

.calls-filter-grid,
.calls-filter-grid-legacy {
    display: grid;
    grid-template-columns: minmax(220px, 1.1fr) minmax(170px, 1fr) minmax(170px, 1fr) minmax(170px, 1fr) minmax(110px, .45fr);
    gap: 12px;
    align-items: end;
}

.calls-filter-grid label span,
.calls-filter-grid-legacy label span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

.calls-filter-grid input,
.calls-filter-grid select,
.calls-filter-grid-legacy input,
.calls-filter-grid-legacy select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    outline: none;
    min-height: 42px;
}

.calls-filter-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.calls-table-card {
    overflow: hidden;
}

.calls-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.calls-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    font-size: 14px;
}

.calls-table th,
.calls-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    text-align: left;
    white-space: nowrap;
}

.calls-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fafc;
    font-size: 12px;
    color: #334155;
}

.calls-table tbody tr:hover {
    background: var(--hover);
}

.calls-nowrap {
    white-space: nowrap;
}

.calls-muted {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}

.calls-empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 12px !important;
}

.row-call-missed td {
    background: #fff0ef;
}

.call-status-missed {
    cursor: pointer;
    background: #fde2e1;
    color: #b42318;
}

.calls-page .phone-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.calls-page .phone-number {
    font-weight: 700;
    white-space: nowrap;
}

.calls-page .phone-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.calls-page .phone-icon-btn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid #dbe2ea;
    border-radius: 7px;
    background: #fff;
    color: #111827;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.calls-page .phone-icon-btn:hover {
    background: #f3f6fb;
    transform: none;
}

.calls-page .copy-phone {
    font-size: 14px;
}

.calls-page .tg-link i,
.calls-page .viber-link i {
    font-size: 15px;
}

.calls-page .call-record-box {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.calls-page .call-play-btn.is-playing {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.calls-page .call-resolved-info {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}

.calls-pagination-crm {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: #fbfdff;
}

.calls-pagination-info {
    color: var(--muted);
    font-size: 13px;
}

.calls-pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.calls-page-link,
.calls-page-current {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 9px;
    border-radius: 10px;
    border: 1px solid #dbe2ea;
    background: #eef2f7;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
}

.calls-page-link:hover {
    background: #e5eefb;
}

.calls-page-current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.calls-page-disabled {
    opacity: .45;
    pointer-events: none;
}

.calls-page .call-mini-player {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
    padding: 14px 44px 14px 14px;
    z-index: 1000;
}

.calls-page .call-mini-player[hidden] {
    display: none;
}

.calls-page .call-mini-title {
    font-weight: 800;
    margin-bottom: 8px;
}

.calls-page .call-mini-audio {
    width: 100%;
}

.calls-page .call-mini-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 8px;
    background: #eef2f7;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.calls-page .call-mini-close:hover {
    background: #e2e8f0;
}

@media (max-width: 1200px) {
    .calls-filter-grid,
    .calls-filter-grid-legacy {
        grid-template-columns: repeat(3, minmax(140px, 1fr));
    }
}

@media (max-width: 760px) {
    .calls-header,
    .calls-header-compact {
        align-items: flex-start;
        flex-direction: column;
    }
    .calls-filter-grid,
    .calls-filter-grid-legacy {
        grid-template-columns: 1fr;
    }
    .calls-pagination-crm {
        align-items: flex-start;
        flex-direction: column;
    }
    .calls-page .call-mini-player {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        max-width: none;
    }
}


/* CRM legacy task state row accents: добавлено без замены глобальных стилей */
.crm-table tbody tr.row-task-overdue:not(.row-deleted):not(.row-duplicate) td {
    background: #fff6f5;
}

.crm-table tbody tr.row-task-today:not(.row-deleted):not(.row-duplicate) td {
    background: #fffbea;
}

.crm-table tbody tr.row-task-planned:not(.row-deleted):not(.row-duplicate) td {
    background: #f6fbf4;
}

.crm-table tbody tr.row-task-done:not(.row-deleted):not(.row-duplicate) td {
    background: #f7fbff;
}

.crm-table tbody tr.row-task-overdue:hover td,
.crm-table tbody tr.row-task-today:hover td,
.crm-table tbody tr.row-task-planned:hover td,
.crm-table tbody tr.row-task-done:hover td {
    background: var(--hover);
}
