/* CRM : barre d'outils, tableaux, cartes, pipeline, fiches. Référence : docs/maquette/CRM.dc.html. */

.crm-browser {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.crm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.search-field {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 280px;
    max-width: 420px;
}

.search-field__icon {
    position: absolute;
    left: 14px;
    color: var(--muted);
}

.search-field .input {
    padding-left: 42px;
}

.crm-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity .15s ease;
}

.crm-panel.is-loading {
    opacity: .6;
}

/* Textes utilitaires */
.muted { color: var(--muted); font-size: var(--text-sm); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; min-width: 0; }

.with-icon {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Tableaux */
.data-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: var(--text-md);
}

.data-table th {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
}

.data-table td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--hover);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background .15s ease;
}

.data-table tbody tr:hover {
    background: var(--surface-soft);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table a {
    color: inherit;
    text-decoration: none;
}

.data-table a:hover .person__name,
.data-table td > a:hover {
    color: var(--teal);
    text-decoration: underline;
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .cell-action {
    text-align: right;
}

.data-table .is-done td {
    color: var(--muted);
}

.data-table .is-done .strong {
    text-decoration: line-through;
}

.table-note {
    padding: 12px 18px;
    border-top: 1px solid var(--line-soft);
    color: var(--muted);
    font-size: var(--text-sm);
}

.score {
    font-weight: 800;
    color: var(--navy);
}

/* Personnes */
.person {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.person__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.person__name {
    font-weight: 600;
    color: var(--ink);
}

.initials {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--radius-pill);
    background: var(--mint);
    color: var(--teal-dark);
    font-size: var(--text-sm);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.initials--lg {
    width: 56px;
    height: 56px;
    background: var(--navy);
    color: var(--aqua);
    font-size: 18px;
    font-weight: 800;
}

.sector-icon {
    flex-shrink: 0;
}

/* Étapes (couleurs de la maquette) */
.stage--prospect_identifie { background: var(--blue); color: var(--muted-strong); }
.stage--premier_echange { background: var(--mint); color: var(--teal-dark); }
.stage--etude_reus { background: var(--amber-bg); color: var(--amber-ink); }
.stage--experimentation { background: #e8eefb; color: #2a4b94; }
.stage--proposition_commerciale { background: #f2eafa; color: #5f347f; }
.stage--vente_conclue { background: var(--green-bg); color: #1a6a4c; }
.stage--perdue { background: var(--red-bg); color: var(--red-ink); }

.stage-accent--prospect_identifie { --accent: #9fc7cc; }
.stage-accent--premier_echange { --accent: var(--aqua); }
.stage-accent--etude_reus { --accent: var(--amber); }
.stage-accent--experimentation { --accent: #5b7fd6; }
.stage-accent--proposition_commerciale { --accent: #9a6cc0; }
.stage-accent--vente_conclue { --accent: var(--green); }

.priority--basse { background: var(--blue); color: var(--muted-strong); }
.priority--normale { background: var(--mint); color: var(--teal-dark); }
.priority--haute { background: var(--amber-bg); color: var(--amber-ink); }
.priority--urgente { background: var(--red-bg); color: var(--red-ink); }

/* Entreprises */
.company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.company-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    color: var(--ink);
    text-decoration: none;
    transition: transform .2s var(--ease-out), box-shadow .2s ease, border-color .2s ease;
}

.company-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--elev);
    border-color: #9fd9d1;
    color: var(--ink);
}

.company-card__head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.company-card__icon,
.record__icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
}

.record__icon {
    width: 56px;
    height: 56px;
}

.company-card__name {
    font-weight: 700;
    color: var(--navy);
}

.company-card__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--hover);
}

.company-card__foot .muted {
    margin-right: auto;
}

/* Bascule colonnes / liste */
.segmented {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    width: fit-content;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

button.segmented__option {
    border: 0;
    background: transparent;
}

.segmented__option[aria-pressed='true'] {
    background: var(--navy);
    color: var(--white);
}

.segmented__option {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--muted-strong);
    cursor: pointer;
}

.segmented__option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented__option:has(input:checked) {
    background: var(--navy);
    color: var(--white);
}

.segmented__option:has(input:focus-visible) {
    outline: 3px solid rgba(41, 203, 183, .45);
}

/* Pipeline */
.board {
    display: grid;
    grid-template-columns: repeat(6, minmax(200px, 1fr));
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.board__column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 320px;
    padding: 12px;
    border-radius: var(--radius-lg);
    background: #e8f0f1;
}

.board__head {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
    padding: 8px 4px 6px;
    border-top: 4px solid var(--accent, var(--line));
    border-radius: 4px;
}

.board__title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--navy);
}

.board__count {
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--white);
    color: var(--muted-strong);
    font-size: var(--text-xs);
    font-weight: 700;
}

.board__total {
    grid-column: 1 / -1;
    font-size: var(--text-xs);
}

.deal-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    color: var(--ink);
    text-decoration: none;
    font-size: var(--text-md);
    transition: transform .2s var(--ease-out), box-shadow .2s ease, border-color .2s ease;
}

.deal-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--elev);
    border-color: #9fd9d1;
    color: var(--ink);
}

.deal-card__title {
    font-weight: 600;
    line-height: 1.3;
}

.deal-card__foot {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 6px;
    border-top: 1px solid var(--hover);
}

/* Fiches */
.record {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.record__head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.record__title {
    font-size: 20px;
    font-weight: 800;
}

.record__section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.record__section > a {
    min-height: 32px;
    text-decoration: none;
}

.record__label {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.record__highlight {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--mint);
    color: var(--navy);
    text-decoration: none;
}

.record__highlight .record__label {
    color: var(--teal-dark);
}

.record__amount {
    font-size: 18px;
    font-weight: 800;
    color: var(--teal);
}

.record__row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--hover);
    color: inherit;
    font-size: var(--text-md);
}

.record-page {
    max-width: 720px;
}

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px 16px;
    margin: 0;
}

.facts dt {
    color: var(--muted);
    font-size: var(--text-sm);
}

.facts dd {
    margin: 0;
    font-weight: 600;
}

.progress-steps {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
}

.progress-steps__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
    font-size: var(--text-md);
    color: var(--muted);
}

.progress-steps__item::before {
    content: '';
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border-radius: var(--radius-pill);
    background: var(--line);
}

.progress-steps__item.is-done {
    color: var(--ink);
}

.progress-steps__item.is-done::before {
    background: var(--teal);
}

.progress-steps__item.is-current {
    color: var(--navy);
    font-weight: 700;
}

.progress-steps__item.is-current::before {
    background: var(--aqua);
    box-shadow: 0 0 0 4px rgba(41, 203, 183, .25);
}

.timeline {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.timeline__item {
    display: flex;
    flex-direction: column;
    padding-left: 14px;
    border-left: 2px solid var(--line);
    font-size: var(--text-md);
}

@media (max-width: 760px) {
    .board {
        grid-template-columns: repeat(6, minmax(220px, 80vw));
    }
}

/* Saisie : pipeline glisser-déposer, tâches à cocher */
.deal-card[draggable='true'] {
    cursor: grab;
}

.deal-card__link {
    color: inherit;
    text-decoration: none;
}

.deal-card__link:hover .deal-card__title {
    color: var(--teal);
    text-decoration: underline;
}

.deal-card.is-dragging {
    opacity: .5;
}

.board__column.is-drop-target {
    outline: 2px dashed var(--aqua);
    outline-offset: -4px;
}

.board[aria-busy='true'] {
    opacity: .7;
}

.input--sm {
    height: 34px;
    padding: 0 10px;
    font-size: var(--text-sm);
}

.cell-check {
    width: 44px;
}

.checkbox-input {
    width: 20px;
    height: 20px;
    accent-color: var(--teal);
    cursor: pointer;
}

.record__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.record__row.is-done .strong {
    text-decoration: line-through;
    color: var(--muted);
}

.interaction-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    border: 1px solid var(--line-soft);
}

.interaction-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
