/* Styles propres à chaque page */

.section-gap { margin-bottom: var(--s5); }
.section-title { font-size: var(--fs-md); font-weight: 700; margin: var(--s4) 0 var(--s2); color: var(--text-2); }

/* ---------- Connexion ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s4);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dfe8dc 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #f1e4c6 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  padding: var(--s8) var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  text-align: center;
}
.login-card .field { text-align: left; }
.login-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: var(--r-lg); }
.pin-input { font-size: 1.5rem; letter-spacing: 0.4em; text-align: center; min-height: 56px; }
.login-note { margin-top: var(--s2); }

/* ---------- Accueil ---------- */
.quick-actions .btn-lg { font-size: var(--fs-md); }
.home-kpis { margin-bottom: var(--s5); }
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s4);
  align-items: start;
}
.home-upcoming, .home-unpaid { grid-column: span 2; }
@media (max-width: 960px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .home-upcoming, .home-unpaid { grid-column: auto; }
}
.home-grid .right, .list-item .right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }

/* ---------- Agenda ---------- */
.agenda-toolbar, .fin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3) var(--s4);
  margin-bottom: var(--s4);
}
.agenda-nav { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.agenda-title { font-size: var(--fs-lg); margin-left: var(--s2); }
.type-filters { margin-bottom: var(--s4); align-items: center; }
.type-chip .swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--type-color); }
.type-chip[aria-pressed='false'] { opacity: 0.6; text-decoration: line-through; }
.type-chip[aria-pressed='true'] { background: var(--type-soft); color: var(--text); border-color: var(--type-color); }

.month { overflow: hidden; margin-bottom: var(--s4); }
.month-head, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-head div { padding: var(--s2); text-align: center; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.day {
  min-height: 112px;
  padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  min-width: 0;
  background: var(--surface);
}
.day:nth-child(7n) { border-right: 0; }
.day:hover { background: #f7f6f1; }
.day.out { background: #f4f3ee; }
.day.out .day-num { color: #8a918c; }
.day.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.day-num { font-weight: 700; font-size: var(--fs-sm); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.day.today .day-num { background: var(--primary); color: var(--text-on-primary); }
.day-events { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ev-chip {
  display: flex;
  gap: 4px;
  align-items: center;
  width: 100%;
  min-height: 24px;
  padding: 1px 6px;
  border: 0;
  border-left: 3px solid var(--type-color);
  border-radius: 4px;
  background: var(--type-soft);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: left;
  overflow: hidden;
}
.ev-chip:hover { filter: brightness(0.96); }
.ev-chip.option { background: repeating-linear-gradient(135deg, var(--type-soft) 0 6px, #ffffff 6px 9px); }
.ev-chip.cancelled { opacity: 0.55; text-decoration: line-through; }
.ev-time { color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; }
.ev-time:empty { display: none; }
.ev-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); padding-left: 6px; }
.day-dots { display: none; gap: 3px; justify-content: center; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--type-color); }
@media (max-width: 760px) {
  .day { min-height: 58px; padding: 4px 2px; align-items: center; }
  .day-events { display: none; }
  .day-dots { display: flex; }
  .agenda-title { width: 100%; margin: var(--s2) 0 0; }
}

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s2); }
.week-day { display: flex; flex-direction: column; min-height: 260px; overflow: hidden; }
.week-day.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.week-day-head { display: flex; align-items: baseline; gap: 6px; padding: var(--s2) var(--s3); background: var(--surface-2); border-bottom: 1px solid var(--border); text-transform: capitalize; }
.week-day-head strong { font-size: var(--fs-lg); }
.week-day.today .week-day-head { background: var(--primary); color: var(--text-on-primary); }
.week-day-body { padding: var(--s2); display: flex; flex-direction: column; gap: var(--s2); flex: 1; }
.week-ev {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 6px 8px; border: 0; border-left: 4px solid var(--type-color); border-radius: 6px;
  background: var(--type-soft); color: var(--text); text-align: left;
}
.week-ev-time { font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); }
.week-ev-name { font-weight: 600; font-size: var(--fs-sm); line-height: 1.25; }
.week-ev-meta { font-size: var(--fs-xs); color: var(--text-2); }
.week-add { margin-top: auto; min-height: 36px; border: 1px dashed var(--border-strong); border-radius: 6px; background: transparent; color: var(--text-muted); display: grid; place-items: center; }
.week-add:hover { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 960px) {
  .week { grid-template-columns: minmax(0, 1fr); }
  .week-day { min-height: 0; }
  .week-day-body { flex-direction: row; flex-wrap: wrap; }
  .week-ev { flex: 1 1 220px; }
  .week-add { flex: 0 0 44px; margin-top: 0; min-height: 44px; }
}
.list-month { margin-bottom: var(--s4); }
.day-detail { margin-bottom: var(--s4); }
.conflict-list { margin: 6px 0 0; padding-left: 20px; }
.space-group { margin-bottom: var(--s3); }
.space-group .hint { display: block; margin-bottom: 4px; font-weight: 600; }
.linked .list-item { padding: var(--s2) var(--s3); min-height: 44px; gap: var(--s3); }

/* ---------- Éditeur de lignes ---------- */
.lines { display: flex; flex-direction: column; gap: var(--s2); }
.lines-head, .line {
  display: grid;
  grid-template-columns: minmax(180px, 3fr) 70px 90px 110px 74px 92px 100px 40px;
  gap: var(--s2);
  align-items: center;
}
.lines-head { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; color: var(--text-2); padding: 0 2px; }
.line .lbl { display: none; }
.line .field { gap: 2px; }
.l-total { text-align: right; font-weight: 600; }
.lines-add { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s1); }
.cat-select { flex: 1 1 260px; max-width: 520px; }
.lines-totals { display: flex; justify-content: flex-end; margin-top: var(--s3); }
.lines-totals .totals, .detail-totals { min-width: min(360px, 100%); padding: var(--s3) var(--s4); background: var(--surface-2); border-radius: var(--r); }
.detail-totals { margin-left: auto; }
@media (max-width: 860px) {
  .lines-head { display: none; }
  .line {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface-2);
  }
  .line .lbl { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
  .l-lib { grid-column: 1 / -1; }
  .l-total { grid-column: 1 / 3; text-align: left; font-size: var(--fs-lg); }
  .l-del { text-align: right; }
}
.status-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--border); }

/* ---------- Factures ---------- */
.table tbody tr.row-late td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.table tbody tr.row-late { background: #fdf3f2; }
@media (max-width: 720px) { .table.responsive tr.row-late { box-shadow: inset 4px 0 0 var(--danger); } }
.type-select { width: auto; min-width: 200px; }
.pay-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); align-items: end; margin-top: var(--s3); padding: var(--s4); background: var(--surface-2); border-radius: var(--r); }
.pay-form .check { grid-column: 1 / 3; }
@media (max-width: 640px) { .pay-form { grid-template-columns: minmax(0, 1fr); } .pay-form .check { grid-column: auto; } }

/* ---------- Finances ---------- */
.fin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s4); }
@media (max-width: 960px) { .fin-grid { grid-template-columns: minmax(0, 1fr); } .fin-grid .span-2 { grid-column: auto; } }
.chart-box { position: relative; height: 280px; }
.chart-box.chart-sm { height: 200px; margin-bottom: var(--s3); }
.compact-table th, .compact-table td { padding: 8px 10px; }
.data-table { margin-top: var(--s3); }
.data-table summary { cursor: pointer; font-weight: 600; color: var(--primary); min-height: 44px; display: flex; align-items: center; }
.result-totals { padding: var(--s3) var(--s4); background: var(--surface-2); border-radius: var(--r); }
.cat-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cat-bars li { display: grid; grid-template-columns: minmax(110px, 1.3fr) 2fr auto; gap: var(--s3); align-items: center; font-size: var(--fs-sm); }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar { height: 10px; }
.cat-bar span { display: block; height: 100%; background: var(--type-anniversaire); border-radius: 0 4px 4px 0; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-popover);
  min-width: 300px; padding: var(--s2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
}
.menu-list button { text-align: left; min-height: 44px; padding: 0 var(--s3); border: 0; border-radius: var(--r-sm); background: transparent; font-weight: 500; }
.menu-list button:hover { background: var(--primary-soft); }
@media (max-width: 640px) { .menu { flex: 1 1 auto; } .menu summary { width: 100%; } .menu-list { left: 0; right: auto; min-width: 100%; } }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 2px solid var(--border); margin-bottom: var(--s4); overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s4);
  border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px;
  background: transparent; color: var(--text-2); font-weight: 600; white-space: nowrap;
}
.tab[aria-selected='true'] { color: var(--primary); border-bottom-color: var(--primary); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--focus); } }

/* ---------- Paramètres ---------- */
.settings { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s5); align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 2px; }
.settings-link {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 46px; padding: 0 var(--s3);
  border: 0; border-radius: var(--r); background: transparent;
  color: var(--text-2); font-weight: 600; text-align: left;
}
.settings-link:hover { background: var(--surface-2); }
.settings-link[aria-current='true'] { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 860px) {
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: var(--s2); }
  .settings-link { white-space: nowrap; border: 1px solid var(--border); background: var(--surface); }
}
.logo-row { display: flex; gap: var(--s5); align-items: center; flex-wrap: wrap; }
.logo-preview { width: 96px; height: 96px; object-fit: contain; border-radius: var(--r-lg); border: 1px solid var(--border); background: #fff; }
.danger-zone { border-color: #f0c0ba; }

/* ---------- Pièces jointes (justificatifs de dépenses) ---------- */
.att-field { display: flex; flex-direction: column; gap: var(--s3); }
.att-list, .att-viewer { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.att-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s2); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.att-thumb { flex: none; width: 48px; height: 48px; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-2); }
.att-icon { display: grid; place-items: center; color: var(--primary); }
.att-icon .icon { width: 24px; height: 24px; }
.att-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.att-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta { font-size: var(--fs-xs); color: var(--text-muted); }
.att-badge {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  margin-top: 4px; padding: 2px 8px; min-height: 28px;
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  background: var(--surface); color: var(--primary);
  font-size: var(--fs-xs); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-badge:hover { background: var(--primary-soft); border-color: var(--primary); }
.att-view { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r); }
.att-view-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.att-preview { max-width: 100%; max-height: 70vh; object-fit: contain; border-radius: var(--r-sm); background: var(--surface-2); align-self: center; }

/* ---------- Prestataires et services ---------- */
.section-gap-sm { margin-top: var(--s3); }
.section-title-row { margin-bottom: var(--s2); }
.trade-tag {
  display: inline-block; vertical-align: 1px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border-radius: var(--r-pill); padding: 1px 8px; margin-left: 4px;
}
.visit-group + .visit-group, .visit-group + .visit-done { border-top: 1px solid var(--border); }
.visit-week {
  margin: 0; padding: var(--s3) var(--s5) var(--s2);
  font-size: var(--fs-sm); font-weight: 700; color: var(--text-2);
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
}
.visit-week .muted { font-weight: 400; }
.visit-late { background: var(--warning-soft); }
.visit-late .visit-week { color: var(--warning); }
.visit-late .list > li { border-color: #ecd59b; }
.visit-item { flex-wrap: wrap; }
.visit-item .meta .icon { width: 1em; height: 1em; }
.visit-box { --type-soft: var(--primary-soft); --type-color: var(--primary); }
.visit-item.is-done .visit-box { --type-soft: var(--surface-2); --type-color: var(--border-strong); }
.visit-item.is-done .title { color: var(--text-2); }
.visit-actions { display: flex; gap: var(--s1); align-items: center; flex: none; }
.visit-done { border-top: 1px solid var(--border); }
.visit-done > summary {
  cursor: pointer; padding: var(--s3) var(--s5); font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: var(--s2); min-height: 48px;
}
.visit-done[open] > summary { border-bottom: 1px solid var(--border); }
@media (max-width: 640px) {
  .visit-actions { width: 100%; justify-content: flex-end; }
  .hide-sm { display: none; }
}

.prov-trade { font-size: var(--fs-md); margin: var(--s5) 0 var(--s3); }
.prov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: var(--s4); align-items: start; }
.prov-card { padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.prov-card.is-inactive { opacity: 0.72; }
.prov-head { display: flex; gap: var(--s3); align-items: flex-start; }
.prov-head h4 { margin: 0; font-size: var(--fs-lg); }
.prov-head .meta { font-size: var(--fs-sm); color: var(--text-muted); }
.prov-contact { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--fs-sm); }
.prov-contact a { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; }
.prov-tasks { margin: 0; }
.prov-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3);
  background: var(--primary-soft); border-radius: var(--r); padding: var(--s2) var(--s3);
}
.prov-total strong { font-variant-numeric: tabular-nums; }
.prov-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2) var(--s4); margin: 0; }
.prov-facts dt { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; color: var(--text-2); }
.prov-facts dd { margin: 0; font-size: var(--fs-sm); }
.prov-notes { margin: 0; padding-left: var(--s3); border-left: 3px solid var(--border); color: var(--text-2); }
.prov-actions { display: flex; gap: var(--s2); flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: var(--s3); }
.prov-actions .btn:last-child { margin-left: auto; }

.task-lines { display: flex; flex-direction: column; gap: var(--s2); }
.task-head, .task-line {
  display: grid; grid-template-columns: minmax(160px, 3fr) 110px 130px 90px 40px;
  gap: var(--s2); align-items: center;
}
.task-head { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; color: var(--text-2); }
.task-line .lbl { display: none; }
.task-line .field { gap: 2px; }
.task-total { text-align: right; font-weight: 600; }
.prov-sum { margin-top: var(--s3); font-weight: 700; color: var(--primary); }
.prov-sum:empty { display: none; }
@media (max-width: 640px) {
  .task-head { display: none; }
  .task-line {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2);
  }
  .task-line .lbl { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
  .task-line > .field:first-child { grid-column: 1 / -1; }
  .task-total { text-align: left; }
  .task-line > div:last-child { text-align: right; }
}

.visit-detail { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.visit-detail li { display: grid; grid-template-columns: minmax(0, 1fr) 84px 90px; gap: var(--s3); align-items: center; }
.visit-detail label { font-weight: 600; }
.visit-detail .strong { text-align: right; }

.home-visits { grid-column: 1 / -1; }
@media (min-width: 961px) {
  .list-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-2col > li:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
  .list-2col > li:nth-child(odd) { border-right: 1px solid var(--border); }
}
.input-group .addon { white-space: nowrap; }
.visit-detail { max-width: 560px; }

/* Planning des passages : vue calendrier */
.pv-cal { padding: var(--s3) var(--s5) 0; }
.pv-cal-nav { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3); }
.pv-cal-title { margin: 0 var(--s2); font-size: var(--fs-lg); }
.pv-legend { list-style: none; margin: 0 0 var(--s3); padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--fs-sm); }
.pv-legend li { display: inline-flex; align-items: center; gap: 6px; }
.pv-legend-done { width: 26px; min-height: 20px; padding: 0 4px; --type-color: var(--border-strong); }
.pv-month { border: 1px solid var(--border); border-radius: var(--r); margin-bottom: var(--s4); }
.pv-month .day { min-height: 104px; }
.ev-chip .icon { width: 0.95em; height: 0.95em; flex: none; }
.ev-chip.is-done { background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.ev-chip.is-late { box-shadow: inset 0 0 0 1px var(--warning); }
.dot.is-done { opacity: 0.4; }
.pv-day { margin: 0 calc(-1 * var(--s5)); border-top: 1px solid var(--border); }
.pv-day-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s3) var(--s5); }
.pv-day-head h3 { margin: 0; font-size: var(--fs-md); }
.pv-day > .list { border-top: 1px solid var(--border); }
.pv-day-empty { margin: 0; padding: 0 var(--s5) var(--s4); }
.seg button .icon { margin-right: 4px; }
@media (max-width: 760px) {
  .pv-cal { padding: var(--s3) var(--s3) 0; }
  .pv-day { margin: 0 calc(-1 * var(--s3)); }
  .pv-month .day { min-height: 58px; }
}

/* Finances : prévisionnel des prestataires, distinct du réel */
.kpi-planned { border-style: dashed; border-color: #b9a6dc; background: repeating-linear-gradient(135deg, var(--surface) 0 10px, #f6f2fb 10px 12px); }
.planned-line { color: var(--type-autre); font-style: italic; }
.result-totals .planned-grand { border-top: 1px dashed #b9a6dc; color: var(--type-autre); }
.result-totals .planned-grand + .planned-grand { border-top: 1px dashed #b9a6dc; }
.planned-cell { color: var(--type-autre); }
.planned-panel { border-style: dashed; border-color: #b9a6dc; }
