:root {
    color-scheme: light;
    --ink: #172133;
    --muted: #6f7785;
    --line: #e7e9ee;
    --panel: #ffffff;
    --background: #f5f6f8;
    --blue: #006be6;
    --blue-soft: #eaf4ff;
    --green: #00a86b;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--background);
}

a { color: inherit; }

.topbar {
    height: 72px;
    padding: 0 max(24px, calc((100vw - 1120px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    font-weight: 800;
    font-size: 20px;
    text-decoration: none;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: white;
    border-radius: 12px;
    background: linear-gradient(135deg, #00aaff, #965eeb 55%, #ff4053);
}

.account { display: flex; align-items: center; gap: 24px; text-align: right; }
.account div { display: grid; gap: 2px; }
.account small { color: var(--muted); }
.account a { color: var(--blue); font-weight: 650; text-decoration: none; }

.page { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 80px; }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 36px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 13px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(36px, 5vw, 56px); line-height: 1; letter-spacing: -.04em; }
.hero p:not(.eyebrow) { margin: 14px 0 0; color: var(--muted); font-size: 17px; }

.refresh-button {
    padding: 12px 20px;
    color: white;
    background: var(--blue);
    border-radius: 11px;
    font-weight: 750;
    text-decoration: none;
}

.notice {
    padding: 26px;
    display: flex;
    gap: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 14px 40px rgba(23, 33, 51, .06);
}

.notice-icon { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; background: var(--blue-soft); color: var(--blue); font-weight: 900; }
.notice h2 { margin: 2px 0 8px; font-size: 20px; }
.notice p { margin: 7px 0; color: var(--muted); line-height: 1.55; }
.notice code { display: inline-block; margin: 6px 6px 4px 0; padding: 7px 10px; background: #f0f2f5; border-radius: 8px; font-size: 13px; }
.notice.error .notice-icon { color: #d32f42; background: #fff0f2; }

.tabs { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 13px 16px; color: var(--muted); font-weight: 700; text-decoration: none; border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--blue); }
.chat-count { margin-left: auto; color: var(--muted); font-size: 14px; }

.chat-list { display: grid; gap: 12px; }
.chat-card { min-height: 150px; padding: 18px; display: grid; grid-template-columns: 152px 1fr; gap: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; transition: transform .15s, box-shadow .15s; }
.chat-card:hover { transform: translateY(-2px); box-shadow: 0 16px 42px rgba(23, 33, 51, .08); }

.item-image { height: 114px; overflow: hidden; display: grid; place-items: center; border-radius: 13px; background: #edf0f4; }
.item-image img { width: 100%; height: 100%; object-fit: cover; }
.item-image.placeholder span { color: #b4bac4; font-weight: 900; font-size: 30px; }
.chat-body { min-width: 0; }
.chat-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.contact { min-width: 0; display: flex; align-items: center; gap: 9px; font-size: 15px; }
.contact img, .avatar-placeholder { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder { display: grid; place-items: center; color: white; background: #7b61d1; font-weight: 800; }
.contact a { font-weight: 750; text-decoration: none; }
.chat-heading time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.item-title { margin: 15px 0 11px; display: flex; gap: 10px; text-decoration: none; }
.item-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
.item-title b { white-space: nowrap; }
.message { margin: 0; display: flex; gap: 10px; color: var(--muted); font-size: 14px; }
.message span:first-child { padding: 3px 7px; flex: 0 0 auto; color: #656d79; background: #f0f2f5; border-radius: 6px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.message.incoming span:first-child { color: var(--green); background: #e8f8f1; }
.message span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; align-self: center; }
.open-chat { margin-top: 16px; display: inline-block; color: var(--blue); font-size: 14px; font-weight: 750; text-decoration: none; }
.open-chat:hover { text-decoration: underline; }

.empty-state { padding: 70px 20px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; }
.empty-state div { width: 50px; height: 50px; margin: 0 auto 16px; display: grid; place-items: center; color: var(--green); background: #e8f8f1; border-radius: 50%; font-weight: 900; }
.empty-state h2 { margin: 0; }
.empty-state p { color: var(--muted); }

.conversation-page { width: min(900px, calc(100% - 40px)); }
.back-link { margin-bottom: 24px; display: inline-block; color: var(--blue); font-weight: 750; text-decoration: none; }
.conversation-header { padding: 20px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; }
.conversation-contact { min-width: 0; display: flex; align-items: center; gap: 13px; }
.conversation-contact img, .conversation-avatar { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; }
.conversation-avatar { display: grid; place-items: center; color: white; background: #7b61d1; font-size: 20px; font-weight: 800; }
.conversation-contact h1 { margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 21px; }
.conversation-contact a, .conversation-item a { color: var(--blue); font-size: 13px; text-decoration: none; }
.conversation-item { max-width: 260px; display: flex; align-items: center; gap: 11px; }
.conversation-item img { width: 58px; height: 46px; flex: 0 0 auto; border-radius: 9px; object-fit: cover; }
.conversation-item div { min-width: 0; display: grid; gap: 4px; }
.conversation-item a, .conversation-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.conversation-item span { font-size: 13px; font-weight: 750; }
.conversation-warning { margin: 12px 0; }
.message-history { min-height: 480px; padding: 28px 24px; display: flex; flex-direction: column; gap: 10px; background: #eaf0f5; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 18px 18px; }
.conversation-message { display: flex; justify-content: flex-start; }
.conversation-message.outgoing { justify-content: flex-end; }
.message-bubble { width: fit-content; max-width: min(72%, 580px); padding: 11px 14px 8px; background: var(--panel); border-radius: 5px 16px 16px 16px; box-shadow: 0 2px 8px rgba(23, 33, 51, .06); }
.conversation-message.outgoing .message-bubble { background: #dff1ff; border-radius: 16px 5px 16px 16px; }
.message-bubble p { margin: 0; white-space: pre-wrap; line-height: 1.45; overflow-wrap: anywhere; }
.message-bubble > a { margin-top: 7px; display: inline-block; color: var(--blue); font-size: 13px; font-weight: 700; }
.message-image { max-width: 100%; max-height: 360px; margin-bottom: 8px; display: block; border-radius: 10px; object-fit: contain; }
.message-bubble footer { margin-top: 6px; display: flex; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 11px; }

@media (max-width: 720px) {
    .topbar { padding: 0 18px; }
    .account div { display: none; }
    .page { width: min(100% - 24px, 1120px); padding-top: 34px; }
    .hero { align-items: start; flex-direction: column; }
    .chat-card { grid-template-columns: 84px 1fr; padding: 14px; gap: 13px; }
    .item-image { height: 72px; }
    .chat-heading { align-items: start; }
    .contact img, .avatar-placeholder { display: none; }
    .item-title { flex-direction: column; gap: 4px; }
    .message { display: block; }
    .message span { display: block; }
    .message span:last-child { margin-top: 6px; white-space: normal; }
    .conversation-page { width: min(100% - 16px, 900px); padding-top: 24px; }
    .conversation-header { grid-template-columns: 1fr auto; gap: 14px; }
    .conversation-item { grid-column: 1 / -1; grid-row: 2; max-width: 100%; }
    .conversation-header .refresh-button { grid-column: 2; grid-row: 1; padding: 10px 13px; font-size: 13px; }
    .message-history { min-height: 420px; padding: 18px 10px; }
    .message-bubble { max-width: 88%; }
}

/* CRM */
.crm-topbar { height: 68px; position: sticky; top: 0; z-index: 20; }
.crm-nav { display: flex; align-self: stretch; align-items: center; gap: 4px; }
.crm-nav a { padding: 10px 14px; color: var(--muted); border-radius: 9px; font-size: 14px; font-weight: 750; text-decoration: none; }
.crm-nav a:hover, .crm-nav a.active { color: var(--ink); background: #f0f4f8; }
.sync-button, .save-button { border: 0; cursor: pointer; color: white; background: var(--blue); border-radius: 10px; font: inherit; font-weight: 750; }
.sync-button { padding: 10px 15px; }
.crm-page { padding: 42px max(22px, calc((100vw - 1500px) / 2)) 70px; }
.crm-heading { margin-bottom: 28px; display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.crm-heading h1, .lead-title h1 { margin: 0; font-size: clamp(34px, 4vw, 48px); letter-spacing: -.035em; }
.crm-heading p:not(.eyebrow), .lead-title p:not(.eyebrow) { margin: 9px 0 0; color: var(--muted); }
.total-leads { padding: 9px 13px; color: var(--blue); background: var(--blue-soft); border-radius: 999px; font-size: 14px; font-weight: 800; }
.flash { margin-bottom: 22px; padding: 14px 17px; color: #075f44; background: #e7f8f1; border: 1px solid #c8eddf; border-radius: 12px; }

.kanban-board { padding-bottom: 18px; display: grid; grid-template-columns: repeat(8, minmax(260px, 1fr)); gap: 13px; overflow-x: auto; }
.kanban-column { min-height: 560px; padding: 12px; background: #eceff3; border-radius: 16px; border-top: 4px solid #9ba5b3; }
.kanban-column.status-new { border-top-color: #1683f8; }
.kanban-column.status-contacted { border-top-color: #00a8a8; }
.kanban-column.status-moved_to_telegram { border-top-color: #7b61d1; }
.kanban-column.status-trial_scheduled { border-top-color: #f59f00; }
.kanban-column.status-trial_completed { border-top-color: #d97706; }
.kanban-column.status-thinking { border-top-color: #ec4899; }
.kanban-column.status-won { border-top-color: #00a86b; }
.kanban-column.status-lost { border-top-color: #d94a5c; }
.kanban-column > header { padding: 4px 3px 13px; display: flex; justify-content: space-between; align-items: center; }
.kanban-column h2 { margin: 0; font-size: 14px; }
.kanban-column > header span { width: 25px; height: 25px; display: grid; place-items: center; color: var(--muted); background: white; border-radius: 50%; font-size: 12px; font-weight: 800; }
.kanban-cards { display: grid; gap: 9px; }
.lead-card { padding: 14px; display: block; background: white; border: 1px solid #e2e6eb; border-radius: 12px; box-shadow: 0 4px 13px rgba(23, 33, 51, .045); text-decoration: none; transition: transform .14s, box-shadow .14s; }
.lead-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(23, 33, 51, .09); }
.lead-card-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.lead-card-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-card time { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.lead-card > p { margin: 8px 0; overflow: hidden; color: var(--blue); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.lead-card blockquote { margin: 0; display: -webkit-box; overflow: hidden; color: #555f6f; font-size: 13px; line-height: 1.45; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.lead-tags { margin-top: 11px; display: flex; flex-wrap: wrap; gap: 5px; }
.lead-tags span { padding: 4px 7px; color: #596273; background: #f0f2f5; border-radius: 6px; font-size: 10px; font-weight: 750; }
.column-empty { padding: 28px 8px; color: #9299a5; text-align: center; font-size: 13px; }

.leads-page { max-width: 1220px; }
.leads-table-wrap { overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 17px; }
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table th, .leads-table td { padding: 15px 17px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.leads-table th { color: var(--muted); background: #fafbfc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.leads-table tbody tr:hover { background: #fafcff; }
.leads-table td a { color: var(--blue); font-weight: 750; text-decoration: none; }
.message-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill { padding: 5px 8px; color: #315b82; background: #eaf4ff; border-radius: 7px; font-size: 12px; font-weight: 750; }

.lead-detail-page { max-width: 1220px; }
.lead-title { margin-bottom: 26px; display: flex; justify-content: space-between; align-items: end; }
.lead-main-status { padding: 10px 14px; color: var(--blue); background: var(--blue-soft); border-radius: 10px; font-weight: 800; }
.lead-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(270px, .85fr); gap: 16px; align-items: start; }
.lead-side { display: grid; gap: 16px; }
.lead-panel { background: white; border: 1px solid var(--line); border-radius: 17px; }
.lead-panel > header { padding: 19px 21px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.lead-panel > header h2 { margin: 0; font-size: 18px; }
.lead-panel > header p, .lead-panel > header span { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.lead-form { padding: 21px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lead-form label { display: grid; gap: 7px; }
.lead-form label > span { color: #596273; font-size: 12px; font-weight: 750; }
.lead-form input, .lead-form select, .lead-form textarea { width: 100%; padding: 11px 12px; color: var(--ink); background: #fbfcfd; border: 1px solid #dce1e7; border-radius: 9px; font: inherit; }
.lead-form input:focus, .lead-form select:focus, .lead-form textarea:focus { outline: 2px solid #b9dcff; border-color: var(--blue); }
.lead-form textarea { resize: vertical; }
.lead-form .wide { grid-column: 1 / -1; }
.save-button { padding: 13px 18px; }
.form-errors { padding: 10px 12px; color: #b72d40; background: #fff0f2; border-radius: 9px; }
.form-errors p { margin: 3px 0; }
.avito-source dl { margin: 0; padding: 20px; display: grid; gap: 5px; }
.avito-source dt { margin-top: 10px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.avito-source dt:first-child { margin-top: 0; }
.avito-source dd { margin: 0; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.avito-source a { color: var(--blue); }
.lead-bottom-layout { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, .8fr); gap: 16px; align-items: start; }
.crm-message-list { max-height: 720px; padding: 20px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; background: #edf3f7; border-radius: 0 0 17px 17px; }
.crm-message { display: flex; justify-content: flex-start; }
.crm-message.outgoing { justify-content: flex-end; }
.crm-message > div { max-width: 76%; padding: 10px 12px 7px; background: white; border-radius: 5px 14px 14px; box-shadow: 0 2px 7px rgba(23,33,51,.05); }
.crm-message.outgoing > div { background: #dff1ff; border-radius: 14px 5px 14px 14px; }
.crm-message p { margin: 0; white-space: pre-wrap; line-height: 1.45; overflow-wrap: anywhere; }
.crm-message a { margin-top: 6px; display: block; color: var(--blue); font-size: 12px; }
.crm-message time { margin-top: 6px; display: block; color: var(--muted); font-size: 10px; text-align: right; }
.mini-empty { padding: 50px 15px; color: var(--muted); text-align: center; }
.timeline { padding: 22px; }
.timeline article { position: relative; padding: 0 0 25px 25px; border-left: 2px solid #e2e7ed; }
.timeline article:last-child { padding-bottom: 0; border-color: transparent; }
.timeline-dot { position: absolute; width: 11px; height: 11px; top: 2px; left: -6px; background: var(--blue); border: 3px solid #dceeff; border-radius: 50%; box-sizing: content-box; }
.timeline time { color: var(--muted); font-size: 11px; }
.timeline h3 { margin: 4px 0; font-size: 14px; }
.timeline p { margin: 5px 0; color: #465163; font-size: 12px; font-weight: 750; }
.timeline small { color: var(--muted); line-height: 1.4; }

@media (max-width: 900px) {
    .crm-topbar { height: auto; min-height: 68px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
    .crm-nav { order: 3; width: 100%; overflow-x: auto; }
    .crm-nav a { white-space: nowrap; }
    .lead-layout, .lead-bottom-layout { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .crm-page { padding: 28px 12px 55px; }
    .crm-heading { align-items: start; flex-direction: column; }
    .kanban-board { grid-template-columns: repeat(8, 84vw); }
    .leads-table-wrap { overflow-x: auto; }
    .leads-table { min-width: 850px; }
    .lead-title { align-items: start; flex-direction: column; gap: 14px; }
    .lead-form { grid-template-columns: 1fr; padding: 16px; }
    .lead-form .wide { grid-column: auto; }
    .crm-message > div { max-width: 88%; }
}

/* Authentication */
.auth-page {
    min-height: 100vh;
    color: var(--crm-text);
    background: #f5f6f8;
}
.auth-shell {
    min-height: 100vh;
    padding: 32px 20px;
    display: grid;
    place-items: center;
}
.auth-panel {
    width: min(380px, calc(100vw - 40px));
    padding: 28px;
    background: #fff;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
}
.auth-header {
    padding-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--crm-border);
}
.auth-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--crm-purple);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 850;
}
.auth-header div { display: grid; gap: 2px; }
.auth-header strong { font-size: 14px; }
.auth-header span:last-child { color: var(--crm-muted); font-size: 10px; }
.auth-copy { padding: 24px 0 20px; }
.auth-copy h1 { margin: 0; font-size: 23px; letter-spacing: -.025em; }
.auth-copy p { margin: 7px 0 0; color: var(--crm-muted); font-size: 12px; line-height: 1.5; }
.auth-form { display: grid; gap: 15px; }
.auth-form label { display: grid; gap: 6px; }
.auth-form label span { color: #555c6b; font-size: 11px; font-weight: 750; }
.auth-form input {
    width: 100%;
    height: 42px;
    padding: 0 11px;
    color: var(--crm-text);
    background: #fff;
    border: 1px solid #d9dde5;
    border-radius: 5px;
    font: inherit;
    font-size: 14px;
}
.auth-form input:focus {
    outline: 3px solid #e4e0fb;
    outline-offset: 1px;
    border-color: #7869ca;
}
.auth-form .auth-code { font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: .18em; }
.auth-form button {
    min-height: 42px;
    margin-top: 2px;
    color: #fff;
    background: var(--crm-purple);
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
}
.auth-form button:hover { background: #5c3ee5; }
.auth-form button:focus-visible, .auth-back:focus-visible, .sidebar-logout button:focus-visible {
    outline: 3px solid #d9d2ff;
    outline-offset: 2px;
}
.auth-form button:disabled { cursor: not-allowed; opacity: .5; }
.auth-message { margin: 0 0 16px; padding: 10px 0; border-block: 1px solid; font-size: 11px; line-height: 1.45; }
.auth-message.error { color: #9c3540; border-color: #efcbd0; }
.auth-message.success { color: #197a55; border-color: #cce9dc; }
.auth-back { margin-top: 17px; display: inline-block; color: #5140b4; font-size: 11px; font-weight: 750; text-decoration: none; }
.auth-back:hover { text-decoration: underline; }
.auth-footer { margin-top: 24px; padding-top: 14px; color: #8a909d; border-top: 1px solid var(--crm-border); font-size: 9px; line-height: 1.5; }
.sidebar-logout { margin-left: auto; }
.sidebar-logout button { padding: 5px 2px; color: var(--crm-muted); background: transparent; border: 0; cursor: pointer; font: inherit; font-size: 9px; font-weight: 700; }
.sidebar-logout button:hover { color: var(--crm-text); }

@media (max-width: 620px) {
    .auth-shell { padding: 18px 12px; }
    .auth-panel { width: calc(100vw - 24px); padding: 22px 18px; }
    .auth-form input, .auth-form button { min-height: 44px; font-size: 16px; }
}

/* CRM v2 — light, action-first workspace */
:root {
    --crm-purple: #6d4aff;
    --crm-purple-soft: #f0edff;
    --crm-text: #202332;
    --crm-muted: #7b8192;
    --crm-border: #e6e8ef;
    --crm-bg: #f6f7fa;
    --crm-sidebar: #ffffff;
    --crm-card: #ffffff;
    --crm-shadow: 0 12px 35px rgba(31, 35, 48, .08);
}

.crm-app { min-width: 1100px; color: var(--crm-text); background: var(--crm-bg); }
.crm-app button, .crm-app input, .crm-app select, .crm-app textarea { font: inherit; }
.app-sidebar { width: 220px; height: 100vh; padding: 22px 16px 18px; position: fixed; inset: 0 auto 0 0; z-index: 50; display: flex; flex-direction: column; background: var(--crm-sidebar); border-right: 1px solid var(--crm-border); }
.sidebar-brand { padding: 0 8px 25px; display: flex; align-items: center; gap: 10px; color: var(--crm-text); font-size: 17px; font-weight: 850; text-decoration: none; }
.sidebar-brand .brand-mark { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; background: linear-gradient(135deg, #7754ff, #9c6dff); }
.sidebar-nav { display: grid; gap: 5px; }
.sidebar-nav a { height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 12px; color: #626879; border-radius: 10px; font-size: 14px; font-weight: 700; text-decoration: none; transition: .15s ease; }
.sidebar-nav a:hover { color: var(--crm-text); background: #f7f7fa; }
.sidebar-nav a.active { color: white; background: linear-gradient(135deg, #7752ff, #6644ed); box-shadow: 0 8px 20px rgba(109,74,255,.24); }
.nav-icon { width: 20px; display: inline-grid; place-items: center; font-size: 17px; }
.sidebar-profile { margin-top: auto; padding: 14px 10px 0; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--crm-border); }
.profile-avatar, .lead-avatar { display: inline-grid; place-items: center; flex: 0 0 auto; color: #6444d7; background: #eee9ff; border-radius: 50%; font-weight: 850; }
.profile-avatar { width: 36px; height: 36px; }
.sidebar-profile div { display: grid; gap: 2px; }
.sidebar-profile strong { font-size: 13px; }
.sidebar-profile small { color: var(--crm-muted); font-size: 11px; }

.app-main { min-height: 100vh; margin-left: 220px; }
.app-header { height: 76px; padding: 0 28px; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 25px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--crm-border); backdrop-filter: blur(12px); }
.app-header h1 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.avito-balance { display: flex; align-items: stretch; background: #f8f8fb; border: 1px solid var(--crm-border); border-radius: 9px; }
.avito-balance[hidden] { display: none; }
.avito-balance-part { min-width: 92px; padding: 7px 10px; display: grid; gap: 1px; }
.avito-balance-part + .avito-balance-part { border-left: 1px solid var(--crm-border); }
.avito-balance-part[hidden] { display: none; }
.avito-balance span { color: #7a8090; font-size: 7px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.avito-balance strong { color: #292d3a; font-size: 12px; white-space: nowrap; }
.avito-balance small { color: #6f7584; font-size: 7px; white-space: nowrap; }
.avito-balance.unavailable { background: #f7f7f9; border-color: #e5e6ea; }
.avito-balance.unavailable strong { color: #8a8f9b; font-size: 9px; }
.avito-balance-part.unavailable strong { color: #8a8f9b; font-size: 9px; }
.global-search { width: 280px; height: 40px; padding: 0 12px; display: flex; align-items: center; gap: 8px; background: #f8f8fb; border: 1px solid var(--crm-border); border-radius: 9px; }
.global-search span { color: var(--crm-muted); font-size: 18px; }
.global-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--crm-text); }
.button { min-height: 39px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 750; text-decoration: none; }
.button.primary { color: white; background: var(--crm-purple); }
.button.secondary { color: #505668; background: white; border-color: var(--crm-border); }
.button.success { color: white; background: #25a46f; }
.button.danger { color: white; background: #d6545e; }
.button.muted { color: #5f6677; background: #f1f2f5; }
.button:hover { filter: brightness(.98); transform: translateY(-1px); }

.app-content { padding: 26px 28px 60px; }
.flash { max-width: 900px; margin: 0 0 18px; padding: 12px 15px; border-radius: 10px; font-size: 13px; }
.flash.success { color: #14754f; background: #eaf9f2; border: 1px solid #cbeddd; }
.flash.info { color: #4d3eaa; background: #f0edff; border: 1px solid #ddd5ff; }
.page-intro { margin-bottom: 22px; display: flex; align-items: end; justify-content: space-between; }
.page-intro p { margin: 0 0 5px; color: var(--crm-purple); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.page-intro h2 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
.page-intro > span { padding: 7px 10px; color: #6d55d6; background: var(--crm-purple-soft); border-radius: 7px; font-size: 12px; font-weight: 750; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.metric { min-height: 108px; padding: 17px; display: flex; align-items: flex-start; gap: 13px; background: var(--crm-card); border: 1px solid var(--crm-border); border-radius: 13px; box-shadow: 0 3px 12px rgba(31,35,48,.025); }
.metric > span { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 10px; font-weight: 900; }
.metric div { min-width: 0; }
.metric strong { display: block; font-size: 22px; line-height: 1; }
.metric p { margin: 7px 0 2px; font-size: 12px; font-weight: 800; }
.metric small { color: var(--crm-muted); font-size: 10px; }
.metric.purple > span { color: #704df2; background: #f1edff; }
.metric.blue > span { color: #3f7bdc; background: #eaf2ff; }
.metric.amber > span { color: #b57613; background: #fff4dd; }
.metric.red > span { color: #c9525d; background: #ffedef; }
.metric.green > span { color: #218e63; background: #e6f7ef; }

.today-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.work-panel { min-width: 0; background: var(--crm-card); border: 1px solid var(--crm-border); border-radius: 14px; overflow: hidden; }
.work-panel > header { height: 54px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--crm-border); }
.work-panel > header div { display: flex; align-items: center; gap: 8px; }
.work-panel h2 { margin: 0; font-size: 14px; }
.work-panel header span { min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; color: #6f52e4; background: #f0edff; border-radius: 999px; font-size: 10px; font-weight: 850; }
.work-panel header a { color: var(--crm-muted); font-size: 11px; font-weight: 700; text-decoration: none; }
.work-list { display: grid; }
.work-item { min-height: 70px; padding: 12px 15px; display: flex; align-items: center; gap: 11px; color: inherit; border-bottom: 1px solid #f0f1f5; text-decoration: none; transition: background .13s; }
.work-item:last-child { border-bottom: 0; }
.work-item:hover { background: #faf9ff; }
.lead-avatar { width: 34px; height: 34px; font-size: 12px; }
.work-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
.work-copy strong { font-size: 12px; }
.work-copy p { margin: 0; overflow: hidden; color: #4f5566; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.work-copy small { color: var(--crm-muted); font-size: 9px; }
.attention-tag { padding: 5px 8px; flex: 0 0 auto; color: #7553e6; background: #f0edff; border-radius: 6px; font-size: 9px; font-weight: 800; }
.attention-tag.neutral { color: #576174; background: #f1f2f5; }
.attention-tag.danger { color: #bd4b55; background: #ffedef; }
.trial-item > time { width: 38px; color: #5b6170; font-size: 11px; font-weight: 850; }
.compact-empty { padding: 28px 16px; color: var(--crm-muted); font-size: 12px; text-align: center; }

.funnel-content { padding-right: 0; }
.funnel-board { padding: 0 28px 18px 0; display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 10px; overflow-x: auto; }
.funnel-column { min-height: 610px; padding: 10px; background: #eff1f5; border-radius: 13px; border-top: 3px solid #aeb5c2; }
.funnel-column.stage-new { border-top-color: #4e87e7; }
.funnel-column.stage-communication { border-top-color: #45a77b; }
.funnel-column.stage-trial { border-top-color: #e2a33e; }
.funnel-column.stage-decision { border-top-color: #9a62db; }
.funnel-column.stage-enrolled { border-top-color: #2aa271; }
.funnel-column > header { min-height: 48px; padding: 0 3px 7px; display: flex; align-items: center; justify-content: space-between; }
.funnel-column h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .025em; }
.funnel-stage-copy { min-width: 0; }
.funnel-stage-copy small { margin-top: 4px; display: block; color: var(--crm-muted); font-size: 8px; font-weight: 700; }
.funnel-column header span { width: 23px; height: 23px; display: grid; place-items: center; color: var(--crm-muted); background: white; border-radius: 50%; font-size: 10px; font-weight: 800; }
.funnel-cards { display: grid; gap: 8px; }
.funnel-card { padding: 12px; display: block; color: inherit; background: white; border: 1px solid #e3e5ea; border-radius: 10px; box-shadow: 0 3px 10px rgba(31,35,48,.035); text-decoration: none; }
.funnel-card:hover { border-color: #cfc7ff; box-shadow: 0 8px 20px rgba(31,35,48,.075); }
.funnel-card > div { display: flex; align-items: center; gap: 7px; }
.funnel-card .lead-avatar { width: 27px; height: 27px; font-size: 10px; }
.funnel-card strong { min-width: 0; flex: 1; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.funnel-card time { color: var(--crm-muted); font-size: 8px; }
.funnel-card p { margin: 9px 0 7px; display: -webkit-box; overflow: hidden; color: #5c6271; font-size: 10px; line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.funnel-card > small { padding: 3px 6px; color: #636979; background: #f2f3f6; border-radius: 5px; font-size: 8px; font-weight: 750; }
.card-warning { margin-top: 8px; display: block; color: #bf505a; font-size: 8px; font-weight: 800; }

.list-toolbar { margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.filter-pills { display: flex; gap: 4px; }
.filter-pills a { padding: 8px 11px; color: var(--crm-muted); border-radius: 8px; font-size: 11px; font-weight: 750; text-decoration: none; }
.filter-pills a.active { color: white; background: var(--crm-purple); }
.filter-pills span { margin-left: 4px; opacity: .7; }
.table-search { display: flex; gap: 8px; }
.table-search input { width: 280px; padding: 0 11px; border: 1px solid var(--crm-border); border-radius: 8px; outline: 0; }
.data-table-wrap { overflow: hidden; background: white; border: 1px solid var(--crm-border); border-radius: 13px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 12px 14px; color: var(--crm-muted); background: #fafbfc; border-bottom: 1px solid var(--crm-border); font-size: 9px; text-align: left; text-transform: uppercase; letter-spacing: .04em; }
.data-table td { padding: 13px 14px; color: #4d5362; border-bottom: 1px solid #eef0f4; font-size: 11px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfaff; }
.data-table td strong, .data-table td small { display: block; }
.data-table td small { margin-top: 3px; color: var(--crm-muted); font-size: 9px; }
.person-cell { display: flex; align-items: center; gap: 9px; color: var(--crm-text); text-decoration: none; }
.person-cell .lead-avatar { width: 30px; height: 30px; }
.stage-badge { padding: 5px 7px; display: inline-flex; color: #3f6fb8; background: #eaf2ff; border-radius: 6px; font-size: 9px; font-weight: 800; }
.stage-badge.stage-communication { color: #25795a; background: #e9f8f1; }
.stage-badge.stage-trial { color: #9a6414; background: #fff3dc; }
.stage-badge.stage-decision { color: #7551b5; background: #f2ebff; }
.stage-badge.stage-enrolled { color: #18764f; background: #e8f7ef; }
.stage-badge.closed { color: #9d4d55; background: #ffedef; }
.stage-badge.archived { color: #626978; background: #eceef2; }
.large-empty { padding: 70px 20px; text-align: center; }
.large-empty span { font-size: 28px; color: var(--crm-muted); }
.large-empty h3 { margin: 10px 0 5px; }
.large-empty p { margin: 0; color: var(--crm-muted); }

.lead-drawer { position: fixed; inset: 0; z-index: 100; visibility: hidden; opacity: 0; transition: opacity .18s, visibility .18s; }
.lead-drawer.open { visibility: visible; opacity: 1; }
.drawer-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(29,31,40,.28); backdrop-filter: blur(2px); cursor: default; }
.drawer-panel { width: min(690px, calc(100vw - 250px)); height: 100%; position: absolute; inset: 0 0 0 auto; overflow-y: auto; background: white; box-shadow: -18px 0 50px rgba(31,35,48,.16); transform: translateX(30px); transition: transform .2s ease; }
.lead-drawer.open .drawer-panel { transform: translateX(0); }
.drawer-loading, .drawer-error { min-height: 100%; display: grid; place-items: center; color: var(--crm-muted); }
.drawer-content { min-height: 100%; background: white; }
.drawer-header { min-height: 86px; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--crm-border); }
.lead-identity { display: flex; align-items: center; gap: 12px; }
.lead-identity > .lead-avatar { width: 44px; height: 44px; font-size: 15px; }
.drawer-title-row { display: flex; align-items: center; gap: 9px; }
.drawer-title-row h2 { margin: 0; font-size: 19px; }
.drawer-header-actions { display: flex; align-items: center; gap: 3px; }
.drawer-refresh { width: 34px; height: 34px; display: grid; place-items: center; color: var(--crm-purple); background: transparent; border: 0; border-radius: 8px; cursor: pointer; font-size: 19px; }
.drawer-refresh:hover { background: #f2f0ff; }
.lead-identity p { margin: 4px 0 0; color: var(--crm-muted); font-size: 10px; }
.drawer-close { width: 34px; height: 34px; display: grid; place-items: center; color: #7e8391; background: transparent; border: 0; border-radius: 8px; cursor: pointer; font-size: 23px; }
.drawer-close:hover { background: #f2f3f6; }
.lead-facts { padding: 14px 22px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; background: #fafbfc; border-bottom: 1px solid var(--crm-border); }
.lead-facts div { min-width: 0; }
.lead-facts small, .lead-facts strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-facts small { margin-bottom: 4px; color: var(--crm-muted); font-size: 8px; text-transform: uppercase; }
.lead-facts strong { font-size: 11px; }
.telegram-link { color: var(--crm-purple); font-size: 11px; font-weight: 800; text-decoration: none; }
.telegram-link:hover { text-decoration: underline; }
.form-sync-action { padding: 10px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #565d6d; background: #f8f6ff; border-bottom: 1px solid #e6e0ff; }
.form-sync-action strong, .form-sync-action small { display: block; }
.form-sync-action strong { font-size: 10px; }
.form-sync-action small { margin-top: 2px; color: var(--crm-muted); font-size: 8px; }
.form-sync-action form { margin: 0; }
.form-sync-action button { padding: 7px 10px; color: #6245d4; background: white; border: 1px solid #d9d0ff; border-radius: 7px; cursor: pointer; font: inherit; font-size: 9px; font-weight: 800; white-space: nowrap; }
.quick-actions { padding: 13px 22px; display: flex; gap: 8px; border-bottom: 1px solid var(--crm-border); }
.archive-notice { padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #565d6d; background: #f1f2f5; border-bottom: 1px solid #e1e3e8; }
.archive-notice strong { display: block; font-size: 11px; }
.archive-notice p { margin: 3px 0 0; color: var(--crm-muted); font-size: 9px; }
.archive-notice form { margin: 0; }
.archive-notice button { padding: 7px 10px; color: #5840c7; background: white; border: 1px solid #d8d1fb; border-radius: 7px; cursor: pointer; font-size: 9px; font-weight: 800; }
.action-menu { position: relative; }
.action-menu > summary { height: 38px; padding: 0 13px; display: flex; align-items: center; list-style: none; color: #555c6c; background: white; border: 1px solid var(--crm-border); border-radius: 8px; cursor: pointer; font-size: 11px; font-weight: 800; }
.action-menu.primary-action > summary { color: white; background: var(--crm-purple); border-color: var(--crm-purple); }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu[open] > form, .action-menu[open] > .action-stack { width: 300px; padding: 13px; position: absolute; top: 45px; left: 0; z-index: 20; display: grid; gap: 9px; background: white; border: 1px solid var(--crm-border); border-radius: 10px; box-shadow: var(--crm-shadow); }
.action-menu > form label { display: grid; gap: 5px; color: var(--crm-muted); font-size: 10px; font-weight: 750; }
.action-menu input, .action-menu select, .action-menu textarea, .action-stack select, .action-stack textarea { width: 100%; padding: 9px; color: var(--crm-text); background: white; border: 1px solid var(--crm-border); border-radius: 7px; }
.action-menu form p { margin: 0; color: var(--crm-muted); font-size: 9px; }
.action-stack { display: grid; gap: 3px; }
.action-stack form, .action-stack details form { display: grid; gap: 7px; }
.action-stack details { border-top: 1px solid #f0f1f4; }
.text-action { width: 100%; padding: 9px 6px; display: block; list-style: none; color: #555c6c; background: transparent; border: 0; cursor: pointer; font-size: 11px; font-weight: 750; text-align: left; }
.text-action.danger { color: #bd4b55; }
.text-action.success { color: #20865e; }
.review-actions { padding: 12px 22px; display: flex; align-items: center; gap: 8px; background: #f3fbf7; border-bottom: 1px solid #dcefe5; }
.review-actions a, .review-actions button { padding: 7px 9px; color: #197451; background: white; border: 1px solid #cfe8da; border-radius: 7px; cursor: pointer; font: inherit; font-size: 9px; font-weight: 750; text-decoration: none; }
.review-actions form { margin: 0; }
.trial-summary { margin: 15px 22px 0; padding: 13px; display: flex; align-items: center; justify-content: space-between; background: #faf9ff; border: 1px solid #e6e0ff; border-radius: 10px; }
.trial-summary > div { display: flex; align-items: center; gap: 10px; }
.section-icon { width: 34px; height: 34px; display: grid; place-items: center; color: #8a6519; background: #fff2d8; border-radius: 8px; }
.trial-summary small, .trial-summary strong { display: block; }
.trial-summary small { margin-bottom: 3px; color: var(--crm-muted); font-size: 8px; text-transform: uppercase; }
.trial-summary strong { font-size: 11px; }
.trial-state { padding: 5px 7px; color: #936416; background: #fff1d7; border-radius: 6px; font-size: 9px; font-weight: 800; }
.trial-summary.trial-completed { background: #f2fbf6; border-color: #cfe9db; }
.trial-summary.trial-completed .section-icon { color: #16865b; background: #ddf5e8; }
.trial-state.state-completed { color: #16764f; background: #dcf4e7; }
.trial-summary.trial-cancelled, .trial-summary.trial-no_show { background: #fff7f7; border-color: #f0d7da; }
.trial-state.state-cancelled, .trial-state.state-no_show { color: #af4650; background: #fde7e9; }
.trial-links { justify-content: flex-end; }
.trial-links a { color: var(--crm-purple); font-size: 9px; font-weight: 750; text-decoration: none; }
.trial-links form { margin: 0; }
.inline-retry { padding: 5px 7px; color: #6b54d6; background: white; border: 1px solid #ddd5ff; border-radius: 6px; cursor: pointer; font-size: 9px; font-weight: 750; }
.drawer-tabs { margin-top: 15px; padding: 0 22px; display: flex; gap: 18px; border-bottom: 1px solid var(--crm-border); }
.drawer-tabs button { padding: 11px 1px; color: var(--crm-muted); background: transparent; border: 0; border-bottom: 2px solid transparent; cursor: pointer; font-size: 11px; font-weight: 750; }
.drawer-tabs button.active { color: var(--crm-purple); border-bottom-color: var(--crm-purple); }
.drawer-tab { display: none; }
.drawer-tab.active { display: block; }
.drawer-messages { min-height: 250px; max-height: 490px; padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; background: #f7f8fa; }
.drawer-message { display: flex; justify-content: flex-start; }
.drawer-message.outgoing { justify-content: flex-end; }
.drawer-message > div { max-width: 75%; padding: 9px 11px 7px; background: white; border: 1px solid #e8eaf0; border-radius: 4px 12px 12px 12px; }
.drawer-message.outgoing > div { color: #4a3f80; background: #eeeaff; border-color: #e2dcff; border-radius: 12px 4px 12px 12px; }
.drawer-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.45; }
.drawer-message time { margin-top: 5px; display: block; color: var(--crm-muted); font-size: 8px; text-align: right; }
.open-avito-link { margin: 0; padding: 13px 22px; display: block; color: var(--crm-purple); border-top: 1px solid var(--crm-border); font-size: 10px; font-weight: 750; text-decoration: none; }
.drawer-timeline { padding: 20px 24px; }
.drawer-timeline article { padding: 0 0 20px 18px; position: relative; border-left: 1px solid #e1e4ea; }
.drawer-timeline article:last-child { border-left-color: transparent; }
.drawer-timeline article > span { width: 9px; height: 9px; position: absolute; top: 1px; left: -5px; background: var(--crm-purple); border: 2px solid #e5dfff; border-radius: 50%; box-sizing: content-box; }
.drawer-timeline time, .drawer-timeline strong, .drawer-timeline p, .drawer-timeline em { display: block; }
.drawer-timeline time { color: var(--crm-muted); font-size: 8px; }
.drawer-timeline strong { margin-top: 4px; font-size: 11px; }
.drawer-timeline p { margin: 4px 0 0; color: var(--crm-muted); font-size: 9px; }
.drawer-timeline em { margin-top: 5px; color: var(--crm-purple); font-size: 9px; font-style: normal; font-weight: 750; }
.drawer-form { padding: 20px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drawer-form label { display: grid; gap: 5px; }
.drawer-form label span { color: var(--crm-muted); font-size: 9px; font-weight: 750; }
.drawer-form input, .drawer-form select, .drawer-form textarea { width: 100%; padding: 9px 10px; color: var(--crm-text); background: #fbfbfd; border: 1px solid var(--crm-border); border-radius: 7px; outline: 0; }
.drawer-form input:focus, .drawer-form select:focus, .drawer-form textarea:focus { border-color: #9c88ff; box-shadow: 0 0 0 3px #eeeaff; }
.drawer-form .wide { grid-column: 1 / -1; }
.form-section-title { margin: 8px 0 0; padding-top: 12px; grid-column: 1 / -1; color: #505667; border-top: 1px solid #eceef3; font-size: 11px; }
.form-section-title:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.source-card { margin: 0 22px 22px; padding: 13px; background: #f8f9fb; border-radius: 9px; }
.source-card small { color: var(--crm-muted); font-size: 8px; text-transform: uppercase; }
.source-card p { margin: 6px 0; font-size: 10px; line-height: 1.45; }
.source-card a { color: var(--crm-purple); font-size: 10px; }
.source-links { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.drawer-open { overflow: hidden; }
.detail-content { max-width: 950px; margin: 0 auto; }
.standalone-drawer { background: white; border: 1px solid var(--crm-border); border-radius: 14px; overflow: hidden; }
.standalone-drawer .drawer-close { display: none; }

.analytics-toolbar { margin-bottom: 14px; padding: 10px; display: flex; align-items: center; justify-content: space-between; gap: 14px; background: white; border: 1px solid var(--crm-border); border-radius: 12px; }
.period-activity-card { margin-bottom: 14px; padding: 18px 20px; background: white; border: 1px solid var(--crm-border); border-radius: 12px; }
.period-activity-card h3 { margin: 0; font-size: 14px; }
.period-activity-card header p { margin: 4px 0 0; color: var(--crm-muted); font-size: 9px; }
.period-activity-grid { margin-top: 13px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.period-activity-grid article { padding: 14px; background: #faf9ff; border-radius: 9px; }
.period-activity-grid small, .period-activity-grid strong { display: block; }
.period-activity-grid small { color: var(--crm-muted); font-size: 9px; font-weight: 750; }
.period-activity-grid strong { margin-top: 5px; font-size: 24px; }
.period-activity-grid p { margin: 3px 0 0; color: #6951ce; font-size: 9px; }
.period-tabs { display: flex; gap: 4px; }
.period-tabs a { padding: 8px 11px; color: var(--crm-muted); border-radius: 7px; font-size: 10px; font-weight: 750; text-decoration: none; }
.period-tabs a:hover { background: #f5f3ff; }
.period-tabs a.active { color: white; background: var(--crm-purple); }
.custom-period { display: flex; align-items: center; gap: 7px; }
.custom-period label { display: flex; align-items: center; gap: 5px; color: var(--crm-muted); font-size: 9px; font-weight: 700; }
.custom-period input { padding: 7px 8px; color: var(--crm-text); background: #fbfbfd; border: 1px solid var(--crm-border); border-radius: 7px; font: inherit; }
.custom-period button { padding: 8px 11px; color: white; background: var(--crm-purple); border: 0; border-radius: 7px; cursor: pointer; font-size: 9px; font-weight: 800; }
.analytics-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.analytics-metrics article { padding: 20px; background: white; border: 1px solid var(--crm-border); border-radius: 12px; }
.analytics-metrics small { color: var(--crm-muted); font-size: 10px; font-weight: 700; }
.analytics-metrics strong { margin: 8px 0 4px; display: block; font-size: 30px; }
.analytics-metrics p { margin: 0; color: #6951ce; font-size: 10px; }
.conversion-card { margin-top: 16px; padding: 22px; background: white; border: 1px solid var(--crm-border); border-radius: 13px; }
.conversion-card h3 { margin: 0; font-size: 15px; }
.conversion-card p { margin: 5px 0 0; color: var(--crm-muted); font-size: 10px; }
.conversion-card-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.funnel-refresh { margin: 0; display: flex; align-items: center; gap: 9px; color: var(--crm-muted); font-size: 9px; white-space: nowrap; }
.funnel-refresh button { padding: 7px 9px; color: #6047ca; background: white; border: 1px solid #dcd5f8; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 800; }
.funnel-stage-controls { margin-top: 15px; padding-bottom: 8px; display: flex; align-items: center; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--crm-border); scrollbar-width: thin; }
.funnel-stage-controls > span { padding: 0 8px 0 0; flex: 0 0 auto; color: var(--crm-muted); font-size: 9px; font-weight: 750; }
.funnel-stage-controls button { min-height: 29px; padding: 0 9px; flex: 0 0 auto; color: #757b89; background: transparent; border: 0; border-radius: 6px; cursor: pointer; font: inherit; font-size: 9px; font-weight: 750; white-space: nowrap; transition: color .12s, background .12s, opacity .12s; }
.funnel-stage-controls button:hover { color: #4f3daf; background: #f6f4ff; }
.funnel-stage-controls button[aria-pressed="true"] { color: #5542b8; background: #f1eefe; }
.funnel-stage-controls button[aria-pressed="false"] { color: #9297a3; opacity: .58; }
.funnel-stage-controls button:disabled { color: #a8adb7; background: transparent; cursor: not-allowed; opacity: .5; }
.funnel-stage-controls .funnel-reset { margin-left: auto; color: #6650ca; }
.funnel-stage-controls .funnel-reset[hidden] { display: none; }
.conversion-flow { margin-top: 25px; display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: center; gap: 13px; }
.conversion-flow.five-stages { grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr auto 1fr; gap: 8px; }
.conversion-flow.customizable-funnel { margin-top: 16px; padding: 4px 0 8px; display: flex !important; flex-flow: row nowrap; align-items: stretch; gap: 0; overflow-x: auto; scrollbar-width: thin; }
.conversion-flow.customizable-funnel .funnel-node { min-width: 104px; min-height: 82px; padding: 15px 10px; display: grid; place-content: center; flex: 1 1 104px; background: #faf9ff; border: 1px solid #eeeafd; border-radius: 9px; }
.conversion-flow.customizable-funnel .funnel-node[hidden], .conversion-flow.customizable-funnel .funnel-arrow[hidden] { display: none !important; }
.conversion-flow.customizable-funnel .funnel-node.avito-stage { background: #f7faff; border-color: #e6edf8; }
.conversion-flow.customizable-funnel.empty::after { content: 'Выбери хотя бы один этап в настройках'; width: 100%; padding: 20px; color: var(--crm-muted); background: #faf9ff; border-radius: 10px; text-align: center; font-size: 10px; }
.conversion-flow div { padding: 20px; text-align: center; background: #faf9ff; border-radius: 10px; }
.conversion-flow strong, .conversion-flow span { display: block; }
.conversion-flow strong { font-size: 24px; }
.conversion-flow span { margin-top: 4px; color: var(--crm-muted); font-size: 9px; }
.conversion-flow i { display: grid; gap: 2px; color: #a9aeb9; font-style: normal; text-align: center; }
.conversion-flow i b { color: #6d54d5; font-size: 9px; }
.conversion-flow .funnel-arrow { min-width: 36px; display: grid; place-content: center; flex: 0 0 36px; align-self: center; }
.conversion-flow .funnel-arrow span { color: #a9aeb9; font-size: 15px; }
.analytics-note { color: var(--crm-muted); font-size: 10px; }
.ad-analytics-card { margin-top: 16px; padding: 22px; background: white; border: 1px solid var(--crm-border); border-radius: 13px; }
.ad-analytics-card > header { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.ad-analytics-card h3 { margin: 0; font-size: 15px; }
.ad-analytics-card header p { margin: 5px 0 0; color: var(--crm-muted); font-size: 10px; }
.ad-analytics-actions { display: flex; align-items: center; gap: 8px; }
.ad-analytics-actions > span { padding: 6px 8px; color: #6550c5; background: #f1edff; border-radius: 7px; font-size: 9px; font-weight: 750; white-space: nowrap; }
.ad-analytics-actions form { margin: 0; }
.ad-analytics-actions button { padding: 8px 11px; color: white; background: var(--crm-purple); border: 0; border-radius: 7px; cursor: pointer; font: inherit; font-size: 9px; font-weight: 800; white-space: nowrap; }
.analytics-api-feedback { margin-top: 16px; padding: 11px 13px; color: #226a4d; background: #ebf8f2; border: 1px solid #cdebdc; border-radius: 9px; font-size: 10px; }
.analytics-api-notice { margin-top: 16px; padding: 15px; color: #6c627c; background: #f7f4ff; border: 1px solid #e6dfff; border-radius: 9px; font-size: 10px; }
.ad-summary-grid { margin-top: 17px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ad-summary-grid article { padding: 13px; background: #fafbfc; border: 1px solid #eef0f3; border-radius: 9px; }
.ad-summary-grid small, .ad-summary-grid strong, .ad-summary-grid p { display: block; }
.ad-summary-grid small { color: var(--crm-muted); font-size: 8px; text-transform: uppercase; }
.ad-summary-grid strong { margin-top: 6px; font-size: 18px; }
.ad-summary-grid p { margin: 4px 0 0; color: #6951ce; font-size: 8px; }
.ad-table-wrap { margin-top: 16px; overflow: hidden; border: 1px solid var(--crm-border); border-radius: 10px; }
.ad-analytics-table { width: 100%; border-collapse: collapse; }
.ad-analytics-table th { padding: 10px; color: var(--crm-muted); background: #fafbfc; border-bottom: 1px solid var(--crm-border); font-size: 8px; text-align: left; text-transform: uppercase; }
.ad-analytics-table td { padding: 11px 10px; border-bottom: 1px solid #eef0f3; font-size: 9px; vertical-align: middle; }
.ad-analytics-table tr:last-child td { border-bottom: 0; }
.ad-analytics-table td:first-child { max-width: 260px; }
.ad-analytics-table a { display: block; overflow: hidden; color: var(--crm-text); font-weight: 800; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.ad-analytics-table strong, .ad-analytics-table small { display: block; }
.ad-analytics-table small { margin-top: 3px; color: var(--crm-muted); font-size: 8px; }

.settings-content { max-width: 900px; }
.settings-list { display: grid; gap: 10px; }
.settings-list article { padding: 17px; display: flex; align-items: center; gap: 14px; background: white; border: 1px solid var(--crm-border); border-radius: 12px; }
.integration-logo { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; color: white; border-radius: 11px; font-weight: 900; }
.integration-logo.avito { background: linear-gradient(135deg,#18a9ff,#8756e9,#ff4053); }
.integration-logo.calendar { color: #3176d9; background: #eaf2ff; }
.integration-logo.forms { color: #7851d8; background: #f0ebff; }
.settings-list article > div { min-width: 0; flex: 1; }
.settings-list h3 { margin: 0; font-size: 13px; }
.settings-list p { margin: 4px 0; color: #585e6d; font-size: 11px; }
.settings-list small { color: var(--crm-muted); font-size: 9px; }
.connection-state { padding: 6px 9px; color: #7b8192; background: #f1f2f5; border-radius: 7px; font-size: 9px; font-weight: 800; }
.connection-state.connected { color: #1e8058; background: #e7f7ef; }
.integration-actions { margin-top: 9px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.integration-actions form { margin: 0; }
.mini-button { padding: 7px 9px; display: inline-flex; align-items: center; color: #5a6170; background: white; border: 1px solid var(--crm-border); border-radius: 7px; cursor: pointer; font: inherit; font-size: 9px; font-weight: 750; text-decoration: none; }
.mini-button.primary { color: white; background: var(--crm-purple); border-color: var(--crm-purple); }
.settings-note { margin-top: 14px; padding: 20px; background: white; border: 1px solid var(--crm-border); border-radius: 12px; }
.settings-note h3 { margin: 0 0 8px; font-size: 14px; }
.settings-note p, .settings-note li { color: #5d6473; font-size: 10px; line-height: 1.55; }
.settings-note ol { margin: 10px 0; padding-left: 20px; }
.settings-note li + li { margin-top: 5px; }

@media (max-width: 1250px) {
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .crm-app { min-width: 0; }
    .app-sidebar { width: 72px; padding: 18px 10px; }
    .sidebar-brand { padding: 0 11px 22px; }
    .sidebar-brand > span:last-child, .sidebar-nav a > span:last-child, .sidebar-profile > div { display: none; }
    .sidebar-nav a { padding: 0; justify-content: center; }
    .nav-icon { width: auto; }
    .sidebar-profile { padding: 14px 8px 0; justify-content: center; }
    .app-main { margin-left: 72px; }
    .app-header { padding: 0 18px; }
    .global-search { display: none; }
    .app-content { padding: 22px 18px 50px; }
    .page-intro { align-items: flex-start; flex-direction: column; gap: 10px; }
    .analytics-toolbar { align-items: flex-start; flex-direction: column; }
    .custom-period { flex-wrap: wrap; }
    .analytics-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .conversion-card-header, .ad-analytics-card > header { align-items: flex-start; flex-direction: column; }
    .ad-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ad-table-wrap { overflow-x: auto; }
    .ad-analytics-table { min-width: 760px; }
}

@media (max-width: 620px) {
    .app-sidebar { width: 62px; padding-inline: 8px; }
    .app-main { margin-left: 62px; }
    .app-header { height: auto; min-height: 76px; padding: 10px 14px; align-items: flex-start; flex-wrap: wrap; }
    .app-header > div:first-child { padding-top: 7px; }
    .header-actions { width: 100%; justify-content: space-between; }
    .app-content { padding: 18px 12px 44px; }
    .analytics-metrics, .period-activity-grid { grid-template-columns: 1fr; }
    .period-tabs { width: 100%; overflow-x: auto; }
    .custom-period label { width: 100%; justify-content: space-between; }
    .custom-period input { flex: 1; }
    .funnel-refresh { align-items: flex-start; flex-direction: column; white-space: normal; }
    .ad-analytics-actions { align-items: flex-start; flex-direction: column; }
    .ad-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* CRM v3 — quiet, dense internal workspace */
:root {
    --crm-purple: #5b4cc4;
    --crm-purple-soft: #f1effc;
    --crm-text: #20242e;
    --crm-muted: #697180;
    --crm-border: #dfe2e7;
    --crm-bg: #f5f6f8;
    --crm-card: #ffffff;
    --crm-sidebar: #ffffff;
    --crm-shadow: 0 16px 40px rgba(25, 29, 38, .12);
}

.ui-icon { width: 16px; height: 16px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.crm-app { min-width: 0; font-size: 13px; }
.crm-app :focus-visible { outline: 2px solid #9d92df; outline-offset: 2px; }
.app-sidebar { width: 208px; padding: 18px 12px 16px; }
.sidebar-brand { padding: 0 10px 20px; gap: 9px; font-size: 16px; }
.sidebar-brand .brand-mark, .brand-mark { border-radius: 6px; background: var(--crm-purple); box-shadow: none; }
.sidebar-nav { gap: 2px; }
.sidebar-nav a { height: 40px; padding: 0 11px; gap: 10px; border-radius: 5px; color: #5f6673; font-size: 13px; font-weight: 650; transition: color .12s, background .12s; }
.sidebar-nav a:hover { color: var(--crm-text); background: #f4f4f7; }
.sidebar-nav a.active { color: #4c3db1; background: var(--crm-purple-soft); box-shadow: inset 3px 0 #5b4cc4; }
.nav-icon { width: 18px; height: 18px; }
.sidebar-profile { padding: 14px 9px 0; }
.profile-avatar { width: 32px; height: 32px; font-size: 12px; }
.sidebar-profile strong { font-size: 12px; }
.sidebar-profile small { font-size: 10px; }

.app-main { margin-left: 208px; }
.app-header { height: 64px; padding: 0 24px; gap: 18px; background: #fff; backdrop-filter: none; }
.app-header h1 { font-size: 18px; letter-spacing: -.015em; }
.header-actions { gap: 8px; }
.avito-balance { background: transparent; border: 0; border-radius: 0; }
.avito-balance-part { min-width: 86px; padding: 3px 10px; }
.avito-balance span { font-size: 8px; }
.avito-balance strong { font-size: 12px; }
.avito-balance small { font-size: 8px; }
.global-search { width: 240px; height: 36px; border-radius: 6px; background: #f7f7f9; }
.global-search span { font-size: inherit; }
.global-search input { font-size: 12px; }
.button { min-height: 36px; padding: 0 12px; gap: 7px; border-radius: 6px; font-size: 12px; }
.button:hover { filter: none; transform: none; }
.button.secondary:hover { color: var(--crm-purple); border-color: #c7c0e9; background: #faf9ff; }
.app-content { padding: 20px 24px 48px; }
.flash { padding: 10px 13px; border-radius: 5px; font-size: 12px; }

.section-heading { min-height: 42px; margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.015em; }
.section-heading p { margin: 4px 0 0; color: var(--crm-muted); font-size: 11px; }
.section-heading > strong { min-width: 26px; padding: 3px 7px; color: #5b6170; background: #eceef2; border-radius: 4px; font-size: 11px; text-align: center; }
.section-heading .period-label { padding: 0; color: var(--crm-muted); background: transparent; font-weight: 600; }

.metric-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: #fff; border-block: 1px solid var(--crm-border); }
.metric-strip article { min-width: 0; padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: 10px; }
.metric-strip article + article { border-left: 1px solid var(--crm-border); }
.metric-strip span { color: #4f5663; font-size: 11px; font-weight: 650; }
.metric-strip strong { grid-column: 2; grid-row: 1 / span 2; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-strip small { margin-top: 4px; color: var(--crm-muted); font-size: 9px; }
.metric-strip .metric-alert strong { color: #b54d57; }

.today-grid { margin-top: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; align-items: stretch; background: #fff; border-block: 1px solid var(--crm-border); }
.work-panel { min-height: 240px; background: transparent; border: 0; border-radius: 0; overflow: visible; }
.work-panel + .work-panel { border-left: 1px solid var(--crm-border); }
.work-panel > header { height: 46px; padding: 0 13px; }
.work-panel h2 { font-size: 12px; }
.work-panel header span { min-width: 18px; height: 18px; border-radius: 4px; font-size: 9px; }
.work-panel header a { color: #5b4cc4; font-size: 10px; }
.work-item { min-height: 64px; padding: 10px 12px; gap: 9px; }
.work-item:hover { background: #f8f7fc; }
.lead-avatar { width: 30px; height: 30px; color: #5142b2; background: #eeeafd; font-size: 11px; }
.work-copy strong { font-size: 11px; }
.work-copy p { font-size: 10px; }
.work-copy small { font-size: 9px; }
.attention-tag { padding: 3px 5px; background: transparent; border-radius: 3px; font-size: 8px; }
.attention-tag.neutral { background: transparent; }
.attention-tag.danger { background: #fff0f1; }
.compact-empty { padding: 22px 13px; text-align: left; font-size: 11px; }

.funnel-content { padding-right: 0; }
.funnel-board { padding: 0 24px 18px 0; grid-template-columns: repeat(5, minmax(205px, 1fr)); gap: 8px; }
.funnel-column { min-height: calc(100vh - 140px); padding: 8px; background: #eef0f3; border-radius: 5px; border-top-width: 2px; }
.funnel-column > header { min-height: 42px; padding: 0 2px 6px; }
.funnel-column h3 { font-size: 11px; }
.funnel-stage-copy small { font-size: 9px; }
.funnel-column header span { width: auto; height: auto; padding: 0; background: transparent; border-radius: 0; font-size: 10px; }
.funnel-cards { gap: 6px; }
.funnel-card { padding: 11px; border-radius: 5px; box-shadow: none; }
.funnel-card:hover { border-color: #aaa0df; box-shadow: none; }
.funnel-card .lead-avatar { width: 26px; height: 26px; }
.funnel-card strong { font-size: 11px; }
.funnel-card time, .funnel-card > small, .card-warning { font-size: 9px; }
.funnel-card p { font-size: 10px; }

.list-toolbar { margin-bottom: 10px; align-items: flex-end; }
.filter-pills { gap: 18px; border-bottom: 1px solid var(--crm-border); }
.filter-pills a { margin-bottom: -1px; padding: 8px 1px; border-bottom: 2px solid transparent; border-radius: 0; font-size: 11px; }
.filter-pills a.active { color: var(--crm-purple); background: transparent; border-bottom-color: var(--crm-purple); }
.table-search input { min-height: 34px; border-radius: 5px; }
.data-table-wrap { border-radius: 5px; }
.data-table th { padding: 10px 12px; font-size: 9px; }
.data-table td { padding: 11px 12px; font-size: 11px; }
.data-table td small { font-size: 9px; }
.stage-badge { border-radius: 3px; font-size: 9px; }
.large-empty { padding: 54px 20px; }
.large-empty h3 { margin: 0 0 5px; font-size: 15px; }

.lead-drawer { transition: opacity .12s, visibility .12s; }
.drawer-backdrop { background: rgba(25, 28, 35, .25); backdrop-filter: none; }
.drawer-panel { width: min(720px, calc(100vw - 208px)); box-shadow: -12px 0 36px rgba(25, 29, 38, .13); }
.lead-drawer.open .drawer-panel { transform: none; }
.drawer-header { min-height: 76px; padding: 14px 20px; }
.lead-identity > .lead-avatar { width: 38px; height: 38px; font-size: 14px; }
.drawer-title-row h2 { font-size: 17px; }
.lead-identity p { font-size: 10px; }
.drawer-refresh, .drawer-close { width: 34px; height: 34px; border-radius: 4px; font-size: inherit; }
.drawer-refresh:hover, .drawer-close:hover { background: #f1f2f5; }
.lead-facts { padding: 12px 20px; gap: 12px; background: #fafafa; }
.lead-facts small { font-size: 9px; }
.lead-facts strong, .telegram-link { font-size: 11px; }
.form-sync-action { padding: 9px 20px; background: #faf9fe; }
.form-sync-action strong { font-size: 11px; }
.form-sync-action small { font-size: 9px; }
.form-sync-action button { min-height: 32px; padding: 0 9px; display: inline-flex; align-items: center; gap: 6px; border-radius: 5px; font-size: 10px; }
.quick-actions { padding: 11px 20px; }
.action-menu > summary { height: 36px; gap: 6px; border-radius: 5px; font-size: 11px; }
.action-menu[open] > form, .action-menu[open] > .action-stack { border-radius: 6px; }
.action-menu > form label, .action-menu form p, .text-action { font-size: 11px; }
.review-actions { padding: 10px 20px; }
.review-actions a, .review-actions button { border-radius: 4px; font-size: 10px; }
.trial-summary { margin: 0; padding: 12px 20px; border: 0; border-bottom: 1px solid var(--crm-border); border-left: 3px solid #c18a2d; border-radius: 0; background: #fffdf7; }
.trial-summary.trial-completed { background: #f7fbf8; border-color: var(--crm-border); border-left-color: #2d9369; }
.trial-summary.trial-cancelled, .trial-summary.trial-no_show { background: #fff8f8; border-color: var(--crm-border); border-left-color: #bd5861; }
.trial-summary small { font-size: 9px; }
.trial-summary strong { font-size: 12px; }
.trial-links a { font-size: 10px; }
.trial-state { border-radius: 3px; font-size: 9px; }
.drawer-tabs { margin-top: 0; padding: 0 20px; gap: 20px; }
.drawer-tabs button { padding: 11px 1px 9px; font-size: 11px; }
.drawer-messages { min-height: 260px; padding: 16px 20px; background: #f5f6f8; }
.drawer-message > div { border-radius: 3px 10px 10px 10px; }
.drawer-message.outgoing > div { border-radius: 10px 3px 10px 10px; }
.drawer-message p { font-size: 12px; }
.drawer-message time { font-size: 9px; }
.open-avito-link { padding: 12px 20px; font-size: 11px; }
.drawer-timeline { padding: 18px 22px; }
.drawer-timeline time { font-size: 9px; }
.drawer-timeline strong { font-size: 12px; }
.drawer-timeline p, .drawer-timeline em { font-size: 10px; }
.drawer-form { padding: 18px 20px; gap: 12px; }
.drawer-form label span { font-size: 10px; }
.drawer-form input, .drawer-form select, .drawer-form textarea { min-height: 36px; border-radius: 5px; font-size: 12px; }
.form-section-title { font-size: 12px; }
.source-card { margin: 0 20px 20px; padding: 14px 0 0; background: transparent; border-top: 1px solid var(--crm-border); border-radius: 0; }
.source-card small { font-size: 9px; }
.source-card p, .source-card a { font-size: 11px; }
.standalone-drawer { border-radius: 5px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--crm-purple); }

.analytics-content { padding-top: 0; }
.analytics-section-nav { height: 47px; margin-bottom: 18px; display: flex; align-items: flex-end; gap: 24px; border-bottom: 1px solid var(--crm-border); }
.analytics-section-nav a { height: 47px; padding-top: 17px; color: var(--crm-muted); border-bottom: 2px solid transparent; font-size: 12px; font-weight: 700; text-decoration: none; }
.analytics-section-nav a:hover { color: var(--crm-text); }
.analytics-section-nav a.active { color: var(--crm-purple); border-bottom-color: var(--crm-purple); }
.analytics-toolbar { margin-bottom: 0; padding: 4px 0; background: transparent; border: 0; border-block: 1px solid var(--crm-border); border-radius: 0; }
.period-tabs { gap: 18px; }
.period-tabs a { min-height: 38px; padding: 11px 1px 8px; border-bottom: 2px solid transparent; border-radius: 0; font-size: 11px; }
.period-tabs a:hover { color: var(--crm-purple); background: transparent; }
.period-tabs a.active { color: var(--crm-purple); background: transparent; border-bottom-color: var(--crm-purple); }
.custom-period-disclosure { position: relative; }
.custom-period-disclosure > summary, .funnel-settings > summary { color: #5b6170; cursor: pointer; font-size: 10px; font-weight: 750; list-style: none; white-space: nowrap; }
.custom-period-disclosure > summary::-webkit-details-marker, .funnel-settings > summary::-webkit-details-marker { display: none; }
.custom-period-disclosure > summary::after { margin-left: 6px; content: '↓'; color: #8b91a0; }
.custom-period-disclosure[open] > summary, .funnel-settings[open] > summary { color: var(--crm-purple); }
.custom-period { min-width: 395px; padding: 10px; position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; background: #fff; border: 1px solid var(--crm-border); border-radius: 6px; box-shadow: var(--crm-shadow); }
.custom-period label { font-size: 10px; }
.custom-period input { min-height: 32px; border-radius: 4px; }
.custom-period button { min-height: 32px; border-radius: 4px; font-size: 10px; }
.analytics-context-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: #fff; border-bottom: 1px solid var(--crm-border); }
.analytics-context-strip article { min-width: 0; padding: 13px 14px; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; align-items: baseline; }
.analytics-context-strip article + article { border-left: 1px solid var(--crm-border); }
.analytics-context-strip span { color: var(--crm-muted); font-size: 10px; font-weight: 650; }
.analytics-context-strip strong { font-size: 19px; line-height: 1; }
.analytics-context-strip small { grid-column: 1 / -1; color: var(--crm-muted); font-size: 9px; }
.analytics-section { margin: 0; padding: 18px 0; background: transparent; border: 0; border-bottom: 1px solid var(--crm-border); border-radius: 0; }
.conversion-card h3 { margin: 0; font-size: 14px; }
.conversion-card p { margin: 4px 0 0; color: var(--crm-muted); font-size: 10px; }
.conversion-card-header { align-items: flex-start; }
.funnel-settings { position: relative; }
.funnel-settings > summary { min-height: 30px; padding: 7px 0; }
.funnel-stage-controls { min-width: 460px; margin: 0; padding: 8px 10px; position: absolute; top: calc(100% + 5px); right: 0; z-index: 15; gap: 13px; overflow: visible; background: #fff; border: 1px solid var(--crm-border); border-radius: 6px; box-shadow: var(--crm-shadow); }
.funnel-stage-controls button { min-height: 30px; padding: 0 1px; border-bottom: 2px solid transparent; border-radius: 0; font-size: 10px; }
.funnel-stage-controls button:hover { color: #4435a8; background: transparent; }
.funnel-stage-controls button[aria-pressed="true"] { color: #4435a8; background: transparent; border-bottom-color: var(--crm-purple); }
.funnel-stage-controls button[aria-pressed="false"] { color: #9297a3; background: transparent; text-decoration: none; opacity: .55; }
.funnel-stage-controls .funnel-reset { margin-left: auto; }
.conversion-flow.customizable-funnel { margin-top: 12px; padding: 0; background: #fff; border-block: 1px solid var(--crm-border); }
.conversion-flow.customizable-funnel .funnel-node { min-width: 112px; min-height: 76px; padding: 12px 10px; background: transparent; border: 0; border-radius: 0; }
.conversion-flow strong { font-size: 21px; }
.conversion-flow span { font-size: 9px; }
.conversion-flow .funnel-arrow { min-width: 34px; flex-basis: 34px; }
.conversion-flow i b { font-size: 9px; }
.avito-report-status { min-height: 55px; padding: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--crm-border); }
.avito-report-status > div { min-width: 0; display: grid; gap: 2px; }
.avito-report-status strong { font-size: 11px; }
.avito-report-status span { color: var(--crm-muted); font-size: 9px; }
.avito-report-status form { margin: 0; }
.avito-report-status button { min-height: 32px; padding: 0 10px; color: #5140b4; background: #fff; border: 1px solid #cfc8ee; border-radius: 4px; cursor: pointer; font: inherit; font-size: 10px; font-weight: 750; white-space: nowrap; }
.avito-report-status button:hover { background: #f8f7fd; }
.analytics-api-feedback { margin-top: 10px; padding: 9px 0; color: #197a55; background: transparent; border: 0; border-bottom: 1px solid #cdebdc; border-radius: 0; font-size: 10px; }
.avito-conversion-strip { display: flex; align-items: stretch; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--crm-border); scrollbar-width: thin; }
.avito-conversion-strip article { min-width: 120px; min-height: 79px; padding: 13px 12px; display: grid; align-content: center; flex: 1 1 120px; }
.avito-conversion-strip article span { color: var(--crm-muted); font-size: 9px; }
.avito-conversion-strip article strong { margin-top: 4px; font-size: 21px; }
.avito-conversion-strip i { min-width: 38px; display: grid; place-content: center; flex: 0 0 38px; color: #a9aeb9; font-style: normal; text-align: center; }
.avito-conversion-strip i b { color: var(--crm-purple); font-size: 9px; }
.avito-conversion-strip i span { margin-top: 2px; font-size: 14px; }
.ad-context-strip { border-top: 0; }
.ad-performance-table-section { padding-top: 18px; }
.ad-performance-table-section > header { display: flex; align-items: center; justify-content: space-between; }
.ad-performance-table-section h3 { margin: 0; font-size: 14px; }
.ad-performance-table-section header span { color: var(--crm-muted); font-size: 10px; }
.ad-table-filters { min-height: 54px; margin-top: 10px; display: flex; align-items: end; gap: 8px; border-block: 1px solid var(--crm-border); }
.ad-table-filters label { display: grid; gap: 4px; color: var(--crm-muted); font-size: 8px; font-weight: 750; text-transform: uppercase; }
.ad-table-filters input, .ad-table-filters select { height: 32px; min-width: 172px; padding: 0 9px; color: var(--crm-text); background: #fff; border: 1px solid var(--crm-border); border-radius: 4px; font: inherit; font-size: 10px; text-transform: none; }
.ad-table-filters input { min-width: 250px; }
.ad-table-filters input:focus, .ad-table-filters select:focus { outline: 2px solid #dcd6f7; outline-offset: 1px; border-color: #9184d6; }
.ad-table-filters button { height: 32px; margin-bottom: 0; padding: 0 5px; color: #5b4cc4; background: transparent; border: 0; cursor: pointer; font: inherit; font-size: 10px; font-weight: 750; }
.ad-table-filters button[hidden] { display: none; }
.ad-table-wrap { margin-top: 10px; overflow: hidden; border-radius: 4px; }
.ad-analytics-table th, .ad-analytics-table td { font-size: 9px; }
.ad-analytics-table small { font-size: 9px; }
.ad-analytics-table tr[hidden] { display: none; }

@media (max-width: 620px) {
    .ad-table-filters { height: auto; padding-block: 9px; align-items: stretch; flex-direction: column; }
    .ad-table-filters label { width: 100%; }
    .ad-table-filters input, .ad-table-filters select { width: 100%; min-width: 0; }
    .ad-table-filters button { align-self: flex-start; }
}
.analytics-note { margin: 14px 0 0; color: var(--crm-muted); font-size: 10px; line-height: 1.45; }

.settings-content { max-width: 940px; }
.settings-list { gap: 0; background: #fff; border-block: 1px solid var(--crm-border); }
.settings-list article { min-height: 86px; padding: 15px 16px; background: transparent; border: 0; border-bottom: 1px solid var(--crm-border); border-radius: 0; }
.settings-list article:last-child { border-bottom: 0; }
.settings-list h3 { font-size: 13px; }
.settings-list p { font-size: 11px; }
.settings-list small { font-size: 10px; }
.connection-state { border-radius: 3px; font-size: 9px; }
.mini-button { min-height: 30px; border-radius: 5px; font-size: 10px; }
.settings-note { margin-top: 20px; padding: 16px 0 0; background: transparent; border: 0; border-top: 1px solid var(--crm-border); border-radius: 0; }
.settings-note h3 { font-size: 13px; }
.settings-note p, .settings-note li { font-size: 11px; }

/* Legacy Avito chat views follow the same restraint. */
.topbar { height: 62px; }
.page { padding-top: 34px; }
.hero { margin-bottom: 24px; }
.hero h1 { font-size: clamp(28px, 4vw, 36px); letter-spacing: -.025em; }
.hero p:not(.eyebrow) { font-size: 14px; }
.eyebrow { font-size: 11px; }
.refresh-button { border-radius: 6px; }
.notice { padding: 18px; border-radius: 6px; box-shadow: none; }
.empty-state { padding: 48px 20px; border-radius: 6px; }
.chat-list { gap: 8px; }
.chat-card { min-height: 132px; border-radius: 6px; transition: background .12s; }
.chat-card:hover { transform: none; background: #fafafa; box-shadow: none; }
.item-image { border-radius: 5px; }
.conversation-header { border-radius: 6px 6px 0 0; }
.message-history { border-radius: 0 0 6px 6px; }

@media (max-width: 1180px) {
    .today-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .work-panel:nth-child(3) { border-left: 0; border-top: 1px solid var(--crm-border); }
    .work-panel:nth-child(4) { border-top: 1px solid var(--crm-border); }
    .analytics-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .analytics-metrics article:nth-child(4) { border-left: 0; }
    .analytics-metrics article:nth-child(n+4) { border-top: 1px solid var(--crm-border); }
}

@media (max-width: 900px) {
    .app-sidebar { width: 68px; padding: 16px 9px; }
    .sidebar-brand { padding-inline: 10px; }
    .app-main { margin-left: 68px; }
    .app-header { padding: 0 16px; }
    .app-content { padding: 18px 16px 44px; }
    .analytics-toolbar { align-items: flex-start; }
    .analytics-context-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .analytics-context-strip article:nth-child(3) { border-left: 0; }
    .analytics-context-strip article:nth-child(n+3) { border-top: 1px solid var(--crm-border); }
    .ad-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ad-summary-grid article:nth-child(4) { border-left: 0; }
    .ad-summary-grid article:nth-child(n+4) { border-top: 1px solid var(--crm-border); }
    .drawer-panel { width: min(720px, calc(100vw - 68px)); }
}

@media (max-width: 620px) {
    .crm-app { padding-bottom: 64px; }
    .app-sidebar { width: 100%; height: 64px; padding: 0; inset: auto 0 0; border-top: 1px solid var(--crm-border); border-right: 0; }
    .sidebar-brand, .sidebar-profile { display: none; }
    .sidebar-nav { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; }
    .sidebar-nav a { height: 64px; padding: 7px 2px 5px; flex-direction: column; justify-content: center; gap: 4px; border-radius: 0; font-size: 9px; }
    .sidebar-nav a.active { box-shadow: inset 0 2px var(--crm-purple); }
    .nav-icon { width: 18px; height: 18px; }
    .sidebar-nav a > span:last-child { display: block; }
    .app-main { margin-left: 0; }
    .app-header { min-height: 58px; padding: 8px 12px; align-items: center; }
    .app-header > div:first-child { padding-top: 0; }
    .app-header h1 { font-size: 16px; }
    .header-actions { width: auto; margin-left: auto; }
    .avito-balance-part { min-width: 64px; padding-inline: 6px; }
    .avito-balance small { display: none; }
    .sync-control { width: 36px; padding: 0; }
    .sync-control span { display: none; }
    .app-content { padding: 14px 12px 28px; }
    .analytics-content { padding-top: 0; }
    .analytics-section-nav { height: 45px; margin: 0 -12px 14px; padding: 0 12px; gap: 20px; overflow-x: auto; }
    .analytics-section-nav a { height: 45px; padding-top: 16px; white-space: nowrap; }
    .section-heading { min-height: 0; margin-bottom: 10px; }
    .section-heading h2 { font-size: 16px; }
    .analytics-intro { flex-direction: column; gap: 4px; }
    .analytics-intro .period-label { align-self: flex-start; white-space: nowrap; }
    .metric-strip { grid-template-columns: repeat(5, minmax(118px, 1fr)); overflow-x: auto; }
    .metric-strip article { padding: 11px 12px; }
    .metric-strip strong { font-size: 20px; }
    .today-grid { grid-template-columns: 1fr; }
    .work-panel { min-height: 0; }
    .work-panel + .work-panel, .work-panel:nth-child(3) { border-left: 0; border-top: 1px solid var(--crm-border); }
    .funnel-board { grid-template-columns: repeat(5, 82vw); padding-right: 12px; }
    .funnel-column { min-height: calc(100vh - 164px); }
    .list-toolbar { align-items: stretch; flex-direction: column; gap: 8px; }
    .filter-pills { width: 100%; gap: 15px; overflow-x: auto; }
    .table-search input { width: 100%; min-height: 36px; }
    .data-table-wrap { overflow-x: auto; }
    .data-table { min-width: 800px; }
    .drawer-panel { width: 100vw; }
    .lead-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lead-facts div:nth-child(n+4) { margin-top: 6px; }
    .trial-summary { align-items: flex-start; flex-direction: column; gap: 8px; }
    .drawer-form { grid-template-columns: 1fr; }
    .drawer-form .wide, .form-section-title { grid-column: auto; }
    .analytics-toolbar { gap: 4px; align-items: stretch; }
    .period-tabs { width: 100%; gap: 14px; overflow-x: auto; }
    .custom-period-disclosure { width: 100%; padding: 7px 0; }
    .custom-period { min-width: 0; width: 100%; margin-top: 8px; padding: 9px 0 3px; position: static; flex-wrap: wrap; background: transparent; border: 0; border-top: 1px solid var(--crm-border); border-radius: 0; box-shadow: none; }
    .custom-period label { flex: 1 1 145px; }
    .custom-period input { min-width: 0; width: 100%; }
    .period-activity-grid, .analytics-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .period-activity-grid article + article { border-left: 1px solid var(--crm-border); }
    .analytics-metrics article:nth-child(odd) { border-left: 0; }
    .analytics-metrics article:nth-child(n+3) { border-top: 1px solid var(--crm-border); }
    .conversion-card-header, .ad-analytics-card > header { gap: 10px; }
    .funnel-settings { width: 100%; }
    .funnel-stage-controls { min-width: 0; width: 100%; margin-top: 4px; padding: 6px 0; position: static; flex-wrap: wrap; gap: 7px 13px; background: transparent; border: 0; border-block: 1px solid var(--crm-border); border-radius: 0; box-shadow: none; }
    .funnel-refresh, .ad-analytics-actions { width: 100%; }
    .avito-report-status { align-items: flex-start; flex-direction: column; gap: 8px; }
    .avito-conversion-strip { margin-right: -12px; padding-right: 12px; }
    .ad-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ad-summary-grid article:nth-child(odd) { border-left: 0; }
    .ad-summary-grid article:nth-child(n+3) { border-top: 1px solid var(--crm-border); }
    .settings-list article { align-items: flex-start; }
    .connection-state { flex: 0 0 auto; }
}
