:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #14171c;
  --muted: #667085;
  --primary: #3b5bdb;
  --primary-hover: #304bc0;
  --primary-soft: #eaefff;
  --awaiting: #b7791f;
  --awaiting-soft: #fdf3e1;
  --progress: #3b5bdb;
  --progress-soft: #eaefff;
  --done: #15803d;
  --done-soft: #e6f6ec;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --high: #c2410c;
  --high-soft: #fdeee6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 236px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #171a1f;
    --surface-2: #20242b;
    --border: #2b3038;
    --text: #eef0f3;
    --muted: #98a1ae;
    --primary: #6d8cff;
    --primary-hover: #8aa3ff;
    --primary-soft: #1e2747;
    --awaiting: #f0b459;
    --awaiting-soft: #33270f;
    --progress: #8aa3ff;
    --progress-soft: #1e2747;
    --done: #4ade80;
    --done-soft: #12301d;
    --danger: #f87171;
    --danger-soft: #3a1515;
    --high: #fb923c;
    --high-soft: #3a2010;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───── Structure ───── */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text); font-weight: 520;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a .count { margin-left: auto; font-size: 12px; background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 1px 8px; }
.nav a.active .count { background: var(--surface); }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 16px 10px 6px; font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20;
}
.content { padding: 26px 28px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.mobile-only { display: none !important; }
.bottom-nav { display: none; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .desktop-only { display: none !important; }
  .mobile-only { display: revert !important; }
  .topbar { padding: 0 16px; height: 56px; padding-top: env(safe-area-inset-top, 0px); height: calc(56px + env(safe-area-inset-top, 0px)); }
  .content { padding: 16px 16px calc(96px + var(--safe-bottom)); }
  h1 { font-size: 22px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
    border-top: 1px solid var(--border); padding: 6px 6px calc(6px + var(--safe-bottom)); justify-content: space-around; align-items: flex-end;
  }
  .bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; position: relative; font-weight: 550;
  }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a .dot { position: absolute; top: 0; right: calc(50% - 18px); background: var(--danger); color: #fff; font-size: 10px; border-radius: 99px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; }
  .bottom-nav .fab {
    width: 58px; height: 58px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 45%, transparent); margin-top: -26px;
  }
  .bottom-nav a.report-link { color: var(--primary); }
}

/* ───── Composants ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 8px 16px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: 38px; transition: background .15s, border-color .15s, transform .1s;
  user-select: none; -webkit-user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.success { background: var(--done); border-color: var(--done); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 11px; min-height: 30px; font-size: 13px; }
.btn.lg { padding: 13px 22px; min-height: 52px; font-size: 16px; }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 38px; border-radius: 50%; }
.icon-svg { width: 18px; height: 18px; flex-shrink: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.section { margin-top: 22px; }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); padding: 9px 12px; min-height: 40px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.textarea { resize: vertical; min-height: 90px; }
.select { appearance: none; 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='%23667085' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
@media (max-width: 899px) { .input, .select, .textarea { font-size: 16px; } }
label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 560; cursor: pointer; color: var(--muted); font-size: 14px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.big button { padding: 10px 16px; font-size: 15px; flex: 1; }
.seg.big { display: flex; }
.seg button.on.high { color: var(--high); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; cursor: pointer; font-weight: 520;
}
.chip:hover { background: var(--surface-2); }
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll .chip { flex-shrink: 0; white-space: nowrap; }
.place-list { min-height: min(52vh, 440px); }
.chips.scroll::-webkit-scrollbar { display: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge.awaiting { background: var(--awaiting-soft); color: var(--awaiting); }
.badge.in_progress { background: var(--progress-soft); color: var(--progress); }
.badge.done { background: var(--done-soft); color: var(--done); }
.badge.high { background: var(--high-soft); color: var(--high); }
.badge.danger, .badge.blocking { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }
.badge.label { background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--c); }
.badge .dot-c { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); flex-shrink: 0; }
.avatar.lg { width: 36px; height: 36px; font-size: 13px; }

/* ───── Stat cards ───── */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; text-align: left; box-shadow: var(--shadow);
  border-top: 3px solid var(--c, var(--border)); transition: transform .12s, box-shadow .12s;
}
.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.stat.on { outline: 2px solid var(--c); outline-offset: -1px; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 560; }
.stat .v { font-size: 28px; font-weight: 760; letter-spacing: -.02em; margin-top: 2px; }
@media (max-width: 899px) {
  .stats { display: flex; overflow-x: auto; gap: 8px; margin: 12px -16px; padding: 2px 16px 6px; scrollbar-width: none; }
  .stats::-webkit-scrollbar { display: none; }
  .stat { padding: 9px 13px; flex: 0 0 auto; min-width: 112px; box-shadow: none; }
  .stat .k { font-size: 12px; white-space: nowrap; }
  .stat .v { font-size: 21px; }
  .page-head p { display: none; }
  .page-head { margin-bottom: 4px; }
  .more-filters { display: none; }
  .more-filters.open { display: contents; }
  .mobile-only.row { display: flex !important; }
}
@media (min-width: 900px) { .more-filters { display: contents; } }

/* ───── Filtres ───── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .select, .filters .input { width: auto; min-width: 150px; min-height: 38px; border-radius: 999px; }
.filters .search { flex: 1; min-width: 200px; position: relative; }
.filters .search .input { width: 100%; padding-left: 36px; }
.filters .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
@media (max-width: 899px) {
  .filters .select { min-width: 0; flex: 1 1 140px; }
  .filters .search { flex: 1 1 0; min-width: 0; }
  .filters .seg { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .filters .seg button { white-space: nowrap; flex: 1 0 auto; }
}

/* ───── Liste des tickets ───── */
.tlist { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.trow {
  display: grid; grid-template-columns: 22px 56px minmax(0, 1fr) 150px 130px 150px 170px; align-items: center; gap: 14px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; box-shadow: var(--shadow); transition: border-color .12s;
}
.trow:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.trow.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.trow .thumb, .tcard .thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.trow .title, .tcard .title { font-weight: 640; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.trow .meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 3px; }
.trow .cell { font-size: 13.5px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.trow .place { font-weight: 650; }
.trow input[type=checkbox], .tcard input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.overdue-txt { color: var(--danger); font-weight: 600; }
@media (max-width: 1180px) { .trow { grid-template-columns: 22px 56px minmax(0, 1fr) 120px 120px 150px; } .trow .c-assignee { display: none; } }

.tcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow); }
.tcard.selected { border-color: var(--primary); }
.tcard .top { display: flex; gap: 12px; align-items: flex-start; }
.tcard .thumb { width: 64px; height: 64px; }
.tcard .bottom { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); margin-top: 11px; padding-top: 10px; font-size: 13.5px; flex-wrap: wrap; }
.tcard .action { margin-top: 10px; }
.place-pill { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }

.bulkbar {
  position: sticky; bottom: 16px; z-index: 25; margin-top: 14px; background: var(--text); color: var(--bg); border-radius: 14px; padding: 10px 12px 10px 18px;
  display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow-lg); flex-wrap: wrap;
}
.bulkbar .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.bulkbar .select { width: auto; background-color: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, transparent); min-height: 34px; border-radius: 999px; }
.bulkbar .select option { color: #111; }
@media (max-width: 899px) { .bulkbar { bottom: calc(84px + var(--safe-bottom)); } }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; margin: 0 auto 10px; opacity: .6; }

/* ───── Drawer / modale ───── */
.overlay { position: fixed; inset: 0; background: rgba(15, 18, 24, .38); z-index: 50; animation: fade .15s ease-out; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); z-index: 51; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: slide-in .22s cubic-bezier(.2, .8, .2, 1);
}
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); padding-top: calc(16px + env(safe-area-inset-top, 0px)); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; -webkit-overflow-scrolling: touch; }
.drawer-foot { border-top: 1px solid var(--border); padding: 12px 18px calc(12px + var(--safe-bottom)); display: flex; gap: 8px; }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 24px)); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); border-radius: 18px; z-index: 51; box-shadow: var(--shadow-lg); padding: 22px; animation: pop .18s cubic-bezier(.2, .8, .2, 1);
}
@media (max-width: 899px) {
  .modal { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; padding-bottom: calc(22px + var(--safe-bottom)); animation: sheet .25s cubic-bezier(.2, .8, .2, 1); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes pop { from { transform: translate(-50%, -48%) scale(.97); opacity: 0; } }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.info { border: 1px solid var(--border); border-radius: 11px; padding: 10px 12px; }
.info .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; display: flex; gap: 5px; align-items: center; }
.info .v { font-weight: 640; margin-top: 3px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.gallery img, .gallery .add { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: zoom-in; background: var(--surface-2); }
.gallery .add { display: grid; place-items: center; border: 1.5px dashed var(--border); cursor: pointer; color: var(--muted); }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 80; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 6px; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 12px; padding-bottom: 14px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); flex-shrink: 0; }
.tl-icon svg { width: 14px; height: 14px; }
.comment { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.comment .who { font-weight: 640; font-size: 13.5px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 9px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--primary); }

/* ───── Signalement ───── */
.report { max-width: 640px; margin: 0 auto; }
.photo-drop {
  border: 2px dashed var(--border); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; background: var(--surface);
  color: var(--muted); text-align: center; transition: border-color .15s, background .15s;
}
.photo-drop:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.photo-drop svg { width: 34px; height: 34px; }
.photo-row { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-row .ph { position: relative; width: 84px; height: 84px; }
.photo-row .ph img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.photo-row .ph button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); cursor: pointer; display: grid; place-items: center; }
.photo-row .ph-add { width: 84px; height: 84px; border-radius: 12px; border: 1.5px dashed var(--border); display: grid; place-items: center; cursor: pointer; color: var(--muted); background: var(--surface); }
.place-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); cursor: pointer; text-align: left; min-height: 52px;
}
.place-btn .v { font-weight: 700; font-size: 17px; }
.place-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 7px; }
.place-grid button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 11px 4px; font-weight: 650; cursor: pointer; font-size: 14.5px; position: relative;
}
.place-grid button:hover { border-color: var(--primary); }
.place-grid button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.place-grid button .n { position: absolute; top: -6px; right: -4px; background: var(--awaiting); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; min-width: 16px; line-height: 16px; }
.place-grid.wide { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.floor-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin: 14px 0 7px; }
.dup-warning { border: 1px solid color-mix(in srgb, var(--awaiting) 40%, transparent); background: var(--awaiting-soft); border-radius: 12px; padding: 11px 13px; font-size: 14px; }
.dup-warning .dup { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.toggle, label.field.toggle { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; background: var(--surface); }
.toggle input { width: 20px; height: 20px; accent-color: var(--danger); }
.success-screen { text-align: center; padding: 30px 10px; }
.success-screen .check { width: 74px; height: 74px; border-radius: 50%; background: var(--done-soft); color: var(--done); display: grid; place-items: center; margin: 0 auto 14px; animation: pop2 .3s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes pop2 { from { transform: scale(.6); opacity: 0; } }

/* ───── Appareil photo intégré ───── */
.camera { position: fixed; inset: 0; z-index: 85; background: #000; color: #fff; display: flex; flex-direction: column; }
.cam-video { flex: 1; width: 100%; min-height: 0; object-fit: cover; background: #000; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.on { animation: camflash .25s ease-out; }
@keyframes camflash { from { opacity: .8; } to { opacity: 0; } }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.cam-close { color: #fff; }
.cam-bottom { background: rgba(0, 0, 0, .85); padding: 10px 16px calc(16px + var(--safe-bottom)); }
.cam-strip { display: flex; gap: 10px; min-height: 0; overflow-x: auto; margin-bottom: 10px; padding: 7px 7px 0 0; }
.cam-strip:empty { display: none; }
.cam-strip .ph { position: relative; flex: 0 0 56px; height: 56px; }
.cam-strip .ph img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.cam-strip .ph button { position: absolute; top: -5px; right: -5px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #fff; color: #000; display: grid; place-items: center; padding: 0; }
.cam-controls { display: flex; align-items: center; justify-content: space-between; }
.cam-controls .btn { width: 96px; padding: 8px 6px; }
.cam-shutter { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; transition: transform .1s; }
.cam-shutter:active { transform: scale(.92); background: rgba(255,255,255,.6); }
.toast-action { background: none; border: 0; color: var(--primary-soft); font-weight: 700; cursor: pointer; padding: 4px 6px; text-decoration: underline; flex-shrink: 0; }
.toast .grow { flex: 1; }

/* ───── Analyse ───── */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .k { font-size: 13px; color: var(--muted); font-weight: 560; }
.kpi .v { font-size: 26px; font-weight: 760; letter-spacing: -.02em; margin-top: 2px; }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.charts .span2 { grid-column: span 2; }
@media (max-width: 899px) { .charts { grid-template-columns: 1fr; } .charts .span2 { grid-column: auto; } }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; font-size: 13.5px; margin-bottom: 7px; }
.hbar .track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 99px; }
.hbar .n { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 5px; }
.heat div { border-radius: 8px; padding: 7px 2px; text-align: center; font-size: 12px; font-weight: 650; cursor: pointer; border: 1px solid var(--border); }
.heat div small { display: block; font-weight: 500; font-size: 10.5px; opacity: .85; }
.insight { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.insight:last-child { border-bottom: 0; }
.insight .ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ───── Toast ───── */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 24px); max-width: 440px; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 550; font-size: 14px; pointer-events: auto; animation: sheet .2s ease-out; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--danger); color: #fff; }

/* ───── Connexion ───── */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { font-size: 24px; margin: 14px 0 4px; }

.auth .card.login-card { width: min(460px, 100%); }
.avatar.xl { width: 58px; height: 58px; font-size: 19px; background: var(--primary-soft); color: var(--primary); }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-top: 4px; }
.who { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 14px 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; transition: border-color .12s, transform .1s; }
.who:hover { border-color: var(--primary); }
.who:active { transform: scale(.97); }
.who-name { font-weight: 650; text-align: center; line-height: 1.2; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 20px 0 6px; }
.pin-dots span { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--muted); transition: background .1s; }
.pin-dots span.on { background: var(--text); border-color: var(--text); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 6px auto 0; }
.pin-key { height: 64px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); font-size: 24px; font-weight: 600; cursor: pointer; display: grid; place-items: center; user-select: none; -webkit-user-select: none; }
.pin-key:active { background: var(--surface-2); transform: scale(.96); }
.pin-key.fn { background: var(--surface-2); }
.pin-key .icon-svg { width: 24px; height: 24px; }
.notif-banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--primary-soft); color: var(--text); margin-bottom: 14px; flex-wrap: wrap; }
.notif-banner .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; flex-shrink: 0; }

.offline-banner { background: var(--awaiting-soft); color: var(--awaiting); text-align: center; font-size: 13.5px; padding: 7px; font-weight: 600; }
.notif { display: flex; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif:last-child { border-bottom: 0; }
.notif.unread { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.notif .bullet { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 7px; flex-shrink: 0; }
.notif:not(.unread) .bullet { background: transparent; }
.kbd { font-size: 11px; border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; color: var(--muted); }

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
}
.qr-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.qr-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; break-inside: avoid; background: #fff; color: #111; }
.qr-card svg { width: 140px; height: 140px; margin: 6px auto; display: block; }
.qr-card .code { font-size: 20px; font-weight: 800; }

/* ───── Impression ───── */
.print-doc { background: #fff; color: #111; padding: 24px; border-radius: 12px; border: 1px solid var(--border); }
.print-doc .muted { color: #666; }
.p-title { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 14px; }
.p-title h1 { font-size: 22px; margin: 2px 0; }
.p-group h2 { font-size: 15px; margin: 18px 0 6px; padding: 5px 9px; background: #f1f3f6; border-radius: 6px; break-after: avoid; }
.p-ticket { border: 1px solid #ddd; border-radius: 8px; padding: 8px 11px; margin-bottom: 8px; break-inside: avoid; font-size: 13px; }
.p-head { display: flex; gap: 8px; align-items: baseline; }
.p-id { color: #666; font-variant-numeric: tabular-nums; }
.p-state { font-size: 11px; border: 1px solid #999; border-radius: 99px; padding: 0 8px; white-space: nowrap; }
.p-done { background: #e6f6ec; border-color: #9cd3ae; }
.p-in_progress { background: #eaefff; border-color: #a9b8f0; }
.p-meta { display: flex; flex-wrap: wrap; gap: 3px 14px; color: #444; margin-top: 4px; font-size: 12px; }
.p-res, .p-comments { margin-top: 5px; font-size: 12px; }
.p-comments div { margin-top: 2px; }
.p-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.p-photos img { width: 120px; height: 120px; object-fit: cover; border-radius: 4px; }
.p-sign { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 8px; color: #777; font-size: 11px; }
@media print {
  @page { margin: 12mm; }
  html, body, .app, .main { background: #fff !important; color: #111; }
  .toasts, .drawer, .overlay, .modal { display: none !important; }
  .print-doc { border: 0; padding: 0; border-radius: 0; }
  .content { padding: 0 !important; }
}

/* ───── Planning ───── */
.rec-card h3 { font-size: 16px; }
.rec-card .icon-svg { width: 15px; height: 15px; vertical-align: -2px; }
@media (max-width: 899px) { .rec-card > .row { flex-wrap: wrap; } }
