/* Topo · admin : composants propres au phasage (en plus d'admin.css, repris de Balise) */

/* Couleurs des états d'une phase : gris = à venir, encre = en cours, mauve = soumise, orange = modifications, vert = validée */
:root { --ph-upcoming: #9A948C; --ph-open: #121212; --ph-submitted: var(--st-pending); --ph-changes: var(--st-changes); --ph-validated: var(--st-approved); }
.status.st-upcoming { color: var(--ph-upcoming); }
.status.st-open { color: var(--ph-open); }
.status.st-submitted { color: var(--ph-submitted); }
.status.st-changes { color: var(--ph-changes); }
.status.st-validated { color: #15803D; } /* texte : vert foncé, lisible ; les aplats prennent --ph-validated */

.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--fg); text-decoration: underline; cursor: pointer; }
.pop-link { display: block; font: 600 13.5px/1.2 var(--font); padding: 9px 10px; text-decoration: none; }
.pop-link:hover { background: var(--bg-2); }
.notice { border: 1px solid var(--line-strong); background: var(--paper); padding: 12px 16px; margin: 0 0 16px; font-size: 14px; border-left: 4px solid var(--ink); }
.notice-warn { border-left-color: var(--warn); background: var(--warn-bg); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spread { justify-content: space-between; align-items: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar select { width: auto; min-width: 200px; }
.inline-label { flex-direction: row; align-items: center; gap: 6px; font-weight: 600; }
.inline-label input { width: auto; }
.inline-form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form-row input:not([type=date]):not([type=checkbox]):not([type=radio]):not([type=hidden]) { flex: 1 1 220px; width: auto; }
.inline-form-row label.check { flex: 0 0 auto; white-space: nowrap; }
.inline-form-row input[type=date] { width: auto; }
.copy-row { display: flex; gap: 8px; margin: 10px 0; }
.copy-row input { font-size: 12.5px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line-strong); }
.table td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table a { text-decoration: none; }
.table .num { text-align: right; }
.t-actions { text-align: right; }
.table-scroll { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.foot-note { margin-top: 12px; }
.kpi-tile { text-decoration: none; color: inherit; }
.kpi-tile.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.kpi-tile b.kpi-money { font-size: 30px; }
.danger { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.danger form { display: flex; flex-direction: column; gap: 4px; }

/* Cartes de projet */
.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
/* align-items : annule le centrage hérité de la carte de Balise (admin.css), qui écrasait la barre de progression */
.project-card { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 18px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 2px; text-decoration: none; color: inherit; }
.project-card:hover { border-color: var(--ink); }
.pc-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pc-client { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pc-title { font: 800 22px/1 var(--head); font-stretch: 85%; text-transform: uppercase; }
.pc-now { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.progress { display: block; height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ph-validated); }

/* Liste des contacts */
.contact-list { display: flex; flex-direction: column; margin: 12px 0; border-top: 1px solid var(--line); }
.contact-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.contact-row.is-off .contact-id b { color: var(--muted); }
.contact-id { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.contact-id .muted { flex-basis: 100%; }
.contact-acts { display: flex; gap: 6px; align-items: center; }
.contact-edit { grid-column: 1 / -1; }
.contact-edit form, .contact-add form { margin-top: 12px; }
.invite-link { margin-bottom: 18px; }

/* Modèle de phases (types) */
.phase-edit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.phase-edit { padding: 0; }
.phase-edit details > form { padding: 0 18px 18px; }
.phase-edit-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none; }
.phase-edit-head::-webkit-details-marker { display: none; }
.phase-edit-head b { flex: 1; }
.drag { cursor: grab; color: var(--muted); letter-spacing: -3px; font-weight: 700; }
.phase-num { width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 700; }
.sortable-ghost { opacity: .4; }
fieldset.billing-fields, fieldset.reopen-origin { border: 1px solid var(--line-strong); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; margin: 0; }
fieldset.billing-fields legend, fieldset.reopen-origin legend { font-weight: 700; font-size: 13px; padding: 0 6px; }
fieldset.billing-fields[disabled] { opacity: .7; }

/* Page projet : frise verticale et détail de la phase */
.proj-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
.phase-rail { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 12px; }
.rail { list-style: none; margin: 0; padding: 0; position: relative; }
.rail::before { content: ""; position: absolute; left: 15px; top: 16px; bottom: 16px; width: 2px; background: var(--line-strong); }
.rail-item a { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 8px 10px 8px 0; text-decoration: none; color: inherit; border-radius: 2px; }
.rail-item a:hover .rail-text b { text-decoration: underline; }
.rail-item.on .rail-text { background: var(--paper); box-shadow: 0 0 0 1px var(--ink); }
.rail-mark { position: relative; z-index: 1; flex: 0 0 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: var(--bg); border: 2px solid var(--ph-upcoming); color: var(--ph-upcoming); }
.rail-text { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; min-width: 0; }
.rail-text b { font-size: 14px; line-height: 1.2; }
.rail-text .small { color: var(--muted); }
.rail-item.st-open .rail-mark { border-color: var(--ph-open); color: var(--ph-open); }
.rail-item.st-submitted .rail-mark { border-color: var(--ph-submitted); background: var(--ph-submitted); color: #fff; }
.rail-item.st-changes .rail-mark { border-color: var(--ph-changes); background: var(--ph-changes); color: #fff; }
.rail-item.st-validated .rail-mark { border-color: var(--ph-validated); background: var(--ph-validated); color: #fff; }
.rail-item.is-upcoming a { cursor: grab; }
.rail-add form { margin-top: 10px; }
.phase-detail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pd-head { display: flex; flex-direction: column; gap: 14px; border-top: 4px solid var(--ph-upcoming); }
.pd-head.st-open { border-top-color: var(--ph-open); }
.pd-head.st-submitted { border-top-color: var(--ph-submitted); }
.pd-head.st-changes { border-top-color: var(--ph-changes); }
.pd-head.st-validated { border-top-color: var(--ph-validated); }
.pd-head h2 { font-size: clamp(26px, 3vw, 36px); margin: 6px 0 8px; }
.pd-facts { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); }
.pd-facts span { display: inline-flex; align-items: center; gap: 5px; }
.pd-actions { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.submit-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.submit-form label { flex: 0 0 auto; }
.submit-form .help { flex-basis: 100%; }
.force-box form { margin-top: 10px; max-width: 520px; }
.pd-text { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.pd-text h3 { margin-top: 0; }
.changes-box { border-left: 4px solid var(--ph-changes); }
.reopen-box { border-left: 4px solid var(--danger); }
.changes-box h3, .reopen-box h3 { margin-top: 0; }
.phase-settings > summary { cursor: pointer; list-style: none; }
.phase-settings > summary h2 { margin: 0; display: inline; }
.phase-settings > summary::after { content: " +"; font-weight: 800; }
.phase-settings[open] > summary::after { content: " −"; }
.phase-settings form { margin-top: 16px; }
.add-box form { margin-top: 12px; }

/* Livrables, éléments, fichiers */
.deliv-list, .item-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.deliv { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.deliv-link { display: inline-flex; gap: 8px; align-items: center; text-decoration: none; }
.deliv > form { margin-left: auto; }
.file-grid { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.file-tile { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; gap: 0 10px; align-items: center; padding: 6px 10px 6px 6px; border: 1px solid var(--line-strong);
  background: var(--paper); text-decoration: none; color: inherit; max-width: 320px; }
.file-tile:hover { border-color: var(--ink); }
.file-tile img, .file-ext { grid-row: 1 / 3; width: 44px; height: 44px; object-fit: cover; display: grid; place-items: center; background: var(--bg-2); font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11.5px; color: var(--muted); }
.item-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.item-main { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item-check { width: 20px; height: 20px; border: 2px solid var(--line-mid); display: inline-grid; place-items: center; flex: 0 0 auto; }
.item-row.is-done .item-check { background: var(--ph-validated); border-color: var(--ph-validated); color: #fff; }
.item-row.is-done b { text-decoration: line-through; color: var(--muted); }
.item-note { margin: 6px 0 0 28px; color: var(--muted); }
.item-edit { margin: 6px 0 0 28px; }
.item-edit form { margin-top: 8px; }
.add-item { margin-top: 8px; }

/* Échanges */
.threads { display: flex; flex-direction: column; gap: 12px; margin: 12px 0 16px; }
.msg { border: 1px solid var(--line-strong); background: var(--paper); padding: 12px 14px; }
.msg.from-client { border-left: 4px solid var(--ph-submitted); }
.msg.from-client.is-resolved { border-left-color: var(--ph-validated); }
.msg-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.msg-menu { margin-left: auto; }
.msg-text { margin-top: 6px; white-space: normal; overflow-wrap: anywhere; }
.msg-reply { margin: 10px 0 0 18px; padding-left: 12px; border-left: 2px solid var(--line-strong); }
.reply-box { margin-top: 8px; }
.reply-box form { margin-top: 8px; }
.reply-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.reply-foot input[type=file] { flex: 1 1 200px; }
.assign-form select { font-size: 13px; padding: 6px 8px; }
.new-msg { border-top: 1px solid var(--line); padding-top: 14px; }

/* Décisions */
.review-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.review-list li { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.review-list details { flex-basis: 100%; }
.notice-proof { white-space: pre-wrap; font: 13px/1.5 var(--font); background: var(--bg-2); padding: 10px 12px; margin: 6px 0 0; }

/* Historique */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.mini-lines { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mini-lines li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 13px; }
.mini-lines .pill { justify-self: start; }

/* Accueil « À faire » */
.todo-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; align-items: start; }
.todo-block { margin-bottom: 24px; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo-list a { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line-strong); background: var(--card); text-decoration: none; color: inherit; }
.todo-list a:hover { border-color: var(--ink); }
.todo-list .muted.small, .todo-list .sch-late, .todo-list .sch-soon { flex-basis: 100%; }
.todo-quote { color: var(--muted); }

/* Facturation */
.billing-table select { font-size: 13px; padding: 6px 8px; width: auto; }
.bl-details { display: flex; gap: 6px; align-items: center; }
.bl-details input { font-size: 13px; padding: 6px 8px; min-width: 110px; }
.bl-cancelled td { opacity: .55; }

@media (max-width: 1100px) {
  .proj-grid { grid-template-columns: 1fr; }
  .phase-rail { position: static; }
}

/* Zone de dépôt et progression des envois (upload.js) */
.drop { position: relative; border: 1px dashed var(--line-mid); background: var(--paper); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; font-weight: 400; }
.drop.is-over { border-color: var(--ink); background: var(--accent-pale); }
.drop-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-hint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.drop-btn { font: 600 13px/1 var(--font); padding: 8px 12px; border: 1px solid var(--line-mid); background: var(--bg); color: var(--fg); border-radius: 2px; cursor: pointer; }
.drop-btn:hover { border-color: var(--ink); }
.drop-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.drop-list:empty { display: none; }
.drop-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; font-size: 13px; padding: 6px 8px; background: var(--bg-2); }
.drop-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-size { color: var(--muted); font-variant-numeric: tabular-nums; }
.drop-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 0 4px; }
.drop-x:hover { color: var(--danger); }
.drop-error { color: var(--danger); font-size: 13px; }
.up-progress { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line-strong); background: var(--paper); }
.up-progress .up-bar { grid-column: 1 / -1; height: 8px; background: var(--bg-2); overflow: hidden; }
.up-progress .up-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.up-label { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.up-cancel { border: 0; background: none; font: 600 13px/1 var(--font); text-decoration: underline; cursor: pointer; color: var(--muted); }

/* Filtre des échanges */
.card-head .thread-filter { margin-left: auto; }
.thread-filter { display: inline-flex; gap: 2px; padding: 3px; background: var(--bg-2); border: 1px solid rgba(18,18,18,.18); border-radius: 2px; }
.thread-filter button { border: 0; background: none; font: 600 12.5px/1 var(--font); padding: 6px 10px; border-radius: 2px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.thread-filter button b { font-weight: 700; margin-left: 2px; }
.thread-filter button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* Paiement sur la frise de l'admin, date de paiement */
.rail-pay { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.rail-pay.pay-invoiced { color: var(--warn); }
.rail-pay.pay-paid { color: var(--ok); }
.rail-pay.pay-hold { color: var(--st-pending); }
.paid-on { margin-top: 6px; }
.paid-on input { padding: 4px 6px; font-size: 12.5px; width: auto; }

/* Bloc « Facturation » d'une phase validée : rouge tant que la facture reste à faire */
.bill-box { border-left: 5px solid var(--line-strong); }
.bill-box.state-to_invoice { border-color: var(--danger); background: var(--danger-bg); }
.bill-box.state-to_invoice h2, .bill-box.state-to_invoice .rail-pay { color: var(--danger); }
.bill-box.state-invoiced { border-left-color: var(--warn); }
.bill-box.state-paid { border-left-color: var(--ok); }
.bill-box.state-hold { border-left-color: var(--st-pending); }
.bill-box p { margin: 8px 0; }
.rail-pay.pay-to_invoice { color: var(--danger); }

/* Livrables en grille : côte à côte, ou l'un au-dessus de l'autre sur un écran étroit */
.deliv-grid { list-style: none; margin: 12px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.deliv-grid .deliv { position: relative; padding: 0; border: 0; display: block; }
.deliv-grid .file-tile { max-width: none; height: 100%; grid-template-rows: auto auto auto; padding-right: 40px; }
.deliv-grid .file-tile img, .deliv-grid .file-ext { grid-row: 1 / 4; }
.deliv-grid .deliv > form { position: absolute; top: 6px; right: 6px; margin: 0; }
.deliv-grid .deliv > form .icon-btn { width: 26px; height: 26px; }
.file-meta { font-size: 11.5px; color: var(--muted); }
.deliv-link .file-ext { color: var(--fg); }
.proof { border-left: 3px solid var(--ok); padding-left: 10px; margin: 8px 0; }
.submit-form .submit-note { flex: 1 1 100%; }
.force-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 10px; }
.force-choices form { border: 1px solid var(--line-strong); background: var(--paper); padding: 14px; }
.force-choices h3 { margin: 0; }
.force-box form { max-width: none; margin-top: 0; }
/* « € » à côté d'une phase facturable (frise de l'admin) */
.rail-euro { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-left: 6px; border-radius: 50%; background: var(--bg-2); color: var(--muted);
  font-size: 10.5px; font-weight: 800; vertical-align: 1px; cursor: help; }
.planning-card .card-head { align-items: center; }
.planning-card .foot-note { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

/* Demande de retour en cours : bandeau en haut de la fiche projet, repère sur la frise, étiquette sur la carte */
.reopen-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0 0 16px; padding: 12px 16px;
  border: 1px solid var(--st-changes); border-left-width: 5px; background: var(--warn-bg); }
.reopen-banner > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reopen-banner b { color: var(--st-changes); }
.reopen-banner.st-quoted { border-color: var(--line-strong); border-left-color: var(--st-changes); background: var(--paper); }
.rail-item.has-reopen .rail-mark { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--st-changes); }
.rail-reopen { font-size: 11.5px; font-weight: 700; color: var(--st-changes); }
.pc-pills { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: 0 1 auto; }

/* Champs numériques : même apparence que les autres (admin.css de Balise ne les prévoyait pas) */
input[type=number], input[type=url], input[type=search], input[type=tel] {
  font: inherit; font-size: 14px; font-weight: 400; color: var(--fg); background: var(--paper);
  border: 1px solid rgba(18,18,18,.22); border-radius: 2px; padding: 10px 12px; width: 100%;
}
input[type=number]:hover, input[type=url]:hover { border-color: rgba(18,18,18,.45); }
input[type=number]:focus, input[type=url]:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-pale); }

/* Fil d'Ariane : liens (inline-flex avec icône) et séparateur sur la même ligne */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Rapport PDF : menu déroulant sous le bouton, dans l'en-tête du projet */
.report-menu { position: relative; }
.report-menu > summary { list-style: none; cursor: pointer; }
.report-menu > summary::-webkit-details-marker { display: none; }
.report-menu .report-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 320px; background: var(--surface, #fff); border: 1px solid var(--line-strong); box-shadow: 0 10px 30px rgba(18, 18, 18, .14); padding: 14px 16px; gap: 10px; }
.report-menu .report-form p { margin: 0; }
