html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body.quiz-app.crm-body {
    --crm-bg: #f5f7fa;
    --crm-surface: #ffffff;
    --crm-surface-subtle: #f8fafc;
    --crm-surface-raised: #ffffff;
    --crm-border: #e3e8ef;
    --crm-border-strong: #cbd5e1;
    --crm-text: #111827;
    --crm-text-soft: #667085;
    --crm-text-muted: #94a3b8;
    --crm-green: var(--qb-brand-primary, #5ab774);
    --crm-green-dark: #2f7a46;
    --crm-green-soft: rgba(90, 183, 116, 0.12);
    --crm-blue: #2563eb;
    --crm-blue-soft: rgba(37, 99, 235, 0.1);
    --crm-amber: #b7791f;
    --crm-amber-soft: rgba(183, 121, 31, 0.12);
    --crm-slate-soft: rgba(15, 23, 42, 0.055);
    --crm-danger: #b42318;
    --crm-danger-soft: rgba(180, 35, 24, 0.1);
    --crm-shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.05);
    --crm-shadow-card: 0 1px 1px rgba(15, 23, 42, 0.03), 0 12px 30px rgba(15, 23, 42, 0.045);
    --crm-shadow-drawer: -24px 0 60px rgba(15, 23, 42, 0.16);
    background: var(--qb-bg);
    color: var(--qb-text);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

a {
    color: inherit;
}

.crm-hidden {
    display: none !important;
}

.crm-app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 0;
    min-height: calc(100vh - var(--qb-header-h, 64px));
    height: calc(100vh - var(--qb-header-h, 64px));
    flex: 1 1 auto;
}

.crm-sidebar {
    min-height: 0;
    background: var(--qb-header-bg);
    border-right: 1px solid var(--qb-header-border);
    color: var(--qb-header-text);
    padding: 16px 12px 18px;
    overflow-y: auto;
}

.crm-nav-group + .crm-nav-group {
    margin-top: 14px;
}

.crm-nav-label {
    padding: 0 10px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--qb-header-text-faint);
}

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

.crm-nav-item {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--qb-header-text);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.crm-nav-item:hover {
    background: var(--qb-header-control-bg);
    border-color: var(--qb-header-control-border);
}

.crm-nav-item.is-active {
    background: rgba(90, 183, 116, 0.18);
    border-color: rgba(90, 183, 116, 0.42);
    color: #f4fff7;
}

.crm-nav-count {
    min-width: 28px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--qb-header-text);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.crm-main {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 12px 16px 12px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.crm-topbar {
    flex-shrink: 0;
    background: #F3F4F6;
    border-bottom: 1px solid #E5E7EB;
    box-shadow: none;
    padding: 10px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.crm-topbar:empty {
    display: none;
}

.crm-topbar-copy h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.05;
    font-weight: 700;
    color: var(--qb-text);
}

.crm-topbar-copy p {
    margin: 6px 0 0;
    max-width: 900px;
    color: var(--qb-text-secondary);
    font-size: 12px;
    line-height: 1.4;
}

.crm-topbar-actions,
.crm-workspace-toolbar-left,
.crm-workspace-toolbar-right,
.crm-workspace-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.crm-topbar-actions {
    margin-left: auto;
    justify-content: flex-end;
}

.crm-content {
    flex: 1;
    overflow: auto;
    min-height: 0;
    padding: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    background: #fff;
    border-radius: 0;
}

.crm-content > .crm-overview-grid {
    min-height: 0;
    overflow: auto;
}

/* Full-bleed under .crm-main rounding — avoid card radius on load vs table (was .crm-panel on .crm-loading-state) */
.crm-content > .crm-loading-state,
.crm-content > .crm-empty-state {
    border-radius: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    min-height: 0;
    overflow: auto;
}

.crm-panel,
.crm-empty-state,
.crm-loading-state,
.crm-modal {
    background: var(--qb-surface);
    border: 1px solid var(--qb-border);
    border-radius: 12px;
    box-shadow: var(--ui-shadow-card);
}

.crm-subpanel,
.crm-workspace-panel {
    padding: 16px;
}

.crm-workspace-panel {
    padding: 0;
    border-radius: 0;
    overflow: hidden;
    border-top: 0;
    box-shadow: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.crm-workspace-panel .crm-workspace-toolbar,
.crm-workspace-panel .crm-chip-row,
.crm-workspace-panel .crm-chip-row-empty {
    flex-shrink: 0;
}

.crm-workspace-panel .crm-pagination {
    flex-shrink: 0;
}

.crm-panel h3,
.crm-drawer-section h4,
.crm-modal-header h3 {
    margin: 0 0 10px;
    color: var(--qb-text);
    font-size: 18px;
    font-weight: 700;
}

.crm-overview-grid,
.crm-overview-panels,
.crm-stat-grid {
    display: grid;
    gap: 16px;
}

.crm-overview-grid {
    padding: 16px;
    box-sizing: border-box;
}

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

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

.crm-stat-card {
    background: #fff;
    border: 1px solid var(--qb-border);
    border-radius: 12px;
    padding: 16px;
}

.crm-stat-label,
.crm-form-label,
.crm-key {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--qb-text-muted);
}

.crm-stat-value {
    margin-top: 8px;
    font-size: 30px;
    font-weight: 700;
    color: var(--qb-text);
}

.crm-list,
.crm-related-list,
.crm-key-value-list {
    display: grid;
    gap: 10px;
}

.crm-list-item,
.crm-related-item {
    background: #fff;
    border: 1px solid var(--qb-border);
    border-radius: 10px;
    padding: 12px 14px;
}

button.crm-related-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

button.crm-related-item--link:hover {
    border-color: rgba(90, 183, 116, 0.45);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.crm-related-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.crm-related-item-header .crm-table-title {
    flex: 1;
    min-width: 0;
}

.crm-related-primary-badge {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--qb-text-muted);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--qb-border);
    background: rgba(0, 0, 0, 0.02);
}

.crm-list-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--qb-text);
    line-height: 1.25;
}

.crm-table-title {
    font-size: 13px;
    font-weight: 400;
    color: var(--qb-text);
    line-height: 1.25;
}

.crm-table-subtitle {
    margin-top: 2px;
}

.crm-list-meta,
.crm-table-subtitle,
.crm-pagination-meta,
.crm-modal-header p,
.crm-inline-banner,
.crm-value {
    font-size: 12px;
    line-height: 1.35;
    color: var(--qb-text-secondary);
}

.crm-workspace-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--qb-border);
    background: #fff;
}

.crm-workspace-toolbar--thead {
    border-bottom: 0;
    background: transparent;
    margin: 0;
}

.crm-workspace-toolbar--thead .crm-workspace-toolbar-left {
    flex: 1 1 200px;
    min-width: 0;
}

.crm-workspace-toolbar--thead .crm-workspace-toolbar-actions {
    flex-shrink: 0;
}

.crm-search-form {
    min-width: 260px;
}

.crm-view-select-wrap {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 190px;
}

.crm-view-select-label {
    color: var(--qb-text-secondary);
    font-size: 12px;
    font-weight: 650;
}

.crm-view-select {
    min-width: 150px;
    max-width: 220px;
}

.crm-input,
.crm-select,
.crm-textarea {
    width: 100%;
    background: #fff;
    border: 1px solid #D1D5DB;
    color: #111827;
    border-radius: 8px;
    padding: 8px 10px;
    outline: none;
    min-height: 36px;
}

.crm-input::placeholder,
.crm-textarea::placeholder {
    color: #9CA3AF;
}

.crm-input:focus,
.crm-select:focus,
.crm-textarea:focus {
    border-color: var(--qb-brand-primary);
    box-shadow: var(--ui-focus-ring);
}

.crm-search {
    min-width: 260px;
}

.crm-textarea {
    min-height: 118px;
    resize: vertical;
}

.crm-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
    padding: 8px 12px;
    border-bottom: 1px solid var(--qb-border);
    background: #fff;
}

.crm-chip-row-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--qb-border);
    background: #fff;
    font-size: 11px;
    color: var(--qb-text-muted);
}

.crm-workspace-panel--leads .crm-workspace-toolbar {
    flex-wrap: nowrap;
}

.crm-workspace-panel--leads .crm-workspace-toolbar-left {
    flex-wrap: nowrap;
    min-width: 0;
    flex: 1;
}

.crm-workspace-panel--leads .crm-workspace-toolbar-actions {
    flex-shrink: 0;
}

.crm-workspace-panel--leads .crm-search-form {
    min-width: 0;
    flex: 1 1 140px;
}

.crm-workspace-panel--leads .crm-search {
    min-width: 0;
}

.crm-chip-row--single-line {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.crm-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--qb-surface-muted);
    border: 1px solid var(--qb-border);
    color: var(--qb-text-secondary);
    font-size: 11px;
    font-weight: 400;
}

.crm-chip--view {
    border-color: rgba(90, 183, 116, 0.28);
    background: rgba(90, 183, 116, 0.1);
    color: var(--crm-green-dark, #2f7a46);
}

.crm-chip button {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.crm-table-shell {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    border: 0;
    border-radius: 0;
    background: #fff;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    --crm-thead-toolbar-h: 56px;
}

.crm-table th,
.crm-table td {
    padding: 7px 10px;
    text-align: left;
    vertical-align: top;
}

.crm-table thead tr.crm-thead-toolbar th {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 0;
    vertical-align: middle;
    background: #fff;
    border-bottom: 1px solid var(--qb-border);
    text-transform: none;
    letter-spacing: normal;
    font-size: inherit;
    font-weight: 400;
    color: inherit;
}

.crm-table thead tr.crm-thead-columns th {
    position: sticky;
    top: var(--crm-thead-toolbar-h);
    z-index: 2;
    padding-top: 6px;
    padding-bottom: 6px;
    background: #F9FAFB;
    border-bottom: 1px solid var(--qb-border);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--qb-text-muted);
}

.crm-icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid #D1D5DB;
    background: #fff;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.crm-icon-btn--labeled {
    width: auto;
    min-width: auto;
    justify-content: flex-start;
    gap: 6px;
    padding: 0 10px 0 8px;
}

.crm-icon-btn-text {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.crm-icon-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
}

.crm-icon-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.crm-icon-btn-svg {
    display: block;
    flex-shrink: 0;
}

.crm-icon-btn--has-badge {
    padding-right: 6px;
}

.crm-icon-btn--labeled.crm-icon-btn--has-badge {
    padding-right: 22px;
}

.crm-icon-btn-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--qb-brand-primary, #5ab774);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.crm-icon-btn--topbar {
    width: 38px;
    height: 36px;
}

.crm-th-sort-btn {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font: inherit;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--qb-text-muted);
    cursor: pointer;
    text-align: left;
    transition: color 0.12s ease;
}

.crm-th-sort-btn:hover:not(:disabled) {
    color: var(--qb-text);
}

.crm-th-sort-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.crm-table tbody td {
    background: #fff;
    font-weight: 400;
}

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

.crm-table tbody tr:hover td {
    background: rgba(90, 183, 116, 0.06);
}

.crm-table tbody tr + tr td {
    border-top: 1px solid #E5E7EB;
}

.crm-workspace-panel[data-section="activities"] .crm-table th[data-column-key="created_at"],
.crm-workspace-panel[data-section="activities"] .crm-table td[data-column-key="created_at"],
.crm-workspace-panel[data-section="activities"] .crm-table th[data-column-key="updated_at"],
.crm-workspace-panel[data-section="activities"] .crm-table td[data-column-key="updated_at"] {
    min-width: 190px;
    width: 190px;
    white-space: nowrap;
}

.crm-workspace-panel[data-section="activities"] .crm-table td[data-column-key="created_at"] .crm-table-title,
.crm-workspace-panel[data-section="activities"] .crm-table td[data-column-key="created_at"] .crm-table-subtitle,
.crm-workspace-panel[data-section="activities"] .crm-table td[data-column-key="updated_at"] .crm-table-title,
.crm-workspace-panel[data-section="activities"] .crm-table td[data-column-key="updated_at"] .crm-table-subtitle {
    white-space: nowrap;
}

.crm-table tbody tr.crm-table-loading-row {
    cursor: default;
}

.crm-table tbody tr.crm-table-loading-row:hover td {
    background: #fff;
}

.crm-table-inline-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 36px 16px;
    color: var(--qb-text-muted);
    font-size: 13px;
    font-weight: 400;
}

.crm-table-inline-loading .crm-spinner {
    width: 22px;
    height: 22px;
    margin: 0;
    border-width: 2px;
}

.crm-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    background: #F3F4F6;
    color: #374151;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.crm-status-pill[data-tone="success"] {
    background: rgba(90, 183, 116, 0.16);
    color: #1f6a37;
}

.crm-status-pill[data-tone="warning"] {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
}

.crm-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-top: 1px solid var(--qb-border);
    background: #fff;
}

.crm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid #D1D5DB;
    background: #fff;
    color: #374151;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.crm-btn:hover {
    background: #F9FAFB;
    border-color: #9CA3AF;
}

.crm-btn-primary {
    background: var(--qb-brand-primary);
    color: #fff;
    border-color: var(--qb-brand-primary);
}

.crm-btn-primary:hover {
    background: var(--qb-brand-primary-strong);
    border-color: var(--qb-brand-primary-strong);
    color: #fff;
}

.crm-btn-danger {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.crm-btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.crm-drawer-backdrop {
    position: fixed;
    inset: var(--qb-header-h, 64px) 0 0 0;
    z-index: 140;
    background: rgba(7, 43, 46, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.crm-drawer-backdrop.is-active {
    opacity: 1;
    pointer-events: auto;
}

/* Outer shell: fixed width clip so only transform moves; inner panel keeps full width for stable text layout. */
.crm-drawer {
    --crm-drawer-width: 420px;
    position: fixed;
    top: var(--qb-header-h, 64px);
    right: 0;
    z-index: 150;
    width: min(var(--crm-drawer-width), 100vw);
    height: calc(100vh - var(--qb-header-h, 64px));
    height: calc(100dvh - var(--qb-header-h, 64px));
    overflow: hidden;
    pointer-events: none;
}

.crm-drawer.is-open {
    pointer-events: auto;
}

.crm-drawer-panel {
    width: 100%;
    min-width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
    border-left: 1px solid var(--qb-border);
    box-shadow: -12px 0 28px rgba(0, 0, 0, 0.08);
    transform: translate3d(100%, 0, 0);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-drawer.is-open .crm-drawer-panel {
    transform: translate3d(0, 0, 0);
}

.crm-drawer-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
}

.crm-drawer-header,
.crm-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.crm-drawer-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--qb-text-muted);
}

.crm-drawer-title {
    margin: 6px 0 0;
    font-size: 24px;
    line-height: 1.05;
    font-weight: 700;
    color: var(--qb-text);
}

.crm-drawer-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #E5E7EB;
}

.crm-key-value {
    display: grid;
    gap: 4px;
}

.crm-modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(7, 43, 46, 0.45);
    z-index: 200;
}

.crm-modal {
    width: min(680px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 18px;
}

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

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

.crm-form-grid .crm-form-field.is-full {
    grid-column: 1 / -1;
}

.crm-searchable-select {
    display: grid;
    gap: 8px;
}

.crm-searchable-select-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.crm-searchable-select-menu {
    max-height: min(280px, 42vh);
    overflow: auto;
    border: 1px solid var(--crm-border, var(--qb-border));
    border-radius: 8px;
    background: #fff;
}

.crm-searchable-select-option {
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--crm-border, var(--qb-border));
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.crm-searchable-select-option:last-child {
    border-bottom: 0;
}

.crm-searchable-select-option:hover,
.crm-searchable-select-option.is-selected {
    background: var(--crm-surface-subtle, rgba(90, 183, 116, 0.08));
}

.crm-searchable-select-option.is-selected .crm-list-title {
    color: var(--crm-green-dark, #2f7a46);
}

.crm-routing-rule-list {
    display: grid;
    gap: 12px;
}

.crm-routing-rule {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--crm-border, var(--qb-border));
    border-radius: 8px;
    background: #fff;
}

.crm-routing-rule-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.crm-toggle-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--crm-muted);
    font-size: 13px;
    white-space: nowrap;
}

.crm-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

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

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

.crm-filter-row {
    border: 1px solid var(--qb-border);
    border-radius: 10px;
    background: #fff;
    padding: 12px;
    display: grid;
    gap: 10px;
}

.crm-filter-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(140px, 0.8fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.crm-filter-help {
    font-size: 11px;
    color: var(--qb-text-muted);
}

.crm-empty-state,
.crm-loading-state {
    padding: 42px 24px;
    text-align: center;
}

.crm-empty-state h1 {
    margin: 0 0 10px;
    font-size: 24px;
    line-height: 1.2;
    color: var(--qb-text-strong);
}

.crm-empty-state p {
    max-width: 560px;
    margin: 0 auto 10px;
    color: var(--qb-text-muted);
    line-height: 1.55;
}

.crm-empty-help {
    font-size: 13px;
}

.crm-empty-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.crm-spinner {
    width: 30px;
    height: 30px;
    margin: 0 auto 12px;
    border-radius: 50%;
    border: 3px solid rgba(90, 183, 116, 0.16);
    border-top-color: var(--qb-brand-primary);
    animation: crm-spin 0.8s linear infinite;
}

.crm-inline-banner {
    padding: 12px 14px;
    border-radius: 10px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
}

.crm-iframe-shell {
    padding: 0;
    overflow: hidden;
}

.crm-iframe-shell iframe {
    display: block;
    width: 100%;
    height: calc(100vh - 190px);
    border: 0;
}

/* Pipeline section: no CRM topbar; iframe fills main column */
body.crm-section-pipeline .crm-topbar {
    display: none;
}

body.crm-section-pipeline .crm-content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.crm-section-pipeline .crm-iframe-shell--pipeline {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 0;
}

body.crm-section-pipeline .crm-iframe-shell--pipeline iframe {
    flex: 1;
    min-height: 0;
    height: 100%;
}

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

@media (max-width: 1080px) {
    .crm-app-shell {
        grid-template-columns: 220px minmax(0, 1fr) 0;
    }

    .crm-overview-panels {
        grid-template-columns: 1fr;
    }
}

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

    .crm-main {
        margin: 10px 12px;
    }

    .crm-sidebar {
        min-height: auto;
        max-height: none;
    }

    .crm-topbar {
        position: static;
    }

    .crm-drawer {
        width: 100%;
        left: 0;
        z-index: 210;
    }
}

@media (max-width: 640px) {
    .crm-main {
        margin: 8px;
        border-radius: 10px;
    }

    .crm-sidebar,
    .crm-topbar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .crm-topbar-copy h1 {
        font-size: 22px;
    }

    .crm-search-form,
    .crm-search {
        min-width: 100%;
    }

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

    .crm-filter-grid {
        grid-template-columns: 1fr;
    }

    .crm-pagination,
    .crm-workspace-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-workspace-panel--leads .crm-workspace-toolbar {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
    }

    .crm-topbar-actions,
    .crm-workspace-toolbar-left,
    .crm-workspace-toolbar-right,
    .crm-workspace-toolbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .crm-workspace-panel--leads .crm-workspace-toolbar-left,
    .crm-workspace-panel--leads .crm-workspace-toolbar-actions {
        width: auto;
    }

    .crm-workspace-panel--leads .crm-search-form,
    .crm-workspace-panel--leads .crm-search {
        min-width: 0;
    }
}

/* Quiet CRM polish layer */
body.quiz-app.crm-body {
    background: var(--crm-bg);
}

.crm-app-shell {
    background: var(--crm-bg);
}

.crm-sidebar {
    background: #072b2e;
    padding: 14px 10px 16px;
}

.crm-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 14px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.crm-sidebar-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(90, 183, 116, 0.16);
    border: 1px solid rgba(90, 183, 116, 0.32);
    color: #e8fcec;
}

.crm-sidebar-brand-icon,
.crm-nav-svg,
.crm-topbar-svg,
.crm-table-context-svg,
.crm-panel-svg,
.crm-stat-svg,
.crm-health-svg,
.crm-empty-svg,
.crm-btn-icon,
.crm-meta-pill-icon,
.crm-inline-value-icon,
.crm-activity-dot-svg,
.crm-drawer-kicker-icon {
    display: block;
    flex-shrink: 0;
}

.crm-sidebar-brand-title {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
}

.crm-sidebar-brand-subtitle {
    margin-top: 2px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.58);
}

.crm-nav-label {
    padding: 10px 10px 7px;
    color: rgba(255, 255, 255, 0.46);
}

.crm-nav-list {
    gap: 4px;
}

.crm-nav-item {
    min-height: 38px;
    border-radius: 8px;
    padding: 8px 9px;
    color: rgba(255, 255, 255, 0.78);
}

.crm-nav-item-main {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.crm-nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    color: rgba(255, 255, 255, 0.68);
    background: rgba(255, 255, 255, 0.06);
}

.crm-nav-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.crm-nav-item:hover .crm-nav-icon,
.crm-nav-item.is-active .crm-nav-icon {
    color: #072b2e;
    background: var(--crm-green);
}

.crm-nav-item.is-active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(90, 183, 116, 0.42);
    color: #ffffff;
}

.crm-nav-count {
    min-width: 24px;
    padding: 2px 7px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.78);
    font-size: 10px;
}

.crm-nav-item.is-active .crm-nav-count {
    background: rgba(232, 252, 236, 0.14);
    color: #e8fcec;
}

.crm-main {
    margin: 12px 14px 12px 12px;
    border-color: var(--crm-border);
    border-radius: 8px;
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-soft);
}

.crm-topbar {
    min-height: 76px;
    padding: 14px 16px;
    background: var(--crm-surface);
    border-bottom-color: var(--crm-border);
}

.crm-topbar-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    color: var(--crm-green-dark);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.crm-topbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--crm-green-soft);
    color: var(--crm-green-dark);
}

.crm-topbar-copy h1 {
    font-size: 22px;
    letter-spacing: 0;
}

.crm-topbar-copy p {
    margin-top: 4px;
    color: var(--crm-text-soft);
}

.crm-content {
    background: var(--crm-surface-subtle);
}

.crm-panel,
.crm-empty-state,
.crm-loading-state,
.crm-modal,
.crm-stat-card,
.crm-list-item,
.crm-related-item,
.crm-filter-row {
    border-color: var(--crm-border);
    border-radius: 8px;
    box-shadow: none;
}

.crm-panel,
.crm-stat-card,
.crm-list-item,
.crm-related-item,
.crm-filter-row,
.crm-modal {
    background: var(--crm-surface);
}

.crm-overview-grid {
    gap: 14px;
    padding: 14px;
}

.crm-stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 12px;
}

.crm-stat-card {
    position: relative;
    overflow: hidden;
    padding: 14px;
    border-top: 3px solid var(--crm-green);
    box-shadow: var(--crm-shadow-card);
}

.crm-stat-card--blue {
    border-top-color: var(--crm-blue);
}

.crm-stat-card--amber {
    border-top-color: var(--crm-amber);
}

.crm-stat-card--slate {
    border-top-color: #64748b;
}

.crm-stat-card-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.crm-stat-icon,
.crm-panel-heading-icon,
.crm-health-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--crm-green-dark);
    background: var(--crm-green-soft);
}

.crm-stat-icon {
    width: 34px;
    height: 34px;
}

.crm-stat-card--blue .crm-stat-icon {
    color: var(--crm-blue);
    background: var(--crm-blue-soft);
}

.crm-stat-card--amber .crm-stat-icon {
    color: var(--crm-amber);
    background: var(--crm-amber-soft);
}

.crm-stat-card--slate .crm-stat-icon {
    color: #475569;
    background: var(--crm-slate-soft);
}

.crm-stat-label,
.crm-form-label,
.crm-key {
    color: var(--crm-text-muted);
}

.crm-stat-value {
    margin-top: 6px;
    font-size: 28px;
    line-height: 1;
    color: var(--crm-text);
}

.crm-stat-detail {
    margin-top: 10px;
    color: var(--crm-text-soft);
    font-size: 12px;
}

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

.crm-post-stat-card {
    padding: 10px;
    border-top-width: 2px;
}

.crm-post-stat-card .crm-stat-icon {
    width: 28px;
    height: 28px;
}

.crm-post-stat-card .crm-stat-value {
    font-size: 20px;
}

.crm-post-stat-sync-time {
    margin-top: 10px;
}

.crm-linkedin-post-card {
    display: grid;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.crm-linkedin-post-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.crm-linkedin-post-author {
    flex: 1;
    min-width: 0;
}

.crm-linkedin-post-author-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.crm-linkedin-post-name {
    min-width: 0;
    overflow: hidden;
    color: var(--crm-text);
    font-size: 14px;
    font-weight: 750;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-linkedin-post-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 6px;
    background: #0a66c2;
    color: #ffffff;
}

.crm-linkedin-post-badge-icon {
    width: 15px;
    height: 15px;
}

.crm-linkedin-post-subtitle,
.crm-linkedin-post-time,
.crm-linkedin-post-footer {
    color: var(--crm-text-soft);
    font-size: 12px;
    line-height: 1.35;
}

.crm-linkedin-post-subtitle {
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.crm-linkedin-post-time {
    margin-top: 3px;
}

.crm-linkedin-post-body {
    color: var(--crm-text);
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.crm-linkedin-post-media {
    display: block;
    overflow: hidden;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: #f8fafc;
    color: inherit;
    text-decoration: none;
}

.crm-linkedin-post-media img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: cover;
}

.crm-empty-inline {
    color: var(--crm-text-muted);
    font-style: italic;
}

.crm-linkedin-post-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--crm-border);
}

.crm-linkedin-post-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.crm-linkedin-post-open {
    flex: 0 0 auto;
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
}

.crm-linkedin-post-open:hover {
    text-decoration: underline;
}

.crm-sync-banner {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-sync-banner[data-state="error"] {
    border-color: rgba(185, 28, 28, 0.22);
    background: rgba(254, 242, 242, 0.92);
}

.crm-inline-spinner {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 2px solid rgba(90, 183, 116, 0.18);
    border-top-color: var(--crm-green);
    animation: crm-spin 0.8s linear infinite;
}

.crm-sync-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    color: var(--crm-green-dark);
}

.crm-sync-banner[data-state="error"] .crm-sync-icon {
    color: var(--crm-danger);
}

.crm-overview-panels {
    gap: 12px;
}

.crm-subpanel {
    padding: 14px;
    box-shadow: var(--crm-shadow-card);
}

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

.crm-panel-heading h3 {
    margin-bottom: 3px;
    font-size: 16px;
}

.crm-panel-heading p {
    margin: 0;
    color: var(--crm-text-soft);
    font-size: 12px;
    line-height: 1.4;
}

.crm-panel-heading-icon,
.crm-health-icon {
    width: 32px;
    height: 32px;
}

.crm-list {
    gap: 8px;
}

.crm-list-item--rich,
.crm-health-item,
.crm-related-item-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.crm-list-item-body,
.crm-related-item-copy,
.crm-identity-copy {
    min-width: 0;
    flex: 1;
}

.crm-list-title,
.crm-table-title {
    color: var(--crm-text);
}

.crm-table-title {
    font-weight: 600;
}

.crm-table-title--truncate,
.crm-table-subtitle,
.crm-value {
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-table-title--truncate {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.crm-table-subtitle,
.crm-list-meta,
.crm-pagination-meta,
.crm-modal-header p,
.crm-inline-banner,
.crm-value {
    color: var(--crm-text-soft);
}

.crm-health-list {
    display: grid;
    gap: 8px;
}

.crm-health-item {
    padding: 11px 12px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: var(--crm-surface-subtle);
}

.crm-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: 8px;
    background: var(--crm-green-soft);
    border: 1px solid rgba(90, 183, 116, 0.26);
    color: var(--crm-green-dark);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.crm-avatar--small {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
    border-radius: 7px;
    font-size: 10px;
}

.crm-avatar--tiny {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    border-radius: 6px;
    font-size: 9px;
}

.crm-avatar--large {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
    border-radius: 8px;
    font-size: 14px;
}

.crm-avatar-icon {
    display: none;
}

.crm-workspace-panel {
    background: var(--crm-surface);
}

.crm-workspace-toolbar {
    min-height: 58px;
    padding: 10px 12px;
    border-bottom-color: var(--crm-border);
}

.crm-workspace-toolbar--thead {
    background: var(--crm-surface);
}

.crm-workspace-toolbar-left {
    gap: 12px;
}

.crm-table-context {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 160px;
}

.crm-table-context-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--crm-slate-soft);
    color: #475569;
}

.crm-table-context-title {
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
}

.crm-table-context-subtitle {
    margin-top: 1px;
    color: var(--crm-text-soft);
    font-size: 11px;
}

.crm-search-form {
    position: relative;
    min-width: 280px;
}

.crm-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    z-index: 1;
    color: var(--crm-text-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.crm-search {
    min-width: 280px;
    padding-left: 34px;
}

.crm-input,
.crm-select,
.crm-textarea {
    border-color: var(--crm-border-strong);
    border-radius: 8px;
    color: var(--crm-text);
    background: var(--crm-surface);
}

.crm-chip-row,
.crm-chip-row-empty {
    background: var(--crm-surface);
    border-bottom-color: var(--crm-border);
}

.crm-chip {
    border-color: var(--crm-border);
    background: var(--crm-surface-subtle);
    color: var(--crm-text-soft);
}

.crm-table-shell {
    background: var(--crm-surface);
}

.crm-table {
    --crm-thead-toolbar-h: 58px;
    table-layout: auto;
}

.crm-table th,
.crm-table td {
    padding: 8px 10px;
}

.crm-table thead tr.crm-thead-toolbar th {
    background: var(--crm-surface);
    border-bottom-color: var(--crm-border);
}

.crm-table thead tr.crm-thead-columns th {
    background: #f8fafc;
    border-bottom-color: var(--crm-border);
    color: var(--crm-text-muted);
}

.crm-th-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.crm-sort-indicator {
    color: var(--crm-green-dark);
    font-weight: 800;
}

.crm-table tbody td {
    background: var(--crm-surface);
}

.crm-table tbody tr + tr td {
    border-top-color: var(--crm-border);
}

.crm-table tbody tr:hover td {
    background: rgba(90, 183, 116, 0.045);
}

.crm-identity-cell,
.crm-inline-value {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.crm-inline-value {
    max-width: 280px;
    color: var(--crm-text-soft);
}

.crm-inline-value span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-inline-value--link {
    color: #2563eb;
}

.crm-media-cell {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    width: 180px;
    max-width: 220px;
    color: #2563eb;
    text-decoration: none;
}

.crm-media-cell img {
    width: 64px;
    height: 40px;
    border: 1px solid var(--crm-border);
    border-radius: 6px;
    background: #f8fafc;
    object-fit: cover;
}

.crm-media-cell span {
    min-width: 0;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-media-cell:hover span {
    text-decoration: underline;
}

.crm-drawer-link {
    color: #2563eb;
    font-weight: 650;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.crm-drawer-link:hover {
    text-decoration: underline;
}

.crm-number-cell {
    color: var(--crm-text);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.crm-date-cell .crm-table-title,
.crm-date-cell .crm-table-subtitle {
    white-space: nowrap;
}

.crm-activity-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 8px;
    background: var(--crm-amber-soft);
    color: var(--crm-amber);
}

.crm-status-pill {
    gap: 6px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #eef2f7;
    color: #475467;
    font-size: 10px;
    font-weight: 700;
}

.crm-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
}

.crm-status-pill[data-tone="success"] {
    border-color: rgba(90, 183, 116, 0.24);
    background: var(--crm-green-soft);
    color: var(--crm-green-dark);
}

.crm-status-pill[data-tone="warning"] {
    border-color: rgba(183, 121, 31, 0.22);
    background: var(--crm-amber-soft);
    color: var(--crm-amber);
}

.crm-status-pill[data-tone="danger"] {
    border-color: rgba(180, 35, 24, 0.2);
    background: var(--crm-danger-soft);
    color: var(--crm-danger);
}

.crm-icon-btn,
.crm-btn {
    border-color: var(--crm-border-strong);
    border-radius: 8px;
    background: var(--crm-surface);
    color: #344054;
}

.crm-icon-btn:hover:not(:disabled),
.crm-btn:hover:not(:disabled) {
    background: var(--crm-surface-subtle);
    border-color: #98a2b3;
}

.crm-btn:disabled,
.crm-icon-btn:disabled {
    opacity: 0.48;
}

.crm-btn-primary {
    background: var(--crm-green);
    border-color: var(--crm-green);
    color: #072b2e;
}

.crm-btn-primary:hover:not(:disabled) {
    background: #4fa768;
    border-color: #4fa768;
    color: #072b2e;
}

.crm-btn-icon {
    width: 15px;
    height: 15px;
}

.crm-skeleton-line {
    display: block;
    width: 74%;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, #eef2f7 0%, #f8fafc 45%, #eef2f7 100%);
    background-size: 200% 100%;
    animation: crm-skeleton 1.2s ease-in-out infinite;
    animation-delay: var(--crm-skeleton-delay, 0ms);
}

.crm-skeleton-line--wide {
    width: 86%;
}

.crm-skeleton-line--short {
    width: 42%;
    margin-top: 7px;
}

.crm-empty-state--table {
    padding: 38px 20px;
    box-shadow: none;
    border: 0;
    background: transparent;
}

.crm-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--crm-slate-soft);
    color: #475569;
}

.crm-pagination {
    border-top-color: var(--crm-border);
    background: var(--crm-surface);
}

.crm-drawer-backdrop {
    background: rgba(7, 43, 46, 0.3);
    backdrop-filter: blur(2px);
}

.crm-drawer {
    --crm-drawer-width: 640px;
}

.crm-drawer-panel {
    background: var(--crm-surface);
    border-left-color: var(--crm-border);
    box-shadow: var(--crm-shadow-drawer);
}

.crm-drawer-inner {
    padding: 0;
}

.crm-drawer-profile {
    padding: 18px;
    border-bottom: 1px solid var(--crm-border);
    background: #fbfcfe;
}

.crm-drawer-header {
    margin-bottom: 12px;
}

.crm-drawer-title-wrap {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.crm-drawer-kicker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--crm-green-dark);
}

.crm-drawer-title {
    margin-top: 4px;
    font-size: 22px;
    line-height: 1.12;
    letter-spacing: 0;
}

.crm-drawer-subtitle {
    margin: 6px 0 0;
    color: var(--crm-text-soft);
    font-size: 13px;
    line-height: 1.4;
}

.crm-drawer-meta-row,
.crm-drawer-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crm-drawer-action-row {
    padding: 12px 18px;
    border-bottom: 1px solid var(--crm-border);
    background: var(--crm-surface);
}

.crm-meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--crm-border);
    background: var(--crm-surface);
    color: var(--crm-text-soft);
    font-size: 11px;
    font-weight: 650;
}

.crm-drawer-section {
    margin: 0;
    padding: 16px 18px;
    border-top: 0;
    border-bottom: 1px solid var(--crm-border);
}

.crm-drawer-section h4 {
    margin-bottom: 10px;
    color: var(--crm-text);
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

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

.crm-key-value {
    gap: 5px;
    padding: 10px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: var(--crm-surface-subtle);
}

.crm-related-list {
    gap: 8px;
}

.crm-related-item {
    padding: 10px;
    background: var(--crm-surface-subtle);
}

.crm-code-block {
    max-height: 300px;
    overflow: auto;
    white-space: pre-wrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    line-height: 1.5;
}

.crm-modal-overlay {
    background: rgba(7, 43, 46, 0.38);
    backdrop-filter: blur(3px);
}

.crm-modal {
    padding: 0;
    border-color: var(--crm-border);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.2);
}

.crm-modal-header {
    margin: 0;
    padding: 16px 18px;
    border-bottom: 1px solid var(--crm-border);
    background: #fbfcfe;
}

.crm-modal-header h3 {
    margin-bottom: 4px;
    font-size: 17px;
}

.crm-modal form,
.crm-modal > .crm-list,
.crm-modal > .crm-inline-banner,
.crm-company-search-results {
    padding: 16px 18px;
}

.crm-modal-footer {
    margin: 16px -18px -16px;
    padding: 12px 18px;
    border-top: 1px solid var(--crm-border);
    background: var(--crm-surface-subtle);
}

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

.crm-column-list {
    max-height: min(55vh, 440px);
    overflow: auto;
}

.crm-column-choice,
.crm-company-search-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.crm-company-search-results {
    margin-top: 0;
    border-top: 1px solid var(--crm-border);
}

.crm-inline-banner {
    background: var(--crm-surface-subtle);
    border-color: var(--crm-border);
}

.crm-loading-state--polished h1 {
    margin: 0 0 6px;
    font-size: 18px;
}

@keyframes crm-skeleton {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@media (max-width: 1080px) {
    .crm-table-context {
        display: none;
    }
}

@media (max-width: 860px) {
    body.quiz-app.crm-body {
        overflow: auto;
    }

    .crm-app-shell {
        min-height: auto;
        height: auto;
    }

    .crm-sidebar {
        display: block;
        overflow-x: auto;
        padding-bottom: 10px;
    }

    .crm-sidebar-brand {
        display: none;
    }

    .crm-nav-group {
        min-width: max-content;
    }

    .crm-nav-list {
        display: flex;
    }

    .crm-main {
        min-height: calc(100vh - var(--qb-header-h, 64px) - 82px);
    }

    .crm-key-value-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .crm-topbar {
        min-height: auto;
    }

    .crm-search-form,
    .crm-search {
        min-width: 0;
        width: 100%;
    }

    .crm-workspace-toolbar-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

    .crm-workspace-toolbar-actions .crm-btn,
    .crm-workspace-toolbar-actions .crm-icon-btn,
    .crm-view-select-wrap {
        flex: 0 0 auto;
    }

    .crm-view-select-wrap {
        min-width: 210px;
    }

    .crm-modal {
        width: 100%;
    }
}

.crm-select-col {
    width: 42px;
    min-width: 42px;
    max-width: 42px;
}

.crm-select-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    cursor: pointer;
}

.crm-select-box input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--crm-green-dark);
}

.crm-select-box span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.crm-table tbody tr.is-selected td {
    background: rgba(90, 183, 116, 0.08);
}

.crm-lead-bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--crm-border);
    background: #f1f8f3;
}

.crm-lead-bulk-copy,
.crm-lead-bulk-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-lead-bulk-copy {
    color: var(--crm-text-soft);
    font-size: 13px;
}

.crm-lead-bulk-copy strong {
    color: var(--crm-text);
}

.crm-modal-body {
    padding: 16px 18px;
}

.crm-inline-banner--danger {
    border-color: rgba(185, 28, 28, 0.22);
    background: rgba(254, 242, 242, 0.92);
    color: var(--crm-danger);
}

.crm-inline-banner--warning {
    border-color: rgba(217, 119, 6, 0.25);
    background: rgba(255, 251, 235, 0.92);
    color: #92400e;
}

.crm-lead-merge-body,
.crm-duplicate-lead-list {
    display: grid;
    gap: 12px;
}

.crm-lead-merge-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(220px, 0.9fr);
    gap: 12px;
}

.crm-lead-merge-panel,
.crm-duplicate-lead-group {
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: var(--crm-surface);
}

.crm-lead-merge-panel {
    padding: 12px;
}

.crm-lead-merge-panel h4 {
    margin: 0 0 10px;
    color: var(--crm-text);
    font-size: 13px;
    line-height: 1.25;
}

.crm-lead-merge-list,
.crm-lead-merge-counts,
.crm-merge-field-list,
.crm-merge-conflict-list {
    display: grid;
    gap: 8px;
}

.crm-lead-merge-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;
    padding: 9px;
    border: 1px solid var(--crm-border);
    border-radius: 8px;
    background: #fff;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.crm-lead-merge-choice.is-selected {
    border-color: rgba(90, 183, 116, 0.48);
    background: rgba(90, 183, 116, 0.06);
}

.crm-lead-merge-choice-copy {
    display: grid;
    min-width: 0;
    flex: 1;
}

.crm-lead-merge-count-row,
.crm-merge-field-row,
.crm-merge-conflict {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--crm-border);
}

.crm-lead-merge-count-row:last-child,
.crm-merge-field-row:last-child,
.crm-merge-conflict:last-child {
    border-bottom: 0;
}

.crm-lead-merge-count-row span,
.crm-merge-field-row span,
.crm-merge-conflict .crm-list-meta {
    min-width: 0;
    overflow-wrap: anywhere;
}

.crm-merge-field-row strong,
.crm-lead-merge-count-row strong {
    color: var(--crm-text);
    text-align: right;
}

.crm-duplicate-lead-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.8fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
}

.crm-duplicate-lead-people {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

@media (max-width: 760px) {
    .crm-lead-bulk-bar,
    .crm-lead-merge-grid,
    .crm-duplicate-lead-group {
        grid-template-columns: 1fr;
    }

    .crm-lead-bulk-bar {
        display: grid;
    }

    .crm-lead-bulk-actions {
        flex-wrap: wrap;
    }
}
