/* ── RESET & BASE ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── HEADER ───────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 0.5px solid #e0e0e0;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo { height: 40px; object-fit: contain; }

.btn-logout {
  color: #888;
  text-decoration: none;
  padding: 6px;
  display: flex;
  align-items: center;
}
.btn-logout:hover { color: #e74c3c; }

/* ── MAIN ─────────────────────────────────────────── */
.app-main { padding: 0 0 32px; }

/* ── FLASH MESSAGES ───────────────────────────────── */
.flash {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}
.flash-success { background: #e6f6f0; color: #1a8a5a; }
.flash-error   { background: #fde8e8; color: #c0392b; }

/* ── PAGE HEADER ──────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border-bottom: 0.5px solid #e0e0e0;
  position: sticky;
  top: 61px;
  z-index: 90;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
}

.page-count {
  background: #5aaedf;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.btn-back {
  color: #5aaedf;
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 4px;
}

/* ── BUTTONS ──────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #5aaedf;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
}
.btn-primary:active { opacity: .85; transform: scale(.98); }
.btn-full { width: 100%; }
.btn-submit { margin: 0 16px; width: calc(100% - 32px); }

/* ── LOGIN ────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: #f4f5f7;
}

.login-logo img {
  height: 90px;
  object-fit: contain;
  margin-bottom: 24px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 2px 16px rgba(0,0,0,.06);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #1a1a1a;
}

.login-sub {
  font-size: 13px;
  color: #888;
  margin-bottom: 24px;
}

/* ── FORMS ────────────────────────────────────────── */
.field { margin-bottom: 12px; }

.field label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: 0.5px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
  color: #1a1a1a;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: #5aaedf;
  background: #fff;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.field textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #555;
}

.field-hint {
  font-size: 11px;
  color: #aaa;
  margin-top: 5px;
}

.optional {
  font-size: 11px;
  color: #aaa;
  font-weight: 400;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── FORM SECTIONS ────────────────────────────────── */
.page-wrap { padding-bottom: 32px; }

.form-section {
  background: #fff;
  margin: 12px 16px;
  border-radius: 14px;
  padding: 16px;
  border: 0.5px solid #e8e8e8;
}

.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #5aaedf;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 0.5px solid #f0f0f0;
}

/* ── INDEX ────────────────────────────────────────── */
.index-wrap { padding: 0 0 32px; }

.index-hero {
  background: #5aaedf;
  padding: 28px 20px 24px;
  color: #fff;
}

.index-date {
  font-size: 12px;
  opacity: .8;
  text-transform: capitalize;
  margin-bottom: 4px;
}

.index-title {
  font-size: 26px;
  font-weight: 700;
}

.index-actions {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 14px;
  text-decoration: none;
  border: 0.5px solid #e8e8e8;
  transition: transform .1s;
}
.btn-action:active { transform: scale(.98); }

.btn-action-primary {
  background: #5aaedf;
  color: #fff;
  border-color: #5aaedf;
}
.btn-action-secondary { background: #fff; color: #1a1a1a; }

.btn-action-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-action-secondary .btn-action-icon {
  background: #f0f7fd;
  color: #5aaedf;
}

.btn-action-text { flex: 1; }
.btn-action-label { display: block; font-size: 16px; font-weight: 600; }
.btn-action-sub { display: block; font-size: 12px; opacity: .7; margin-top: 2px; }

/* ── SECTION LABEL ────────────────────────────────── */
.section-label {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── CARDS ────────────────────────────────────────── */
.cards-list { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }

.rapport-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  border: 0.5px solid #e8e8e8;
}

.rapport-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.rapport-card-client {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
}

.rapport-card-adresse {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.rapport-card-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #888;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.rapport-card-meta svg { vertical-align: -2px; margin-right: 3px; }

.rapport-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-card-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s;
}
.btn-card-action:active { opacity: .8; }

.btn-continuer { background: #5aaedf; color: #fff; }
.btn-edit      { background: #f0f7fd; color: #5aaedf; }
.btn-pdf       { background: #e6f6f0; color: #1a8a5a; }
.btn-delete    { background: #fde8e8; color: #c0392b; }

/* ── BADGES ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-terminee { background: #e6f6f0; color: #1a8a5a; }
.badge-encours  { background: #fff8e6; color: #b07d00; }
.badge-reprog   { background: #fde8e8; color: #c0392b; }

/* ── URGENCE ──────────────────────────────────────── */
.urgence-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}
.urgence-normal      { background: #f0f0f0; color: #666; }
.urgence-urgent      { background: #fff3e0; color: #e67e22; }
.urgence-tres_urgent { background: #fde8e8; color: #c0392b; }

/* ── FILTERS ──────────────────────────────────────── */
.filters {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.filter-btn {
  white-space: nowrap;
  padding: 7px 14px;
  border-radius: 99px;
  border: 0.5px solid #ddd;
  background: #fff;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.filter-btn.active {
  background: #5aaedf;
  color: #fff;
  border-color: #5aaedf;
}

/* ── PHOTOS ───────────────────────────────────────── */
.photos-label {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 8px 0 6px;
}

.photo-list { display: flex; flex-direction: column; gap: 10px; }

.photo-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 0.5px solid #e0e0e0;
}

.photo-item img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
}

.photo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.add-photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  border: 1.5px dashed #ccc;
  border-radius: 10px;
  background: #fafafa;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  position: relative;
  font-family: inherit;
}

.add-photo-btn input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── SIGNATURE ────────────────────────────────────── */
.sig-wrap-small {
  border: 0.5px solid #ddd;
  border-radius: 10px;
  background: #f8f8f8;
  overflow: hidden;
}

.sig-label-small {
  font-size: 11px;
  color: #aaa;
  padding: 6px 10px 4px;
  user-select: none;
}

.sig-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.sig-btns button {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  border: 0.5px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
  color: #555;
  cursor: pointer;
  font-family: inherit;
}

.btn-expand {
  background: #5aaedf !important;
  color: #fff !important;
  border-color: #5aaedf !important;
}

/* ── SIGNATURE MODALE ─────────────────────────────── */
/* ── SIGNATURE MODALE ─────────────────────────────── */
.sig-modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.85);
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.sig-modal-bg.active { display: flex; }

.sig-modal {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  overflow: hidden;
}

.sig-modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e8e8e8;
  font-size: 16px;
  font-weight: 600;
  color: #222;
}

.sig-modal-hint {
  font-size: 12px;
  color: #999;
  text-align: center;
  padding: 6px 0;
  background: #fafafa;
}

.sig-modal-canvas-wrap {
  background: #fff;
  position: relative;
}

.sig-modal-canvas-wrap::after {
  content: '';
  position: absolute;
  bottom: 30px;
  left: 8%;
  right: 8%;
  height: 1px;
  background: #e0e0e0;
  pointer-events: none;
}

.sig-modal-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid #e8e8e8;
  background: #fff;
}

.sig-modal-actions button {
  flex: 1;
  padding: 13px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.btn-ov-clear   { background: #f0f0f0; color: #555; }
.btn-ov-confirm { background: #5aaedf; color: #fff; }

/* ── EMAILS ───────────────────────────────────────── */
.email-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 4px;
}

.email-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0f7fd;
  color: #5aaedf;
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 13px;
}

.email-tag button {
  background: none;
  border: none;
  cursor: pointer;
  color: #5aaedf;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}

.email-input-row { display: flex; gap: 8px; }
.email-input-row input { flex: 1; }
.email-input-row button {
  padding: 10px 14px;
  background: #5aaedf;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

/* ── DIVIDER ──────────────────────────────────────── */
.divider {
  height: 0.5px;
  background: #f0f0f0;
  margin: 14px 0;
}

/* ── EMPTY STATE ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #aaa;
  font-size: 15px;
}


.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 16px;
}

.btn-draft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  color: #5aaedf;
  border: 1.5px solid #5aaedf;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}