/* GED du cabinet — feuille de style unique */
:root {
  --navy: #1b2440;
  --navy-2: #26325a;
  --navy-3: #34416e;
  --gold: #c9a227;
  --gold-2: #e2c25a;
  --bg: #f3f4f8;
  --card: #ffffff;
  --line: #e1e4ec;
  --text: #1d2233;
  --muted: #667089;
  --primary: #2f4fa8;
  --primary-2: #24408d;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --danger: #c0392b;
  --req: #fde2e2;
  --req-line: #e57373;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Mise en page générale ---------- */
.shell { display: grid; grid-template-columns: 78px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar { grid-column: 1 / 3; background: var(--navy); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 250px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand b { display: block; font-size: 15px; letter-spacing: .2px; }
.brand span { display: block; font-size: 11px; color: #b9c1dc; text-transform: uppercase; letter-spacing: .6px; }
.globalsearch { flex: 1; max-width: 620px; display: flex; }
.globalsearch input { flex: 1; border: 0; border-radius: 6px 0 0 6px; padding: 9px 12px; background: var(--navy-2); color: #fff; font-size: 14px; }
.globalsearch input::placeholder { color: #9aa5c7; }
.globalsearch button { border: 0; background: var(--gold); color: var(--navy); border-radius: 0 6px 6px 0; padding: 0 14px; cursor: pointer; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.userbox .who { text-align: right; line-height: 1.2; }
.userbox .who small { color: #b9c1dc; display: block; }
.btn-top { background: transparent; border: 1px solid #4a5682; color: #fff; border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.btn-top:hover { background: var(--navy-2); }
.sidebar { background: var(--navy); padding-top: 6px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar a { color: #b9c1dc; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px; font-size: 11px; text-align: center; border-left: 3px solid transparent; }
.sidebar a:hover { color: #fff; background: var(--navy-2); text-decoration: none; }
.sidebar a.active { color: #fff; background: var(--navy-2); border-left-color: var(--gold); }
.sidebar svg { width: 22px; height: 22px; }
.main { overflow: auto; padding: 20px 24px 40px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumbs a { color: var(--muted); }
.crumbs .sep { opacity: .6; }

/* ---------- Cartes, grilles ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.split-wide { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .split, .split-wide { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .shell { grid-template-columns: 60px 1fr; } .brand div { display: none; } .brand { min-width: 0; } .userbox .who { display: none; } }
.stat { padding: 16px 18px; }
.stat b { font-size: 28px; display: block; color: var(--navy); }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.hero { background: linear-gradient(120deg, var(--navy), var(--navy-3)); color: #fff; border-radius: var(--radius); padding: 18px 22px; display: flex; gap: 18px; align-items: center; margin-bottom: 16px; }
.hero img { width: 54px; height: 54px; }
.hero h1 { margin: 0; font-size: 20px; }
.hero p { margin: 4px 0 0; color: #c8cfe6; }

/* ---------- Boutons, formulaires ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 6px; padding: 7px 12px; cursor: pointer; font-size: 13px; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: #f6f7fb; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--navy); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: #f0c4bf; }
.btn.danger:hover { background: #fdf0ee; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.f .lab { display: flex; align-items: center; gap: 6px; }
label.f .req { color: var(--danger); }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=email], input[type=search], select, textarea {
  font: inherit; color: var(--text); border: 1px solid #cdd2de; border-radius: 6px; padding: 7px 9px; background: #fff; width: 100%; font-weight: 400;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d4fb; border-color: var(--primary); }
/* Attribut obligatoire non renseigné ou invalide : fond rouge (comme dans le formulaire IntelliScan) */
.is-required-empty, .is-invalid { background: var(--req) !important; border-color: var(--req-line) !important; }
.field-error { color: var(--danger); font-size: 12px; font-weight: 400; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); font-weight: 400; cursor: pointer; }
.mem { font-weight: 400; font-size: 11px; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; margin-left: auto; cursor: pointer; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar select { width: auto; min-width: 180px; }

/* ---------- Tableaux, listes ---------- */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfd; position: sticky; top: 0; }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f6f8fd; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #eef1f8; color: var(--navy-3); white-space: nowrap; }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.warn { background: #fbf0dc; color: var(--warn); }
.badge.danger { background: #fbe5e2; color: var(--danger); }
.badge.gold { background: #f7eecd; color: #7d6210; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.list li:last-child { border-bottom: 0; }
.doc-ico { width: 30px; height: 36px; border-radius: 4px; display: inline-flex; align-items: flex-end; justify-content: center; font-size: 9px; font-weight: 700; color: #fff; padding-bottom: 4px; flex: none; }
.doc-ico.pdf { background: #c0392b; } .doc-ico.img { background: #8e44ad; } .doc-ico.doc { background: #2f5fb3; }
.doc-ico.xls { background: #1f8a4c; } .doc-ico.oth { background: #7f8aa6; }
mark { background: #fff1a8; padding: 0 1px; }

/* ---------- Plan de classement ---------- */
.tree { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; }
.tree .node { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 5px; cursor: pointer; }
.tree .node:hover { background: #f1f3f9; }
.tree .node.sel { background: #e7ecfb; font-weight: 600; }
.tree .tog { width: 14px; color: var(--muted); flex: none; text-align: center; }
.tree .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .cnt { background: var(--navy); color: #fff; border-radius: 99px; font-size: 10px; padding: 1px 7px; }
.folder-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.folder-row:hover { background: #f6f8fd; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: 12px; text-align: center; cursor: pointer; background: #fff; }
.tile:hover { border-color: var(--primary); }
.tile .doc-ico { width: 44px; height: 54px; font-size: 11px; margin-bottom: 8px; }
.tile .tt { font-size: 12px; word-break: break-word; }

/* ---------- Archivage (assistant type IntelliScan) ---------- */
.steps { display: flex; gap: 0; margin-bottom: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.steps div { flex: 1; padding: 10px 12px; font-size: 12px; color: var(--muted); border-right: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.steps div:last-child { border-right: 0; }
.steps div b { width: 22px; height: 22px; border-radius: 50%; background: #e5e8f0; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.steps div.on { color: var(--navy); font-weight: 600; background: #f5f7fd; }
.steps div.on b { background: var(--primary); color: #fff; }
.steps div.done b { background: var(--ok); color: #fff; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; user-select: none; }
.task:hover { border-color: var(--primary); }
.task.sel { border-color: var(--primary); background: #f3f6fe; outline: 2px solid #c7d4fb; }
.task .ti { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.task .ti.scan { background: #e4ebfc; color: var(--primary); }
.task .ti.imp { background: #f7eecd; color: #7d6210; }
.task .ti svg { width: 20px; height: 20px; }
.task h3 { margin: 0 0 2px; font-size: 14px; }
.task p { margin: 0; font-size: 12px; color: var(--muted); }
.classement { background: #f6f8fd; border: 1px dashed #b9c6ea; border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.classement b { color: var(--navy); }
.dropzone { border: 2px dashed #b9c6ea; border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); background: #fafbff; }
.dropzone.over { background: #eef3ff; border-color: var(--primary); }
.camera { background: #111; border-radius: 8px; overflow: hidden; position: relative; aspect-ratio: 4 / 3; max-height: 420px; }
.camera video { width: 100%; height: 100%; object-fit: contain; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { width: 92px; border: 2px solid var(--line); border-radius: 6px; padding: 3px; background: #fff; cursor: pointer; position: relative; text-align: center; font-size: 11px; }
.thumb.sel { border-color: var(--primary); }
.thumb img, .thumb canvas { width: 100%; height: 110px; object-fit: contain; background: #f2f3f6; display: block; }
.thumb .n { position: absolute; top: 4px; left: 4px; background: var(--navy); color: #fff; border-radius: 4px; font-size: 10px; padding: 0 4px; }
.validation { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 12px; min-height: 520px; }
.vlist { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 640px; background: #fff; }
.vlist .it { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 8px; align-items: center; font-size: 12px; }
.vlist .it.sel { background: #e7ecfb; }
.vlist .it .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer { border: 1px solid var(--line); border-radius: 8px; background: #e9ebf1; display: flex; flex-direction: column; overflow: hidden; }
.viewer .vt { display: flex; gap: 4px; flex-wrap: wrap; padding: 6px; background: #fff; border-bottom: 1px solid var(--line); align-items: center; }
.viewer .vt .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.viewer .vc { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 12px; min-height: 460px; max-height: 640px; }
.viewer .vc canvas, .viewer .vc img { box-shadow: 0 2px 10px rgba(0, 0, 0, .2); background: #fff; }
.icon-btn { border: 1px solid transparent; background: transparent; border-radius: 5px; padding: 5px 7px; cursor: pointer; font-size: 12px; display: inline-flex; gap: 4px; align-items: center; color: var(--text); }
.icon-btn:hover { background: #eef1f8; border-color: var(--line); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn svg { width: 16px; height: 16px; }
.progress { height: 8px; background: #e5e8f0; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); transition: width .2s; }
.log { background: #0f1529; color: #c8d3f5; font-family: ui-monospace, Consolas, monospace; font-size: 12px; border-radius: 6px; padding: 10px; max-height: 160px; overflow: auto; }

/* ---------- Visionneuse de document ---------- */
.preview { background: #e9ebf1; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.preview iframe { width: 100%; height: 76vh; border: 0; display: block; background: #fff; }
.preview img { max-width: 100%; display: block; margin: 0 auto; }
.preview .none { padding: 60px 20px; text-align: center; color: var(--muted); }
.path { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; }
.path a { background: #eef1f8; padding: 2px 8px; border-radius: 4px; color: var(--navy-3); }

/* ---------- Fenêtres, messages ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 21, 41, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal.wide { max-width: 900px; }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-h h2 { margin: 0; }
.modal-b { padding: 18px; max-height: 70vh; overflow: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.toasts { position: fixed; right: 16px; top: 66px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: 420px; }
.toast { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); font-size: 13px; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
.alert { padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.alert.err { background: #fbe5e2; color: #8e2a1f; border: 1px solid #f0c4bf; }
.alert.warn { background: #fbf0dc; color: #7a5212; border: 1px solid #efd9a8; }
.alert.info { background: #e8eefc; color: #23397a; border: 1px solid #c9d6f6; }
.alert.ok { background: #e3f4ea; color: #155e35; border: 1px solid #bfe3cc; }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(140deg, var(--navy), var(--navy-3)); padding: 20px; }
.login { background: #fff; border-radius: 12px; width: 100%; max-width: 400px; padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login .lg { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.login .lg img { width: 52px; height: 52px; }
.login .lg b { font-size: 18px; color: var(--navy); display: block; }
.login .lg span { font-size: 12px; color: var(--muted); }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login .foot { margin-top: 16px; font-size: 11px; color: var(--muted); text-align: center; }

/* ---------- Agenda ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-h { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfd; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-d { min-height: 110px; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; overflow: hidden; }
.cal.semaine .cal-d { min-height: 320px; }
.cal-d.today { background: #f3f6fe; }
.cal-d.out { background: #fafafa; opacity: .55; }
.cal-n { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.cal-e { font-size: 11.5px; padding: 3px 5px; margin-bottom: 3px; border-left: 3px solid; background: #f4f6fb; border-radius: 3px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-e:hover { background: #e7ecfb; }
.cal-e.done { opacity: .55; text-decoration: line-through; }
.cal-e.late { background: #fbe5e2; }
@media (max-width: 760px) { .cal { grid-template-columns: 1fr; } .cal-h { display: none; } .cal-d, .cal.semaine .cal-d { min-height: 0; } }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.on { color: var(--navy); border-bottom-color: var(--gold); }
.tabs a:hover { text-decoration: none; color: var(--navy); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.aide h2 { margin-top: 22px; } .aide h3 { margin-top: 14px; } .aide p, .aide li { line-height: 1.55; } .aide ol, .aide ul { padding-left: 22px; }
.aide .sommaire a { display: block; padding: 4px 0; }
@media print {
  .topbar, .sidebar, .no-print, .toasts { display: none !important; }
  .shell { display: block; height: auto; } .main { overflow: visible; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  body, html { background: #fff; }
}

/* ---------- Espace client ---------- */
.client-shell { grid-template-columns: 1fr; }
.client-shell .topbar { grid-column: 1; justify-content: space-between; }
.client-shell .main { max-width: 1100px; width: 100%; margin: 0 auto; }
@media (max-width: 760px) { .client-shell .brand { min-width: 0; } .client-shell .brand span { display: none; } }
@media (max-width: 760px) { .card { overflow-x: auto; } .t { min-width: 520px; } }
