.crm-workspace {
    --ws-ink: #1a2335;
    --ws-muted: #68748a;
    --ws-line: #e1e7f0;
    --ws-blue: #3159d5;
    --ws-blue-soft: #eef3ff;
    color: var(--ws-ink);
    display: grid;
    gap: 18px;
    min-width: 0;
}

.crm-workspace *,
.crm-workspace *::before,
.crm-workspace *::after,
.crm-ws-modal *,
.crm-ws-modal *::before,
.crm-ws-modal *::after { box-sizing: border-box; }

.crm-ws-hero {
    align-items: flex-start;
    background: linear-gradient(132deg, #fff 0%, #f5f8ff 72%, #edf4ff 100%);
    border: 1px solid #dce5f5;
    border-radius: 20px;
    box-shadow: 0 18px 42px rgba(37, 57, 104, .08);
    display: flex;
    justify-content: space-between;
    min-height: 148px;
    padding: 28px 30px;
}

.crm-ws-hero > div > span,
.crm-ws-modal > header > span,
.crm-relation-content > header > div > span {
    color: #4468d7;
    display: block;
    font-size: 12px;
    font-weight: 760;
    letter-spacing: .13em;
    margin-bottom: 8px;
}

.crm-ws-hero h2 {
    font-size: clamp(25px, 2.5vw, 35px);
    letter-spacing: -.028em;
    line-height: 1.2;
    margin: 0;
}

.crm-ws-hero p {
    color: #4e5d78;
    font-size: 15px;
    line-height: 1.7;
    margin: 10px 0 4px;
    max-width: 790px;
}

.crm-ws-hero small {
    color: #7e899c;
    display: block;
    font-size: 12px;
    line-height: 1.55;
}

.crm-ws-hero > aside {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.crm-ws-hero em {
    background: rgba(255, 255, 255, .9);
    border: 1px solid #d5def4;
    border-radius: 999px;
    color: #435278;
    font-size: 12px;
    font-style: normal;
    font-weight: 650;
    padding: 7px 11px;
    white-space: nowrap;
}

.crm-ws-kpis {
    display: grid;
    gap: 13px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.crm-ws-kpis article {
    background: #fff;
    border: 1px solid var(--ws-line);
    border-radius: 15px;
    display: grid;
    gap: 6px;
    min-height: 112px;
    padding: 18px;
}

.crm-ws-kpis span { color: #6e798d; font-size: 12px; font-weight: 650; }
.crm-ws-kpis strong { font-size: clamp(23px, 2vw, 31px); letter-spacing: -.03em; }
.crm-ws-kpis small { color: #8994a6; font-size: 11px; line-height: 1.45; }

.crm-ws-toolbar {
    align-items: end;
    background: #fff;
    border: 1px solid var(--ws-line);
    border-radius: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 11px;
    padding: 15px;
}

.crm-ws-toolbar label,
.crm-account-picker form label {
    display: grid;
    flex: 1 1 210px;
    gap: 6px;
    min-width: 170px;
}

.crm-ws-toolbar label > span,
.crm-account-picker form label > span,
.crm-ws-form-grid label > span {
    color: #59657c;
    font-size: 12px;
    font-weight: 650;
}

.crm-ws-toolbar input,
.crm-ws-toolbar select,
.crm-account-picker input,
.crm-ws-form-grid input,
.crm-ws-form-grid select,
.crm-ws-form-grid textarea {
    background: #fff;
    border: 1px solid #cdd6e5;
    border-radius: 10px;
    color: var(--ws-ink);
    font: inherit;
    min-width: 0;
    padding: 10px 12px;
    width: 100%;
}

.crm-ws-toolbar input,
.crm-ws-toolbar select,
.crm-account-picker input { height: 42px; }

.crm-workspace button:focus-visible,
.crm-ws-modal button:focus-visible,
.crm-ws-modal input:focus,
.crm-ws-modal select:focus,
.crm-ws-modal textarea:focus,
.crm-workspace input:focus,
.crm-workspace select:focus {
    outline: 3px solid rgba(49, 89, 213, .2);
    outline-offset: 2px;
}

.crm-ws-btn,
.crm-ws-link {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
}

.crm-ws-btn.primary { background: var(--ws-blue); color: #fff; }
.crm-ws-btn.secondary,
.crm-ws-link { background: #fff; border-color: #ced7e7; color: #34466e; }
.crm-ws-btn.ghost { background: #f7f8fb; border-color: #e2e6ef; color: #59667d; }
.crm-ws-btn:disabled { cursor: not-allowed; opacity: .45; }

.crm-market-grid {
    align-items: start;
    display: grid;
    gap: 15px;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr);
}

.crm-market-side { display: grid; gap: 15px; }

.crm-ws-card,
.crm-calendar-agenda,
.crm-relation-content,
.crm-account-picker {
    background: #fff;
    border: 1px solid var(--ws-line);
    border-radius: 16px;
    min-width: 0;
}

.crm-ws-card { padding: 18px; }

.crm-ws-card > header,
.crm-calendar-agenda > header,
.crm-relation-content > header {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 14px;
}

.crm-ws-card h3,
.crm-calendar-agenda h3,
.crm-relation-content h3 { font-size: 17px; margin: 0; }
.crm-ws-card header p { color: #7c879a; font-size: 11px; line-height: 1.45; margin: 4px 0 0; }
.crm-ws-card header > span,
.crm-calendar-agenda header > span { background: #f1f4f8; border-radius: 999px; color: #657087; font-size: 11px; padding: 5px 8px; }

.crm-market-queue {
    border: 1px solid #e5e9f0;
    border-radius: 12px;
    overflow: hidden;
}

.crm-market-queue article {
    align-items: center;
    border-bottom: 1px solid #e8ecf2;
    display: grid;
    gap: 13px;
    grid-template-columns: 130px minmax(0, 1fr) auto;
    padding: 14px;
}

.crm-market-queue article:last-child { border-bottom: 0; }
.crm-market-queue article.overdue { border-left: 3px solid #cc4b57; }
.crm-market-queue time { color: #536586; font-size: 11px; font-weight: 690; }
.crm-market-queue article > div { display: grid; gap: 3px; min-width: 0; }
.crm-market-queue strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-market-queue span,
.crm-market-queue small { color: #7a8598; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-market-queue article.overdue small { color: #b33e4a; font-weight: 650; }

.crm-source-list { display: grid; gap: 12px; }
.crm-source-list > div { align-items: center; display: grid; gap: 9px; grid-template-columns: 78px minmax(0, 1fr) 30px; }
.crm-source-list span,
.crm-source-list b { color: #606d84; font-size: 11px; }
.crm-source-list b { text-align: right; }
.crm-source-list i { background: #edf0f5; border-radius: 99px; height: 7px; overflow: hidden; position: relative; }
.crm-source-list i::after { background: linear-gradient(90deg, #6d87db, #4e68c6); border-radius: inherit; content: ""; inset: 0 auto 0 0; position: absolute; width: var(--ratio); }

.crm-recent-list { display: grid; }
.crm-recent-list article { align-items: center; border-top: 1px solid #e9edf3; display: flex; gap: 10px; justify-content: space-between; padding: 11px 0; }
.crm-recent-list article:first-child { border-top: 0; }
.crm-recent-list article > div { display: grid; gap: 3px; min-width: 0; }
.crm-recent-list strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-recent-list span { color: #7e899b; font-size: 10px; }

.crm-ws-method {
    align-items: flex-start;
    background: #f5f7fb;
    border-left: 3px solid #8194cf;
    border-radius: 0 10px 10px 0;
    display: flex;
    gap: 12px;
    padding: 12px 14px;
}

.crm-ws-method strong { color: #43516c; flex: 0 0 auto; font-size: 12px; }
.crm-ws-method p { color: #68748a; font-size: 12px; line-height: 1.6; margin: 0; }

.crm-ws-pagination {
    align-items: center;
    color: #717d91;
    display: flex;
    font-size: 11px;
    justify-content: space-between;
    margin-top: 14px;
}

.crm-ws-pagination > div { display: flex; gap: 7px; }

.crm-calendar-controls {
    align-items: center;
    background: #fff;
    border: 1px solid var(--ws-line);
    border-radius: 15px;
    display: flex;
    justify-content: space-between;
    padding: 13px 15px;
}

.crm-calendar-controls > div { align-items: center; display: flex; gap: 9px; }
.crm-calendar-controls > div button { background: #fff; border: 1px solid #d7deea; border-radius: 8px; color: #52617c; cursor: pointer; font: inherit; height: 34px; min-width: 34px; }
.crm-calendar-controls strong { font-size: 14px; min-width: 115px; text-align: center; }

.crm-calendar-agenda { padding: 18px; }
.crm-calendar-agenda > article {
    align-items: center;
    border-top: 1px solid #e8ecf2;
    display: grid;
    gap: 13px;
    grid-template-columns: 110px 8px minmax(0, 1fr) auto;
    padding: 14px 4px;
}

.crm-calendar-agenda > article:nth-child(2) { border-top: 0; }
.crm-calendar-agenda time { display: grid; gap: 3px; }
.crm-calendar-agenda time strong { font-size: 11px; }
.crm-calendar-agenda time span { color: #8893a5; font-size: 10px; }
.crm-calendar-agenda article > i { background: #8897b4; border-radius: 999px; height: 8px; width: 8px; }
.crm-calendar-agenda article > i.calendar { background: #3159d5; }
.crm-calendar-agenda article > i.activity { background: #2f9170; }
.crm-calendar-agenda article > i.leadFollow { background: #ca7b2c; }
.crm-calendar-agenda article > i.opportunityAction { background: #7d5ac9; }
.crm-calendar-agenda article > i.opportunityClose { background: #c44b59; }
.crm-calendar-agenda article > div { display: grid; gap: 3px; min-width: 0; }
.crm-calendar-agenda article > div strong,
.crm-calendar-agenda article > div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-calendar-agenda article > div strong { font-size: 13px; }
.crm-calendar-agenda article > div span,
.crm-calendar-agenda article > div small { color: #778397; font-size: 11px; }

.crm-relation-layout {
    align-items: start;
    display: grid;
    gap: 15px;
    grid-template-columns: 300px minmax(0, 1fr);
}

.crm-account-picker { padding: 14px; }
.crm-account-picker form { display: flex; gap: 7px; margin-bottom: 12px; }
.crm-account-picker form label { min-width: 0; }
.crm-account-picker form button { align-self: end; }
.crm-account-picker > div { display: grid; gap: 6px; }
.crm-account-picker > div > button {
    background: #fff;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    display: grid;
    gap: 4px;
    padding: 12px;
    text-align: left;
}

.crm-account-picker > div > button:hover { background: #f7f9fd; }
.crm-account-picker > div > button.active { background: var(--ws-blue-soft); border-color: #ccd8f6; color: #2c4597; }
.crm-account-picker > div strong { font-size: 13px; }
.crm-account-picker > div span { color: #7a8699; font-size: 10px; }

.crm-relation-content { padding: 20px; }
.crm-relation-content > header { border-bottom: 1px solid #e7ebf2; padding-bottom: 16px; }
.crm-relation-content > header h3 { font-size: 22px; }
.crm-relation-content > header p { color: #718096; font-size: 12px; margin: 5px 0 0; }

.crm-relation-map {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
    padding-top: 4px;
}

.crm-relation-center {
    align-items: center;
    background: linear-gradient(135deg, #3159d5, #5275dc);
    border-radius: 14px;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 5px;
    grid-column: 1 / -1;
    justify-content: center;
    min-height: 112px;
    padding: 20px;
    text-align: center;
}

.crm-relation-center > span,
.crm-relation-center > small { font-size: 11px; opacity: .8; }
.crm-relation-center > strong { font-size: 21px; }

.crm-relation-group {
    background: #f7f8fb;
    border: 1px solid #e2e7ef;
    border-radius: 13px;
    min-height: 190px;
    padding: 11px;
}

.crm-relation-group > header { align-items: center; display: flex; justify-content: space-between; margin-bottom: 9px; }
.crm-relation-group > header strong { font-size: 12px; }
.crm-relation-group > header span { background: #e9edf4; border-radius: 99px; color: #667188; font-size: 10px; padding: 3px 6px; }
.crm-relation-group > button {
    background: #fff;
    border: 1px solid #e0e5ee;
    border-radius: 9px;
    cursor: pointer;
    display: grid;
    gap: 4px;
    margin-top: 7px;
    padding: 10px;
    text-align: left;
    width: 100%;
}

.crm-relation-group > button em { color: #4764bd; font-size: 9px; font-style: normal; font-weight: 700; }
.crm-relation-group > button strong { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-relation-group > button span,
.crm-relation-group > p { color: #7d889b; font-size: 9px; line-height: 1.45; margin: 0; }

.crm-ws-loading,
.crm-ws-error,
.crm-ws-empty {
    align-items: center;
    background: #fff;
    border: 1px dashed #ced7e6;
    border-radius: 15px;
    color: #68748a;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    min-height: 210px;
    padding: 26px;
    text-align: center;
}

.crm-ws-empty { min-height: 150px; }
.crm-ws-empty > span,
.crm-ws-error > b { color: #7182b3; font-size: 28px; }
.crm-ws-empty p,
.crm-ws-error p { line-height: 1.6; margin: 0; }
.crm-ws-loading { flex-direction: row; }
.crm-ws-loading i { animation: crmWsPulse 1.2s infinite ease-in-out; background: #6881d6; border-radius: 99px; height: 8px; width: 8px; }
.crm-ws-loading i:nth-child(2) { animation-delay: .15s; }
.crm-ws-loading i:nth-child(3) { animation-delay: .3s; }

.crm-ws-modal-mask {
    align-items: center;
    background: rgba(21, 29, 45, .58);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    z-index: 1500;
}

.crm-ws-modal {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 28px 70px rgba(16, 25, 45, .3);
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    max-height: min(760px, calc(100vh - 48px));
    max-width: 780px;
    overflow: hidden;
    position: relative;
    width: min(780px, 100%);
}

.crm-ws-modal > header { border-bottom: 1px solid #e5e9f0; padding: 24px 60px 20px 24px; }
.crm-ws-modal > header h2 { color: #1c2639; font-size: 24px; margin: 0; }
.crm-ws-modal > header p { color: #758196; font-size: 12px; margin: 7px 0 0; }
.crm-ws-modal-x { align-items: center; background: #fff; border: 1px solid #d7deeb; border-radius: 999px; color: #53627d; cursor: pointer; display: flex; font-size: 22px; height: 38px; justify-content: center; line-height: 1; position: absolute; right: 18px; top: 18px; width: 38px; }

.crm-ws-modal > nav { border-bottom: 1px solid #e5e9f0; display: flex; gap: 4px; overflow-x: auto; padding: 0 20px; }
.crm-ws-modal > nav button { background: transparent; border: 0; border-bottom: 2px solid transparent; color: #68748a; cursor: pointer; font: inherit; font-size: 13px; font-weight: 650; padding: 14px 13px 12px; white-space: nowrap; }
.crm-ws-modal > nav button[aria-selected="true"] { border-bottom-color: #3159d5; color: #2d4ca9; }
.crm-ws-modal-body { overflow: auto; padding: 22px 24px; }
.crm-ws-modal > footer,
.crm-ws-form-modal form > footer { align-items: center; background: #fafbfc; border-top: 1px solid #e5e9f0; display: flex; justify-content: space-between; padding: 14px 20px; }
.crm-ws-modal > footer > span { color: #8590a2; font-size: 11px; }

.crm-ws-facts { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.crm-ws-facts > div { background: #f7f8fb; border-radius: 10px; display: grid; gap: 5px; min-height: 68px; padding: 12px; }
.crm-ws-facts dt { color: #7c8799; font-size: 10px; }
.crm-ws-facts dd { color: #2d394e; font-size: 13px; line-height: 1.55; margin: 0; overflow-wrap: anywhere; }
.crm-ws-longtext { background: #f7f8fb; border-radius: 10px; color: #40506a; font-size: 13px; line-height: 1.7; padding: 15px; white-space: pre-wrap; }

.crm-ws-form-modal { grid-template-rows: auto minmax(0, 1fr); }
.crm-ws-form-modal form { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; min-height: 0; overflow: auto; }
.crm-ws-form-grid { display: grid; gap: 15px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 22px 24px; }
.crm-ws-form-grid label { display: grid; gap: 6px; }
.crm-ws-form-grid label.wide { grid-column: 1 / -1; }
.crm-ws-form-grid label > span b { color: #d04452; font-size: 10px; }
.crm-ws-form-grid label > small { color: #c03846; font-size: 10px; min-height: 14px; }
.crm-ws-form-grid label.invalid input,
.crm-ws-form-grid label.invalid select,
.crm-ws-form-grid label.invalid textarea { border-color: #d84c59; box-shadow: 0 0 0 3px rgba(216, 76, 89, .09); }
.crm-calendar-confirm { align-items: start; background: #f7f9fd; border: 1px solid #e0e6f0; border-radius: 10px; grid-template-columns: auto 1fr; padding: 12px; }
.crm-calendar-confirm input { height: 18px; margin-top: 1px; width: 18px; }
.crm-calendar-confirm small { grid-column: 2; }
.crm-ws-form-error { color: #bd3442; font-size: 12px; min-height: 18px; padding: 0 24px 10px; }

@keyframes crmWsPulse {
    0%, 80%, 100% { opacity: .35; transform: scale(.75); }
    40% { opacity: 1; transform: scale(1); }
}

@media (max-width: 1160px) {
    .crm-ws-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .crm-market-grid { grid-template-columns: 1fr; }
    .crm-market-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .crm-relation-map { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
    .crm-relation-layout { grid-template-columns: 1fr; }
    .crm-account-picker > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .crm-workspace { gap: 14px; }
    .crm-ws-hero { display: grid; gap: 15px; min-height: 0; padding: 21px; }
    .crm-ws-hero > aside { justify-content: flex-start; }
    .crm-ws-kpis { grid-template-columns: 1fr; }
    .crm-ws-toolbar { align-items: stretch; display: grid; }
    .crm-ws-toolbar label { min-width: 0; }
    .crm-ws-toolbar button { width: 100%; }
    .crm-market-side { grid-template-columns: 1fr; }
    .crm-market-queue article { align-items: start; grid-template-columns: 1fr auto; }
    .crm-market-queue time { grid-column: 1 / -1; }
    .crm-calendar-controls { align-items: stretch; display: grid; gap: 12px; }
    .crm-calendar-controls > div { justify-content: center; }
    .crm-calendar-agenda > article { align-items: start; grid-template-columns: 85px 8px minmax(0, 1fr); }
    .crm-calendar-agenda > article > button { grid-column: 3; justify-self: start; }
    .crm-relation-map { grid-template-columns: 1fr; }
    .crm-account-picker > div { grid-template-columns: 1fr; }
    .crm-ws-method { display: grid; }
    .crm-ws-pagination { align-items: stretch; display: grid; gap: 9px; }
    .crm-ws-pagination > div { display: grid; grid-template-columns: 1fr 1fr; }
    .crm-ws-modal-mask { align-items: flex-end; padding: 0; }
    .crm-ws-modal { border-radius: 18px 18px 0 0; max-height: 92vh; max-width: none; width: 100%; }
    .crm-ws-facts,
    .crm-ws-form-grid { grid-template-columns: 1fr; }
    .crm-ws-form-grid label.wide { grid-column: 1; }
    .crm-ws-modal > footer { align-items: stretch; display: grid; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .crm-ws-loading i { animation: none; }
}
