/**
 * Phase G (rev): CRM-списки AGENT/SERVICE — на всю ширину main.
 * С portal-crm-shell-ui-ready: без site-header-bar, shell как SYSTEM (topbar + вкладки).
 */
@import url('./system-shell.css');
@import url('./portal-crm-sidebar.css');

.portal-crm-shell-topbar {
    display: none !important;
}

[data-site-header-mount][hidden] {
    display: none !important;
}

body.portal-crm-shell-ui-ready {
    --portal-header-stack: 0px;
    background: #fff;
}

/* CRM: не сжимать main из-за body{display:flex} из sysAdminSidebar.css */
:is(body.portal-sector-service, body.portal-sector-agent).crm-service-page {
    display: block;
    overflow-x: hidden;
}

[data-crm-rail-mount],
[data-agent-rail-mount],
[data-user-rail-mount] {
    display: contents;
}

body.portal-crm-shell-ui-ready .crm-service-rail {
    top: 0;
    height: 100vh;
}

body.portal-crm-shell-ui-ready .crm-service-rail__brand {
    display: block;
    padding: 14px 12px 10px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.02em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.portal-crm-shell-ui-ready .crm-service-rail__brand:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

body.portal-crm-shell-ui-ready .crm-service-main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    min-width: 0;
    margin-top: 0;
    min-height: 100vh;
    padding: 0;
}

body.portal-crm-shell-ui-ready .crm-service-main .sys-shell-content-mount > .card.sys-list-page-card,
body.portal-crm-shell-ui-ready .crm-service-main .sys-shell-content-mount > .card,
body.portal-crm-shell-ui-ready .crm-service-main .sys-shell-content-mount > .service-welcome-card,
body.portal-crm-shell-ui-ready .crm-service-main .sys-shell-content-mount > .service-wait-card {
    min-height: 0;
}

:is(body.portal-sector-agent, body.portal-sector-service).crm-service-page {
    background: var(--color-surface, #fff);
}

:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main {
    margin-top: var(--portal-header-stack, 64px);
    margin-left: var(--portal-crm-sidebar-width-effective, var(--sidebar-width, 220px));
    margin-right: 0;
    padding: 0;
    width: calc(100vw - var(--portal-crm-sidebar-width-effective, var(--sidebar-width, 220px)));
    max-width: calc(100vw - var(--portal-crm-sidebar-width-effective, var(--sidebar-width, 220px)));
    min-width: 0;
    box-sizing: border-box;
    min-height: calc(100vh - var(--portal-header-stack, 64px));
    background: var(--color-surface, #fff);
    overflow-x: hidden;
}

body.portal-crm-shell-ui-ready.portal-sector-agent .crm-service-main,
body.portal-crm-shell-ui-ready.portal-sector-service .crm-service-main {
    margin-top: 0;
    min-height: 100vh;
}

body.portal-crm-shell-ui-ready.portal-sector-agent .crm-service-main .sys-shell-content-mount,
body.portal-crm-shell-ui-ready.portal-sector-service .crm-service-main .sys-shell-content-mount {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

body.portal-crm-shell-ui-ready.portal-sector-agent .crm-service-main .sys-list-page-card .sys-list-table-wrap,
body.portal-crm-shell-ui-ready.portal-sector-service .crm-service-main .sys-list-page-card .sys-list-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .card.sys-list-page-card {
    width: 100%;
    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 16px 22px 40px;
    box-sizing: border-box;
    min-height: calc(100vh - var(--portal-header-stack, 64px));
}

/* Phase F: дашборды, настройки, ожидание — та же ширина main, что у CRM-списков */
:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .service-welcome-card,
:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .service-wait-card,
:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main > .card,
:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .agent-portal-card-wrap {
    width: 100%;
    max-width: none;
    margin: 0;
    box-sizing: border-box;
}

:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .service-welcome-card,
:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .service-wait-card {
    padding: 24px 22px 32px;
    border-radius: 0;
    box-shadow: none;
    min-height: calc(100vh - var(--portal-header-stack, 64px));
}

:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .crm-company-settings-card,
:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .crm-agent-settings-card {
    max-width: none;
    border-radius: 0;
    box-shadow: none;
    padding: 16px 22px 40px;
    min-height: calc(100vh - var(--portal-header-stack, 64px));
}

:is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main .agent-portal-card-wrap > .card {
    border-radius: 0;
    box-shadow: none;
    padding: 24px 22px 32px;
    min-height: calc(100vh - var(--portal-header-stack, 64px));
}

body.portal-crm-shell-ui-ready.portal-sector-service .sys-shell-topbar__company {
    margin: 0;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

:is(body.portal-sector-agent, body.portal-sector-service) .crm-portal-page-heading {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    color: #111827;
    line-height: 1.05;
    letter-spacing: 0.02em;
}

@media (max-width: 960px) {
    :is(body.portal-sector-agent, body.portal-sector-service) .crm-service-main {
        margin-left: 0;
    }
}
