:root {
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f7;
    --border: #e5e9f0;
    --border-strong: #d3dae4;
    --text: #1c2430;
    --text-2: #5b6675;
    --muted: #98a2b3;
    --accent: #2aa37f;
    --accent-rgb: 42, 163, 127;
    --accent-2: #3f8fd0;
    --accent-2-rgb: 63, 143, 208;
    --green: #2ecc71;
    --green-rgb: 46, 204, 113;
    --green-strong: #1f9d55;
    --orange: #f59e0b;
    --orange-rgb: 245, 158, 11;
    --orange-strong: #b26a00;
    --red: #e5484d;
    --red-rgb: 229, 72, 77;
    --purple: #8b5cf6;
    --purple-rgb: 139, 92, 246;
    --teal: #14b8a6;
    --teal-rgb: 20, 184, 166;
    --teal-strong: #0d9488;
    --dot: rgba(28, 36, 48, .045);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 6px 18px rgba(16, 24, 40, .07);
    --shadow-lg: 0 18px 50px rgba(16, 24, 40, .16);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --sidebar-w: 244px;
    --topbar-h: 60px;
    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

html, body.crm-app { max-width: 100%; overflow-x: hidden; }
* { box-sizing: border-box; }

html, body { height: 100%; }

body.crm-app {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background-color: var(--bg);
    background-image: radial-gradient(var(--dot) 1px, transparent 1px);
    background-size: 22px 22px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

svg { display: block; }

/* ===== Shell ===== */
.crm-shell { min-height: 100%; }

.crm-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 40;
}

.crm-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.crm-brand-mark {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .04em;
}
.crm-brand-text { font-size: 16px; letter-spacing: .04em; }

.crm-icon-btn {
    width: 38px; height: 38px;
    display: inline-grid; place-items: center;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--text-2);
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: background .15s, color .15s;
}
.crm-icon-btn:hover { background: var(--surface-3); color: var(--text); }
.crm-burger { display: none; }

.crm-search {
    flex: 1; max-width: 520px;
    display: flex; align-items: center; gap: 9px;
    padding: 0 12px;
    height: 38px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
}
.crm-search input {
    flex: 1; border: 0; outline: 0; background: transparent;
    font: inherit; color: var(--text);
}
.crm-search input::placeholder { color: var(--muted); }

.crm-top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.crm-dot {
    position: absolute; top: 7px; right: 7px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--red); border: 2px solid var(--surface);
}
.crm-user { display: flex; align-items: center; gap: 10px; padding-left: 10px; border-left: 1px solid var(--border); }
.crm-user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.crm-user-name { font-weight: 600; font-size: 13px; }
.crm-user-role { font-size: 11px; color: var(--muted); }
.crm-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(var(--accent-rgb), .14);
    color: var(--accent); font-weight: 700;
}

.crm-body { padding-top: var(--topbar-h); display: flex; min-height: 100vh; }

.crm-side {
    position: fixed;
    top: var(--topbar-h); bottom: 0; left: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 12px 10px;
    overflow-y: auto;
    z-index: 30;
}
.crm-nav { display: flex; flex-direction: column; gap: 2px; }
.crm-nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px;
    border-radius: 10px;
    color: var(--text-2);
    font-weight: 500;
    transition: background .15s, color .15s;
}
.crm-nav-item:hover { background: var(--surface-3); color: var(--text); }
.crm-nav-item.is-active { background: rgba(var(--accent-rgb), .12); color: var(--accent); font-weight: 600; }
.crm-nav-ico { flex: none; display: grid; place-items: center; }
.crm-nav-label { flex: 1; }
.crm-nav-item.is-danger:hover { background: rgba(var(--red-rgb), .1); color: var(--red); }
.crm-badge {
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; background: var(--accent); color: #fff;
    font-size: 11px; font-weight: 700;
    display: grid; place-items: center;
}
.crm-side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

.crm-main { flex: 1; margin-left: var(--sidebar-w); padding: 22px 26px 60px; min-width: 0; }
.crm-overlay { display: none; }

/* ===== Page head ===== */
.crm-page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.crm-page-title h1 { font-size: 22px; }
.crm-page-title p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.crm-page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ===== Buttons ===== */
.crm-btn {
    display: inline-flex; align-items: center; gap: 7px;
    height: 38px; padding: 0 15px;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-weight: 600; font-size: 13px;
    cursor: pointer;
    transition: transform .1s, box-shadow .15s, background .15s;
    white-space: nowrap;
}
.crm-btn:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.crm-btn:active { transform: none; }
.crm-btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.crm-btn-blue { background: var(--accent-2); border-color: transparent; color: #fff; }
.crm-btn-danger { background: rgba(var(--red-rgb), .1); border-color: rgba(var(--red-rgb), .3); color: var(--red); }
.crm-btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.crm-btn-ghost:hover { background: var(--surface-3); color: var(--text); box-shadow: none; }
.crm-btn-sm { height: 32px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.crm-btn-icon { width: 32px; padding: 0; justify-content: center; }

/* ===== Cards ===== */
.crm-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    min-width: 0;
    max-width: 100%;
}
.crm-card-pad { padding: 18px; }
.crm-card-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); min-width: 0; flex-wrap: wrap; }
.crm-card-head h3 { font-size: 15px; min-width: 0; }
.crm-card-head .crm-page-actions { margin-left: auto; }

.crm-grid { display: grid; gap: 14px; min-width: 0; }
.crm-grid > * { min-width: 0; }
.crm-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.crm-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.crm-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.crm-stat { padding: 16px 18px; }
.crm-stat-label { color: var(--text-2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.crm-stat-value { font-size: 26px; font-weight: 750; margin-top: 6px; }
.crm-stat-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ===== Forms ===== */
.crm-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.crm-field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.crm-field .req { color: var(--red); }
.crm-input, .crm-select, .crm-textarea {
    width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.crm-textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.crm-input:focus, .crm-select:focus, .crm-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .15);
}
.crm-form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.crm-hint { font-size: 12px; color: var(--muted); }
.crm-form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; }

/* ===== Table ===== */
.crm-table-wrap { overflow-x: auto; min-width: 0; max-width: 100%; }
table.crm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.crm-table th {
    text-align: left; padding: 11px 14px;
    color: var(--text-2); font-weight: 600; font-size: 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.crm-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.crm-table tbody tr:hover { background: var(--surface-2); }
.crm-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.crm-table .actions { text-align: right; white-space: nowrap; }

/* ===== Chips / tags ===== */
.crm-chip {
    display: inline-flex; align-items: center; gap: 5px;
    height: 24px; padding: 0 10px;
    border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: var(--surface-3); color: var(--text-2);
}
.crm-chip-green { background: rgba(var(--green-rgb), .14); color: var(--green-strong); }
.crm-chip-blue { background: rgba(var(--accent-2-rgb), .14); color: var(--accent-2); }
.crm-chip-orange { background: rgba(var(--orange-rgb), .16); color: var(--orange-strong); }
.crm-chip-red { background: rgba(var(--red-rgb), .12); color: var(--red); }
.crm-chip-purple { background: rgba(var(--purple-rgb), .14); color: var(--purple); }
.crm-chip-teal { background: rgba(var(--teal-rgb), .14); color: var(--teal-strong); }

/* ===== Flash / empty ===== */
.crm-flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.crm-flash-ok { background: rgba(var(--green-rgb), .12); color: var(--green-strong); border: 1px solid rgba(var(--green-rgb), .3); }
.crm-flash-err { background: rgba(var(--red-rgb), .1); color: var(--red); border: 1px solid rgba(var(--red-rgb), .3); }
.crm-empty { padding: 46px 20px; text-align: center; color: var(--text-2); }
.crm-empty svg { margin: 0 auto 12px; color: var(--muted); }
.crm-empty h3 { margin-bottom: 5px; }

/* ===== Modal ===== */
.crm-modal { position: fixed; inset: 0; z-index: 60; display: none; }
.crm-modal.is-open { display: block; }
.crm-modal-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, .45); backdrop-filter: blur(2px); }
.crm-modal-box {
    position: relative;
    margin: 5vh auto;
    width: min(680px, calc(100% - 32px));
    max-height: 90vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: crmPop .18s ease;
}
.crm-modal-box.crm-modal-lg { width: min(1040px, calc(100% - 32px)); }
@keyframes crmPop { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.crm-modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.crm-modal-head h3 { font-size: 16px; }
.crm-modal-head .crm-icon-btn { margin-left: auto; }
.crm-modal-body { padding: 20px 22px; }
.crm-modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ===== Consent banner ===== */
.crm-consent { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; background: rgba(16, 24, 40, .55); backdrop-filter: blur(2px); padding: 18px; }
.crm-consent-card { width: min(720px, 100%); max-height: 88vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 22px; animation: crmPop .18s ease; }
.crm-consent-card h2 { font-size: 17px; margin: 0 0 8px; }
.crm-consent-card p { color: var(--text-2); font-size: 13px; margin: 0 0 16px; }
.crm-consent-card a { color: var(--accent); text-decoration: underline; }
.crm-consent-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
    .crm-consent { align-items: center; padding: 12px; }
    .crm-consent-card { padding: 18px 16px; }
    .crm-consent-actions { flex-direction: column-reverse; }
    .crm-consent-actions .crm-btn { width: 100%; justify-content: center; }
}

/* ===== Login ===== */
.crm-login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.crm-login-theme {
    position: fixed; top: 16px; right: 16px; z-index: 50;
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.crm-captcha { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.crm-captcha-img { border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #0d1117; }
.crm-captcha-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.crm-captcha-option { padding: 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text); font: inherit; font-weight: 600; font-family: ui-monospace, Consolas, monospace; cursor: pointer; transition: all .15s; }
.crm-captcha-option:hover { border-color: var(--accent); }
.crm-captcha-option.is-active { background: rgba(var(--accent-rgb), .14); border-color: var(--accent); color: var(--accent); }
@media (max-width: 480px) { .crm-captcha-option { padding: 8px; font-size: 14px; } }
.crm-login-box { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 30px 28px; }
.crm-login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.crm-login-logo .crm-brand-mark { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; }
.crm-login-logo h1 { font-size: 18px; }
.crm-login-logo p { margin: 3px 0 0; color: var(--text-2); font-size: 12px; }
.crm-login-error { background: rgba(var(--red-rgb), .1); color: var(--red); border: 1px solid rgba(var(--red-rgb), .3); padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.crm-login-btn { width: 100%; height: 44px; justify-content: center; margin-top: 4px; }

/* ===== Calendar ===== */
.crm-cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.crm-cal-nav { display: flex; align-items: center; gap: 4px; }
.crm-cal-title { font-size: 18px; font-weight: 700; min-width: 190px; text-transform: capitalize; }
.crm-seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.crm-seg a { padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.crm-seg a.is-active { background: var(--accent); color: #fff; }

.crm-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.crm-month-dow { background: var(--surface-2); padding: 9px 10px; font-size: 12px; font-weight: 600; color: var(--text-2); text-align: center; }
.crm-month-cell { background: var(--surface); min-height: 128px; padding: 7px; display: flex; flex-direction: column; gap: 5px; }
.crm-month-cell.is-out { background: var(--surface-2); }
.crm-month-cell.is-today .crm-month-num { background: var(--accent); color: #fff; }
.crm-month-num { align-self: flex-start; font-size: 12px; font-weight: 700; color: var(--text-2); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.crm-ev {
    display: block; padding: 6px 8px; border-radius: 8px; font-size: 12px; line-height: 1.25;
    border-left: 3px solid var(--accent); background: rgba(var(--accent-rgb), .09);
    cursor: pointer; overflow: hidden;
}
.crm-ev:hover { background: rgba(var(--accent-rgb), .16); }
.crm-ev-time { font-weight: 700; }
.crm-ev-title { color: var(--text-2); display: block; }
.crm-ev.is-done { border-left-color: var(--green); background: rgba(var(--green-rgb), .1); }
.crm-ev.is-canceled { border-left-color: var(--muted); background: var(--surface-3); opacity: .7; text-decoration: line-through; }
.crm-more { font-size: 11px; color: var(--accent); font-weight: 600; padding-left: 4px; }

.crm-week { display: grid; grid-template-columns: 64px repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.crm-week-head { background: var(--surface-2); padding: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); text-align: center; border-bottom: 1px solid var(--border); }
.crm-week-head.is-today { color: var(--accent); }
.crm-week-time { font-size: 11px; color: var(--muted); text-align: right; padding: 4px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.crm-week-cell { min-height: 54px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 3px; }

/* ===== Kanban ===== */
.crm-kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.crm-kan-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 200px; }
.crm-kan-head { padding: 12px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); font-weight: 650; font-size: 13px; }
.crm-kan-count { margin-left: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--text-2); }
.crm-kan-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 120px; }
.crm-kan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow-sm); cursor: grab; }
.crm-kan-card:hover { border-color: var(--border-strong); }
.crm-kan-card.is-drag { opacity: .5; }
.crm-kan-col.is-over { outline: 2px dashed rgba(var(--accent-rgb), .5); outline-offset: -3px; }
.crm-kan-name { font-weight: 650; font-size: 13px; }
.crm-kan-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.crm-kan-foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }

/* ===== Chat ===== */
.crm-chat { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; height: calc(100vh - 250px); min-height: 380px; max-width: 100%; }
.crm-chat-list { display: flex; flex-direction: column; overflow: hidden; }
.crm-chat-items { overflow-y: auto; }
.crm-chat-item { display: block; padding: 12px 15px; border-bottom: 1px solid var(--border); }
.crm-chat-item:hover { background: var(--surface-2); }
.crm-chat-item.is-active { background: rgba(var(--accent-rgb), .1); }
.crm-chat-item .ci-top { display: flex; align-items: center; gap: 8px; }
.crm-chat-item .ci-name { font-weight: 650; font-size: 13px; }
.crm-chat-item .ci-time { margin-left: auto; font-size: 11px; color: var(--muted); }
.crm-chat-item .ci-preview { color: var(--text-2); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-chat-unread { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.crm-chat-main { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.crm-chat-inline { height: calc(100vh - 300px); min-height: 360px; }
.crm-chat-back { display: none; }
.crm-chat-head { padding: 13px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.crm-chat-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); min-height: 0; }
.crm-msg { max-width: 72%; padding: 8px 12px; border-radius: 13px; font-size: 13px; line-height: 1.4; word-break: break-word; }
.crm-msg-text { white-space: pre-wrap; word-break: break-word; }
.crm-msg-in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.crm-msg-out { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 4px; }
.crm-msg-author { font-size: 11px; font-weight: 700; margin-bottom: 4px; opacity: .85; }
.crm-msg-in .crm-msg-author { color: var(--accent); }
.crm-msg-out .crm-msg-author { color: #eaf7f2; }
.crm-msg-time { font-size: 10px; opacity: .7; margin-top: 3px; }
.crm-chat-compose { display: flex; gap: 9px; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface); align-items: flex-end; flex-wrap: wrap; }
.crm-chat-compose textarea { flex: 1 1 220px; min-width: 160px; min-height: 46px; max-height: 150px; resize: none; padding: 11px 13px; line-height: 1.45; }
.crm-chat-compose .crm-btn { flex: none; height: 46px; }
.crm-chat-compose .crm-icon-btn { flex: none; height: 46px; }
@media (max-width: 760px) {
    .crm-chat-compose textarea { flex-basis: 100%; width: 100%; }
    .crm-chat-compose .crm-btn { flex: 1; justify-content: center; }
}
.crm-chat-placeholder { flex: 1; display: grid; place-items: center; color: var(--text-2); text-align: center; }

/* ===== Misc ===== */
.crm-muted { color: var(--muted); }
.crm-flex { display: flex; align-items: center; gap: 10px; }
.crm-flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.crm-mt { margin-top: 14px; }
.crm-error-page { text-align: center; padding: 80px 20px; }
.crm-error-code { font-size: 64px; font-weight: 800; color: var(--accent); }
.crm-error-page p { color: var(--text-2); margin: 8px 0 22px; }
.crm-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.crm-tab { padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.crm-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.crm-progress { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.crm-progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.crm-checklist { display: flex; flex-direction: column; gap: 9px; }
.crm-check-row { display: grid; grid-template-columns: 26px minmax(0, 1.6fr) 110px 90px minmax(0, 1fr); gap: 8px; align-items: center; }
.crm-check-row .crm-input, .crm-check-row .crm-select { height: 34px; }
.crm-grade { width: 74px; text-align: center; }
.crm-dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
.crm-dl dt { color: var(--text-2); font-weight: 600; }
.crm-dl dd { margin: 0; }

@media (max-width: 1100px) {
    .crm-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .crm-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .crm-burger { display: inline-grid; }
    .crm-side { transform: translateX(-104%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
    .crm-shell.nav-open .crm-side { transform: none; }
    .crm-main { margin-left: 0; padding: 16px; }
    .crm-shell.nav-open .crm-overlay { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(16,24,40,.4); z-index: 25; }
    .crm-user-meta { display: none; }
    .crm-chat { grid-template-columns: 1fr; height: auto; min-height: 0; }
}
@media (max-width: 760px) {
    .crm-chat { grid-template-columns: 1fr; height: calc(100vh - 190px); min-height: 340px; }
    .crm-chat.is-open .crm-chat-list { display: none; }
    .crm-chat:not(.is-open) .crm-chat-main { display: none; }
    .crm-chat-back { display: inline-grid; }
    .crm-chat-msgs { min-height: 0; }
    .crm-chat-inline { height: 60vh; }
}
@media (max-width: 640px) {
    .crm-grid-4, .crm-grid-3, .crm-grid-2 { grid-template-columns: 1fr; }
    .crm-form-row { grid-template-columns: 1fr; }
    .crm-search { display: none; }
    .crm-page-actions { width: 100%; }
    .crm-check-row { grid-template-columns: 1fr; }
    .crm-month-cell { min-height: 84px; }
    .crm-brand-text { display: none; }
    .crm-quick-add { display: none; }
    .crm-topbar { gap: 6px; padding: 0 10px; }
    .crm-top-actions { gap: 2px; }
    .crm-user { padding-left: 4px; gap: 6px; }
    .crm-dl { grid-template-columns: 1fr; gap: 2px 0; }
    .crm-dl dt { margin-top: 8px; }
    .crm-page-head { align-items: flex-start; }
}
