/* =============================================================================
   Bombay Advisory APW — feuille de style unique, mobile-first
   - Cibles tactiles >= 44px, champs 16px (pas de zoom iOS)
   - Barre de navigation basse sur mobile, barre latérale sur ordinateur
   - Thème clair + sombre (prefers-color-scheme)
   ============================================================================= */
:root {
  --brand: #0f2a4a;
  --brand-2: #1d4d82;
  --gold: #c8a24a;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --border: #d9e0e8;
  --text: #16202c;
  --muted: #5b6b7d;
  --focus: #2f7de1;
  --ok: #1d7a46;       --ok-bg: #e3f4ea;
  --warn: #9a6400;     --warn-bg: #fff3dc;
  --danger: #b3261e;   --danger-bg: #fde7e5;
  --info: #1d5fa8;     --info-bg: #e5effb;
  --purple: #6a3fb0;   --purple-bg: #efe8fb;
  --teal: #0f7472;     --teal-bg: #dff3f2;
  --gray-bg: #eceff3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,32,52,.06), 0 4px 16px rgba(16,32,52,.06);
  --nav-h: 64px;
  --top-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1520; --surface: #152131; --surface-2: #1b2a3d; --border: #2a3b51;
    --text: #e6edf5; --muted: #9fb0c3; --brand-2: #7fb0ea;
    --ok: #6fd39a; --ok-bg: #173a28; --warn: #f0c060; --warn-bg: #3b2f14;
    --danger: #ff8f86; --danger-bg: #3d1b19; --info: #8fc0f5; --info-bg: #162e4b;
    --purple: #c3a6f5; --purple-bg: #2b2044; --teal: #6fd6d2; --teal-bg: #133634; --gray-bg: #243244;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
a { color: var(--brand-2); }
h1 { font-size: 1.35rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ----------------------------------------------------------------- En-tête */
.topbar {
  position: sticky; top: 0; z-index: 30; height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0; display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff;
}
.topbar .logo { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; }
.topbar .logo img { width: 32px; height: 32px; border-radius: 8px; }
.topbar .logo span small { display: block; font-weight: 400; font-size: .7rem; color: #c9d6e6; line-height: 1; }
.topbar .spacer { flex: 1; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: inherit;
  text-decoration: none; font-size: 1.25rem; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }
.count-badge {
  position: absolute; top: 4px; right: 2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: #e5484d; color: #fff; font-size: .72rem; font-weight: 700;
  display: none; align-items: center; justify-content: center; line-height: 1;
}
.count-badge.show { display: inline-flex; }
.offline-banner { display: none; background: var(--warn-bg); color: var(--warn); text-align: center; padding: 6px; font-size: .9rem; }
body.is-offline .offline-banner { display: block; }

/* ----------------------------------------------------------------- Mise en page */
.layout { display: block; }
.sidebar { display: none; }
main { padding: 16px; max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { flex: 1 1 auto; min-width: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head .head-main { flex: 1 1 auto; min-width: 0; }
@media (max-width: 640px) { .page-head .head-main { flex-basis: calc(100% - 48px); } }

@media (min-width: 992px) {
  body { padding-bottom: 0; }
  .layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - var(--top-h)); }
  .sidebar {
    display: block; background: var(--surface); border-right: 1px solid var(--border);
    padding: 12px 8px; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto;
  }
  .bottom-nav { display: none !important; }
  main { padding: 24px 32px; width: 100%; }
}
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.active { background: var(--info-bg); color: var(--brand-2); }
.sidebar .sep { margin: 12px 12px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sidebar .ico { width: 22px; text-align: center; }

/* Barre de navigation basse (mobile) — accessible au pouce */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .72rem; color: var(--muted); text-decoration: none; border: 0; background: none; position: relative; cursor: pointer;
}
.bottom-nav .ico { font-size: 1.35rem; line-height: 1; }
.bottom-nav a.active { color: var(--brand-2); font-weight: 600; }
.bottom-nav .fab-new .ico {
  width: 48px; height: 48px; margin-top: -18px; border-radius: 50%; background: var(--gold); color: #1a1300;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; box-shadow: var(--shadow);
}
.bottom-nav .count-badge { top: 4px; right: calc(50% - 22px); }

/* Menu mobile (tiroir) */
.drawer { position: fixed; inset: 0; z-index: 60; display: none; }
.drawer.open { display: block; }
.drawer .backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.drawer .panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(320px, 86vw); background: var(--surface);
  padding: calc(16px + env(safe-area-inset-top)) 8px 16px; overflow-y: auto;
}
.drawer .panel a, .drawer .panel button.link {
  display: flex; gap: 12px; align-items: center; padding: 12px; min-height: 48px; border-radius: 8px;
  color: var(--text); text-decoration: none; width: 100%; background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.drawer .panel a:hover { background: var(--surface-2); }

/* ----------------------------------------------------------------- Cartes, grilles */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 992px) { .grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* Tuiles KPI */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi {
  display: block; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; min-height: 88px; box-shadow: var(--shadow);
}
.kpi:hover { border-color: var(--brand-2); }
.kpi .v { font-size: 1.75rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .82rem; color: var(--muted); }
.kpi.alert { border-left: 4px solid var(--danger); }
.kpi.alert .v { color: var(--danger); }

/* Montants par devise */
.money-table td.num, .money-table th.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ----------------------------------------------------------------- Badges de statut (couleur + libellé) */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-gray { background: var(--gray-bg); color: var(--muted); }
.badge-blue { background: var(--info-bg); color: var(--info); }
.badge-teal { background: var(--teal-bg); color: var(--teal); }
.badge-green { background: var(--ok-bg); color: var(--ok); }
.badge-orange { background: var(--warn-bg); color: var(--warn); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.late { color: var(--danger); font-weight: 600; font-size: .8rem; white-space: nowrap; }
.late::before { content: "⏰ "; }
.soon { color: var(--warn); font-weight: 600; font-size: .8rem; }

/* ----------------------------------------------------------------- Formulaires */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
.req::after { content: " *"; color: var(--danger); }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search],
select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(47,125,225,.2); }
.hint { display: block; margin-top: 4px; font-size: .82rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; min-height: 44px; }
.check input { width: 22px; height: 22px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }
.form-actions {
  display: flex; gap: 10px; flex-wrap: wrap; position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 5;
  background: var(--bg); padding: 12px 0;
}
@media (min-width: 992px) { .form-actions { bottom: 0; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px;
  border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--surface-2); color: var(--text);
}
.btn-primary { background: var(--brand-2); color: #fff; }
.btn-success { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-gold { background: var(--gold); color: #1a1300; }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
@media (prefers-color-scheme: dark) { .btn-primary { background: #2f6fb8; } .btn-success { background: #1d7a46; } .btn-danger { background: #b3261e; } }

/* Choix segmenté (Conforme / Non conforme, Autoriser / Refuser) */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-bottom: 12px; }
.segmented input { position: absolute; opacity: 0; }
.segmented label {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 46px; padding: 8px;
  border: 1px solid var(--border); border-radius: 10px; font-weight: 600; cursor: pointer; margin: 0;
}
.segmented input:checked + label { background: var(--info-bg); border-color: var(--brand-2); color: var(--brand-2); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); }

/* ----------------------------------------------------------------- Photo / upload mobile */
.upload-box { border: 2px dashed var(--border); border-radius: var(--radius); padding: 12px; }
.upload-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.upload-buttons label { margin: 0; }
.upload-buttons input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-preview { margin-top: 10px; display: none; align-items: center; gap: 10px; }
.upload-preview.show { display: flex; }
.upload-preview img { max-width: 96px; max-height: 120px; border-radius: 8px; border: 1px solid var(--border); object-fit: cover; }
.upload-preview .name { font-size: .88rem; word-break: break-all; }

/* ----------------------------------------------------------------- Messages */
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger); }
.flash-warning { background: var(--warn-bg); color: var(--warn); }
.flash-info { background: var(--info-bg); color: var(--info); }
.note { padding: 10px 12px; border-radius: 10px; background: var(--info-bg); color: var(--info); font-size: .9rem; margin-bottom: 12px; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.danger { background: var(--danger-bg); color: var(--danger); }

/* ----------------------------------------------------------------- Aide contextuelle */
.help-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--brand-2); color: var(--brand-2); background: var(--surface); font-weight: 800; cursor: pointer; flex: none;
}
details.help-inline { background: var(--info-bg); border-radius: 10px; padding: 0 12px; margin-bottom: 16px; color: var(--text); }
details.help-inline > summary { cursor: pointer; padding: 10px 0; font-weight: 600; color: var(--info); list-style: none; min-height: 44px; display: flex; align-items: center; }
details.help-inline > summary::-webkit-details-marker { display: none; }
details.help-inline > summary::before { content: "💡"; margin-right: 8px; }
details.help-inline[open] { padding-bottom: 10px; }
details.help-inline ul { margin: 4px 0 8px; padding-left: 20px; }
.tip {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-left: 4px; border-radius: 50%;
  background: var(--surface-2); color: var(--brand-2); font-size: .75rem; font-weight: 800; cursor: help; position: relative; vertical-align: middle;
}
.tip:hover::after, .tip:focus::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: 130%; transform: translateX(-50%); width: max-content; max-width: 260px;
  background: #16202c; color: #fff; padding: 8px 10px; border-radius: 8px; font-size: .8rem; font-weight: 400; z-index: 20; white-space: normal;
}

/* Modale (aide, aperçu) — bottom sheet sur mobile */
.modal { position: fixed; inset: 0; z-index: 70; display: none; align-items: flex-end; justify-content: center; }
.modal.open { display: flex; }
.modal .backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal .sheet {
  position: relative; background: var(--surface); width: 100%; max-height: 85vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 720px) { .modal { align-items: center; } .modal .sheet { width: 640px; border-radius: 18px; } }
.modal .sheet header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.modal .sheet header h2 { flex: 1; margin: 0; }
.modal.viewer .sheet { width: min(1000px, 100%); height: 90vh; max-height: 90vh; display: flex; flex-direction: column; }
.viewer-body { flex: 1; overflow: auto; background: var(--surface-2); border-radius: 10px; touch-action: pan-x pan-y pinch-zoom; }
.viewer-body img { display: block; max-width: 100%; margin: 0 auto; transform-origin: top left; }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

/* ----------------------------------------------------------------- Tableaux → cartes sur mobile */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-size: .92rem; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: var(--surface-2); }
@media (max-width: 760px) {
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; padding: 8px 12px; }
  table.responsive td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; }
  table.responsive td.main { display: block; text-align: left; font-weight: 600; }
  table.responsive td.main::before { display: none; }
}

/* Liste de dossiers en cartes (tâches) */
.dossier-card {
  display: block; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  color: var(--text); text-decoration: none; margin-bottom: 10px; box-shadow: var(--shadow);
}
.dossier-card:hover { border-color: var(--brand-2); }
.dossier-card.is-late { border-left: 4px solid var(--danger); }
.dossier-card.is-soon { border-left: 4px solid var(--warn); }
.dossier-card .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.dossier-card .num { font-weight: 700; font-size: .92rem; }
.dossier-card .amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dossier-card .sup { color: var(--muted); font-size: .9rem; margin: 2px 0 6px; }
.dossier-card .row3 { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Filtres */
.quick-filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: .88rem; min-height: 40px; display: inline-flex; align-items: center; white-space: nowrap;
}
.chip.active { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
details.filters > summary { list-style: none; }
details.filters > summary::-webkit-details-marker { display: none; }
@media (min-width: 992px) { details.filters > summary { display: none; } }
.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.searchbar input { flex: 1; }
.pagination { display: flex; gap: 6px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }

/* ----------------------------------------------------------------- Fiche dossier */
.dossier-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.amounts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
@media (min-width: 720px) { .amounts { grid-template-columns: repeat(4, 1fr); } }
.amounts div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.amounts .l { font-size: .78rem; color: var(--muted); display: block; }
.amounts .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.amounts .v.warn { color: var(--danger); }

.stepper { display: flex; gap: 4px; overflow-x: auto; padding: 4px 0 8px; margin: 0 0 8px; list-style: none; scrollbar-width: thin; }
.stepper li { flex: 1 0 72px; text-align: center; font-size: .72rem; color: var(--muted); position: relative; padding-top: 30px; }
.stepper li::before {
  content: attr(data-n); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted);
}
.stepper li.done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.stepper li.current { color: var(--text); font-weight: 700; }
.stepper li.current::before { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.stepper li.blocked::before { background: var(--danger); border-color: var(--danger); color: #fff; content: "!"; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; position: sticky; top: var(--top-h); background: var(--bg); z-index: 10; }
.tabs a { padding: 12px 14px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--brand-2); border-bottom-color: var(--brand-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
dl.props { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin: 0; }
dl.props dt { font-size: .8rem; color: var(--muted); margin-top: 8px; }
dl.props dd { margin: 0; font-weight: 500; word-break: break-word; }
@media (min-width: 720px) { dl.props { grid-template-columns: 200px 1fr; } dl.props dt { margin-top: 0; padding: 6px 0; } dl.props dd { padding: 6px 0; } }

.action-card { border: 2px solid var(--brand-2); }
.action-card h2 { color: var(--brand-2); }
.action-block + .action-block { border-top: 1px dashed var(--border); margin-top: 16px; padding-top: 16px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand-2); }
.timeline li.sys::before { background: var(--muted); }
.timeline li.neg::before { background: var(--danger); }
.timeline .t-head { font-weight: 600; }
.timeline .t-meta { font-size: .8rem; color: var(--muted); }
.timeline .t-reason { background: var(--danger-bg); color: var(--danger); padding: 6px 10px; border-radius: 8px; margin-top: 4px; font-size: .9rem; }
.timeline .t-details { font-size: .8rem; color: var(--muted); margin-top: 4px; word-break: break-word; }

.attachments { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .attachments { grid-template-columns: 1fr 1fr; } }
.att { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.att .thumb { width: 52px; height: 52px; border-radius: 8px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; overflow: hidden; flex: none; }
.att .thumb img { width: 100%; height: 100%; object-fit: cover; }
.att .meta { flex: 1; min-width: 0; font-size: .85rem; }
.att .meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------------- Kanban */
.kanban { display: grid; gap: 12px; }
@media (min-width: 992px) { .kanban { grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); overflow-x: auto; padding-bottom: 8px; } }
.kanban-col { background: var(--surface-2); border-radius: var(--radius); padding: 0 10px 10px; }
.kanban-col > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; font-weight: 700; cursor: pointer; min-height: 48px; }
.kanban-col > summary::-webkit-details-marker { display: none; }
.kanban-col .n { background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: .85rem; }
.kanban-col .dossier-card { margin-bottom: 8px; }
@media (min-width: 992px) { .kanban-col > summary { pointer-events: none; } }

/* Barres simples (analyse) — une seule série, une teinte */
.bar-cell { min-width: 120px; }
.bar { height: 10px; border-radius: 0 4px 4px 0; background: var(--brand-2); min-width: 2px; }

/* ----------------------------------------------------------------- Robot bombayAdvisory */
.bot-fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 50;
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  background: var(--brand); color: #fff; font-size: 1.6rem; display: flex; align-items: center; justify-content: center;
}
.bot-fab::after { content: ""; position: absolute; top: 6px; right: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); border: 2px solid var(--brand); }
@media (min-width: 992px) { .bot-fab { bottom: 24px; right: 24px; } }
.bot-panel {
  position: fixed; z-index: 55; display: none; flex-direction: column; background: var(--surface);
  box-shadow: 0 10px 40px rgba(0,0,0,.3); border: 1px solid var(--border);
  /* Mobile : demi-écran en bas, l'écran en cours reste visible au-dessus */
  left: 0; right: 0; bottom: 0; height: min(72vh, 620px); border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom);
}
.bot-panel.open { display: flex; }
.bot-panel.expanded { height: calc(100vh - var(--top-h)); }
@media (min-width: 720px) {
  .bot-panel { left: auto; right: 24px; bottom: 96px; width: 390px; height: min(620px, calc(100vh - 140px)); border-radius: 18px; }
  .bot-panel.expanded { height: min(620px, calc(100vh - 140px)); }
}
.bot-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--brand); color: #fff; border-radius: 18px 18px 0 0; }
.bot-head .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.bot-head .who { flex: 1; line-height: 1.2; }
.bot-head .who small { color: #c9d6e6; display: block; font-size: .75rem; }
.bot-grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.5); margin: 0 auto 4px; }
.bot-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); overscroll-behavior: contain; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; font-size: .94rem; line-height: 1.45; }
.msg ul { margin: 4px 0; padding-left: 18px; }
.msg.bot { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: var(--brand-2); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .go { display: inline-flex; margin-top: 8px; padding: 8px 12px; background: var(--info-bg); color: var(--info); border-radius: 8px; text-decoration: none; font-weight: 600; font-size: .88rem; }
.msg .fb { display: flex; gap: 6px; margin-top: 6px; align-items: center; font-size: .8rem; color: var(--muted); }
.msg .fb button { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; min-width: 36px; min-height: 32px; cursor: pointer; }
.msg .fb button.sel { background: var(--ok-bg); border-color: var(--ok); }
.bot-suggest { display: flex; gap: 6px; flex-wrap: wrap; }
.bot-suggest button {
  border: 1px solid var(--brand-2); color: var(--brand-2); background: var(--surface); border-radius: 999px;
  padding: 8px 12px; font: inherit; font-size: .84rem; cursor: pointer; min-height: 38px; text-align: left;
}
.bot-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.bot-form input { flex: 1; min-height: 46px; }
.bot-form button { min-width: 46px; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin: 0 2px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; } }

/* Bandeau d'installation PWA */
.install-banner {
  display: none; position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 45;
  background: var(--brand); color: #fff; border-radius: 14px; padding: 12px; gap: 10px; align-items: center; box-shadow: var(--shadow);
}
.install-banner.show { display: flex; }
.install-banner p { margin: 0; flex: 1; font-size: .9rem; }
@media (min-width: 992px) { .install-banner { left: auto; width: 420px; bottom: 24px; right: 100px; } }

/* ----------------------------------------------------------------- Connexion */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--brand), #1d4d82); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; padding: 28px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card .brand { text-align: center; margin-bottom: 18px; }
.auth-card .brand img { width: 72px; height: 72px; border-radius: 16px; }
.demo-accounts { font-size: .82rem; margin-top: 16px; }
.demo-accounts button { margin: 3px 2px; }

/* ----------------------------------------------------------------- Impression */
@media print {
  .topbar, .sidebar, .bottom-nav, .bot-fab, .bot-panel, .form-actions, .help-btn, details.help-inline, .no-print, .install-banner { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { box-shadow: none; }
}
