:root {
  --app-bg: #f4f5f8;
  --app-surface: #ffffff;
  --app-border: #e4e6ec;
  --app-accent: #3b5bdb;
  --app-accent-soft: #edf1ff;
  --app-avatar-glow: 0 0 0 1px rgba(20, 30, 60, .06), 0 1px 6px rgba(20, 30, 60, .22);
  --app-private: #fff6e0;
  --app-private-border: #f0c75e;
  --app-muted: #6b7280;
  --fc-total: #c5d0fa;
  --bs-primary: #3b5bdb;
  --bs-primary-rgb: 59, 91, 219;
  --bs-link-color: #3b5bdb;
  --bs-link-color-rgb: 59, 91, 219;
}

body { background: var(--app-bg); font-size: .925rem; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn-primary { --bs-btn-bg: var(--app-accent); --bs-btn-border-color: var(--app-accent); --bs-btn-hover-bg: #324fc4; --bs-btn-hover-border-color: #324fc4; }

/* ---- navbar ---- */
.app-nav { background: #1f2433; }
.app-nav .navbar-brand, .app-nav .nav-link, .app-nav .nav-icon { color: #d6dae6; }
.app-nav .nav-link:hover, .app-nav .nav-link.active { color: #fff; }
.app-nav .nav-link.active { box-shadow: inset 0 -2px 0 #8aa2ff; }
.app-nav .navbar-toggler { border-color: #4b5268; }
/* The bar is dark in both themes: a light icon always (no invert, which turned it black in the dark theme). */
.app-nav .navbar-toggler-icon { --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23d6dae6' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e"); }
/* An admin browsing as an employee (security/impersonation): unmissable, above the menu on every page. */
.impersonation-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem .75rem;
  padding: .4rem 1rem; color: #1f2433; font-size: .875rem; text-align: center;
  background: repeating-linear-gradient(-45deg, #ffcd39 0 14px, #ffc107 14px 28px); }
.impersonation-bar form { margin: 0; }
.nav-icon { font-size: 1.2rem; text-decoration: none; }
.nav-badge { position: absolute; top: 0; right: -2px; font-size: .65rem; }
.nav-search { position: relative; min-width: 310px; }
.nav-search i { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: #9aa1b5; }
.nav-search input { padding-left: 1.9rem; background: #2c3245; border-color: #3a4157; color: #fff; }
.nav-search input::placeholder { color: #9aa1b5; }
.nav-search input:focus { background: #fff; color: #222; }

/* ---- surfaces ---- */
.card { border-color: var(--app-border); border-radius: .6rem; }
.card-header { background: transparent; border-bottom-color: var(--app-border); font-weight: 600; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.45rem; margin: 0; font-weight: 650; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.kicker { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--app-muted); }
.table > :not(caption) > * > * { padding: .55rem .65rem; }
/* To-do list sections (Aujourd'hui, 7 prochains jours…). */
.due-group-head > th { background: var(--bs-tertiary-bg) !important; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--app-muted); font-weight: 600; }
.due-group-overdue .due-group-head > th { color: var(--bs-danger); }
/* Client list: regroupement heading rows, their members indented */
.org-group > td { background: var(--bs-tertiary-bg) !important; font-weight: 600; padding-top: .45rem !important; padding-bottom: .45rem !important; }
.org-group a { color: var(--bs-body-color); }
.org-member > td:first-child { padding-left: 1.75rem !important; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--app-muted); font-weight: 600; }
/* Sortable header (macro sort_th): the whole label is the link, the active column darker with its caret. */
.sort-th { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-th:hover, .sort-th.is-on { color: var(--bs-body-color); }
.sort-th .bi { font-size: .65rem; }
.list-group-item { border-color: var(--app-border); }
.dl-grid { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl-grid dt { color: var(--app-muted); font-weight: 500; }
.dl-grid dd { margin: 0; }
/* Communications list: the « Relié à » column keeps room for a client's or contact's name on one or two lines. */
.col-links { min-width: 14rem; }
/* Descriptions rendered from Markdown (|markdown): headings stay in proportion with the card. */
.md-text { overflow-wrap: anywhere; }
.md-text > :last-child { margin-bottom: 0; }
.md-text h1, .md-text h2, .md-text h3, .md-text h4, .md-text h5, .md-text h6 { font-weight: 600; margin: .9rem 0 .4rem; }
.md-text h1 { font-size: 1.2rem; } .md-text h2 { font-size: 1.1rem; } .md-text h3, .md-text h4, .md-text h5, .md-text h6 { font-size: 1rem; }
.md-text > :first-child { margin-top: 0; }
.md-text p, .md-text ul, .md-text ol, .md-text blockquote, .md-text pre, .md-text table { margin-bottom: .6rem; }
.md-text ul, .md-text ol { padding-left: 1.4rem; }
.md-text blockquote { padding-left: .8rem; border-left: 3px solid var(--app-border); color: var(--app-muted); }
.md-text code { font-size: .875em; padding: .05rem .3rem; border-radius: .25rem; background: var(--bs-tertiary-bg); color: var(--bs-body-color); }
.md-text pre { padding: .6rem .8rem; border-radius: .4rem; background: var(--bs-tertiary-bg); }
.md-text pre code { padding: 0; background: none; }
.md-text table { display: block; max-width: 100%; overflow-x: auto; }
.md-text .table thead th { font-size: inherit; text-transform: none; letter-spacing: normal; color: inherit; }
.md-text hr { margin: .8rem 0; }
/* A long description (data-fold, app.js) shows its first lines, faded; « Suite… » or a click on it shows it all. */
.md-text.folded { max-height: 7.5em; overflow: hidden; cursor: pointer;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent); mask-image: linear-gradient(to bottom, #000 60%, transparent); }
.md-fold-more { border: 0; background: none; padding: 0; margin-top: .25rem; font-size: .75rem; color: var(--app-muted); }
.md-fold-more:hover { color: var(--bs-body-color); }

/* ---- avatars & badges ---- */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--app-accent-soft); color: var(--app-accent); font-weight: 650; font-size: .75rem; border: 0; flex-shrink: 0; }
.avatar-sm { width: 32px; height: 32px; }
.avatar { box-shadow: var(--app-avatar-glow); }  /* a soft halo, photos and initials alike */
.avatar-lg { width: 56px; height: 56px; font-size: 1.3rem; }
.avatar.photo { padding: 0; overflow: hidden; background: transparent; }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-nav .avatar { background: #3a4157; color: #fff; }
.avatar.external { background: #fdecef; color: #c2255c; }
.owner { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.badge-status { font-weight: 600; }
.st-todo { background: #e7ecff; color: #3b5bdb; }
.st-in_progress { background: #fff3d6; color: #a15c00; }
.st-waiting { background: #f1e8ff; color: #6f42c1; }
.st-done { background: #e3f6e8; color: #2b8a3e; }
.st-cancelled { background: #eee; color: #777; }
.st-open { background: #e7ecff; color: #3b5bdb; }
.st-won { background: #e3f6e8; color: #2b8a3e; }
.st-lost { background: #fde8e8; color: #c92a2a; }
.st-stage { background: var(--c-opportunity-soft); color: var(--c-opportunity); }
.badge-stage { font-weight: 600; }
/* Techso project code (Intranet) on opportunities */
.project-code { font-family: var(--bs-font-monospace); font-size: .78em; font-weight: 600; letter-spacing: .02em;
  padding: .05rem .35rem; border-radius: .3rem; background: var(--bs-tertiary-bg); color: var(--bs-body-color); }
.kicker .project-code { text-transform: none; letter-spacing: .02em; }
.overdue { color: #c92a2a; font-weight: 600; }
.tag { background: #eef0f4; color: #374151; border-radius: 999px; padding: .15rem .55rem; font-size: .75rem; display: inline-flex; gap: .3rem; align-items: center; }
.tag form { display: inline; }
/* Contact list (contacts/_rows.html): name over « poste · organisation », quiet reach icons on the right. */
.contact-list td { padding-top: .55rem; padding-bottom: .55rem; }
.contact-reach { text-align: right; white-space: nowrap; width: 1%; }
.contact-reach a { display: inline-flex; padding: .3rem .4rem; border-radius: .4rem; color: var(--app-muted); text-decoration: none; }
.contact-reach a:hover { color: var(--app-accent); background: var(--app-accent-soft); }
.contact-clock { text-align: right; white-space: nowrap; width: 1%; }

/* World clock (_macros.local_clock): the time at a client or contact, 24 h; soft blue by day, night blue at night. */
.local-clock { --lc-bg: #e7ecff; --lc-fg: #3b5bdb; --lc-icon: #f5b301;
  display: inline-flex; align-items: center; gap: .35rem; padding: .12rem .5rem; border-radius: .4rem;
  background: var(--lc-bg); color: var(--lc-fg); font-size: .8rem; font-weight: 500; line-height: 1.5;
  font-variant-numeric: tabular-nums; white-space: nowrap; vertical-align: middle; cursor: default; }
.local-clock i { color: var(--lc-icon); font-size: .85em; }
.local-clock.is-night { --lc-bg: #2c3245; --lc-fg: #e3e7f3; --lc-icon: #c9d3f5; }
.local-clock.is-approx .lc-time::before { content: "≈"; margin-right: .1rem; opacity: .7; }
.local-clock .lc-gap { font-size: .7em; opacity: .75; margin-left: -.1rem; }
.local-clock-lg { font-size: .875rem; padding: .2rem .6rem; }
h1 .local-clock { font-size: .875rem; }
.contact-card-reach { display: flex; flex-direction: column; gap: .15rem; }
.contact-card-reach a { display: flex; align-items: center; gap: .4rem; min-width: 0; color: var(--bs-body-color); text-decoration: none; }
.contact-card-reach a i { color: var(--app-muted); }
.contact-card-reach a:hover { color: var(--app-accent); }
.contact-cards .card-body { padding: .9rem 1rem; }
/* Categories: a coloured dot and quiet text, not a filled badge (they sit next to names in every list). */
.cat { display: inline-flex; align-items: center; gap: .3rem; margin-left: .35rem; font-size: .75rem; font-weight: 500; color: var(--bs-secondary-color); white-space: nowrap; vertical-align: .05em; }
dd > .cat:first-child, div > .cat:first-child { margin-left: 0; }
.cat-dot { width: .45rem; height: .45rem; border-radius: 50%; flex: none; }
/* Category picker (macro category_picker): a ring when off, a filled dot on a faint tint when on. */
.cat-pick { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border: 1px solid var(--bs-border-color);
  border-radius: 999px; font-size: .8rem; color: var(--bs-secondary-color); cursor: pointer; user-select: none; }
.cat-pick .cat-dot { box-shadow: inset 0 0 0 1.5px var(--cat); }
.cat-pick:hover { border-color: color-mix(in srgb, var(--cat) 50%, var(--bs-border-color)); color: var(--bs-body-color); }
.btn-check:checked + .cat-pick { color: var(--bs-body-color); border-color: color-mix(in srgb, var(--cat) 55%, transparent);
  background: color-mix(in srgb, var(--cat) 10%, transparent); }
.btn-check:checked + .cat-pick .cat-dot { background: var(--cat); }
.btn-check:focus-visible + .cat-pick { box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--cat) 25%, transparent); }
.tag button { border: 0; background: none; padding: 0; color: #9aa1b5; line-height: 1; }

/* Source e-mail of an AI proposal (suggestions/_source.html) */
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .875rem; line-height: 1.5; max-height: 60vh; overflow: auto;
  padding: .75rem; border: 1px solid var(--app-border); border-radius: .4rem; background: var(--bs-tertiary-bg); }
.mail-body mark { padding: 0 .1rem; border-radius: .2rem; }
/* The AI's quote in the e-mail a to-do comes from (todos/detail.html, communications/detail.html?todo=…#citation) */
.comm-quote { font-size: .875rem; line-height: 1.5; overflow-wrap: anywhere; }
.comm-quote mark, .comm-body mark { padding: 0 .1rem; border-radius: .2rem; }
#citation { scroll-margin-top: 30vh; }
/* « N documents » in a detail page's head (attachments_jump) jumps to the attachments card, below the sticky header. */
.page-head .att-jump { white-space: nowrap; }
#attachments { scroll-margin-top: 5rem; }
#attachments:target { animation: att-flash 1.6s ease-out; }
@keyframes att-flash { from { box-shadow: 0 0 0 .25rem var(--bs-primary-border-subtle); } to { box-shadow: 0 0 0 .25rem transparent; } }
.comm-quote-fold > summary { list-style: none; cursor: pointer; display: flex; gap: .5rem; align-items: flex-start; }
.comm-quote-fold > summary::-webkit-details-marker { display: none; }
.comm-quote-fold > summary .bi-chevron-down { margin-left: auto; color: var(--app-muted); transition: transform .15s; }
.comm-quote-fold > summary:hover .bi-chevron-down { color: var(--bs-body-color); }
.comm-quote-fold[open] > summary .bi-chevron-down { transform: rotate(180deg); }
.comm-quote-fold[open] > summary .comm-quote-short { visibility: hidden; height: 0; flex: 1; }

/* ---- private notes: must be obvious ---- */
.note { border: 1px solid var(--app-border); border-radius: .5rem; padding: .65rem .8rem; background: var(--app-surface); }
.note.private { background: var(--app-private); border: 1px dashed var(--app-private-border); }
.note .private-flag { color: #a15c00; font-weight: 650; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
/* Privacy badge of a communication (its author only): a click shares it / makes it private again. */
.comm-privacy { border: 1px solid transparent; font-weight: 600; cursor: pointer; vertical-align: .1em; }
.comm-privacy.is-private { background: #fff3e0; color: #a15c00; border-color: #ffd8a8; }
.comm-privacy.is-shared { background: transparent; color: var(--bs-secondary-color); border-color: var(--bs-border-color); }
.comm-privacy:hover { filter: brightness(.95); }

/* ---- "Ici / Tout le dossier" (meta panel: notes, attachments) ---- */
.dossier-tabs { gap: .15rem; font-size: .75rem; }
.dossier-tabs .nav-link { padding: .1rem .5rem; border-radius: 999px; color: var(--app-muted); }
.dossier-tabs .nav-link.active { background: var(--bs-tertiary-bg); color: var(--bs-body-color); font-weight: 600; }
.dossier-tabs .nav-link span, .dossier-chip span { opacity: .65; }
.dossier-chip { border: 1px solid var(--bs-border-color); background: none; border-radius: 999px; padding: .05rem .55rem; font-size: .75rem; color: var(--app-muted); }
.dossier-chip.active { border-color: var(--app-accent); color: var(--bs-body-color); }
.dossier-list > li { padding: .35rem 0; border-bottom: 1px solid var(--bs-border-color-translucent); }
.dossier-list > li:last-child { border-bottom: 0; }
.dossier-src { font-size: .75rem; color: var(--app-muted); padding-left: 1.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dossier-src a { color: inherit; }
.note .dossier-src { padding-left: 0; }
.dossier-via { border: 1px dashed var(--bs-border-color); border-radius: 999px; padding: 0 .4rem; }
/* Fil du dossier (dossier_feed.html) */
.feed { list-style: none; padding: 0; margin: 0; }
.feed-day { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--app-muted); padding: .9rem 0 .35rem; }
.feed-day:first-child { padding-top: 0; }
.feed-item { display: flex; gap: .7rem; padding: .45rem 0; position: relative; }
.feed-icon { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center; font-size: .85rem;
  background: var(--bs-tertiary-bg); color: var(--app-muted); }
.feed-communication .feed-icon { color: var(--c-communication); background: var(--c-communication-soft); }
.feed-progress .feed-icon { color: var(--c-opportunity); background: var(--c-opportunity-soft); }
.feed-note .feed-icon { color: #a15c00; background: #fff3d6; }
.feed-body { min-width: 0; flex: 1; }
.feed-meta { font-size: .75rem; color: var(--app-muted); }
.feed-notebody { white-space: normal; }
.feed-notebody.private { background: var(--app-private); border: 1px dashed var(--app-private-border); border-radius: .4rem; padding: .3rem .5rem; }

/* ---- funnel / kanban ---- */
/* overscroll-behavior: a sideways swipe at the board's edge must not become the browser's back/forward gesture. */
.kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; overscroll-behavior-x: contain; }
html:has(#kanban), html:has(#kanban) body { overscroll-behavior-x: none; }
.kanban-col { flex: 1 0 190px; min-width: 0; background: #eceef3; border-radius: .6rem; display: flex; flex-direction: column; max-height: 75vh; }
.kanban-col header { padding: .6rem .75rem; border-bottom: 1px solid #dde0e7; }
.kanban-col header .totals { font-size: .75rem; color: var(--app-muted); }
.kanban-col.won { background: #e6f4ea; }
.kanban-col.lost { background: #f8e9e9; }
.kanban-list { padding: .5rem; overflow-y: auto; min-height: 80px; flex: 1; }
.kanban-older { display: block; padding: .4rem .75rem .6rem; font-size: .75rem; color: var(--app-muted); }
.kanban-card { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .5rem; padding: .55rem .65rem; margin-bottom: .5rem; cursor: grab; }
.kanban-card:active { cursor: grabbing; }
.kanban-card .value { font-weight: 650; }
.sortable-ghost { opacity: .4; }
/* A folded column: a narrow strip with its name written vertically and its count; still a drop target. */
.kanban-fold { padding: 0 .2rem; line-height: 1; color: var(--app-muted); }
.kanban-fold:hover { color: var(--bs-body-color); }
.kanban-col:not(.folded) .kanban-fold[data-fold="0"], .kanban-col.folded .kanban-fold[data-fold="1"] { display: none; }
.kanban-col.folded { flex: 0 0 2.75rem; }
.kanban-col.folded header { border-bottom: 0; padding: .5rem .25rem; }
.kanban-col.folded header > div { flex-direction: column-reverse; align-items: center !important; gap: .5rem !important; }
.kanban-col.folded header .badge { margin-left: 0 !important; }
.kanban-col.folded .kanban-title { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.kanban-col.folded header .totals, .kanban-col.folded .kanban-older, .kanban-col.folded .kanban-card { display: none; }
.kanban-col.folded .kanban-list { padding: .25rem; min-height: 40px; }

/* ---- search boxes ---- */
.search-box .card-header { display: flex; align-items: center; gap: .5rem; }
.search-box .htmx-indicator { display: none; }
.search-box.htmx-request .htmx-indicator, .search-box .htmx-request.htmx-indicator { display: inline-block; }

/* ---- suggestions ---- */
.sugg-card { border-left: 4px solid var(--app-accent); }
.sugg-card.kind-contact { border-left-color: #12b886; }
.sugg-card.kind-opportunity { border-left-color: #f59f00; }
.sugg-card.kind-followup { border-left-color: #e64980; }
.sugg-card.kind-complete_todo { border-left-color: #2b8a3e; }
.sugg-card.kind-attachment { border-left-color: #868e96; }
/* Suggestions loaded while scrolling (suggestions/_page.html): the marker fades out, the cards fade in in turn. */
.sugg-more { transition: opacity .2s ease; }
.sugg-more.htmx-swapping { opacity: 0; }
.sugg-batch.is-new > div { animation: sugg-in .35s ease-out both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes sugg-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sugg-batch.is-new > div { animation: none; } }
.sugg-reason { font-size: .82rem; color: var(--app-muted); font-style: italic; }
/* Each field of a proposal card has its label above it: a placeholder is gone once the field holds a value. */
.sugg-label { display: block; font-size: .72rem; color: var(--app-muted); margin-bottom: .1rem; }
.sugg-title { resize: vertical; }

/* ---- timeline ---- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; }
.timeline li::before { content: ""; position: absolute; left: .35rem; top: .35rem; width: .55rem; height: .55rem; border-radius: 50%; background: var(--app-accent); }
.timeline li::after { content: ""; position: absolute; left: .58rem; top: 1rem; bottom: 0; width: 1px; background: var(--app-border); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: .75rem; color: var(--app-muted); }

/* ---- list filter bar (form.filter-bar, macro filter_chip; app.js highlights the filters in use) ---- */
.filter-bar { display: flex; flex-direction: column; gap: .55rem; padding: .65rem; margin-bottom: .5rem;
  background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .6rem; }
.filter-line { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.filter-search { position: relative; flex: 1 1 18rem; }
.filter-search > i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--app-muted); pointer-events: none; }
.filter-search input { padding-left: 2.1rem; border-radius: 2rem; background: var(--bs-tertiary-bg); border-color: transparent; }
.filter-search input:focus { background: var(--bs-body-bg); }
/* Segmented control (one choice among a few, one click). */
.filter-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 2rem; background: var(--bs-tertiary-bg); max-width: 100%; }
.filter-seg label { padding: .3rem .9rem; border-radius: 2rem; color: var(--app-muted); font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, color .15s, box-shadow .15s; }
.filter-seg label:hover { color: var(--bs-body-color); }
.filter-seg .btn-check:checked + label { background: var(--app-surface); color: var(--app-accent); box-shadow: 0 1px 3px rgba(16, 24, 40, .14); }
.filter-seg .btn-check:focus-visible + label { outline: 2px solid var(--app-accent); outline-offset: 1px; }
/* A select as a pill, with its icon; filled with the accent while it holds a value. */
.filter-chip { position: relative; display: inline-flex; margin: 0; max-width: 100%; }
.filter-chip > i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--app-muted); pointer-events: none; font-size: .85rem; }
.filter-chip .form-select { field-sizing: content; min-width: 7rem; max-width: 16rem; padding: .3rem 2rem .3rem 1.9rem; font-size: .875rem;
  border-radius: 2rem; border-color: var(--app-border); color: var(--app-muted); cursor: pointer; text-overflow: ellipsis; }
.filter-chip .form-select:hover { border-color: var(--app-muted); }
.filter-chip.is-active .form-select { background-color: var(--app-accent-soft); border-color: var(--app-accent); color: var(--app-accent); font-weight: 500; }
.filter-chip.is-active > i { color: var(--app-accent); }
.filter-chip .form-select option { color: var(--bs-body-color); font-weight: 400; }
/* A period: « Du … au … » in one pill, its two dates borderless inside. */
.filter-dates { align-items: center; gap: .3rem; padding: .1rem .5rem .1rem 1.9rem; font-size: .875rem; color: var(--app-muted);
  border: 1px solid var(--app-border); border-radius: 2rem; }
.filter-dates label { margin: 0; }
.filter-dates .form-control { width: auto; padding: .2rem .3rem; font-size: .875rem; border: 0; background: transparent; color: inherit; }
.filter-dates.is-active { background-color: var(--app-accent-soft); border-color: var(--app-accent); color: var(--app-accent); font-weight: 500; }
.filter-toggle { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .85rem; font-size: .875rem; border-radius: 2rem;
  border: 1px solid var(--app-border); color: var(--app-muted); background: var(--bs-body-bg); cursor: pointer; white-space: nowrap; margin: 0; }
.filter-toggle:hover { border-color: var(--app-muted); }
.btn-check:checked + .filter-toggle { background: var(--app-accent-soft); border-color: var(--app-accent); color: var(--app-accent); font-weight: 500; }
.btn-check:focus-visible + .filter-toggle { outline: 2px solid var(--app-accent); outline-offset: 1px; }
.filter-reset { margin-left: auto; font-size: .85rem; color: var(--app-muted); white-space: nowrap; }
.filter-reset:hover { color: var(--bs-danger); text-decoration: none; }

/* ---- stats ---- */
.stat { padding: .9rem 1rem; }
.stat .num { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { font-size: .75rem; color: var(--app-muted); text-transform: uppercase; letter-spacing: .05em; }
a.stat:hover { border-color: var(--app-muted); }
a.stat.active { border-color: var(--app-accent); background: var(--app-accent-soft); }

/* ---- mobile ---- */
@media (max-width: 767.98px) {
  body { font-size: .95rem; }
  .page-head h1 { font-size: 1.2rem; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .table-responsive-cards thead { display: none; }
  .table-responsive-cards tr { display: block; border-bottom: 1px solid var(--app-border); padding: .4rem 0; }
  .table-responsive-cards td { display: flex; justify-content: space-between; border: 0; padding: .2rem .6rem !important; }
  .table-responsive-cards td[data-label]::before { content: attr(data-label); color: var(--app-muted); font-size: .8rem; margin-right: 1rem; }
  .kanban { scroll-snap-type: x proximity; }
  .kanban-col { flex: 0 0 85vw; scroll-snap-align: start; }
  .kanban-col.folded { flex: 0 0 2.75rem; }
  .nav-search { min-width: 0; width: 100%; }
  .filter-seg { width: 100%; }
  .filter-seg label { flex: 1; padding: .3rem .4rem; text-align: center; }
  .filter-seg.view-seg { width: auto; }  /* the rows / cards switch stays a small pill on phones */
  .filter-seg.view-seg label { flex: none; padding: .3rem .8rem; }
  .contact-reach a { padding: .5rem .55rem; font-size: 1.1rem; }  /* finger-sized */
}

/* Closed items (done/cancelled to-dos, won/lost opportunities): folded and dimmed. */
.closed-fold > summary { list-style: none; cursor: pointer; padding: .5rem 1rem; font-size: .8rem; color: var(--app-muted); border-top: 1px solid var(--bs-border-color-translucent); }
.closed-fold > summary::-webkit-details-marker { display: none; }
.closed-fold > summary .bi-chevron-right { display: inline-block; transition: transform .15s; }
.closed-fold[open] > summary .bi-chevron-right { transform: rotate(90deg); }
.closed-fold > summary:hover { color: var(--bs-body-color); }
.card-body .closed-fold > summary { padding: .25rem 0; border-top: 0; }
.is-closed { background: var(--bs-tertiary-bg); }
.is-closed .closed-title, .is-closed .closed-title a { color: var(--app-muted); text-decoration: line-through; font-weight: 400; }

/* ---- pipeline KPIs (funnel, forecast) ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.kpi { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .6rem; padding: .65rem .85rem; color: inherit; text-decoration: none; }
.kpi-label { font-size: .75rem; color: var(--app-muted); }
.kpi-value { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-value.small { font-size: .9rem; font-weight: 500; color: var(--app-accent); padding-top: .35rem; }
.kpi-main { border-color: var(--app-accent); background: var(--app-accent-soft); }
.kpi-main .kpi-value { color: var(--app-accent); }
.kpi-link:hover { border-color: var(--app-accent); }

/* ---- forecast: one bar per month, total (light) behind weighted (solid), both from the baseline ---- */
.fc-chart { display: flex; align-items: flex-end; gap: .5rem; height: 240px; padding: 1.5rem .25rem 0; border-bottom: 1px solid var(--app-border); }
.fc-col { flex: 1; min-width: 0; color: var(--bs-body-color); text-decoration: none; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; cursor: default; }
.fc-bars { position: relative; width: min(56px, 80%); height: 100%; }
.fc-bar { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 4px 4px 0 0; }
.fc-bar.total { background: var(--fc-total); }
.fc-bar.weighted { background: var(--app-accent); left: 2px; right: 2px; }
.fc-value { position: absolute; left: 50%; transform: translate(-50%, -100%); font-size: .72rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; padding-bottom: 2px; }
.fc-labels { display: flex; gap: .5rem; padding: .35rem .25rem 0; }
.fc-labels > span { flex: 1; min-width: 0; text-align: center; font-size: .75rem; color: var(--app-muted); text-transform: capitalize; white-space: nowrap; }
.fc-labels .y { display: block; font-size: .68rem; color: var(--app-muted); opacity: .8; }
@media (max-width: 576px) {
  .kpi { padding: .5rem .65rem; }
  .kpi-value { font-size: 1.1rem; }
  .fc-chart, .fc-labels { gap: .2rem; }
  .fc-labels > span { font-size: .68rem; }
  /* 12 months on a phone: values stay in the tooltip and the table; label every other month. */
  .fc-many .fc-value { display: none; }
  .fc-many .fc-labels > span:nth-child(even) .m { visibility: hidden; }
}
.fc-col .fc-tip { display: none; position: absolute; bottom: calc(100% - 1rem); z-index: 5; background: #1f2937; color: #fff; border-radius: .4rem; padding: .4rem .55rem; font-size: .75rem; white-space: nowrap; pointer-events: none; }
.fc-col:hover .fc-tip, .fc-col:focus .fc-tip { display: block; }
.fc-col:hover .fc-bar.total { background: #aebcf6; }
.fc-legend { display: flex; gap: 1rem; font-size: .75rem; color: var(--app-muted); }
.fc-legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; vertical-align: -1px; margin-right: .3rem; }
.fc-month { text-transform: capitalize; }
.fc-compact .fc-chart { height: 150px; }

/* ---- edit forms (form_section, form_actions in _macros.html): one card per group of fields, the object's colour on
   its header; on a wide screen the short groups go in a column on the right. The save bar stays at the bottom. ---- */
.form-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1.25rem; align-items: start; }
@media (min-width: 992px) { .form-cols { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); } }
.form-sec { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: .6rem; margin-bottom: 1.25rem;
  scroll-margin-top: 1rem; }
.form-sec-head { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; border-radius: .6rem .6rem 0 0;
  background: var(--ent-soft, var(--bs-tertiary-bg)); box-shadow: inset 0 3px 0 var(--ent, var(--app-accent));
  border-bottom: 1px solid color-mix(in srgb, var(--ent, var(--app-accent)) 18%, transparent); }
.form-sec-icon { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .5rem;
  background: var(--app-surface); color: var(--ent, var(--app-accent)); font-size: 1rem;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ent, var(--app-accent)) 20%, transparent); }
.form-sec-head h2 { font-size: .975rem; font-weight: 600; margin: 0; line-height: 1.3; }
.form-sec-head p { font-size: .8rem; color: var(--app-muted); margin: .1rem 0 0; line-height: 1.35; }
.form-sec-body { padding: 1rem 1rem 0; }
.form-sec-body .form-label { font-weight: 500; margin-bottom: .3rem; }
.form-sec-body .form-text { font-size: .78rem; }
.form-actions { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; gap: .5rem;
  padding: .75rem 0 calc(.75rem + env(safe-area-inset-bottom));
  /* Full width without overflowing the page: the background goes on as a shadow, clipped to the bar's height. */
  --bar-bg: color-mix(in srgb, var(--app-bg) 92%, transparent);
  background: var(--bar-bg); box-shadow: 0 0 0 100vmax var(--bar-bg), 0 -1px 0 100vmax var(--app-border);
  clip-path: inset(-1px -100vmax 0); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.md-hint code { white-space: nowrap; color: inherit; font-size: .95em; }
.form-actions .btn-primary { min-width: 9rem; }
@media (max-width: 575.98px) {
  .form-sec { margin-bottom: 1rem; }
  .form-sec-body { padding: .85rem .85rem 0; }
  .form-actions .btn { flex: 1; }
}
/* Touch screens (iPhone, iPad): 16 px fields, else Safari zooms in on focus; bigger targets for the category chips. */
@media (pointer: coarse) {
  .form-control, .form-select, .input-group-sm > .form-control, .ts-wrapper .ts-control, .ts-wrapper .ts-control input,
  .ts-dropdown { font-size: 16px; }
  .cat-pick { padding: .4rem .8rem; }
  .form-check-input { width: 1.2em; height: 1.2em; }
  .form-switch .form-check-input { width: 2.2em; }
}

/* ---- object colour code: one colour per type, everywhere (card title bands, page titles, link icons) ----
   Set on any element with .ent-<key> (key = ent_key(obj): client|partner|internal|contact|opportunity|todo|communication). */
:root {
  --c-client: #3b5bdb;  --c-client-soft: #edf1ff;
  --c-partner: #2b8a3e; --c-partner-soft: #e9f7ec;
  --c-internal: #6b7280; --c-internal-soft: #f1f3f5;
  --c-contact: #0c8599; --c-contact-soft: #e3f7fa;
  --c-opportunity: #7048e8; --c-opportunity-soft: #f1edff;
  --c-todo: #d9480f;    --c-todo-soft: #fff1e8;
  --c-communication: #495a74; --c-communication-soft: #edf0f5;
}
.ent-client { --ent: var(--c-client); --ent-soft: var(--c-client-soft); }
.ent-organization { --ent: var(--c-client); --ent-soft: var(--c-client-soft); }
.ent-partner { --ent: var(--c-partner); --ent-soft: var(--c-partner-soft); }
.ent-internal { --ent: var(--c-internal); --ent-soft: var(--c-internal-soft); }
.ent-contact { --ent: var(--c-contact); --ent-soft: var(--c-contact-soft); }
.ent-opportunity { --ent: var(--c-opportunity); --ent-soft: var(--c-opportunity-soft); }
.ent-todo { --ent: var(--c-todo); --ent-soft: var(--c-todo-soft); }
.ent-communication { --ent: var(--c-communication); --ent-soft: var(--c-communication-soft); }

.card.ent > .card-header { background: var(--ent-soft); box-shadow: inset 0 3px 0 var(--ent); border-bottom-color: color-mix(in srgb, var(--ent) 18%, transparent); }
.card.ent > .card-header > .bi:first-child, .card.ent > .card-header > span:first-child > .bi:first-child { color: var(--ent); }
.page-head.ent h1 > .bi:first-child { color: var(--ent); }
.page-head.ent .kicker:first-child { color: var(--ent); font-weight: 600; }
a > .bi.ent, .kanban-card .bi.ent, .opp-parties .bi.ent { color: var(--ent); }
.navbar .nav-link > .bi.ent { color: color-mix(in srgb, var(--ent) 55%, #fff); }
.ent-legend { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; }
.ent-legend::before { content: ""; width: .6rem; height: .6rem; border-radius: 2px; background: var(--ent); }

/* ---- attachment viewer (_partials/attachment_viewer.html) ---- */
.att-body { min-height: 50vh; }
.modal-dialog:not(.modal-fullscreen) .att-body { max-height: 78vh; }
.att-frame { display: block; width: 100%; height: 78vh; border: 0; background: #525659; }
.modal-fullscreen .att-frame { height: calc(100vh - 70px); }
.att-image { display: flex; align-items: center; justify-content: center; background: repeating-conic-gradient(#f1f3f5 0% 25%, #fff 0% 50%) 50% / 20px 20px; }
.att-image img { max-width: 100%; max-height: 74vh; object-fit: contain; }
.modal-fullscreen .att-image img { max-height: calc(100vh - 110px); }
.att-text { white-space: pre-wrap; word-break: break-word; font-size: .82rem; background: var(--app-bg); border-radius: .4rem; padding: .75rem; margin: 0; }
.att-table { max-height: 70vh; }
.att-table th { position: sticky; top: 0; background: var(--app-surface); z-index: 1; }
.att-table td, .att-table th { white-space: nowrap; font-size: .8rem; }
.att-docx { max-width: 820px; margin: 0 auto; line-height: 1.55; }
.att-docx img { max-width: 100%; height: auto; }
.att-docx table { border-collapse: collapse; margin: .75rem 0; }
.att-docx td, .att-docx th { border: 1px solid var(--app-border); padding: .25rem .5rem; }
.comm-gist { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: .15rem; }
.fc-bar.won { background: var(--c-partner); left: 4px; right: 4px; }

/* Version number, discreet in the bottom-left corner (VERSION env var). */
.app-version { position: fixed; left: .5rem; bottom: .25rem; z-index: 1; font-size: .7rem; opacity: .45;
  color: var(--bs-secondary-color); pointer-events: none; user-select: none; }

/* To-do chains (services/chains.chain_layout), drawn as a tree down the left: column c is centred at
   .8rem + c × 1.1rem. Every step has a dot, where the lines to its next steps start; each line ends with an
   arrowhead on the dot of the step it leads to. A lone next step stays in its step's column (arrow down); the
   next steps of a step that has several sit one column right, joined to its line by an elbow (├, └; arrow
   right). Closed steps have a hollow dot. */
.list-group-item.chain { padding-left: calc(1.75rem + var(--chain-col, 0) * 1.1rem); }
.chain-guides { position: absolute; inset: 0 auto 0 0; pointer-events: none; }
.chain-guides > span, .chain-mark, .chain-arrow { position: absolute; left: calc(.8rem + var(--c) * 1.1rem); }
.chain-guides > span { top: 0; bottom: 0; }
.chain-guides i { position: absolute; display: block; background: var(--app-accent); opacity: .45; }
.chain-guides .up { left: -1px; width: 2px; top: 0; height: 50%; }
.chain-guides .dn { left: -1px; width: 2px; top: 50%; bottom: 0; }
.chain-guides .rt { left: 0; width: calc(1.1rem - 12px); top: calc(50% - 1px); height: 2px; }
.chain-mark { top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--app-accent); }
.chain.is-closed .chain-mark { background: var(--app-surface); border: 2px solid var(--app-accent); }
/* The arrowhead touches the dot: from above (down) or from the left (right). */
.chain-arrow { top: 50%; width: 0; height: 0; }
.chain-arrow.down { margin: -12px 0 0 -5px; border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 7px solid var(--app-accent); }
.chain-arrow.right { margin: -5px 0 0 -12px; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  border-left: 7px solid var(--app-accent); }
/* The step's dot removes the link that comes into it (todos.unlink): its arrow turns red while the row is
   hovered, and the dot becomes a red × under the pointer (a 20px round button centred on the dot). */
.chain-unlink { position: absolute; top: 50%; left: calc(.8rem + var(--c) * 1.1rem); margin: -10px 0 0 -10px; z-index: 1; }
.chain-unlink button { display: block; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: none;
  color: var(--bs-danger); font-size: .7rem; line-height: 20px; cursor: pointer; }
.chain-unlink button i { opacity: 0; }
.chain:hover .chain-arrow.down { border-top-color: var(--bs-danger); }
.chain:hover .chain-arrow.right { border-left-color: var(--bs-danger); }
.chain-unlink button:hover, .chain-unlink button:focus-visible { background: var(--bs-danger-bg-subtle); }
.chain-unlink button:hover i, .chain-unlink button:focus-visible i { opacity: 1; }
.chain:has(.chain-unlink button:hover, .chain-unlink button:focus-visible) .chain-mark { visibility: hidden; }
/* The link about to be removed (app.js): its segments and its arrowhead in red. */
.chain-guides i.unlinking { background: var(--bs-danger); opacity: 1; z-index: 1; }
.chain.unlinking .chain-arrow.down { border-top-color: var(--bs-danger); }
.chain.unlinking .chain-arrow.right { border-left-color: var(--bs-danger); }

/* « #7 »: a to-do's number within its client (Todo.number), also in "Suite de". */
.todo-main { flex: 1 1 16rem; min-width: 0; }
.todo-controls { flex: none; margin-left: auto; }
.todo-controls .link-pill { white-space: nowrap; }
/* Each row is measured on its own (iPad: the to-do card is half the page). Below 32rem, the controls get their
   own full line and may wrap, the date on the left, and « Étape suivante » keeps only its arrow. A query container
   is a stacking context, so the row with an open menu goes above the next ones. */
.todo-row { container-type: inline-size; }
.todo-row:has(.dropdown-menu.show) { z-index: 3; }
@container (max-width: 32rem) {
  .todo-controls { flex: 1 1 100%; flex-wrap: wrap; row-gap: .25rem; margin-left: 0; }
  .todo-controls > :first-child { margin-right: auto; }
  .todo-controls .link-pill-label { display: none; }
}
.todo-num { color: var(--app-muted); font-variant-numeric: tabular-nums; margin-right: .3rem; }

/* "Étape suivante": the pill to drag, the dashed arrow that follows the pointer, the to-do it would link to. */
.link-pill { border: 1px dashed var(--app-accent); color: var(--app-accent); background: transparent; border-radius: 999px;
  font-size: .7rem; padding: 0 .45rem; line-height: 1.4rem; cursor: grab; touch-action: none; user-select: none; }
.link-pill:hover { background: var(--app-accent-soft); }
body.linking, body.linking * { cursor: grabbing !important; user-select: none; }
.link-overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2000; overflow: visible; }
.link-overlay line { stroke: var(--app-accent); stroke-width: 2; stroke-dasharray: 6 4; }
.link-overlay circle, .link-overlay marker path { fill: var(--app-accent); }
.list-group-item.link-source { background: var(--app-accent-soft); }
.list-group-item.link-target { outline: 2px solid var(--app-accent); outline-offset: -2px; background: var(--app-accent-soft); }

/* The to-do page shows its current status large (status_menu with the 'page' slot). */
.status-lg .badge-status { font-size: 1rem; padding: .5rem .9rem; border-radius: .5rem; }
.status-lg .bi-chevron-down { font-size: .9rem; }

/* A card shown full screen (data-fullscreen-toggle, app.js): whole texts and the extra rows appear. */
.fs-only, .comm-full { display: none; }
.card-fullscreen { position: fixed; inset: 1.5rem; z-index: 1050; overflow: auto; margin: 0 !important;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
.card-fullscreen .card-header { position: sticky; top: 0; z-index: 1; }
.card-fullscreen .fs-only { display: block; }
/* Each message a distinct block; its text clamped to 8 lines, a click shows it all (app.js). */
.card-fullscreen .list-group { padding: .75rem; gap: .75rem; }
.card-fullscreen .list-group-item { border: 1px solid var(--app-border) !important; border-left: 4px solid var(--app-accent) !important;
  border-radius: .5rem !important; padding: 0; overflow: hidden; }
.card-fullscreen .list-group-item > .d-flex:first-child { background: var(--bs-tertiary-bg); padding: .5rem .85rem; }
.card-fullscreen .list-group-item > :not(:first-child) { padding-left: .85rem; padding-right: .85rem; }
.card-fullscreen .comm-full { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 8; overflow: hidden;
  white-space: pre-line; margin: .5rem 0; color: var(--bs-body-color); line-height: 1.45; cursor: pointer; }
.card-fullscreen .comm-full.expanded { display: block; -webkit-line-clamp: unset; }
.card-fullscreen .comm-more-toggle { display: block; font-size: .75rem; color: var(--app-accent); margin: -.25rem 0 .5rem; cursor: pointer; }
.comm-more-toggle { display: none; }
/* Accordion (app.js): a click on a message's gist unfolds its whole text in place; a click on the text folds it. */
.comm-gist { cursor: pointer; }
/* The x of a communication on an opportunity's page: faint at rest, plain with its row. */
.comm-unlink { border: 0; background: none; padding: 0 .1rem; font-size: .75rem; color: var(--bs-secondary-color); opacity: .45; }
.list-group-item:hover .comm-unlink, .comm-unlink:focus-visible { opacity: 1; }
.comm-unlink:hover { color: var(--bs-danger); }
@media (hover: none) { .comm-unlink { opacity: 1; } }
/* A thread taken out of an opportunity, at the foot of its Communications card. */
.ai-adjustment { padding-top: .5rem; margin-top: .5rem; border-top: 1px solid var(--bs-border-color-translucent); }
.ai-adjustment .btn-link { padding: 0; border: 0; font-size: inherit; vertical-align: baseline; text-decoration: none; }
.ai-adjustment-delete { border: 0; background: none; padding: 0 .1rem; color: var(--bs-secondary-color); }
.ai-adjustment-delete:hover { color: var(--bs-danger); }
.comm-gist::after { content: "\F282"; font-family: bootstrap-icons; font-size: .7em; margin-left: .3rem; }
.comm-open > .comm-gist { display: none; }
.comm-open > .comm-full { display: block; white-space: pre-line; margin: .35rem 0; padding: .5rem .75rem; cursor: pointer;
  color: var(--bs-body-color); line-height: 1.45; background: var(--bs-tertiary-bg); border-radius: .375rem;
  max-height: 32rem; overflow: auto; overflow-wrap: anywhere; }
.card-fullscreen .comm-gist { display: none; }
@media (max-width: 575.98px) { .card-fullscreen { inset: 0; } }

/* Opportunity lost (app.js celebrate('lost')): a rain cloud over a sad face, then it fades away. */
.sad-fx { position: fixed; top: 18vh; left: 50%; z-index: 2000; pointer-events: none; display: flex; flex-direction: column; align-items: center;
  transform: translateX(-50%); animation: sad-fade 3s ease forwards; }
.sad-cloud { font-size: 5rem; line-height: 1; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .3)); animation: sad-drift 3s ease-in-out; }
.sad-rain { position: relative; width: 6rem; height: 3.5rem; margin-top: -1.2rem; }
.sad-rain i { position: absolute; top: 0; width: 3px; height: 12px; border-radius: 2px; background: #6ea8fe; opacity: 0;
  animation: sad-drop .8s linear infinite; }
.sad-face { font-size: 3.5rem; line-height: 1; animation: sad-droop 3s ease-in-out forwards; }
@keyframes sad-fade { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes sad-drift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-6px); } }
@keyframes sad-drop { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: .9; } 100% { transform: translateY(3rem); opacity: 0; } }
@keyframes sad-droop { 0% { transform: translateY(-4px) rotate(0); } 40% { transform: translateY(4px) rotate(-6deg); } 100% { transform: translateY(8px) rotate(-10deg); } }

/* ---- dark mode (data-bs-theme on <html>, chosen in the avatar menu: base.html, app.js) ---- */
.theme-switch .btn { --bs-btn-padding-y: .15rem; }
:root[data-bs-theme=dark] {
  color-scheme: dark;
  --app-bg: #12151c;
  --app-surface: #1b1f28;
  --app-border: #2e3442;
  --app-accent: #8aa2ff;
  --app-accent-soft: #232b48;
  --app-avatar-glow: 0 0 0 1px rgba(255, 255, 255, .08), 0 0 8px rgba(138, 162, 255, .35);
  --app-private: #33290f;
  --app-private-border: #8a6d1f;
  --app-muted: #9aa1b5;
  --fc-total: #2f3a66;
  --bs-body-bg: #1b1f28;
  --bs-body-color: #dde1ea;
  --bs-secondary-bg: #232834;
  --bs-tertiary-bg: #20242e;
  --bs-border-color: #2e3442;
  --bs-border-color-translucent: rgba(255, 255, 255, .1);
  --bs-primary: #8aa2ff;
  --bs-primary-rgb: 138, 162, 255;
  --bs-link-color: #8aa2ff;
  --bs-link-color-rgb: 138, 162, 255;
  --bs-link-hover-color: #b0c0ff;
  --bs-link-hover-color-rgb: 176, 192, 255;
  --c-client: #748ffc;  --c-partner: #51cf66; --c-internal: #adb5bd; --c-contact: #3bc9db;
  --c-opportunity: #9775fa; --c-todo: #ff8743; --c-communication: #8da2c0;
  --c-client-soft: color-mix(in srgb, var(--c-client) 16%, var(--app-surface));
  --c-partner-soft: color-mix(in srgb, var(--c-partner) 16%, var(--app-surface));
  --c-internal-soft: color-mix(in srgb, var(--c-internal) 12%, var(--app-surface));
  --c-contact-soft: color-mix(in srgb, var(--c-contact) 16%, var(--app-surface));
  --c-opportunity-soft: color-mix(in srgb, var(--c-opportunity) 16%, var(--app-surface));
  --c-todo-soft: color-mix(in srgb, var(--c-todo) 16%, var(--app-surface));
  --c-communication-soft: color-mix(in srgb, var(--c-communication) 16%, var(--app-surface));
}
[data-bs-theme=dark] .btn-primary { --bs-btn-bg: #4263eb; --bs-btn-border-color: #4263eb; --bs-btn-hover-bg: #3b5bdb; --bs-btn-hover-border-color: #3b5bdb;
  --bs-btn-active-bg: #364fc7; --bs-btn-active-border-color: #364fc7; }
[data-bs-theme=dark] .app-nav { background: #0d1016; border-bottom: 1px solid var(--app-border); }
[data-bs-theme=dark] .nav-search input:focus { background: var(--bs-body-bg); color: var(--bs-body-color); }
[data-bs-theme=dark] .text-bg-light { background-color: var(--bs-secondary-bg) !important; color: var(--bs-body-color) !important; }
[data-bs-theme=dark] .avatar.external { background: #3a1d28; color: #f783ac; }
[data-bs-theme=dark] .st-todo, [data-bs-theme=dark] .st-open { background: rgba(116, 143, 252, .18); color: #91a7ff; }
[data-bs-theme=dark] .st-in_progress { background: rgba(250, 176, 5, .16); color: #ffc078; }
[data-bs-theme=dark] .st-waiting { background: rgba(151, 117, 250, .18); color: #b197fc; }
[data-bs-theme=dark] .st-done, [data-bs-theme=dark] .st-won { background: rgba(81, 207, 102, .15); color: #69db7c; }
[data-bs-theme=dark] .st-cancelled { background: rgba(255, 255, 255, .08); color: #9aa1b5; }
[data-bs-theme=dark] .st-lost { background: rgba(255, 107, 107, .15); color: #ff8787; }
[data-bs-theme=dark] .overdue { color: #ff8787; }
[data-bs-theme=dark] .tag { background: #2a2f3b; color: #c9ced8; }
[data-bs-theme=dark] .local-clock { --lc-bg: #3b5bdb; --lc-fg: #fff; --lc-icon: #ffd43b; }
[data-bs-theme=dark] .local-clock.is-night { --lc-bg: #0d1016; --lc-fg: #c9ced8; --lc-icon: #9aa7d6; box-shadow: inset 0 0 0 1px var(--app-border); }
[data-bs-theme=dark] .note .private-flag { color: #ffc078; }
[data-bs-theme=dark] .comm-privacy.is-private { background: rgba(255, 192, 120, .12); color: #ffc078; border-color: rgba(255, 192, 120, .35); }
[data-bs-theme=dark] .kanban-col { background: #191d26; }
[data-bs-theme=dark] .feed-note .feed-icon { background: #3a2e12; color: #f0b44c; }
[data-bs-theme=dark] .kanban-col header { border-bottom-color: var(--app-border); }
[data-bs-theme=dark] .kanban-col.won { background: #15241b; }
[data-bs-theme=dark] .kanban-col.lost { background: #2a1a1d; }
[data-bs-theme=dark] .fc-col:hover .fc-bar.total { background: #3a4780; }
[data-bs-theme=dark] .att-image { background: repeating-conic-gradient(#2a2f3a 0% 25%, #1f232c 0% 50%) 50% / 20px 20px; }
[data-bs-theme=dark] .card-fullscreen { box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .65); }

/* Searchable selects (Tom Select, app.js): follow the theme. */
.ts-wrapper .ts-control, .ts-wrapper .ts-control input, .ts-dropdown { color: var(--bs-body-color); }
.ts-wrapper.single .ts-control, .ts-dropdown { background-color: var(--bs-body-bg); }
.ts-wrapper .ts-control input::placeholder { color: var(--bs-secondary-color); }
.ts-dropdown .optgroup-header { color: var(--bs-secondary-color); background: var(--bs-tertiary-bg); font-weight: 600; }
.ts-dropdown .active { background-color: var(--bs-primary-bg-subtle); color: var(--bs-emphasis-color); }
/* Single choice on one line: a long name is cut with "…" instead of pushing the search box (min 7rem) onto a second line. */
.ts-wrapper.single .ts-control { flex-wrap: nowrap; }
.ts-wrapper.single .ts-control > .item { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-wrapper.single.has-items .ts-control > input { flex: 1 0 3rem; min-width: 3rem; }

/* Floating flash messages (flash_toasts macro in _macros.html). */
.app-toasts { position: fixed; top: 4.5rem; right: 1rem; z-index: 1090; width: min(440px, calc(100vw - 2rem)); display: grid; gap: .5rem; }

/* ---- client logos (logos.*, macro org_logo) ---- */
.org-logo { object-fit: contain; vertical-align: middle; }
.org-logo-sm { height: 20px; max-width: 64px; margin-left: .5rem; }  /* after the name (client list) */
.org-logo-lg { max-height: 120px; max-width: 100%; }
:root[data-bs-theme=dark] .org-logo { background: rgba(255, 255, 255, .9); border-radius: 3px; padding: 1px 2px; }
.org-logo-card { position: relative; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
:root[data-bs-theme=dark] .org-logo-card { background: rgba(255, 255, 255, .92); }
:root[data-bs-theme=dark] .org-logo-card .org-logo { background: none; padding: 0; }
.org-logo-x { position: absolute; top: .5rem; right: .5rem; z-index: 2; display: none; align-items: center; justify-content: center;
  width: 20px; height: 20px; padding: 0; border-radius: 50%; font-size: 1rem; line-height: 1;
  background: var(--bs-danger); border: 2px solid var(--bs-body-bg); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.org-logo-card:hover .org-logo-x, .org-logo-x:focus-visible { display: inline-flex; }
@media (hover: none) { .org-logo-x { display: inline-flex; } }
.logo-search .htmx-indicator { display: none; }
.logo-search.htmx-request .htmx-indicator { display: inline-block; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.logo-tile { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .5rem;
  border: 1px solid var(--bs-border-color); border-radius: .5rem; background: var(--bs-body-bg); }
.logo-tile:hover, .logo-tile:focus-visible { border-color: var(--bs-primary); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .25); }
.logo-checker { display: flex; align-items: center; justify-content: center; width: 100%; height: 100px; border-radius: .25rem;
  background: repeating-conic-gradient(#e9ecef 0% 25%, #fff 0% 50%) 50% / 16px 16px; }
.logo-checker img { max-width: 90%; max-height: 90px; object-fit: contain; }

/* Amounts: the currency stays on the number's line, smaller and paler. */
.money { white-space: nowrap; }
.money .cur { font-size: .8em; font-weight: 400; color: var(--bs-secondary-color); }

/* Admin › Utilisateurs et accès (admin/_users.html): a read-only list, one side panel per user. */
.min-w-0 { min-width: 0; }
.users-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.users-search { width: min(320px, 100%); }
.access-help { display: grid; gap: .5rem; background: var(--bs-tertiary-bg); }
.users-table .user-name { font-size: inherit; line-height: 1.3; }
.users-table .user-name:hover { color: var(--app-accent) !important; }
.users-table tr.user-inactive td > * { opacity: .6; }
.users-table tr.user-inactive td:last-child > * { opacity: 1; }
.user-panel { --bs-offcanvas-width: min(480px, 100vw); }
.user-panel .panel-section + .panel-section { border-top: 1px solid var(--app-border); margin-top: 1.25rem; padding-top: 1.25rem; }
.user-panel .kicker { margin-bottom: .75rem; }
.user-panel .scope-line { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.user-panel .scope-add { background: var(--bs-tertiary-bg); border-radius: .5rem; padding: .75rem; }
.scope-chip { gap: .55rem; }
.scope-chip i { opacity: .65; }
@media (min-width: 992px) {  /* a toast next to an open user panel, not over its header */
  body:has(.user-panel.show) .app-toasts { right: calc(min(480px, 100vw) + 1rem); }
}
.scope-any { color: var(--bs-tertiary-color); font-style: italic; }

/* A modal whose header / body / footer sit inside a wrapper (a <div> or a <form>) rather than right under
   .modal-content: put .modal-flex on each wrapper so the body scrolls and the footer's buttons stay in sight
   (Bootstrap's .modal-dialog-scrollable only reaches direct children). */
.modal-flex { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.modal-flex > .modal-body { overflow-y: auto; }

/* « En veille » (zzz): an opportunity the viewer put to sleep, shown only with « Afficher en veille ». */
.snooze-badge { background: var(--bs-secondary-bg); color: var(--bs-secondary-color); font-weight: 500; }
tr.is-snoozed > td, .kanban-card.is-snoozed, .list-group-item.is-snoozed { opacity: .6; }
tr.is-snoozed:hover > td, .kanban-card.is-snoozed:hover, .list-group-item.is-snoozed:hover { opacity: 1; }
