/* CartoFlow en ligne : charte de la Cellule SIG & Innovation (CSI), comme l'extension. */
:root {
  --bg: #f3f5f8; --card: #ffffff; --text: #1c2433; --muted: #5b6678; --border: #dde2ea;
  --title: #14224a; --rule: #2a9db5; --accent: #3747d6; --accent-text: #ffffff;
  --ok: #1e8e4e; --ok-bg: #e6f4ec; --warn: #b26a00; --warn-bg: #fdf1df; --error: #c62828; --error-bg: #fbe9e9;
  --info: #2a6db5; --info-bg: #e7f0fa; --row-hover: #f6f8fb; --shadow: 0 1px 2px rgba(20, 34, 74, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420; --card: #171e2d; --text: #e3e8f0; --muted: #98a3b6; --border: #2a3346;
    --title: #e3e8f0; --rule: #2a9db5; --accent: #6b78ff; --accent-text: #ffffff;
    --ok: #4cc38a; --ok-bg: #16301f; --warn: #f0a43a; --warn-bg: #33270f; --error: #ef6b6b; --error-bg: #3a1a1a;
    --info: #79aef0; --info-bg: #172a40; --row-hover: #1c2537; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", "Noto Sans", Roboto, Arial, sans-serif; }
a { color: var(--accent); }
h2 { margin: 0 0 12px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: Consolas, "DejaVu Sans Mono", monospace; font-size: 13.5px; }
[hidden] { display: none !important; }

/* Bandeau */
.brand { background: #ffffff; border-bottom: 1px solid var(--border); }
.brand-inner { max-width: 1400px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; }
.brand-logo img { height: 46px; display: block; }
.brand-text { flex: 1; min-width: 0; }
.brand-title { font-size: 22px; font-weight: 700; color: #14224a; }
.brand-rule { height: 2px; background: var(--rule); margin: 3px 0 4px; max-width: 520px; }
.brand-subtitle { font-size: 13px; color: #4a5a70; }
.brand-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.signature { height: 40px; }
.signature.dark { display: none; }
.logout { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #4a5a70; }
@media (prefers-color-scheme: dark) {
  .brand { background: #0b1a33; border-color: #0b1a33; }
  .brand-title { color: #ffffff; }
  .brand-subtitle, .logout { color: #b9c3d6; }
  .brand-logo { background: #ffffff; border-radius: 6px; padding: 2px 6px; }
  .signature.light { display: none; }
  .signature.dark { display: block; }
}

/* Mise en page */
.page { max-width: 1400px; margin: 0 auto; padding: 18px 20px 96px; }
body.narrow .page { max-width: 460px; }
.crumbs { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 560px); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .columns { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.sticky { position: sticky; top: 12px; }

/* Formulaires */
label { display: block; margin: 10px 0; font-size: 14px; }
input[type=text], input:not([type]), input[type=password], input[type=search] {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--text); font: inherit;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; cursor: pointer; border-radius: 6px; padding: 8px 16px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:disabled { opacity: .45; cursor: default; }
button.primary.stop { background: var(--error); border-color: var(--error); }
button.secondary:hover { background: var(--row-hover); }
button.link { border: none; background: none; padding: 0; color: var(--accent); }
a.primary-link { display: inline-block; padding: 8px 16px; border-radius: 6px; background: var(--accent); color: var(--accent-text);
  font-weight: 600; text-decoration: none; }
button.link.danger { color: var(--error); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.field { margin: 12px 0; }
.field .label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field.row { display: flex; gap: 14px; flex-wrap: wrap; }
.field.row label { flex: 1; min-width: 160px; margin: 0; }
label.check { display: flex; gap: 8px; align-items: center; }

/* Choix exclusifs (Segmented) */
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 14px; font-size: 14px; border-right: 1px solid var(--border); cursor: pointer; }
.segmented label:last-child span { border-right: none; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-text); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Pastilles d'état */
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.chip.block { display: block; border-radius: 8px; padding: 8px 12px; margin-top: 10px; font-weight: 500; }
.chip.ok { color: var(--ok); background: var(--ok-bg); }
.chip.warn { color: var(--warn); background: var(--warn-bg); }
.chip.error { color: var(--error); background: var(--error-bg); }
.chip.info { color: var(--info); background: var(--info-bg); }
.flash { display: block; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

/* Dépôt */
.drop { position: relative; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center;
  border: 2px dashed var(--border); border-radius: 10px; padding: 26px 16px; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--row-hover); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-title { font-weight: 600; }
.drop-files { font-size: 13px; color: var(--accent); }

/* Listes */
.projects { list-style: none; margin: 0; padding: 0; }
.projects li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.projects li:first-child { border-top: none; }
.project-link { display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.project-title { font-weight: 600; }
.layers { list-style: none; margin: 0; padding: 0; }
.layers li { display: flex; gap: 10px; align-items: center; padding: 4px 0; flex-wrap: wrap; }
.layer-role { width: 90px; color: var(--muted); font-size: 14px; }

/* Parcelles */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; margin: 0; }
.table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { position: sticky; top: 0; background: var(--card); text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--row-hover); }
tr.current { background: var(--info-bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Aperçu */
.preview-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
#preview-img { width: 100%; border: 1px solid var(--border); border-radius: 4px; background: #fff; display: block; }
.warnings { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--warn); }

/* Lots */
.job { border-top: 1px solid var(--border); padding: 12px 0; }
.job:first-child { border-top: none; padding-top: 0; }
.job-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.tiles { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.tile { flex: 1; min-width: 110px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.tile b { display: block; font-size: 22px; }
.tile.ok b { color: var(--ok); }
.tile.error b { color: var(--error); }
.rows { font-size: 13px; }
.rows td { vertical-align: top; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; }

/* Barre d'actions fixe */
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--card); border-top: 1px solid var(--border); box-shadow: 0 -2px 8px rgba(0,0,0,.05); }
.danger-zone { display: flex; gap: 12px; align-items: center; margin: 8px 0 0; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .bar > div { transition: none; } }

@media (max-width: 640px) {
  .brand-inner { flex-wrap: wrap; padding: 10px 16px; }
  .brand-logo img { height: 36px; }
  .brand-subtitle { display: none; }
  .brand-side { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; }
  .signature { height: 30px; }
  .page { padding: 14px 16px 96px; }
  .action-bar { padding: 10px 16px; }
  th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5) { display: none; }
}
