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

:root {
  /* ── Brand (thème dynamique — vert par défaut) ── */
  --brand:      #1B5E3A;
  --brand-900:  #0F3D26;
  --brand-50:   #F1F8F3;
  --brand-soft: #E0F0E5;
  --brand-tint: #F1F8F3;

  /* ── Aliases legacy (compatibilité code existant) ── */
  --primary:     #1B5E3A;
  --primary-dk:  #0F3D26;
  --primary-lt:  #226B43;
  --primary-xlt: #F1F8F3;

  /* ── Base ── */
  --bg:       #FAFAF7;
  --bg-elev:  #FFFFFF;
  --bg-soft:  #F5F6F4;
  --surface:  #FFFFFF;

  /* ── Texte ── */
  --text:      #0E1614;
  --text-soft: #4A5752;
  --text-mute: #6B7873;
  --noir:      #0E1614;
  --gris:      #6B7873;
  --gris-lt:   #E5E8E6;

  /* ── Bordures & ombres ── */
  --border:  #EBEDEB;
  --sh:      rgba(14,22,20,.06);
  --sh-md:   rgba(14,22,20,.14);

  /* ── Couleurs sémantiques ── */
  --vert:       #1B5E3A;
  --vert-lt:    #E0F0E5;
  --rouge:      #C8453B;
  --rouge-lt:   #FBE4E1;
  --orange:     #E5A23B;
  --orange-lt:  #FCE9C7;

  /* ── Layout ── */
  --header-h:  62px;
  --nav-h:     64px;
  --text-base: 15px;
}

/* ── MODE SOMBRE ── */
[data-theme="dark"] {
  --bg:       #0E1614;
  --bg-elev:  #1A2421;
  --bg-soft:  #16201D;
  --surface:  #1A2421;
  --text:     #F5F6F4;
  --text-soft:#B5BCB8;
  --text-mute:#8E9994;
  --noir:     #F5F6F4;
  --gris:     #8E9994;
  --gris-lt:  #2B3733;
  --border:   #2B3733;
  --brand-tint: color-mix(in srgb, var(--brand) 15%, transparent);
  --sh:       rgba(0,0,0,.35);
  --sh-md:    rgba(0,0,0,.55);
  color-scheme: dark;
}
[data-theme="dark"] .app-header         { background: #1E293B; border-bottom-color: #334155; }
[data-theme="dark"] .bottom-nav         { background: #1E293B; border-top-color: #334155; }
[data-theme="dark"] .login-screen       { background: #0F172A; }
[data-theme="dark"] .login-form         { background: #1E293B; box-shadow: none; }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea            { background: var(--bg) !important; color: var(--text) !important; border-color: var(--border); }
[data-theme="dark"] .more-menu-sheet    { background: #1E293B; }
[data-theme="dark"] .modal-box          { background: #1E293B; }
[data-theme="dark"] .filter-tab                    { background: var(--bg-elev); color: var(--text-soft); border-color: var(--border); }
[data-theme="dark"] .filter-tab.active             { background: var(--brand); color: #fff; box-shadow: none; border-color: transparent; }
[data-theme="dark"] .filter-tab.active .tab-count  { background: rgba(255,255,255,.22); color: #fff; }
[data-theme="dark"] .toast             { background: #F1F5F9; color: #0F172A; }
/* ── brand-tint surfaces : surcharge CSS pure indépendante du JS ── */
[data-theme="dark"] .menu-backup-card  { background: var(--bg-elev); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
[data-theme="dark"] .filter-tab .tab-count { background: rgba(255,255,255,.07); color: var(--text-soft); }
[data-theme="dark"] .photo-cat-chip.active { background: var(--bg-elev); color: var(--brand); border-color: var(--brand); }
[data-theme="dark"] .cd-tile-icon      { background: rgba(255,255,255,.06); }
[data-theme="dark"] .cd-section-add    { background: rgba(255,255,255,.06); }
[data-theme="dark"] .cd-client-row     { background: rgba(255,255,255,.04); }
[data-theme="dark"] .menu-list-badge   { background: rgba(255,255,255,.08); }
[data-theme="dark"] .badge-termine,
[data-theme="dark"] .badge-gris        { background: var(--bg-elev); }
[data-theme="dark"] .db-icon-btn       { color: var(--text-soft); }

/* ── DENSITÉ COMPACT ── */
[data-density="compact"] .card         { padding: .5rem .75rem; }
[data-density="compact"] .card-list    { gap: .35rem; }
[data-density="compact"] .card-title   { font-size: .88rem; }
[data-density="compact"] .card-sub     { font-size: .73rem; }
[data-density="compact"] .stat-card    { padding: .7rem .6rem; }
[data-density="compact"] .stat-val     { font-size: 1.5rem; }

html, body {
  height: 100%;
  font-size: var(--text-base);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  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(--bg);
}

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

.login-logo-icon {
  width: 80px; height: 80px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 24px rgba(30,64,175,.3);
}

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

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

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

.app-header {
  height: var(--header-h);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 .8rem;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(15,23,42,.15);
}

.header-center { display: flex; align-items: center; gap: .5rem; }

.header-logo-img {
  width: 42px; height: 42px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255,255,255,.15);
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,.25);
}

.header-title {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  flex: 1;
  text-align: center;
  letter-spacing: .02em;
}

.btn-icon {
  background: none; border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: .5rem;
  border-radius: 8px;
  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(--bg);
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  display: flex;
  flex-shrink: 0;
  box-shadow: 0 -1px 0 var(--border);
}

.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .15rem;
  background: none; border: none;
  color: var(--text-mute);
  cursor: pointer;
  transition: color .2s;
  padding: .4rem 0;
  position: relative;
}
.nav-item.active { color: var(--brand); font-weight: 700; }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--brand);
  border-radius: 0 0 3px 3px;
}
.nav-icon  { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; }
.nav-label { font-size: .64rem; font-weight: 600; letter-spacing: .02em; }

/* ── MORE MENU ── */
.more-menu-backdrop {
  position: fixed; inset: 0;
  z-index: 200;
}
.more-menu-sheet {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px var(--sh-md);
  z-index: 201;
  min-width: 180px;
  overflow: hidden;
  animation: popUp .18s ease;
}
@keyframes popUp {
  from { opacity: 0; transform: scale(.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.more-menu-item {
  display: flex; align-items: center; gap: .8rem;
  width: 100%; padding: .9rem 1.2rem;
  background: none; border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer; font-family: inherit;
  font-size: .9rem; font-weight: 500;
  color: var(--noir); text-align: left;
  transition: background .15s;
}
.more-menu-item:last-child { border-bottom: none; }
.more-menu-item:active { background: var(--primary-xlt); }
.more-menu-item.active { color: var(--primary-lt); background: var(--primary-xlt); font-weight: 600; }
.more-menu-icon { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; }

/* ── VIEWS ── */
.view { padding: 1rem; padding-bottom: calc(env(safe-area-inset-bottom) + 5.5rem); min-height: 100%; }

/* ── DASHBOARD ── */

/* Header doux */
.db-header {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--brand-50) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}
[data-theme="dark"] .db-header {
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg) 100%);
}
.db-header-halo {
  position: absolute; top: -60px; right: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand) 0%, transparent 70%);
  opacity: .12; pointer-events: none;
}
[data-theme="dark"] .db-header-halo { opacity: .18; }
[data-theme="dark"] .db-logo-pill { background: color-mix(in srgb, var(--brand) 55%, #fff); box-shadow: none; filter: none; }

.db-header-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 0; position: relative;
}
.db-logo-pill {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .7rem; letter-spacing: -.3px;
  box-shadow: 0 4px 10px var(--brand-soft); flex-shrink: 0;
}
.db-logo-img {
  width: 34px; height: 34px; border-radius: 10px;
  object-fit: contain; border: 1.5px solid var(--border);
}
.db-header-actions { display: flex; align-items: center; gap: 6px; }
.db-icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg-elev); color: var(--brand);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; cursor: pointer; font-family: inherit;
}
.db-sync {
  font-size: .75rem; padding: .2rem .5rem; border-radius: 6px;
  background: var(--bg-elev); color: var(--text-mute);
  border: 1px solid var(--border);
}

.db-greeting { padding: 16px 18px 0; position: relative; }
.db-date-line {
  font-size: .68rem; font-weight: 700; color: var(--brand);
  letter-spacing: .08em; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.db-date-line::before { content:''; width:14px; height:2px; background:var(--brand); border-radius:2px; }
.db-bonjour { font-size: 1.4rem; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; color: var(--text); }
.db-subtitle { font-size: .82rem; color: var(--text-soft); margin-top: 4px; }
.db-subtitle strong { color: var(--brand); }

/* Chips KPI — marge négative pour contrer le padding du parent (0 14px 90px) et donner pleine largeur */
.db-chips {
  padding: 10px 14px 4px !important;
  margin: 0 -14px !important;
}

/* Hero card chantier */
.db-hero {
  background: var(--bg-elev); border-radius: 18px;
  margin: 10px 0 12px; padding: 16px;
  border: 1px solid var(--brand-soft);
  box-shadow: 0 4px 16px var(--brand-tint);
  position: relative; overflow: hidden;
}
[data-theme="dark"] .db-hero { box-shadow: none; }
.db-hero::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 4px; height: 100%; background: var(--brand);
}
.db-hero-eyebrow {
  font-size: .65rem; font-weight: 700; color: var(--brand);
  letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px;
}
.db-hero-title {
  font-size: 1rem; font-weight: 700; color: var(--text);
  line-height: 1.25; margin-bottom: 4px;
}
.db-hero-meta { font-size: .78rem; color: var(--text-soft); margin-bottom: 12px; }
.db-hero-actions { display: flex; gap: 8px; }
.db-hero-btn {
  flex: 1; height: 40px; border-radius: 10px; border: none;
  font-size: .85rem; font-weight: 700; font-family: inherit;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.db-hero-btn-primary { background: var(--brand); color: #fff; }
.db-hero-btn-outline  { background: var(--bg-elev); color: var(--brand); border: 1.5px solid var(--brand) !important; }

/* ── PAGE HEADER (liste views : chantiers, notes, devis, clients…) ── */
.page-header {
  position: relative; overflow: hidden; flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-50) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .page-header {
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg) 100%);
}
.page-header-halo {
  position: absolute; top: -60px; right: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand) 0%, transparent 70%);
  opacity: .12; pointer-events: none;
}
[data-theme="dark"] .page-header-halo { opacity: .18; }
.page-header-top {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 14px 0; position: relative;
}
.page-header-title {
  font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em;
  color: var(--text); flex: 1;
}
.page-header-search {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; margin: 12px 14px 0;
}
.page-header-search input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: .85rem; color: var(--text); font-family: inherit;
}
.page-header-search input::placeholder { color: var(--text-mute); }
.page-chips {
  padding: 10px 14px 14px !important;
  margin-bottom: 0 !important;
}

/* Legacy stat cards (gardés pour compatibilité) */
.dashboard-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: .5rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-elev); border-radius: 12px; padding: .75rem .3rem; text-align: center; border: 1px solid var(--border); box-shadow: 0 1px 4px var(--sh); cursor: pointer; }
.stat-val { font-size: 1.5rem; font-weight: 700; color: var(--brand); line-height: 1; }
.stat-lbl { font-size: .6rem; color: var(--text-mute); margin-top: .3rem; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

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

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

.card {
  background: var(--bg-elev);
  border-radius: 14px;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; gap: .8rem;
  transition: transform .15s, box-shadow .15s;
  -webkit-user-select: none; user-select: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.card:active { transform: scale(.97); box-shadow: 0 4px 16px var(--sh-md); }

.card-avatar {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--brand-tint);
  color: var(--brand);
  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: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub   { font-size: .78rem; color: var(--text-soft); margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-arrow { color: var(--text-mute); font-size: 1.2rem; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: .18rem .55rem;
  border-radius: 6px;
  font-size: .68rem; font-weight: 600;
}
.badge-en-cours   { background: var(--vert-lt);    color: var(--vert);   }
.badge-en-attente { background: var(--orange-lt);  color: var(--orange); }
.badge-termine    { background: #F1F5F9;            color: var(--gris);   }
.badge-vert  { background: var(--vert-lt);    color: var(--vert);    }
.badge-bleu  { background: var(--brand-50); color: var(--brand); }
.badge-gris  { background: #F1F5F9;            color: var(--gris);    }
.badge-rouge   { background: var(--rouge-lt);   color: var(--rouge);   }
.badge-orange  { background: var(--orange-lt);  color: var(--orange);  }

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

/* ── FILTER TABS / CHIPS KPI ── */
.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;
  display: flex; align-items: center; gap: .45rem;
  padding: .44rem .9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text);
  font-size: .8rem; cursor: pointer; white-space: nowrap;
  font-family: inherit; font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
  transition: all .18s;
}
.filter-tab .tab-count {
  background: var(--brand-tint);
  color: var(--brand);
  font-size: .72rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 999px; min-width: 18px; text-align: center;
}
.filter-tab.active {
  background: var(--brand);
  color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px var(--brand-soft);
}
.filter-tab.active .tab-count {
  background: rgba(255,255,255,.22);
  color: #fff;
}

/* ── 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(--border);
  border-radius: 10px; font-size: .9rem;
  font-family: inherit; background: var(--surface);
  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(--brand); }
.form-group textarea { resize: vertical; min-height: 80px; }

.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 2.8rem; }
.pwd-eye {
  position: absolute; right: .7rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--gris); padding: .2rem;
  line-height: 1; -webkit-tap-highlight-color: transparent;
}

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

/* ── BUTTONS ── */
.btn-primary {
  width: 100%; padding: .9rem;
  background: var(--brand);
  color: #fff;
  border: none; border-radius: 12px;
  font-size: .93rem; font-weight: 700;
  font-family: inherit; cursor: pointer;
  letter-spacing: .02em;
  box-shadow: 0 4px 14px var(--brand-soft);
  transition: all .18s;
}
.btn-primary:hover  { box-shadow: 0 6px 20px var(--brand-soft); }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 2px 8px var(--brand-soft); }

.btn-secondary {
  width: 100%; padding: .84rem;
  background: var(--brand-50);
  color: var(--brand);
  border: 1.5px solid var(--brand-soft);
  border-radius: 12px; font-size: .9rem;
  font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .18s;
}
.btn-secondary:active { background: var(--brand-soft); transform: translateY(1px); }

.btn-danger {
  width: 100%; padding: .8rem;
  background: var(--rouge-lt);
  color: var(--rouge);
  border: 1.5px solid rgba(220,38,38,.25);
  border-radius: 12px; font-size: .88rem;
  font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .18s;
}
.btn-danger:active { transform: translateY(1px); }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + .8rem);
  right: 1rem;
  width: 56px; height: 56px;
  border-radius: 18px;
  background: var(--brand); color: #fff;
  border: none; font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 8px 22px var(--brand-soft), 0 2px 6px rgba(0,0,0,.2);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s;
  z-index: 50;
}
.fab:active { transform: scale(.9); }

/* ── FAB AIDE ── */
.fab-help {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + .8rem);
  left: 1rem;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--brand);
  border: 2px solid var(--brand);
  font-size: 1.4rem; font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
  z-index: 50;
}
.fab-help:active { transform: scale(.9); }

/* ── BOUTON VOCAL DEVIS ── */
.btn-voice-devis {
  width: 100%;
  padding: .65rem 1rem;
  border: 2px dashed var(--brand);
  border-radius: 10px;
  background: var(--brand-tint);
  color: var(--brand);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: .5rem;
  transition: background .15s;
}
.btn-voice-devis:active { background: var(--brand-soft); }
.btn-voice-devis:disabled { opacity: .6; cursor: not-allowed; }

/* ── SECTION EYEBROW ── */
.section-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: .68rem; font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 1.2rem 0 .5rem;
}
.section-eyebrow::before {
  content: '';
  width: 14px; height: 2px;
  background: var(--brand);
  flex-shrink: 0;
  border-radius: 2px;
}

/* ── CHANTIER DETAIL (cd-) ── */
.cd-hero { background: var(--bg-elev); border-radius: 16px; border: 1px solid var(--border); overflow: hidden; }
.cd-hero-cover { height: 130px; position: relative; display: flex; align-items: center; justify-content: center; }
.cd-hero-badge { position: absolute; display: flex; align-items: center; gap: 5px; background: rgba(255,255,255,.18); backdrop-filter: blur(6px); font-size: .65rem; font-weight: 800; letter-spacing: .05em; color: #fff; padding: 4px 9px; border-radius: 999px; border: 1px solid rgba(255,255,255,.3); }
.cd-hero-badge--status { top: 10px; right: 10px; }
.cd-hero-badge--photos { bottom: 10px; left: 10px; }
.cd-hero-body { padding: 14px 16px 16px; }
.cd-hero-label { font-size: .65rem; font-weight: 700; color: var(--brand); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }
.cd-hero-title { font-size: 1.1rem; font-weight: 800; color: var(--text); line-height: 1.2; letter-spacing: -.02em; }
.cd-client-row { margin-top: 10px; padding: 10px 12px; background: var(--brand-tint); border-radius: 10px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: opacity .12s; }
.cd-client-row:active { opacity: .75; }
.cd-client-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 800; flex-shrink: 0; }
.cd-primary-actions { display: flex; gap: 8px; padding: 12px 14px 0; }
.cd-action-primary { flex: 1; height: 46px; border-radius: 12px; border: none; background: var(--brand); color: #fff; font-weight: 700; font-size: .88rem; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-family: inherit; transition: opacity .12s; }
.cd-action-primary:active { opacity: .82; }
.cd-action-secondary { flex: 1; height: 46px; border-radius: 12px; background: var(--bg-elev); color: var(--text); font-weight: 600; font-size: .84rem; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-family: inherit; transition: background .12s; }
.cd-action-secondary:active { background: var(--brand-tint); }
.cd-tiles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 14px 0; }
.cd-tile { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; font-family: inherit; transition: background .12s; }
.cd-tile:active { background: var(--brand-tint); }
.cd-tile-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-tint); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.cd-tile-label { font-size: .72rem; font-weight: 600; color: var(--text-soft); }
.cd-section { padding: 20px 14px 0; }
.cd-section-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cd-section-eyebrow { font-size: .68rem; font-weight: 800; color: var(--text-mute); text-transform: uppercase; letter-spacing: .1em; display: flex; align-items: center; gap: 8px; }
.cd-section-eyebrow::before { content: ''; width: 14px; height: 2px; border-radius: 2px; background: var(--brand); flex-shrink: 0; }
.cd-section-count { font-weight: 600; opacity: .7; }
.cd-section-add { width: 28px; height: 28px; border-radius: 8px; background: var(--brand-tint); color: var(--brand); border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cd-empty { padding: 22px 14px; background: var(--bg-elev); border-radius: 12px; border: 1.5px dashed var(--border); display: flex; align-items: center; justify-content: center; }
.cd-doc-card { background: var(--bg-elev); border-radius: 12px; border: 1px solid var(--border); padding: 12px 14px; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; cursor: pointer; transition: background .12s; }
.cd-doc-card:active { background: var(--brand-tint); }
.cd-doc-icon { width: 38px; height: 46px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: .58rem; font-weight: 800; letter-spacing: .05em; flex-shrink: 0; }
.cd-doc-icon--fact  { background: var(--rouge-lt); color: var(--rouge); }
.cd-doc-icon--devis { background: var(--orange-lt); color: var(--orange); }
.cd-danger-btn { width: 100%; padding: 13px; border-radius: 12px; background: var(--rouge-lt); color: var(--rouge); font-size: .84rem; font-weight: 700; border: 1px solid rgba(200,69,59,.2); cursor: pointer; font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 8px; }
[data-theme="dark"] .cd-danger-btn { background: rgba(200,69,59,.12); border-color: rgba(200,69,59,.3); }

/* ── FICHE CHANTIER V4 ── */
#view-chantier-detail.view { padding: 0; }
.cd-tabs { display: flex; background: var(--bg-elev); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.cd-tab { flex: 1; padding: 13px 4px; font-size: .7rem; font-weight: 700; color: var(--text-mute); background: none; border: none; border-bottom: 2.5px solid transparent; margin-bottom: -1px; cursor: pointer; font-family: inherit; letter-spacing: .01em; transition: color .12s; }
.cd-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.cd-actions-primary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 14px 0; }
.cd-actions-secondary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 14px 0; }
.cd-tile-prim { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; font-family: inherit; transition: opacity .12s; }
.cd-tile-prim:active { opacity: .75; }
.cd-tile-prim .tip-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; }
.cd-tile-sec { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; font-family: inherit; transition: opacity .12s; }
.cd-tile-sec:active { opacity: .75; }
.cd-tile-sec .tip-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-tint); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.cd-fin-kpi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 14px 0; }
.cd-fin-kpi-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.cd-fin-kpi-card--full { grid-column: 1 / -1; }
.cd-fin-kpi-label { font-size: .65rem; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.cd-fin-kpi-value { font-size: 1.05rem; font-weight: 800; color: var(--text); }
[data-theme="dark"] .cd-fin-kpi-card { background: rgba(255,255,255,.04); }

/* ── DETAIL PAGES ── */
.detail-header {
  background: var(--surface);
  border-radius: 14px; padding: 1.2rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px var(--sh);
}
.detail-avatar {
  width: 60px; height: 60px; border-radius: 12px;
  background: var(--primary-xlt); color: var(--primary);
  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(--noir); 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: .62rem .4rem;
  border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--noir);
  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;
  box-shadow: 0 1px 4px var(--sh);
  transition: all .15s;
}
.detail-actions a:active,
.detail-actions button:active { transform: translateY(1px); box-shadow: none; }
.detail-actions .btn-danger-sm { border-color: rgba(220,38,38,.3); color: var(--rouge); background: var(--rouge-lt); }

/* ── DEVIS / FACTURES ── */
.type-btn {
  flex: 1; padding: .5rem; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--surface);
  color: var(--gris); font-weight: 600; font-size: .85rem;
  cursor: pointer; font-family: inherit;
}
.type-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.ligne-row { margin-bottom: .6rem; }
.ligne-section-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary-xlt); border-radius: 6px; padding: .4rem .7rem;
  margin: .8rem 0 .4rem; gap: .5rem;
}
.ligne-section-label {
  font-weight: 600; font-size: .82rem; color: var(--primary);
  text-transform: uppercase; letter-spacing: .04em; flex: 1;
}
.ligne-desc input { width: 100%; margin-bottom: .3rem; }
.ligne-nums { display: flex; gap: .3rem; align-items: center; }
.ligne-total-val {
  font-size: .8rem; font-weight: 700; color: var(--primary);
  white-space: nowrap; min-width: 52px; text-align: right;
}
.ligne-del {
  background: none; border: none; color: var(--gris-lt);
  font-size: 1rem; cursor: pointer; padding: .2rem; flex-shrink: 0;
}

.devis-totaux {
  background: var(--primary-xlt); border-radius: 8px;
  padding: .8rem 1rem; margin: .8rem 0;
}
.total-row {
  display: flex; justify-content: space-between;
  font-size: .88rem; color: var(--gris); padding: .2rem 0;
}
.total-ttc {
  font-size: 1rem; font-weight: 700; color: var(--primary);
  border-top: 1px solid var(--border); margin-top: .4rem; padding-top: .5rem;
}

.lignes-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.lignes-table th {
  text-align: left; font-size: .7rem; color: var(--gris);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border); padding: .3rem .4rem;
}
.lignes-table td {
  padding: .45rem .4rem; border-bottom: 1px solid var(--border); vertical-align: top;
}
.ligne-section-tr td {
  background: var(--primary-xlt); color: var(--primary);
  font-weight: 600; font-size: .75rem; text-transform: uppercase;
  letter-spacing: .05em; padding: .35rem .6rem;
}

/* ── VUE AIDE ── */
.aide-quick-start {
  background: var(--primary); color: #fff;
  border-radius: 12px; padding: 1.1rem 1.2rem; margin-bottom: 1.2rem;
}
.aide-quick-start h2 { font-size: .95rem; font-weight: 700; margin-bottom: .75rem; }
.aide-step { display: flex; gap: .7rem; align-items: flex-start; margin-bottom: .55rem; }
.aide-step:last-child { margin-bottom: 0; }
.aide-step-num {
  background: rgba(255,255,255,.25); color: #fff; border-radius: 50%;
  width: 22px; height: 22px; min-width: 22px;
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: .1rem;
}
.aide-step-text { font-size: .86rem; line-height: 1.5; }
.aide-step-text strong { color: rgba(255,255,255,.9); }

.aide-section { border-radius: 10px; margin-bottom: .6rem; overflow: hidden; }
.aide-section-btn {
  background: var(--bg); cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  padding: .8rem 1rem; border: none; width: 100%; text-align: left;
  font-size: .93rem; font-weight: 700; color: var(--noir);
}
.aide-section-btn:active { background: var(--border); }
.aide-section-arrow { color: var(--gris); font-size: .8rem; transition: transform .2s; }
.aide-section-btn[aria-expanded="true"] .aide-section-arrow { transform: rotate(90deg); }
.aide-section-body {
  background: var(--surface); padding: 0 1rem;
  max-height: 0; overflow: hidden; transition: max-height .3s ease, padding .2s;
}
.aide-section-body.open { max-height: 2400px; padding: .9rem 1rem; }
.aide-section-body h3 { font-size: .85rem; font-weight: 700; color: var(--primary); margin: .75rem 0 .3rem; }
.aide-section-body h3:first-child { margin-top: 0; }
.aide-section-body p { font-size: .84rem; color: var(--gris); margin-bottom: .45rem; line-height: 1.55; }
.aide-section-body ul { padding-left: 1.1rem; margin-bottom: .45rem; }
.aide-section-body li { font-size: .84rem; color: var(--gris); margin-bottom: .22rem; line-height: 1.5; }
.aide-section-body li strong { color: var(--noir); }
.aide-tip {
  background: var(--primary-xlt); border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0; padding: .5rem .7rem;
  font-size: .8rem; color: var(--gris); margin: .5rem 0;
}
.aide-tip strong { color: var(--primary); }

.aide-status-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.aide-status { font-size: .76rem; padding: .15rem .5rem; border-radius: 12px; font-weight: 600; }
.aide-s-encours { background: #D4EDDA; color: #1A5C2A; }
.aide-s-attente { background: #FFF3CD; color: #7A5A00; }
.aide-s-termine { background: #F0D0C8; color: #7A1A0A; }
.aide-s-devis   { background: #D0E4F0; color: #0A3A5A; }
.aide-s-accepte { background: #D4EDDA; color: #1A5C2A; }
.aide-s-refuse  { background: #F0D0C8; color: #7A1A0A; }
.aide-s-facture { background: #E8D8F0; color: #4A1A6A; }
.aide-s-payee   { background: #D4EDDA; color: #1A5C2A; }

.aide-role-table { width: 100%; border-collapse: collapse; font-size: .8rem; margin: .5rem 0; }
.aide-role-table th { background: var(--bg); color: var(--primary); font-weight: 700; padding: .4rem .6rem; text-align: left; }
.aide-role-table td { padding: .32rem .6rem; border-bottom: 1px solid var(--border); color: var(--gris); }
.aide-role-table tr:last-child td { border-bottom: none; }
.aide-ok  { color: var(--vert); font-weight: 700; }
.aide-non { color: var(--gris-lt); }
.aide-badge-chef { display: inline-block; background: var(--vert); color: #fff; font-size: .68rem; font-weight: 700; padding: .1rem .38rem; border-radius: 4px; }
.aide-badge-emp  { display: inline-block; background: var(--orange); color: #fff; font-size: .68rem; font-weight: 700; padding: .1rem .38rem; border-radius: 4px; }
.aide-badge-admin { display: inline-block; background: var(--primary); color: #fff; font-size: .68rem; font-weight: 700; padding: .1rem .38rem; border-radius: 4px; }
.aide-code-box { background: var(--primary-xlt); border-radius: 8px; padding: .5rem .8rem; font-family: monospace; font-size: .98rem; font-weight: 700; color: var(--primary); letter-spacing: .06em; text-align: center; margin: .4rem 0; }
.aide-version { text-align: center; font-size: .73rem; color: var(--gris-lt); padding: 1rem 0 .5rem; }

/* ── Bloc Sur mesure (tarifs + modal abonnement) ── */
.custom-inner {
  background: var(--primary-xlt);
  border: 1.5px solid var(--primary-lt);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  flex-wrap: wrap;
  margin-top: .6rem;
}
.custom-icon { font-size: 1.5rem; flex-shrink: 0; }
.custom-content { flex: 1; min-width: 160px; }
.custom-content h3 { font-size: .82rem; font-weight: 700; margin-bottom: .2rem; }
.custom-content p { font-size: .73rem; color: var(--gris); line-height: 1.5; margin: 0; }
.custom-cta {
  background: var(--primary);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  padding: .5rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.custom-cta:hover { opacity: .88; }

/* ── CERFA — Modal sélection ── */
.cerfa-choice-btn {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; cursor: pointer;
  font-family: inherit; text-align: left; transition: background .12s;
  width: 100%;
}
.cerfa-choice-btn:active { background: var(--brand-tint); }
details[open] .cerfa-details-arrow { transform: rotate(180deg); }
details summary::-webkit-details-marker { display: none; }
.cerfa-choice-num {
  min-width: 52px; height: 52px; border-radius: 12px;
  background: var(--brand-tint); color: var(--brand);
  font-size: .78rem; font-weight: 800; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center;
}
.cerfa-choice-info { flex: 1; }
.cerfa-choice-title { font-weight: 700; font-size: .92rem; color: var(--text); }
.cerfa-choice-sub   { font-size: .75rem; color: var(--text-soft); margin-top: 2px; }
.cerfa-section-title {
  font-size: .68rem; font-weight: 800; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .1em;
  margin: 14px 0 6px; padding-bottom: 5px; border-bottom: 1px solid var(--border);
}

/* ── PDF DEVIS ── */
@media print {
  .pdf-devis { font-family: 'Segoe UI', system-ui, sans-serif; color: #111; }

  .pdf-banner {
    background: var(--primary); color: #fff;
    padding: .9rem 1.4rem;
    display: flex; align-items: center; justify-content: space-between;
  }
  .pdf-banner-type { font-size: .7rem; font-weight: 700; opacity: .8; text-transform: uppercase; letter-spacing: .12em; }
  .pdf-banner-num  { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
  .pdf-banner-statut {
    border: 1.5px solid rgba(255,255,255,.65); border-radius: 20px;
    padding: .18rem .65rem; font-size: .72rem; font-weight: 600;
  }

  .pdf-info-row {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: .85rem 1.4rem; border-bottom: 1px solid #e0e0e0; margin-bottom: 1.2rem;
  }
  .pdf-societe-logo   { height: 44px; object-fit: contain; display: block; margin-bottom: .2rem; }
  .pdf-societe-nom    { font-size: 1rem; font-weight: 800; color: var(--primary); }
  .pdf-societe-detail { font-size: .77rem; color: #555; line-height: 1.55; margin-top: .18rem; }
  .pdf-dates-block  { text-align: right; font-size: .82rem; color: #555; line-height: 1.7; }
  .pdf-dates-block strong { color: #111; }

  .pdf-dest-row { display: flex; gap: 1.2rem; padding: 0 1.4rem; margin-bottom: 1.4rem; }
  .pdf-dest-block { flex: 1; border-left: 3px solid var(--primary); padding-left: .75rem; }
  .pdf-dest-label {
    font-size: .65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .1em; color: var(--primary); margin-bottom: .2rem;
  }
  .pdf-dest-nom    { font-size: .93rem; font-weight: 700; margin-bottom: .12rem; }
  .pdf-dest-detail { font-size: .81rem; color: #555; line-height: 1.5; }

  .pdf-lignes-wrap  { padding: 0 1.4rem; margin-bottom: 1.2rem; }
  .pdf-lignes-table { width: 100%; border-collapse: collapse; }
  .pdf-lignes-table thead tr { background: var(--primary); color: #fff; }
  .pdf-lignes-table th { padding: .45rem .65rem; text-align: left; font-size: .77rem; font-weight: 700; }
  .pdf-lignes-table td { padding: .4rem .65rem; font-size: .83rem; border-bottom: 1px solid #eee; }
  .pdf-lignes-table tbody tr:nth-child(even) td { background: #f7f7f7; }
  .pdf-ligne-section td {
    background: var(--primary-xlt) !important; color: var(--primary);
    font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  }

  .pdf-totaux-wrap  { padding: 0 1.4rem; display: flex; justify-content: flex-end; margin-bottom: .8rem; }
  .pdf-devis-totaux { width: 265px; border: 1px solid #ddd; border-radius: 6px; overflow: hidden; }
  .pdf-total-row { display: flex; justify-content: space-between; padding: .4rem .8rem; font-size: .86rem; }
  .pdf-total-row + .pdf-total-row { border-top: 1px solid #eee; }
  .pdf-total-ttc { background: var(--primary); color: #fff; font-weight: 700; font-size: .94rem; }

  .pdf-note-wrap { padding: 0 1.4rem; }
  .pdf-devis-note { font-size: .81rem; color: #555; padding-top: .65rem; border-top: 1px solid #eee; margin-top: .35rem; line-height: 1.5; }

  .pdf-signature-block {
    padding: .6rem 1.4rem 0;
    border-top: 1px solid #e5e7eb; margin-top: .6rem;
  }
  .pdf-sig-label { font-size: .7rem; color: #888; margin-bottom: .3rem; }
  .pdf-sig-img   { max-width: 160px; max-height: 65px; border: 1px solid #ddd; border-radius: 4px; background: #fff; padding: 4px; display: block; }
  .pdf-sig-date  { font-size: .68rem; color: #aaa; margin-top: .2rem; }

  .pdf-mentions-wrap {
    padding: .55rem 1.4rem 0;
    font-size: .68rem; color: #777; line-height: 1.6;
    border-top: 1px solid #e5e7eb; margin-top: .6rem;
  }

  .pdf-footer-wrap {
    margin-top: 1.6rem; padding: .42rem 1.4rem;
    border-top: 2px solid var(--primary);
    font-size: .7rem; color: #aaa; text-align: center;
  }
}

.preset-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.preset-info { display: flex; flex-direction: column; gap: .1rem; }
.preset-desc { font-size: .88rem; font-weight: 600; }
.preset-prix { font-size: .75rem; color: var(--gris); }

.preset-picker {
  background: var(--surface); border-radius: 8px;
  margin-top: .4rem; overflow: hidden; border: 1px solid var(--border);
}
.preset-pick-btn {
  width: 100%; display: flex; justify-content: space-between;
  align-items: center; padding: .65rem .9rem;
  background: none; border: none; border-bottom: 1px solid var(--border);
  cursor: pointer; font-family: inherit; font-size: .85rem;
  text-align: left; color: var(--noir);
}
.preset-pick-btn:last-child { border-bottom: none; }
.preset-pick-btn:active { background: var(--primary-xlt); }
.preset-pick-prix { font-size: .78rem; color: var(--primary); font-weight: 600; }

.couleurs-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.couleur-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer; transition: border-color .15s;
}
.couleur-btn.active { border-color: var(--noir); }

.btn-voice {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; padding: 0 .3rem;
  vertical-align: middle; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.btn-voice.voice-active { animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

.detail-section { margin-top: 1.2rem; }
.detail-section-title {
  font-size: .7rem; font-weight: 700; color: var(--gris);
  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(--primary-lt);
  font-size: 1.4rem; cursor: pointer; padding: 0 .3rem;
}

/* ── NOTES ── */
.note-card { border-left: 3px solid transparent; cursor: pointer; }
.note-card--rappel { border-left-color: var(--orange); }
.note-card--urgent { border-left-color: var(--rouge); background: var(--rouge-lt); }
[data-theme="dark"] .note-card--urgent { background: rgba(200,69,59,.15); }

.note-title    { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: .3rem; }
.note-chantier-badge {
  display: inline-block; font-size: .72rem; font-weight: 500;
  color: var(--brand); background: var(--brand-tint);
  padding: 2px 8px; border-radius: 99px; margin-bottom: .3rem; cursor: pointer;
}
.note-content  { font-size: .82rem; color: var(--text-soft); line-height: 1.5; }
.note-rappel   { font-size: .72rem; color: var(--orange); margin-top: .4rem; font-weight: 500; }
.note-rappel.urgent { color: var(--rouge); }

.tab-count--urgent { background: var(--rouge-lt); color: var(--rouge); }
.tab-count--amber  { background: var(--orange-lt); color: var(--orange); }

/* ── 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(--border); cursor: pointer; position: relative;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* Overlay spinner pendant upload optimiste */
.photo-uploading-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.38);
  border-radius: inherit;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.photo-spinner {
  width: 24px; height: 24px;
  border: 3px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: photo-spin .7s linear infinite;
}
@keyframes photo-spin { to { transform: rotate(360deg); } }
.photo-galerie-badge {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,.55); border-radius: 4px;
  font-size: .75rem; padding: 1px 4px; line-height: 1.4; pointer-events: none;
}
.photo-add {
  aspect-ratio: 1; border-radius: 8px;
  border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: var(--gris-lt);
  cursor: pointer; background: none;
}
.photo-cat-badge {
  position: absolute; bottom: 4px; left: 4px;
  border-radius: 4px; font-size: .6rem; font-weight: 800;
  padding: 2px 5px; line-height: 1.3; pointer-events: none; letter-spacing: .04em;
}
.photo-cat-badge--avant { background: #2563EB; color: #fff; }
.photo-cat-badge--apres { background: #16A34A; color: #fff; }
.photos-sub-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-mute);
  margin: .85rem 0 .25rem; display: flex; align-items: center; gap: .35rem;
}
.photos-sub-label:first-of-type { margin-top: .4rem; }
.photos-sub-label span {
  background: var(--bg-elev); border-radius: 10px;
  padding: 0 .45rem; font-size: .62rem; font-weight: 500; line-height: 1.6;
}
.photo-cat-chips { display: flex; gap: .5rem; margin-bottom: 1rem; }
.photo-cat-chip {
  flex: 1; padding: .45rem .4rem; border-radius: 8px;
  border: 2px solid var(--border); font-size: .82rem; font-weight: 600;
  background: var(--bg); color: var(--text-soft); cursor: pointer; transition: all .15s;
}
.photo-cat-chip.active { border-color: var(--brand); color: var(--brand); background: var(--brand-tint); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-box {
  background: var(--surface);
  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(--border); border-radius: 2px;
  margin: 0 auto 1.2rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--noir); margin-bottom: 1.2rem; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 1rem);
  left: 50%; transform: translateX(-50%);
  background: var(--noir); color: #fff;
  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; }

/* ── APP MENU ── */
.menu-profile-header {
  background: linear-gradient(180deg, var(--brand-50) 0%, var(--bg) 100%);
  border-radius: 20px 20px 0 0; position: relative; overflow: hidden;
}
[data-theme="dark"] .menu-profile-header { background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg) 100%); }
.menu-profile-halo {
  position: absolute; top: -50px; right: -30px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand) 0%, transparent 70%);
  opacity: .10; pointer-events: none;
}
.menu-profile-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-elev); border-radius: 16px; border: 1px solid var(--border);
  padding: 14px 16px; box-shadow: 0 4px 14px var(--brand-tint);
}
.menu-user-avatar {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 800; color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 10px var(--brand-tint);
}
.menu-role-badge {
  font-size: .6rem; font-weight: 800; letter-spacing: .05em;
  color: #fff; padding: 2px 6px; border-radius: 4px;
}

.menu-section-label {
  font-size: .68rem; font-weight: 800; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .1em;
  margin: 18px 0 9px; display: flex; align-items: center; gap: 8px;
}
.menu-section-label::before {
  content: ''; width: 14px; height: 2px; border-radius: 2px;
  background: var(--brand); flex-shrink: 0;
}

.menu-espace-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.menu-espace-tile {
  background: var(--bg-elev); border-radius: 14px; border: 1px solid var(--border);
  padding: 14px 8px; text-align: center; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform .15s;
}
.menu-espace-tile:active { transform: scale(.95); }
.menu-espace-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.menu-espace-label { font-size: .8rem; font-weight: 700; color: var(--text); }
.menu-espace-count { font-size: .74rem; color: var(--text-mute); }

.menu-backup-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--brand-tint); border: 1px solid var(--brand-soft);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 6px;
}
.menu-backup-badge {
  font-size: .72rem; font-weight: 800;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap; flex-shrink: 0;
}

.menu-list-group {
  background: var(--bg-elev); border-radius: 14px;
  border: 1px solid var(--border); overflow: hidden; margin-bottom: 4px;
}
.menu-list-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 13px 16px;
  background: none; border: none; border-bottom: 1px solid var(--border);
  cursor: pointer; font-family: inherit; color: var(--text); text-align: left;
  transition: background .12s;
}
.menu-list-group .menu-list-item:last-child { border-bottom: none; }
.menu-list-item:active { background: var(--brand-tint); }
.menu-list-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.menu-list-body  { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.menu-list-label { font-size: .88rem; font-weight: 600; color: var(--text); }
.menu-list-sub   { font-size: .74rem; color: var(--text-mute); }
.menu-list-badge { font-size: .7rem; font-weight: 700; color: var(--brand); background: var(--brand-tint); padding: 2px 7px; border-radius: 6px; flex-shrink: 0; }
.menu-list-arrow { width: 14px; height: 14px; color: var(--text-mute); flex-shrink: 0; }

.menu-logout-btn {
  margin-top: 20px; width: 100%; padding: 14px; border-radius: 14px;
  background: var(--rouge-lt); color: var(--rouge); font-size: .88rem; font-weight: 700;
  border: 1px solid rgba(200,69,59,.2); cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
[data-theme="dark"] .menu-logout-btn { background: rgba(200,69,59,.15); border-color: rgba(200,69,59,.3); }
[data-theme="dark"] .menu-list-icon  { background: rgba(255,255,255,.1) !important; color: var(--text) !important; }
[data-theme="dark"] .menu-espace-icon { background: rgba(255,255,255,.1) !important; color: var(--text) !important; }

/* ── TOGGLE SWITCH ── */
.toggle-switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #CBD5E1; border-radius: 13px; transition: .2s;
}
[data-theme="dark"] .toggle-slider { background: var(--border); }
.toggle-slider::before {
  position: absolute; content: '';
  width: 20px; height: 20px; border-radius: 50%;
  left: 3px; top: 3px;
  background: #fff; transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ── SEGMENT BUTTON ── */
.segment-btn {
  padding: .5rem .3rem; border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface); color: var(--gris);
  font-size: .8rem; font-weight: 600;
  cursor: pointer; transition: all .15s; text-align: center;
}
.segment-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── 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 CHANTIER ── */
@media print {
  @page { size: A4; margin: 1.5cm; }
  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 #1E40AF; margin-bottom: 1.4rem;
  }
  .print-logo { font-size: 1.4rem; font-weight: 800; color: #1E40AF; }
  .print-date { font-size: .8rem; color: #64748B; }
  .print-title { font-size: 1.6rem; font-weight: 700; color: #1E40AF; margin-bottom: .4rem; }

  .print-badge { display: inline-block; padding: .18rem .6rem; border-radius: 6px; font-size: .72rem; font-weight: 600; margin-bottom: 1rem; }
  .print-badge-en-cours   { background: #DCFCE7; color: #166534; }
  .print-badge-en-attente { background: #FEF3C7; color: #92400E; }
  .print-badge-termine    { background: #F1F5F9; color: #475569; }

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

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

  .print-note { margin-bottom: .8rem; padding: .6rem .8rem; border: 1px solid #E2E8F0; border-radius: 6px; }
  .print-note-title   { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
  .print-note-rappel  { font-size: .78rem; color: #2563EB; 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 #E2E8F0; font-size: .72rem; color: #aaa; text-align: center;
  }
}

/* ═══════════════════════════════════════════ AGENDA ═══ */
.ag-nav { display:flex; align-items:center; justify-content:space-between; padding:.6rem 1rem; border-bottom:1px solid var(--border); }
.ag-nav-btn { background:var(--bg-elev); border:1px solid var(--border); border-radius:8px; width:36px; height:36px; font-size:1.2rem; cursor:pointer; color:var(--text); display:flex; align-items:center; justify-content:center; }
.ag-nav-title { font-weight:700; font-size:.88rem; color:var(--text); }
.ag-today-btn { background:none; border:none; color:var(--brand); font-size:.7rem; cursor:pointer; padding:2px 0 0; display:block; text-align:center; font-weight:600; }

/* Mois */
.ag-month-grid { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:1px; background:var(--border); }
.ag-month-header { background:var(--bg-base); padding:.35rem 0; text-align:center; font-size:.65rem; font-weight:700; color:var(--text-mute); text-transform:uppercase; min-width:0; overflow:hidden; }
.ag-month-cell { background:var(--bg-base); padding:.25rem; cursor:pointer; overflow:hidden; min-width:0; }
.gc-month-cell { min-height:72px; }
.ag-month-cell:active { background:var(--bg-elev); }
.ag-other-month .ag-day-num { color:var(--text-mute); }
.ag-other-month .gc-chip { opacity:.45; }
.ag-month-cell.ag-today { background:color-mix(in srgb, var(--brand) 8%, var(--bg-base)); }
.ag-day-num { font-size:.72rem; font-weight:700; color:var(--text); margin-bottom:.2rem; }
.ag-today-circle { display:inline-flex; align-items:center; justify-content:center; width:20px; height:20px; background:var(--brand); color:#fff !important; border-radius:50%; font-size:.7rem; }
/* chips mois + all-day */
.gc-chip { font-size:.64rem; font-weight:600; color:#fff; padding:1px 4px; border-radius:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; cursor:pointer; display:block; line-height:1.65; margin-bottom:1px; }
.gc-chip:active { opacity:.8; }

/* Google Calendar — grille horaire */
.gc-wrapper { background:var(--bg-card); border:1px solid var(--border); border-radius:12px; overflow:hidden; margin-bottom:80px; }
.gc-week-header { display:flex; border-bottom:1px solid var(--border); }
.gc-head-day { flex:1; text-align:center; padding:.4rem .1rem; display:flex; flex-direction:column; align-items:center; gap:2px; }
.gc-head-today { background:color-mix(in srgb,var(--brand) 6%,var(--bg-card)); }
.gc-head-day-name { font-size:.6rem; font-weight:700; text-transform:uppercase; color:var(--text-mute); }
.gc-head-today .gc-head-day-name { color:var(--brand); }
.gc-head-day-num { font-size:.88rem; font-weight:700; color:var(--text); width:26px; height:26px; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; }
.gc-head-today .gc-head-day-num { background:var(--brand); color:#fff; }
.gc-gutter { width:36px; flex-shrink:0; }
.gc-allday-row { display:flex; border-bottom:1px solid var(--border); min-height:24px; }
.gc-allday-empty { min-height:0; height:0; border:none; overflow:hidden; }
.gc-allday-col { padding:2px 2px 2px 3px; overflow:hidden; border-left:1px solid var(--border); }
.gc-time-scroll { overflow-y:auto; max-height:460px; }
.gc-time-scroll::-webkit-scrollbar { width:3px; }
.gc-time-scroll::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }
.gc-day-col { border-left:1px solid var(--border); cursor:pointer; position:relative; box-sizing:border-box; }
.gc-event-block { position:absolute; left:2px; right:2px; border-radius:4px; padding:2px 4px; cursor:pointer; overflow:hidden; color:#fff; z-index:1; box-sizing:border-box; display:flex; flex-direction:column; justify-content:flex-start; }
.gc-event-block:active { opacity:.85; }
.gc-ev-title { font-size:.68rem; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.gc-ev-time { font-size:.6rem; opacity:.9; white-space:nowrap; }
.gc-ev-edit { position:absolute; top:1px; right:1px; background:rgba(0,0,0,.2); border:none; border-radius:3px; cursor:pointer; font-size:.65rem; padding:1px 3px; color:#fff; line-height:1; }
.gc-now-line { position:absolute; left:0; right:0; height:2px; background:#ea4335; z-index:2; pointer-events:none; }
.gc-now-dot { position:absolute; left:-4px; top:-4px; width:8px; height:8px; border-radius:50%; background:#ea4335; }

.ag-empty { text-align:center; color:var(--text-mute); font-size:.85rem; padding:2.5rem 0; }

.ag-fab-row { position:fixed; bottom:80px; right:14px; display:flex; flex-direction:column; gap:.4rem; z-index:10; align-items:flex-end; }
.ag-add-btn { background:var(--brand); color:#fff; border:none; border-radius:20px; padding:.55rem 1.1rem; font-size:.82rem; font-weight:700; cursor:pointer; box-shadow:0 2px 10px rgba(0,0,0,.2); }
.ag-add-btn--secondary { background:var(--bg-elev); color:var(--text); border:1px solid var(--border); box-shadow:none; }

.ag-mini-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:.4rem; }
.ag-mini-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:2px; }
.ag-mini-cell { text-align:center; padding:.25rem .1rem; border-radius:7px; cursor:pointer; }
.ag-mini-cell:active { background:var(--bg-elev); }
.ag-mini-today { background:color-mix(in srgb, var(--brand) 10%, var(--bg-base)); }
.ag-mini-day-name { font-size:.55rem; font-weight:700; text-transform:uppercase; color:var(--text-mute); }
.ag-mini-day-num { font-size:.8rem; font-weight:700; color:var(--text); margin:.05rem 0; }
.ag-mini-dots { display:flex; justify-content:center; gap:2px; min-height:8px; align-items:center; }
.ag-db-event-row { display:flex; align-items:flex-start; gap:.5rem; padding:.35rem .4rem; border-radius:8px; cursor:pointer; }
.ag-db-event-row:active { background:var(--bg-base); }
/* ════════════════════════════════════════════════════════ */

/* ── PC / TABLETTE ── */
@media (min-width: 640px) {
  html, body { background: #E2E8F0; overflow: auto; }
  .app, .login-screen { max-width: 480px; margin: 0 auto; }
  .app {
    min-height: 100vh;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    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; }
}
