/* Mise en page des modules du CRM ; couleurs et composants viennent de style.css. */

/* Marque SWAT */
.brand-swat { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #111111; color: #A5D900; font-weight: 800; letter-spacing: .04em; font-size: 15px; }
.topbar .brand .brand-name { font-weight: 700; }

.mainnav { overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a { white-space: nowrap; }

textarea {
  display: block; width: 100%; min-height: 90px; padding: 10px 12px; margin-top: 4px; resize: vertical;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
input[type=number], input[type=time], input[type=tel], input[type=search] {
  display: block; width: 100%; padding: 10px 12px; margin-top: 4px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
dialog.modal.wide { width: min(640px, calc(100vw - 32px)); }

/* Deux colonnes : contenu principal + panneau latéral */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.split > div { display: grid; gap: 16px; min-width: 0; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; } }
.split .card { margin: 0; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-plain > li:last-child { border-bottom: 0; }
.list-row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.empty { color: var(--muted); font-style: italic; margin: 8px 0; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: normal; }
.overdue { color: var(--err-text); font-weight: 600; }

/* Barre de recherche / filtres d'une liste */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1 1 240px; margin: 0; }
.toolbar select { width: auto; margin: 0; }
.toolbar button { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); text-decoration: none; font-size: .9rem; background: var(--surface); }
.chip[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Pipeline (Kanban) */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--sunk); border-radius: var(--radius); padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.kcol.drop { outline: 2px dashed var(--accent); }
.kcol-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 2px 4px 6px; }
.kcol-head h2 { margin: 0; font-size: .95rem; }
.kcol-head small { color: var(--muted); }
.kcard { display: block; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none; cursor: grab; }
.kcard:hover { border-color: var(--accent); }
.kcard.dragging { opacity: .5; }
.kcard strong { display: block; }
.kcard .small { display: block; }

/* Horaire : semaine en colonnes */
.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; }
.day { background: var(--sunk); border-radius: var(--radius); padding: 8px; min-height: 160px; display: flex; flex-direction: column; gap: 6px; }
.day.today { outline: 2px solid var(--accent); }
.day-head { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); padding: 0 2px 4px; }
.day-head b { color: var(--text); text-transform: capitalize; }
.visit { display: block; padding: 8px 10px; border-radius: 8px; border-left: 4px solid var(--accent); background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem; }
.visit:hover { box-shadow: 0 0 0 1px var(--accent); }
.visit.terminee { border-left-color: var(--ok-text); opacity: .75; }
.visit.annulee { border-left-color: var(--border); opacity: .55; text-decoration: line-through; }
.visit.unassigned { border-left-color: var(--err-text); }
.visit strong { display: block; }
.visit .small { display: block; color: var(--muted); }
@media (max-width: 900px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
}
.week-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.week-nav .button, .week-nav button { margin: 0; }
.week-nav form { display: flex; gap: 8px; align-items: center; margin: 0; }
.week-nav select { width: auto; margin: 0; }

/* Fil d'activité */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .ico { text-align: center; }
.timeline .meta { color: var(--muted); font-size: .85rem; }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline li.systeme .body { color: var(--muted); }

/* Visite (vue préposé) */
.big-address { font-size: 1.15rem; font-weight: 600; }
.checklist { margin: 0; padding-left: 20px; }
.checklist li { padding: 3px 0; }
.secret { font-family: ui-monospace, monospace; font-size: 1.4rem; letter-spacing: .1em; padding: 8px 12px; border-radius: 8px; background: var(--sunk); display: inline-block; }

/* ---------- Lot 1 ---------- */
.tag.bad { background: var(--err-bg); color: var(--err-text); }
input[type=file] { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }

/* Recherche dans le menu du haut */
.topsearch { margin: 0 8px 0 auto; flex: 0 1 220px; min-width: 110px; }
.topsearch input { margin: 0; height: 36px; padding: 0 12px; border-radius: 999px; background: var(--bg); }
.topsearch + .usermenu { margin-left: 0; }
@media (max-width: 720px) { .topsearch { display: none; } }

/* Ligne d'ajout (lignes de soumission) */
.line-form { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: flex-end; margin-top: 12px; }
.line-form label { margin-top: 8px; }
.line-form button { margin-top: 8px; }
table.inspect input, table.inspect select { margin: 0; }
table.inspect td { vertical-align: middle; }

/* Document imprimable (soumission) */
.doc-body { background: var(--sunk); }
.doc-bar { display: flex; gap: 8px; justify-content: center; padding: 16px; }
.doc-bar .button, .doc-bar button { margin: 0; }
.doc { max-width: 800px; margin: 0 auto 40px; padding: 48px; background: #fff; color: #111111; border-radius: 6px; box-shadow: 0 2px 12px rgb(0 0 0 / .12); color-scheme: light; }
.doc a { color: inherit; }
.doc h1 { margin: 0 0 4px; font-size: 1.6rem; }
.doc h2 { margin: 28px 0 8px; font-size: 1.1rem; }
.doc h3 { margin: 0 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: #5d6676; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 3px solid #111111; }
.doc-brand { font-size: 1.5rem; font-weight: 800; }
.doc-meta { text-align: right; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th, .doc-table td { padding: 8px 10px; border-bottom: 1px solid #dde1e7; text-align: left; color: #111111; background: none; }
.doc-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #5d6676; }
.doc-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-table tfoot td { border-bottom: 0; padding: 4px 10px; }
.doc-table tfoot tr:first-child td { padding-top: 12px; }
.doc-table tr.total td { font-weight: 700; font-size: 1.05rem; border-top: 2px solid #111111; }
.doc-sign { display: grid; grid-template-columns: 2fr 1fr; gap: 32px; margin-top: 56px; }
.doc-sign div { border-top: 1px solid #111111; padding-top: 6px; font-size: .85rem; color: #5d6676; }

@media print {
  .no-print, .topbar, .page-actions, .page-back, .page-tabs { display: none !important; }
  body, .doc-body { background: #fff !important; }
  .doc { box-shadow: none; margin: 0; padding: 0; max-width: none; border-radius: 0; }
  .card { break-inside: avoid; box-shadow: none; }
  .split { grid-template-columns: 1fr; }
  @page { margin: 18mm 16mm; }
}

/* ---------- Menu vertical à gauche + bouton Créer ---------- */
:root { --side-w: 220px; --side-bg: #111111; --side-text: #c9d4e4; --side-hover: #1e3b63; --lime: #A5D900; }
body.with-side { padding-left: var(--side-w); }
.side {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--side-w); display: flex; flex-direction: column; gap: 10px;
  padding: 14px 10px; background: var(--side-bg); color: var(--side-text); overflow-y: auto;
}
.side .brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 10px; color: #fff; text-decoration: none; font-weight: 700; }
.side .brand-swat { background: var(--lime); color: #111111; }
.side .mainnav { flex-direction: column; align-items: stretch; gap: 2px; overflow: visible; }
.side .mainnav a { gap: 12px; height: 40px; padding: 0 12px; color: var(--side-text); font-weight: 500; }
.side .mainnav a svg { flex: none; opacity: .85; }
.side .mainnav a:hover { background: var(--side-hover); color: #fff; }
.side .mainnav a[aria-current="page"] { background: var(--side-hover); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--lime); }
.side .mainnav a[aria-current="page"] svg { color: var(--lime); opacity: 1; }

.create { position: relative; }
.create-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border-radius: 10px; cursor: pointer; list-style: none; user-select: none;
  background: var(--lime); color: #111111; font-weight: 700;
}
.create-btn::-webkit-details-marker { display: none; }
.create-btn:hover { filter: brightness(1.06); }
.create-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px rgb(0 0 0 / .25);
}
.create-panel a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.create-panel a svg { color: var(--accent); }
.create-panel a:hover { background: var(--bg); }

.topbar-inner { gap: 8px 12px; }
.topsearch { margin: 0; flex: 1 1 auto; max-width: 420px; }
.burger { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; margin: 0; border-radius: 8px; cursor: pointer; color: var(--text); }
.burger:hover { background: var(--bg); }
.side-backdrop { display: none; }

@media (max-width: 900px) {
  body.with-side { padding-left: 0; }
  .side { transform: translateX(-100%); transition: transform .18s; box-shadow: 0 0 40px rgb(0 0 0 / .4); }
  .side-toggle:checked ~ .side { transform: none; }
  .side-toggle:checked ~ .side-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgb(15 18 24 / .45); }
  .burger { display: inline-flex; }
  .topbar-inner { flex-wrap: nowrap; padding: 0 12px; }
  .topsearch { display: block; min-width: 0; }
}
@media print { body.with-side { padding-left: 0; } .side, .side-backdrop { display: none !important; } }

/* Pages un peu plus aérées, cartes plus nettes */
body.with-side .page { padding: 28px 32px 56px; }
@media (max-width: 640px) { body.with-side .page { padding: 16px 12px 40px; } }
.page-head h1 { font-size: 1.75rem; letter-spacing: -.01em; }

/* Flux de travail sur l'accueil : Demandes → Soumissions → Travaux → Factures */
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1000px) { .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .flow { grid-template-columns: 1fr; } }
.flow-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-top: 4px solid var(--c, var(--accent)); border-radius: var(--radius); background: var(--surface); }
.flow-card h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.flow-card h3 svg { color: var(--c, var(--accent)); }
.flow-big { display: flex; align-items: baseline; gap: 8px; color: var(--text); text-decoration: none; }
.flow-big b { font-size: 2rem; line-height: 1; }
.flow-big span { color: var(--muted); }
.flow-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .92rem; }
.flow-rows a { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; color: var(--text); text-decoration: none; border-bottom: 1px dashed var(--border); }
.flow-rows a:hover { color: var(--accent); }
.flow-rows b { font-variant-numeric: tabular-nums; }
.flow-card .button { margin: auto 0 0; text-align: center; }

/* Statuts en pastilles (listes de demandes, soumissions, travaux, factures) */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--muted)); }
.status.blue { --dot: #0879D9; } .status.green { --dot: #2e9e5b; } .status.orange { --dot: #e08a00; } .status.red { --dot: #d1432f; } .status.grey { --dot: #9aa3b0; } .status.purple { --dot: #7a5cd6; }

/* Fiche client : propriétés + onglets de travail */
.subtabs { display: flex; gap: 4px; margin: 0 0 8px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.subtabs a { padding: 8px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; font-size: .92rem; text-decoration: none; white-space: nowrap; }
.subtabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.balance { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Calendrier : vue mois */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.month-head { padding: 6px 8px; background: var(--sunk); font-size: .8rem; font-weight: 700; text-transform: capitalize; color: var(--muted); }
.mday { min-height: 104px; padding: 4px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; }
.mday.out { background: var(--sunk); }
.mday.today .mday-num { background: var(--accent); color: #fff; }
.mday.drop, .day.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.mday-num { align-self: flex-start; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; display: grid; place-items: center; font-size: .8rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.mchip { display: block; padding: 2px 6px; border-radius: 5px; border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--text); font-size: .76rem; line-height: 1.3; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: grab; }
.mchip.terminee { border-left-color: #2e9e5b; background: var(--ok-bg); }
.mchip.annulee { border-left-color: var(--border); background: var(--sunk); text-decoration: line-through; color: var(--muted); }
.mchip.unassigned { border-left-color: #d1432f; background: var(--err-bg); }
.mchip.dragging, .visit.dragging { opacity: .4; }
.visit[draggable="true"] { cursor: grab; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: 7px 14px; color: var(--muted); font-weight: 600; font-size: .9rem; text-decoration: none; background: var(--surface); }
.seg a + a { border-left: 1px solid var(--border); }
.seg a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.cal-title { font-weight: 700; font-size: 1.05rem; text-transform: capitalize; margin: 0 6px; }
@media (max-width: 700px) { .mday { min-height: 64px; } .mchip { font-size: 0; height: 6px; padding: 0; } }

/* Vue jour : une colonne par préposé */
.dayview { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 10px; overflow-x: auto; }

/* Logo officiel */
.side .brand { justify-content: center; padding: 6px 8px 12px; }
.side-logo { width: 120px; height: auto; display: block; }
.guest-brand { flex-direction: column; }
.guest-logo { width: 160px; height: auto; display: block; mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { .guest-logo { mix-blend-mode: normal; } }
.doc-logo { width: 150px; height: auto; display: block; margin-bottom: 6px; }

/* Menu « Créer » dans l'en-tête d'une page (fiche client) */
.page-create .create-btn { height: 40px; padding: 0 16px; background: var(--accent); color: var(--accent-text); }
.page-create .create-panel { left: auto; right: 0; min-width: 190px; }

.topbar .topsearch + .usermenu, .topbar .usermenu { margin-left: auto; }

/* ---------- Noir et blanc, comme swatentretien.com ----------
   Noir #111111 / blanc ; le vert lime ne sert que de repère (page courante). Les couleurs de statut
   (pastilles, en retard, payé) restent : elles portent une information. */
:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --text: #111111;
  --muted: #6b6b6b;
  --border: #e5e5e5;
  --sunk: #ededed;
  --accent: #111111;
  --accent-text: #ffffff;
  --accent-soft: #ececec;
  --info-bg: #ececec;
  --info-text: #111111;
  --side-bg: #111111;
  --side-text: #cfcfcf;
  --side-hover: #2b2b2b;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --surface: #171717;
    --text: #f2f2f2;
    --muted: #a3a3a3;
    --border: #2b2b2b;
    --sunk: #111111;
    --accent: #ffffff;
    --accent-text: #111111;
    --accent-soft: #2b2b2b;
    --info-bg: #2b2b2b;
    --info-text: #f2f2f2;
    --side-bg: #000000;
  }
  .side { border-right: 1px solid var(--border); }
}
a { color: var(--text); text-underline-offset: 2px; }
h1, h2, h3 { letter-spacing: -.01em; }
.page-head h1 { font-weight: 800; }
.card { box-shadow: none; border: 1px solid var(--border); }

/* Menu : noir, texte blanc, bouton Créer blanc */
.create-btn { background: #ffffff; color: #111111; }
.create-btn:hover { filter: none; background: #e5e5e5; }
.page-create .create-btn { background: var(--accent); color: var(--accent-text); }
.page-create .create-btn:hover { background: var(--accent); opacity: .85; }
.create-panel a svg { color: var(--text); }
.side .mainnav a[aria-current="page"] { background: #ffffff; color: #111111; box-shadow: none; }
.side .mainnav a[aria-current="page"] svg { color: #111111; }

/* Boutons : noir plein, ou contour noir */
button.secondary, .button.secondary { background: var(--surface); color: var(--text); border-color: var(--text); }
button.secondary:hover, .button.secondary:hover { background: var(--text); color: var(--surface); }
.chip[aria-current="page"], .seg a[aria-current="page"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.subtabs a[aria-current="page"], .page-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }
.page-eyebrow { color: var(--muted); }

/* Accueil et calendrier : sans couleur d'accent */
.flow-card { --c: var(--text) !important; border-top-width: 3px; }
.mday.today .mday-num { background: var(--accent); color: var(--accent-text); }
.mchip { border-left-color: var(--text); background: var(--sunk); }
.visit { border-left-color: var(--text); }
.kcard:hover, .visit:hover { border-color: var(--text); }
.topsearch input { background: var(--bg); border-color: var(--border); }

.week { grid-template-columns: repeat(7, minmax(112px, 1fr)); }
@media (max-width: 900px) { .week { grid-template-columns: 1fr; } }

/* Photos et documents */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.gallery figure { margin: 0; }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--sunk); }
.gallery figcaption { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; margin-top: 4px; }
.gallery figcaption form { margin: 0; }
.upload-form { display: grid; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.upload-form label, .upload-form input, .upload-form button { margin: 0; }
.upload-form button { justify-self: start; }
.inline-select { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-select select { margin: 0; width: auto; max-width: 220px; }
.inline-select button { margin: 0; }

/* Page publique d'une soumission : acceptation */
.accept { margin-top: 28px; padding: 20px; border: 2px solid #111111; border-radius: 10px; }
.accept h2 { margin-top: 0; }
.accept label { color: #111111; }
.accept input[type=text], .accept textarea { background: #ffffff; color: #111111; }
.accept button { background: #111111; color: #ffffff; border-color: #111111; }
.accept button.secondary { background: #ffffff; color: #111111; }
.accept-done { margin: 0; font-weight: 700; font-size: 1.05rem; }
.doc .alert { margin: 16px 0 0; }
