:root {
    color-scheme: light;
    --bg: #f5f6f4;
    --surface: #ffffff;
    --surface-2: #f0f3f1;
    --surface-3: #e8ece9;
    --line: #d9dfdc;
    --line-strong: #c4ccc8;
    --text: #17201d;
    --muted: #66736f;
    --soft: #87928e;
    --green: #18764d;
    --green-soft: #dff2e9;
    --blue: #246fbb;
    --blue-soft: #e1edf8;
    --yellow: #a96800;
    --yellow-soft: #fff0cf;
    --red: #b14242;
    --red-soft: #fde3df;
    --ink: #0d1512;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

body:not(.crm-auth-page) {
    overflow-x: hidden;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select,
input,
textarea {
    border-radius: 7px;
}

button {
    cursor: pointer;
}

.crm-app {
    display: grid;
    grid-template-columns: minmax(188px, 216px) minmax(0, 1fr);
    min-height: 100vh;
    min-width: 0;
}

.crm-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100vh;
    overflow-y: auto;
    padding: 14px;
    border-right: 1px solid var(--line);
    background: #fbfcfb;
    overscroll-behavior: contain;
}

.crm-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
}

.crm-brand > span:first-child {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 7px;
    background: var(--ink);
    color: #fff;
    font-weight: 800;
}

.crm-brand strong,
.crm-brand h1 {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.1;
}

.crm-brand div span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: .78rem;
}

.crm-nav {
    display: grid;
    gap: 6px;
}

.crm-nav a,
.crm-toolbar a,
.crm-icon-link,
.crm-tabs a,
.crm-replay-list a {
    text-decoration: none;
}

.crm-nav a {
    display: flex;
    min-height: 34px;
    align-items: center;
    min-width: 0;
    padding: 0 9px;
    border-radius: 7px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.crm-nav a.is-active,
.crm-nav a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.crm-site-link {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--muted);
    padding: 0 9px;
    text-decoration: none;
}

.crm-site-link:hover {
    color: var(--text);
    background: var(--surface-2);
}

.crm-side-card,
.crm-auth-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.crm-side-card {
    display: grid;
    gap: 6px;
    padding: 10px;
}

.crm-side-card > span,
.crm-side-card small {
    color: var(--muted);
}

.crm-side-card > strong {
    font-size: 1.18rem;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.crm-side-card summary {
    cursor: pointer;
    font-weight: 800;
}

.crm-logout {
    margin-top: auto;
}

.crm-logout button,
.crm-form button,
.crm-toolbar button,
.crm-stage-form button,
.crm-feed button,
.crm-manager-list button {
    min-height: 36px;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: #fff;
    padding: 0 12px;
    font-weight: 750;
}

.crm-logout button {
    width: 100%;
    border-color: var(--line);
    background: var(--surface-2);
    color: var(--text);
}

.crm-main {
    min-width: 0;
    max-width: 100%;
    padding: 18px;
}

.crm-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.crm-eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.crm-topbar h1 {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.1;
    letter-spacing: 0;
}

.crm-user {
    display: grid;
    min-width: 120px;
    justify-items: end;
    gap: 2px;
    color: var(--text);
}

.crm-user small {
    color: var(--muted);
}

.crm-flash {
    overflow: hidden;
    max-height: 180px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    animation: crmFlashAutoHide 4.8s ease forwards;
    will-change: opacity, transform, max-height, margin, padding;
}

.crm-flash--error {
    border-color: #efb8b0;
    background: var(--red-soft);
    color: #7d2525;
}

.crm-flash--success {
    border-color: #b9dfca;
    background: var(--green-soft);
    color: #105536;
}

@keyframes crmFlashAutoHide {
    0%,
    82% {
        visibility: visible;
        opacity: 1;
        transform: translateY(0);
        max-height: 180px;
        margin-bottom: 12px;
        padding-top: 10px;
        padding-bottom: 10px;
        border-width: 1px;
    }

    100% {
        visibility: hidden;
        opacity: 0;
        transform: translateY(-4px);
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-width: 0;
    }
}

@keyframes crmFlashAutoHideReduced {
    0%,
    99% {
        visibility: visible;
        opacity: 1;
        max-height: 180px;
        margin-bottom: 12px;
        padding-top: 10px;
        padding-bottom: 10px;
        border-width: 1px;
    }

    100% {
        visibility: hidden;
        opacity: 0;
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .crm-flash {
        animation-name: crmFlashAutoHideReduced;
    }
}

.crm-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.crm-metrics article,
.crm-info-grid article,
.crm-behavior-summary article {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px;
}

.crm-metrics span,
.crm-info-grid span,
.crm-behavior-summary span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
}

.crm-metrics strong,
.crm-behavior-summary strong {
    display: block;
    margin-top: 6px;
    font-size: 1.45rem;
}

.crm-workspace {
    display: grid;
    grid-template-areas: "board detail";
    grid-template-columns: minmax(0, 1fr) minmax(336px, clamp(360px, 34vw, 520px));
    gap: 12px;
    align-items: start;
    max-width: 100%;
    min-width: 0;
}

.crm-board-shell,
.crm-detail,
.crm-admin {
    min-width: 0;
    max-width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .78);
}

.crm-board-shell {
    grid-area: board;
    order: 1;
    overflow: hidden;
}

.crm-board-context,
.crm-board-queue {
    display: grid;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.crm-board-context {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
}

.crm-board-queue {
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    background: #fbfcfb;
}

.crm-board-context article,
.crm-board-queue article {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 9px;
}

.crm-board-context span,
.crm-board-queue span {
    display: block;
    color: var(--muted);
    font-size: .76rem;
}

.crm-board-context strong,
.crm-board-queue strong {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.crm-detail {
    grid-area: detail;
    order: 2;
}

.crm-toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(116px, 142px)) minmax(150px, 1fr) auto auto;
    gap: 7px;
    align-items: end;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.crm-toolbar label,
.crm-form label {
    display: grid;
    gap: 5px;
    min-width: 0;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 750;
}

.crm-toolbar input,
.crm-toolbar select,
.crm-form input,
.crm-form select,
.crm-form textarea,
.crm-stage-form select,
.crm-manager-list input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text);
    padding: 8px 9px;
    outline: none;
}

.crm-form textarea {
    resize: vertical;
}

.crm-toolbar input:focus,
.crm-toolbar select:focus,
.crm-form input:focus,
.crm-form select:focus,
.crm-form textarea:focus,
.crm-stage-form select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(36, 111, 187, .12);
}

.crm-toolbar a {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 0 10px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 750;
    text-align: center;
    white-space: normal;
}

.crm-kanban {
    display: grid;
    grid-template-columns: repeat(5, minmax(188px, 1fr));
    gap: 8px;
    overflow-x: auto;
    padding: 10px;
    overscroll-behavior-x: contain;
}

.crm-column {
    display: grid;
    grid-template-rows: auto minmax(160px, 1fr);
    min-width: 188px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
}

.crm-column header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    min-height: 74px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
}

.crm-column h2 {
    margin: 0;
    font-size: .96rem;
    letter-spacing: 0;
}

.crm-column p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: .78rem;
}

.crm-column header > strong {
    display: grid;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    place-items: center;
    border-radius: 7px;
    background: #fff;
    color: var(--muted);
}

.crm-card-list {
    display: grid;
    align-content: start;
    gap: 7px;
    padding: 7px;
}

.crm-lead-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 9px;
}

.crm-lead-card.is-selected {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(36, 111, 187, .12);
}

.crm-lead-card a {
    display: grid;
    gap: 4px;
    min-width: 0;
    text-decoration: none;
}

.crm-lead-card a > span,
.crm-lead-card small,
.crm-card-meta,
.crm-empty {
    color: var(--muted);
}

.crm-lead-card strong {
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.crm-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 8px 0;
    font-size: .78rem;
}

.crm-card-meta span {
    border-radius: 7px;
    background: var(--surface-2);
    padding: 3px 6px;
}

.crm-stage-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
}

.crm-stage-form button {
    min-height: 34px;
    padding: 0 9px;
}

.crm-detail {
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 24px);
    overflow: auto;
    background: var(--surface);
    overscroll-behavior: contain;
}

.crm-detail-empty {
    padding: 20px;
}

.crm-detail-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
}

.crm-detail-head > div {
    min-width: 0;
}

.crm-detail-head h2 {
    margin: 8px 0 4px;
    font-size: 1.25rem;
    line-height: 1.2;
    letter-spacing: 0;
}

.crm-detail-head p {
    margin: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.crm-action-panel {
    display: grid;
    gap: 10px;
    margin: 12px 14px 0;
    padding: 12px;
    border: 1px solid #b9dfca;
    border-radius: 8px;
    background: linear-gradient(180deg, #f1fbf6 0%, var(--green-soft) 100%);
    box-shadow: 0 10px 24px rgba(24, 118, 77, .1);
}

.crm-action-panel h3,
.crm-section-card h3,
.crm-disclosure h3 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0;
}

.crm-action-panel p,
.crm-section-card p,
.crm-disclosure p {
    margin: 0;
    color: var(--muted);
}

.crm-action-panel button,
.crm-action-panel .crm-button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border-color: var(--green);
    background: var(--green);
    color: #fff;
    padding: 0 12px;
    text-decoration: none;
}

.crm-section-card,
.crm-disclosure {
    min-width: 0;
    margin: 12px 14px 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.crm-section-card {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.crm-section-card > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.crm-disclosure {
    overflow: hidden;
}

.crm-disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    padding: 11px 12px;
    cursor: pointer;
    font-weight: 800;
    list-style: none;
}

.crm-disclosure > summary::-webkit-details-marker {
    display: none;
}

.crm-disclosure > summary::after {
    display: grid;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--muted);
    content: "+";
    font-weight: 900;
}

.crm-disclosure[open] > summary::after {
    content: "-";
}

.crm-disclosure > :not(summary) {
    padding: 0 12px 12px;
}

.crm-icon-link {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 1.3rem;
}

.crm-status-dot {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 7px;
    padding: 0 8px;
    font-size: .76rem;
    font-weight: 800;
}

.crm-status-new { background: var(--blue-soft); color: #174e86; }
.crm-status-qualified { background: var(--green-soft); color: #115d3b; }
.crm-status-proposal { background: var(--yellow-soft); color: #7b4b00; }
.crm-status-won { background: #d8f0d4; color: #2e6d26; }
.crm-status-lost { background: var(--red-soft); color: #8a2d2d; }

.crm-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}

.crm-tabs a {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    border-radius: 7px;
    padding: 0 10px;
    color: var(--muted);
    white-space: nowrap;
}

.crm-tabs a.is-active,
.crm-tabs a:hover {
    background: var(--ink);
    color: #fff;
}

.crm-form {
    display: grid;
    gap: 10px;
}

.crm-detail-form,
.crm-tab-panel {
    padding: 14px;
}

.crm-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.crm-info-grid,
.crm-behavior-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0 14px 14px;
}

.crm-info-grid article p {
    margin: 6px 0 0;
}

.crm-answer-list {
    display: grid;
    gap: 8px;
    padding: 0 14px 16px;
}

.crm-answer-list h3,
.crm-admin h2 {
    margin: 0;
    letter-spacing: 0;
}

.crm-answer-list dl {
    display: grid;
    gap: 4px;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.crm-answer-list dt {
    color: var(--muted);
    font-size: .78rem;
}

.crm-answer-list dd {
    margin: 0;
}

.crm-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.crm-pill-row span {
    border-radius: 7px;
    background: var(--surface-2);
    padding: 5px 8px;
    font-size: .82rem;
}

.crm-spec-panel {
    display: grid;
    gap: 12px;
}

.crm-spec-form {
    gap: 12px;
}

.crm-spec-head,
.crm-spec-box,
.crm-spec-function,
.crm-spec-regenerate {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.crm-spec-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
}

.crm-spec-head h3 {
    margin: 2px 0 4px;
    font-size: 1rem;
    letter-spacing: 0;
}

.crm-spec-links,
.crm-spec-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crm-spec-links a {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 0 10px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.crm-spec-links a:hover {
    border-color: var(--ink);
}

.crm-spec-box {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 12px;
}

.crm-spec-box > legend {
    padding: 0 6px;
    font-weight: 850;
}

.crm-spec-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.crm-spec-grid[hidden],
.crm-spec-panel [hidden] {
    display: none;
}

.crm-spec-grid .is-wide,
.crm-spec-actions,
.crm-spec-regenerate,
.crm-spec-sections label {
    grid-column: 1 / -1;
}

.crm-spec-function-list,
.crm-spec-sections {
    display: grid;
    gap: 10px;
}

.crm-spec-function {
    display: grid;
    grid-template-columns: minmax(180px, .8fr) minmax(0, 1.1fr) minmax(0, 1.1fr);
    gap: 10px;
    padding: 10px;
    background: var(--surface);
}

.crm-spec-actions button,
.crm-spec-regenerate button {
    min-height: 36px;
}

.crm-spec-regenerate {
    display: flex;
    justify-content: flex-start;
    padding: 12px;
    background: var(--surface);
}

.crm-feed {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.crm-feed article {
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.crm-feed article > span {
    color: var(--muted);
    font-size: .78rem;
}

.crm-feed p {
    margin: 0;
    white-space: pre-wrap;
}

.crm-feed form {
    justify-self: start;
}

.crm-feed button,
.crm-manager-list button {
    min-height: 30px;
    border-color: var(--line-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: .78rem;
}

.crm-task.is-done {
    opacity: .64;
}

.crm-task-form {
    grid-template-columns: minmax(0, 1fr) 150px auto;
    align-items: end;
}

.crm-file-list,
.crm-replay-list {
    display: grid;
    gap: 8px;
}

.crm-file-list a,
.crm-replay-list a {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    min-height: 42px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0 10px;
}

.crm-file-list strong,
.crm-replay-list a {
    min-width: 0;
    overflow-wrap: anywhere;
}

.crm-file-list span {
    flex: 0 0 auto;
    color: var(--muted);
}

.crm-replay-list a.is-active {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: #174e86;
}

.crm-replay-player {
    min-height: 260px;
    margin-top: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.crm-replay-player .rr-player,
.crm-replay-player .rr-player__frame,
.crm-replay-player .rr-controller {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}

.crm-replay-player .rr-controller {
    overflow-x: auto;
}

.crm-replay-player .replayer-mouse-tail {
    max-width: 100%;
}

.crm-event-table {
    margin-top: 12px;
    max-height: min(420px, 52dvh);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.crm-event-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
    background: #fff;
}

.crm-event-table th,
.crm-event-table td {
    border-bottom: 1px solid var(--line);
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

.crm-event-table th {
    color: var(--muted);
    font-size: .75rem;
    text-transform: uppercase;
}

.crm-admin {
    display: grid;
    gap: 14px;
    margin-top: 14px;
    padding: 14px;
}

.crm-admin p {
    margin: 4px 0 0;
    color: var(--muted);
}

.crm-admin-grid {
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    gap: 14px;
}

.crm-manager-list {
    display: grid;
    align-content: start;
    gap: 8px;
}

.crm-manager-list article {
    display: flex;
    align-self: start;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.crm-manager-list span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
}

.crm-manager-list form {
    display: grid;
    grid-template-columns: 120px auto;
    gap: 6px;
}

.crm-auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 18px;
}

.crm-auth {
    width: min(420px, 100%);
}

.crm-auth-card {
    display: grid;
    gap: 16px;
    padding: 18px;
}

.crm-auth-page .crm-brand > span:first-child {
    width: 34px;
    height: 34px;
}

.crm-auth-page .crm-brand strong,
.crm-auth-page .crm-brand h1 {
    font-size: 1rem;
}

.crm-brand--auth {
    pointer-events: none;
}

.crm-login-form button {
    width: 100%;
}

@media (max-width: 1180px) {
    .crm-app {
        grid-template-columns: 1fr;
    }

    .crm-sidebar {
        position: static;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
        height: auto;
        padding: 10px 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .crm-nav {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
        padding-bottom: 1px;
    }

    .crm-side-card {
        grid-column: 1 / -1;
    }

    .crm-logout {
        margin-top: 0;
        justify-self: end;
    }

    .crm-logout button {
        width: auto;
    }

    .crm-workspace {
        grid-template-areas: none;
        grid-template-columns: 1fr;
    }

    .crm-board-shell,
    .crm-detail {
        grid-area: auto;
    }

    .crm-board-shell {
        order: 2;
    }

    .crm-detail {
        order: 1;
        position: static;
        max-height: none;
    }

    .crm-detail:has(.crm-detail-empty) {
        order: 2;
    }

    .crm-detail:has(.crm-detail-empty) ~ .crm-board-shell {
        order: 1;
    }
}

@media (max-width: 820px) {
    .crm-main {
        padding: 14px;
    }

    .crm-topbar,
    .crm-manager-list article {
        display: grid;
        justify-items: start;
    }

    .crm-user {
        justify-items: start;
    }

    .crm-metrics,
    .crm-info-grid,
    .crm-behavior-summary,
    .crm-admin-grid {
        grid-template-columns: 1fr;
    }

    .crm-toolbar,
    .crm-task-form,
    .crm-form-grid {
        grid-template-columns: 1fr;
    }

    .crm-kanban {
        grid-template-columns: repeat(5, minmax(210px, 82vw));
        padding: 8px;
    }

    .crm-manager-list form {
        grid-template-columns: 1fr;
        width: 100%;
    }
}

/* Lead-first CRM layout */
.crm-app {
    grid-template-columns: 224px minmax(0, 1fr);
}

.crm-sidebar {
    gap: 12px;
    padding: 14px;
}

.crm-workspace {
    grid-template-columns: minmax(300px, 34vw) minmax(0, 1fr);
    grid-template-areas: "board detail";
}

.crm-board-shell {
    grid-area: board;
    overflow: visible;
}

.crm-detail {
    grid-area: detail;
}

.crm-board-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.crm-board-head h2 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0;
}

.crm-board-head > strong {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 7px;
    background: var(--ink);
    color: #fff;
}

.crm-board-shell .crm-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.crm-board-shell .crm-metrics article {
    padding: 10px;
}

.crm-board-shell .crm-metrics strong {
    font-size: 1.16rem;
}

.crm-board-shell .crm-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
}

.crm-board-shell .crm-toolbar .is-wide,
.crm-board-shell .crm-toolbar button,
.crm-board-shell .crm-toolbar a {
    grid-column: span 2;
}

.crm-kanban {
    grid-template-columns: 1fr;
    overflow: visible;
}

.crm-column {
    min-width: 0;
    grid-template-rows: auto auto;
}

.crm-column header {
    min-height: 0;
    padding: 10px;
}

.crm-card-list {
    gap: 7px;
}

.crm-lead-card {
    padding: 9px;
}

.crm-detail-head {
    align-items: flex-start;
    background: var(--surface);
}

.crm-detail-head h2 {
    font-size: clamp(1.35rem, 2vw, 2rem);
}

.crm-detail-head p {
    overflow-wrap: anywhere;
}

.crm-action-panel {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: #fbfcfb;
}

.crm-next-action {
    display: grid;
    gap: 6px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    padding: 16px;
}

.crm-next-action span,
.crm-next-action small {
    color: rgba(255, 255, 255, .72);
    font-size: .78rem;
    font-weight: 750;
}

.crm-next-action strong {
    font-size: clamp(1.15rem, 1.6vw, 1.55rem);
    line-height: 1.25;
}

.crm-contact-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crm-contact-strip a,
.crm-contact-strip span {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    padding: 7px 9px;
    color: var(--text);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.crm-quick-form {
    grid-template-columns: minmax(110px, .8fr) minmax(160px, 1.2fr) minmax(110px, .8fr) minmax(220px, 1.6fr) minmax(120px, .8fr) auto;
    align-items: end;
}

.crm-quick-form button {
    white-space: nowrap;
}

.crm-action-panel .crm-tabs {
    border-bottom: 0;
    padding: 0;
}

.crm-section-card {
    margin: 12px 16px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.crm-disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
}

.crm-disclosure > summary::-webkit-details-marker {
    display: none;
}

.crm-disclosure > summary::after {
    content: "+";
    display: grid;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 850;
}

.crm-disclosure[open] > summary::after {
    content: "-";
}

.crm-section-card > summary {
    min-height: 44px;
    padding: 0 12px;
    border-bottom: 1px solid transparent;
    font-weight: 850;
}

.crm-section-card[open] > summary {
    border-bottom-color: var(--line);
}

.crm-section-card .crm-detail-form,
.crm-section-card .crm-tab-panel,
.crm-section-card .crm-info-grid,
.crm-section-card .crm-answer-list {
    padding: 12px;
}

.crm-section-card .crm-info-grid,
.crm-section-card .crm-behavior-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crm-admin {
    padding: 0;
}

.crm-admin > summary {
    padding: 14px;
}

.crm-admin > summary > div,
.crm-admin > summary h2 {
    min-width: 0;
}

.crm-admin-grid {
    padding: 0 14px 14px;
}

@media (max-width: 1520px) {
    .crm-quick-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .crm-quick-form .is-wide {
        grid-column: span 2;
    }
}

@media (max-width: 1180px) {
    .crm-app {
        grid-template-columns: 1fr;
    }

    .crm-sidebar {
        display: grid;
        grid-template-columns: minmax(180px, auto) minmax(0, 1fr) minmax(150px, auto);
        align-items: start;
        height: auto;
    }

    .crm-brand,
    .crm-nav,
    .crm-site-link,
    .crm-side-card,
    .crm-logout {
        min-width: 0;
    }

    .crm-side-card:not(details) {
        align-self: stretch;
    }

    .crm-logout {
        margin-top: 0;
    }

    .crm-workspace {
        grid-template-columns: 1fr;
        grid-template-areas:
            "detail"
            "board";
    }

    .crm-detail {
        position: static;
        max-height: none;
    }

    .crm-board-shell .crm-toolbar {
        grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto;
    }

    .crm-board-shell .crm-toolbar .is-wide,
    .crm-board-shell .crm-toolbar button,
    .crm-board-shell .crm-toolbar a {
        grid-column: auto;
    }

    .crm-kanban {
        grid-template-columns: repeat(5, minmax(210px, 1fr));
        overflow-x: auto;
    }
}

@media (max-width: 820px) {
    .crm-main {
        padding: 12px;
    }

    .crm-sidebar {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px 12px;
    }

    .crm-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-side-card:not(details) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 9px 10px;
    }

    .crm-side-card:not(details) > strong {
        font-size: 1.05rem;
    }

    .crm-side-card:not(details) small {
        display: none;
    }

    .crm-topbar {
        margin-bottom: 12px;
    }

    .crm-board-shell .crm-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-board-shell .crm-toolbar,
    .crm-quick-form,
    .crm-task-form,
    .crm-spec-grid,
    .crm-spec-function,
    .crm-form-grid,
    .crm-section-card .crm-info-grid,
    .crm-section-card .crm-behavior-summary {
        grid-template-columns: 1fr;
    }

    .crm-quick-form .is-wide,
    .crm-board-shell .crm-toolbar .is-wide,
    .crm-spec-grid .is-wide,
    .crm-board-shell .crm-toolbar button,
    .crm-board-shell .crm-toolbar a {
        grid-column: auto;
    }

    .crm-spec-head,
    .crm-spec-actions {
        display: grid;
    }

    .crm-action-panel,
    .crm-detail-head,
    .crm-section-card .crm-detail-form,
    .crm-section-card .crm-tab-panel,
    .crm-section-card .crm-info-grid,
    .crm-section-card .crm-answer-list {
        padding: 12px;
    }

    .crm-section-card {
        margin: 10px 12px;
    }

    .crm-kanban {
        grid-template-columns: repeat(5, 82vw);
        overflow-x: auto;
    }

    .crm-contact-strip a,
    .crm-contact-strip span {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .crm-sidebar {
        grid-template-columns: minmax(0, 1fr) auto;
        padding: 10px 12px;
    }

    .crm-brand {
        min-width: 0;
    }

    .crm-logout {
        grid-column: 2;
        grid-row: 1;
    }

    .crm-nav,
    .crm-site-link,
    .crm-side-card {
        grid-column: 1 / -1;
    }

    .crm-main {
        padding: 12px;
    }

    .crm-topbar {
        margin-bottom: 12px;
    }

    .crm-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .crm-detail-head {
        display: grid;
        padding: 12px;
    }

    .crm-icon-link {
        justify-self: end;
    }

    .crm-tabs {
        padding: 8px 10px;
    }

    .crm-detail-form,
    .crm-tab-panel {
        padding: 12px;
    }

    .crm-info-grid,
    .crm-behavior-summary {
        padding: 0 12px 12px;
    }

    .crm-answer-list {
        padding: 0 12px 12px;
    }

    .crm-action-panel,
    .crm-section-card,
    .crm-disclosure {
        margin: 10px 12px 0;
    }
}

@media (max-width: 640px) {
    .crm-detail-head {
        display: flex;
    }

    .crm-detail-head .crm-icon-link {
        align-self: flex-start;
        justify-self: auto;
        margin-left: auto;
    }

    .crm-action-panel,
    .crm-sidebar .crm-disclosure {
        margin: 0;
    }

    .crm-section-card {
        margin: 10px 12px;
    }
}

@media (min-width: 821px) and (max-width: 1180px) {
    .crm-sidebar {
        grid-template-columns: auto auto minmax(190px, 1fr) minmax(190px, auto) auto;
        align-items: center;
    }

    .crm-brand,
    .crm-nav,
    .crm-site-link,
    .crm-side-card,
    .crm-logout {
        grid-column: auto;
        grid-row: auto;
    }

    .crm-side-card {
        align-self: stretch;
    }

    .crm-side-card:not(details) {
        display: grid;
        gap: 2px;
    }

    .crm-side-card:not(details) > strong {
        font-size: 1.05rem;
    }

    .crm-side-card:not(details) small {
        display: none;
    }

    .crm-side-card.crm-disclosure {
        min-height: 48px;
    }

    .crm-logout {
        justify-self: end;
    }
}

/* Responsive subsection and section-layout pass */
body:not(.crm-auth-page) {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

@supports (overflow: clip) {
    body:not(.crm-auth-page) {
        overflow-x: clip;
    }
}

body:not(.crm-auth-page) .crm-app,
body:not(.crm-auth-page) .crm-main,
body:not(.crm-auth-page) .crm-sidebar,
body:not(.crm-auth-page) .crm-workspace,
body:not(.crm-auth-page) .crm-board-shell,
body:not(.crm-auth-page) .crm-detail {
    min-width: 0;
    max-width: 100%;
}

body:not(.crm-auth-page) .crm-app {
    width: 100%;
    min-height: 100dvh;
}

body:not(.crm-auth-page) .crm-main {
    overflow-x: hidden;
}

@supports (overflow: clip) {
    body:not(.crm-auth-page) .crm-main {
        overflow-x: clip;
    }
}

.crm-section-layout,
.crm-signals-layout {
    display: grid;
    grid-template-columns: minmax(220px, .72fr) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    min-width: 0;
    max-width: 100%;
}

.crm-section-layout > *,
.crm-signals-layout > *,
.crm-chat-panel > *,
.crm-lead-list > * {
    min-width: 0;
    max-width: 100%;
}

.crm-section-layout.is-stacked,
.crm-section-layout--stack {
    grid-template-columns: 1fr;
}

.crm-left-primary-subsections,
.crm-primary-subsections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-content: start;
    min-width: 0;
    max-width: 100%;
}

.crm-left-primary-subsections a,
.crm-left-primary-subsections button,
.crm-left-primary-subsections summary,
.crm-primary-subsections a,
.crm-primary-subsections button,
.crm-primary-subsections summary {
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    padding: 8px 10px;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.crm-left-primary-subsections a.is-active,
.crm-left-primary-subsections button.is-active,
.crm-primary-subsections a.is-active,
.crm-primary-subsections button.is-active {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
}

.crm-lead-list {
    display: grid;
    gap: 8px;
    align-content: start;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-x: hidden;
}

.crm-board-shell .crm-lead-list {
    max-height: min(760px, calc(100dvh - 320px));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
}

.crm-lead-list a {
    color: inherit;
    text-decoration: none;
}

.crm-signals-layout .crm-info-grid,
.crm-signals-layout .crm-behavior-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0;
}

.crm-section-layout .crm-event-table,
.crm-signals-layout .crm-event-table {
    max-width: 100%;
    margin-top: 0;
    overflow-x: auto;
}

.crm-chat-panel {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 360px;
    max-height: min(680px, calc(100dvh - 260px));
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.crm-chat-panel .crm-feed,
.crm-chat-panel .crm-chat-messages {
    min-height: 0;
    margin-top: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 2px;
}

.crm-chat-panel > .crm-form,
.crm-chat-panel > form {
    min-width: 0;
    align-self: end;
}

.crm-detail--section-first {
    display: flex;
    flex-direction: column;
}

.crm-detail--section-first .crm-detail-head {
    order: 1;
}

.crm-detail--section-first .crm-section-card {
    order: 2;
}

.crm-detail--section-first .crm-action-panel {
    order: 3;
}

.crm-section-card {
    display: block;
}

.crm-section-card > *,
.crm-section-card .crm-tab-panel,
.crm-section-card .crm-behavior-summary,
.crm-section-card .crm-event-table {
    min-width: 0;
    max-width: 100%;
}

.crm-section-card .crm-event-table {
    overflow-x: auto;
}

@media (min-width: 1181px) {
    .crm-workspace {
        grid-template-columns: minmax(280px, clamp(320px, 32vw, 520px)) minmax(0, 1fr);
    }

    .crm-section-layout {
        grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    }

    .crm-signals-layout {
        grid-template-columns: minmax(220px, .62fr) minmax(0, 1fr);
    }
}

@media (max-width: 1180px) {
    .crm-app {
        grid-template-columns: 1fr;
    }

    .crm-sidebar {
        position: static;
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .crm-workspace,
    .crm-section-layout,
    .crm-signals-layout {
        grid-template-columns: 1fr;
    }

    .crm-board-shell .crm-lead-list,
    .crm-chat-panel {
        max-height: none;
    }

    .crm-left-primary-subsections,
    .crm-primary-subsections {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (min-width: 821px) and (max-width: 1180px) {
    .crm-sidebar {
        grid-template-columns: minmax(150px, auto) minmax(0, 1fr) minmax(150px, auto) auto;
        align-items: center;
    }

    .crm-sidebar .crm-disclosure {
        grid-column: 1 / -1;
    }

    .crm-sidebar .crm-form {
        grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
        align-items: end;
    }
}

@media (max-width: 820px) {
    .crm-section-layout,
    .crm-signals-layout,
    .crm-chat-panel {
        gap: 10px;
    }

    .crm-left-primary-subsections,
    .crm-primary-subsections {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-signals-layout .crm-info-grid,
    .crm-signals-layout .crm-behavior-summary {
        grid-template-columns: 1fr;
    }

    .crm-chat-panel {
        min-height: 340px;
    }
}

@media (max-width: 640px) {
    .crm-sidebar {
        max-width: 100%;
    }

    .crm-section-layout,
    .crm-signals-layout {
        gap: 8px;
    }

    .crm-left-primary-subsections,
    .crm-primary-subsections {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-flow: row;
        grid-auto-columns: auto;
        gap: 8px;
        overflow-x: visible;
        padding-bottom: 0;
    }

    .crm-left-primary-subsections > *,
    .crm-primary-subsections > * {
        min-width: 0;
    }

    .crm-board-shell .crm-lead-list {
        overflow-y: visible;
        padding-right: 0;
    }

    .crm-chat-panel {
        min-height: 320px;
    }
}

/* Dashboard, lead picking, and funnel v1 */
.crm-muted {
    color: var(--muted);
}

.crm-dashboard,
.crm-pipeline-page {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.crm-dashboard-kpis {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.crm-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

.crm-dashboard-panel {
    margin: 0;
}

.crm-dashboard-panel header {
    margin-bottom: 10px;
}

.crm-dashboard-panel h2,
.crm-pipeline-head h2,
.crm-dialog-head h2,
.crm-dialog-section h3 {
    margin: 0;
    letter-spacing: 0;
}

.crm-rank-list {
    display: grid;
    gap: 7px;
}

.crm-rank-list article {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 9px 10px;
}

.crm-rank-list span,
.crm-dialog-leads span,
.crm-dialog-leads small {
    min-width: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.crm-feed--compact {
    margin-top: 0;
}

.crm-manager-admin {
    grid-column: 1 / -1;
}

.crm-manager-unlock {
    max-width: 420px;
}

.crm-manager-admin .crm-admin-grid {
    padding: 0;
}

.crm-manager-admin .crm-manager-list form {
    grid-template-columns: auto;
}

.crm-button-secondary {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--text);
    padding: 0 10px;
    font-weight: 750;
    text-decoration: none;
}

.crm-button-secondary:hover {
    border-color: var(--line-strong);
    background: var(--surface-3);
}

.crm-workspace--detail-only {
    display: block;
}

.crm-workspace--detail-only .crm-detail {
    position: static;
    max-height: none;
}

.crm-workspace--list-only {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "board";
}

.crm-workspace--list-only .crm-board-shell {
    grid-area: board;
}

.crm-lead-picker .crm-card-list {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    padding: 10px;
}

.crm-pipeline-page {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
}

.crm-pipeline-head {
    border-bottom: 1px solid var(--line);
}

.crm-funnel {
    display: grid;
    gap: 8px;
    padding: 14px;
}

.crm-funnel-step {
    display: grid;
    grid-template-columns: minmax(90px, var(--funnel-width)) minmax(180px, 1fr);
    gap: 12px;
    align-items: stretch;
    width: 100%;
    min-height: 58px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 0;
    text-align: left;
}

.crm-funnel-step:focus-visible,
.crm-funnel-loss:focus-visible,
.crm-button-secondary:focus-visible,
.crm-dialog button:focus-visible {
    outline: 3px solid rgba(36, 111, 187, .28);
    outline-offset: 2px;
}

.crm-funnel-step:hover {
    border-color: var(--line-strong);
    background: #fbfcfb;
}

.crm-funnel-bar {
    display: block;
    min-height: 100%;
    border-radius: 7px 0 0 7px;
    background: var(--surface-3);
}

.crm-funnel-step--new .crm-funnel-bar { background: var(--blue-soft); }
.crm-funnel-step--briefing .crm-funnel-bar { background: var(--green-soft); }
.crm-funnel-step--proposal .crm-funnel-bar { background: var(--yellow-soft); }
.crm-funnel-step--in_development .crm-funnel-bar { background: #e6e5f6; }
.crm-funnel-step--sold .crm-funnel-bar { background: #d8f0d4; }

.crm-funnel-copy {
    display: grid;
    align-content: center;
    gap: 4px;
    min-width: 0;
    padding: 10px 12px 10px 0;
}

.crm-funnel-copy strong,
.crm-funnel-copy small {
    overflow-wrap: anywhere;
}

.crm-funnel-copy small {
    color: var(--muted);
}

.crm-funnel-loss {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 54px;
    margin: 0 14px 14px;
    border: 1px solid #efb8b0;
    border-radius: 8px;
    background: var(--red-soft);
    color: #7d2525;
    padding: 0 12px;
    text-align: left;
}

.crm-dialog {
    width: min(920px, calc(100vw - 24px));
    max-height: min(820px, calc(100dvh - 24px));
    border: 0;
    border-radius: 8px;
    background: transparent;
    padding: 0;
    color: var(--text);
}

.crm-dialog::backdrop {
    background: rgba(13, 21, 18, .42);
}

.crm-dialog-frame {
    display: grid;
    gap: 12px;
    max-height: inherit;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
}

.crm-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.crm-dialog-head form {
    margin: 0;
}

.crm-dialog-metrics {
    padding: 0;
}

.crm-dialog-section {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.crm-dialog-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.crm-dialog-total {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 850;
}

.crm-dialog-leads {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}

.crm-dialog-leads article {
    display: grid;
    gap: 4px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.crm-dialog-leads a {
    font-weight: 850;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.crm-upsell-panel {
    display: grid;
    gap: 12px;
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
    padding: 12px;
}

.crm-upsell-panel[hidden] {
    display: none;
}

.crm-upsell-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.crm-upsell-grid > div {
    display: grid;
    align-content: start;
    gap: 7px;
    min-width: 0;
}

.crm-upsell-grid label {
    display: flex;
    gap: 7px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.crm-upsell-grid p {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    padding: 7px 8px;
}

.crm-status-briefing { background: var(--green-soft); color: #115d3b; }
.crm-status-in_development { background: #e6e5f6; color: #38305f; }
.crm-status-sold { background: #d8f0d4; color: #2e6d26; }

@media (max-width: 980px) {
    .crm-dashboard-kpis,
    .crm-dashboard-grid,
    .crm-dialog-columns,
    .crm-upsell-grid {
        grid-template-columns: 1fr;
    }

    .crm-manager-admin {
        grid-column: auto;
    }

    .crm-funnel-step {
        grid-template-columns: minmax(72px, 34%) minmax(0, 1fr);
    }
}

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

    .crm-funnel {
        padding: 10px;
    }

    .crm-funnel-step {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .crm-funnel-bar {
        min-height: 14px;
        width: var(--funnel-width);
        border-radius: 7px 7px 0 0;
    }

    .crm-funnel-copy {
        padding: 9px 10px;
    }

    .crm-funnel-loss {
        margin: 0 10px 10px;
    }

    .crm-dialog-frame {
        padding: 12px;
    }

    .crm-detail-head {
        display: grid;
    }

    .crm-detail-head .crm-button-secondary {
        justify-self: start;
    }
}
