/* Mon espace : mode « portefeuille » (beaucoup d'adresses).
   Variables du site uniquement. Chargé après le CSS de la page. */

/* ── Grille de page ── */
.pg-compte #main > .cols { grid-template-columns: minmax(0, 1fr); }
.pg-compte .kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi--urgent .kpi__value { color: var(--alert-red); }
.kpi--urgent.is-zero .kpi__value { color: var(--green); }

/* ── Mises à l’enquête à surveiller ── */
.pf-urgent[hidden] { display: none; }
.pf-urgent { border-left: 4px solid var(--alert-red); }
.pf-urgent.is-zero { border-left-color: var(--green); }
.pf-urgent .card__head { align-items: baseline; flex-wrap: wrap; }
.pf-pill { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 12px; background: var(--alert-bg); color: var(--alert-red); white-space: nowrap; }
.pf-urgent.is-zero .pf-pill { background: var(--green-bg); color: var(--green); }
.pf-sub { font-size: 14px; line-height: 1.55; color: var(--ink-70); margin: -6px 0 14px; }
.pf-item { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 8px 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--ink-15); }
.pf-item__when { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.pf-item__when small { font-size: 12px; color: var(--ink-70); line-height: 1.3; }
.pf-days { display: inline-block; font-size: 13px; font-weight: 700; border-radius: 999px; padding: 4px 11px; background: var(--amber-bg); color: #8a5a00; border: 1px solid rgba(245, 158, 11, .35); white-space: nowrap; }
.pf-days--soon { background: var(--alert-bg); color: var(--alert-red); border-color: rgba(220, 38, 38, .3); }
.pf-item__title { font-size: 15px; font-weight: 600; color: var(--sapin-dark); line-height: 1.35; overflow-wrap: anywhere; }
.pf-item__meta { font-size: 13.5px; color: var(--ink-70); margin-top: 3px; line-height: 1.45; }
.pf-item__meta b { color: var(--ink); font-weight: 600; }
.pf-item__more { color: var(--ink-70); }
.pf-item__addr { font-size: 12.5px; color: var(--ink-40); margin-top: 2px; overflow-wrap: anywhere; }
.pf-item__act { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pf-item__act .btn { padding: 9px 14px; font-size: 13px; min-height: 40px; }
.pf-more { margin-top: 6px; min-height: 44px; }
.pf-more[hidden] { display: none; }
.pf-foot { font-size: 13px; color: var(--ink-70); margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--ink-15); }
.pf-foot a { color: var(--sapin-dark); font-weight: 600; }
.pf-empty { font-size: 14px; line-height: 1.6; color: var(--ink-70); }
.pf-empty strong { color: var(--green); }

/* ── Espace de travail : liste d'adresses + carte ── */
.pf-ws { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.pf-ws > .card { margin-bottom: 0; }
.pf-ws .perim-card.has-map { grid-template-columns: minmax(0, 1fr); }
.pf-ws .perim-card .pmap-view { margin-top: 14px; }
.pf-ws .perim-card .pmap-info { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--ink-15); }
.pf-ws .perim-card .perim-main { min-width: 0; }
@media (min-width: 1240px) {
  .pf-ws.pf-ws--split { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .pf-ws.pf-ws--split .perim-card { position: sticky; top: 84px; }
}

/* ── Liste d'adresses ── */
#addr-card .card__head { flex-wrap: wrap; align-items: baseline; }
.pf-quota { font-size: 13px; font-weight: 600; color: var(--ink-70); background: var(--parchment2); border-radius: 999px; padding: 3px 11px; }
.pf-bar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.pf-search { position: relative; }
.pf-search input { width: 100%; min-height: 44px; padding: 10px 40px 10px 40px; border: 1px solid #c9d3de; border-radius: var(--radius); font-size: 14.5px; font-family: var(--font-body); background: #fff; color: var(--ink); }
.pf-search input:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--sapin); }
.pf-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-40); pointer-events: none; }
.pf-search .pf-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: transparent; color: var(--ink-70); font-size: 20px; line-height: 1; cursor: pointer; border-radius: 8px; }
.pf-search .pf-clear[hidden] { display: none; }
.pf-search .pf-clear:hover { background: var(--parchment); }
.pf-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pf-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid #c9d3de; border-radius: 999px; background: #fff; color: var(--ink); font: 600 13.5px var(--font-body); cursor: pointer; }
.pf-chip b { font-variant-numeric: tabular-nums; font-size: 12px; background: var(--parchment2); color: var(--sapin); border-radius: 999px; padding: 1px 8px; }
.pf-chip[aria-pressed="true"] { background: var(--sapin); border-color: var(--sapin); color: #fff; }
.pf-chip[aria-pressed="true"] b { background: rgba(255, 255, 255, .2); color: #fff; }
.pf-chip:disabled { opacity: .5; cursor: default; }
.pf-chip:focus-visible, .pf-sel:focus-visible, .pf-pg button:focus-visible, .pf-item .btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.pf-sel { min-height: 40px; padding: 0 10px; border: 1px solid #c9d3de; border-radius: var(--radius); background: #fff; font: 500 13.5px var(--font-body); color: var(--ink); max-width: 100%; }
.pf-sel[hidden] { display: none; }
#adresses-list.pf-on { display: flex; flex-direction: column; max-height: none; overflow: visible; padding-right: 0; }
#adresses-list .adresse-row[hidden] { display: none !important; }
#adresses-list.has-map-list .adresse-row { grid-template-columns: 10px minmax(0, 1fr) auto auto; grid-template-areas: "dot label open tag" "dot text text text"; }
#adresses-list.has-map-list .adresse-open { grid-area: open; align-self: center; }
.adresse-open { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 9px; white-space: nowrap; background: var(--alert-bg); color: var(--alert-red); }
.adresse-open.is-none { background: transparent; color: var(--ink-40); font-weight: 500; }
.adresse-open[hidden] { display: none; }
.pf-pg { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pf-pg[hidden] { display: none; }
.pf-pg span { font-size: 13px; color: var(--ink-70); font-variant-numeric: tabular-nums; }
.pf-pg .btn { min-height: 40px; padding: 8px 14px; font-size: 13px; }
.pf-pg button:disabled { opacity: .45; cursor: default; }
.pf-none { border: 1px dashed var(--ink-15); border-radius: var(--radius); padding: 14px; font-size: 14px; color: var(--ink-70); line-height: 1.55; }
.pf-none button { margin-left: 6px; }
.pf-edit-filter { width: 100%; min-height: 44px; padding: 10px 12px; margin-bottom: 12px; border: 1px solid #c9d3de; border-radius: var(--radius); font-size: 14.5px; font-family: var(--font-body); }
#address-rows .addr-row[hidden] { display: none !important; }

/* ── Mobile ── */
@media (max-width: 640px) {
  .pf-item { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .pf-item__when { flex-direction: row; align-items: center; gap: 10px; }
  .pf-item__act { justify-content: flex-start; }
  .pf-item__act .btn { flex: 1 1 auto; text-align: center; }
  #adresses-list.has-map-list .adresse-row { grid-template-columns: 10px minmax(0, 1fr); grid-template-areas: "dot label" "dot text" "dot open" "dot tag"; row-gap: 4px; }
  #adresses-list.has-map-list .adresse-open, #adresses-list.has-map-list .adresse-tag { justify-self: start; }
  .pf-filters .pf-chip { flex: 1 1 auto; justify-content: center; }
  .pf-sel { flex: 1 1 100%; }
  .pf-pg .btn { flex: 1 1 auto; }
}

/* ── Sections en onglets ── */
#main.pf-tabs > [data-pf-panel]:not(.pf-active) { display: none !important; }
#main.pf-tabs > .pf-urgent.pf-active[hidden] { display: none !important; }
.pg-compte #main.pf-tabs > .a-side { grid-row: 1 / span 20; }
.a-side a { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.a-side a[hidden] { display: none !important; }
.a-side .pf-tab-n { font-size: 12px; font-weight: 700; background: var(--alert-red); color: #fff; border-radius: 999px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.a-side .pf-tab-n[hidden] { display: none; }
.a-side .pf-tab-ext { margin-top: 10px; border-top: 1px solid var(--ink-15); border-radius: 0; padding-top: 14px; color: var(--sapin-dark); font-weight: 600; }
.a-side a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.kpi--link { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.kpi--link:hover { border-color: var(--sapin); box-shadow: var(--shadow-sm); }
.kpi--link:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
@media (max-width: 900px) {
  .pg-compte #main.pf-tabs > * { grid-column: 1; }
  .pg-compte #main.pf-tabs > .a-side {
    display: flex; flex-direction: row; gap: 6px; overflow-x: auto; position: sticky; top: 0; z-index: 50;
    grid-row: auto; margin: 0 -18px; padding: 10px 18px; background: var(--parchment); border-bottom: 1px solid var(--ink-15);
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .pg-compte #main.pf-tabs > .a-side::-webkit-scrollbar { display: none; }
  .pg-compte #main.pf-tabs > .a-side a { flex: none; white-space: nowrap; padding: 10px 14px; min-height: 44px; font-size: 14px; background: #fff; border-color: var(--ink-15); }
  .pg-compte #main.pf-tabs > .a-side a.on { background: var(--sapin); color: #fff; border-color: var(--sapin); }
  .a-side .pf-tab-ext { margin-top: 0; border-top: 1px solid var(--ink-15); border-radius: 8px; padding-top: 10px; }
}

/* Ordre des onglets : glisser-déposer */
.a-side a[role="tab"], .a-side a.pf-tab-ext { cursor: grab; touch-action: pan-x pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.a-side.pf-sorting, .a-side.pf-sorting a { cursor: grabbing; }
/* Poignée : deux petits traits à gauche de chaque onglet */
.a-side a[role="tab"], .a-side a.pf-tab-ext { justify-content: flex-start; position: relative; transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease, background-color .15s ease; transform-origin: left center; }
.a-side a[role="tab"] > span:first-child { margin-right: auto; }
.a-side a[role="tab"]::before, .a-side a.pf-tab-ext::before { content: ""; flex: none; width: 12px; height: 8px; margin-right: 10px; opacity: .38; transition: opacity .15s ease;
  background: linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat, linear-gradient(currentColor, currentColor) 0 6px / 100% 2px no-repeat; }
.a-side a[role="tab"]:hover::before, .a-side a[role="tab"]:focus-visible::before, .a-side a.pf-tab-ext:hover::before, .a-side a.pf-tab-ext:focus-visible::before { opacity: .75; }
/* Onglet saisi : +10 %, mis en avant ; les autres s'estompent */
.a-side a.pf-dragging { background: #fff; box-shadow: 0 10px 26px rgba(30, 41, 59, .30); border-radius: 10px; position: relative; z-index: 5; opacity: 1; transform: scale(1.1); transition: transform .15s ease, box-shadow .15s ease; }
.a-side a.pf-dragging::before { opacity: .9; }
.a-side.pf-sorting a:not(.pf-dragging) { opacity: .6; }
@media (max-width: 899px) { .a-side a[role="tab"]::before, .a-side a.pf-tab-ext::before { margin-right: 7px; width: 10px; } .a-side a.pf-dragging { transform-origin: center; } }
@media (prefers-reduced-motion: reduce) { .a-side a[role="tab"], .a-side a.pf-tab-ext, .a-side a.pf-dragging { transition: none; } }

/* Historique placé ailleurs qu'en dernier : plus de filet de séparation */
.a-side a.pf-tab-ext.pf-tab-ext--mid { margin-top: 0; border-top: 0; border-top-color: transparent; border-radius: 8px; padding-top: 12px; }
.a-side a.pf-tab-ext.pf-dragging { border-radius: 10px; margin-top: 0; }

/* Filtre « Responsable » (cases à cocher) */
.pf-resp { position: relative; }
.pf-resp[hidden] { display: none; }
.pf-resp__btn { cursor: pointer; font-weight: 600; }
.pf-resp__btn.is-on { background: var(--sapin); border-color: var(--sapin); color: #fff; }
.pf-resp__pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 230px; max-width: min(320px, 86vw); max-height: 320px; overflow: auto; padding: 8px; background: #fff; border: 1.5px solid var(--sapin); border-radius: 10px; box-shadow: 0 6px 18px rgba(15, 37, 64, .22); }
.pf-resp__pop[hidden] { display: none; }
.pf-resp__o { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font: 500 14px var(--font-body); color: var(--ink); cursor: pointer; }
.pf-resp__o:hover { background: var(--parchment2); }
.pf-resp__o input { width: 18px; height: 18px; accent-color: var(--sapin); flex: none; }
.pf-resp__o span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pf-resp__o b { font-variant-numeric: tabular-nums; font-size: 12px; background: var(--parchment2); color: var(--sapin); border-radius: 999px; padding: 1px 8px; }
@media (max-width: 700px) { .pf-resp { flex: 1 1 100%; } .pf-resp__btn { width: 100%; } }
