:root {
  --primary:        #1e3a5f;
  --accent:         #2563eb;
  --accent-light:   #dbeafe;
  --success:        #16a34a;
  --success-light:  #dcfce7;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  font-size: 16px;
}

/* ── Header & nav ── */
header {
  background: var(--primary);
  color: var(--white);
  padding: .875rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-md);
}
.header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-link {
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  padding: .3rem .6rem;
  border-radius: 6px;
  transition: color .15s, background .15s;
  letter-spacing: -.01em;
}
.nav-link:hover { color: var(--white); background: rgba(255,255,255,.1); }
.nav-active     { color: var(--white); background: rgba(255,255,255,.15); }

.edit-hint {
  font-size: .78rem;
  color: var(--gray-400);
  margin-left: .5rem;
}

/* ── Main ── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1rem 6rem;
}

/* ── Status bar ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.status-label { font-size: .8rem; color: var(--gray-600); }
.badge {
  display: inline-block;
  padding: .2rem .75rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-nouveau { background: var(--gray-200); color: var(--gray-600); }
.badge-projet  { background: var(--warning-light); color: var(--warning); }
.badge-valide  { background: var(--success-light); color: var(--success); }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.card-title {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-size: .95rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.1rem;
  padding-bottom: .75rem;
  border-bottom: 1.5px solid var(--gray-100);
}
.card-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.625rem;
  height: 1.625rem;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Form grid ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .875rem;
}
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.field.full { grid-column: 1 / -1; }

.field label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field input,
.field select {
  width: 100%;
  padding: .6rem .8rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-size: .9rem;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--gray-300); }
.date-fr-wrap { position: relative; }
.date-fr-wrap input[type="text"] { padding-right: 2.6rem; cursor: pointer; caret-color: transparent; }
.field .date-fr-wrap .date-fr-picker {
  position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
  width: 1.8rem; height: 1.8rem; padding: 0; border: 0; background: transparent;
  color: var(--gray-800); cursor: pointer; box-shadow: none;
}
.date-fr-picker::-webkit-datetime-edit { display: none; }
.date-fr-picker::-webkit-calendar-picker-indicator { margin: 0; padding: .2rem; cursor: pointer; }

.field textarea {
  width: 100%;
  padding: .6rem .8rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-size: .9rem;
  color: var(--gray-800);
  background: var(--white);
  font-family: inherit;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field-link { display: inline-block; margin-top: .3rem; font-size: .78rem; }
.field-check {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--gray-600);
  cursor: pointer;
}
.field-check input { width: 1.1rem; height: 1.1rem; accent-color: var(--primary); cursor: pointer; }

/* ── Damier ── */
.box-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.box-header-label { font-size: .8rem; color: var(--gray-600); }
.box-badge-display {
  background: var(--primary);
  color: var(--white);
  padding: .2rem .9rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: .95rem;
  min-width: 3.5rem;
  text-align: center;
}
.box-hint {
  font-size: .75rem;
  color: var(--gray-400);
  margin-left: auto;
}

.legend {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  color: var(--gray-600);
}
.legend-swatch {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 4px;
  border: 1.5px solid;
  flex-shrink: 0;
}
.legend-swatch.free     { background: var(--gray-50);     border-color: var(--gray-300); }
.legend-swatch.selected { background: var(--accent-light); border-color: var(--accent);  }
.legend-swatch.occupied { background: var(--gray-200);    border-color: var(--gray-400); }

.floor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  max-width: 300px;
  margin: 0 auto;
}

.grid-cell {
  aspect-ratio: 5 / 4;
  border: 2px solid var(--gray-200);
  border-radius: 6px;
  background: var(--gray-50);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--gray-400);
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.grid-cell:hover:not(.occupied):not(.selected) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.grid-cell.selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.grid-cell.selected .cell-dot { display: block; }
.cell-dot {
  display: none;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-top: 3px;
}
.grid-cell.occupied {
  background: var(--gray-200);
  border-color: var(--gray-300);
  color: var(--gray-400);
  cursor: not-allowed;
}
.grid-cell.occupied .cell-label { opacity: .5; }

.grid-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--gray-400);
  font-size: .875rem;
  line-height: 1.6;
}
.grid-placeholder .placeholder-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: .5rem;
  opacity: .4;
}

.grid-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: .82rem;
  color: var(--gray-600);
  flex-wrap: wrap;
  gap: .5rem;
}
.btn-clear-sel {
  background: none;
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
  padding: .3rem .75rem;
  border-radius: 6px;
  font-size: .78rem;
  cursor: pointer;
  transition: background .12s;
}
.btn-clear-sel:hover { background: var(--gray-100); }

/* ── Actions bar ── */
.actions-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(241,245,249,.97);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid var(--gray-200);
  padding: .75rem 1rem;
  display: flex;
  gap: .75rem;
  flex-direction: column;
  z-index: 100;
}
@media (min-width: 480px) {
  .actions-bar { flex-direction: row; }
}

.btn {
  flex: 1;
  padding: .8rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  letter-spacing: .01em;
}
.btn:active { transform: scale(.98); }

.btn-save {
  background: #dc2626;
  color: var(--white);
  transition: background .25s, opacity .15s, transform .1s;
}
.btn-save.btn-clean {
  background: var(--success);
}
.btn-save:hover { opacity: .88; }

.btn-pdf {
  background: var(--white);
  color: #000000;
  border: 2px solid #000000;
}
.btn-pdf:hover { background: var(--gray-100); }

.btn-validate {
  background: #dc2626;
  color: var(--white);
  transition: background .25s, opacity .15s, transform .1s;
}
.btn-validate.btn-validated {
  background: var(--success);
}
.btn-validate:hover { opacity: .88; }

/* ── Toast notification ── */
.toast {
  position: fixed;
  top: 4.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(-1rem);
  background: var(--gray-800);
  color: var(--white);
  padding: .65rem 1.25rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 300;
  width: max-content;
  max-width: calc(100vw - 2rem);
  text-align: center;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success { background: var(--success); }
.toast-error   { background: #dc2626; }
.toast-info    { background: var(--gray-800); }

/* ── Section facturation ── */
.billing-list { display: flex; flex-direction: column; gap: .5rem; }
.billing-empty {
  font-size: .82rem;
  color: var(--gray-400);
  text-align: center;
  padding: 1.25rem 0;
}
.billing-row {
  display: grid;
  grid-template-columns: 5.5rem 8rem 1fr auto auto;
  align-items: center;
  gap: .625rem;
  padding: .625rem .875rem;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  font-size: .84rem;
}
.billing-acompte  { background: var(--success-light); border-color: var(--success); }
.billing-credit   { color: var(--success); }
.billing-num    { font-weight: 700; }
.billing-period { font-weight: 600; }
.billing-detail { font-size: .76rem; color: var(--gray-400); }
.billing-amount { font-weight: 700; white-space: nowrap; text-align: right; }
.billing-btn {
  padding: .3rem .7rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.billing-btn:hover { background: #1d4ed8; }
.billing-btn-ph { width: 3.5rem; }
.billing-btns { display: flex; gap: .35rem; align-items: center; }
.billing-btn-quittance {
  padding: .3rem .7rem;
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.billing-btn-quittance:hover { background: #15803d; }
.billing-btn-envoyer {
  padding: .3rem .7rem;
  background: #c2410c;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.billing-btn-envoyer:hover { background: #9a3412; }
.billing-entree {
  border-color: #0891b2;
  background: #ecfeff;
}
.billing-entree-label { color: #155e75; font-style: italic; }
.billing-entree-text  { grid-column: 2 / 4; }
.billing-cloture {
  border-color: #f59e0b;
  background: #fffbeb;
}
.billing-cloture-label { color: #92400e; font-style: italic; }
.billing-cloture-date-wrap { display: flex; align-items: center; }
.billing-date-input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: .22rem .375rem;
  font-size: .8rem;
  font-family: inherit;
  color: var(--gray-700);
  background: white;
  box-sizing: border-box;
}
.billing-custom {
  border-color: #7c3aed;
  background: #f5f3ff;
}
.billing-custom-label { color: #4c1d95; font-style: italic; }
.billing-custom-amount-wrap { display: flex; align-items: center; gap: .3rem; }
.billing-num-input {
  width: 5.5rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: .22rem .375rem;
  font-size: .8rem;
  font-family: inherit;
  text-align: right;
  background: white;
}
.billing-eur { font-size: .8rem; color: var(--gray-500); font-weight: 600; }
.billing-label-input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: .22rem .375rem;
  font-size: .8rem;
  font-family: inherit;
  color: var(--gray-700);
  background: white;
  min-width: 0;
}
.billing-row.billing-tiime-client { display: flex; justify-content: space-between; margin-bottom: .5rem; }
.billing-tiime-client .billing-detail { display: block; }
.billing-tiime-client .billing-btn:disabled { background: var(--gray-300); cursor: not-allowed; }

@media (max-width: 560px) {
  .billing-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
  }
  .billing-num    { grid-column: 1; grid-row: 1; }
  .billing-btn, .billing-btn-ph, .billing-btns, .billing-btn-quittance { grid-column: 2; grid-row: 1; }
  .billing-period { grid-column: 1 / -1; grid-row: 2; }
  .billing-cloture-date-wrap { grid-column: 1 / -1; grid-row: 2; }
  .billing-custom-amount-wrap { grid-column: 1 / -1; grid-row: 2; }
  .billing-label-input { grid-column: 1 / -1; grid-row: 3; }
  .billing-detail { grid-column: 1 / -1; grid-row: 3; }
  .billing-amount { grid-column: 1 / -1; grid-row: 4; text-align: left; }
  .billing-entree .billing-amount { grid-row: 3; }
}
/* Générer / Envoyer / Quittancer sur leur propre ligne tant qu'ils ne tiennent pas à côté du contenu */
@media (max-width: 720px) {
  .billing-btns { grid-column: 1 / -1; grid-row: auto; justify-content: flex-end; }
}

/* ── Section upload ── */
.upload-notice {
  font-size: .8rem;
  color: var(--warning);
  background: var(--warning-light);
  border-radius: 6px;
  padding: .6rem .875rem;
  margin-bottom: 1rem;
}
.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
}
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  padding: .75rem .5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .625rem;
  transition: border-color .15s, background .15s;
}
.upload-has-file {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-light);
}
.upload-zone-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-600);
}
.req { color: #dc2626; }
.upload-file-info { font-size: .8rem; min-height: 1.2rem; }
.file-absent { color: var(--gray-400); }
.file-present { color: var(--success); font-weight: 600; word-break: break-all; }
.upload-progress { font-size: .78rem; color: var(--accent); }
.btn-file-label {
  display: inline-block;
  padding: .45rem .9rem;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-file-label:hover { background: var(--gray-100); border-color: var(--gray-400); }
.upload-has-file .btn-file-label { border-color: var(--success); color: var(--success); }
.upload-zone .field { align-self: stretch; }
.annexe-list { list-style: none; display: flex; flex-direction: column; gap: .4rem; font-size: .85rem; }

@media (max-width: 480px) {
  main { padding-bottom: 13rem; }
}

/* ── Page clients ── */
.clients-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}
.clients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.clients-title { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.clients-header-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.btn-new {
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: .55rem 1.1rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: opacity .15s;
}
.btn-new:hover { opacity: .85; }

.clients-legend {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: .65rem 1rem;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  font-size: .78rem;
  color: var(--gray-600);
}
.legend-item-cl { display: flex; align-items: center; gap: .4rem; }
.legend-dot {
  display: inline-block;
  width: .9rem;
  height: .9rem;
  border-radius: 3px;
  border: 1.5px solid;
  flex-shrink: 0;
}
.dot-active   { background: #bbf7d0; border-color: #4ade80; }
.dot-upcoming { background: #fed7aa; border-color: #fb923c; }
.dot-partial  { background: #fecaca; border-color: #f87171; }

.box-code-legend {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  padding: .5rem 1rem;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1rem; font-size: .78rem; color: var(--gray-600);
}
.bcl-label { font-weight: 600; color: var(--gray-800); }
.bcl-example { font-family: monospace; font-size: .95rem; font-weight: 700; letter-spacing: .02em; }
.bcl-lot   { background: #dbeafe; color: #1d4ed8; border-radius: 3px; padding: 1px 3px; }
.bcl-niv   { background: #fef3c7; color: #b45309; border-radius: 3px; padding: 1px 3px; }
.bcl-porte { background: #dcfce7; color: #15803d; border-radius: 3px; padding: 1px 3px; }
.bcl-sep   { color: var(--gray-300); }
.bcl-item  { display: flex; align-items: center; gap: .3rem; }
.bcl-chip  { padding: 1px 6px; border-radius: 3px; font-size: .72rem; font-weight: 700; }
.bcl-chip-lot   { background: #dbeafe; color: #1d4ed8; }
.bcl-chip-niv   { background: #fef3c7; color: #b45309; }
.bcl-chip-porte { background: #dcfce7; color: #15803d; }

.clients-count {
  font-size: .78rem;
  color: var(--gray-400);
  margin-bottom: .75rem;
  padding: 0 .25rem;
}

.clients-list {
  list-style: none;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.client-row {
  display: flex;
  align-items: center;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  gap: .875rem;
  flex-wrap: wrap;
  transition: filter .1s;
}
.client-row:last-child { border-bottom: none; }
.client-row:hover { filter: brightness(.97); }

.row-active   { background: #bbf7d0; }
.row-upcoming { background: rgba(251,146,60,.35); }
.row-partial  { background: rgba(248,113,113,.35); }

.client-name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--primary);
  text-decoration: none;
  flex: 1;
  min-width: 140px;
}
.client-name:hover { text-decoration: underline; }

.client-meta {
  font-size: .78rem;
  color: var(--gray-600);
  flex: 2;
  min-width: 130px;
}

.client-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

/* Facturation : mois restants avant l'anniversaire d'entrée */
.client-anniv { flex-shrink: 0; min-width: 5rem; text-align: right; font-size: .78rem; color: var(--gray-600); }
.fact-mois-row { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.fact-mois-row .field { flex: 0 1 260px; }
.fact-mois-row .import-hint { flex: 1 1 240px; margin: 0 0 .55rem; }
/* Facturation : sélection multiple + pop-up du lot « Créer Facture » */
.fact-lot-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.fact-sel { flex-shrink: 0; width: 1.1rem; height: 1.1rem; accent-color: var(--primary); cursor: pointer; }
.fact-lot-dialog { margin: auto; border: none; border-radius: var(--radius); padding: 1.25rem; width: min(480px, calc(100vw - 2rem)); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.fact-lot-dialog::backdrop { background: rgba(0,0,0,.45); }
.fact-lot-dialog progress { width: 100%; height: .9rem; margin-bottom: .5rem; accent-color: var(--primary); }
.fact-lot-annonce { font-size: .95rem; font-weight: 600; margin-bottom: .35rem; }
.fact-lot-doublons { list-style: none; margin-top: .4rem; }
.fact-lot-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

.btn-delete {
  background: none;
  border: 1px solid #fca5a5;
  color: #dc2626;
  padding: .3rem .7rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.btn-delete:hover { background: #fee2e2; }

.box-group {
  margin-bottom: 1.25rem;
}
.box-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45rem .85rem;
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.box-group-count {
  font-weight: 400;
  opacity: .75;
  font-size: .77rem;
}
.box-group .clients-list {
  border-radius: 0 0 var(--radius) var(--radius);
}

.clients-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
  font-size: .9rem;
}

/* ── Page overview ── */
.overview-main { max-width: 1300px; }

.ov-toc { display: flex; gap: .5rem; flex-wrap: wrap; }
.ov-toc a {
  padding: .3rem .8rem;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--white);
  color: var(--primary);
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
}
.ov-toc a:hover { background: var(--gray-50); }

.ov-anomalies { border-left: 4px solid var(--warning); }
.ov-anomalies-title { font-size: .9rem; font-weight: 700; color: var(--warning); margin-bottom: .5rem; }
.ov-anomalies ul { padding-left: 1.1rem; font-size: .82rem; line-height: 1.5; }

.ov-section { margin-bottom: 2rem; scroll-margin-top: 4.5rem; }
.ov-section-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .75rem;
}
.ov-section-meta { font-size: .78rem; font-weight: 500; color: var(--gray-600); }

.ov-lot { margin-bottom: 1.25rem; }
.ov-lot-title {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gray-600);
  margin-bottom: .6rem;
}
.ov-box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 1rem;
  align-items: start;
}
.ov-box { margin-bottom: 0; }
.ov-box-head { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; }
.ov-box-free { margin-left: auto; font-size: .75rem; color: var(--gray-600); }
.ov-chip-loyer { background: #ede9fe; color: #6d28d9; }

/* Plan : même damier que la fiche, avec le nom du locataire dans chaque case */
.ov-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ov-cell {
  position: relative;
  aspect-ratio: 5 / 4;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .85rem .3rem .3rem;
  border: 2px solid var(--gray-200);
  border-radius: 6px;
  background-color: var(--gray-50);
  color: var(--gray-800);
  text-align: center;
  text-decoration: none;
  line-height: 1.2;
}
.ov-cell-label {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: .62rem;
  font-weight: 700;
  color: var(--gray-600);
}
.ov-cell-free { padding: .3rem; }
.ov-cell-free .ov-cell-label { position: static; font-size: .8rem; color: var(--gray-400); }
.ov-cell-taken {
  border-color: var(--zone);
  background-color: color-mix(in srgb, var(--zone) 24%, var(--white));
  transition: background-color .12s;
}
.ov-cell-taken:hover { background-color: color-mix(in srgb, var(--zone) 38%, var(--white)); }
.ov-cell-nom,
.ov-cell-prenom {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.ov-cell-nom    { font-size: .72rem; font-weight: 700; }
.ov-cell-prenom { font-size: .68rem; color: var(--gray-600); }
.ov-cell-orphan,
.ov-cell-conflict { border-style: dashed; border-color: var(--gray-400); background-color: var(--gray-200); }
.ov-cell-conflict { border-color: var(--warning); }
.ov-cell-orphan .ov-cell-nom,
.ov-cell-conflict .ov-cell-nom { color: var(--gray-600); }

/* Couleur de zone : pastille (légende) et variantes partagées avec les cases */
.ov-swatch {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  border: 2px solid var(--zone, var(--gray-400));
  border-radius: 4px;
  background-color: color-mix(in srgb, var(--zone, var(--gray-400)) 24%, var(--white));
}
.ov-hatched {
  background-image: repeating-linear-gradient(45deg,
    color-mix(in srgb, var(--zone, var(--gray-400)) 40%, transparent) 0 2px, transparent 2px 7px);
}
.ov-hatched .ov-cell-label,
.ov-hatched .ov-cell-nom,
.ov-hatched .ov-cell-prenom {   /* texte sur fond uni : les hachures ne gênent pas la lecture */
  padding: 0 3px;
  border-radius: 3px;
  background-color: color-mix(in srgb, var(--zone) 24%, var(--white));
}
.ov-pending { border-style: dashed; }

/* Couloir (non louable) : croisillons — /overview et fiche client (.grid-cell : passe devant .occupied) */
.couloir,
.grid-cell.couloir {
  border-color: var(--gray-300);
  background-color: var(--gray-100);
  background-image:
    repeating-linear-gradient(0deg,  var(--gray-300) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(90deg, var(--gray-300) 0 1px, transparent 1px 7px);
}

/* Porte : sous la colonne B, comme sur le plan du bail */
.ov-entrance {
  width: calc((100% - 12px) / 3);
  margin: 5px auto 0;
  padding-top: 2px;
  border-top: 3px solid var(--gray-400);
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
  color: var(--gray-400);
}

.ov-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-top: .9rem;
  padding-top: .75rem;
  border-top: 1.5px solid var(--gray-100);
}
.ov-legend li { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; font-size: .8rem; }
.ov-legend-name { font-weight: 600; color: var(--primary); text-decoration: none; }
.ov-legend-name:hover { text-decoration: underline; }
.ov-legend-cells { font-size: .72rem; color: var(--gray-400); }

.badge-planifie { background: #fed7aa; color: #c2410c; }

/* Trousseaux */
.ov-key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));   /* comme .ov-box-grid : 3 par ligne sur PC */
  gap: 1rem;
  align-items: start;
}
.ov-key-grid .box-group { margin-bottom: 0; }
.ov-key-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem;
  padding: .45rem .85rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: .82rem;
}
.ov-key-row:last-child { border-bottom: none; }
.ov-key-id {
  min-width: 4.4rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--gray-100);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
  font-weight: 700;
  text-align: center;
}
.ov-key-holder { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; flex: 1; min-width: 0; }
.ov-key-name { font-weight: 600; color: var(--primary); text-decoration: none; }
.ov-key-name:hover { text-decoration: underline; }
.ov-key-free { color: var(--gray-400); font-style: italic; }
.ov-keeper { font-size: .78rem; padding: 1px 4px; border: 1px solid var(--gray-300); border-radius: 4px; background: var(--white); cursor: pointer; }
.ov-keeper-tbd { background: var(--warning-light); border-color: var(--warning); }
.ov-key-has-info { text-decoration: underline dotted; text-underline-offset: 2px; cursor: help; }
.ov-key-edit { flex: none; padding: 0 .1rem; border: none; background: none; appearance: none; font-size: .85rem; line-height: 1; cursor: pointer; opacity: .35; }
.ov-key-has-info ~ .ov-key-edit, .ov-key-edit:hover, .ov-key-edit:focus-visible { opacity: 1; }
.ov-key-grid .clients-list { overflow: visible; }   /* laisse dépasser les infobulles */
.ov-key-tip-wrap { position: relative; outline: none; }
.ov-key-tip-wrap .ov-key-id { display: inline-block; cursor: help; }
.ov-key-tip-wrap:focus-visible .ov-key-id { box-shadow: 0 0 0 2px var(--accent); }
.ov-key-tip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  width: max-content;
  max-width: min(18rem, 80vw);
  align-items: flex-start;
  gap: .5rem;
  padding: .45rem .6rem;
  border-radius: 6px;
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow);
  font-size: .78rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.ov-key-tip-wrap:hover .ov-key-tip,
.ov-key-tip-wrap:focus-within .ov-key-tip { display: flex; }
.ov-key-tip-text:empty::before { content: 'Aucune information'; font-style: italic; opacity: .7; }
.ov-key-tip-edit { flex: none; padding: 0 .15rem; border: none; background: none; font-size: .85rem; line-height: 1.2; cursor: pointer; }
.ov-key-note { flex-basis: 100%; font-size: .72rem; color: var(--warning); }

/* ── Page import LLM ── */
.import-hint {
  font-size: .85rem;
  color: var(--gray-600);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.import-textarea {
  width: 100%;
  min-height: 280px;
  padding: .75rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-family: 'Courier New', Courier, monospace;
  font-size: .82rem;
  color: var(--gray-800);
  background: var(--gray-50);
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
}
.import-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: var(--white);
}
.import-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.import-result {
  margin-top: .875rem;
  padding: .75rem 1rem;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.5;
}
.import-result-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}
.import-result-success {
  background: var(--success-light);
  border: 1px solid #86efac;
  color: #166534;
}
.import-result-warning {
  background: var(--warning-light);
  border: 1px solid #fcd34d;
  color: #92400e;
}
.btn-inline {
  display: inline-block;
  padding: .55rem 1.25rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn-inline:disabled { opacity: .55; cursor: not-allowed; }
.btn-inline-primary { background: var(--primary); color: var(--white); }
.btn-inline-primary:hover:not(:disabled) { opacity: .85; }

/* ── Visionneuse pièces justificatives ── */
.file-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.file-modal-inner {
  position: relative;
  max-width: min(95vw, 900px);
  max-height: 92vh;
  background: var(--white);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-modal-close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: rgba(0,0,0,.55);
  color: white;
  border: none;
  border-radius: 50%;
  width: 2.1rem;
  height: 2.1rem;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  line-height: 1;
  transition: background .15s;
}
.file-modal-close:hover { background: rgba(0,0,0,.8); }
.file-modal-img {
  display: block;
  max-width: min(95vw, 900px);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
}
.file-modal-fallback {
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 2rem;
  color: var(--gray-600);
  font-size: .9rem;
  text-align: center;
}
.file-viewable {
  cursor: pointer;
  text-decoration: underline dotted;
  transition: color .12s;
}
.file-viewable:hover { color: var(--accent); }

/* ── Logout + initiale de l'utilisateur connecté ── */
.nav-logout { margin-left: auto; }
.nav-logout:hover { background: rgba(255,80,80,.18); }
.nav-session { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.nav-user {
  width: 1.75rem;
  height: 1.75rem;
  margin: -.25rem 0;   /* n'agrandit pas la barre */
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--primary);
  font-family: Georgia, serif;
  font-size: .95rem;
  font-weight: 700;
  cursor: default;
  user-select: none;
}

/* ── Login page ── */
.login-page {
  background-color: #10243d;
  background-image:
    radial-gradient(60rem 30rem at 10% -10%, rgba(37,99,235,.45), transparent 60%),
    radial-gradient(50rem 30rem at 110% 110%, rgba(14,165,233,.22), transparent 60%),
    linear-gradient(160deg, var(--primary), #0b1a2e);
}
.login-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4.5rem 1rem 1.5rem;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 24px 48px -12px rgba(2,12,27,.45), 0 2px 6px rgba(2,12,27,.12);
  padding: 2.25rem 2rem 2rem;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  display: block;
  width: 6rem;
  height: 6rem;
  margin: -5.25rem auto .875rem;
  padding: .375rem;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 8px 20px rgba(2,12,27,.25);
}
.login-title {
  font-family: Georgia, serif;
  font-size: 2rem;
  font-weight: 400;
  color: var(--primary);
  text-align: center;
  letter-spacing: .01em;
  margin-bottom: .35rem;
}
.login-subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gray-400);
  margin-bottom: 1.75rem;
}
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 10px;
  padding: .65rem .9rem;
  font-size: .875rem;
  margin-bottom: 1.25rem;
}
.login-form .login-field { margin-bottom: 1.1rem; }
.login-form label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: .4rem;
}
.login-form input {
  width: 100%;
  height: 2.875rem;
  padding: 0 .9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-size: 1rem;
  color: var(--gray-800);
  background: var(--gray-50);
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.login-form input:hover { border-color: var(--gray-300); }
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(37,99,235,.14);
}
.login-form input::-ms-reveal { display: none; }
.login-password { position: relative; }
.login-password input { padding-right: 3rem; }
.login-reveal {
  position: absolute;
  top: 50%;
  right: .375rem;
  transform: translateY(-50%);
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  transition: color .15s, background-color .15s;
}
.login-reveal:hover { color: var(--primary); background: var(--gray-100); }
.login-reveal:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-reveal[aria-pressed="true"] { color: var(--accent); }
.login-reveal:not([aria-pressed="true"]) .login-reveal-slash { display: none; }
.btn-login {
  width: 100%;
  height: 3rem;
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  margin-top: .75rem;
  box-shadow: 0 8px 16px -8px rgba(37,99,235,.7);
  transition: background-color .15s, transform .05s;
}
.btn-login:hover { background: #1d4ed8; }
.btn-login:active { transform: translateY(1px); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .form-grid        { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .field.full       { grid-column: 1; }
  .card             { padding: 1rem; }
  .client-meta      { flex-basis: 100%; order: 3; }
}
@media (max-width: 360px) {
  .form-grid.cols-3 { grid-template-columns: 1fr; }
}

/* ── Bandeau de navigation en bas d'écran sur téléphone (PC inchangé) ── */
@media (max-width: 600px) {
  .has-nav { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .has-nav > header {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    padding-bottom: calc(.875rem + env(safe-area-inset-bottom));
  }
  .has-nav .header-inner {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1.75rem;
    row-gap: .25rem;
    justify-items: center;
    align-items: center;
  }
  .has-nav .nav-logout,
  .has-nav .nav-session { margin-left: 0; }
  .has-nav .actions-bar { bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .has-nav .home-main { min-height: calc(100vh - 5.5rem - env(safe-area-inset-bottom)); }
}

/* ── Version du programme (pied de page de base.html) ── */
.app-version {
  text-align: center;
  font-size: .72rem;
  color: var(--gray-600);
  padding: .75rem 1rem;
}
.home-main + .app-version { margin-top: -3rem; }        /* dans le bas de l'accueil, sans barre de défilement */
.actions-bar ~ .app-version { padding-bottom: 6rem; }   /* au-dessus de la barre d'actions fixe (fiche client) */
@media (max-width: 480px) {
  .actions-bar ~ .app-version { padding-bottom: 13rem; }
}

/* Page d'accueil */
.home-main {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 60px);
}
.home-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.home-subtitle {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: .01em;
}
.home-logo {
  width: calc(860px / 3);
  max-width: 33.33vw;
  height: auto;
  display: block;
}

/* Page Tiime (VNC) */
.tiime-main   { max-width: 1300px; }
.tiime-vnc-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}
.tiime-vnc-frame {
  width: 100%;
  height: 80vh;
  border: none;
  display: block;
}
.tiime-actions  { display: flex; gap: .75rem; margin-bottom: .25rem; }
.tiime-mfa-row  { display: flex; align-items: flex-end; gap: .75rem; margin-top: .875rem; max-width: 320px; }
.tiime-mfa-row .field { flex: 1; }

.tiime-session-card .tiime-stepup-row { display: flex; align-items: flex-end; gap: .75rem; max-width: 360px; }
.tiime-session-card .field { flex: 1; }
.tiime-countdown {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .75rem;
  font-variant-numeric: tabular-nums;
}
.tiime-vnc-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80vh;
  color: var(--gray-400);
  font-size: .9rem;
  text-align: center;
  padding: 1rem;
}
.btn-inline-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.btn-inline-danger:hover:not(:disabled) { opacity: .85; }
