.app-container .main-content.crm-stats-page {
    flex: 1;
    margin-left: calc(240px + var(--sidebar-layout-offset, 0px) - var(--sidebar-main-seam, 0px));
    padding: 20px;
    background: #f2f2f7;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.app-container.sidebar-collapsed .main-content.crm-stats-page {
    margin-left: calc(60px + var(--sidebar-layout-offset, 0px) - var(--sidebar-main-seam, 0px));
}

@media (max-width: 768px) {
    .app-container .main-content.crm-stats-page {
        margin-left: 0;
        padding: 12px;
    }
}

.crm-stats-container {
    max-width: 1200px;
    margin: 0 auto;
}

.crm-stats-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    padding: 22px 24px;
    margin-bottom: 18px;
}

.crm-stats-header-main {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.crm-stats-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #007aff, #5856d6);
    font-size: 20px;
    flex-shrink: 0;
}

.crm-stats-header h1 {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 700;
    color: #1d1d1f;
}

.crm-stats-header p {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.45;
    max-width: 560px;
}

.crm-stats-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.crm-stats-select,
.crm-stats-search {
    border: 1px solid #d1d1d6;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    background: #fff;
    color: #1d1d1f;
}

.crm-stats-search {
    min-width: 220px;
}

.crm-stats-btn {
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #007aff;
    color: #fff;
}

.crm-stats-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.crm-stats-status {
    font-size: 13px;
    color: #666;
    margin-bottom: 14px;
    min-height: 20px;
}

.crm-stats-status--error {
    color: #c62828;
}

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

@media (max-width: 900px) {
    .crm-stats-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.crm-stats-card {
    background: #fff;
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    padding: 16px 18px;
}

.crm-stats-card-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    margin-bottom: 6px;
}

.crm-stats-card-value {
    font-size: 28px;
    font-weight: 700;
    color: #1d1d1f;
    line-height: 1.1;
}

.crm-stats-card-sub {
    margin-top: 4px;
    font-size: 12px;
    color: #888;
}

.crm-stats-intents {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.crm-stats-intent-chip {
    border: 1px solid #e5e5ea;
    background: #fff;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.crm-stats-intent-chip:hover {
    border-color: #007aff;
}

.crm-stats-intent-chip.active {
    background: rgba(0, 122, 255, 0.1);
    border-color: #007aff;
    color: #007aff;
    font-weight: 600;
}

.crm-stats-intent-chip strong {
    margin-left: 4px;
}

.crm-stats-board {
    background: #fff;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    overflow: hidden;
}

.crm-stats-board-head {
    padding: 16px 20px;
    border-bottom: 1px solid #ececec;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.crm-stats-board-head h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #1d1d1f;
}

.crm-stats-board-head span {
    font-size: 13px;
    color: #888;
}

.crm-stats-table-wrap {
    overflow-x: auto;
}

.crm-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.crm-stats-table th,
.crm-stats-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f2;
    vertical-align: top;
}

.crm-stats-table th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    background: #fafafa;
}

.crm-stats-table tbody tr {
    cursor: pointer;
    transition: background 0.1s ease;
}

.crm-stats-table tbody tr:hover {
    background: #f8f9ff;
}

.crm-stats-table tbody tr.expanded {
    background: #f3f6ff;
}

.crm-stats-question {
    font-weight: 500;
    color: #1d1d1f;
    line-height: 1.45;
    word-break: break-word;
}

.crm-stats-variants {
    margin-top: 4px;
    font-size: 12px;
    color: #888;
    line-height: 1.4;
}

.crm-stats-count {
    font-weight: 700;
    color: #007aff;
    white-space: nowrap;
}

.crm-stats-intent-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f0f0f2;
    color: #555;
    white-space: nowrap;
}

.crm-stats-intent-badge--quote { background: #e8f4ff; color: #0066cc; }
.crm-stats-intent-badge--schedule { background: #e8f8ef; color: #1b7f4a; }
.crm-stats-intent-badge--cancel { background: #fff0f0; color: #c62828; }
.crm-stats-intent-badge--service { background: #f3eeff; color: #6b4fc7; }
.crm-stats-intent-badge--greeting { background: #fff8e6; color: #9a6700; }
.crm-stats-intent-badge--confirm { background: #e8f8ef; color: #1b7f4a; }
.crm-stats-intent-badge--thanks { background: #fff4e6; color: #b45309; }

.crm-stats-detail-row td {
    background: #fafbff;
    padding: 0;
    border-bottom: 1px solid #e8ecf8;
}

.crm-stats-detail {
    padding: 14px 20px 18px;
}

.crm-stats-detail h4 {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.crm-stats-client-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-stats-client-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #ececec;
    border-radius: 8px;
    flex-wrap: wrap;
}

.crm-stats-client-item a {
    color: #007aff;
    font-weight: 600;
    text-decoration: none;
}

.crm-stats-client-item a:hover {
    text-decoration: underline;
}

.crm-stats-client-meta {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}

.crm-stats-client-sample {
    flex: 1 1 100%;
    font-size: 13px;
    color: #444;
    line-height: 1.45;
    font-style: italic;
}

.crm-stats-empty {
    padding: 48px 24px;
    text-align: center;
    color: #888;
    font-size: 14px;
    line-height: 1.5;
}

html[data-theme="dark"] .main-content.crm-stats-page {
    background: #111;
}

html[data-theme="dark"] .crm-stats-header,
html[data-theme="dark"] .crm-stats-card,
html[data-theme="dark"] .crm-stats-board,
html[data-theme="dark"] .crm-stats-client-item {
    background: #1c1c1e;
    border-color: #333;
    color: #f5f5f7;
}

html[data-theme="dark"] .crm-stats-header h1,
html[data-theme="dark"] .crm-stats-card-value,
html[data-theme="dark"] .crm-stats-question,
html[data-theme="dark"] .crm-stats-board-head h2 {
    color: #f5f5f7;
}

html[data-theme="dark"] .crm-stats-table th {
    background: #252528;
}

html[data-theme="dark"] .crm-stats-table tbody tr:hover,
html[data-theme="dark"] .crm-stats-table tbody tr.expanded,
html[data-theme="dark"] .crm-stats-detail-row td {
    background: #222228;
}
