* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f2f2f2;
  color: #111;
}

header, main {
  max-width: 1280px;
  margin: auto;
}

header {
  padding: 18px 20px 6px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

h1 { margin-bottom: 4px; }

.panel {
  background: white;
  margin: 16px 20px;
  padding: 16px;
  border-radius: 10px;
  box-shadow: 0 2px 8px #0002;
}

.settings-grid {
  display: grid;
  grid-template-columns: 180px 180px 1fr;
  gap: 12px;
  align-items: end;
}

label {
  font-weight: bold;
  display: block;
}

input, button {
  font: inherit;
}

input[type="date"], input[type="number"], input[type="text"] {
  width: 100%;
  padding: 7px;
  margin-top: 5px;
}

button {
  border: 0;
  padding: 9px 12px;
  border-radius: 7px;
  background: #222;
  color: white;
  cursor: pointer;
}

button:hover { opacity: .85; }

.calendar-link-btn {
  background: #f7f7f7;
  color: #222;
  border: 1px solid #ccc;
  padding: 8px 11px;
  font-size: 13px;
  margin-top: 4px;
}

.calendar-link-btn:hover {
  background: #ececec;
  opacity: 1;
}

.actions-zone {
  display: grid;
  gap: 10px;
}

.auto-fill-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid #d5dbe6;
  border-radius: 12px;
  background: linear-gradient(180deg, #f9fbff, #eef3fb);
}

.auto-fill-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.auto-fill-card span {
  display: block;
  font-size: 12px;
  color: #555;
}

.primary-action-btn {
  background: #1f4f8f;
  padding: 11px 18px;
  border-radius: 9px;
  font-weight: 700;
  box-shadow: 0 2px 6px #0002;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.primary-action-btn:hover {
  opacity: 1;
  background: #183f73;
  transform: translateY(-1px);
  box-shadow: 0 5px 12px #0003;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.group-box {
  border: 2px solid #222;
  border-radius: 10px;
  overflow: hidden;
  background: #fafafa;
}

.group-title {
  background: #222;
  color: white;
  padding: 9px 10px;
  font-weight: bold;
}

.group-body {
  padding: 8px;
}

.cdr-row {
  display: grid;
  grid-template-columns: 1fr 92px 72px 38px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.cdr-row input[type="text"] {
  margin-top: 0;
}

.check-label {
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  border-radius: 6px;
  padding: 4px;
}

.check-floor { background: #ffe1e1; color: #990000; }
.check-absent { background: #111; color: white; }

.check-label input {
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px auto 0;
}

.absent-name {
  opacity: .45;
  text-decoration: line-through;
}

.delete-btn {
  background: #8b0000;
  padding: 7px;
}

.add-btn {
  background: #555;
  width: 100%;
  margin-top: 4px;
}

.hint {
  font-size: 12px;
  color: #555;
}

.summary-accordion,
.planning-accordion {
  padding: 0;
  overflow: hidden;
}

.summary-toggle {
  width: 100%;
  background: white;
  color: #111;
  padding: 16px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 700;
  text-align: left;
}

.summary-toggle:hover {
  opacity: 1;
  background: #f7f7f7;
}

.summary-arrow {
  font-size: 18px;
  transition: transform .15s ease;
}

.summary-content {
  padding: 0 16px 16px;
}

.summary-accordion.collapsed .summary-content,
.planning-accordion.collapsed .summary-content {
  display: none;
}

.summary-accordion:not(.collapsed) .summary-arrow,
.planning-accordion:not(.collapsed) .summary-arrow {
  transform: rotate(90deg);
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.summary-table th,
.summary-table td {
  border: 1px solid #777;
  padding: 4px;
  vertical-align: top;
}

.summary-table th {
  background: #eee;
}

.red {
  color: #c00000;
  font-weight: bold;
}

.day-page {
  background: white;
  width: 210mm;
  min-height: 297mm;
  margin: 20px auto;
  padding: 10mm;
  box-shadow: 0 2px 10px #0003;
  page-break-after: always;
}

.day-title {
  text-align: center;
  font-size: 18px;
  margin: 0 0 8px;
}

.service-title {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  margin: 10px 0 6px;
  text-transform: uppercase;
}

.planning-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.planning-table th,
.planning-table td {
  border: 2px solid #222;
  padding: 4px;
  height: 29px;
  vertical-align: middle;
}

.planning-table th {
  background: #eee;
  text-transform: uppercase;
}

.service-col { width: 24%; }
.rang-col { width: 18%; }
.name-col { width: 26%; }
.recipe-col { width: 16%; }

.cdr-input {
  width: 100%;
  border: 0;
  padding: 5px;
  font-size: 12px;
  background: white;
}

.cdr-input:focus {
  outline: 2px solid #555;
}

.total-row td {
  font-weight: bold;
  height: 26px;
}

@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: white; }
  .no-print { display: none !important; }
  .day-page {
    margin: 0;
    width: 210mm;
    min-height: 297mm;
    box-shadow: none;
    padding: 10mm;
  }
}


.rank-cell {
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.shift-jour {
  background: #c9f2c9 !important;
}
.shift-coupure {
  background: #fff3a6 !important;
}
.shift-nuit {
  background: #cfe2ff !important;
}
.rank-hint {
  font-size: 9px;
  font-weight: normal;
  text-transform: none;
  color: #333;
}


.separator-after td {
  border-bottom-width: 5px !important;
}
.week-summary {
  margin-bottom: 18px;
}
.week-summary h3 {
  margin: 14px 0 6px;
  background: #222;
  color: white;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 14px;
}


.shift-jour-dark {
  background: #8fd18f !important;
}


.auto-filled {
  background: #e8f0ff !important;
  font-weight: bold;
}
.conflict-note {
  color: #b00000;
  font-weight: bold;
}


.cycle-calendar-panel {
  overflow-x: auto;
}
.cycle-calendar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.cycle-calendar-table th,
.cycle-calendar-table td {
  border: 1px solid #777;
  padding: 5px;
  text-align: center;
}
.cycle-calendar-table th {
  background: #222;
  color: white;
}
.cycle-calendar-table tr:nth-child(even) td {
  background: #f6f6f6;
}
.cycle-s1 { background: #e8f5e9 !important; }
.cycle-s2 { background: #fff8e1 !important; }
.cycle-s3 { background: #e3f2fd !important; }
.cycle-s4 { background: #fce4ec !important; }


/* V21 - Planning général hebdomadaire */
.general-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 10px 0 12px;
  font-size: 12px;
  font-weight: 700;
}
.general-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.general-legend i {
  width: 18px;
  height: 12px;
  display: inline-block;
  border: 1px solid #999;
  border-radius: 3px;
}
.legend-open { background: #c9f2c9; }
.legend-close { background: #cfe2ff; }
.legend-break { background: #fff3a6; }
.legend-rest { background: #eadcff; }
.legend-absence { background: #ff8b8b; }

.general-week-summary {
  overflow-x: auto;
}
.general-planning-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}
.general-planning-table th,
.general-planning-table td {
  border: 1px solid #aaa;
  padding: 6px 5px;
  text-align: center;
  vertical-align: middle;
  height: 44px;
}
.general-planning-table thead th {
  background: #f0f0f0;
  font-weight: 800;
  text-transform: uppercase;
}
.general-planning-table thead th span {
  font-size: 10px;
  font-weight: 600;
}
.general-cdr-name {
  width: 155px;
  text-align: left !important;
  background: #fafafa !important;
  font-weight: 800;
  position: sticky;
  left: 0;
  z-index: 1;
}
.general-ouverture {
  background: #c9f2c9;
  font-weight: 800;
}
.general-fermeture {
  background: #cfe2ff;
  font-weight: 800;
}
.general-coupure {
  background: #fff3a6;
  font-weight: 800;
  text-transform: uppercase;
}
.general-rest {
  background: #eadcff;
  font-weight: 900;
  color: #4a277d;
}
.general-absence {
  background: #ff8b8b;
  font-weight: 900;
  color: #760000;
}
.general-empty {
  background: #fff;
}
.general-outside {
  background: #f5f5f5;
}
.general-planning-table td span {
  font-weight: 600;
  font-size: 10px;
}
.general-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 18px;
  font-size: 12px;
}
.general-stats span,
.general-stats strong {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 999px;
  padding: 5px 9px;
}


/* V24 - modification manuelle depuis le planning général : menu stable en deux étapes */
.general-editable-cell {
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.general-editable-cell:hover {
  filter: brightness(0.96);
  box-shadow: inset 0 0 0 2px #2228;
}
.manual-rank-menu {
  position: absolute;
  z-index: 99999;
  width: 280px;
  background: #ffffff;
  color: #111827;
  border: 1px solid #c7cdd8;
  border-radius: 12px;
  box-shadow: 0 14px 38px rgba(15, 23, 42, 0.28);
  padding: 10px;
  font-size: 13px;
}
.manual-rank-menu * {
  color: #111827;
  box-sizing: border-box;
}
.manual-rank-title {
  font-weight: 900;
  margin: 2px 4px 2px;
}
.manual-rank-subtitle {
  color: #4b5563;
  font-size: 11px;
  margin: 0 4px 8px;
}
.manual-rank-panel {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.manual-rank-category-btn,
.manual-rank-item-btn,
.manual-rank-back {
  width: 100%;
  border: 1px solid transparent;
  background: #ffffff;
  color: #111827;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.manual-rank-category-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.manual-rank-back {
  background: #f3f4f6;
  color: #374151;
  margin-bottom: 4px;
}
.manual-rank-category-btn:hover,
.manual-rank-item-btn:hover,
.manual-rank-back:hover {
  background: #eaf2ff;
  border-color: #b7cffc;
  color: #0f3f8c;
}
.cdr-input.manual-filled {
  background: #fff7d6;
}


/* V25 - bouton flottant de recalcul ponctuel après absence manuelle */
.floating-auto-zone {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  width: 330px;
}
.floating-auto-update {
  width: 100%;
  max-width: 330px;
  background: #184f8f;
  color: #fff;
  border: 1px solid #0f3f74;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .28);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.floating-auto-update:hover {
  opacity: 1;
  background: #113b6e;
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, .34);
}
.auto-update-console {
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
  background: rgba(255,255,255,.98);
  color: #172033;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .18);
  padding: 10px 12px;
  font-size: 12px;
}
.auto-console-title {
  font-weight: 900;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.auto-console-title span { color: #64748b; font-weight: 700; }
.auto-console-summary { color: #334155; margin-bottom: 6px; font-weight: 700; }
.auto-update-console ul { margin: 0; padding-left: 18px; }
.auto-update-console li { margin: 3px 0; line-height: 1.25; }
@media print {
  .floating-auto-zone, .floating-auto-update { display: none !important; }
}

/* V29 - planning général : coupures midi/soir et absences spécifiques */
.legend-break-midi { background: #d9f7df; }
.legend-break-soir { background: #dbeafe; }
.legend-absence-specific { background: #f4b6c7; }
.legend-rest { background: #fff3a6; }
.general-rest {
  background: #fff3a6 !important;
  color: #6b4b00 !important;
}
.general-coupure-split {
  padding: 0 !important;
  font-weight: 800;
  text-transform: none;
}
.split-coupure {
  display: grid;
  grid-template-rows: 1fr 1fr;
  height: 100%;
  min-height: 44px;
}
.split-coupure > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4px 3px;
  line-height: 1.05;
}
.split-coupure-midi {
  background: #d9f7df;
  border-bottom: 1px solid rgba(0,0,0,.18);
}
.split-coupure-soir {
  background: #dbeafe;
}
.split-coupure span,
.general-planning-table td span {
  font-size: 9px;
  font-weight: 700;
  opacity: .85;
}
.general-absence-purple {
  background: #eadcff;
  color: #4a277d;
  font-weight: 900;
}
.general-absence-pink {
  background: #f4b6c7;
  color: #7f1d1d;
  font-weight: 900;
}
.manual-rank-category-btn.manual-coupure-midi,
.manual-rank-item-btn.manual-coupure-midi {
  background: #e8fbe9;
  border-color: #bdecc5;
}
.manual-rank-category-btn.manual-coupure-soir,
.manual-rank-item-btn.manual-coupure-soir {
  background: #e9f2ff;
  border-color: #bdd7ff;
}
.manual-rank-item-btn.general-absence-purple {
  background: #f1e8ff;
  border-color: #d4c2fb;
  color: #4a277d;
}
.manual-rank-item-btn.general-absence-pink {
  background: #ffe4eb;
  border-color: #f5b8c8;
  color: #7f1d1d;
}

/* V30 - lisibilité planning général et feuilles */
.legend-open { background: #9fe3a2 !important; }
.legend-close { background: #aac8ee !important; }
.general-ouverture {
  background: #9fe3a2 !important;
  font-weight: 900;
}
.general-fermeture {
  background: #aac8ee !important;
  font-weight: 900;
}
.general-planning-table th,
.general-planning-table td {
  height: 62px;
  padding: 7px 5px;
}
.general-cdr-name {
  height: 62px;
}
.general-coupure-split {
  height: 62px;
}
.split-coupure {
  min-height: 62px;
  height: 62px;
}
.split-coupure > div {
  min-height: 31px;
  padding: 5px 3px;
  overflow: hidden;
}
.split-coupure span,
.general-planning-table td span {
  font-size: 9px;
  line-height: 1.1;
}
.general-absence-orange {
  background: #ffb347 !important;
  color: #5c2c00 !important;
  font-weight: 900;
}
.manual-rank-item-btn.general-absence-orange {
  background: #ffe0ad !important;
  border-color: #ffb347 !important;
  color: #5c2c00 !important;
}
.legend-absence-specific { background: #ffb347 !important; }

/* Feuilles de planning : noms CDR plus lisibles */
.planning-table th {
  background: #e8e8e8;
  border-bottom-width: 3px;
}
.planning-table th:nth-child(3),
.planning-table th:nth-child(4),
.planning-table th:nth-child(5) {
  background: #f1f3f5;
}
.planning-table td:nth-child(3),
.planning-table td:nth-child(4),
.planning-table td:nth-child(5) {
  border-left-width: 3px;
}
.cdr-input {
  text-align: center;
  font-weight: 900;
  font-size: 13px;
  padding: 7px 6px;
  min-height: 28px;
}
.cdr-input.manual-filled {
  font-weight: 900;
}

/* V32 - Barre d'actions intégrée au Planning général */
.summary-titlebar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  background: #fff;
  border-radius: 10px 10px 0 0;
}

.summary-toggle-inline {
  flex: 1 1 auto;
  border-radius: 10px 0 0 10px;
}

.summary-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 0;
  flex-wrap: wrap;
}

.compact-primary {
  padding: 9px 14px;
  font-size: 13px;
  white-space: nowrap;
}

.secondary-danger-btn {
  background: #fff3f3;
  color: #8a1f1f;
  border: 1px solid #e1aaaa;
  padding: 9px 13px;
  border-radius: 9px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}

.secondary-danger-btn:hover {
  opacity: 1;
  background: #ffe0e0;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px #0002;
}

@media (max-width: 900px) {
  .summary-titlebar {
    flex-direction: column;
  }
  .summary-toggle-inline {
    border-radius: 10px 10px 0 0;
  }
  .summary-title-actions {
    padding: 0 12px 12px;
  }
}
#generateCoupuresBtn:disabled{opacity:.45;cursor:not-allowed;filter:grayscale(.4)}
.secondary-action-btn{border:1px solid #2563eb;background:#eff6ff;color:#1e3a8a;border-radius:10px;padding:10px 14px;font-weight:700;transition:.15s ease;}
.secondary-action-btn:not(:disabled):hover{background:#dbeafe;transform:translateY(-1px);box-shadow:0 6px 14px rgba(37,99,235,.18);}


/* V36 - glisser-déposer manuel sur les feuilles de planning */
.cdr-input {
  cursor: grab;
  user-select: none;
}
.cdr-input:active {
  cursor: grabbing;
}
.cdr-input.drag-source {
  opacity: 0.55;
  outline: 2px dashed #1f4f8f;
}
.cdr-input.drag-over {
  outline: 3px solid #f59e0b;
  background: #fff7ed !important;
}
