/* ---- V1.44 (Sunday build Theme 9): the CRM (crm-, Client\Apps\Crm), Marketing's LinkedIn drafts (li-) and the marketing
   dashboard (md-, Client\Apps\Marketing). The theme's tokens only (--panel, --border, --accent...), so light and dark both work.
   The stages: one colour each, mixed into the panel so that dark mode keeps its contrast. ---- */

.crm-toolbar { align-items: center; gap: 8px; margin-bottom: 8px; }
.crm-search { flex: 1 1 260px; max-width: 420px; }
.crm-check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.crm-problem { color: var(--warn); }
.crm-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.crm-switch button, .crm-kinds button { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border: 0; background: var(--field);
    color: var(--text); font: inherit; font-size: 0.85rem; cursor: pointer; }
.crm-switch button + button { border-left: 1px solid var(--border); }
.crm-switch button.on, .crm-kinds button.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.crm-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.crm-kinds button { border: 1px solid var(--border); border-radius: 999px; }

/* The stages */
.crm-stage-lead { --stage: var(--info); }
.crm-stage-qualified { --stage: var(--accent); }
.crm-stage-proposal { --stage: var(--gold-text); }
.crm-stage-won { --stage: var(--good-text); }
.crm-stage-lost { --stage: var(--muted); }
.crm-stage { display: inline-block; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--stage) 14%, var(--panel));
    color: var(--stage); font-size: 0.78rem; font-weight: 800; white-space: nowrap; }

/* The board */
.crm-board { flex-shrink: 0; display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.crm-column { display: flex; flex-direction: column; gap: 8px; min-height: 160px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius);
    border-top: 3px solid var(--stage); background: var(--head-bg); }
.crm-column.crm-drop { outline: 2px dashed var(--stage); outline-offset: -4px; }
.crm-column-head { display: flex; align-items: baseline; gap: 6px; padding: 2px 4px; }
.crm-column-name { font-weight: 900; color: var(--stage); }
.crm-count { padding: 0 6px; border-radius: 999px; background: var(--chip); color: var(--chip-text); font-size: 0.75rem; font-weight: 700; }
.crm-sum { margin-left: auto; color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.crm-card { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); cursor: pointer; }
.crm-card:hover, .crm-card:focus-visible { border-color: var(--accent); }
.crm-card[draggable="true"] { cursor: grab; }
.crm-card-title { font-weight: 800; overflow-wrap: anywhere; }
.crm-card-sub { color: var(--muted); font-size: 0.82rem; }
.crm-card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.crm-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.crm-card-last { margin-top: 4px; color: var(--muted); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-empty { padding: 12px; color: var(--faint); font-size: 0.82rem; text-align: center; }
.crm-chip { display: inline-flex; align-items: center; gap: 3px; padding: 0 7px; border-radius: 999px; background: var(--chip); color: var(--chip-text);
    font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.crm-chip-po { background: var(--good-soft); color: var(--good-text); }

/* The tables (the list, the contacts, the companies, the codes, the dashboard) */
.crm-table-wrap { flex-shrink: 0; overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.crm-table th { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 0.76rem; font-weight: 800; text-align: left;
    text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.crm-table td { padding: 7px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.crm-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.crm-row { cursor: pointer; }
.crm-row:hover td { background: var(--accent-soft); }
.crm-archived td, li.crm-archived { opacity: 0.6; }
.crm-sort { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-transform: inherit; cursor: pointer; }

/* The forms */
.crm-form { margin-bottom: 10px; }
.crm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 8px; }
.crm-field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.8rem; font-weight: 800; }
.crm-field .pdm-input { color: var(--text); }
.crm-wide { grid-column: 1 / -1; }
.crm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.crm-linkbutton { padding: 0; border: 0; background: none; color: var(--accent-strong); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.crm-linkbutton:disabled { opacity: 0.5; cursor: default; }
.crm-link { color: var(--accent-strong); font-weight: 700; }

/* A deal, a contact, a company */
.crm-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.crm-head h2 { margin: 2px 0 4px; font-size: 1.35rem; font-weight: 900; }
.crm-head-sub { color: var(--muted); font-size: 0.9rem; }
.crm-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crm-eyebrow { color: var(--muted); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.3px; text-transform: uppercase; }
.crm-notes { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.crm-stages { margin-bottom: 10px; }
.crm-stagebar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 0 0 10px; padding: 0; list-style: none; }
.crm-stagebar li { padding: 6px 4px; border-radius: 6px; background: var(--chip); color: var(--muted); font-size: 0.82rem; font-weight: 700; text-align: center; }
.crm-stagebar li.passed { background: color-mix(in srgb, var(--stage) 12%, var(--panel)); color: var(--stage); }
.crm-stagebar li.current { background: var(--stage); color: var(--on-accent); }
.crm-stage-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.crm-stage-line .spacer { flex: 1; }
.crm-lost { color: var(--muted); font-style: italic; }
.crm-lose { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.crm-lose .pdm-input { flex: 1 1 280px; }
.crm-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; margin-bottom: 10px; }
.crm-links { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.crm-links li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--rule); }
.crm-picker { margin-bottom: 10px; padding: 8px 10px; border: 1px dashed var(--border); border-radius: 8px; background: var(--head-bg); }
.crm-picker .pdm-input { width: 100%; }
.crm-picker ul { display: grid; gap: 4px; margin: 8px 0; padding: 0; list-style: none; font-size: 0.86rem; }
.crm-code { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.crm-code-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.crm-code-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; color: var(--muted); font-size: 0.84rem; }
.crm-code-facts b { color: var(--text); font-variant-numeric: tabular-nums; }
.crm-code-apps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* The activities */
.crm-timeline { margin-bottom: 10px; }
.crm-activity-form { margin-bottom: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--head-bg); }
.crm-activities { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.crm-activity { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.crm-activity-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
    background: var(--chip); color: var(--chip-text); }
.crm-kind-visit .crm-activity-icon, .crm-kind-return .crm-activity-icon { background: var(--info-soft); color: var(--info); }
.crm-kind-quote .crm-activity-icon { background: var(--gold-soft); color: var(--gold-text); }
.crm-kind-po .crm-activity-icon { background: var(--good-soft); color: var(--good-text); }
.crm-kind-stage .crm-activity-icon { background: var(--accent-soft); color: var(--accent-strong); }
.crm-activity-main { min-width: 0; flex: 1; }
.crm-activity-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.crm-activity-body { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* The panels in other apps: the visit page of a prospect code, the quote builder */
.crm-of-code { margin-bottom: 10px; }
.crm-quote-deal { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: 0.88rem; }
.crm-quote-deal .pdm-input { min-width: 220px; }

/* LinkedIn drafts */
.li-draft { margin-bottom: 10px; border-left: 3px solid var(--border); }
.li-draft.li-approved { border-left-color: var(--good); }
.li-draft.li-posted { border-left-color: var(--accent); }
.li-draft.li-discarded { opacity: 0.7; }
.li-status { margin-right: 6px; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--chip-text); font-size: 0.75rem; }
.li-approved .li-status { background: var(--good-soft); color: var(--good-text); }
.li-posted .li-status { background: var(--accent-soft); color: var(--accent-strong); }
.li-texts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.li-texts textarea { width: 100%; resize: vertical; line-height: 1.4; }
.li-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 8px; }
.li-bar .spacer { flex: 1; }
.li-language { flex: 0 1 230px; }
.li-length { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.li-too-long { color: var(--bad); font-weight: 800; }
.li-steps { margin: 8px 0 0; padding-left: 20px; font-size: 0.88rem; }
.li-steps li { margin-bottom: 4px; }

/* The marketing dashboard: one bar per week in each column (one measure, one colour: --accent), the value beside it */
.md-kpis { margin-bottom: 10px; }
.md-table td.num { min-width: 92px; }
.md-cell { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; width: 100%; }
.md-track { display: inline-block; flex: none; width: 56px; height: 8px; }
.md-bar { display: block; height: 8px; border-radius: 0 4px 4px 0; background: var(--accent); }
.md-value { min-width: 26px; text-align: right; }
.md-note { max-width: 240px; color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.md-edit td { background: var(--head-bg); }
.md-upload { position: relative; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.md-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.md-sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; margin-top: 10px; }
.md-source h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.md-source ol { margin: 6px 0 0; padding-left: 20px; font-size: 0.86rem; }
.md-source ol li { margin-bottom: 4px; }
.md-connected h3 { color: var(--good-text); }
.md-not h3 { color: var(--warn); }

@media (max-width: 760px) {
    .crm-board { grid-template-columns: repeat(5, minmax(180px, 80vw)); }
    .crm-stagebar li { font-size: 0.72rem; }
}

/* ---- V1.44: CRM > Client health (health-, Client\Apps\Crm\CrmHealthPage.razor): the status dots, the reasons under the client's
   name, the sortable titles; on a phone each row is a card (the cell's title from its data-label) ---- */
.health-toolbar { flex-wrap: wrap; }
.health-counts { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-variant-numeric: tabular-nums; }
.health-counts .health-dot:not(:first-child) { margin-left: 8px; }
.health-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 8px; }
.health-legend .health-dot { margin-right: -10px; }
.health-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--good); }
.health-dot.red { background: var(--bad); }
.health-dot.amber { background: var(--warn); }
.health-sort { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.health-table th.num .health-sort { text-align: right; }
.health-row.red td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.health-row.amber td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
.health-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.health-status { color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.health-reasons { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0 0; padding: 0; list-style: none; }
.health-reasons li { padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.health-reasons li.red { background: var(--bad-soft); color: var(--bad); }
.health-reasons li.amber { background: var(--warn-soft); color: var(--warn); }
.health-table td.num a { font-weight: 700; }

@media (max-width: 760px) {
    .health-wrap { overflow-x: visible; }
    .health-table thead { display: none; }
    .health-table, .health-table tbody, .health-table tr, .health-table td { display: block; width: 100%; }
    .health-table tr { margin: 0 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
    .health-table td { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; border-bottom: 1px solid var(--rule); }
    .health-table td.num { text-align: right; }
    .health-table td::before { content: attr(data-label); color: var(--muted); font-size: 0.74rem; font-weight: 800; text-transform: uppercase; }
    .health-table td.health-client { display: block; }
    .health-table td.health-client::before { content: none; }
    .health-table td .hint { flex-basis: 100%; text-align: right; }
    .health-table td:last-child { border-bottom: 0; }
}

/* Bookings (V1.62, CRM > Bookings: Client\Apps\Crm\CrmBooking*.razor): full page width, the design system's tokens (--os-*,
   weights 400-600 only: Docs\Design system\Design system.md) */
.bk-toolbar .crm-switch button .crm-count { margin-left: 4px; }
.bk-open, .bk-closed { padding: 2px 10px; border-radius: var(--os-radius-pill); font-size: 0.8rem; font-weight: 600; }
.bk-open { background: var(--os-good-soft); color: var(--os-good-text); }
.bk-closed { background: var(--os-warn-soft); color: var(--os-warn-text); }
.bk-table td.bk-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bk-status { display: inline-block; padding: 1px 8px; border-radius: var(--os-radius-pill); background: var(--os-neutral-soft); color: var(--os-neutral-text); font-size: 0.78rem; font-weight: 600; }
.bk-confirmed { background: var(--os-good-soft); color: var(--os-good-text); }
.bk-requested { background: var(--os-warn-soft); color: var(--os-warn-text); }
.bk-declined, .bk-noshow { background: var(--os-bad-soft); color: var(--os-bad-text); }
.bk-cancelled { color: var(--os-text-2); }
.bk-completed { background: var(--os-accent-soft); color: var(--os-accent-text); }
.bk-status-big { padding: 3px 12px; font-size: 0.85rem; }
.bk-summary { margin-top: 6px; }
.bk-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr); gap: 10px; margin-bottom: 10px; }
.bk-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.bk-dl dt { color: var(--os-text-2); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; padding-top: 2px; }
.bk-dl dd { margin: 0; overflow-wrap: anywhere; }
.bk-h { margin: 0 0 8px; font-size: 0.95rem; font-weight: 600; }
.bk-h4 { margin: 0 0 4px; font-size: 0.86rem; font-weight: 600; }
.bk-action { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--os-border-subtle); }
.bk-action:last-of-type { border-bottom: 0; }
.bk-action .crm-field { flex: 1 1 200px; }
.bk-action .hint, .bk-action p { flex-basis: 100%; margin: 0; }
.bk-match { color: var(--os-info-text); }
.bk-events { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; font-size: 0.86rem; }
.bk-events li { padding: 4px 0; border-bottom: 1px solid var(--os-border-subtle); }
.bk-event-when { display: inline-block; min-width: 9.5em; color: var(--os-text-2); font-variant-numeric: tabular-nums; }
.bk-section { margin-bottom: 10px; }
.bk-week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 8px; margin: 8px 0 12px; overflow-x: auto; }
.bk-day { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--os-border); border-radius: var(--os-radius-md); background: var(--os-surface-sunken); }
.bk-range { display: flex; align-items: center; gap: 4px; }
.bk-range .pdm-input { min-width: 0; flex: 1; }
.bk-type { padding: 6px 0; border-bottom: 1px solid var(--os-border-subtle); }
.bk-type summary { cursor: pointer; }
.bk-preview { display: grid; gap: 4px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.bk-ok { color: var(--os-good-text); }
.bk-save { justify-content: flex-end; position: sticky; bottom: 0; padding: 8px 0; background: var(--os-canvas); }

@media (max-width: 900px) {
    .bk-grid { grid-template-columns: 1fr; }
}
.btn.bk-danger { border-color: var(--os-bad); background: var(--os-bad-soft); color: var(--os-bad-text); }
