/* ─── Отчеты ─────────────────────────────────────────────────────────────── */

.rp-wrap {
    padding: 0 0 2rem;
}

/* Шапка — табы типов отчетов (замена card-header) */
.rp-type-tabs {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
    padding: .6rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid #f0f2f5;
    margin-bottom: 0;
    border-radius: 0.875rem 0.875rem 0 0;
}

.rp-type-tab {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: 1.5px solid transparent;
    background: transparent;
    color: #64748b;
    border-radius: 8px;
    padding: .4rem .9rem;
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .13s, color .13s, background .13s;
    font-family: inherit;
    white-space: nowrap;
}

.rp-type-tab:hover {
    background: #f4f5f8;
    color: #334155;
}

.rp-type-tab--active {
    border-color: #6366f1;
    background: #eef2ff;
    color: #6366f1;
}

/* Тулбар */
.rp-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem 1rem;
    padding: 1rem 1.25rem 0;
    margin-bottom: 1.25rem;
}

/* Область отчета */
#rp-report-area {
    padding: 0 1.25rem;
}

/* Пилюли периода */
.rp-period-pills {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
}

.rp-pill {
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #475569;
    border-radius: 20px;
    padding: .3rem .85rem;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    font-family: inherit;
    white-space: nowrap;
}

.rp-pill:hover        { border-color: #6366f1; color: #6366f1; }
.rp-pill--active      { border-color: #6366f1; background: #6366f1; color: #fff; }
.rp-pill--active:hover { color: #fff; }

/* Группировка */
.rp-group-select {
    display: flex;
    align-items: center;
    gap: .45rem;
}

.rp-group-label {
    font-size: .8rem;
    color: #94a3b8;
    white-space: nowrap;
}

.rp-select {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: .3rem .65rem;
    font-size: .8rem;
    color: #334155;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .15s;
    outline: none;
}
.rp-select:focus { border-color: #6366f1; }

.rp-status-filter-box {
    background: #fff;
    border: 1.5px solid #e8eaed;
    border-radius: 12px;
    padding: .95rem 1rem;
    margin-bottom: 1rem;
}

.rp-status-filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.rp-status-filter-title {
    font-size: .85rem;
    font-weight: 700;
    color: #0f172a;
}

.rp-status-filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.rp-status-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #475569;
    border-radius: 999px;
    padding: .42rem .75rem;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .15s, background .15s, color .15s;
}

.rp-status-chip:hover {
    border-color: var(--rp-status-accent, #6366f1);
    color: var(--rp-status-accent, #6366f1);
}

.rp-status-chip--active {
    border-color: var(--rp-status-accent, #6366f1);
    background: color-mix(in srgb, var(--rp-status-accent, #6366f1) 12%, #fff);
    color: var(--rp-status-accent, #6366f1);
}

.rp-status-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rp-status-accent, #6366f1);
    flex-shrink: 0;
}

/* KPI карточки */
.rp-kpi-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.rp-kpi-card {
    display: flex;
    align-items: center;
    gap: .85rem;
    background: #fff;
    border: 1.5px solid #e8eaed;
    border-radius: 12px;
    padding: .85rem 1.1rem;
    min-width: 170px;
    flex: 1;
}

.rp-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.rp-kpi-body {
    display: flex;
    flex-direction: column;
    gap: .12rem;
    min-width: 0;
}

.rp-kpi-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rp-kpi-label {
    font-size: .73rem;
    color: #94a3b8;
    white-space: nowrap;
}

/* Переключатель метрики (товары) */
.rp-metric-toggle {
    display: flex;
    gap: .25rem;
    margin-bottom: .875rem;
}

.rp-mtbtn {
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    border-radius: 8px;
    padding: .3rem .85rem;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: border-color .13s, color .13s, background .13s;
}
.rp-mtbtn:hover       { border-color: #6366f1; color: #6366f1; }
.rp-mtbtn--active     { border-color: #6366f1; background: #6366f1; color: #fff; }

/* Двухколоночный лейаут */
.rp-split {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

/* Обертка графика */
.rp-chart-wrap {
    background: #fff;
    border: 1.5px solid #e8eaed;
    border-radius: 12px;
    padding: 1.25rem 1.25rem 1rem;
    position: relative;
    height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.rp-chart-wrap--side {
    height: 340px;
    min-width: 260px;
    flex: 0 0 38%;
}

.rp-chart-wrap--doughnut {
    flex: 0 0 30%;
    min-width: 220px;
}

.rp-chart-wrap canvas { max-height: 100%; }

/* Лоадер */
.rp-area-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
}

.rp-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: rp-spin .7s linear infinite;
    display: inline-block;
}

@keyframes rp-spin { to { transform: rotate(360deg); } }

/* Пустое состояние */
.rp-area-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 2rem;
    font-size: .875rem;
    color: #94a3b8;
    text-align: center;
    gap: .35rem;
    width: 100%;
}

/* Колонка таблицы во split-лейауте */
.rp-tbl-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.rp-tbl-col .rp-table-wrap {
    flex: 1;
}

/* Таблица */
.rp-table-wrap {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
}

.rp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.rp-table thead th {
    padding: .65rem 1rem;
    background: #f8fafc;
    color: #64748b;
    font-weight: 600;
    font-size: .73rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

.rp-table td {
    padding: .65rem 1rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.rp-table tbody tr:last-child td { border-bottom: none; }
.rp-table tbody tr:hover td      { background: #f8fafc; }
.rp-td-r { text-align: right !important; }

.rp-client-name,
.rp-client-phone {
    display: block;
}
.rp-client-phone {
    font-size: .75rem;
    color: #94a3b8;
    margin-top: .1rem;
}

.rp-th-sort {
    cursor: pointer;
    user-select: none;
}
.rp-th-sort:hover { color: #4f46e5; }

.rp-sort-icon {
    margin-left: .3rem;
    font-size: .68rem;
    opacity: .35;
    vertical-align: middle;
}
.rp-sort-icon--on {
    opacity: 1;
    color: #4f46e5;
}

/* Точка статуса в воронке */
.rp-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: .45rem;
    flex-shrink: 0;
}

/* Пагинация */
.rp-pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    padding: .5rem .9rem .6rem;
    border-top: 1px solid #f1f5f9;
}

.rp-pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    color: #475569;
    font-size: .78rem;
    cursor: pointer;
    transition: border-color .13s, color .13s;
}
.rp-pager-btn:hover:not(:disabled) { border-color: #6366f1; color: #6366f1; }
.rp-pager-btn:disabled { opacity: .4; cursor: default; }

.rp-pager-info {
    font-size: .78rem;
    color: #94a3b8;
    white-space: nowrap;
}

/* DRP */
.rp-drp-wrap {
    position: relative;
    display: inline-flex;
}

.rp-drp-trigger {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    cursor: pointer;
    border-radius: 20px;
}

.rp-drp-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 0;
    margin-left: .1rem;
    color: inherit;
    cursor: pointer;
    line-height: 1;
}
.rp-drp-clear:hover { opacity: .7; }

.rp-drp-popup {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 1050;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(15,23,42,.12);
    padding: 1rem;
    white-space: normal;
}
.rp-drp-popup.rp-drp-open { display: block; }

.rp-drp-calendars {
    display: flex;
    gap: 1rem;
}

.rp-drp-cal { min-width: 220px; }

.rp-drp-col-divider {
    width: 1px;
    background: #e8eaed;
    margin: 0 .25rem;
}

.rp-drp-month-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .5rem;
}

.rp-drp-month-title {
    font-size: .82rem;
    font-weight: 600;
    color: #334155;
}

.rp-drp-nav-btn {
    background: transparent;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1rem; color: #475569;
    transition: border-color .13s, color .13s;
}
.rp-drp-nav-btn:hover { border-color: #6366f1; color: #6366f1; }

.rp-drp-nav-placeholder { width: 26px; }

.rp-drp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.rp-drp-day-hdr {
    text-align: center;
    font-size: .7rem;
    color: #94a3b8;
    font-weight: 600;
    padding: .2rem 0;
}

.rp-drp-day {
    text-align: center;
    font-size: .78rem;
    color: #334155;
    padding: .28rem .1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background .1s, color .1s;
}
.rp-drp-day:hover:not(.rp-drp-sel-start):not(.rp-drp-sel-end) { background: #f1f5f9; }
.rp-drp-today { font-weight: 700; color: #6366f1; }
.rp-drp-in-range    { background: #eef2ff; border-radius: 0; }
.rp-drp-range-start { background: #eef2ff; border-radius: 5px 0 0 5px; }
.rp-drp-range-end   { background: #eef2ff; border-radius: 0 5px 5px 0; }
.rp-drp-sel-start,
.rp-drp-sel-end     { background: #6366f1 !important; color: #fff !important; border-radius: 5px; }

.rp-drp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: .85rem;
    padding-top: .75rem;
    border-top: 1px solid #f1f5f9;
    gap: .75rem;
}

.rp-drp-hint {
    font-size: .78rem;
    color: #94a3b8;
}

.rp-drp-actions { display: flex; gap: .5rem; }

.rp-drp-btn-cancel {
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    border-radius: 8px;
    padding: .3rem .85rem;
    font-size: .8rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .13s;
}
.rp-drp-btn-cancel:hover { border-color: #94a3b8; }

.rp-drp-btn-apply {
    border: none;
    background: #6366f1;
    color: #fff;
    border-radius: 8px;
    padding: .3rem .85rem;
    font-size: .8rem;
    font-family: inherit;
    cursor: pointer;
    transition: background .13s;
}
.rp-drp-btn-apply:hover:not(:disabled) { background: #4f46e5; }
.rp-drp-btn-apply:disabled { opacity: .45; cursor: default; }

/* Адаптив */
@media (max-width: 900px) {
    .rp-split { flex-direction: column; }
    .rp-chart-wrap--side, .rp-chart-wrap--doughnut { flex: 1 1 100%; min-width: 0; height: 280px; }
    .rp-table-wrap { width: 100%; }
}

@media (max-width: 768px) {
    .rp-wrap { padding: 0 0 1.5rem; }
    .rp-type-tabs { gap: .2rem; padding: .5rem .875rem; }
    .rp-toolbar { padding: .875rem .875rem 0; }
    #rp-report-area { padding: 0 .875rem; }
    .rp-type-tab { padding: .35rem .7rem; font-size: .78rem; }
    .rp-kpi-card { min-width: calc(50% - .5rem); padding: .7rem .9rem; }
    .rp-chart-wrap { height: 260px; }
}

@media (max-width: 480px) {
    .rp-kpi-card { min-width: 100%; }
}

/* ─── Модалка заказов клиента ───────────────────────────────────────────── */

.rp-client-row { cursor: pointer; }
.rp-client-row:hover td { background: #f0f4ff !important; }

.rp-co-content {
    border-radius: 16px;
    overflow: hidden;
}

.rp-co-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.1rem 1.4rem .9rem;
    border-bottom: 1px solid #f0f2f5;
    background: #fafafa;
}
.rp-co-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}
.rp-co-phone {
    font-size: .82rem;
    color: #64748b;
    margin-top: .15rem;
}
.rp-co-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1rem;
    cursor: pointer;
    padding: .2rem;
    line-height: 1;
}
.rp-co-close:hover { color: #334155; }

.rp-co-body {
    padding: 0;
    max-height: 70vh;
    overflow-y: auto;
}

.rp-co-table { font-size: .83rem; }
.rp-co-table thead th { position: sticky; top: 0; z-index: 1; }
.rp-co-date   { white-space: nowrap; color: #64748b; width: 80px; }
.rp-co-products { max-width: 320px; white-space: normal; line-height: 1.4; }
.rp-co-status { white-space: nowrap; }
.rp-co-total  { white-space: nowrap; font-weight: 600; }
.rp-co-badge  {
    display: inline-block;
    padding: .18rem .55rem;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
}
.rp-co-manager {
    font-size: .75rem;
    color: #94a3b8;
    margin-top: .2rem;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
