/* Veille AO — RK Data
   Parti pris : l'échéance est l'information qui commande la décision. Elle occupe la
   colonne de gauche de chaque ligne, en chiffres condensés, colorée selon l'urgence.
   Tout le reste reste calme : bleu RK Data, gris froids, aucune décoration. */

:root {
  --ink: #13233F;
  --ink-2: #2E405E;
  --muted: #5B6B82;
  --paper: #F3F6FA;
  --surface: #FFFFFF;
  --line: #DCE3ED;
  --line-strong: #C3CEDD;
  --brand: #1F5FBF;
  --brand-deep: #0E3B80;
  --brand-wash: #E8F0FC;
  --critical: #B42318;
  --critical-wash: #FDECEA;
  --soon: #A5470A;
  --soon-wash: #FEF1E3;
  --ok: #1D6F42;
  --ok-wash: #E6F3EB;
  --radius: 8px;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --condensed: "IBM Plex Sans Condensed", "Arial Narrow", var(--sans);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
}
a { color: var(--brand-deep); text-underline-offset: 2px; }
a:hover { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 600; margin: 0 0 .4rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; line-height: 1.3; font-weight: 600; margin: 0; }
mark {
  background: var(--brand-wash); color: var(--brand-deep);
  padding: 0 .4em; border-radius: 4px; font-size: .85em; white-space: nowrap;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hint { display: block; color: var(--muted); font-size: .85rem; font-weight: 400; margin-top: .25rem; }

/* ---------- barre supérieure */
.topbar {
  display: flex; align-items: center; gap: 2rem;
  padding: 0 24px; height: 60px;
  background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark { color: #7FB0FF; display: inline-flex; }
.brand-name { font-weight: 600; font-size: 1.05rem; }
.brand-product { color: #AFC0DA; font-size: .9rem; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a {
  color: #D6E0EE; text-decoration: none; padding: .45rem .75rem; border-radius: 6px; font-weight: 500;
}
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.mainnav a[aria-current="page"] { background: rgba(127,176,255,.18); color: #fff; }
.usermenu { position: relative; }
.usermenu summary { cursor: pointer; color: #D6E0EE; list-style: none; padding: .45rem .5rem; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-panel {
  position: absolute; right: 0; top: 2.6rem; min-width: 220px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .5rem; box-shadow: 0 8px 24px rgba(19,35,63,.16);
  display: grid; gap: .1rem;
}
.usermenu-panel a, .usermenu-panel .linkbtn { padding: .45rem .6rem; border-radius: 6px; text-decoration: none; color: var(--ink); text-align: left; }
.usermenu-panel a:hover, .usermenu-panel .linkbtn:hover { background: var(--paper); }
.usermenu-org { margin: .2rem .6rem .4rem; color: var(--muted); font-size: .85rem; }

/* ---------- page */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.summary { margin-bottom: 1.25rem; }
.summary-with-action { display: flex; gap: 2rem; align-items: flex-start; justify-content: space-between; }
.summary-line { margin: 0; font-size: 1.05rem; color: var(--ink-2); max-width: 75ch; }
.summary-run { margin: .35rem 0 0; color: var(--muted); font-size: .9rem; }
.summary-run.run-error, .summary-run.run-partial { color: var(--critical); }
.section-title { margin: 2rem 0 .75rem; }
.crumbs { margin: 0 0 .75rem; font-size: .9rem; }
.crumbs a::before { content: "‹ "; }

.flashes { margin-bottom: 1rem; }
.flash { margin: 0 0 .5rem; padding: .65rem .9rem; border-radius: var(--radius); background: var(--ok-wash); color: var(--ok); }
.flash-error { background: var(--critical-wash); color: var(--critical); }

/* ---------- boutons et formulaires */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 500 .95rem/1 var(--sans); padding: .65rem 1rem; border-radius: 6px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); color: #fff; }
.btn-primary[disabled] { background: var(--line-strong); cursor: not-allowed; }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-quiet:hover { border-color: var(--brand); color: var(--brand-deep); }
.btn-danger { background: var(--surface); color: var(--critical); border-color: #E9B4AE; }
.btn-danger:hover { background: var(--critical-wash); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-deep); cursor: pointer; }
.linkbtn.danger { color: var(--critical); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: .55rem .65rem; width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid var(--brand-wash); }
label { display: block; font-weight: 500; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
label.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 400; }
label.check input { width: auto; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: .5rem; }
.form { display: grid; gap: 1.1rem; }
.form.narrow { max-width: 640px; margin-bottom: 2rem; }
.form fieldset.inline { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; }
.form fieldset.inline legend { width: 100%; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; align-items: center; }
.danger-zone { max-width: 640px; border-top: 1px solid var(--line); padding-top: 1.25rem; }

/* ---------- filtres */
.filters {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; display: grid; gap: .85rem; margin-bottom: 1rem;
}
.filters-search input { font-size: 1rem; padding: .7rem .8rem; }
.filters-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: .75rem; }
.filters-row label { font-size: .82rem; color: var(--muted); }
.filters-actions { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; }
.filters-actions .spacer { flex: 1; }
.filters-more { display: grid; gap: .85rem; }
.filters-more > summary { display: none; }
.filters-more[open] { display: grid; gap: .85rem; }
.filters-more[open] > .filters-row { margin-top: 0; }
.result-count { color: var(--muted); font-size: .9rem; margin: 0 0 .5rem; }

/* ---------- liste des consultations : la ligne d'échéance */
.ao-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ao {
  --urgency: var(--brand);
  display: grid; grid-template-columns: 128px 1fr 200px; gap: 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--urgency);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.ao--critical { --urgency: var(--critical); }
.ao--soon { --urgency: var(--soon); }
.ao--closed, .ao--none { --urgency: var(--line-strong); }
.ao-due { display: flex; flex-direction: column; gap: .2rem; }
.ao-count {
  font-family: var(--condensed); font-weight: 700; font-size: 2rem; line-height: 1;
  color: var(--urgency); letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
}
.ao--critical .ao-count { font-size: 2.15rem; }
.ao-date { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.ao-title { font-size: 1.02rem; font-weight: 600; line-height: 1.4; max-width: 72ch; }
.ao-title a { color: var(--ink); text-decoration: none; }
.ao-title a:hover { color: var(--brand-deep); text-decoration: underline; }
.ao-meta { margin: .35rem 0 0; display: flex; flex-wrap: wrap; gap: .15rem 1rem; font-size: .86rem; color: var(--muted); }
.ao-buyer { color: var(--ink-2); font-weight: 500; }
.ao-why { margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; font-size: .82rem; }
.ao-why-label { color: var(--muted); margin-right: .25rem; }
.ao-side { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; text-align: right; }
.ao-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.ao-kind, .ao-owner { font-size: .82rem; color: var(--muted); }
.quickstatus { width: 100%; max-width: 170px; margin-top: .2rem; }
.status-select { padding: .4rem .5rem; font-size: .88rem; }
.st-none { color: var(--muted); border-style: dashed; }
.st-go, .st-en_preparation { border-color: var(--ok); color: var(--ok); background: var(--ok-wash); }
.st-depose, .st-gagne { border-color: var(--brand); color: var(--brand-deep); background: var(--brand-wash); }
.st-no_go, .st-perdu { color: var(--muted); }

.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.25rem; color: var(--muted); }
.empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 1.5rem; color: var(--ink-2); }
.empty p { margin: 0 0 .35rem; }

/* ---------- fiche consultation */
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.detail-head { --urgency: var(--brand); display: grid; grid-template-columns: 150px 1fr; gap: 1.5rem; align-items: start; }
.detail-head h1 { font-size: 1.45rem; max-width: 60ch; }
.detail-due .ao-count { font-size: 2.6rem; }
.detail-buyer { margin: .2rem 0 0; color: var(--ink-2); font-weight: 500; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 1.5rem; margin: 1.5rem 0 0; padding: 1.25rem 0 0; border-top: 1px solid var(--line); }
.facts dt { font-size: .82rem; color: var(--muted); }
.facts dd { margin: .15rem 0 0; font-weight: 500; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 1.5rem 0 0; }
.detail-actions .hint { margin: 0; }
.why { margin-top: 1.5rem; }
.why h2 { font-size: 1rem; margin-bottom: .4rem; }
.why ul { margin: 0; padding-left: 1.1rem; }
.why li { margin-bottom: .3rem; }
.why mark { margin-right: .25rem; }

.pursuit { margin-top: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.pursuit > h2 { margin-bottom: 1rem; }
.pursuit-form { display: grid; gap: 1.5rem; }
.pursuit-grid { display: grid; grid-template-columns: 1fr; gap: 1rem 1.5rem; }
.pursuit-grid > label:not(.notes) { max-width: 320px; }
.pursuit-grid .status-choices { grid-column: 1 / -1; }
.pursuit-grid .notes { grid-column: 1 / -1; }
.status-choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.status-choices legend { width: 100%; }
.status-choice { position: relative; }
.status-choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.status-choice span {
  display: inline-block; padding: .45rem .85rem; border: 1px solid var(--line-strong); border-radius: 999px;
  font-weight: 500; font-size: .9rem; cursor: pointer;
}
.status-choice input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.status-choice input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.status-choice.status-go input:checked + span, .status-choice.status-en_preparation input:checked + span { background: var(--ok); border-color: var(--ok); }
.status-choice.status-no_go input:checked + span, .status-choice.status-perdu input:checked + span { background: var(--muted); border-color: var(--muted); }
.checklist ul { list-style: none; margin: 0 0 .75rem; padding: 0; columns: 2; column-gap: 2rem; }
.checklist li { break-inside: avoid; padding: .3rem 0; }
.checklist li label { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; font-size: .93rem; }
.checklist li input[type=checkbox] { margin-top: .25rem; width: auto; }
.checklist input:checked ~ span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.progress { font-weight: 400; color: var(--muted); font-size: .9rem; margin-left: .4rem; }
.new-item { max-width: 420px; }

/* ---------- suivi (tableau) */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
.column { background: #E9EEF5; border-radius: var(--radius); padding: .75rem; min-height: 120px; }
.column h2 { font-size: .98rem; display: flex; justify-content: space-between; margin-bottom: .6rem; padding: 0 .2rem; }
.column-count { color: var(--muted); font-weight: 500; }
.column ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.column-empty { color: var(--muted); font-size: .9rem; margin: .2rem; }
.card { --urgency: var(--brand); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--urgency); border-radius: 6px; padding: .65rem .75rem; }
.card.ao--critical { --urgency: var(--critical); }
.card.ao--soon { --urgency: var(--soon); }
.card-title { font-weight: 600; font-size: .9rem; line-height: 1.35; color: var(--ink); text-decoration: none; }
.card-title:hover { text-decoration: underline; }
.card-buyer { margin: .25rem 0 0; font-size: .8rem; color: var(--muted); }
.card-meta { margin: .4rem 0 0; display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; }
.card-due { font-family: var(--condensed); font-weight: 600; color: var(--urgency); font-size: .9rem; }
.card-progress, .card-owner { color: var(--muted); }
.card-owner { margin: .2rem 0 0; font-size: .8rem; }
.archive { margin-top: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; }
.archive summary { cursor: pointer; font-weight: 600; }
.archive .table { margin-top: .75rem; }

/* ---------- profils */
.profiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.profile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.profile-off { opacity: .7; }
.profile-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.profile-head h2 a { color: var(--ink); text-decoration: none; }
.profile-head h2 a:hover { text-decoration: underline; }
.profile-count { font-size: .9rem; }
.profile-terms { margin: .6rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.profile-terms .more { color: var(--muted); font-size: .85rem; align-self: center; }
.profile-excl { margin: .5rem 0 0; color: var(--muted); font-size: .86rem; }
.badge { font-size: .78rem; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 999px; padding: .1rem .55rem; color: var(--muted); }

/* ---------- collecte et tables */
.actions-stack { display: grid; gap: .5rem; justify-items: stretch; min-width: 240px; }
.actions-stack .btn { width: 100%; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .92rem; }
.table th, .table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-weight: 600; color: var(--muted); font-size: .82rem; background: #F8FAFC; }
.table th.num, .table td.num { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.run-badge { font-size: .8rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--paper); white-space: nowrap; }
.run-badge.run-ok { background: var(--ok-wash); color: var(--ok); }
.run-badge.run-partial { background: var(--soon-wash); color: var(--soon); }
.run-badge.run-error { background: var(--critical-wash); color: var(--critical); }
.run-badge.run-running { background: var(--brand-wash); color: var(--brand-deep); }
.run-msg { color: var(--muted); font-size: .85rem; max-width: 46ch; }

/* ---------- connexion */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.login-page .flashes { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); width: min(420px, 90vw); }
.login { width: min(420px, 100%); }
.login-brand { color: #fff; margin-bottom: 1.5rem; }
.login-brand .brand-mark { color: #7FB0FF; margin-bottom: .75rem; }
.login-brand h1 { font-size: 1.6rem; }
.login-brand p { color: #AFC0DA; margin: 0; }
.login-form { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; display: grid; gap: 1rem; }

/* ---------- petits écrans */
@media (max-width: 960px) {
  .board { grid-template-columns: repeat(2, 1fr); }
  .ao { grid-template-columns: 110px 1fr; }
  .ao-side { grid-column: 2; align-items: flex-start; text-align: left; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: .5rem 1rem; position: static; }
  .brand-product { display: none; }
  .mainnav { order: 3; flex: 1 0 100%; overflow-x: auto; margin: 0 -8px; }
  .mainnav a { white-space: nowrap; padding: .4rem .6rem; }
  .usermenu { margin-left: auto; }
  .page { padding: 20px 16px 48px; }
  .summary-with-action { flex-direction: column; gap: 1rem; }
  .actions-stack { width: 100%; }
  .filters-more > summary { display: list-item; cursor: pointer; font-weight: 500; color: var(--brand-deep); }
  .filters-more[open] > summary { margin-bottom: .25rem; }
  .ao { grid-template-columns: 1fr; gap: .6rem; }
  .ao-due { flex-direction: row; align-items: baseline; gap: .6rem; }
  .ao-count { font-size: 1.6rem; }
  .ao-side { grid-column: 1; }
  .detail-head { grid-template-columns: 1fr; gap: .75rem; }
  .facts { grid-template-columns: 1fr; }
  .pursuit-grid { grid-template-columns: 1fr; }
  .checklist ul { columns: 1; }
  .board { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
