/* ============================================
   CRM PROTOTYPE — С ТЕМНОЙ ТЕМОЙ
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Shared operation-center palette, from crm-operations.html. */
    --primary: #365fc3;
    --primary-dark: #294da2;
    --primary-light: #315dba;
    --success: #187b50;
    --warning: #926011;
    --danger: #b33946;
    --info: #315dba;
    --bg: #e6ebf0;
    --surface: #f2f4f7;
    --on-action: #dce5ef;
    --action-primary: #3156a4;
    --action-success: #236548;
    --action-danger: #9b3844;
    --action-warning: #79541c;
    --nav: #edf0f4;
    --raised: #e8edf2;
    --text: #48576a;
    --support-heading: #9144d5;
    --support-subheading: #b77f00;
    --text-muted: #596879;
    --text-secondary: var(--text-muted);
    --border: #d7deea;
    --scroll-thumb: #718196;
    --scroll-hover: #65768c;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 7px;
    --radius-sm: 5px;
}

/* Темная тема */
[data-theme="dark"] {
    color-scheme: dark;
    background-color: var(--bg) !important;
    --primary: #456bcb;
    --primary-dark: #3656a8;
    --primary-light: #8baaff;
    --success: #76d1a6;
    --warning: #edbd72;
    --danger: #f18a91;
    --info: #8baaff;
    --bg: #14171d;
    --surface: #1b2029;
    --nav: #191e27;
    --raised: #232b38;
    --text: #bcc6d4;
    --support-heading: #dfaaff;
    --support-subheading: #ffdc75;
    --text-muted: #98a5b7;
    --border: #303948;
    --scroll-thumb: #60758f;
    --scroll-hover: #7890ad;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    min-height: 100vh;
    transition: background 0.2s, color 0.2s;
}

/* ============================================
   ОДНОСТРОЧНАЯ ВЕРХНЯЯ ПАНЕЛЬ
   ============================================ */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar {
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 24px;
    flex-wrap: nowrap;
    transition: background 0.2s, border-color 0.2s;
}

.sidebar-header {
    display: flex;
    align-items: center;
    margin-right: 12px;
    padding: 0;
    border: none;
}

.sidebar-logo {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    white-space: nowrap;
    text-decoration: none;
}
a.sidebar-logo { cursor: pointer; }

.sidebar-logo .logo-icon {
    width: 26px;
    height: 26px;
    background: var(--action-primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--on-action);
}

.sidebar-subtitle {
    display: none;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin-bottom: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 7px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-link.active {
    background: var(--raised);
    color: var(--primary-light);
    box-shadow: inset 0 -2px var(--primary-light);
}

.nav-link .icon {
    font-size: 14px;
}

.nav-section {
    display: none;
}

/* Кнопка переключения темы */
.theme-toggle {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg);
    transform: scale(1.1);
}

/* Single navigation list: inline desktop tabs, accessible mobile dropdown.
   Its original permission-filtered links are never cloned. */
.crm-nav-toggle { display:none; }
@media (max-width:1050px) {
    .app { min-width:0; max-width:100%; }
    .sidebar {
        width:100%;
        min-width:0;
        max-width:100%;
        padding:0 8px;
        gap:8px;
    }
    .sidebar-header { display:none; }
    .sidebar .crm-nav-toggle {
        display:flex;
        flex:1 1 auto;
        min-width:0;
        max-width:100%;
        height:36px;
        align-items:center;
        justify-content:space-between;
        gap:8px;
        padding:5px 10px;
        border:1px solid var(--border);
        border-radius:7px;
        background:var(--surface);
        color:var(--text);
        font-size:13px;
        font-family:inherit;
        font-weight:600;
        line-height:1.3;
        cursor:pointer;
    }
    .sidebar .crm-nav-toggle-label {
        overflow:hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
    }
    .sidebar .crm-nav-toggle:focus-visible {
        outline:2px solid var(--primary);
        outline-offset:2px;
    }
    .sidebar .crm-nav-toggle-chevron { flex:none; }
    .sidebar .nav-menu {
        display:none;
        position:absolute;
        left:8px;
        right:8px;
        top:calc(100% + 3px);
        z-index:101;
        width:auto;
        max-height:min(65dvh,440px);
        overflow-y:auto;
        overflow-x:hidden;
        overscroll-behavior:contain;
        padding:7px;
        margin:0;
        flex-direction:column;
        align-items:stretch;
        gap:2px;
        background:var(--surface);
        border:1px solid var(--border);
        border-radius:9px;
        box-shadow:var(--shadow-lg);
    }
    .sidebar.crm-nav-open .nav-menu { display:flex; }
    .sidebar .nav-menu .nav-item { flex:none; }
    .sidebar .nav-menu .nav-link {
        display:flex;
        min-height:39px;
        width:100%;
        white-space:normal;
        padding:9px 11px;
    }
    .sidebar .user-profile {
        flex:0 0 auto;
        gap:4px;
        margin-left:0;
    }
    .sidebar #current-username { display:none; }
    .sidebar .user-btn { padding:5px 7px; }
    .main { min-width:0; }
}

/* ============================================
   ОСНОВНОЙ КОНТЕНТ
   ============================================ */
.main {
    flex: 1;
    width: 100%;
    padding: 16px 19px;
    min-width: 0;
}

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

.page-title {
    font-size: 21px;
    font-weight: 600;
    color: var(--text);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

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

/* ============================================
   КАРТОЧКИ
   ============================================ */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 13px;
    box-shadow: none;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    transition: background 0.2s, border-color 0.2s;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon {
    font-size: 18px;
}

/* ============================================
   КНОПКИ
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-primary {
    background: var(--action-primary);
    color: var(--on-action);
}

.btn-primary:hover {
    background: #29477f;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
}

.btn-success { background: var(--action-success); color: var(--on-action); }
.btn-success:hover { background: #12663f; }
.btn-danger { background: var(--action-danger); color: var(--on-action); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ============================================
   ТАБЛИЦЫ
   ============================================ */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

thead {
    background: var(--bg);
}

th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 11px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tbody tr {
    transition: background 0.1s;
}

tbody tr:hover {
    background: var(--bg);
    cursor: pointer;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   БЕЙДЖИ
   ============================================ */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary { background: #eef2ff; color: var(--primary-dark); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-muted { background: #f1f5f9; color: var(--text-muted); }

[data-theme="dark"] .badge-primary { background: #1e3a8a; color: var(--primary-light); }
[data-theme="dark"] .badge-success { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-warning { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .badge-danger { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-info { background: #1e3a8a; color: var(--primary-light); }
[data-theme="dark"] .badge-muted { background: #334155; color: #cbd5e1; }

/* ============================================
   ФОРМЫ
   ============================================ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-label .required { color: var(--danger); }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: all 0.15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

/* ============================================
   МОДАЛЬНЫЕ ОКНА
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 6px;
}

.modal-close:hover { color: var(--text); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ============================================
   УВЕДОМЛЕНИЯ
   ============================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

[data-theme="dark"] .alert-success { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
[data-theme="dark"] .alert-danger { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fcd34d; border-color: #92400e; }

/* ============================================
   СТАТИСТИКА
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

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

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin-top: 8px;
}

/* ============================================
   АНИМАЦИИ И УТИЛИТЫ
   ============================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

.loading { text-align: center; padding: 32px; color: var(--text-muted); }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ============================================
   ПРОФИЛЬ ПОЛЬЗОВАТЕЛЯ В МЕНЮ
   ============================================ */
.user-profile {
    margin-left: auto;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}

.user-btn:hover {
    background: var(--border);
}

.user-avatar {
    font-size: 16px;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}

.user-dropdown.active {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg);
    color: var(--danger);
}

/* ============================================
   ОБЩИЙ ВИЗУАЛЬНЫЙ СТАНДАРТ CRM
   ============================================ */
.crm-table-card { padding: 0; overflow: hidden; }
.crm-table-card .card-header { padding: 18px 20px; margin: 0; border-bottom: 1px solid var(--border); }
.crm-data-table { font-size: 12px; }
.crm-data-table thead { background: var(--raised); }
.crm-data-table th { padding: 8px 10px; font-size: 11px; font-weight: 500; border-bottom: 1px solid var(--border); }
.crm-data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.crm-data-table tbody tr:last-child td { border-bottom: none; }
.crm-data-table tbody tr:hover { background: var(--bg); }
.crm-data-table .date-cell { min-width: 105px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.crm-data-table .date-main,
.crm-data-table .date-time { display: inline; color: var(--text-muted); font-size: 12px; font-weight: 500; opacity: 1; margin: 0; white-space: nowrap; }
.crm-data-table .date-time:not(:empty) { margin-left: 5px; }
.crm-data-table .name-cell { min-width: 180px; max-width: 340px; }
.crm-data-table .name-cell .cell-value { color: var(--text); font-weight: 600; line-height: 1.35; }
.crm-data-table .subtle-text { color: var(--text-muted); font-size: 12px; }
.crm-data-table .inline-select { font-family: inherit; font-size: 12px; color: var(--text-muted); padding: 5px 20px 5px 5px; border: 1px solid transparent; border-radius: 6px; max-width: 220px; text-overflow: ellipsis; }
.crm-data-table .inline-select:hover, .crm-data-table .inline-select:focus { color: var(--text); background: var(--bg); border-color: var(--border); }
.crm-data-table .inline-select option { color: var(--text); background: var(--surface); }
.crm-data-table .row-actions { width: 110px; white-space: nowrap; text-align: right; }
.crm-data-table .row-action { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 1px solid transparent; background: transparent; border-radius: 6px; color: var(--text-muted); font-size: 14px; cursor: pointer; }
.crm-data-table .row-action:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.crm-data-table .row-action:focus-visible, .crm-data-table .inline-select:focus-visible, .crm-data-table .edit-icon:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.crm-data-table .row-action:disabled { opacity: .35; cursor: not-allowed; }
.crm-data-table .edit-icon { color: var(--text-muted); right: -14px; }
.crm-data-table .editable-cell:focus-within .edit-icon { display: block; }
.crm-data-table .row-status-new { color: var(--text-muted); }
.crm-data-table .row-status-active { color: var(--primary); }
.crm-data-table .row-status-regular { color: var(--success); }
.crm-data-table .row-status-spam { color: var(--danger); }
.crm-data-table .text-right { text-align: right; }
.crm-data-table td.text-right { font-variant-numeric: tabular-nums; }
.crm-task-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.crm-task-card .task-title { font-size: 14px; color: var(--text); }
.crm-task-card .task-meta { font-size: 12px; color: var(--text-muted); }
@media (max-width: 900px) {
    .crm-table-card .card-header { padding: 14px 16px; }
    .crm-data-table td, .crm-data-table th { padding-left: 10px; padding-right: 10px; }
}

/* CRM: consistent readable links in all content journals and both themes. */
.main a:not(.btn):not(.btn-play):not(.nav-link),
.modal a:not(.btn),
.main .task-link {
    color: var(--primary-light);
    font-weight: 600;
    text-decoration: none;
    text-underline-offset: 3px;
}
:root:not([data-theme="dark"]) .main a:not(.btn):not(.btn-play):not(.nav-link),
:root:not([data-theme="dark"]) .modal a:not(.btn) {
    color: var(--primary-light);
}
.main a:not(.btn):not(.btn-play):not(.nav-link):hover,
.modal a:not(.btn):hover,
.main a:not(.btn):not(.btn-play):not(.nav-link):focus-visible,
.modal a:not(.btn):focus-visible {
    text-decoration: underline;
}
[data-theme="dark"] .main a:not(.btn):not(.btn-play):not(.nav-link),
[data-theme="dark"] .modal a:not(.btn),
[data-theme="dark"] .main .task-link {
    color: var(--primary-light);
}
[data-theme="dark"] .main a:not(.btn):not(.btn-play):not(.nav-link):hover,
[data-theme="dark"] .modal a:not(.btn):hover { color: #bfdbfe; }
.crm-modal-tabs { display:flex; gap:6px; border-bottom:1px solid var(--border); margin-bottom:16px; }
.crm-modal-tab {
    border:0; border-bottom:2px solid transparent; color:var(--text-muted);
    background:transparent; padding:10px 12px; cursor:pointer; font:inherit; font-weight:600;
}
.crm-modal-tab.active { border-bottom-color:var(--primary);color:var(--text); }
.crm-modal-tab:hover, .crm-modal-tab:focus-visible { color:var(--text); }
.crm-requisites-help { color:var(--text-muted); font-size:12px; margin-bottom:12px; }
#new-person-panel[hidden], #new-legal-panel[hidden] { display:none; }
#modal .modal { max-width:620px; }

/* Journal lists: navigation already names the section; reserve top area for actions. */
.journal-page > .topbar { justify-content:flex-end; margin-bottom:12px; min-height:0; }
.journal-page > .topbar .topbar-actions { margin-left:auto; }

/* Unified, responsive record-card tabs (counterparties, orders, calculations). */
.crm-card-tabs { margin: 12px 0 24px; min-width: 0; }
/* Settings and record cards share one tab appearance. */
.crm-card-tab-nav, .settings-tabs, .task-sections {
    display:flex; flex-wrap:nowrap; gap:6px; overflow-x:auto;
    scrollbar-width:thin; padding:0; margin-bottom:12px;
    border-bottom:1px solid var(--border);
}
.crm-card-tab, .settings-tab, .task-section-btn {
    flex:0 0 auto; border:0; border-bottom:2px solid transparent;
    border-radius:0; background:transparent; color:var(--text-muted);
    padding:11px 17px; cursor:pointer; font:inherit; font-size:14px;
    line-height:1.5; font-weight:400;
}
.crm-card-tab:hover, .settings-tab:hover, .task-section-btn:hover { color:var(--text); }
.crm-card-tab.active, .crm-card-tab[aria-selected="true"], .settings-tab.active, .task-section-btn.active {
    background:transparent; color:var(--text); border-bottom-color:var(--primary);
    font-weight:650;
}
.crm-card-tab:focus-visible, .settings-tab:focus-visible, .task-section-btn:focus-visible {
    outline:2px solid var(--border); outline-offset:-2px;
}
.crm-card-tab-panels { min-width: 0; }
.crm-card-tab-panel[hidden] { display: none !important; }
.crm-card-tab-panel { min-width: 0; }
.crm-card-tab-panel > .card { margin-bottom: 16px; }
.crm-card-tab-panel > .info-grid { margin: 0; }


/* CRM dialog refresh: wider desktop layout, compact spacing, controlled mobile fit. */
.modal-overlay.active { padding:12px; overflow-y:auto; box-sizing:border-box; }
.modal-overlay > .modal {
  box-sizing:border-box;
  width:min(860px,calc(100vw - 28px)) !important;
  max-width:860px !important;
  max-height:calc(100dvh - 24px);
  padding:16px 20px;
  overflow-y:auto;
  overscroll-behavior:contain;
}
.modal .modal-header { margin-bottom:11px; padding-bottom:9px; }
.modal .modal-footer { margin-top:12px; padding-top:9px; }
.modal .form-group { margin-bottom:9px; min-width:0; }
.modal .form-label { margin-bottom:4px; font-size:12px; }
.modal .form-input,.modal .form-select,.modal .form-textarea {
  box-sizing:border-box; min-width:0; padding:7px 10px; font-size:13px;
}
.modal .form-row { gap:8px 13px; }
/* Payment and adjustment forms share the single-column financial dialog.
   Do not place its expense category in a second outer grid column. */
#payment-form > .form-group > textarea { min-height:55px; }
@media(max-width:640px) {
  .modal-overlay { align-items:flex-start; }
  .modal-overlay > .modal { width:100% !important; max-width:100% !important; padding:14px; }
  .modal .form-row { grid-template-columns:1fr; }
}


/* A lighter elevated dialog surface in dark theme, without lightening the app. */
[data-theme="dark"] .modal-overlay > .modal {
  background:var(--surface);
  color:var(--text);
  border:1px solid var(--border);
  box-shadow:0 24px 72px rgba(0,0,0,.56);
}
[data-theme="dark"] .modal-overlay > .modal .modal-header,
[data-theme="dark"] .modal-overlay > .modal .modal-footer {
  border-color:#485c76;
}
[data-theme="dark"] .modal-overlay > .modal .form-label {
  color:#a5b4c8;
  font-weight:500;
}
[data-theme="dark"] .modal-overlay > .modal .modal-title {
  color:#bcc6d4;
}
[data-theme="dark"] .modal-overlay > .modal :is(
  .form-input,.form-select,.form-textarea,input:not([type="checkbox"]):not([type="radio"]),select,textarea
) {
  background:#232b38;
  color:#bcc6d4;
  border-color:#485365;
}
[data-theme="dark"] .modal-overlay > .modal :is(input,textarea)::placeholder {
  color:var(--text-muted);
  opacity:1;
}
[data-theme="dark"] .modal-overlay > .modal :is(.payment-stage-note,.calc-muted,.text-muted) {
  color:var(--text-muted);
}
[data-theme="dark"] .modal-overlay > .modal :is(input,select,textarea):disabled {
  background:#303d50;
  color:var(--text);
  opacity:1;
}
[data-theme="dark"] .modal-overlay > .modal :is(input,select,textarea):focus-visible {
  border-color:#93c5fd;
  outline:2px solid #93c5fd;
  outline-offset:1px;
}


/* One rule for ALL modal forms, regardless of screen size:
   captions stay LEFT of their corresponding controls. */
.modal-overlay > .modal .form-group:has(> .form-label) {
  display:grid;
  grid-template-columns:clamp(88px,23%,155px) minmax(0,1fr);
  column-gap:10px;
  row-gap:5px;
  align-items:center;
  min-width:0;
}
.modal-overlay > .modal .form-group:has(> .form-label) > .form-label {
  grid-column:1;
  margin:0 !important;
  width:auto;
  min-width:0;
  color:var(--text-muted) !important;
  font-size:12px;
  font-weight:500;
  line-height:1.35;
  overflow-wrap:anywhere;
  align-self:center;
}
.modal-overlay > .modal .form-group:has(> .form-label) > :not(.form-label) {
  grid-column:2;
  min-width:0;
  width:100%;
}
.modal-overlay > .modal .form-group:has(> .form-label) > input[type="hidden"] {
  display:none !important;
}
.modal-overlay > .modal .form-group:has(> .form-label) > :is(
  .payment-stage-note,.text-muted,.calc-muted,.crm-requisites-help
) {
  grid-column:2;
}
/* Two separate label/control pairs in one expense-category cell. */
#group-category.form-group,
#bank-edit-expense-group.form-group {
  display:grid;
  grid-template-columns:clamp(88px,23%,155px) minmax(0,1fr);
  gap:8px 10px;
  align-items:center;
}
#group-category > label:nth-of-type(1),
#bank-edit-expense-group > label:nth-of-type(1) {grid-column:1;grid-row:1}
#group-category > #payment-expense-group,
#bank-edit-expense-group > #bank-edit-category-group {grid-column:2;grid-row:1}
#group-category > label:nth-of-type(2),
#bank-edit-expense-group > label:nth-of-type(2) {grid-column:1;grid-row:2;margin:0!important}
#group-category > #payment-expense-category,
#bank-edit-expense-group > #bank-edit-category {grid-column:2;grid-row:2}
#group-category > #payment-expense-autofill {grid-column:2;grid-row:3}
/* Narrow view: keep the same left/right order; just narrow the label column. */
@media(max-width:700px) {
  .modal-overlay > .modal .form-group:has(> .form-label),
  #group-category.form-group,
  #bank-edit-expense-group.form-group {
    grid-template-columns:88px minmax(0,1fr);
    column-gap:8px;
  }
}


/* Light theme: inputs are slightly darker than the dialog, with clear edges. */
[data-theme="light"] .modal-overlay > .modal {
  background:var(--surface);
  border:1px solid var(--border);
  color:var(--text);
}
[data-theme="light"] .modal-overlay > .modal :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,textarea,.form-input,.form-select,.form-textarea
) {
  background:#e5ebf3;
  border-color:#a7b6c9;
  color:#48576a;
}
[data-theme="light"] .modal-overlay > .modal :is(input,textarea)::placeholder {
  color:#65768c;
  opacity:1;
}
[data-theme="light"] .modal-overlay > .modal :is(input,select,textarea):focus-visible {
  background:#dce8f7;
  border-color:#3b82f6;
  outline:2px solid rgba(59,130,246,.36);
  outline-offset:1px;
}
[data-theme="light"] .modal-overlay > .modal :is(input,select,textarea):disabled {
  background:#e2e8f0;
  border-color:#c6d0dc;
  color:#64748b;
  opacity:1;
}
[data-theme="light"] .modal-overlay > .modal .modal-title {
  color:#48576a;
}
[data-theme="light"] .modal-overlay > .modal .form-label {
  color:#52647a !important;
}

/* Shared journal counterparty links and non-invasive row selection. */
.crm-client-link{color:var(--primary-dark);font-weight:600;text-decoration:none;border-bottom:1px solid transparent}
.crm-client-link:hover,.crm-client-link:focus-visible{border-bottom-color:currentColor;text-decoration:none}
[data-theme="dark"] .crm-client-link{color:var(--primary-light)}
.crm-table-card tbody tr.crm-journal-row-selected>td,
#table-body tr.crm-journal-row-selected>td{background:color-mix(in srgb,var(--primary) 7%,var(--surface))!important}
.crm-table-card tbody tr.crm-journal-row-selected>td:first-child,
#table-body tr.crm-journal-row-selected>td:first-child{box-shadow:inset 3px 0 color-mix(in srgb,var(--primary) 58%,var(--surface))}

/* Fixed compact journal shell and sticky table headings 2026-11-07 */
@media (min-width: 721px){
  .main.journal-page{height:calc(100dvh - 50px);min-height:0;overflow:hidden;display:flex;flex-direction:column;}
  .main.journal-page > .crm-table-card{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden;}
  .main.journal-page > .crm-table-card > .table-wrapper{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;}
  .main.journal-page > #tasks-container{flex:1;min-height:0;overflow:auto;}
  .main.journal-page > section[role="tabpanel"]:not([hidden]){flex:1 1 auto;min-height:0;overflow:hidden;display:flex;flex-direction:column;}
  .main.journal-page > section[role="tabpanel"]:not([hidden]) > .card{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden;}
  .main.journal-page > section[role="tabpanel"]:not([hidden]) > .card > .table-wrapper{flex:1 1 auto;min-height:0;overflow:auto;}

}
.main.journal-page > .crm-table-card > .card-header:not(:has(.payments-sync-times)){display:none!important}
.main.journal-page > .crm-table-card > .card-header:has(.payments-sync-times){padding:4px 10px;margin:0;border-bottom:1px solid var(--border);}
.main.journal-page > .crm-table-card > .card-header .card-title{display:none!important}
.main.journal-page :is(.crm-data-table,.settings-source-table,.crm-table-card table) thead th,
.main.journal-page section[role="tabpanel"] .table-wrapper table thead th{position:sticky;top:0;z-index:4;background:var(--surface);box-shadow:0 1px 0 var(--border);}
.crm-phone-copy.crm-email-copy{margin-left:5px}


/* Calculation journal actions aligned with order actions */
.calc-row-actions {
    white-space: nowrap;
    vertical-align: middle;
}
.calc-row-actions .btn + .btn {
    margin-left: 5px;
}
.calc-row-actions .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 31px;
    min-height: 30px;
    text-decoration: none;
}


/* CRM unified rounded checkboxes */
input[type="checkbox"]:not([role="switch"]) {
  appearance:none;
  -webkit-appearance:none;
  box-sizing:border-box;
  display:inline-grid;
  place-content:center;
  width:17px;
  height:17px;
  min-width:17px;
  min-height:17px;
  margin:0 6px 0 0;
  vertical-align:middle;
  border:1px solid var(--border);
  border-radius:5px;
  background:var(--surface);
  color: var(--on-action);
  cursor:pointer;
}
input[type="checkbox"]:not([role="switch"])::after {
  content:"";
  width:8px;
  height:4px;
  border-left:2px solid currentColor;
  border-bottom:2px solid currentColor;
  transform:translateY(-1px) rotate(-45deg);
  opacity:0;
}
input[type="checkbox"]:not([role="switch"]):checked {
  background:var(--primary);
  border-color:var(--primary);
}
input[type="checkbox"]:not([role="switch"]):checked::after {
  opacity:1;
}
input[type="checkbox"]:not([role="switch"]):focus-visible {
  outline:2px solid var(--primary);
  outline-offset:3px;
}
input[type="checkbox"]:not([role="switch"]):disabled {
  opacity:.5;
  cursor:not-allowed;
}

/* Access role matrix — collapsible cards, same checkbox styling as CRM */
.access-intro { margin-bottom:14px; }
.access-intro .card-title { margin:0 0 6px; }
.access-intro p { margin:5px 0; font-size:13px; }
.access-role-grid {
 display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,335px),1fr));
 gap:14px; align-items:start;
}
.access-role-card {
 background:var(--surface); border:1px solid var(--border);
 border-radius:var(--radius); overflow:hidden;
}
.access-role-card.access-unsaved { border-color:var(--primary); }
.access-role-heading {
 display:flex; align-items:center; gap:10px; width:100%;
 text-align:left; padding:15px 17px; cursor:pointer;
 border:0; background:transparent; color:var(--text);
 font:inherit; font-size:14px; font-weight:650;
}
.access-role-heading:hover { background:var(--bg); }
.access-role-heading:focus-visible { outline:2px solid var(--primary); outline-offset:-2px; }
.access-role-count { margin-left:auto; white-space:nowrap; color:var(--text-muted); font-size:12px; font-weight:400; }
.access-role-chevron { font-size:18px; color:var(--text-muted); }
.access-role-body { border-top:1px solid var(--border); padding:12px 17px 16px; }
.access-role-group + .access-role-group { margin-top:14px; }
.access-group-heading { font-size:12px; font-weight:700; color:var(--text-muted); margin-bottom:8px; }
.access-check-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:8px 14px; }
.access-check-label { display:flex; align-items:center; gap:5px; font-size:13px; cursor:pointer; }
.access-role-footer { display:flex; align-items:center; justify-content:flex-end; gap:12px; margin-top:17px; }
.access-role-status { color:var(--text-muted); font-size:12px; }


/* Muted blue-ivory surfaces for the light theme; dark palette unchanged. */
:root:not([data-theme="dark"]) {
    color-scheme: light;
    background-color: var(--bg) !important;
}
:root:not([data-theme="dark"]) .main :is(.form-input,.form-select,.form-textarea) {
    background-color: var(--raised);
}

/* Common positioning and dimensions for action controls across CRM screens.
   Keep primary/danger/secondary semantics and existing click handlers intact. */
.main .topbar-actions,
.main .card-header .topbar-actions {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}
.main .topbar-actions > :is(.btn,button),
.main .card-header .topbar-actions > :is(.btn,button) {
    min-height: 34px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.35;
    white-space: nowrap;
}
.main .topbar-actions > .btn-sm,
.main .card-header .topbar-actions > .btn-sm {
    min-height: 32px;
}

/* The selected-counterparty toolbar uses the same action dimensions as topbars. */
/* Shared creation toolbar: counterparty and calculation journals use the SAME rules. */
.main .crm-journal-actionbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    overflow: visible;
    padding: 2px 0 5px;
}
.crm-action-label { font-size:13px; font-weight:500; color:var(--text-muted); white-space:nowrap; flex:none; margin-right:2px; }
.crm-action-divider { width:1px; height:20px; background:var(--border); margin:0 3px; flex:none; }
.crm-action-spacer { flex:1 0 5px; min-width:5px; }
.main .crm-journal-actionbar .crm-journal-action {
    display:inline-flex; align-items:center; justify-content:center; gap:8px; flex:none;
    min-height:30px; padding:5px 10px; border:1px solid #c8d9ef; border-radius:7px;
    background:#e6f0fb; color:#48576a;
    font:600 12px/1.35 -apple-system,BlinkMacSystemFont,'Segoe UI',Arial,sans-serif;
    white-space:nowrap; cursor:pointer;
    transition:background .14s,border-color .14s,box-shadow .14s;
}
.main .crm-journal-actionbar .crm-journal-action:hover:not(:disabled) {
    background:#dae9fa; border-color:#94b5df;
}
.main .crm-journal-actionbar .crm-journal-action:focus-visible {
    outline:2px solid var(--primary); outline-offset:2px;
}
.main .crm-journal-actionbar .crm-journal-action:disabled { opacity:.48; cursor:not-allowed; }
.main .crm-journal-actionbar .crm-action-svg { width:15px; height:15px; flex:none; }
.main .crm-journal-actionbar .crm-journal-action:nth-of-type(5n + 1) .crm-action-svg { color:#2e70c7; }
.main .crm-journal-actionbar .crm-journal-action:nth-of-type(5n + 2) .crm-action-svg { color:#3c8b78; }
.main .crm-journal-actionbar .crm-journal-action:nth-of-type(5n + 3) .crm-action-svg { color:#8a60bb; }
.main .crm-journal-actionbar .crm-journal-action:nth-of-type(5n + 4) .crm-action-svg { color:#d18a29; }
.main .crm-journal-actionbar .crm-journal-action:nth-of-type(5n) .crm-action-svg { color:#3469bb; }
.main .crm-journal-actionbar .crm-journal-action:last-of-type .crm-action-svg { color:#c35252; }
:root:not([data-theme="dark"]) .main .crm-journal-actionbar .crm-journal-action {
    background:color-mix(in srgb,var(--primary) 7%,var(--surface));
    border-color:color-mix(in srgb,var(--primary) 37%,var(--border));
}
:root:not([data-theme="dark"]) .main .crm-journal-actionbar .crm-journal-action:hover:not(:disabled) {
    background:color-mix(in srgb,var(--primary) 13%,var(--surface));
}
[data-theme="dark"] .main .crm-journal-actionbar .crm-journal-action {
    background:#223b58; border-color:#385779; color:#cbd8e8;
}
[data-theme="dark"] .main .crm-journal-actionbar .crm-journal-action:hover:not(:disabled) {
    background:#2b4c70; border-color:#5981b1;
}
[data-theme="dark"] .main .crm-journal-actionbar .crm-action-svg { filter:brightness(1.35); }
@media(max-width:700px) {
    .main .crm-journal-actionbar .crm-action-label { width:100%; }
    .main .crm-journal-actionbar .crm-journal-action { flex:0 1 auto; }
}

/* Counterparty overview: one instance of each existing live journal section.
   Tables scroll independently without cloning data or making extra API requests. */
.crm-overview-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:12px;
    margin-top:12px;
    align-items:start;
}
.crm-overview-block { min-width:0; }
.crm-overview-block[hidden] { display:none!important; }
.crm-card-tab[hidden] { display:none!important; }
.crm-overview-block > .card { padding:12px; margin:0; min-width:0; }
.crm-overview-block .card-header {
    padding:0 0 8px;
    margin:0 0 8px;
    gap:8px;
}
.crm-overview-block .card-title { font-size:13px; }
.crm-overview-block .table-wrapper {
    max-height:245px;
    overflow:auto;
    overscroll-behavior:contain;
}
.crm-overview-block table { font-size:12px; }
.crm-overview-block th,
.crm-overview-block td { padding:6px 8px; }
.crm-overview-block thead th {
    position:sticky;
    top:0;
    z-index:1;
    background:var(--surface);
}
.crm-overview-block :is(#client-comms-pager,.card-header .topbar-actions) {
    flex-wrap:wrap;
}
/* Compact mode is presentation-only: the same original tables remain
   available in full on their respective detail tabs. */
.crm-overview-grid {grid-template-columns:minmax(0,1fr) minmax(0,1.15fr);gap:10px;}
.crm-overview-block > .card {padding:10px;}
.crm-overview-block.crm-overview-contacts .table-wrapper,
.crm-overview-block.crm-overview-communications .table-wrapper {max-height:340px;}
.crm-overview-block:not(.crm-overview-contacts):not(.crm-overview-communications) .table-wrapper {
    max-height:105px;overflow:auto;
}
.crm-overview-block:not(.crm-overview-contacts):not(.crm-overview-communications) thead {display:none;}
.crm-overview-block:not(.crm-overview-contacts):not(.crm-overview-communications) table {
    width:100%;border:0;font-size:12px;
}
.crm-overview-block:not(.crm-overview-contacts):not(.crm-overview-communications) tbody {
    display:flex;flex-wrap:wrap;align-items:center;gap:3px 10px;
}
.crm-overview-block:not(.crm-overview-contacts):not(.crm-overview-communications) tbody tr {
    display:inline-flex;align-items:center;border:0;background:transparent;
}
.crm-overview-block:not(.crm-overview-contacts):not(.crm-overview-communications) tbody td {
    display:none;border:0;padding:3px 2px;font-size:12px;color:var(--text-muted);
}
.crm-overview-block:is(.crm-overview-calculations,.crm-overview-orders,.crm-overview-tasks)
    tbody td:first-child {display:inline;}
.crm-overview-block.crm-overview-payments tbody td:is(:first-child,:nth-child(3)) {display:inline;}
.crm-overview-block.crm-overview-documents tbody td:is(:first-child,:nth-child(2),:last-child) {
    display:inline;
}
.crm-overview-block:not(.crm-overview-contacts):not(.crm-overview-communications) tbody td a {
    color:var(--text-muted);text-decoration:none;
}
.crm-overview-block:not(.crm-overview-contacts):not(.crm-overview-communications) tbody td a:hover {
    color:var(--primary);text-decoration:underline;
}
@media(max-width:900px) {
    .crm-overview-grid { grid-template-columns:minmax(0,1fr); }
    .crm-overview-block { grid-column:1/-1; }
}

/* Shared scrollbars follow the active palette in both themes. */
:root,
:root * {
    scrollbar-color:var(--scroll-thumb) var(--bg);
    scrollbar-width:thin;
}
:root ::-webkit-scrollbar {
    width:10px;
    height:10px;
}
:root ::-webkit-scrollbar-track {
    background:var(--bg);
    border-radius:8px;
}
:root ::-webkit-scrollbar-thumb {
    background:var(--scroll-thumb);
    border:2px solid var(--bg);
    border-radius:8px;
}
:root ::-webkit-scrollbar-thumb:hover {
    background:var(--scroll-hover);
}

/* One compact numbered footer for every server-paginated CRM list. */
.crm-pagination-bar {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,auto) minmax(0,1fr);
    align-items:center;
    position:sticky;
    bottom:0;
    z-index:5;
    min-height:30px;
    padding:2px 8px;
    border:1px solid var(--border);
    border-radius:0 0 var(--radius-sm) var(--radius-sm);
    background:var(--surface);
    gap:6px;
}

.crm-pagination-pages {
    grid-column:2;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:2px;
    min-width:0;
    overflow-x:auto;
    scrollbar-width:none;
}
.crm-pagination-pages::-webkit-scrollbar { display:none; }
.crm-pagination-page,
.crm-pagination-refresh {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    flex:0 0 auto;
    min-width:23px;
    height:23px;
    padding:0 4px;
    border:1px solid transparent;
    border-radius:4px;
    background:transparent;
    color:var(--text-muted);
    font:inherit;
    font-size:11px;
    line-height:1;
    cursor:pointer;
}
.crm-pagination-page:hover:not(:disabled),
.crm-pagination-refresh:hover {
    color:var(--text);
    background:var(--bg);
    border-color:var(--border);
}
.crm-pagination-page.active {
    color:var(--text);
    background:var(--bg);
    border-color:var(--border);
    font-weight:700;
    cursor:default;
    opacity:1;
}
.crm-pagination-actions {
    grid-column:3;
    display:flex;
    align-items:center;
    justify-self:end;
    min-width:0;
    gap:4px;
}
.crm-pagination-refresh {
    font-size:16px;
}
@media(max-width:640px) {
    .crm-pagination-bar {grid-template-columns:minmax(0,1fr) minmax(0,auto) minmax(0,1fr);}
    .crm-pagination-actions {max-width:100%;}
}
.crm-pagination-ellipsis {
    padding:0 2px;
    font-size:11px;
    color:var(--text-muted);
}

/* Pagination hides a page without changing search matches or export scope. */
.crm-page-hidden { display:none!important; }
.main.journal-page > .crm-pagination-bar {flex:0 0 auto;}

.crm-pagination-status {
    display:inline-flex;
    align-items:center;
    color:var(--text-muted);
    font-size:11px;
    font-weight:400;
    white-space:nowrap;
}
.crm-pagination-status[hidden] {display:none!important;}

/* Counts belong to the left side of each shared journal page footer. */
.crm-pagination-count{
    grid-column:1;grid-row:1;justify-self:start;
    color:var(--text-muted);font-size:11px;white-space:nowrap;
    overflow:hidden;text-overflow:ellipsis;min-width:0;
}
/* The old payments-toolbar hides its inline count; the footer must show it. */
.crm-pagination-bar .crm-pagination-count {display:block!important}

/* Shared, theme-aware file chooser for every CRM form. Native input/label
   behavior and keyboard accessibility remain unchanged. */
input[type="file"]{
    color:var(--text-muted);background:transparent;
    border-color:var(--border);cursor:pointer;
}
input[type="file"]::file-selector-button{
    appearance:none;background:transparent;color:var(--text);
    border:1px solid var(--border);border-radius:10px;
    padding:7px 11px;margin-right:8px;
    font:inherit;font-weight:600;cursor:pointer;
    transition:border-color .15s,background .15s;
}
input[type="file"]:hover::file-selector-button{
    border-color:var(--primary);
    background:color-mix(in srgb,var(--primary) 5%,transparent);
}
input[type="file"]:focus-visible::file-selector-button{
    outline:2px solid var(--primary);outline-offset:2px;
}
input[type="file"]:disabled::file-selector-button{opacity:.55;cursor:not-allowed}

/* Shared compact file picker across existing CRM forms. */
.form-input[type="file"]{font-size:12px;min-height:36px;padding:5px 7px}
.form-input[type="file"]::file-selector-button{font-size:12px;line-height:1.25}

/* Persisted transcripts: subtly visible in all three call journals. */
button.crm-transcription-ready {
    border-color: var(--success, #15803d);
    background: color-mix(in srgb, var(--success, #15803d) 14%, var(--surface, #fff));
    color: var(--text, inherit);
    font-weight: 600;
}
button.crm-transcription-ready:hover {
    background: color-mix(in srgb, var(--success, #15803d) 23%, var(--surface, #fff));
}

/* Compact transcript in the existing table surface: only the words change
   hue between real acoustic speakers. The background remains unchanged. */
.crm-call-transcription-cell {
    padding:8px 12px!important;
    background:transparent;
    color:var(--text-muted);
    white-space:pre-wrap;
    overflow-wrap:anywhere;
    font-size:12.5px;
    font-weight:400;
}
.crm-transcript-lines {display:block;max-width:100%}
.crm-transcript-line {
    display:flex;
    align-items:baseline;
    flex-wrap:nowrap;
    gap:0 7px;
    padding:2px 0;
    margin:0;
    border:0;
    border-radius:0;
    background:transparent;
    white-space:normal;
}
.crm-transcript-head {
    display:inline-flex;
    align-items:baseline;
    flex:0 0 auto;
    gap:6px;
    color:var(--text-muted);
    font-size:11px;
    line-height:1.55;
}
.crm-transcript-label {font-weight:600;opacity:.85}
/* Hide the legacy generic label even if an older JS bundle remains in a tab. */
.crm-transcript-line:not(.crm-transcript-speaker-1):not(.crm-transcript-speaker-2) .crm-transcript-label {display:none}
.crm-transcript-time {font-variant-numeric:tabular-nums;opacity:.75}
.crm-transcript-text {
    display:inline;
    flex:1 1 0;
    min-width:0;
    color:var(--text-muted);
    line-height:1.55;
    font-size:12.5px;
    white-space:pre-wrap;
    overflow-wrap:anywhere;
}
.crm-transcript-speaker-1 .crm-transcript-text {
    color:color-mix(in srgb,var(--text-muted) 74%,var(--primary));
}
.crm-transcript-speaker-2 .crm-transcript-text {
    color:color-mix(in srgb,var(--text-muted) 74%,var(--success));
}
@media(max-width:620px) {
    .crm-transcript-line {display:block}
    .crm-transcript-head {margin-right:8px}
    .crm-transcript-text {display:inline}
}

/* Shared spam marker beside a customer's displayed name, in either theme. */
.crm-spam-marker{display:inline-flex;align-items:center;justify-content:center;vertical-align:-2px;width:16px;height:16px;margin-inline-start:5px;flex:none;color:#dc3545;font-size:19px;line-height:1;font-weight:600}
svg.crm-spam-marker{stroke:#dc3545}

/* Shared journal filter pills: contractors and calls use the same controls. */
.main .task-filters{display:flex;align-items:center;gap:12px;margin-bottom:16px;flex-wrap:wrap}
.main .filter-btn{padding:8px 16px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text);cursor:pointer;transition:all .15s;font:inherit}
.main .filter-btn:hover{background:var(--bg)}
.main .filter-btn.active{background:var(--primary);color:#eaf0f8;border-color:var(--primary)}
.main .filter-btn:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.main .journal-toolbar #calls-filter-controls{margin-bottom:0}
.main .journal-toolbar #calls-employee-filter{min-width:155px;max-width:280px}
.main .journal-toolbar #calls-employee-filter option{background:var(--surface);color:var(--text)}

/* Same compact spam filter layout in contractors and calls. */
.main .task-filters .crm-spam-filter{display:inline-flex;align-items:center;justify-content:center;gap:5px;white-space:nowrap}
.main .task-filters .crm-spam-filter .crm-spam-icon{display:block;width:15px;height:15px;min-width:15px;max-width:15px;max-height:15px;flex:0 0 15px;vertical-align:middle}

/* One muted stage palette reused by the journal, the customer card and Kanban. */
.crm-customer-sales-stage[data-stage],
.crm-pipeline-link[data-stage]{
    display:inline-block;padding:0;border:0;background:transparent;
    font-size:11px;line-height:1.35;text-decoration:none;
}
.crm-customer-sales-stage[data-stage*="Новая"],
.crm-customer-sales-stage[data-stage*="новые"],
.crm-pipeline-link[data-stage="new"],
.crm-pipeline-lane[data-stage="new"] .crm-pipeline-lane-head strong{
    color:#64748b;
}
.crm-customer-sales-stage[data-stage*="работ"],
.crm-pipeline-link[data-stage="in_work"],
.crm-pipeline-lane[data-stage="in_work"] .crm-pipeline-lane-head strong{
    color:#8a681e;
}
.crm-customer-sales-stage[data-stage*="Квалификац"],
.crm-customer-sales-stage[data-stage*="согласован"],
.crm-pipeline-link[data-stage="qualified"],
.crm-pipeline-link[data-stage="preliminary_approved"],
.crm-pipeline-link[data-stage="final_approved"],
.crm-pipeline-lane[data-stage="qualified"] .crm-pipeline-lane-head strong{
    color:#20745b;
}
.crm-customer-sales-stage[data-stage*="расчёт"],
.crm-customer-sales-stage[data-stage*="отправлен"],
.crm-pipeline-link[data-stage="brief"],
.crm-pipeline-link[data-stage="brief_sent"],
.crm-pipeline-link[data-stage="preliminary_sent"],
.crm-pipeline-link[data-stage="final_sent"],
.crm-pipeline-link[data-stage="handed_off"],
.crm-pipeline-lane[data-stage="brief"] .crm-pipeline-lane-head strong{
    color:#376da1;
}
.crm-customer-sales-stage[data-stage*="Не прошёл"],
.crm-pipeline-link[data-stage="lost"],
.crm-pipeline-lane[data-stage="lost"] .crm-pipeline-lane-head strong{
    color:#a04d55;
}
.crm-pipeline-link[data-stage="won"],
.crm-pipeline-link[data-stage="contract"],
.crm-pipeline-lane[data-stage="won"] .crm-pipeline-lane-head strong{
    color:#20745b;
}
[data-theme="dark"] .crm-customer-sales-stage[data-stage*="работ"],
[data-theme="dark"] .crm-pipeline-link[data-stage="in_work"],
[data-theme="dark"] .crm-pipeline-lane[data-stage="in_work"] .crm-pipeline-lane-head strong{color:#e9c77d}
[data-theme="dark"] .crm-customer-sales-stage[data-stage*="Квалификац"],
[data-theme="dark"] .crm-pipeline-link[data-stage="qualified"],
[data-theme="dark"] .crm-pipeline-lane[data-stage="qualified"] .crm-pipeline-lane-head strong{color:#79c7ab}
[data-theme="dark"] .crm-customer-sales-stage[data-stage*="расчёт"],
[data-theme="dark"] .crm-pipeline-link[data-stage="brief"],
[data-theme="dark"] .crm-pipeline-link[data-stage="handed_off"]{color:#9bc4eb}
[data-theme="dark"] .crm-pipeline-link[data-stage="lost"],
[data-theme="dark"] .crm-pipeline-lane[data-stage="lost"] .crm-pipeline-lane-head strong{color:#e6a0a8}
/* Later sales stages use the same soft families, including dark theme. */
.crm-pipeline-lane[data-stage="preliminary_approved"] .crm-pipeline-lane-head strong,
.crm-pipeline-lane[data-stage="final_approved"] .crm-pipeline-lane-head strong,
.crm-pipeline-lane[data-stage="contract"] .crm-pipeline-lane-head strong,
.crm-pipeline-lane[data-stage="won"] .crm-pipeline-lane-head strong,
.crm-pipeline-link[data-stage="contract"],
.crm-pipeline-link[data-stage="won"]{
    color:#20745b
}
.crm-pipeline-lane[data-stage="brief_sent"] .crm-pipeline-lane-head strong,
.crm-pipeline-lane[data-stage="preliminary_sent"] .crm-pipeline-lane-head strong,
.crm-pipeline-lane[data-stage="final_sent"] .crm-pipeline-lane-head strong,
.crm-pipeline-lane[data-stage="handed_off"] .crm-pipeline-lane-head strong,
.crm-pipeline-lane[data-stage="measurement"] .crm-pipeline-lane-head strong,
.crm-pipeline-link[data-stage="measurement"]{
    color:#376da1
}
[data-theme="dark"] .crm-pipeline-link[data-stage="contract"],
[data-theme="dark"] .crm-pipeline-link[data-stage="won"],
[data-theme="dark"] .crm-pipeline-lane[data-stage="contract"] .crm-pipeline-lane-head strong,
[data-theme="dark"] .crm-pipeline-lane[data-stage="won"] .crm-pipeline-lane-head strong{color:#79c7ab}

/* Shared compact phone/email actions, used by calls and contact cards. */
:is(.crm-calls-phone,.crm-client-contact-actions) {
  display:inline-flex;align-items:center;gap:3px;white-space:nowrap;
  color:var(--text-muted);font-size:12px;
}
:is(.crm-calls-phone,.crm-client-contact-actions) .crm-phone-copy {
  display:inline-flex;align-items:center;justify-content:center;
  width:19px;height:19px;padding:0;border:1px solid transparent;
  border-radius:4px;background:transparent;color:var(--text-muted);
  cursor:pointer;font-size:11px;line-height:1;
}
:is(.crm-calls-phone,.crm-client-contact-actions) .crm-phone-copy:hover {
  border-color:var(--border);background:var(--bg);color:var(--text);
}
:is(.crm-calls-phone,.crm-client-contact-actions) .crm-phone-copy:focus-visible {
  outline:2px solid var(--primary);outline-offset:1px;
}


/* Document records: one quiet list across order, counterparty and tasks. */
.crm-doc-list{display:flex;flex-direction:column;min-width:0;padding:0 12px 8px}
.crm-doc-row{display:flex;gap:12px;align-items:center;justify-content:space-between;
    padding:9px 2px;border-bottom:1px solid var(--border);min-width:0}
.crm-doc-row:last-child{border-bottom:0}
.crm-doc-main{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1}
.crm-doc-name{font-size:13px;font-weight:550;color:var(--text);text-align:left;
    background:none;border:0;padding:0;cursor:pointer;text-decoration:none;
    overflow-wrap:anywhere;line-height:1.45}
.crm-doc-name:hover{text-decoration:underline;color:var(--primary)}
.crm-doc-name:focus-visible{outline:2px solid var(--primary);outline-offset:3px}
.crm-doc-meta{font-size:11px;color:var(--text-muted);overflow-wrap:anywhere}
.crm-doc-actions{display:flex;align-items:center;gap:5px;flex-shrink:0}
.crm-doc-actions .btn{font-size:11px;padding:4px 7px}
.crm-doc-empty{font-size:12px;color:var(--text-muted);padding:11px 0}
.crm-doc-attach{padding:7px 12px;border-top:1px solid var(--border);background:transparent;box-shadow:none}
.crm-doc-attach summary{cursor:pointer;color:var(--text-muted);font-size:12px}
.crm-doc-attach[open] summary{margin-bottom:8px}
.crm-doc-group{font-size:11px;font-weight:600;color:var(--text-muted);
    padding:10px 12px 2px}
.crm-doc-list-table{width:100%;border:0;border-collapse:collapse}
.crm-doc-list-table thead{display:none}
.crm-doc-list-table tbody tr{display:block;border:0}
.crm-doc-list-table tbody td{display:block;padding:0 12px;border:0}
.crm-doc-list-table .crm-doc-row{padding:9px 0}
.crm-doc-list-table .crm-doc-empty{display:block}
.crm-doc-generated{padding:0 12px 10px;margin:0}
.crm-doc-generated .crm-doc-list{padding:0}
.crm-doc-generated h3{margin:8px 0 0;font-size:12px;color:var(--text-muted);font-weight:600}
.crm-doc-generated .crm-doc-actions button{margin:0}
.task-signed-documents .crm-doc-name{font-size:12px}
.calc-file-modal-row .crm-doc-actions{margin-left:auto}
.calc-file-modal-row .crm-doc-actions summary{cursor:pointer;color:var(--text-muted);
    padding:3px 8px;border-radius:4px}
.calc-file-modal-row .crm-doc-actions[open]{background:var(--surface)}
@media(max-width:600px){.crm-doc-row{align-items:flex-start}
 .crm-doc-actions{flex-wrap:wrap;justify-content:flex-end}
 .crm-doc-attach .order-document-attach-row{flex-wrap:wrap}}

/* Shared financial row styles: one renderer for journal and counterparty card. */
.type-badge { padding: 3px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.type-income { background: color-mix(in srgb, var(--success) 13%, var(--surface)); color: var(--success); }
.payment-expense-detail { margin-top:4px;font-size:12px;line-height:1.4;color:var(--text-muted);overflow-wrap:anywhere; }
.type-expense { background: color-mix(in srgb, var(--danger) 13%, var(--surface)); color: var(--danger); }
.type-transfer { background: color-mix(in srgb, var(--info) 13%, var(--surface)); color: var(--info); }
.type-adjustment { background: color-mix(in srgb, var(--warning) 17%, var(--surface)); color: var(--warning); }
.adjustment-row { box-shadow:inset 3px 0 var(--warning); }
.amount-income { color: var(--success); font-weight: 600; }
.amount-expense { color: var(--danger); font-weight: 600; }
.amount-transfer { color: var(--info); font-weight: 600; }
.amount-adjustment { color: var(--warning); font-weight: 700; }
.bank-imported-row { box-shadow:inset 3px 0 var(--primary); }
.payment-stage-cell { font-weight:600; color:var(--text); }
.crm-payment-table{width:100%;min-width:1160px;font-size:12px}
.crm-payment-table td,.crm-payment-table th{padding:9px 8px}
.crm-payment-table .payment-amount-cell{white-space:nowrap;font-variant-numeric:tabular-nums;text-align:right}
.crm-payment-table .payment-cash-cell{width:156px;max-width:156px;min-width:130px;white-space:normal;font-size:11.5px;font-weight:600;line-height:1.28;overflow-wrap:anywhere}
.crm-payment-table .cash-source{display:block}
.crm-payment-table .cash-destination{display:block;color:var(--text-muted);font-size:11px;font-weight:500;margin-top:2px}
.crm-payment-table td:nth-child(8){min-width:220px;overflow-wrap:anywhere}
.crm-payment-table td:first-child,.crm-payment-table td:nth-child(2),.crm-payment-table td:nth-child(6),.crm-payment-table td:nth-child(7),.crm-payment-table td:nth-child(9),.crm-payment-table td:last-child{white-space:nowrap}

/* Compact work-case workspace; inherits the single shared theme. */
.support-page{padding:10px 14px}
.support-layout{display:grid;grid-template-columns:minmax(210px,280px) minmax(0,1fr) minmax(210px,275px);gap:10px;align-items:start}
.support-layout>*{min-width:0}
.support-rail,.support-side{position:sticky;top:60px;max-height:calc(100vh - 72px);overflow:auto}
.support-panel{background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:10px;margin-bottom:8px}
.support-panel h2{font-size:14px;margin:0 0 8px}
.support-tools,.support-line{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
#support-error{margin:0 0 8px}
#support-error:empty{display:none}
.support-tools{margin:5px 0}
.support-search{width:100%;margin-bottom:6px}
.support-list{display:grid;gap:3px;margin:6px 0}
.support-entry{display:grid;grid-template-columns:minmax(65px,auto) minmax(0,1fr);gap:3px 8px;text-align:left;width:100%;font:inherit;font-size:12px;color:var(--text);border:1px solid transparent;background:transparent;padding:6px;border-radius:5px;cursor:pointer}
.support-entry:hover,.support-entry[aria-current=true]{background:var(--bg);border-color:var(--primary)}
.support-entry small,.support-muted{color:var(--text-muted);font-size:11px}
.support-entry strong,.support-entry small{overflow-wrap:anywhere;min-width:0}
.support-entry .support-customer{font-size:13px;font-weight:600;grid-column:2}.support-list-status{grid-column:2}
.support-section{padding:0}
.support-section>summary{cursor:pointer;padding:9px 10px;font-weight:600;font-size:13px}
.support-section>summary,.support-panel>h2{color:var(--support-heading)}
.support-section .support-section>summary,.support-subhead>strong{color:var(--support-subheading)}
.support-section .support-section>summary,.support-subhead>strong{font-size:12px}
.support-section>div{padding:0 10px 10px}
.support-section .support-section{margin:5px 0}
.support-section p{white-space:pre-wrap;overflow-wrap:anywhere;margin:6px 0}
.support-facts{display:grid;grid-template-columns:minmax(75px,auto) minmax(0,1fr);gap:5px 8px;font-size:12px;margin:0}
.support-facts dt{color:var(--text-muted)}
.support-facts dd{margin:0;overflow-wrap:anywhere}
.support-line{justify-content:space-between;border-top:1px solid var(--border);padding:6px 0;font-size:12px;overflow-wrap:anywhere}
.support-line>*{min-width:0}
.support-page [hidden]{display:none!important}
.support-page .btn{font-size:12px}
.support-layout.rail-hidden{grid-template-columns:minmax(0,1fr) minmax(210px,275px)}
.support-layout.rail-hidden>.support-rail{display:none}
@media(min-width:1051px){.sidebar{padding:0 10px}.nav-menu{gap:1px}.nav-link{font-size:12px}.nav-link .icon{font-size:12px}.sidebar-logo{font-size:13px}.sidebar-header{margin-right:10px}}
@media(min-width:1051px) and (max-width:1250px){.nav-link .icon{display:none}.sidebar-logo>div:last-child{display:none}.nav-link{padding:5px 6px}.sidebar #current-username{display:none}}
@media(max-width:1050px){.support-layout,.support-layout.rail-hidden{grid-template-columns:minmax(200px,255px) minmax(0,1fr)}.support-side{grid-column:2;position:static;max-height:none}.support-layout.rail-hidden{grid-template-columns:minmax(0,1fr)}.support-layout.rail-hidden .support-side{grid-column:1}}
@media(max-width:720px){.support-page{padding:8px}.support-layout,.support-layout.rail-hidden{display:block}.support-rail,.support-side{position:static;max-height:none}.support-list{max-height:230px;overflow:auto}}

/* Work-case overview, using shared buttons and theme tokens. */
.support-title-row,.support-identity,.support-subhead{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.support-hero{padding:12px}
.support-title-row,.support-subhead{justify-content:space-between}
.support-identity{min-width:0;justify-content:flex-start}
.support-identity h2{font-size:17px;margin:0}
.support-deal-name{font-size:16px;overflow-wrap:anywhere}
.support-title-icon{color:var(--primary);font-size:18px;line-height:1}
.support-subtitle{font-size:12px;color:var(--text-muted);margin:7px 0}
.support-chips{display:flex;gap:5px;flex-wrap:wrap;margin-top:8px}
.support-chip{font-size:11px;color:var(--text);border:1px solid var(--border);padding:4px 7px;border-radius:4px;text-decoration:none}
a.support-chip:hover{border-color:var(--primary)}
.support-page a.btn{display:inline-flex;align-items:center;text-decoration:none}
.support-page .btn{font-size:12px;line-height:1.3;padding:6px 9px;min-height:28px}
.support-quick{justify-content:flex-end;margin:0 0 0 auto;min-width:0}
.support-page .support-icon-button{display:inline-flex;align-items:center;justify-content:center;width:28px;min-width:28px;padding:0;font-size:15px;flex-shrink:0}
.support-next{display:flex;align-items:center;justify-content:space-between;gap:10px;border-color:var(--primary);background:var(--surface)}
.support-next>div{display:grid;gap:4px;min-width:0}
.support-next-title{font-size:14px;overflow-wrap:anywhere}
.support-urgent{font-size:11px;color:var(--danger);font-weight:600}
.support-subsection{margin-top:12px}
.support-subhead{margin-bottom:6px;font-size:13px}
.support-description{font-size:13px;margin:6px 0 10px}
.support-table-wrap{max-width:100%;overflow:auto}
.support-table{width:100%;border-collapse:collapse;font-size:12px;text-align:left}
.support-table th,.support-table td{padding:6px 7px;border-bottom:1px solid var(--border);vertical-align:top;overflow-wrap:anywhere}
.support-table th{color:var(--text-muted);background:var(--bg);font-weight:500;white-space:nowrap}
.support-calculation-top{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px;align-items:stretch}
.support-calculation-top>section{min-width:0}
#support-edit-case-form{padding:10px 16px}
#support-edit-case-form .form-group{display:grid;grid-template-columns:145px minmax(0,1fr);align-items:center;gap:8px;margin-bottom:10px}
#support-edit-case-form .form-label{margin:0}
@media(max-width:480px){#support-edit-case-form .form-group{grid-template-columns:minmax(0,1fr)}}
.support-calculation-files{border-left:1px solid var(--border);padding-left:10px}
.support-comments-table{table-layout:fixed}
.support-comments-table th{white-space:normal}
.support-comments-table th:first-child{width:16%}
.support-comments-table th:nth-child(2){width:17%}
.support-comments-table th:last-child{width:23%}
.support-comments-table td>div+div{margin-top:4px}
.support-comments-table td>p{margin:3px 0}
.support-calculation-files .crm-doc-row,.support-comments-table .crm-doc-row{display:flex;align-items:center;flex-wrap:nowrap;gap:4px;padding:4px 0}
.support-calculation-files .crm-doc-main,.support-comments-table .crm-doc-main{flex:1 1 0;min-width:0}
.support-calculation-files .crm-doc-name,.support-comments-table .crm-doc-name{padding:0;overflow-wrap:anywhere;white-space:normal}
.support-calculation-files .crm-doc-actions,.support-comments-table .crm-doc-actions{flex:0 1 auto;min-width:0;max-width:65%;flex-wrap:wrap;justify-content:flex-end;gap:3px}
.support-calculation-files .crm-doc-actions .btn,.support-comments-table .crm-doc-actions .btn{white-space:normal;overflow-wrap:anywhere;max-width:100%}
.support-calculation-files .crm-doc-actions .btn,.support-comments-table .crm-doc-actions .btn{font-size:11px;min-height:23px;padding:3px 5px}
@media(max-width:720px){.support-calculation-top{grid-template-columns:minmax(0,1fr)}.support-calculation-files{border-left:0;padding-left:0;border-top:1px solid var(--border);padding-top:8px}}
.support-finance-total{display:block;font-size:22px;margin:6px 0}
.support-finance progress{display:block;width:100%;height:8px;accent-color:var(--success);margin:8px 0 12px}
.support-side .support-panel>.btn{margin-top:8px}
.support-section[id]{scroll-margin-top:60px}
.support-section .support-section{border-radius:4px;box-shadow:none}
@media(min-width:1051px){.support-entry{padding:8px 6px;border-radius:3px}}
@media(max-width:720px){.support-title-row,.support-next{align-items:flex-start}.support-next{flex-wrap:wrap}.support-identity h2,.support-deal-name{font-size:15px}}

/* Operations shell: the existing top journals are kept, with grouped
   navigation to the very same authorized pages on the left. */
.crm-operations-nav{display:none}
 .crm-operations-group{margin:10px 0 16px}
 .crm-operations-group h2{font-size:10px;font-weight:500;letter-spacing:.09em;text-transform:uppercase;color:var(--text-muted);padding:0 9px 5px;margin:0}
 .crm-operations-link,.crm-operations-planned{display:flex;align-items:center;gap:9px;padding:7px 9px;border-radius:var(--radius-sm);font-size:13px;font-weight:400;text-decoration:none;color:var(--text-muted);line-height:1.35;min-width:0}
 .crm-operations-link:hover,.crm-operations-link.active{background:var(--raised);color:var(--text)}
 .crm-operations-link.active{box-shadow:inset 3px 0 var(--primary-light)}
 .crm-operations-link:focus-visible,.crm-operations-toggle:focus-visible{outline:2px solid var(--primary-light);outline-offset:-2px}
 .crm-operations-icon{width:19px;flex:none;text-align:center;color:var(--primary-light);font-size:15px}
 .crm-operations-label{min-width:0;overflow-wrap:anywhere}
 .crm-operations-planned{opacity:.65;font-size:12px}
 .crm-operations-planned .crm-operations-icon{color:var(--text-muted)}
 .crm-operations-plan{margin-left:auto;font-size:9px;color:var(--text-muted)}
@media(max-width:850px){
 .sidebar.crm-operations-ready.crm-nav-open .nav-menu{display:none}
 .sidebar.crm-operations-ready.crm-nav-open + .crm-operations-nav{display:block}
 .crm-operations-nav{position:fixed;inset:53px 8px auto;z-index:101;max-height:min(65vh,440px);max-height:min(65dvh,440px);overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;padding:7px;background:var(--surface);border:1px solid var(--border);border-radius:9px;box-shadow:var(--shadow-lg)}
 .crm-operations-heading{display:none}
 .crm-operations-group{margin:6px 0 12px}
 .crm-operations-link{min-height:44px}
}
@media(min-width:851px){
 .app.crm-operations-shell{display:grid;grid-template-columns:224px minmax(0,1fr);grid-template-rows:50px 1fr;align-items:start;min-width:0}
 .app.crm-operations-shell.crm-operations-collapsed{grid-template-columns:58px minmax(0,1fr)}
 .crm-operations-shell>#sidebar-container{grid-column:1/-1;grid-row:1}
 .crm-operations-shell>.main{grid-column:2;grid-row:2;min-width:0;width:100%;max-width:100%}
 .crm-operations-nav{display:block;grid-column:1;grid-row:2;position:sticky;top:50px;height:calc(100vh - 50px);height:calc(100dvh - 50px);min-height:0;overflow:auto;overscroll-behavior:contain;background:var(--nav);border-right:1px solid var(--border);padding:10px 8px 18px}
 .crm-operations-heading{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:0 6px 6px;font-size:12px;font-weight:600}
 .crm-operations-toggle{width:30px;height:28px;display:grid;place-items:center;flex:none;border:1px solid var(--border);border-radius:var(--radius-sm);background:transparent;color:var(--text-muted);font:inherit;cursor:pointer}
 .crm-operations-toggle:hover{background:var(--raised);color:var(--text)}
 .crm-operations-collapsed .crm-operations-heading{justify-content:center;padding:0}
 .crm-operations-collapsed .crm-operations-heading-label,.crm-operations-collapsed .crm-operations-group h2,.crm-operations-collapsed .crm-operations-label,.crm-operations-collapsed .crm-operations-planned{display:none}
 .crm-operations-collapsed .crm-operations-link{justify-content:center;padding:8px 4px}
 .crm-operations-collapsed .crm-operations-group{margin:5px 0 12px}
}
@media(min-width:851px) and (max-width:1250px){
 .app.crm-operations-shell:not(.crm-operations-collapsed){grid-template-columns:200px minmax(0,1fr)}
}
/* Account for the new rail without changing the existing mobile journal. */
@media(min-width:851px) and (max-width:1320px){
 .crm-operations-shell:not(.crm-operations-collapsed) .support-layout{grid-template-columns:minmax(195px,245px) minmax(0,1fr)}
 .crm-operations-shell:not(.crm-operations-collapsed) .support-side{grid-column:2;position:static;max-height:none}
 .crm-operations-shell:not(.crm-operations-collapsed) .support-layout.rail-hidden{grid-template-columns:minmax(0,1fr)}
 .crm-operations-shell:not(.crm-operations-collapsed) .support-layout.rail-hidden .support-side{grid-column:1}
}
@media(min-width:851px) and (max-width:980px){
 .crm-operations-shell:not(.crm-operations-collapsed) .support-layout{display:block}
 .crm-operations-shell:not(.crm-operations-collapsed) .support-rail{position:static;max-height:none}
 .crm-operations-shell:not(.crm-operations-collapsed) .support-list{max-height:230px;overflow:auto}
}
.support-new-case-options{display:grid;gap:8px;margin-top:12px}
.support-new-case-option{display:grid;grid-template-columns:110px minmax(0,1fr);align-items:center;gap:10px}

/* Separate entity groups; use existing heading palette and disclosures. */
.support-entity-group{display:grid;gap:8px;min-width:0}
.support-entity-heading{font-size:13px;font-weight:600;color:var(--support-heading);margin:4px 0 0}
.support-measurement-request{padding:8px 0;border-bottom:1px solid var(--border)}
.support-measurement-request:last-child{border-bottom:0}
.measurement-brief-line{white-space:pre-wrap;overflow-wrap:anywhere;margin:5px 0;font-size:13px}

.support-entity-header{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.support-entity-header .support-entity-heading{margin:0}
/* crm-release-control-5aba5dc81418 */
