:root {
  --primary: #0b3b5a;
  --accent: #17803d;
  --bg: #f2f5f8;
  --danger: #b3261e;
}
* { box-sizing: border-box; font-family: Arial, sans-serif; }
.hidden { display: none; }
body {
  margin: 0;
  background: linear-gradient(145deg, #e6f0f7 0%, #f2f5f8 45%, #ddeaf3 100%);
  color: #1d2329;
}
.topbar { position: sticky; top: 0; z-index: 2; background: var(--primary); color: #fff; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }
.bottombar {
  height: 52px;
  background: var(--primary);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
}
h1, h2, h3, h4 { margin: 0; }
.container { max-width: 980px; margin: 12px auto 80px; padding: 0 12px; }
.card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.grid.two.align-end-row {
  align-items: end;
}
.address-compact {
  resize: vertical;
  max-width: 100%;
  min-height: 2.75rem;
  max-height: 5rem;
  width: 100%;
}
@media (min-width: 640px) {
  .address-compact {
    max-width: 280px;
  }
}
.grid { display: grid; gap: 10px; margin-bottom: 10px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
input, select, textarea { border: 1px solid #ccd3da; border-radius: 8px; padding: 10px; font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.btn { border: 0; background: var(--accent); color: #fff; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 700; }
.btn.secondary { background: #425466; }
.btn.danger { background: var(--danger); }
.menuiserie-item { border: 1px solid #dce3ea; border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.client-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 12px;
}
.client-picker label {
  flex: 1 1 240px;
  min-width: 0;
}
.client-picker .btn {
  flex: 0 0 auto;
  align-self: flex-end;
}
.total-live, .total-ht { font-size: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid #e2e8ee; padding: 8px; text-align: left; white-space: nowrap; }
.history-panel { position: fixed; top: 0; right: 0; width: min(420px, 100%); height: 100%; background: #fff; z-index: 5; box-shadow: -4px 0 18px rgba(0,0,0,0.2); padding: 14px; overflow: auto; }
.history-panel.hidden { display: none; }
#historyList { list-style: none; margin: 8px 0 0; padding: 0; }
#historyList li { border: 1px solid #d6dde5; border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.history-actions { margin-top: 8px; display: flex; gap: 6px; }
.photo-list {
  font-size: 13px;
  color: #425466;
  margin-bottom: 8px;
}

.devis-statut-field {
  margin-bottom: 12px;
  max-width: 280px;
}

.devis-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.devis-badge--en_attente {
  background: #e2e8f0;
  color: #475569;
}
.devis-badge--envoye {
  background: #dbeafe;
  color: #1e40af;
}
.devis-badge--valide {
  background: #dcfce7;
  color: #166534;
}
.devis-badge--traite {
  background: #cffafe;
  color: #0e7490;
}
.devis-badge--a_revoir {
  background: #ffedd5;
  color: #c2410c;
}

.liste-devis-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.liste-devis-toolbar label {
  flex: 1 1 200px;
  min-width: 0;
  margin: 0;
}
.liste-devis-toolbar .liste-devis-filter {
  flex: 0 1 200px;
}
.liste-devis-ref-cell {
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.liste-devis-client-cell strong {
  display: block;
}
.liste-devis-client-cell small {
  color: #64748b;
  font-size: 12px;
}
.liste-devis-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.liste-devis-statut-cell {
  vertical-align: middle;
  min-width: 11rem;
}
.liste-devis-statut-select {
  width: 100%;
  max-width: 220px;
  font-size: 13px;
  padding: 8px 10px;
}
@media (max-width: 640px) {
  .liste-devis-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .liste-devis-actions .btn {
    width: 100%;
  }
  .liste-devis-statut-select {
    max-width: none;
  }
}

.liste-devis-table td {
  white-space: normal;
  vertical-align: top;
}
.liste-devis-table th {
  white-space: nowrap;
}

.save-confirm-inner {
  max-width: min(440px, 100%);
}
.save-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}
.save-confirm-actions .btn {
  flex: 1 1 120px;
}

.mesures-simple {
  margin-bottom: 8px;
}
.mesures-heading {
  margin: 10px 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}
.photo-actions-row-simple {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px 0;
}
.photo-actions-row-simple .btn {
  flex: 1 1 160px;
}

.photo-zone-panel {
  background: #e5e7eb;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  margin: 14px 0 14px 0;
}
.photo-separator-block {
  height: 10px;
  border-radius: 8px;
  background: #cbd5e1;
  margin: 0 0 12px 0;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.15);
}
.photo-dropzone {
  background: #d1d5db;
  border: 1px dashed #9ca3af;
  border-radius: 10px;
  padding: 10px;
  margin: 0;
  min-height: 84px;
}
.photo-dropzone-empty {
  margin: 0;
  font-size: 13px;
  color: #4b5563;
  font-weight: 600;
}
.photo-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 58px));
  gap: 8px;
  margin-top: 6px;
}
.photo-thumb {
  width: 58px;
  height: 58px;
  min-width: 58px;
  min-height: 58px;
  max-width: 58px;
  max-height: 58px;
  flex: 0 0 58px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  display: grid;
  place-items: center;
}
.photo-thumb-cover {
  width: 58px;
  height: 58px;
  min-width: 58px;
  min-height: 58px;
  max-width: 58px;
  max-height: 58px;
  border-radius: 8px;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.photo-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: grid;
  place-items: center;
  z-index: 2000;
  padding: 16px;
}
.photo-modal.hidden { display: none; }
.photo-modal-inner {
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  max-width: min(480px, 100%);
  width: 100%;
}
.cam-video {
  width: 100%;
  border-radius: 10px;
  background: #0f172a;
  max-height: 50vh;
}
.photo-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.82);
  display: grid;
  place-items: center;
  padding: 16px;
}
.photo-viewer.hidden {
  display: none;
}
.photo-viewer-inner {
  position: relative;
  width: min(94vw, 980px);
  max-height: 92vh;
}
.photo-viewer-image {
  width: 100%;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 10px;
  background: #0f172a;
}
.photo-viewer-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.home-card {
  text-align: center;
  padding: 22px;
  background: linear-gradient(160deg, #ffffff 0%, #f5f9fc 100%);
}
.home-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 2.2rem;
  line-height: 1;
}
.home-title span {
  color: #ea580c;
  letter-spacing: 1px;
}
.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
}
.home-link {
  display: block;
  text-decoration: none;
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 12px;
  padding: 18px 16px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.25);
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.home-link:nth-child(1) { background: linear-gradient(135deg, #ea580c, #c2410c); }
.home-link:nth-child(2) { background: linear-gradient(135deg, #1d4ed8, #1e40af); }
.home-link:nth-child(3) { background: linear-gradient(135deg, #0e7490, #155e75); }
.home-link:nth-child(4) { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
.home-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.28);
  filter: brightness(1.03);
}
.home-link:active {
  transform: translateY(1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}

.home-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.home-page .container {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 12px;
  min-height: 0;
}

.home-page .home-card {
  width: min(640px, 100%);
  margin-bottom: 0;
}

/* Calendrier RDV */
.cal-card {
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(11, 59, 90, 0.1);
  box-shadow: 0 8px 28px rgba(11, 59, 90, 0.1);
}
.cal-intro {
  margin: 0;
  padding: 14px 16px 12px;
  background: linear-gradient(145deg, rgba(11, 59, 90, 0.06) 0%, rgba(23, 128, 61, 0.05) 100%);
  border-bottom: 1px solid rgba(11, 59, 90, 0.08);
}
.cal-toolbar {
  margin: 0;
  padding: 14px 14px 12px;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #e8eef4;
}
.cal-nav-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0 !important;
  border-radius: 50% !important;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
  background: #fff !important;
  border: 2px solid rgba(11, 59, 90, 0.14) !important;
  color: var(--primary) !important;
  box-shadow: 0 2px 8px rgba(11, 59, 90, 0.06);
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}
.cal-nav-btn:hover {
  border-color: rgba(23, 128, 61, 0.55) !important;
  color: var(--accent) !important;
  box-shadow: 0 4px 12px rgba(11, 59, 90, 0.1);
}
.cal-nav-btn:active {
  transform: scale(0.96);
}
.cal-month-title {
  font-size: 1.2rem;
  font-weight: 800;
  text-transform: capitalize;
  flex: 1;
  text-align: center;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  margin: 0;
  padding: 10px 10px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--primary) 0%, #134a6e 100%);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  padding: 14px 12px 16px;
  background: linear-gradient(180deg, #e8eef5 0%, #dfe8f2 100%);
}
.cal-cell {
  min-height: 54px;
  display: flex;
  align-items: stretch;
}
.cal-cell-empty {
  min-height: 0;
  pointer-events: none;
}
.cal-day {
  flex: 1;
  border: none;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  font: inherit;
  color: #1e293b;
  box-shadow: 0 1px 4px rgba(11, 59, 90, 0.07);
  transition: box-shadow 0.18s ease, transform 0.15s ease, background 0.15s ease;
}
.cal-day:hover {
  background: #fff;
  box-shadow: 0 6px 18px rgba(11, 59, 90, 0.14);
  transform: translateY(-2px);
}
.cal-day:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(11, 59, 90, 0.1);
}
.cal-day-today {
  box-shadow: 0 0 0 2px var(--accent), 0 4px 14px rgba(23, 128, 61, 0.2);
}
.cal-day-today .cal-day-num {
  background: var(--accent);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
}
.cal-day-num {
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
.cal-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 8px;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0e7490, var(--accent));
  box-shadow: 0 1px 2px rgba(11, 59, 90, 0.2);
}

/* Calendrier : petits écrans (lisibilité + zone tactile) */
@media (max-width: 480px) {
  .cal-toolbar {
    gap: 8px;
    padding: 12px 10px;
  }
  .cal-nav-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }
  .cal-month-title {
    font-size: 1.05rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cal-weekdays {
    font-size: 9px;
    padding: 8px 6px;
    letter-spacing: 0.05em;
  }
  .cal-grid {
    gap: 6px;
    padding: 10px 8px 14px;
  }
  .cal-cell {
    min-height: 46px;
  }
  .cal-day {
    min-height: 46px;
    padding: 6px 2px 4px;
    border-radius: 12px;
    -webkit-tap-highlight-color: rgba(23, 128, 61, 0.15);
  }
  .cal-day-num {
    font-size: 12px;
  }
  .cal-day-today .cal-day-num {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }
  .cal-dot {
    width: 5px;
    height: 5px;
  }
}

@media (max-width: 360px) {
  .cal-weekdays span {
    letter-spacing: 0.02em;
  }
}

.rdv-modal-inner {
  max-width: min(560px, 100%);
}
.rdv-modal-actions {
  justify-content: space-between;
  flex-wrap: wrap;
}
.rdv-day-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: min(52vh, 420px);
  overflow: auto;
}
.rdv-day-empty {
  padding: 12px;
  color: #64748b;
  font-size: 14px;
}
.rdv-day-item {
  border: 1px solid #e2e8ee;
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
}
.rdv-day-item-main {
  width: 100%;
  text-align: left;
  border: 0;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.rdv-day-item-main:hover {
  background: #f1f5f9;
}
.rdv-time {
  font-weight: 700;
  color: #0b3b5a;
  margin-right: 6px;
}
.rdv-day-mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 10px 10px;
}
.rdv-mini-link {
  text-decoration: none;
  font-size: 13px;
  padding: 8px 10px;
  display: inline-block;
  text-align: center;
}
.rdv-fieldset {
  border: 1px solid #dce3ea;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0;
}
.rdv-fieldset legend {
  padding: 0 6px;
  font-weight: 700;
  font-size: 14px;
}
.rdv-hint {
  margin: 6px 0 0;
}
.rdv-form-actions {
  justify-content: space-between;
  margin-top: 4px;
}
.rdv-remind-row {
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.rdv-remind-row .btn {
  flex: 1 1 200px;
}
