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

:root {
  --terre: #5C3317;
  --ocre: #C8823A;
  --ocre-lt: #E0A55A;
  --sable: #E8D0A8;
  --creme: #F5EAD6;
  --blanc: #FBF6EE;
  --noir: #1A0F06;
  --gris: #7A6650;
  --gris-lt: #B8A898;
  --accent: #C04820;
  --vert: #3A6B45;
  --rouge: #C04820;
  --sh: rgba(92,51,23,0.12);
  --header-h: 56px;
  --nav-h: 64px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--blanc);
  color: var(--noir);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ── LOGIN ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--creme);
}

.login-logo { text-align: center; margin-bottom: 2.5rem; }

.login-logo-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--terre);
  color: var(--blanc);
  font-size: 1.4rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  letter-spacing: .05em;
}

.login-logo h1 { font-size: 2rem; font-weight: 700; color: var(--terre); }
.login-logo p { font-size: .85rem; color: var(--gris); margin-top: .3rem; }

.login-form {
  width: 100%; max-width: 360px;
  background: var(--blanc);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 8px 32px var(--sh);
}

/* ── APP LAYOUT ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.app-header {
  height: var(--header-h);
  background: var(--terre);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .8rem;
  flex-shrink: 0;
  z-index: 100;
}

.header-title {
  color: var(--blanc);
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
}

.btn-icon {
  background: none; border: none;
  color: var(--blanc);
  font-size: 1.5rem;
  cursor: pointer;
  padding: .5rem;
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.btn-icon:hover { background: rgba(255,255,255,.15); }

.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--blanc);
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  height: var(--nav-h);
  background: var(--blanc);
  border-top: 1px solid var(--sable);
  display: flex;
  flex-shrink: 0;
  box-shadow: 0 -2px 12px var(--sh);
}

.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .15rem;
  background: none; border: none;
  color: var(--gris-lt);
  cursor: pointer;
  transition: color .2s;
  padding: .4rem 0;
}
.nav-item.active { color: var(--terre); }
.nav-icon { font-size: 1.35rem; }
.nav-label { font-size: .62rem; font-weight: 500; letter-spacing: .02em; }

/* ── VIEWS ── */
.view { padding: 1rem; min-height: 100%; }

/* ── DASHBOARD ── */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .7rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--creme);
  border-radius: 12px;
  padding: 1rem .5rem;
  text-align: center;
  border: 1px solid rgba(200,130,58,.2);
}

.stat-val { font-size: 1.9rem; font-weight: 700; color: var(--terre); line-height: 1; }
.stat-lbl { font-size: .65rem; color: var(--gris); margin-top: .3rem; }

.section-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .7rem;
}
.section-h3 {
  font-size: .75rem; font-weight: 700;
  color: var(--terre);
  text-transform: uppercase; letter-spacing: .08em;
}

/* ── CARDS ── */
.card-list { display: flex; flex-direction: column; gap: .6rem; }

.card {
  background: var(--creme);
  border-radius: 12px;
  padding: .9rem 1rem;
  border: 1px solid rgba(200,130,58,.15);
  cursor: pointer;
  display: flex; align-items: center; gap: .8rem;
  transition: transform .15s, box-shadow .15s;
  -webkit-user-select: none; user-select: none;
}
.card:active { transform: scale(.97); box-shadow: 0 4px 16px var(--sh); }

.card-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--terre);
  color: var(--blanc);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; font-weight: 700;
  flex-shrink: 0;
}

.card-body { flex: 1; min-width: 0; }
.card-title { font-size: .95rem; font-weight: 600; color: var(--noir); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-size: .78rem; color: var(--gris); margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-arrow { color: var(--gris-lt); font-size: 1.2rem; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: .18rem .55rem;
  border-radius: 20px;
  font-size: .68rem; font-weight: 600;
}
.badge-en-cours { background: rgba(58,107,69,.15); color: var(--vert); }
.badge-en-attente { background: rgba(200,130,58,.15); color: var(--ocre); }
.badge-termine { background: rgba(122,102,80,.15); color: var(--gris); }

/* ── SEARCH ── */
.search-bar { margin-bottom: 1rem; }
.search-bar input {
  width: 100%; padding: .75rem 1rem;
  border: 1.5px solid var(--sable);
  border-radius: 12px; font-size: .9rem;
  background: var(--creme); color: var(--noir);
  outline: none; font-family: inherit;
}
.search-bar input:focus { border-color: var(--ocre); }

/* ── FILTER TABS ── */
.filter-tabs {
  display: flex; gap: .5rem;
  margin-bottom: 1rem;
  overflow-x: auto; scrollbar-width: none;
  -ms-overflow-style: none; padding-bottom: .2rem;
}
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
  flex-shrink: 0; padding: .42rem 1rem;
  border-radius: 20px; border: 1.5px solid var(--sable);
  background: var(--blanc); color: var(--gris);
  font-size: .8rem; cursor: pointer; white-space: nowrap;
  font-family: inherit; transition: all .2s;
}
.filter-tab.active { background: var(--terre); color: var(--blanc); border-color: var(--terre); }

/* ── FORMS ── */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }

.form-group label {
  font-size: .7rem; font-weight: 600;
  color: var(--gris);
  text-transform: uppercase; letter-spacing: .06em;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: .72rem 1rem;
  border: 1.5px solid var(--sable);
  border-radius: 10px; font-size: .9rem;
  font-family: inherit; background: var(--blanc);
  color: var(--noir); outline: none;
  transition: border-color .2s; width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--ocre); }
.form-group textarea { resize: vertical; min-height: 80px; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }

/* ── BUTTONS ── */
.btn-primary {
  width: 100%; padding: .88rem;
  background: var(--terre); color: var(--blanc);
  border: none; border-radius: 10px;
  font-size: .93rem; font-weight: 600;
  font-family: inherit; cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover { background: var(--accent); }

.btn-secondary {
  width: 100%; padding: .82rem;
  background: transparent; color: var(--terre);
  border: 1.5px solid var(--terre);
  border-radius: 10px; font-size: .9rem;
  font-weight: 600; font-family: inherit;
  cursor: pointer; margin-top: .6rem;
}

.btn-danger {
  width: 100%; padding: .78rem;
  background: transparent; color: var(--rouge);
  border: 1.5px solid var(--rouge);
  border-radius: 10px; font-size: .88rem;
  font-weight: 600; font-family: inherit;
  cursor: pointer; margin-top: .4rem;
}

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 1rem);
  right: 1rem;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--ocre); color: var(--blanc);
  border: none; font-size: 1.7rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(200,130,58,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, background .2s;
  z-index: 50;
}
.fab:active { transform: scale(.9); }

/* ── DETAIL PAGES ── */
.detail-header {
  background: var(--creme);
  border-radius: 14px; padding: 1.2rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(200,130,58,.15);
}
.detail-avatar {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--terre); color: var(--blanc);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; margin-bottom: .8rem;
}
.detail-name { font-size: 1.15rem; font-weight: 700; color: var(--terre); margin-bottom: .4rem; }
.detail-info { display: flex; flex-direction: column; gap: .25rem; }
.detail-info span { font-size: .84rem; color: var(--gris); }

.detail-actions {
  display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem;
}
.detail-actions a,
.detail-actions button {
  flex: 1; min-width: 80px;
  padding: .6rem .4rem;
  border-radius: 8px; border: 1.5px solid var(--terre);
  background: transparent; color: var(--terre);
  font-size: .78rem; font-weight: 600; text-align: center;
  cursor: pointer; text-decoration: none;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: .2rem;
}

.detail-section { margin-top: 1.2rem; }
.detail-section-title {
  font-size: .72rem; font-weight: 700; color: var(--terre);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: .6rem;
  display: flex; justify-content: space-between; align-items: center;
}
.detail-section-add {
  background: none; border: none; color: var(--ocre);
  font-size: 1.4rem; cursor: pointer; padding: 0 .3rem;
}

/* ── NOTES ── */
.note-card {
  background: var(--creme); border-radius: 10px;
  padding: .9rem; margin-bottom: .6rem;
  border: 1px solid rgba(200,130,58,.15);
  cursor: pointer;
}
.note-card.has-rappel { border-left: 3px solid var(--ocre); }
.note-card.rappel-urgent { border-left: 3px solid var(--rouge); background: rgba(192,72,32,.04); }

.note-title { font-size: .9rem; font-weight: 600; color: var(--noir); margin-bottom: .25rem; }
.note-content { font-size: .82rem; color: var(--gris); line-height: 1.5; }
.note-rappel { font-size: .72rem; color: var(--ocre); margin-top: .35rem; font-weight: 500; }
.note-rappel.urgent { color: var(--rouge); }

/* ── PHOTOS ── */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem; margin-top: .6rem;
}
.photo-thumb {
  aspect-ratio: 1; border-radius: 8px;
  overflow: hidden; background: var(--sable); cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-add {
  aspect-ratio: 1; border-radius: 8px;
  border: 2px dashed var(--sable);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: var(--gris-lt);
  cursor: pointer; background: none;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(26,15,6,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-box {
  background: var(--blanc);
  border-radius: 20px 20px 0 0;
  width: 100%; max-height: 92vh;
  overflow-y: auto; padding: 1.2rem 1.5rem 2rem;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-drag {
  width: 40px; height: 4px;
  background: var(--sable); border-radius: 2px;
  margin: 0 auto 1.2rem;
}
.modal-title {
  font-size: 1.1rem; font-weight: 700;
  color: var(--terre); margin-bottom: 1.2rem;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 1rem);
  left: 50%; transform: translateX(-50%);
  background: var(--noir); color: var(--blanc);
  padding: .7rem 1.4rem;
  border-radius: 20px; font-size: .86rem; font-weight: 500;
  z-index: 400; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  white-space: nowrap;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 2.5rem 1rem; color: var(--gris);
}
.empty-state-icon { font-size: 2.8rem; opacity: .35; margin-bottom: .7rem; }
.empty-state p { font-size: .88rem; }

/* ── UTILITIES ── */
.hidden { display: none !important; }

/* ── MENU SECTION LABEL ── */
.menu-section-label {
  font-size: .7rem; font-weight: 700;
  color: var(--terre);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 1.2rem 0 .5rem;
}

/* ── SYNC STATUS ── */
.sync-status {
  min-height: 22px;
  font-size: .82rem;
  margin: .5rem 0;
  color: var(--gris);
  transition: color .2s;
}
.sync-status[data-type="ok"]    { color: var(--vert);  }
.sync-status[data-type="error"] { color: var(--rouge); }
.sync-status[data-type="info"]  { color: var(--gris);  }

/* ── PRINT VIEW (caché à l'écran) ── */
#print-view { display: none; }

/* ── IMPRESSION PDF ── */
@media print {
  body > *:not(#print-view) { display: none !important; }

  #print-view {
    display: block;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #111;
    padding: 0;
  }

  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: .8rem;
    border-bottom: 2px solid #5C3317;
    margin-bottom: 1.4rem;
  }
  .print-logo  { font-size: 1.4rem; font-weight: 800; color: #5C3317; }
  .print-date  { font-size: .8rem; color: #7A6650; }

  .print-title { font-size: 1.6rem; font-weight: 700; color: #5C3317; margin-bottom: .4rem; }

  .print-badge {
    display: inline-block;
    padding: .18rem .6rem;
    border-radius: 20px;
    font-size: .72rem; font-weight: 600;
    margin-bottom: 1rem;
  }
  .print-badge-en-cours   { background: #c8e6c9; color: #2e7d32; }
  .print-badge-en-attente { background: #fff3e0; color: #e65100; }
  .print-badge-termine    { background: #e0e0e0; color: #424242; }

  .print-info {
    width: 100%; border-collapse: collapse;
    margin-bottom: 1.4rem;
  }
  .print-info td {
    padding: .38rem .5rem;
    font-size: .88rem;
    border-bottom: 1px solid #e0d0c0;
  }
  .print-info td:first-child { font-weight: 600; color: #5C3317; width: 34%; }

  .print-section {
    font-size: .8rem; font-weight: 700; color: #5C3317;
    text-transform: uppercase; letter-spacing: .06em;
    margin: 1.2rem 0 .5rem;
    padding-bottom: .25rem;
    border-bottom: 1px solid #e0d0c0;
  }
  .print-text { font-size: .88rem; line-height: 1.6; color: #333; }

  .print-note {
    margin-bottom: .8rem; padding: .6rem .8rem;
    border: 1px solid #e0d0c0; border-radius: 6px;
  }
  .print-note-title   { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
  .print-note-rappel  { font-size: .78rem; color: #C8823A; margin-bottom: .2rem; }
  .print-note-content { font-size: .85rem; line-height: 1.5; color: #555; }

  .print-photos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .4rem; margin-top: .4rem;
  }
  .print-photo {
    width: 100%; aspect-ratio: 1;
    object-fit: cover; border-radius: 4px;
  }

  .print-footer {
    margin-top: 2rem; padding-top: .4rem;
    border-top: 1px solid #e0d0c0;
    font-size: .72rem; color: #aaa;
    text-align: center;
  }
}

/* ── PC / TABLETTE ── */
@media (min-width: 640px) {
  html, body { background: var(--creme); overflow: auto; }

  .app, .login-screen {
    max-width: 480px;
    margin: 0 auto;
  }
  .app {
    min-height: 100vh;
    border-left: 1px solid var(--sable);
    border-right: 1px solid var(--sable);
    box-shadow: 0 0 48px rgba(0,0,0,.08);
  }
  html, body { overflow: hidden; }

  .modal-overlay { align-items: center; }
  .modal-box {
    border-radius: 16px;
    max-width: 480px;
    margin: 0 auto;
  }
}
