:root {
  --sidebar: #22384a;
  --sidebar-dark: #1a2c3c;
  --sidebar-active: #31506a;
  --blue: #4096d6;
  --blue-dark: #2477b9;
  --green: #30a852;
  --orange: #e5a029;
  --red: #d94d42;
  --page: #eef3f8;
  --surface: #ffffff;
  --line: #dfe7ef;
  --text: #28415a;
  --muted: #71879d;
  --soft-blue: #eaf5ff;
  --soft-green: #eaf8ef;
  --soft-orange: #fff5df;
  --soft-red: #ffefee;
  --shadow: 0 14px 32px rgba(33, 55, 76, 0.12);
}

/* Pièces détachées, commandes et fiches atelier numériques */
.operation-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.operation-summary-card {
  appearance: none;
  width: 100%;
  border: 1px solid #dfe5ee;
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  cursor: pointer;
}

.operation-summary-card strong { font-size: 24px; color: #17233d; }
.operation-summary-card span { color: #667085; font-size: 13px; }
.operation-summary-card:hover { border-color: #9abbd5; background: #f8fbfe; transform: translateY(-1px); }
.operation-summary-card:focus-visible { outline: 3px solid rgba(23, 105, 170, .25); outline-offset: 2px; }
.operation-summary-card.warning { border-left: 4px solid #f59e0b; }
.operation-summary-card.success { border-left: 4px solid #16a34a; }
.operation-summary-card.info { border-left: 4px solid #2563eb; }

.operation-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}

.operation-tabs button {
  border: 1px solid #d6deea;
  background: #fff;
  color: #344054;
  border-radius: 999px;
  padding: 9px 15px;
  cursor: pointer;
}

.operation-tabs button.active {
  background: #17233d;
  border-color: #17233d;
  color: #fff;
}

.operations-toolbar { grid-template-columns: minmax(240px, 1fr) minmax(190px, 280px); }
.operations-footnote { color: #667085; font-size: 12px; margin-top: 10px; }

.parts-customer-grid { grid-template-columns: 1.25fr 1.25fr 1fr .9fr .8fr .7fr; }
.parts-supplier-grid { grid-template-columns: 1.2fr .9fr 1fr .9fr .9fr .8fr; }
.parts-catalog-grid { grid-template-columns: 1fr 2.2fr 1.5fr .7fr; }
.workshop-sheet-grid { grid-template-columns: 1.2fr 1.3fr 1fr .55fr 1fr .8fr .75fr; }
.parts-customer-identity { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.parts-customer-identity small { display: block; color: #667085; }
.parts-open-order-tag { display: inline-flex !important; width: fit-content; padding: 2px 7px; border-radius: 999px; background: #fff3cd; color: #7a4d00 !important; font-weight: 700; }
.parts-articles-summary { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.parts-articles-summary small { color: #667085; }
.parts-status-select {
  width: 100%;
  min-width: 145px;
  min-height: 35px;
  padding: 5px 28px 5px 8px;
  border: 1px solid #c9d7e5;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.table-body.parts-work-queue-host { max-height: none; overflow: visible; padding: 12px; background: #f5f8fb; }
.dossier-workspace { margin: 0 0 18px; padding: 16px; border-radius: 12px; }
.dossier-workspace[hidden] { display: none; }
.dossier-heading, .dossier-detail > header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.dossier-heading h2, .dossier-detail h3 { margin: 0; color: #244965; font-size: 18px; }
.dossier-heading p, .dossier-workspace [role="status"], .dossier-footnote, .dossier-count { margin: 6px 0 12px; color: #667085; font-size: 12px; }
.dossier-filters { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin: 12px 0; }
.dossier-filters[hidden] { display: none; }
.dossier-filters label, .dossier-association label { display: grid; gap: 5px; color: #475467; font-size: 12px; }
.dossier-filters input, .dossier-filters select, .dossier-association input, .dossier-association select { width: 100%; min-height: 38px; padding: 8px; border: 1px solid #ccd9e4; border-radius: 7px; background: #fff; }
.dossier-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dossier-card { display: grid; gap: 6px; min-width: 0; padding: 13px; border: 1px solid #dbe5ee; border-left: 4px solid #3990c8; border-radius: 9px; text-align: left; background: #f8fbfe; cursor: pointer; }
.dossier-card:hover { border-color: #398bc2; background: #eef6fd; }
.dossier-card strong { color: #1e4667; font-size: 15px; }
.dossier-card span, .dossier-card small { overflow-wrap: anywhere; color: #667085; font-size: 12px; }
.dossier-card b { color: #1769aa; font-size: 12px; }
.dossier-detail { margin: 14px 0 18px; padding: 14px; border: 1px solid #b8d5e9; border-radius: 10px; background: #fbfdff; }
.dossier-node { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid #e6edf3; }
.dossier-node strong, .dossier-node small { display: block; overflow-wrap: anywhere; }
.dossier-node strong { color: #294966; font-size: 13px; }
.dossier-node small { margin-top: 5px; color: #667085; font-size: 12px; }
.dossier-status { padding: 5px 8px; border-radius: 7px; background: #e9f2fc; color: #245b88; font-size: 12px; }
.dossier-node.is-done .dossier-status { color: #147349; background: #e2f5ea; }
.dossier-association { margin-top: 12px; }
.dossier-association summary { padding: 8px 0; color: #245b88; cursor: pointer; font-size: 13px; font-weight: 700; }
.dossier-association form { display: grid; gap: 10px; padding: 12px; border: 1px solid #dce7f0; border-radius: 8px; background: #fff; }
.dossier-association .dossier-confirm { display: flex; align-items: center; gap: 9px; }
.dossier-confirm input { width: 18px; min-height: 18px; }
.dossier-link-row { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 9px 0; font-size: 12px; }
.dossier-entry { margin: 8px 0; }
@media (max-width: 760px) {
  .dossier-grid, .dossier-filters, .dossier-node { grid-template-columns: 1fr; }
  .dossier-heading, .dossier-detail > header, .dossier-link-row { align-items: flex-start; flex-direction: column; }
}
.parts-work-queue { display: grid; gap: 14px; }
.parts-queue-group { overflow: hidden; border: 1px solid #dbe4ec; border-left: 5px solid #7aa7ca; border-radius: 10px; background: #fff; }
.parts-queue-group.tone-warning { border-left-color: #f59e0b; }
.parts-queue-group.tone-success { border-left-color: #16a34a; }
.parts-queue-group.tone-danger { border-left-color: #d92d20; }
.parts-queue-group.tone-archive { border-left-color: #98a2b3; background: #f8fafc; }
.parts-queue-group-header { display: flex; align-items: center; gap: 9px; padding: 10px 13px; color: #294966; background: #f8fbfe; font-size: 14px; font-weight: 800; }
.parts-queue-group-header > span { flex: 1; }
.parts-queue-group-header strong { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 24px; padding: 2px 8px; border-radius: 999px; color: #294966; background: #e5eef5; }
details.parts-queue-group > summary { cursor: pointer; list-style: none; }
details.parts-queue-group > summary::-webkit-details-marker { display: none; }
details.parts-queue-group > summary::before { content: "›"; color: #667085; font-size: 22px; line-height: 1; transform: rotate(0); transition: transform .15s ease; }
details.parts-queue-group[open] > summary::before { transform: rotate(90deg); }
details.parts-queue-group > summary:hover { background: #edf5fb; }
.parts-queue-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 8px; border-top: 1px solid #edf2f6; background: #f5f8fb; }
.parts-queue-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; min-width: 0; padding: 10px 11px; border: 1px solid #dfe7ee; border-left: 4px solid transparent; border-radius: 8px; background: #fff; }
.parts-queue-card.tone-danger { border-left-color: #d92d20; background: #fff8f7; }
.parts-queue-card.tone-warning { border-left-color: #f59e0b; }
.parts-queue-card.tone-success { border-left-color: #16a34a; }
.parts-queue-card.tone-info { border-left-color: #3b82c4; }
.parts-queue-main { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.parts-queue-main small { overflow: hidden; color: #667085; text-overflow: ellipsis; white-space: nowrap; }
.parts-queue-refs { color: #475467 !important; font-size: 11px; }
.parts-queue-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.parts-queue-title > strong { overflow: hidden; color: #172b4d; text-overflow: ellipsis; white-space: nowrap; }
.parts-overdue-tag { display: inline-flex; padding: 2px 7px; border-radius: 999px; color: #b42318; background: #fee4e2; font-size: 11px; font-weight: 800; white-space: nowrap; }
.parts-queue-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #667085; font-size: 11px; }
.parts-queue-meta span:last-child { text-align: right; }
.parts-queue-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 2px; }
.parts-queue-actions > button { min-height: 31px; padding: 5px 9px; font-size: 11px; }
.parts-queue-status { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 999px; color: #175b8f; background: #e8f3fb; font-size: 11px; font-weight: 800; }
.parts-queue-status.tone-warning { color: #8a5700; background: #fff3cd; }
.parts-queue-status.tone-danger { color: #b42318; background: #fee4e2; }
.parts-queue-status.tone-success { color: #067647; background: #dcfae6; }
.parts-status-menu { position: relative; }
.parts-status-menu summary { color: #475467; cursor: pointer; font-size: 11px; font-weight: 700; white-space: nowrap; }
.parts-status-menu[open] { flex-basis: 100%; padding: 8px; border-radius: 8px; background: #f2f4f7; }
.parts-status-menu .parts-status-select { margin-top: 7px; }

.operations-progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 6px;
  margin: 0 0 18px;
}

.operations-progress-step {
  padding: 9px 8px;
  border-radius: 8px;
  background: #f2f4f7;
  color: #667085;
  font-size: 11px;
  text-align: center;
}

.operations-progress-step.done { background: #e8f7ee; color: #137333; }
.operations-progress-step.active { background: #e8efff; color: #1d4ed8; font-weight: 700; box-shadow: inset 0 0 0 1px #93b4ff; }

.operations-lines { border: 1px solid #e4e7ec; border-radius: 10px; overflow: hidden; }
.operations-line {
  display: grid;
  grid-template-columns: minmax(135px, .9fr) minmax(260px, 2.5fr) minmax(112px, .7fr) minmax(102px, .65fr) 40px;
  gap: 8px;
  align-items: end;
  padding: 9px;
  border-bottom: 1px solid #eef1f5;
}
.operations-line:last-child { border-bottom: 0; }
.operations-line.customer-line { grid-template-columns: minmax(135px, .9fr) minmax(260px, 2.5fr) minmax(112px, .7fr) 40px; }
.operations-line.supplier-arrival-line { grid-template-columns: minmax(180px, 280px) 40px; }
.operations-line label { min-width: 0; }
.operations-line input { width: 100%; }
.operations-line .remove-line { min-width: 32px; padding: 8px; }
.operations-line-head { padding: 9px 12px; background: #f8fafc; font-weight: 700; color: #475467; font-size: 12px; }
.operations-line.part-entry-invalid { background: #fff5f5; box-shadow: inset 3px 0 0 #d92d20; }
.operations-line.part-entry-invalid [data-part-reference],
.operations-line.part-entry-invalid [data-part-designation],
.operations-line.part-entry-invalid [data-part-qty],
.operations-line.part-entry-invalid [data-line-reference],
.operations-line.part-entry-invalid [data-line-designation],
.operations-line.part-entry-invalid [data-line-qty],
.operations-line.part-entry-invalid [data-line-received] { border-color: #d92d20; background: #fffafa; }
.operations-line.part-entry-valid { background: #f7fdf9; box-shadow: inset 3px 0 0 #12b76a; }
.operations-line.part-entry-valid [data-part-designation][readonly],
.operations-line.part-entry-valid [data-line-designation][readonly] { color: #344054; background: #f2f4f7; cursor: default; }
.operations-line.part-entry-line { padding-bottom: 27px; }
.part-entry-reference { position: relative; }
.part-entry-status { position: absolute; top: calc(100% + 3px); left: 0; right: 0; display: block; min-height: 15px; font-size: 11px; font-weight: 700; line-height: 1.2; }
.part-entry-status.invalid { color: #b42318; }
.part-entry-status.valid { color: #067647; }
.operations-add-line { margin-top: 9px; }
.workshop-qty-stepper { display: grid; grid-template-columns: 36px minmax(46px, 1fr) 36px; align-items: stretch; gap: 4px; }
.workshop-qty-stepper button { min-height: 42px; border: 1px solid #98a2b3; border-radius: 8px; background: #f8fafc; color: #172b4d; cursor: pointer; font-size: 21px; font-weight: 700; line-height: 1; }
.workshop-qty-stepper button:hover { background: #e8efff; border-color: #5b8def; }
.workshop-qty-stepper input { min-width: 0; min-height: 42px; padding-inline: 4px; text-align: center; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; appearance: textfield; }
.workshop-qty-stepper input::-webkit-inner-spin-button,
.workshop-qty-stepper input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.workshop-subassembly .operations-line.customer-line { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 126px 36px; }

.workshop-paper-form { background: #fbfcfe; border: 1px solid #dfe5ee; border-radius: 12px; padding: 14px; }
.workshop-paper-form .paper-title { text-align: center; margin-bottom: 14px; }
.sage-notice { padding: 10px 12px; background: #fff8e7; border: 1px solid #f8d58b; border-radius: 8px; color: #76520b; font-size: 12px; }
.locked-notice { padding: 10px 12px; background: #eef4ff; border: 1px solid #bfd2ff; border-radius: 8px; color: #264b96; margin-bottom: 12px; }
.catalog-ref-missing { color: #b54708; font-style: italic; }

.workshop-case-searchbar {
  position: sticky;
  top: -18px;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  background: #fff;
}

.workshop-free-sheet-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  padding: 13px 15px;
  border: 1px solid #bcd7eb;
  border-radius: 10px;
  background: #eef7fd;
}

.workshop-free-sheet-callout div { display: grid; gap: 3px; }
.workshop-free-sheet-callout strong { color: #173452; }
.workshop-free-sheet-callout span { color: #61788f; font-size: 12px; }
.workshop-free-sheet-callout button { white-space: nowrap; }

.workshop-case-searchbar input {
  width: 100%;
  min-height: 48px;
  border: 2px solid #4096d6;
  border-radius: 10px;
  padding: 0 15px;
  font-size: 16px;
}

.workshop-case-results {
  display: grid;
  gap: 8px;
}

.workshop-case-result {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 14px;
  border: 1px solid #dfe5ee;
  border-radius: 10px;
  background: #fff;
  padding: 13px 15px;
  text-align: left;
  color: #28415a;
}

.workshop-case-result:hover,
.workshop-case-result:focus {
  border-color: #4096d6;
  background: #f2f8ff;
  outline: none;
}

.workshop-case-result strong { font-size: 15px; color: #173452; }
.workshop-case-result span { grid-column: 1; color: #536b82; }
.workshop-case-result small { grid-column: 1; color: #71879d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workshop-case-result em { grid-column: 2; grid-row: 1 / span 3; align-self: center; color: #2477b9; font-style: normal; font-size: 12px; font-weight: 700; }

.workshop-autosave-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 13px;
  border: 1px solid #b8dfc4;
  border-radius: 9px;
  background: #eefaf2;
  color: #315c3d;
  font-size: 12px;
}

.workshop-save-state { font-weight: 800; color: #24763c; }
.workshop-save-state.saving { color: #8a6415; }
.workshop-save-state.error { color: #b42318; }

.workshop-form-section {
  margin-top: 16px;
  padding: 15px;
  border: 1px solid #dfe5ee;
  border-radius: 12px;
  background: #fff;
}

.workshop-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.workshop-section-title h3 { margin: 0 0 3px; color: #173452; }
.workshop-section-title p { margin: 0; color: #71879d; font-size: 12px; }
.workshop-section-title > strong { font-size: 24px; color: #2477b9; }

.workshop-participant-row {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 180px 40px;
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.workshop-participant-row label,
.workshop-subassembly label {
  display: grid;
  gap: 5px;
}

.workshop-participant-row label > span,
.workshop-subassembly label > span {
  color: #61788f;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.workshop-participant-row input,
.workshop-participant-row select,
.workshop-subassembly input,
.workshop-subassembly textarea {
  width: 100%;
  border: 1px solid #ccd8e4;
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
}

.workshop-subassembly {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid #cfdbe7;
  border-left: 4px solid #4096d6;
  border-radius: 10px;
  background: #f9fbfd;
}

.workshop-subassembly-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, .8fr) auto;
  gap: 10px;
  align-items: end;
}

.workshop-subassembly-comment { margin: 11px 0; }
.workshop-subassembly .operations-lines { background: #fff; }
.workshop-subassembly > .operations-add-line { margin-top: 8px; }

body.workshop-sheet-editor-open { overflow: hidden; }

.workshop-sheet-editor {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: #eef3f8;
  color: #28415a;
}

.workshop-sheet-editor-form {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.workshop-sheet-editor-header {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid #d9e2ec;
  background: #fff;
  box-shadow: 0 3px 12px rgba(33, 55, 76, 0.08);
}

.workshop-sheet-back {
  border: 1px solid #ced9e4;
  border-radius: 8px;
  background: #fff;
  color: #31506a;
  padding: 10px 13px;
  font-weight: 700;
}

.workshop-sheet-editor-title { min-width: 0; }
.workshop-sheet-editor-title small { color: #71879d; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.workshop-sheet-editor-title h2 { margin: 2px 0; color: #173452; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workshop-sheet-editor-title h2 span { color: #536b82; font-weight: 500; }
.workshop-sheet-editor-title p { margin: 0; color: #71879d; font-size: 12px; }
.workshop-sheet-editor-title .badge,
.workshop-sheet-editor-title .status-badge { vertical-align: middle; }

.workshop-sheet-editor-save {
  min-width: 125px;
  padding: 8px 11px;
  border-radius: 8px;
  background: #eefaf2;
  text-align: center;
}

.workshop-sheet-editor-actions { display: flex; gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.workshop-sheet-editor-actions button { white-space: nowrap; }

.workshop-sheet-editor-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid #d9e2ec;
  background: #f8fafc;
}

.workshop-sheet-editor-tabs button {
  min-width: 210px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #536b82;
  padding: 8px 13px;
  text-align: left;
}

.workshop-sheet-editor-tabs button > b {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #dfe7ef;
  color: #536b82;
}

.workshop-sheet-editor-tabs button > span { display: grid; font-weight: 800; }
.workshop-sheet-editor-tabs button small { color: #8596a8; font-size: 11px; font-weight: 500; }
.workshop-sheet-editor-tabs button.active { border-color: #a9cce5; background: #eaf5ff; color: #2477b9; }
.workshop-sheet-editor-tabs button.active > b { background: #4096d6; color: #fff; }

.workshop-sheet-editor-body {
  overflow: auto;
  padding: 24px max(24px, calc((100vw - 1280px) / 2));
}

.workshop-sheet-panel { display: none; }
.workshop-sheet-panel.active { display: block; }

.workshop-sheet-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.workshop-sheet-panel-heading > div > span { color: #4096d6; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.workshop-sheet-panel-heading h3 { margin: 3px 0; color: #173452; font-size: 24px; }
.workshop-sheet-panel-heading p { margin: 0; color: #71879d; }
.workshop-sheet-panel-heading > strong { font-size: 30px; color: #2477b9; }

.workshop-machine-fields {
  max-width: 980px;
  margin: 0 auto;
  padding: 22px;
  border: 1px solid #d9e2ec;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(33, 55, 76, 0.06);
}
.workshop-contract-status {
  align-self: end;
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #b9d9c4;
  border-radius: 8px;
  background: #eff9f1;
  color: #236b38;
  font-weight: 800;
}

.workshop-editor-subassemblies {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.workshop-editor-subassemblies .workshop-subassembly { min-width: 0; margin: 0; align-self: start; }
.workshop-editor-general-notes { display: grid; gap: 6px; margin-top: 16px; padding: 16px; border: 1px solid #d9e2ec; border-radius: 12px; background: #fff; }
.workshop-editor-general-notes > span { color: #61788f; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.workshop-editor-general-notes textarea { width: 100%; border: 1px solid #ccd8e4; border-radius: 8px; padding: 10px; }

.workshop-editor-participants { max-width: 850px; }
.workshop-finish-extra-fields { max-width: 850px; display: grid; gap: 16px; margin-top: 16px; }
.workshop-finish-extra-fields label { display: grid; gap: 6px; }
.workshop-finish-extra-fields label > span { color: #61788f; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.workshop-finish-extra-fields input { max-width: 160px; }
.workshop-finish-extra-fields small { color: #71879d; font-size: 12px; }
.workshop-coverage-choice { margin: 0; padding: 14px 16px 16px; border: 1px solid #d9e2ec; border-radius: 12px; background: #fff; }
.workshop-coverage-choice legend { padding: 0 4px; color: #173452; font-weight: 700; }
.workshop-coverage-choice legend b { margin-left: 5px; color: #b42318; font-size: 11px; text-transform: uppercase; }
.workshop-coverage-choice p { margin: 0 0 12px; color: #61788f; font-size: 13px; }
.workshop-coverage-options { display: flex; flex-wrap: wrap; gap: 10px; }
.workshop-coverage-options label { position: relative; cursor: pointer; }
.workshop-coverage-options input { position: absolute; max-width: none; opacity: 0; pointer-events: none; }
.workshop-coverage-options span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 15px; border: 1px solid #b9c9d9; border-radius: 9px; color: #294966; background: #f8fafc; font-weight: 700; }
.workshop-coverage-options input:checked + span { border-color: #1769aa; color: #fff; background: #1769aa; box-shadow: 0 0 0 2px rgba(23, 105, 170, .16); }
.workshop-coverage-options input:focus-visible + span { outline: 3px solid rgba(23, 105, 170, .3); outline-offset: 2px; }
.workshop-coverage-options input:disabled + span { cursor: default; opacity: .78; }
.workshop-loan-options { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 12px 14px; border: 1px solid #d9e2ec; border-radius: 10px; background: #fff; }
.workshop-loan-options label { display: inline-flex; grid-template-columns: none; align-items: center; gap: 8px; cursor: pointer; }
.workshop-loan-options input { width: 18px; height: 18px; max-width: none; margin: 0; accent-color: #1769aa; }
.workshop-loan-options label > span { color: #294966; font-size: 13px; font-weight: 700; text-transform: none; }
.workshop-loan-options label:has(input:disabled) { cursor: default; opacity: .55; }
.workshop-loan-options > small { flex-basis: 100%; }

.workshop-finish-summary {
  max-width: 850px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.workshop-finish-summary > div { display: grid; gap: 4px; padding: 15px; border: 1px solid #d9e2ec; border-radius: 10px; background: #fff; }
.workshop-finish-summary span { color: #71879d; font-size: 12px; }
.workshop-finish-summary strong { color: #173452; font-size: 22px; }

.workshop-sheet-panel-next { display: flex; justify-content: flex-end; margin-top: 20px; }
.workshop-finish-action { display: flex; justify-content: flex-end; margin-top: 16px; }
.workshop-finish-action .primary-button { padding: 13px 20px; font-size: 15px; }

@media (max-width: 1180px) {
  .parts-customer-grid, .parts-supplier-grid, .parts-catalog-grid, .workshop-sheet-grid { grid-template-columns: repeat(4, minmax(130px, 1fr)); }
  .operation-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workshop-sheet-editor-header { grid-template-columns: auto minmax(220px, 1fr) auto; }
  .workshop-sheet-editor-save { grid-column: 2; grid-row: 2; justify-self: start; }
  .workshop-sheet-editor-actions { grid-column: 3; grid-row: 1 / span 2; }
  .workshop-editor-subassemblies { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .operation-summary { grid-template-columns: 1fr 1fr; }
  .operations-toolbar { grid-template-columns: 1fr; }
  .operations-line, .operations-line.customer-line { grid-template-columns: 1fr; }
  .parts-queue-list { grid-template-columns: 1fr; }
  .parts-queue-card { gap: 9px; }
  .parts-queue-actions { justify-content: flex-start; }
  .parts-queue-main small { white-space: normal; }
  .operations-line.part-entry-line { padding-bottom: 9px; }
  .part-entry-status { position: static; margin-top: 3px; }
  .workshop-subassembly .operations-line.customer-line { grid-template-columns: 1fr; }
  .parts-customer-grid, .parts-supplier-grid, .parts-catalog-grid, .workshop-sheet-grid { min-width: 980px; }
  .workshop-case-searchbar { grid-template-columns: 1fr; }
  .workshop-free-sheet-callout { align-items: stretch; flex-direction: column; }
  .workshop-case-result { grid-template-columns: 1fr; }
  .workshop-case-result em { grid-column: 1; grid-row: auto; }
  .workshop-participant-row, .workshop-subassembly-head { grid-template-columns: 1fr; }
  .workshop-sheet-editor-form { grid-template-rows: auto auto minmax(0, 1fr); }
  .workshop-sheet-editor-header { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 10px 12px; }
  .workshop-sheet-editor-title h2 { font-size: 16px; }
  .workshop-sheet-editor-title p { display: none; }
  .workshop-sheet-editor-save { grid-column: 1 / span 2; grid-row: 2; justify-self: stretch; }
  .workshop-sheet-editor-actions { grid-column: 1 / span 2; grid-row: 3; justify-content: stretch; }
  .workshop-sheet-editor-actions button { flex: 1; }
  .workshop-sheet-editor-tabs { justify-content: stretch; padding: 7px; }
  .workshop-sheet-editor-tabs button { min-width: 0; flex: 1; justify-content: center; padding: 7px; }
  .workshop-sheet-editor-tabs button > span { display: none; }
  .workshop-sheet-editor-body { padding: 16px 12px; }
  .workshop-sheet-panel-heading h3 { font-size: 20px; }
  .workshop-finish-summary { grid-template-columns: 1fr; }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

/* Utilitaire : cache n'importe quel element auquel on ajoute la classe. */
.hidden {
  display: none !important;
}

/* --- Selecteur de departement (topbar, admins) ------------------------- */
.dept-switcher {
  display: inline-flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px;
  border-radius: 10px;
  margin-right: 14px;
}
.dept-btn {
  border: 0;
  background: transparent;
  color: #fff;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.8;
}
.dept-btn:hover { opacity: 1; }
.dept-btn.active {
  background: #fff;
  color: var(--sidebar);
  opacity: 1;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #dce9f5;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.brand-logo {
  width: 174px;
  max-width: calc(100% - 42px);
  height: auto;
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.brand strong,
.brand span,
.user-pill span,
.user-pill strong {
  display: block;
}

.brand strong {
  font-size: 19px;
}

.brand span {
  color: #a9bbcc;
  font-size: 13px;
}

.primary-action,
.primary-button {
  border: 0;
  background: var(--green);
  color: #fff;
  border-radius: 4px;
  padding: 11px 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--blue);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 4px;
  padding: 10px 14px;
}

.side-search span {
  display: block;
  color: #8da3b7;
  font-size: 12px;
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 3px;
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(64, 150, 214, 0.12);
}

.side-search input {
  background: var(--sidebar-dark);
  border-color: #38566f;
  color: #fff;
}

.global-search-results {
  display: grid;
  gap: 5px;
  margin: -8px 20px 18px;
  max-height: 340px;
  overflow: auto;
}

.global-search-results.hidden {
  display: none;
}

.global-result {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid rgba(124, 157, 185, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #e8f3ff;
  border-radius: 6px;
  padding: 8px 9px;
  text-align: left;
  cursor: pointer;
}

.global-result:hover {
  background: rgba(64, 150, 214, 0.22);
  border-color: rgba(135, 190, 232, 0.6);
}

.global-result b {
  color: #8fd0ff;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.global-result span {
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}

.global-result small {
  color: #a9bdd0;
  font-size: 11px;
  line-height: 1.25;
}

.global-result-empty {
  color: #a9bdd0;
  border: 1px dashed rgba(124, 157, 185, 0.35);
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-data-group {
  margin-top: 8px;
  border-top: 1px solid rgba(220, 233, 245, 0.14);
  padding-top: 8px;
}

.nav-data-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: #a9bdd0;
  min-height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  cursor: pointer;
}

.nav-data-toggle b { font-size: 18px; line-height: 1; transition: transform .15s ease; }
.nav-data-items { display: flex; flex-direction: column; gap: 4px; }
.nav-data-items .nav-item { padding-left: 22px; }
.nav-data-group.collapsed .nav-data-items { display: none; }
.nav-data-group.collapsed .nav-data-toggle b { transform: rotate(-90deg); }

.nav-item {
  border: 0;
  background: transparent;
  color: #dce9f5;
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  border-left: 3px solid transparent;
  text-align: left;
}

.nav-item.active {
  background: var(--sidebar-active);
  border-left-color: #77c7ff;
}

.nav-item b,
.top-tab b {
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
}

.side-crm-entry {
  margin-top: -8px;
  padding-top: 16px;
  border-top: 1px solid rgba(220, 233, 245, 0.14);
}

.crm-entry-button {
  width: 100%;
  min-height: 62px;
  border-radius: 8px;
  border-left: 0;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(109, 78, 215, 0.98), rgba(64, 150, 214, 0.92));
  color: #fff;
  box-shadow: 0 12px 24px rgba(10, 22, 40, 0.22);
}

.crm-entry-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(10, 22, 40, 0.28);
}

.crm-entry-button span {
  display: grid;
  gap: 2px;
}

.crm-entry-button strong {
  font-size: 14px;
  line-height: 1.15;
}

.crm-entry-button small {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  line-height: 1.2;
}

.crm-entry-button b {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.top-tab,
.user-pill {
  min-width: 126px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid rgba(0, 0, 0, 0.12);
  gap: 8px;
}

.top-tab.active {
  background: rgba(255, 255, 255, 0.08);
}

.user-pill {
  min-width: 190px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #21445f;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.6);
  font-weight: 800;
}

.user-pill span {
  font-size: 12px;
  opacity: 0.9;
}

.view {
  display: none;
  padding: 28px 32px 42px;
}

.view.active {
  display: block;
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.title-actions {
  display: flex;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 28px;
  color: #386f9f;
  font-weight: 500;
}

h1 span {
  color: var(--muted);
  font-size: 16px;
}

.data-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.support-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.pickup-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.support-tile {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  padding: 14px 16px;
  box-shadow: 0 8px 18px rgba(33, 55, 76, 0.06);
}

.support-tile.warning {
  border-top-color: var(--orange);
}

.support-tile.danger {
  border-top-color: var(--red);
}

.support-tile.success {
  border-top-color: var(--green);
}

.support-tile strong {
  display: block;
  color: var(--blue-dark);
  font-size: 28px;
}

.support-tile span {
  color: var(--muted);
  font-size: 13px;
}

.support-alert-list {
  grid-column: 1 / -1;
  background: var(--soft-red);
  border: 1px solid rgba(217, 77, 66, 0.35);
  border-left: 5px solid var(--red);
  padding: 14px;
  box-shadow: 0 10px 24px rgba(217, 77, 66, 0.12);
}

.support-alert-list h3 {
  margin: 0 0 10px;
  color: #96362e;
  font-size: 15px;
}

.support-alert-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 1px solid rgba(217, 77, 66, 0.25);
  padding: 10px 12px;
  margin-top: 8px;
}

.support-alert-card strong,
.support-alert-card span {
  display: block;
}

.support-alert-card span {
  color: var(--muted);
  margin-top: 2px;
}

.support-alert-card button.primary {
  border: 0;
  background: var(--red);
  color: #fff;
  border-radius: 4px;
  padding: 8px 12px;
  font-weight: 800;
}

.table-grid {
  display: grid;
  align-items: stretch;
}

.ticket-grid {
  grid-template-columns: 44px 88px 124px minmax(150px, 1fr) 108px minmax(280px, 1.55fr) 140px 142px 90px 150px;
}

.atelier-grid {
  grid-template-columns: 64px minmax(170px, 1.45fr) 100px 120px 130px 145px 116px 132px;
}

.machine-grid {
  grid-template-columns: 84px minmax(210px, 1.5fr) 105px 160px 150px 110px 140px 160px;
}

.loan-grid {
  grid-template-columns: 84px 100px 150px 150px 145px minmax(180px, 1fr) 110px 120px 150px;
}

.pickup-grid {
  grid-template-columns: 82px 170px minmax(170px, 1fr) 82px 128px 112px 112px 178px 132px;
}

.table-head {
  color: #477ba9;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.table-head > div {
  min-height: 86px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 10px;
  text-align: center;
  border-right: 1px solid var(--line);
  font-weight: 700;
}

.table-head.compact > div {
  min-height: 52px;
  align-items: flex-start;
  text-align: left;
}

.sortable-head {
  cursor: pointer;
  user-select: none;
}

.sortable-head:hover {
  color: var(--blue);
  background: #f5f9fd;
}

.sortable-head.active {
  color: var(--blue);
}

.sortable-head.active::after {
  content: attr(data-sort-label);
  display: inline-flex;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  color: var(--blue);
}

.table-head span {
  font-size: 13px;
}

.filter-row {
  min-height: 64px;
  background: #fbfdff;
  border-bottom: 1px solid var(--line);
}

.filter-row > * {
  margin: 10px;
  min-width: 0;
}

.filter-row button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 4px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 260px;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.table-body {
  max-height: calc(100vh - 265px);
  overflow: auto;
}

.row {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.row > div {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 9px 12px;
  border-right: 1px solid #edf2f6;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row:nth-child(odd) {
  background: #fbfdff;
}

.row:nth-child(even) {
  background: #fff;
}

.row.parts-order-sent {
  background: #f1f3f5;
  color: #667085;
}

.row.needs-attention {
  background: #fff0ef;
  box-shadow: inset 5px 0 0 var(--red);
  animation: attentionGlow 1.8s ease-in-out infinite;
}

.row.needs-attention .num-badge {
  background: var(--red);
}

/* --- Marquage SUPER URGENT (defini APRES needs-attention pour gagner la cascade) --- */
.row.super-urgent {
  background: #ffe0db;
  box-shadow: inset 6px 0 0 #c0271b;
  animation: superUrgentGlow 1.2s ease-in-out infinite;
}
.row.super-urgent .num-badge {
  background: #c0271b;
}
@keyframes superUrgentGlow {
  0%, 100% { background: #ffe0db; }
  50% { background: #ffcfc8; }
}

.super-urgent-tag {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  vertical-align: middle;
}

.super-urgent-banner {
  background: var(--red);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
  text-align: center;
  animation: superUrgentGlow 1.2s ease-in-out infinite;
}

.super-urgent-btn {
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 700;
}
.super-urgent-btn:hover {
  background: #b8241a;
}

.group-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef4fb;
  color: #31516c;
  border: 1px solid #d8e6f2;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

.group-badge.special {
  background: #fff3cd;
  border-color: #f0c766;
  color: #7a4f00;
}

.group-notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #fff8e6;
  border: 1px solid #f3d27b;
  border-left: 5px solid #d49400;
  border-radius: 8px;
  color: #553700;
}

.group-notice strong {
  font-size: 13px;
  text-transform: uppercase;
}

.group-notice span {
  font-size: 13px;
  line-height: 1.35;
}

.support-tile.super-urgent {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.support-tile.super-urgent strong,
.support-tile.super-urgent span {
  color: #fff;
}

/* Case a cocher "programmé" dans les enlevements */
.pickup-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.pickup-check input { cursor: pointer; margin: 0; }
.pickup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.mini-action {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.mini-action:hover {
  background: var(--soft-blue);
}

.mini-action.primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.mini-action.primary:hover {
  background: #1d476c;
}

.inline-status-select {
  width: 100%;
  min-width: 0;
  max-width: 178px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 700;
  outline: none;
}

.inline-status-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.14);
}
@media (min-width: 761px) {
  /* La cellule Statut des enlevements empile le badge + la case a cocher */
  .pickup-grid.row > div:nth-child(8) {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    white-space: normal !important;
    overflow: visible !important;
  }
}

.pickup-grid .row-actions {
  gap: 6px;
}

.pickup-grid .row-actions button {
  padding: 6px 8px;
}

.attention-pulse {
  animation: attentionGlow 1.8s ease-in-out infinite;
}

.attention-banner {
  background: #fff0ef;
  border: 1px solid rgba(217, 77, 66, 0.35);
  border-left: 5px solid var(--red);
  color: #96362e;
  font-weight: 800;
  padding: 12px 14px;
  margin-bottom: 14px;
}

@keyframes attentionGlow {
  0%,
  100% {
    box-shadow: inset 5px 0 0 var(--red), 0 0 0 rgba(217, 77, 66, 0);
  }
  50% {
    box-shadow: inset 5px 0 0 var(--red), 0 0 0 4px rgba(217, 77, 66, 0.12);
  }
}

.num-badge {
  background: var(--blue);
  color: #fff;
  border-radius: 3px;
  min-width: 32px;
  text-align: center;
  padding: 4px 7px;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  padding: 4px 9px;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

.badge.info {
  color: #0c4a6e;
  background: var(--soft-blue);
}

.badge.warning {
  color: #915e00;
  background: var(--soft-orange);
}

.badge.success {
  color: #0c6a38;
  background: var(--soft-green);
}

.badge.danger {
  color: #a33129;
  background: var(--soft-red);
}

.badge.neutral {
  color: #445b70;
  background: #eef2f6;
}

.contract-pill,
.return-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.contract-pill.warranty {
  color: #7a4d00;
  background: #fff2cb;
}

.contract-pill.contract,
.return-pill.ok {
  color: #0c6a38;
  background: var(--soft-green);
}

.contract-pill.no-contract,
.return-pill.waiting {
  color: #915e00;
  background: var(--soft-orange);
}

.contract-pill.unknown {
  color: #64748b;
  background: #eef2f6;
}

.return-pill {
  margin-top: 4px;
}

.priority {
  font-weight: 800;
}

.priority.urgent {
  color: var(--red);
}

.priority.normal {
  color: #9d7a15;
}

.row-actions {
  gap: 8px;
}

.row-actions button,
.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue-dark);
  border-radius: 4px;
  padding: 6px 9px;
}

.row-actions button.primary,
.ghost-button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.row-actions button.danger {
  color: var(--red);
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.workflow-card,
.kpi-card {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  padding: 14px 16px;
}

.workflow-card {
  cursor: pointer;
  position: relative;
}

/* Pastille "nouvelle machine de prêt à expédier" (par poste) */
.workflow-new-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(217, 77, 66, 0.45);
  animation: shipBadgePulse 1.8s ease-in-out infinite;
}

@keyframes shipBadgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.workflow-card.selected,
.support-tile.filter-tile.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(64, 150, 214, 0.18), 0 8px 18px rgba(18, 57, 92, 0.12);
  background: #f7fbff;
}

.workflow-card.selected {
  border-top-color: var(--green);
}

.support-tile.filter-tile.selected {
  outline: 3px solid rgba(64, 150, 214, 0.16);
  outline-offset: 2px;
}

.workflow-card strong,
.kpi-card strong {
  display: block;
  font-size: 28px;
  color: var(--blue-dark);
}

.workflow-card span,
.kpi-card span {
  color: var(--muted);
  font-size: 13px;
}

.atelier-kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding: 0 0 14px;
  margin-bottom: 16px;
  scroll-snap-type: x proximity;
}

.atelier-kanban.hidden {
  display: none;
}

.atelier-kanban-column {
  min-height: 430px;
  max-height: calc(100vh - 330px);
  background: #f7fafc;
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scroll-snap-align: start;
}

.atelier-kanban-column.tone-warning { border-top-color: var(--orange); }
.atelier-kanban-column.tone-success { border-top-color: var(--green); }
.atelier-kanban-column.tone-danger { border-top-color: var(--red); }
.atelier-kanban-column.tone-info { border-top-color: var(--blue); }
.atelier-kanban-column.drag-over {
  background: #edf7ff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(64, 150, 214, 0.16);
}

.atelier-kanban-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.atelier-kanban-column header span {
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
}

.atelier-kanban-column header strong {
  min-width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  background: #e6eef5;
  color: var(--blue-dark);
  border-radius: 999px;
  font-size: 12px;
}

.atelier-kanban-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  overflow-y: auto;
}

.atelier-kanban-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 6px solid #cbd6e2;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 6px 16px rgba(18, 57, 92, 0.08);
  cursor: grab;
}

.atelier-kanban-card.material-sb {
  border-left-color: #2563eb;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.09), #fff 34%);
}

.atelier-kanban-card.material-nmd {
  border-left-color: #ec4899;
  background: linear-gradient(90deg, rgba(236, 72, 153, 0.1), #fff 34%);
}

.atelier-kanban-card.material-mib {
  border-left-color: #eab308;
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.13), #fff 34%);
}

.atelier-kanban-card.material-cashio {
  border-left-color: #16a34a;
  background: linear-gradient(90deg, rgba(22, 163, 74, 0.1), #fff 34%);
}

.atelier-kanban-card.material-grg {
  border-left-color: #7c3aed;
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.1), #fff 34%);
}

.atelier-kanban-card.material-arca {
  border-left-color: #0891b2;
  background: linear-gradient(90deg, rgba(8, 145, 178, 0.11), #fff 34%);
}

.atelier-kanban-card.material-peripheral {
  border-left-color: #f97316;
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.1), #fff 34%);
}

.atelier-kanban-card.material-other {
  border-left-color: #94a3b8;
}

.atelier-kanban-card.dragging {
  opacity: 0.55;
}

.atelier-kanban-card.super-urgent {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(225, 83, 70, 0.15), 0 8px 18px rgba(18, 57, 92, 0.1);
}

.atelier-kanban-card.needs-attention {
  border-left: 4px solid var(--red);
}

.atelier-kanban-card.sla-late {
  background: #fff8f6;
}

.atelier-kanban-card-head,
.atelier-kanban-card-meta,
.atelier-kanban-card-foot,
.atelier-kanban-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.atelier-kanban-card-head {
  justify-content: space-between;
}

.atelier-kanban-card-alerts {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.atelier-new-ship-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .02em;
  box-shadow: 0 1px 4px rgba(217, 77, 66, 0.32);
}

.atelier-kanban-card-head strong {
  min-width: 0;
  color: var(--blue-dark);
  font-size: 13px;
  line-height: 1.25;
}

.atelier-kanban-card-meta,
.atelier-kanban-card-foot {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 8px;
}

.atelier-kanban-card p {
  margin: 8px 0 0;
  color: #1d3145;
  font-size: 12.5px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.atelier-kanban-card-foot em {
  font-style: normal;
  color: var(--red);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
}

.atelier-kanban-card-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.atelier-kanban-card-actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue-dark);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
}

.atelier-kanban-card-actions button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.support-ticket-grid {
  grid-template-columns: 95px 110px minmax(160px, 1fr) minmax(240px, 1.7fr) minmax(155px, .9fr) 135px 80px;
}

.support-ticket-grid .muted {
  font-size: 11px;
}

.support-normal-tag {
  font-size: inherit;
}

.support-status-select {
  width: 100%;
  min-width: 155px;
  box-sizing: border-box;
  min-height: 35px;
  padding: 5px 26px 5px 8px;
  border: 1px solid #c9d7e5;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.support-history {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 12px;
}

.support-history h3 {
  margin: 0 0 8px;
  color: var(--blue-dark);
  font-size: 13px;
}

.support-history > div {
  border-left: 3px solid #cbd6e2;
  margin: 8px 0;
  padding: 6px 10px;
}

.support-history span {
  color: var(--muted);
  font-size: 11px;
  margin-left: 8px;
}

.support-history p {
  margin: 4px 0 0;
  white-space: pre-wrap;
}

.support-action-toolbar {
  display: flex;
  justify-content: flex-start;
}

.support-action-toolbar .secondary-button {
  min-height: 40px;
  font-size: 14px;
  font-weight: 800;
}

.atelier-kanban-empty {
  display: grid;
  place-items: center;
  min-height: 90px;
  border: 1px dashed #cbd6e2;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.kpi-panel {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.kpi-panel h3 {
  margin: 0 0 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 36px;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.bar-track {
  height: 10px;
  background: #edf3f8;
  border-radius: 20px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
}

/* --- KPI : refonte (sections, histogrammes, estimation main d'oeuvre) --- */

/* Le conteneur #kpiGrid n'est plus une grille 3 colonnes : il empile des
   sections verticalement. L'ID l'emporte sur la classe .kpi-grid. */
#kpiGrid {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.kpi-section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
  flex-wrap: wrap;
}
.kpi-section-head h2 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}
.kpi-section-head span {
  color: var(--muted);
  font-size: 13px;
}

.kpi-section .kpi-grid {
  margin-bottom: 16px;
}

/* Cartes : tons d'alerte */
.kpi-card.danger { border-top-color: var(--red); }
.kpi-card.danger strong { color: var(--red); }
.kpi-card.warning { border-top-color: var(--orange); }
.kpi-card.warning strong { color: var(--orange); }
.kpi-card.success { border-top-color: var(--green); }
.kpi-card.success strong { color: var(--green); }

/* Conteneur de panels (graphes) */
.kpi-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

/* Histogrammes colonnes */
.kpi-columns {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 175px;
  padding-top: 10px;
}
.kpi-col-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.kpi-col-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 120px;
  width: 100%;
}
.kpi-col {
  width: 16px;
  min-height: 2px;
  background: var(--blue);
  border-radius: 3px 3px 0 0;
}
.kpi-col.a { background: var(--blue); }
.kpi-col.b { background: var(--orange); }
.kpi-col-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.kpi-col-label {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.kpi-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.kpi-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 2px;
}
.kpi-dot.a { background: var(--blue); }
.kpi-dot.b { background: var(--orange); margin-left: 10px; }

/* Estimation main d'oeuvre */
.kpi-manpower {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.kpi-mp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.kpi-mp-row:last-of-type { border-bottom: none; }
.kpi-mp-row span { color: var(--muted); font-size: 13px; }
.kpi-mp-row strong { font-size: 15px; }
.kpi-mp-row.alert strong { color: var(--red); }
.kpi-mp-row.ok strong { color: var(--green); }
.kpi-mp-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Balance flux atelier (entrants vs sortants) */
.kpi-balance {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 16px;
}
.kpi-balance strong { font-size: 20px; white-space: nowrap; }
.kpi-balance span { font-size: 13px; }
.kpi-balance.danger { background: var(--soft-red); color: #96362e; }
.kpi-balance.danger strong { color: var(--red); }
.kpi-balance.success { background: var(--soft-green); color: #1c6b39; }
.kpi-balance.success strong { color: var(--green); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(10, 22, 34, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(1040px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: modalIn 150ms ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-close {
  position: absolute;
  right: 16px;
  top: 14px;
  z-index: 2;
  border: 0;
  background: #edf2f7;
  border-radius: 50%;
  width: 32px;
  height: 32px;
}

.modal-header {
  padding: 24px 28px;
  background: #f6f9fc;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.modal-body {
  padding: 22px 28px 28px;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.info-box {
  border: 1px solid var(--line);
  padding: 15px;
}

.info-box label,
.form-grid label span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.info-box p {
  margin: 0 0 13px;
}

.issue-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #fbfdff;
  min-height: 92px;
  line-height: 1.5;
}

.history-list {
  margin-top: 16px;
  border: 1px solid var(--line);
}

.history-list h3 {
  margin: 0;
  padding: 12px 14px;
  background: #fbfdff;
  border-bottom: 1px solid var(--line);
}

.history-list .history-row {
  display: grid;
  grid-template-columns: 94px 110px minmax(180px, 1fr) 150px 82px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #edf2f6;
}

.history-list .history-row button {
  padding: 5px 8px;
}

.order-items-card { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.order-items-heading { display: flex; justify-content: space-between; align-items: end; gap: 14px; padding: 12px 14px; background: #fbfdff; border-bottom: 1px solid var(--line); }
.order-items-heading h3 { margin: 0; font-size: 15px; }
.order-items-heading small { display: block; margin-top: 3px; color: #667085; }
.order-items-search { display: grid; gap: 4px; min-width: min(100%, 250px); }
.order-items-search span, .order-items-columns { color: #667085; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.order-items-search input { min-height: 36px; }
.order-items-columns, .order-items-row { display: grid; align-items: center; gap: 12px; padding: 9px 14px; }
.order-items-columns.customer, .order-items-row.customer { grid-template-columns: minmax(130px, .85fr) minmax(220px, 2fr) 115px; }
.order-items-columns.supplier, .order-items-row.supplier { grid-template-columns: minmax(130px, .8fr) minmax(190px, 2fr) 118px 100px; }
.order-items-columns { padding-top: 8px; padding-bottom: 8px; background: #f8fafc; border-bottom: 1px solid #edf2f6; }
.order-items-body { max-height: 330px; overflow: auto; }
.order-items-row { min-height: 48px; border-bottom: 1px solid #edf2f6; }
.order-items-row:last-child { border-bottom: 0; }
.order-items-row strong { color: #172b4d; font-size: 13px; }
.order-items-row > span { color: #475467; font-size: 13px; }
.order-items-row b { color: #172b4d; }
.order-items-quantity { justify-self: end; white-space: nowrap; }
.order-items-empty, .order-items-no-result { margin: 0; padding: 16px 14px; color: #667085; text-align: center; }

@media (max-width: 760px) {
  .order-items-heading { align-items: stretch; flex-direction: column; }
  .order-items-search { min-width: 0; }
  .order-items-columns { display: none; }
  .order-items-row, .order-items-row.supplier, .order-items-row.customer { grid-template-columns: 1fr; gap: 4px; }
  .order-items-quantity { justify-self: start; }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label.full {
  grid-column: 1 / -1;
}

/* Les blocs non-label (lignes de commande, listes, boutons) doivent eux aussi
   prendre les deux colonnes de la fenêtre, pas rester coincés à gauche. */
.form-grid > .full {
  grid-column: 1 / -1;
  min-width: 0;
}

.form-grid label.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.form-grid label.checkline input[type="checkbox"] {
  width: auto;
  min-width: 18px;
  height: 18px;
  box-shadow: none;
}

.form-grid label.checkline span {
  margin: 0;
  text-transform: none;
  font-size: 13px;
  color: var(--text);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 28px 24px;
  border-top: 1px solid var(--line);
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
}

.machine-results {
  border: 1px solid var(--line);
  max-height: 260px;
  overflow: auto;
  background: #fbfdff;
}

.machine-result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid #edf2f6;
  cursor: pointer;
}

.machine-result:hover,
.machine-result.active {
  background: var(--soft-blue);
}

.machine-result strong,
.machine-result span {
  display: block;
}

.machine-result span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.empty-state {
  color: var(--muted);
  padding: 16px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.danger-button {
  border: 1px solid var(--red);
  background: #fff;
  color: var(--red);
  border-radius: 4px;
  padding: 10px 14px;
}

.mail-note {
  border-left: 4px solid var(--blue);
  background: var(--soft-blue);
  padding: 12px 14px;
  margin-top: 14px;
  color: var(--text);
}

.procedure-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(420px, 1.2fr);
  gap: 16px;
}

.procedure-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 13px 14px;
  margin-bottom: 10px;
  cursor: pointer;
}

.procedure-card:hover,
.procedure-card.active {
  background: var(--soft-blue);
  border-color: #b8d9f3;
}

.procedure-card strong,
.procedure-card span {
  display: block;
}

.procedure-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.merge-search-panel {
  margin-top: 14px;
}

.merge-search-panel label {
  display: block;
}

.merge-search-panel label span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.merge-ticket-results {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
  margin: 12px 0 16px;
  padding-right: 4px;
}

.merge-ticket-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
  padding: 13px 14px;
  border-radius: 6px;
  cursor: pointer;
}

.merge-ticket-card:hover,
.merge-ticket-card.selected {
  border-color: #6fb7ea;
  background: #f3f9fe;
  box-shadow: 0 0 0 3px rgba(64, 153, 219, 0.12);
}

.merge-ticket-main strong,
.merge-ticket-main span,
.merge-ticket-meta span {
  display: block;
}

.merge-ticket-main strong {
  color: var(--blue-dark);
  font-size: 14px;
  margin-bottom: 4px;
}

.merge-ticket-main span {
  color: var(--text);
  line-height: 1.35;
}

.merge-ticket-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 120px;
}

.merge-ticket-side small,
.merge-ticket-meta {
  color: var(--muted);
  font-size: 12px;
}

.merge-ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
}

.merge-ticket-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 1 / -1;
}

.merge-mini-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #eaf3fb;
  color: var(--blue-dark);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.mail-preview {
  border: 1px solid var(--line);
  background: #fbfdff;
  padding: 14px;
}

.mail-preview label {
  display: block;
  margin-bottom: 10px;
}

.mail-preview textarea {
  min-height: 180px;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--soft-blue);
  color: var(--blue-dark);
  border: 1px solid #b8d9f3;
  padding: 8px 10px;
  border-radius: 4px;
  margin-top: 8px;
}

/* Pieces jointes dans le formulaire de reponse */
.reply-attach-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.reply-attach-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.reply-attach-pill {
  display: inline-flex;
  align-items: center;
  background: var(--soft-green);
  color: #1c6b39;
  border: 1px solid #b5e0c4;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.conversation {
  margin-top: 16px;
  border: 1px solid var(--line);
  background: #fff;
}

.conversation h3 {
  margin: 0;
  padding: 12px 14px;
  background: #fbfdff;
  border-bottom: 1px solid var(--line);
}

.message {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid #edf2f6;
}

.message-meta strong,
.message-meta span {
  display: block;
}

.message-meta span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.5;
}

.message.client {
  background: #fff;
}

.message.support {
  background: #fbfdff;
}

.message.system {
  background: var(--soft-blue);
}

.casino-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}

.casino-card:hover {
  background: var(--soft-blue);
}

.casino-card strong,
.casino-card span {
  display: block;
}

.casino-card span {
  color: var(--muted);
  margin-top: 4px;
}

.casino-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(420px, 1.2fr);
  gap: 16px;
}

.compact-list {
  border: 1px solid var(--line);
  background: #fff;
  max-height: 360px;
  overflow: auto;
}

.compact-list .list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #edf2f6;
}

.compact-list .list-row strong,
.compact-list .list-row span {
  display: block;
}

.compact-list .list-row span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.toast {
  position: fixed;
  right: 26px;
  bottom: 24px;
  /* Doit rester visible au-dessus de l’éditeur plein écran des fiches atelier. */
  z-index: 100;
  background: #1e2f40;
  color: #fff;
  border-left: 5px solid var(--green);
  box-shadow: var(--shadow);
  padding: 14px 18px;
}

.toast.hidden {
  display: none;
}

/* Bouton repli dans la sidebar (a cote du logo) */
.sidebar-collapse-btn {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #fff;
  opacity: 0.7;
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  flex: 0 0 auto;
}
.sidebar-collapse-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}

/* Bouton fixe pour reafficher la sidebar quand elle est repliee (desktop) */
.sidebar-reopen {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  background: var(--sidebar);
  color: #fff;
  border: 0;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* Repli de la sidebar sur desktop (le workspace prend toute la largeur) */
@media (min-width: 761px) {
  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }
  body.sidebar-collapsed .sidebar {
    display: none;
  }
  body.sidebar-collapsed .sidebar-reopen {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Tableaux : une seule ligne par cellule, troncature propre (...) */
  .table-body .row > div:not(.row-actions) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .row-actions { flex-wrap: nowrap; }
  .row-actions button { white-space: nowrap; }
}

/* Le bouton repli sidebar est masque sur mobile (burger fixe a la place) */
@media (max-width: 760px) {
  .sidebar-collapse-btn { display: none; }
  .sidebar-reopen { display: none !important; }
}

/* ======================================================================
   Ecrans intermediaires (portables 13-16") : 761px -> 1600px
   Les tableaux passent en colonnes FLUIDES qui se compriment pour tenir
   dans la largeur disponible (plus de debordement / colonnes coupees).
   ====================================================================== */
@media (min-width: 761px) and (max-width: 1600px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .data-card { overflow-x: auto; }

  .table-grid.row > div,
  .table-grid.table-head > div {
    font-size: 12.5px;
  }

  .ticket-grid {
    grid-template-columns: 32px 54px minmax(0, 0.9fr) minmax(90px, 1.3fr) minmax(0, 0.8fr) minmax(120px, 1.9fr) 82px minmax(60px, 1fr) minmax(0, 0.7fr) 100px;
  }
  .atelier-grid {
    grid-template-columns: 48px minmax(118px, 1.45fr) minmax(62px, 0.7fr) minmax(76px, 0.8fr) minmax(92px, 0.95fr) minmax(92px, 1fr) minmax(62px, 0.75fr) 94px;
  }
  .machine-grid {
    grid-template-columns: 60px minmax(110px, 1.5fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.7fr) minmax(64px, 1fr) 116px;
  }
  .loan-grid {
    grid-template-columns: 60px minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1fr) minmax(64px, 1fr) minmax(90px, 1.2fr) minmax(0, 0.8fr) minmax(0, 0.8fr) 104px;
  }
  .pickup-grid {
    grid-template-columns: 70px minmax(90px, 1.2fr) minmax(90px, 1.2fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 0.9fr) minmax(60px, 1fr) 104px;
  }
  .casino-grid {
    grid-template-columns: minmax(120px, 2fr) minmax(0, 1fr) minmax(0, 0.6fr) minmax(0, 0.85fr) minmax(0, 0.8fr) minmax(0, 0.5fr) 88px;
  }

  .workflow-strip,
  .kpi-grid,
  .support-dashboard,
  .pickup-dashboard,
  .kpi-panels {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .casino-layout,
  .split-panel,
  .procedure-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Authentification : ecran de login et bouton deconnexion --- */

body.auth-locked {
  overflow: hidden;
}

.app-shell.locked {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(34, 56, 74, 0.92), rgba(26, 44, 60, 0.96));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.auth-gate.visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-card {
  background: var(--surface);
  color: var(--text);
  padding: 32px 32px 24px;
  border-radius: 14px;
  width: min(420px, 100%);
  box-shadow: 0 22px 60px rgba(10, 25, 40, 0.45);
}

.auth-card h1 {
  margin: 14px 0 6px;
  font-size: 22px;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--sidebar);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.auth-brand strong {
  display: block;
  font-size: 16px;
}

.auth-brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.auth-logo {
  width: min(270px, 100%);
  height: auto;
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(20, 40, 70, 0.12);
}

.auth-help {
  color: var(--muted);
  margin: 4px 0 18px;
  font-size: 13px;
}

.auth-card form label {
  display: block;
  margin-bottom: 12px;
}

.auth-card form label span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.auth-card form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.auth-card form input:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-color: var(--blue);
}

.auth-card .primary-button {
  width: 100%;
  padding: 10px 14px;
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  margin-top: 4px;
}

.auth-card .primary-button:hover:not(:disabled) {
  background: var(--blue-dark);
}

.auth-card .primary-button:disabled {
  opacity: 0.7;
  cursor: progress;
}

.auth-error {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--soft-red);
  color: var(--red);
  font-size: 13px;
}

.auth-footnote {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}

.auth-logout {
  margin-left: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: transparent;
  color: inherit;
  font-size: 12px;
}

.auth-logout:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* --- Vue Casinos : grille tableau -------------------------------------- */

.casino-grid {
  grid-template-columns: minmax(220px, 2fr) 1fr 0.6fr 0.7fr 0.5fr 0.9fr;
}

/* --- SLA atelier : badge age + ligne en retard ------------------------- */

.age-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}

.age-pill.ok {
  background: var(--soft-green);
  color: var(--green);
}

.age-pill.watch {
  background: var(--soft-orange);
  color: var(--orange);
}

.age-pill.late {
  background: var(--soft-red);
  color: var(--red);
}

.age-pill.neutral {
  background: var(--line);
  color: var(--muted);
}

.row.sla-late {
  border-left: 3px solid var(--red);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
  margin-left: 6px;
}

.ghost-button:hover {
  background: var(--soft-blue);
  border-color: var(--blue);
  color: var(--blue);
}

/* Tuiles atelier cliquables : curseur pointer */
#atelierDashboard .support-tile {
  cursor: pointer;
  transition: transform 0.1s ease;
}

#atelierDashboard .support-tile:hover {
  transform: translateY(-1px);
}

/* --- Responsive tablette / mobile -------------------------------------- */

/* Bouton menu burger : visible uniquement sur mobile */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  background: var(--sidebar);
  color: #fff;
  border: 0;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  font-size: 22px;
  line-height: 1;
  box-shadow: var(--shadow);
}

/* Tablette : 760-1100px */
@media (max-width: 1100px) {
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-card {
    max-width: 95vw;
  }

  .form-grid,
  .modal-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ======================================================================
   Mobile : <= 760px
   Refonte complete : les tables deviennent des cartes empilees, les
   filtres compliques disparaissent, les boutons sont taille pouce (44px).
   ====================================================================== */
@media (max-width: 760px) {
  /* --- Layout principal ------------------------------------------------- */
  .app-shell { grid-template-columns: 1fr; }

  .mobile-nav-toggle {
    display: block;
    background: var(--sidebar);
    box-shadow: 0 6px 18px rgba(10, 25, 40, 0.45);
  }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 300px;
    max-width: 88vw;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
    box-shadow: 6px 0 24px rgba(10, 25, 40, 0.45);
    overflow-y: auto;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::before {
    content: "";
    position: fixed; inset: 0;
    background: rgba(10, 25, 40, 0.55);
    z-index: 45;
  }

  .workspace { padding: 64px 12px 24px; }

  .breadcrumb { display: none; }

  /* --- Topbar simplifiee ------------------------------------------------ */
  .topbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px;
  }
  .top-tab { display: none; }
  .top-tab.active {
    display: inline-flex;
    font-size: 13px;
    padding: 4px 8px;
  }
  .user-pill {
    margin-top: 0;
    margin-left: auto;
    width: auto;
    font-size: 12px;
    gap: 6px;
    padding: 6px 8px;
  }
  .user-pill .avatar { width: 30px; height: 30px; font-size: 13px; }
  .user-pill > div:nth-child(2) { display: none; } /* nom invisible, juste avatar */
  .auth-logout { padding: 6px 10px; font-size: 11px; margin-left: 4px; min-height: 36px; }

  /* --- Entete de page --------------------------------------------------- */
  .page-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-title h1 { font-size: 20px; line-height: 1.2; }
  .title-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .title-actions button {
    flex: 1 1 140px;
    min-height: 44px;
    font-size: 13px;
  }

  /* --- Tables -> Cartes (le coeur de la refonte) ----------------------- */
  .data-card {
    padding: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  /* Entetes de colonnes : invisibles dans la vue carte */
  .table-head { display: none !important; }

  /* Ligne de filtres : invisible sur mobile, on filtre via la toolbar */
  .filter-row { display: none !important; }

  /* Toolbar (recherche + statut) : empilee, plein largeur, tactile */
  .toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(33, 55, 76, 0.05);
  }
  .toolbar input,
  .toolbar select {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  /* Corps du tableau : pile verticale de cartes */
  .table-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Carte de base : commune a tous les .row */
  .ticket-grid.row,
  .atelier-grid.row,
  .machine-grid.row,
  .loan-grid.row,
  .pickup-grid.row,
  .casino-grid.row {
    display: grid !important;
    min-width: 0 !important;
    padding: 14px !important;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    gap: 6px 10px;
    box-shadow: 0 2px 8px rgba(33, 55, 76, 0.05);
    overflow: hidden;
  }

  /* Conserver les indicateurs visuels d'urgence / retard en mode carte */
  .row.needs-attention {
    background: #fff0ef;
    border-color: rgba(217, 77, 66, 0.45);
    box-shadow: inset 5px 0 0 var(--red), 0 2px 8px rgba(33, 55, 76, 0.05);
  }
  .row.sla-late {
    border-left: 4px solid var(--red);
  }

  /* Reset des row-actions sur mobile : on les repositionne plus bas */
  .row-actions {
    display: flex !important;
    gap: 6px;
    flex-wrap: wrap;
  }
  .row-actions button {
    flex: 1 1 auto;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
  }

  /* --- TICKETS : grille de carte ---------------------------------------
     Colonnes DOM : 1.checkbox 2.# 3.tech 4.casino 5.material 6.title
                    7.date 8.status 9.priorite 10.actions */
  .ticket-grid.row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "id     status"
      "casino casino"
      "title  title"
      "tech   mat"
      "date   prio"
      "actions actions";
  }
  .ticket-grid.row > div:nth-child(1) { display: none; } /* checkbox masque */
  .ticket-grid.row > div:nth-child(2) { grid-area: id; font-weight: 700; font-size: 13px; color: var(--muted); }
  .ticket-grid.row > div:nth-child(3) { grid-area: tech; font-size: 12px; color: var(--muted); }
  .ticket-grid.row > div:nth-child(3)::before { content: "Tech : "; }
  .ticket-grid.row > div:nth-child(4) { grid-area: casino; font-weight: 600; font-size: 15px; color: var(--text); }
  .ticket-grid.row > div:nth-child(5) { grid-area: mat; font-size: 12px; color: var(--muted); text-align: right; }
  .ticket-grid.row > div:nth-child(6) { grid-area: title; font-size: 14px; line-height: 1.3; }
  .ticket-grid.row > div:nth-child(7) { grid-area: date; font-size: 12px; color: var(--muted); }
  .ticket-grid.row > div:nth-child(7)::before { content: "Le "; }
  .ticket-grid.row > div:nth-child(8) { grid-area: status; justify-self: end; }
  .ticket-grid.row > div:nth-child(9) { grid-area: prio; justify-self: end; font-size: 12px; }
  .ticket-grid.row > div:nth-child(10) {
    grid-area: actions;
    padding-top: 8px; margin-top: 4px;
    border-top: 1px solid var(--line);
  }

  /* --- ATELIER : grille de carte ---------------------------------------
     Colonnes DOM : 1.age 2.casino 3.material 4.serial
                    5.contract 6.status 7.tech 8.actions */
  .atelier-grid.row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "age      status"
      "casino   casino"
      "material serial"
      "contract contract"
      "tech     tech"
      "actions  actions";
  }
  .atelier-grid.row > div:nth-child(1) { grid-area: age; font-weight: 700; font-size: 13px; }
  .atelier-grid.row > div:nth-child(2) { grid-area: casino; font-weight: 600; font-size: 15px; }
  .atelier-grid.row > div:nth-child(3) { grid-area: material; font-size: 12px; color: var(--muted); }
  .atelier-grid.row > div:nth-child(3)::before { content: "Matériel : "; }
  .atelier-grid.row > div:nth-child(4) { grid-area: serial; font-size: 12px; color: var(--muted); text-align: right; }
  .atelier-grid.row > div:nth-child(4)::before { content: "Série : "; }
  .atelier-grid.row > div:nth-child(5) { grid-area: contract; font-size: 12px; color: var(--muted); }
  .atelier-grid.row > div:nth-child(5)::before { content: "Couverture : "; }
  .atelier-grid.row > div:nth-child(6) { grid-area: status; justify-self: end; }
  .atelier-grid.row > div:nth-child(7) { grid-area: tech; font-size: 12px; color: var(--muted); }
  .atelier-grid.row > div:nth-child(7)::before { content: "Tech : "; }
  .atelier-grid.row > div:nth-child(8) {
    grid-area: actions;
    padding-top: 8px; margin-top: 4px;
    border-top: 1px solid var(--line);
  }

  /* --- MACHINES : grille de carte --------------------------------------
     Colonnes DOM : 1.ID 2.casino 3.type 4.model 5.serial 6.contract
                    7.status 8.actions */
  .machine-grid.row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "id       status"
      "casino   casino"
      "type     model"
      "serial   contract"
      "actions  actions";
  }
  .machine-grid.row > div:nth-child(1) { grid-area: id; font-weight: 700; font-size: 12px; color: var(--muted); }
  .machine-grid.row > div:nth-child(2) { grid-area: casino; font-weight: 600; font-size: 15px; }
  .machine-grid.row > div:nth-child(3) { grid-area: type; font-size: 13px; }
  .machine-grid.row > div:nth-child(3)::before { content: "Type : "; color: var(--muted); font-size: 11px; }
  .machine-grid.row > div:nth-child(4) { grid-area: model; font-size: 12px; color: var(--muted); text-align: right; }
  .machine-grid.row > div:nth-child(5) { grid-area: serial; font-size: 12px; }
  .machine-grid.row > div:nth-child(5)::before { content: "S/N : "; color: var(--muted); }
  .machine-grid.row > div:nth-child(6) { grid-area: contract; font-size: 12px; color: var(--muted); text-align: right; }
  .machine-grid.row > div:nth-child(6)::before { content: "Contrat : "; }

  /* Machines a sous : libelles machine adaptes en mode carte mobile */
  body.dept-mas .machine-grid.row > div:nth-child(3)::before { content: "Marque : "; }
  body.dept-mas .machine-grid.row > div:nth-child(6)::before { content: "Jeu : "; }
  .machine-grid.row > div:nth-child(7) { grid-area: status; justify-self: end; }
  .machine-grid.row > div:nth-child(8) {
    grid-area: actions;
    padding-top: 8px; margin-top: 4px;
    border-top: 1px solid var(--line);
  }

  /* --- LOANS : grille de carte -----------------------------------------
     Colonnes DOM : 1.ID 2.type 3.model 4.serial 5.status 6.customer
                    7.departure 8.expectedReturn 9.actions */
  .loan-grid.row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "id       status"
      "type     model"
      "serial   serial"
      "customer customer"
      "dep      ret"
      "actions  actions";
  }
  .loan-grid.row > div:nth-child(1) { grid-area: id; font-weight: 700; font-size: 12px; color: var(--muted); }
  .loan-grid.row > div:nth-child(2) { grid-area: type; font-weight: 600; font-size: 14px; }
  .loan-grid.row > div:nth-child(3) { grid-area: model; font-size: 12px; color: var(--muted); text-align: right; }
  .loan-grid.row > div:nth-child(4) { grid-area: serial; font-size: 12px; }
  .loan-grid.row > div:nth-child(4)::before { content: "S/N : "; color: var(--muted); }
  .loan-grid.row > div:nth-child(5) { grid-area: status; justify-self: end; }
  .loan-grid.row > div:nth-child(6) { grid-area: customer; font-size: 13px; }
  .loan-grid.row > div:nth-child(6)::before { content: "Client : "; color: var(--muted); font-size: 11px; }
  .loan-grid.row > div:nth-child(7) { grid-area: dep; font-size: 12px; color: var(--muted); }
  .loan-grid.row > div:nth-child(7)::before { content: "Départ : "; }
  .loan-grid.row > div:nth-child(8) { grid-area: ret; font-size: 12px; color: var(--muted); text-align: right; }
  .loan-grid.row > div:nth-child(8)::before { content: "Retour prévu : "; }
  .loan-grid.row > div:nth-child(9) {
    grid-area: actions;
    padding-top: 8px; margin-top: 4px;
    border-top: 1px solid var(--line);
  }

  /* --- PICKUPS : grille de carte ---------------------------------------
     Colonnes DOM : 1.priority 2.type 3.casino 4.folder 5.machine
                    6.trigger 7.due 8.status 9.actions */
  .pickup-grid.row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "type    status"
      "casino  prio"
      "folder  folder"
      "machine machine"
      "trigger due"
      "actions actions";
  }
  .pickup-grid.row > div:nth-child(1) { grid-area: prio; justify-self: end; font-size: 12px; }
  .pickup-grid.row > div:nth-child(2) { grid-area: type; font-weight: 600; font-size: 14px; }
  .pickup-grid.row > div:nth-child(3) { grid-area: casino; font-size: 13px; }
  .pickup-grid.row > div:nth-child(3)::before { content: "Casino : "; color: var(--muted); font-size: 11px; }
  .pickup-grid.row > div:nth-child(4) { grid-area: folder; font-size: 12px; color: var(--muted); }
  .pickup-grid.row > div:nth-child(4)::before { content: "Dossier : "; }
  .pickup-grid.row > div:nth-child(5) { grid-area: machine; font-size: 12px; color: var(--muted); }
  .pickup-grid.row > div:nth-child(5)::before { content: "Machine : "; }
  .pickup-grid.row > div:nth-child(6) { grid-area: trigger; font-size: 12px; color: var(--muted); }
  .pickup-grid.row > div:nth-child(6)::before { content: "Déclencheur : "; }
  .pickup-grid.row > div:nth-child(7) { grid-area: due; font-size: 12px; color: var(--muted); text-align: right; }
  .pickup-grid.row > div:nth-child(7)::before { content: "Échéance : "; }
  .pickup-grid.row > div:nth-child(8) { grid-area: status; justify-self: end; }
  .pickup-grid.row > div:nth-child(9) {
    grid-area: actions;
    padding-top: 8px; margin-top: 4px;
    border-top: 1px solid var(--line);
  }

  /* --- CASINOS : grille de carte ---------------------------------------
     Colonnes DOM : 1.name 2.city 3.machines 4.atelier 5.loans 6.actions */
  .casino-grid.row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "name      name"
      "city      city"
      "machines  atelier"
      "loans     loans"
      "actions   actions";
  }
  .casino-grid.row > div:nth-child(1) { grid-area: name; font-weight: 600; font-size: 16px; }
  .casino-grid.row > div:nth-child(2) { grid-area: city; font-size: 12px; color: var(--muted); }
  .casino-grid.row > div:nth-child(2)::before { content: "Ville : "; }
  .casino-grid.row > div:nth-child(3) { grid-area: machines; font-size: 13px; }
  .casino-grid.row > div:nth-child(3)::before { content: "Machines : "; color: var(--muted); font-size: 11px; }
  .casino-grid.row > div:nth-child(4) { grid-area: atelier; font-size: 13px; }
  .casino-grid.row > div:nth-child(4)::before { content: "Atelier actif : "; color: var(--muted); font-size: 11px; }
  .casino-grid.row > div:nth-child(5) { grid-area: loans; font-size: 13px; }
  .casino-grid.row > div:nth-child(5)::before { content: "Prêts : "; color: var(--muted); font-size: 11px; }
  .casino-grid.row > div:nth-child(6) {
    grid-area: actions;
    padding-top: 8px; margin-top: 4px;
    border-top: 1px solid var(--line);
  }

  /* Cartes : 1 colonne sur la plupart des conteneurs */
  .modal-grid,
  .form-grid,
  .pickup-dashboard,
  .kpi-panels {
    grid-template-columns: 1fr;
  }

  /* KPI : cartes en 2 colonnes (compact), panels en pile */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .kpi-card { padding: 10px 12px; }
  .kpi-card strong { font-size: 22px; }
  .kpi-card span { font-size: 11px; }

  /* Estimation main d'oeuvre : lignes empilees */
  .kpi-mp-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  /* Balance flux : vertical */
  .kpi-balance {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* Histogrammes : reduire la hauteur et les labels */
  .kpi-columns { height: 150px; gap: 4px; }
  .kpi-col-bars { height: 100px; }
  .kpi-col { width: 12px; }
  .kpi-col-label { font-size: 9px; }

  /* Barres horizontales : reduire la colonne label */
  .bar-row {
    grid-template-columns: 110px 1fr 30px;
    gap: 6px;
  }

  /* Dashboard support : 2 colonnes pour rester compact */
  .support-dashboard {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }
  .support-tile {
    padding: 12px !important;
    text-align: center;
  }
  .support-tile strong { font-size: 22px !important; }
  .support-tile span { font-size: 11px !important; }

  /* Workflow strip : scroll horizontal au lieu de la grille empilee */
  .workflow-strip {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    gap: 8px !important;
    padding-bottom: 8px;
    grid-template-columns: unset !important;
    scrollbar-width: thin;
  }
  .workflow-card {
    flex: 0 0 130px;
    min-width: 130px;
  }

  /* Alerte support sur dossier atelier : carte plein largeur */
  .support-alert-list { padding: 0; }
  .support-alert-card {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .support-alert-card button {
    width: 100%;
    min-height: 44px;
  }

  /* --- Modales plein ecran ------------------------------------------- */
  .modal-card {
    max-width: 100vw;
    width: 100vw;
    border-radius: 0;
    min-height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
  }
  .modal-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
    margin: 0;
  }
  .modal-header h2 { font-size: 18px; margin: 0 0 4px; }
  .modal-header span { font-size: 12px; color: var(--muted); }
  .modal-body { padding: 14px 16px; flex: 1; }
  .modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 10px 12px;
    margin: 0;
    flex-wrap: wrap;
    gap: 6px;
  }
  .modal-footer button {
    flex: 1 1 calc(50% - 6px);
    min-height: 44px;
    font-size: 13px;
  }
  .modal-close {
    width: 44px; height: 44px;
    font-size: 22px;
  }

  /* Toast */
  .toast {
    right: 12px;
    left: 12px;
    bottom: 12px;
    font-size: 13px;
  }

  /* --- Login screen ---------------------------------------------------- */
  .auth-card {
    padding: 24px 20px;
    width: 100%;
    max-width: 100%;
    box-shadow: none;
  }
  .auth-card form input {
    min-height: 44px;
    font-size: 16px; /* evite le zoom auto iOS */
  }
  .auth-card .primary-button {
    min-height: 48px;
    font-size: 15px;
  }
}

/* Tres petit : <= 380px */
@media (max-width: 380px) {
  .auth-card { padding: 22px 16px; }
  .workspace { padding: 60px 8px 20px; }
  .ticket-grid.row,
  .atelier-grid.row,
  .machine-grid.row,
  .loan-grid.row,
  .pickup-grid.row,
  .casino-grid.row {
    padding: 12px !important;
  }
  .support-tile strong { font-size: 18px !important; }
}

/* ============================================================
   ESPACE CRM (Orion CRM)
   Visible UNIQUEMENT pour les emails listes dans
   CAPS_CONFIG.crmAllowedEmails (gere par applyCrmAccess()).
   Cohabite avec Orion : body.crm-mode bascule l'affichage.
   ============================================================ */

:root {
  --crm-accent: #6d4ed7;
  --crm-accent-dark: #4a31a3;
  --crm-accent-soft: #ece6fb;
  --crm-sidebar: #1d2746;
  --crm-sidebar-dark: #151c34;
  --crm-sidebar-active: #2a3a66;
  --crm-page: #f4f1fb;
  --crm-line: #e2dcef;
}

/* Bouton "Ouvrir CRM" dans la topbar Orion (masque si pas autorise) */
.topbar-crm-btn {
  background: transparent;
  color: var(--sidebar);
  border: 1.5px solid var(--crm-accent);
  border-radius: 8px;
  padding: 6px 14px;
  margin-left: auto;
  margin-right: 12px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}
.topbar-crm-btn:hover {
  background: var(--crm-accent);
  color: #fff;
}

/* Par defaut, l'espace CRM est cache ; on l'affiche en plein ecran en
   mode CRM, et on masque alors le shell Orion. */
.crm-shell { display: none; }
body.crm-mode .crm-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}
body.crm-mode .app-shell,
body.crm-mode .mobile-nav-toggle,
body.crm-mode .sidebar-reopen,
body.crm-mode #bridgeBanner {
  display: none !important;
}
body.crm-mode { background: var(--crm-page); }

/* Sidebar CRM */
.crm-sidebar {
  background: var(--crm-sidebar);
  color: #d8d0f3;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.crm-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.crm-brand .crm-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
}
.crm-brand .crm-subbrand {
  font-size: 12px;
  font-weight: 700;
  color: var(--crm-accent);
  letter-spacing: 1.4px;
  text-transform: uppercase;
  background: var(--crm-accent-soft);
  padding: 2px 8px;
  border-radius: 5px;
}
.crm-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.crm-nav-item {
  background: transparent;
  border: 0;
  color: #d8d0f3;
  text-align: left;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.crm-nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.crm-nav-item.active {
  background: var(--crm-sidebar-active);
  color: #fff;
}
.crm-nav-item b {
  background: var(--crm-accent);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
}
.crm-nav-item em {
  font-style: normal;
  font-size: 10.5px;
  color: rgba(216,208,243,0.55);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.crm-nav-item.disabled,
.crm-nav-item[disabled] {
  cursor: default;
  opacity: 0.55;
}
.crm-nav-item.disabled:hover { background: transparent; }
.crm-back-btn {
  background: transparent;
  color: #d8d0f3;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.crm-back-btn:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}

/* Workspace CRM */
.crm-workspace {
  display: flex;
  flex-direction: column;
  background: var(--crm-page);
  min-height: 100vh;
}
.crm-topbar {
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--crm-line);
  padding: 14px 28px;
  gap: 16px;
}
.crm-topbar-context {
  font-size: 14px;
  font-weight: 700;
  color: var(--crm-sidebar-dark);
  letter-spacing: 0.3px;
}
.crm-topbar-context .crm-context-sep { color: var(--muted); margin: 0 6px; font-weight: 400; }
.crm-topbar-spacer { flex: 1; }
.crm-user-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 12px;
  color: var(--muted);
}
.crm-user-pill strong { color: var(--crm-accent-dark); font-size: 13px; }

/* Vues CRM */
.crm-view {
  display: none;
  padding: 24px 28px 40px;
}
.crm-view.active { display: block; }

.crm-page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}
.crm-page-title h1 {
  margin: 4px 0 0;
  font-size: 22px;
  color: var(--crm-sidebar-dark);
}
.crm-page-title .crm-breadcrumb {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.crm-title-actions { display: flex; gap: 8px; }

.crm-btn {
  background: var(--crm-accent);
  color: #fff;
  border: 0;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
}
.crm-btn:hover { background: var(--crm-accent-dark); }
.crm-btn.secondary {
  background: #fff;
  color: var(--crm-accent-dark);
  border: 1px solid var(--crm-line);
}
.crm-btn.secondary:hover {
  background: var(--crm-accent-soft);
}
.crm-btn.ghost {
  background: transparent;
  color: var(--crm-accent-dark);
  border: 1px solid transparent;
  padding: 6px 10px;
  font-size: 12px;
}
.crm-btn.ghost:hover {
  border-color: var(--crm-line);
  background: #fff;
}

/* KPI dashboard */
.crm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.crm-kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  border: 1px solid var(--crm-line);
  box-shadow: 0 2px 8px rgba(50, 30, 100, 0.04);
}
.crm-kpi-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-bottom: 6px;
}
.crm-kpi-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--crm-sidebar-dark);
}
.crm-kpi-card .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.crm-kpi-card.accent {
  border-color: var(--crm-accent);
}
.crm-kpi-card.hot {
  border-color: #ef4444;
}
.crm-kpi-card.hot .label,
.crm-kpi-card.hot .value {
  color: #991b1b;
}

/* CRM dashboard cockpit */
.crm-dash-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.8fr);
  gap: 18px;
  margin-bottom: 18px;
}
.crm-dash-hero-main,
.crm-dash-hero-side {
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 2px 8px rgba(50, 30, 100, 0.04);
}
.crm-dash-hero-main {
  border-left: 5px solid var(--crm-accent);
}
.crm-dash-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--crm-accent-dark);
  font-weight: 800;
  margin-bottom: 6px;
}
.crm-dash-hero h2 {
  margin: 0;
  color: var(--crm-sidebar-dark);
  font-size: 26px;
  line-height: 1.15;
}
.crm-dash-hero p {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 13px;
}
.crm-dash-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.crm-dash-action-card,
.crm-dash-action-empty {
  border: 1px solid var(--crm-line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
}
.crm-dash-action-card {
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.crm-dash-action-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(50, 30, 100, 0.09);
}
.crm-dash-action-card strong {
  display: block;
  font-size: 24px;
  color: var(--crm-sidebar-dark);
}
.crm-dash-action-card span,
.crm-dash-action-empty strong {
  display: block;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
.crm-dash-action-card small,
.crm-dash-action-empty span {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}
.crm-dash-action-card.danger { border-color: var(--red); }
.crm-dash-action-card.danger strong { color: var(--red); }
.crm-dash-action-card.warn { border-color: var(--orange); }
.crm-dash-action-card.warn strong { color: var(--orange); }
.crm-dash-action-card.hot { border-color: #ef4444; }
.crm-dash-action-card.hot strong { color: #991b1b; }
.crm-dash-big-number {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.crm-dash-big-number span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  font-weight: 700;
}
.crm-dash-big-number strong {
  font-size: 34px;
  color: var(--crm-accent-dark);
  line-height: 1.1;
  margin: 8px 0;
}
.crm-dash-big-number small {
  color: var(--muted);
  font-size: 12px;
}
.crm-dashboard-main-kpis {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}
.crm-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.crm-dash-bars {
  display: grid;
  gap: 10px;
}
.crm-dash-bar-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
}
.crm-dash-bar-row > div:first-child {
  color: var(--muted);
  font-weight: 700;
}
.crm-dash-bar-row strong {
  text-align: right;
  color: var(--crm-sidebar-dark);
}
.crm-dash-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--crm-page);
  overflow: hidden;
}
.crm-dash-bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--crm-accent);
}
.crm-dash-temp-chart {
  height: 180px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  padding-top: 10px;
}
.crm-dash-temp {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.crm-dash-temp-fill {
  width: 44px;
  border-radius: 10px 10px 3px 3px;
  min-height: 8px;
  box-shadow: inset 0 -8px 16px rgba(0, 0, 0, 0.08);
}
.crm-dash-temp strong {
  color: var(--crm-sidebar-dark);
  font-size: 15px;
}
.crm-dash-list {
  display: grid;
  gap: 8px;
}
.crm-dash-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--crm-line);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.crm-dash-list-item:hover {
  background: var(--crm-page);
  border-color: var(--crm-accent);
}
.crm-dash-list-item strong,
.crm-dash-list-item b {
  display: block;
  color: var(--crm-sidebar-dark);
  font-size: 13px;
}
.crm-dash-list-item span {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}
.crm-dash-list-item > div:last-child {
  text-align: right;
}

.crm-install-planned-machines {
  display: grid;
  gap: 8px;
}
.crm-install-planned-row {
  display: grid;
  grid-template-columns: 0.8fr 1.4fr 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--crm-line);
  border-radius: 9px;
  background: #fff;
}

@media (max-width: 1100px) {
  .crm-dash-hero,
  .crm-dashboard-grid,
  .crm-tools-grid {
    grid-template-columns: 1fr;
  }
  .crm-dashboard-main-kpis {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 720px) {
  .crm-dash-hero-main,
  .crm-dash-hero-side {
    padding: 16px;
  }
  .crm-dash-hero h2 {
    font-size: 21px;
  }
  .crm-dashboard-main-kpis {
    grid-template-columns: 1fr;
  }
  .crm-tool-inputs,
  .crm-tool-results,
  .crm-tool-result-grid {
    grid-template-columns: 1fr;
  }
  .crm-dash-actions {
    grid-template-columns: 1fr;
  }
  .crm-dash-bar-row {
    grid-template-columns: 78px minmax(0, 1fr) 28px;
  }
  .crm-dash-temp-chart {
    height: 150px;
    gap: 8px;
  }
  .crm-dash-temp-fill {
    width: 34px;
  }
  .crm-dash-list-item {
    grid-template-columns: 1fr;
  }
  .crm-dash-list-item > div:last-child {
    text-align: left;
  }
  .crm-install-planned-row {
    grid-template-columns: 1fr;
  }
}

/* Section / cartes */
.crm-section {
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.crm-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.crm-section-head h2 {
  margin: 0;
  font-size: 15px;
  color: var(--crm-sidebar-dark);
}
.crm-section-head .crm-search {
  flex: 1;
  max-width: 320px;
  padding: 7px 12px;
  border: 1px solid var(--crm-line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--crm-page);
}

/* Tableau groupes */
.crm-table {
  display: grid;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--crm-line);
}
.crm-table-head, .crm-table-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 0.8fr 0.8fr 1fr 0.6fr;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
}
.crm-table-head {
  background: var(--crm-accent-soft);
  color: var(--crm-accent-dark);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.crm-table-row {
  background: #fff;
  border-top: 1px solid var(--crm-line);
}
.crm-table-row:hover { background: var(--crm-accent-soft); cursor: pointer; }
.crm-table-row .muted { color: var(--muted); }
.crm-table-row strong { color: var(--crm-sidebar-dark); font-weight: 600; }
.crm-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Fiche detail (groupe / casino) */
.crm-detail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 2fr;
  gap: 18px;
  align-items: start;
}
.crm-detail-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.crm-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.crm-form-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 700;
}
.crm-form-field input,
.crm-form-field textarea,
.crm-form-field select {
  padding: 8px 11px;
  border: 1px solid var(--crm-line);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
.crm-form-field textarea { resize: vertical; min-height: 70px; }

.crm-mini-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}
.crm-mini-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  background: var(--crm-page);
  border-radius: 6px;
  font-size: 12.5px;
  border: 1px solid transparent;
}
.crm-mini-list-item:hover { border-color: var(--crm-line); cursor: pointer; }
.crm-mini-list-item .muted { color: var(--muted); font-size: 11px; }

/* CRM outils commerciaux */
.crm-tools-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.8fr);
  gap: 16px;
  align-items: start;
}
.crm-tool-group {
  margin-bottom: 18px;
}
.crm-tool-card {
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(50, 30, 100, 0.04);
}
.crm-tool-card .crm-section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.crm-tool-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.crm-tool-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.crm-tool-results.single {
  grid-template-columns: 1fr;
}
.crm-tool-result {
  border: 1px solid var(--crm-line);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
}
.crm-tool-result.muted {
  min-height: 138px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  color: var(--muted);
  background: var(--crm-page);
}
.crm-tool-result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}
.crm-tool-result-head strong {
  color: var(--crm-sidebar-dark);
  font-size: 15px;
}
.crm-tool-result-head span {
  color: var(--crm-accent-dark);
  font-weight: 800;
}
.crm-tool-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.crm-tool-result-grid div {
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--crm-page);
}
.crm-tool-result-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  margin-bottom: 4px;
}
.crm-tool-result-grid strong {
  color: var(--crm-sidebar-dark);
  font-size: 15px;
}
.crm-tool-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--crm-accent-soft);
  color: var(--crm-sidebar-dark);
  font-size: 12.5px;
  line-height: 1.55;
}
.crm-tool-placeholder .crm-mini-list {
  gap: 8px;
}
.crm-tool-table {
  display: grid;
  border: 1px solid var(--crm-line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.crm-tool-table-head,
.crm-tool-table-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 1fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  font-size: 12.5px;
}
.crm-tool-table-head {
  background: var(--crm-accent-soft);
  color: var(--crm-accent-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.45px;
}
.crm-tool-table-row {
  border-top: 1px solid var(--crm-line);
}
.crm-tool-table-row:hover {
  background: var(--crm-page);
}
.crm-tool-table-row strong {
  color: var(--crm-sidebar-dark);
}

/* Import devis Sage (PDF) : zone de depot */
.crm-sage-dropzone {
  border: 2px dashed var(--crm-accent);
  border-radius: 10px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--crm-accent-dark);
  background: var(--crm-accent-soft);
  transition: background 0.15s, border-color 0.15s;
}
.crm-sage-dropzone:hover,
.crm-sage-dropzone.dragover {
  background: #ddd2f7;
  border-color: var(--crm-accent-dark);
}

/* Import devis Sage : etape de rapprochement produits */
.crm-sage-client {
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.crm-sage-client-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--crm-sidebar-dark);
}
.crm-sage-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
}
.crm-sage-line {
  background: var(--crm-page);
  border: 1px solid var(--crm-line);
  border-radius: 8px;
  padding: 12px 14px;
}
.crm-sage-line-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.crm-sage-line-choice {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--crm-line);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
}
.crm-sage-badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.crm-sage-badge.ok    { background: #dff5e6; color: #1e7038; }
.crm-sage-badge.maybe { background: #e0efff; color: #1c5798; }
.crm-sage-badge.new   { background: #fff1d6; color: #9b6311; }
.crm-sage-badge.aux   { background: #e9eef4; color: #5a6b80; }
.crm-sage-create-fields {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr 0.8fr;
  gap: 8px;
  margin-top: 8px;
}
.crm-sage-create-fields label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 700;
}
.crm-sage-create-fields input {
  padding: 6px 9px;
  border: 1px solid var(--crm-line);
  border-radius: 6px;
  font-size: 12.5px;
  background: #fff;
}
@media (max-width: 760px) {
  .crm-sage-create-fields { grid-template-columns: 1fr 1fr; }
}

/* Agenda (Phase 8) : cartes tâches */
.crm-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.crm-task-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: 8px;
  padding: 10px 12px;
  transition: box-shadow 0.15s;
}
.crm-task-card:hover {
  box-shadow: 0 2px 8px rgba(50, 30, 100, 0.06);
}

/* Commissions (Phase 7) : tableau trimestriel + total */
.crm-commissions-table .crm-table-head,
.crm-commissions-table .crm-table-row {
  grid-template-columns: 1fr 1fr 1fr 1.1fr 1.1fr 1.1fr 0.9fr;
}
.crm-commission-row.current-quarter {
  background: var(--crm-accent-soft);
}
.crm-commission-totals {
  background: var(--crm-page);
  border-top: 2px solid var(--crm-line);
  font-weight: 600;
}
.crm-commission-totals strong { color: var(--crm-sidebar-dark); }

/* Installations (Phase 6) : cartes commandes + planning */
.crm-orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.crm-order-card {
  background: #fff;
  border: 1px solid var(--crm-line);
  border-radius: 10px;
  padding: 12px 14px;
  border-left: 3px solid var(--orange);
}
.crm-installs-table .crm-table-head,
.crm-installs-table .crm-table-row {
  grid-template-columns: 0.9fr 1.6fr 1fr 0.7fr 0.9fr 0.9fr;
}

/* Contrats (Phase 5) : tableau 7 colonnes + cartes alertes */
.crm-contracts-table .crm-table-head,
.crm-contracts-table .crm-table-row {
  grid-template-columns: 1.6fr 1fr 0.9fr 1.1fr 0.9fr 0.8fr 0.7fr;
}
.crm-contract-alerts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.crm-contract-alert {
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(50, 30, 100, 0.04);
  transition: box-shadow 0.15s;
}
.crm-contract-alert:hover {
  box-shadow: 0 4px 12px rgba(50, 30, 100, 0.1);
}

/* Tarifs négociés (Phase 4) : table 5 colonnes + liste casinos du tier */
.crm-pricing-table .crm-table-head,
.crm-pricing-table .crm-table-row {
  grid-template-columns: 1.4fr 0.9fr 1.2fr 1.4fr 1fr;
}
.crm-tier-casinos-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 420px;
  overflow-y: auto;
}
.crm-tier-casino-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--crm-page);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
}
.crm-tier-casino-row:hover { border-color: var(--crm-line); }
.crm-tier-casino-row.active {
  background: var(--crm-accent-soft);
  border-color: var(--crm-accent);
}
.crm-tier-casino-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--crm-accent);
}

/* Pipeline devis : kanban 5 colonnes + cartes deal + lignes form */
.crm-deal-kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.crm-deal-column {
  display: flex;
  flex-direction: column;
  background: var(--crm-page);
  border-radius: 10px;
  border: 1px solid var(--crm-line);
  min-height: 280px;
}
.crm-deal-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px 10px 0 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.crm-deal-column-count {
  background: rgba(255, 255, 255, 0.6);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
}
.crm-deal-column-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  flex: 1;
  overflow-y: auto;
  max-height: 70vh;
}
.crm-deal-column-empty {
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  padding: 20px 6px;
  font-style: italic;
}
.crm-deal-card {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(50, 30, 100, 0.05);
  transition: box-shadow 0.15s, transform 0.1s;
}
.crm-deal-card:hover {
  box-shadow: 0 4px 12px rgba(50, 30, 100, 0.1);
  transform: translateY(-1px);
}
.crm-deal-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.crm-deal-card header strong {
  font-size: 12px;
  color: var(--crm-sidebar-dark);
  letter-spacing: 0.3px;
}
.crm-deal-age {
  font-size: 10.5px;
  background: var(--crm-page);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 5px;
}
.crm-deal-temperature {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  white-space: nowrap;
}
.crm-deal-temperature.small {
  padding: 2px 7px;
  font-size: 10.5px;
}
.crm-deal-card-casino {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}
.crm-deal-card-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.crm-deal-card-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 700;
  color: var(--crm-sidebar-dark);
}
.crm-deal-card-marge {
  font-size: 11px;
  font-weight: 500;
  color: var(--green);
}
.crm-deal-card-commission {
  margin-top: 6px;
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--crm-accent-soft);
  color: var(--crm-accent-dark);
  font-size: 11px;
  font-weight: 700;
}
.crm-deal-card-foot {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
}
.crm-deal-mini-warn {
  color: var(--red);
  font-weight: 600;
}

/* Tableau lignes du devis dans la fiche detail (6 colonnes) */
.crm-deal-detail-table .crm-table-head,
.crm-deal-detail-table .crm-table-row {
  grid-template-columns: 2fr 0.6fr 1fr 1.2fr 1fr 1fr;
}

/* Lignes du formulaire devis (modal) */
.crm-deal-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.crm-deal-line {
  display: grid;
  grid-template-columns: 2fr 0.7fr 1.2fr 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  background: var(--crm-page);
  border-radius: 8px;
  border: 1px solid transparent;
}
.crm-deal-line.warn {
  border-color: var(--red);
  background: #fff1f0;
}
.crm-deal-line.reference-valid [data-line-field="productCode"]{border-color:#258044;background:#f1faf4}
.crm-deal-line.reference-invalid [data-line-field="productCode"]{border-color:#bf3939;background:#fff3f3}
.crm-reference-status{display:block;min-height:1.2em;font-size:11px;margin-top:3px}
.reference-valid .crm-reference-status{color:#216b3a}
.reference-invalid .crm-reference-status{color:#a12c2c}
.crm-deal-line .crm-line-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-deal-line button[data-line-action="remove"] {
  font-size: 18px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--crm-line);
}
.crm-deal-line button[data-line-action="remove"]:hover {
  background: #fff1f0;
  border-color: var(--red);
}
.crm-deal-totals {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 24px;
  padding: 14px 16px;
  background: var(--crm-accent-soft);
  border-radius: 8px;
  margin-top: 10px;
}

/* Catalogue produits : tableau 9 colonnes (code/nom/famille/prix x3/coeff/marge/actions) */
.crm-catalog-table .crm-table-head,
.crm-catalog-table .crm-table-row {
  grid-template-columns: 0.95fr 1.65fr 0.9fr 0.9fr 0.95fr 0.9fr 0.7fr 0.85fr 0.85fr;
}
.crm-catalog-row code {
  background: var(--crm-page);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
}

/* Formulaire produit dans la modal (catalog + autres CRM forms) */
.crm-modal-form {
  padding: 24px 26px 22px;
}
.crm-modal-form h2 {
  font-family: inherit;
}
.crm-modal-form input,
.crm-modal-form textarea,
.crm-modal-form select {
  padding: 8px 11px;
  border: 1px solid var(--crm-line);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  width: 100%;
}
.crm-modal-form textarea { resize: vertical; min-height: 70px; }
.crm-modal-form input:focus,
.crm-modal-form textarea:focus,
.crm-modal-form select:focus {
  outline: none;
  border-color: var(--crm-accent);
  box-shadow: 0 0 0 3px rgba(109, 78, 215, 0.15);
}

/* Mobile : CRM en pleine largeur, sidebar collapse en topbar minimaliste */
@media (max-width: 760px) {
  body.crm-mode .crm-shell {
    grid-template-columns: 1fr;
  }
  .crm-sidebar {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px 12px;
    gap: 6px;
    position: sticky; top: 0; z-index: 4;
  }
  .crm-brand { border: 0; padding: 4px 6px 4px 0; flex-shrink: 0; }
  .crm-nav { flex-direction: row; flex: 1; overflow-x: auto; }
  .crm-nav-item { white-space: nowrap; padding: 6px 10px; font-size: 12px; }
  .crm-nav-item b, .crm-nav-item em { display: none; }
  .crm-back-btn { flex-shrink: 0; padding: 6px 10px; font-size: 11px; }
  .crm-view { padding: 16px 14px 32px; }
  .crm-detail-grid { grid-template-columns: 1fr; }
  .crm-table-head, .crm-table-row {
    grid-template-columns: 1.4fr 0.8fr 0.6fr;
    font-size: 12.5px;
  }
  .crm-table-head > div:nth-child(n+4),
  .crm-table-row > div:nth-child(n+4) { display: none; }
  /* Catalogue : on garde code / nom / marge en mobile */
  .crm-catalog-table .crm-table-head,
  .crm-catalog-table .crm-table-row {
    grid-template-columns: 1fr 1.5fr 0.9fr;
  }
  .crm-catalog-table .crm-table-head > div:nth-child(3),
  .crm-catalog-table .crm-table-row > div:nth-child(3) { display: none; }
  .crm-catalog-table .crm-table-head > div:nth-child(8),
  .crm-catalog-table .crm-table-row > div:nth-child(8) { display: block; text-align: right; }
  .crm-modal-form { padding: 18px 16px 16px; }
  .crm-modal-form > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  /* Kanban devis : scroll horizontal sur mobile */
  .crm-deal-kanban {
    grid-template-columns: repeat(5, 230px);
    gap: 8px;
  }
  .crm-deal-column-body {
    max-height: 60vh;
  }
  /* Lignes devis : 2 colonnes par ligne */
  .crm-deal-line {
    grid-template-columns: 1fr 1fr;
  }
  .crm-deal-line > .crm-form-field:first-child {
    grid-column: 1 / -1;
  }
  .crm-deal-line button[data-line-action="remove"] {
    grid-column: 1 / -1;
    justify-self: end;
  }
  /* Detail table devis : on cache les colonnes secondaires */
  .crm-deal-detail-table .crm-table-head,
  .crm-deal-detail-table .crm-table-row {
    grid-template-columns: 1.6fr 0.5fr 1fr 1fr;
  }
  .crm-deal-detail-table .crm-table-head > div:nth-child(4),
  .crm-deal-detail-table .crm-table-row > div:nth-child(4) { display: none; }
  .crm-deal-totals {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  /* Pricing : 3 colonnes max sur mobile (produit / prix / actions) */
  .crm-pricing-table .crm-table-head,
  .crm-pricing-table .crm-table-row {
    grid-template-columns: 1.4fr 0.9fr 0.8fr;
  }
  .crm-pricing-table .crm-table-head > div:nth-child(3),
  .crm-pricing-table .crm-table-row > div:nth-child(3),
  .crm-pricing-table .crm-table-head > div:nth-child(4),
  .crm-pricing-table .crm-table-row > div:nth-child(4) { display: none; }
  /* Contrats : 4 colonnes max sur mobile (casino / fin / statut / actions) */
  .crm-contracts-table .crm-table-head,
  .crm-contracts-table .crm-table-row {
    grid-template-columns: 1.4fr 1fr 0.7fr 0.7fr;
  }
  .crm-contracts-table .crm-table-head > div:nth-child(2),
  .crm-contracts-table .crm-table-row > div:nth-child(2),
  .crm-contracts-table .crm-table-head > div:nth-child(3),
  .crm-contracts-table .crm-table-row > div:nth-child(3),
  .crm-contracts-table .crm-table-head > div:nth-child(5),
  .crm-contracts-table .crm-table-row > div:nth-child(5) { display: none; }
  /* Installations : 4 colonnes max sur mobile (date / casino / statut / actions) */
  .crm-installs-table .crm-table-head,
  .crm-installs-table .crm-table-row {
    grid-template-columns: 0.9fr 1.5fr 0.8fr 0.8fr;
  }
  .crm-installs-table .crm-table-head > div:nth-child(3),
  .crm-installs-table .crm-table-row > div:nth-child(3),
  .crm-installs-table .crm-table-head > div:nth-child(4),
  .crm-installs-table .crm-table-row > div:nth-child(4) { display: none; }
  /* Commissions : 4 colonnes max sur mobile (trim / marge / théorique / actions) */
  .crm-commissions-table .crm-table-head,
  .crm-commissions-table .crm-table-row {
    grid-template-columns: 0.8fr 1.1fr 1.1fr 0.9fr;
  }
  .crm-commissions-table .crm-table-head > div:nth-child(2),
  .crm-commissions-table .crm-table-row > div:nth-child(2),
  .crm-commissions-table .crm-table-head > div:nth-child(5),
  .crm-commissions-table .crm-table-row > div:nth-child(5),
  .crm-commissions-table .crm-table-head > div:nth-child(6),
  .crm-commissions-table .crm-table-row > div:nth-child(6) { display: none; }
  /* Tasks : empilement vertical du titre + actions sur mobile */
  .crm-task-card {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Inventaire groupe (préparation RDV) : tableau + pastilles types */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.inv-table th,
.inv-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.inv-table th {
  background: var(--page);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
}
.inv-table tbody tr:hover { background: var(--soft-blue); }
.inv-type-pill {
  display: inline-block;
  background: var(--soft-blue);
  color: var(--blue-dark);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12.5px;
  margin: 0 4px 6px 0;
}

/* Préparation des machines neuves --------------------------------------- */
.prep-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.prep-summary-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-left: 4px solid #8797a8;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.prep-summary-card strong { font-size: 25px; color: var(--blue-dark); }
.prep-summary-card span { color: var(--muted); font-size: 13px; }
.prep-summary-card.warning { border-left-color: var(--orange); }
.prep-summary-card.info { border-left-color: var(--blue); }
.prep-summary-card.success { border-left-color: var(--green); }
.prep-toolbar { grid-template-columns: minmax(240px, 1fr) 230px 210px auto; align-items: center; }
.prep-my-tasks { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 13px; }
.prep-my-tasks input { width: auto; }
.prep-grid { grid-template-columns: 1.4fr 1fr 1fr 1.2fr .8fr .7fr; }
.prep-customer-group { margin: 0 0 14px; border: 1px solid #dbe5ef; border-radius: 12px; overflow: hidden; }
.prep-customer-header { display: flex; align-items: stretch; gap: 10px; padding: 8px; background: #f3f8fc; }
.prep-customer-summary { display: flex; flex: 1; width: 100%; justify-content: space-between; gap: 12px; align-items: center; padding: 4px 6px; border: 0; background: transparent; color: #153e68; text-align: left; cursor: pointer; }
.prep-delete-group { align-self: center; white-space: nowrap; padding: 8px 11px; font-size: 12px; }
.prep-customer-summary span { display: grid; gap: 3px; }
.prep-customer-summary small { color: #667085; font-size: 12px; }
.prep-customer-summary b { font-size: 12px; color: #2167a6; white-space: nowrap; }
.prep-customer-details { border-top: 1px solid #dbe5ef; }
.prep-grid.row > div { min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center; }
.prep-grid.row small { color: var(--muted); margin-top: 3px; }
.prep-grid.row.prep-mine { background: #f3f9ff; box-shadow: inset 4px 0 var(--blue); }
.prep-grid.row .row-actions { flex-direction: row; }
.prep-timeline {
  display: grid;
  grid-template-columns: repeat(8, minmax(90px, 1fr));
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 22px;
}
.prep-step { min-width: 90px; padding: 9px; border-top: 4px solid #d8e0e8; background: #f5f7f9; font-size: 11px; }
.prep-step b { display: block; }
.prep-step small { display: block; color: var(--muted); margin-top: 4px; }
.prep-step.done { border-top-color: var(--green); background: #effaf4; }
.prep-step.active { border-top-color: var(--blue); background: var(--soft-blue); }
.prep-tests { border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.prep-tests > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.prep-tests .checkline { display: inline-flex; margin: 4px 18px 4px 0; }
.prep-control-warning { margin-top: 16px; padding: 12px 14px; background: #fff5e6; border-left: 4px solid var(--orange); }

@media (max-width: 1100px) {
  .prep-toolbar { grid-template-columns: 1fr 1fr; }
  .prep-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .prep-summary, .prep-toolbar { grid-template-columns: 1fr; }
  .prep-grid.table-head { display: none; }
  .prep-grid.row { display: grid; grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
  .prep-grid.row > div { min-height: 40px; }
  .prep-grid.row .row-actions { grid-column: 1 / -1; }
}
/* Centre de suivi opérationnel et Sage */
.operations-intro{margin:5px 0 0;color:var(--muted);font-size:13px}.operations-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-bottom:14px}.operations-tabs{display:flex;gap:4px;padding:10px 12px;border-bottom:1px solid var(--line)}.operations-tabs button{border:0;background:transparent;border-radius:7px;padding:9px 18px;font-weight:700;color:var(--muted);cursor:pointer}.operations-tabs button.active{background:#e7f1fb;color:#185c97}.operations-toolbar{grid-template-columns:minmax(260px,1fr) 220px}.operations-group{margin:14px;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:#fff}.operations-group-title{display:flex;align-items:center;justify-content:space-between;padding:10px 14px;background:#f6f8fb;border-bottom:1px solid var(--line)}.operations-group-title h2{margin:0;font-size:14px;color:#243b55}.operations-group-title span{display:grid;place-items:center;min-width:25px;height:25px;padding:0 7px;border-radius:999px;background:#e7edf4;font-size:12px;font-weight:800}.operations-group.danger .operations-group-title{background:#fff3f1;color:#9a302a}.operations-group.today .operations-group-title{background:#fff9ea;color:#8a5a0c}.operations-followup-row,.operations-sage-row{display:grid;align-items:center;gap:14px;padding:11px 14px;border-top:1px solid #edf0f4}.operations-group-title+.operations-followup-row,.operations-group-title+.operations-sage-row{border-top:0}.operations-followup-row{grid-template-columns:minmax(300px,1fr) 210px 90px}.operations-sage-row{grid-template-columns:minmax(240px,2fr) 185px 170px minmax(220px,1fr)}.operations-followup-main small,.operations-sage-row small{display:flex;gap:7px;color:var(--muted);margin-top:4px}.operations-followup-date{display:flex;align-items:center;justify-content:flex-end;gap:9px}.operations-followup-row.overdue{box-shadow:inset 4px 0 #d94d42}.operations-followup-row.today{box-shadow:inset 4px 0 #e5a029}.operations-priority,.operations-sage-state{display:inline-flex;padding:4px 8px;border-radius:999px;font-size:11px;font-weight:800;text-transform:capitalize;background:#edf2f7;color:#536578}.operations-priority.urgente,.operations-sage-state.failed{background:#ffe1de;color:#9a302a}.operations-priority.haute,.operations-sage-state.pending{background:#fff1d6;color:#9b6311}.operations-sage-state.generated{background:#e0efff;color:#1c5798}.operations-sage-state.imported{background:#dff5e6;color:#1e7038}.operations-sage-row .row-actions{display:flex;justify-content:flex-end;gap:7px;flex-wrap:wrap}.operations-all-clear{display:flex;flex-direction:column;gap:5px;padding:26px}.operations-sage-history{margin:14px;border:1px solid var(--line);border-radius:10px;overflow:hidden}.operations-sage-history summary{padding:12px 14px;cursor:pointer;font-weight:700;color:var(--muted);background:#f8fafc}.operations-sage-history .operations-sage-row{opacity:.82}@media(max-width:900px){.operations-summary{grid-template-columns:repeat(2,minmax(0,1fr))}.operations-toolbar,.operations-followup-row,.operations-sage-row{grid-template-columns:1fr}.operations-followup-date{justify-content:flex-start}.operations-followup-row .row-actions,.operations-sage-row .row-actions{justify-content:flex-start}}

/* Accueil de travail épuré de Pierre et Alexis. */
.daily-work-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;margin-bottom:24px}
.daily-work-actions[hidden],.daily-request-panel[hidden],.daily-notification-filters[hidden]{display:none}
.daily-work-actions>button{display:grid;justify-items:start;gap:10px;min-height:165px;padding:24px;border:1px solid #dce5ee;border-radius:14px;background:#fff;color:#243b55;text-align:left;cursor:pointer}
.daily-work-actions>button:hover,.daily-work-actions>button:focus-visible{border-color:#2372b8;background:#f8fbff;box-shadow:0 4px 14px #1e3d5b0a}
.daily-work-actions strong{font-size:20px}.daily-work-actions small{color:var(--muted);font-size:13px}.daily-work-icon{font-size:26px;color:#2167a6;line-height:1}
#dashboardView.daily-simple .daily-summary,#dashboardView.daily-simple .daily-dashboard-side,#dashboardView.daily-simple #dailyDashboardSubtitle,#dashboardView.daily-simple .daily-card-heading>div>span{display:none}
#dashboardView.daily-simple .daily-dashboard-layout{display:block}
#dashboardView.daily-simple .daily-card-heading{background:#fff;padding:20px 22px;border-bottom:0}
.daily-request-panel{padding:22px;margin-bottom:24px;border:1px solid var(--line);border-radius:14px;background:#fff}.daily-request-panel header{display:flex;justify-content:space-between;align-items:center;gap:12px}.daily-request-panel h2{margin:0;font-size:18px}.daily-request-panel p{color:var(--muted);font-size:13px}.daily-request-choices{display:flex;flex-wrap:wrap;gap:10px}
.daily-request-panel button,.daily-notification-actions button,.daily-notification-filters button,.daily-notification-more{padding:8px 12px;border:1px solid #d4dfeb;border-radius:8px;background:#fff;color:#2167a6;font-weight:600;cursor:pointer}
.daily-request-panel button:hover,.daily-notification-actions button:hover,.daily-notification-more:hover{background:#eef6fd}
.daily-notification-filters{display:flex;gap:7px;padding:0 22px 14px}.daily-notification-filters button{border-color:transparent;color:var(--muted)}.daily-notification-filters button[aria-pressed=true]{color:#2167a6;background:#edf5fd}
.daily-notification{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:16px 22px;border-top:1px solid #edf0f4}.daily-notification.is-urgent{box-shadow:inset 3px 0 #d94d42}.daily-notification-text{display:grid;gap:4px;min-width:0}.daily-notification-text strong{font-size:14px;color:#243b55;overflow-wrap:anywhere}.daily-notification-text span,.daily-notification-text small{font-size:12px;color:var(--muted)}.daily-notification.is-urgent small{color:#b9362d}.daily-notification-actions{display:flex;gap:8px;flex-shrink:0}.daily-notification-actions button:first-child{background:#edf5fd;border-color:transparent}.daily-notification-more{display:block;margin:16px auto}
@media(max-width:760px){.daily-work-actions{gap:10px;grid-template-columns:1fr}.daily-work-actions>button{min-height:100px;padding:16px;grid-template-columns:32px 1fr;gap:6px 12px}.daily-work-icon{grid-row:1/3}.daily-work-actions strong{font-size:18px}.daily-notification{align-items:flex-start;flex-direction:column;gap:12px}.daily-notification-actions{align-self:flex-end}}

/* Les trois actions à gauche, une liste paginée compacte à droite. */
#dashboardView.daily-simple{display:none;grid-template-columns:minmax(260px,.9fr) minmax(360px,1.1fr);gap:20px;align-items:start}
#dashboardView.daily-simple.active{display:grid}
#dashboardView.daily-simple>.daily-dashboard-title{grid-column:1/-1;margin-bottom:0}
#dashboardView.daily-simple>.daily-work-actions{grid-column:1;grid-row:2;grid-template-columns:1fr;gap:14px;margin:0}
#dashboardView.daily-simple .daily-work-actions>button{min-height:128px;grid-template-columns:36px 1fr;align-content:center;gap:8px 16px;padding:22px}
#dashboardView.daily-simple .daily-work-icon{grid-row:1/3;align-self:center;font-size:30px}
#dashboardView.daily-simple>.daily-dashboard-layout{grid-column:2;grid-row:2;min-width:0}
#dashboardView.daily-simple>.daily-request-panel,#dashboardView.daily-simple>.dossier-workspace{grid-column:1/-1;margin:0}
#dashboardView.daily-simple .daily-card-heading{padding:16px 18px 12px}
#dashboardView.daily-simple .daily-notification-filters{padding:0 18px 10px}
#dashboardView.daily-simple .daily-notification{padding:12px 18px;gap:10px;min-height:88px}
#dashboardView.daily-simple .daily-notification-text strong{font-size:13px}
#dashboardView.daily-simple .daily-notification-text span{font-size:11px}
#dashboardView.daily-simple .daily-notification-actions{gap:5px}
#dashboardView.daily-simple .daily-notification-actions button{padding:7px 9px;font-size:12px}
.daily-notification-pagination{display:flex;align-items:center;justify-content:center;gap:16px;padding:12px;border-top:1px solid #edf0f4;color:var(--muted);font-size:12px}
.daily-notification-pagination button{border:1px solid #d4dfeb;border-radius:7px;background:#fff;color:#2167a6;padding:6px 12px;cursor:pointer}.daily-notification-pagination button:disabled{opacity:.35;cursor:default}
@media(max-width:1000px){#dashboardView.daily-simple{grid-template-columns:1fr}#dashboardView.daily-simple>.daily-dashboard-layout{grid-column:1;grid-row:3}#dashboardView.daily-simple .daily-work-actions>button{min-height:100px}#dashboardView.daily-simple .daily-notification{flex-direction:row;align-items:center}}

.daily-notification-block>header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:9px 16px;background:#f6f9fc;border-top:1px solid #e5edf4}.daily-notification-block h3{margin:0;font-size:13px;color:#31506f}.daily-notification-block>header>span{font-size:11px;color:var(--muted)}
#dashboardView.daily-simple .daily-notification-block .daily-notification{min-height:64px;padding:9px 16px}
#dashboardView.daily-simple .daily-notification-block .daily-notification-text>small{display:none}
.daily-notification-block .daily-notification-pagination{padding:5px;gap:12px;font-size:11px}.daily-notification-block .daily-notification-pagination button{padding:3px 10px}
.daily-block-empty{margin:0;padding:12px 16px;color:var(--muted);font-size:12px}

/* Bureau de travail CRM : les autres vues restent des pages de consultation. */
.crm-work-layout{display:grid;grid-template-columns:minmax(260px,.9fr) minmax(360px,1.1fr);gap:22px;align-items:start}
.crm-work-buttons{display:grid;gap:14px}.crm-work-buttons>button{display:grid;grid-template-columns:30px 1fr;gap:7px 14px;align-content:center;min-height:120px;padding:22px;border:1px solid #dedeea;border-radius:13px;background:#fff;text-align:left;cursor:pointer;color:#283950}.crm-work-buttons>button:hover{border-color:var(--crm-accent);background:#fcfbff}.crm-work-buttons>button>b{grid-row:1/3;align-self:center;color:var(--crm-accent);font-size:28px;font-weight:400}.crm-work-buttons strong{font-size:18px}.crm-work-buttons small{color:var(--muted);font-size:12px}
.crm-work-block{border:1px solid #e1e5ee;border-radius:10px;background:#fff;overflow:hidden;margin-bottom:12px}.crm-work-block>header{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:11px 16px;background:#faf9fd}.crm-work-block h2{margin:0;font-size:14px;color:#35415a}.crm-work-block header>span{color:var(--crm-accent);font-size:12px;font-weight:700}.crm-work-block article{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:11px 16px;border-top:1px solid #eef0f5;min-height:65px}.crm-work-block article>div{display:grid;gap:4px;min-width:0}.crm-work-block article strong{font-size:13px;overflow-wrap:anywhere}.crm-work-block article small{font-size:11px;color:var(--muted)}.crm-work-block article button{font-size:12px;padding:6px 9px;flex-shrink:0}.crm-work-block nav{display:flex;justify-content:center;align-items:center;gap:12px;padding:6px;border-top:1px solid #eef0f5;font-size:11px;color:var(--muted)}.crm-work-block nav button{border:1px solid #e1deed;background:#fff;border-radius:6px;padding:3px 10px;cursor:pointer}.crm-work-block nav button:disabled{opacity:.3;cursor:default}.crm-work-empty{padding:12px 16px;margin:0;color:var(--muted);font-size:12px}
.crm-work-search,.crm-work-selection{border:1px solid #dedeea;border-radius:12px;background:#fff;margin-top:18px;padding:18px}.crm-work-search[hidden],.crm-work-selection[hidden]{display:none}.crm-work-search header,.crm-work-selection header{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}.crm-work-search h2,.crm-work-selection h2{margin:0;font-size:17px}.crm-work-selection header p{font-size:12px;color:var(--muted);margin:5px 0 0}.crm-work-search input{width:100%;padding:12px;border:1px solid #d9dfeb;border-radius:8px}.crm-work-search [data-workdesk-results]{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:12px}.crm-work-search [data-workdesk-results]>.crm-work-empty{grid-column:1/-1}.crm-work-context-actions,.crm-work-related{display:flex;flex-wrap:wrap;gap:8px}.crm-work-related{margin-top:15px}.crm-work-recents{display:grid;gap:7px}.crm-work-recents>small{color:var(--muted);margin-top:8px}.crm-work-recents button{text-align:left;white-space:normal;font-size:12px}
@media(max-width:1000px){.crm-work-layout{grid-template-columns:1fr}.crm-work-buttons>button{min-height:96px}.crm-work-search [data-workdesk-results]{grid-template-columns:1fr}}


/* Tableau de bord personnel ------------------------------------------- */
.daily-dashboard-title p{margin:5px 0 0;color:var(--muted);font-size:13px}.daily-dashboard-date{align-self:center;color:#49627c;font-size:13px;font-weight:700;text-transform:capitalize}.daily-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:16px}.daily-summary-card{display:grid;grid-template-columns:1fr auto;gap:2px 10px;align-items:center;padding:15px 17px;border:1px solid var(--line);border-left:4px solid #8797a8;border-radius:10px;background:#fff;text-align:left;cursor:pointer;box-shadow:0 3px 10px rgba(30,61,91,.04)}.daily-summary-card:hover{border-color:#a8bdd1;transform:translateY(-1px)}.daily-summary-card span{color:#49627c;font-size:12px;font-weight:800;text-transform:uppercase}.daily-summary-card strong{grid-row:1/3;grid-column:2;font-size:28px;color:#153e68}.daily-summary-card small{color:var(--muted);font-size:12px}.daily-summary-card.info{border-left-color:var(--blue)}.daily-summary-card.warning{border-left-color:var(--orange)}.daily-summary-card.danger{border-left-color:#d94d42}.daily-summary-card.success{border-left-color:var(--green)}.daily-dashboard-layout{display:grid;grid-template-columns:minmax(0,2fr) minmax(280px,.8fr);gap:16px;align-items:start}.daily-focus-card,.daily-panel{overflow:hidden}.daily-card-heading{display:flex;align-items:center;justify-content:space-between;gap:15px;padding:15px 17px;border-bottom:1px solid var(--line);background:#f8fafc}.daily-card-heading span{display:block;color:#718096;font-size:10px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}.daily-card-heading h2{margin:3px 0 0;color:#243b55;font-size:17px}.daily-card-heading small{padding:5px 9px;border-radius:999px;background:#e7edf4;color:#536578;font-weight:700}.daily-dashboard-side{display:grid;gap:16px}.daily-task{display:grid;grid-template-columns:5px minmax(0,1fr) auto auto;align-items:center;gap:13px;padding:12px 14px;border-top:1px solid #edf0f4;background:#fff}.daily-card-heading+.daily-task{border-top:0}.daily-task-marker{width:5px;height:36px;border-radius:6px;background:#8797a8}.daily-task.danger .daily-task-marker{background:#d94d42}.daily-task.warning .daily-task-marker{background:var(--orange)}.daily-task.info .daily-task-marker{background:var(--blue)}.daily-task-content{display:grid;gap:4px;min-width:0}.daily-task-content strong{overflow:hidden;color:#243b55;font-size:13px;text-overflow:ellipsis;white-space:nowrap}.daily-task-content span{overflow:hidden;color:var(--muted);font-size:12px;text-overflow:ellipsis;white-space:nowrap}.daily-task time{color:#718096;font-size:11px;white-space:nowrap}.daily-task button,.daily-quick-links button{border:1px solid #cbd8e5;border-radius:7px;background:#fff;color:#2167a6;font-weight:700;cursor:pointer}.daily-task button{padding:7px 10px}.daily-task button:hover,.daily-quick-links button:hover{background:#eef6fd}.daily-quick-links{display:grid;padding:8px}.daily-quick-links button{display:flex;align-items:center;justify-content:space-between;padding:11px 10px;border-color:transparent;text-align:left}.daily-quick-links b{font-size:18px}.daily-watch-row{display:grid;grid-template-columns:34px 1fr;align-items:center;gap:9px;width:100%;padding:10px 13px;border:0;border-top:1px solid #edf0f4;background:#fff;text-align:left;cursor:pointer}.daily-card-heading+.daily-watch-row{border-top:0}.daily-watch-row:hover{background:#f7fafc}.daily-watch-row strong{display:grid;place-items:center;min-width:30px;height:30px;border-radius:8px;background:#fff1d6;color:#9b6311}.daily-watch-row span{color:#49627c;font-size:12px}.daily-empty{display:grid;gap:5px;padding:34px 18px;text-align:center;color:var(--muted)}.daily-empty strong{color:#31506f}.daily-empty.compact{padding:22px 14px}.nav-item[data-view="dashboard"] b{background:#e7f1fb;color:#185c97}
.daily-task-group{border-top:1px solid #edf0f4;background:#fff}.daily-card-heading+.daily-task-group{border-top:0}.daily-task-group+.daily-task-group{margin-top:6px}.daily-task-group-heading{display:grid;grid-template-columns:minmax(0,1fr) auto 18px;align-items:center;gap:12px;padding:11px 14px;background:#f7fafc;cursor:pointer;list-style:none}.daily-task-group-heading::-webkit-details-marker{display:none}.daily-task-group-heading::after{content:"›";justify-self:end;color:#49627c;font-size:22px;font-weight:400;line-height:1}.daily-task-group[open] .daily-task-group-heading{border-bottom:1px solid #edf0f4}.daily-task-group[open] .daily-task-group-heading::after{content:"⌄";font-size:18px}.daily-task-group-heading>span{display:grid;gap:2px;min-width:0}.daily-task-group-heading h3{margin:0;color:#49627c;font-size:12px;font-weight:800;line-height:1.2;text-transform:uppercase}.daily-task-group-heading small{color:#718096;font-size:11px;font-weight:600;line-height:1.2}.daily-task-group-heading b{display:grid;place-items:center;min-width:24px;height:24px;padding:0 7px;border-radius:999px;background:#e7edf4;color:#536578;font-size:11px;font-weight:800}.daily-task-group.has-urgent .daily-task-group-heading b{background:#fde7e5;color:#b9362d}.daily-task-group.has-urgent .daily-task-group-heading small{color:#b9362d}.daily-task-group .daily-task:first-of-type{border-top:0}
@media(max-width:1050px){.daily-summary{grid-template-columns:repeat(2,minmax(0,1fr))}.daily-dashboard-layout{grid-template-columns:1fr}.daily-dashboard-side{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){.daily-summary,.daily-dashboard-side{grid-template-columns:1fr}.daily-task{grid-template-columns:5px minmax(0,1fr) auto}.daily-task time{display:none}.daily-task-content strong,.daily-task-content span{white-space:normal}.daily-dashboard-date{display:none}}
