:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --text-muted: #71717a;
  --accent: #5b5bd6;
  --accent-hover: #4c4cc0;
  --accent-soft: #f1f0fe;
  --danger: #e5484d;
  --danger-soft: #fdf2f2;
  --warning: #f5a524;
  --warning-soft: #fff8e8;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

svg {
  display: block;
  width: 1em;
  height: 1em;
}

button {
  font-family: inherit;
}

/* ---- Shell ---- */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 20px;
}

.brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}

.brand-name {
  font-weight: 650;
  font-size: 14px;
  line-height: 1.2;
}

.brand-tag {
  font-size: 11px;
  color: var(--text-muted);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  text-decoration: none;
  width: 100%;
  cursor: pointer;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--text-muted);
}

.nav-item:hover {
  background: #f4f4f5;
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.is-active svg {
  color: var(--accent);
}

.nav-item.is-disabled {
  color: #c1c1c5;
  cursor: default;
}

.nav-item.is-disabled:hover {
  background: none;
}

.nav-item.is-disabled svg {
  color: #d4d4d8;
}

.nav-soon {
  margin-left: auto;
  font-size: 9.5px;
  font-weight: 600;
  color: #a1a1aa;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  white-space: nowrap;
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.sidebar-foot-text {
  font-size: 10.5px;
  color: #c1c1c5;
  padding: 8px 10px 2px;
  line-height: 1.4;
}

.nav-item.is-logout {
  color: var(--danger);
}

.nav-item.is-logout svg {
  color: var(--danger);
}

.nav-item.is-logout:hover {
  background: var(--danger-soft);
}

.content {
  flex: 1;
  min-width: 0;
  /* clip (et non hidden) : ne cree pas de conteneur de defilement, position: sticky reste possible */
  overflow-x: clip;
}

.view {
  display: block;
}

[hidden] {
  display: none !important;
}

.view[hidden] {
  display: none;
}

.page {
  padding: 28px 36px 60px;
  max-width: none;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 20px;
  font-weight: 650;
  margin: 0;
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn svg {
  width: 14px;
  height: 14px;
}

.btn:hover {
  background: #f4f4f5;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

.btn-icon {
  padding: 6px;
  width: 30px;
  height: 30px;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Hub ---- */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.hub-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.hub-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.hub-card.is-disabled {
  cursor: default;
  opacity: 0.55;
}

.hub-card.is-disabled:hover {
  border-color: var(--border);
  transform: none;
}

.hub-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}

.hub-icon svg {
  width: 18px;
  height: 18px;
}

.hub-title {
  font-size: 14px;
  font-weight: 600;
}

.hub-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.hub-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  align-self: flex-start;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card + .card {
  margin-top: 14px;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-body {
  padding: 16px;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}

.tab:hover {
  background: #f4f4f5;
}

.tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- Planning ---- */
.day-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
}

.day-col {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
}

.day-col.is-operator-absent {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.day-absence {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -14px -16px 12px;
  padding: 7px 16px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 650;
  border-radius: var(--radius) var(--radius) 0 0;
}

.day-absence svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.day-absence span {
  font-weight: 500;
  opacity: 0.8;
}

.day-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 0 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.day-col-date {
  font-size: 13.5px;
  font-weight: 650;
  text-transform: capitalize;
}

.day-col-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.day-col-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.day-load {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 260px;
  min-width: 200px;
}

.day-load-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: #f0f0f2;
  overflow: hidden;
  min-width: 100px;
}

.day-load-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #2a9d5c;
  transition: width 0.15s ease;
}

.day-load-bar-fill.is-warning {
  background: var(--warning);
}

.day-load-bar-fill.is-danger {
  background: var(--danger);
}

.day-load-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.day-load-text.is-danger {
  color: var(--danger);
  font-weight: 650;
}

.of-table {
  overflow-x: auto;
}

.day-drop {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: fit-content;
  min-height: 60px;
  padding: 2px;
  border-radius: var(--radius);
  transition: background 0.1s ease;
}

.day-drop.is-dragover {
  background: var(--accent-soft);
  outline: 1px dashed var(--accent);
  outline-offset: 2px;
}

.day-drop.is-dragover .empty-state {
  display: none;
}

/* Ligne d'insertion pendant le glisser-deposer */
.drop-indicator {
  position: relative;
  height: 3px;
  margin: 2px 6px;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
}

.drop-indicator::before,
.drop-indicator::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.drop-indicator::before { left: -6px; }
.drop-indicator::after { right: -6px; }

/* Mini-calendrier (ajout de journee) */
.mini-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.mini-cal-title {
  font-weight: 600;
  font-size: 14px;
}
.mini-cal-weekdays,
.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.mini-cal-weekdays span {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  padding-bottom: 4px;
}
.mini-day {
  font: inherit;
  font-size: 13px;
  padding: 7px 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.mini-day:hover:not(:disabled) {
  border-color: var(--accent);
}
.mini-day:disabled {
  cursor: not-allowed;
}
.mini-day.is-empty {
  visibility: hidden;
}
.mini-day.is-weekend {
  color: var(--border);
}
.mini-day.is-holiday,
.mini-cal-legend i.is-holiday {
  background: #eef0f3;
  border-color: #cfd4dc;
}
.mini-day.is-existing,
.mini-cal-legend i.is-existing {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: #8a5a00;
}
.mini-day.is-vacation,
.mini-cal-legend i.is-vacation {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}
.mini-day.is-today,
.mini-cal-legend i.is-today {
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.mini-day.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.mini-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.mini-cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mini-cal-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid;
}
.mini-cal-selected {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 500;
}

/* Une ligne par OF, colonnes alignees avec l'en-tete .of-head */
.of-grid {
  display: grid;
  /* OF, Commande, Client, Format, Qte, Temps, Expedition, Matieres, Finition, Machine, Machine suivante, Prix / bouton */
  grid-template-columns: 96px 90px minmax(130px, 1.6fr) 90px 64px 52px 84px minmax(110px, 1.2fr) minmax(90px, 1fr) 100px 112px 96px;
  align-items: center;
  column-gap: 8px;
  padding: 7px 12px 7px 10px;
  border: 1px solid transparent;
  border-left-width: 3px;
}

.of-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.of-cell.is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.of-head {
  padding-top: 2px;
  padding-bottom: 4px;
}

.of-head .of-cell {
  font-size: 10.5px;
  font-weight: 650;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}


.of-card {
  background: var(--surface);
  border-color: var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Portail operateur : bouton Commencer en debut de ligne, pas de colonne Prix */
#dayRow.has-of-actions .of-grid {
  grid-template-columns: 112px 96px 82px minmax(130px, 1.6fr) 82px 64px 52px 84px minmax(110px, 1.2fr) minmax(90px, 1fr) 100px 112px;
}

.of-cell-action {
  overflow: visible;
}

.of-start-btn {
  width: 100%;
  justify-content: center;
}

.of-start-btn.is-done {
  background: #e4e4e7;
  border-color: #d4d4d8;
  color: var(--text-muted);
}

/* Page Info OF (portail operateur) */
/* Fabrication et Conditionnement cote a cote, meme hauteur ; Infos produit en dessous */
.info-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.info-layout > .info-wide {
  grid-column: 1 / -1;
}

@media (max-width: 1300px) {
  .info-layout { grid-template-columns: 1fr; }
}

.info-layout > .card + .card {
  margin-top: 0;
}

/* Page detail OF : bandeau de 4 grandes cases */
.of-hero {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 1300px) {
  .of-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.of-hero-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.of-hero-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.of-hero-icon svg {
  width: 26px;
  height: 26px;
}

.of-hero-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.of-hero-label {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.of-hero-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Case Etat aux couleurs du planning */
.of-hero-tile.is-etat-reprise { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.of-hero-tile.is-etat-urgent { background: #d63384; border-color: #d63384; color: #fff; }
.of-hero-tile.is-etat-bloque { background: #ef4444; border-color: #ef4444; color: #fff; }
.of-hero-tile.is-etat-fini { background: #e4e4e7; border-color: #d4d4d8; }
.of-hero-tile[class*="is-etat-"]:not(.is-etat-direct):not(.is-etat-fini) .of-hero-label { color: rgba(255, 255, 255, 0.85); }
.of-hero-tile[class*="is-etat-"]:not(.is-etat-direct) .of-hero-icon { background: rgba(255, 255, 255, 0.25); color: inherit; }

/* Fiche de fabrication : une ligne par information, icone + libelle + valeur */
.of-detail-row {
  display: grid;
  grid-template-columns: 34px 130px 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.of-detail-row:first-child { padding-top: 0; }
.of-detail-row:last-child { border-bottom: none; }

.of-detail-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: #f4f4f5;
  color: var(--text-muted);
}

.of-detail-icon svg { width: 19px; height: 19px; }

.of-detail-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-muted);
}

.of-detail-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.detail-strong {
  font-size: 18px;
  font-weight: 700;
}

.detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f4f4f5;
  font-size: 14px;
  font-weight: 600;
}

.detail-chip svg { width: 16px; height: 16px; color: var(--text-muted); }

/* Longueur de papier necessaire : bobine plus visible */
.detail-chip.is-length {
  background: var(--accent-soft);
  color: var(--accent);
}

.detail-chip.is-length svg { width: 20px; height: 20px; color: var(--accent); }

/* Encres : pastille de couleur + nom */
.ink-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ink-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--surface);
}

.ink-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.ink-chip.is-cut {
  padding-left: 9px;
  border-style: dashed;
}

.ink-chip.is-cut svg { width: 16px; height: 16px; }

/* Parcours machines : etapes flechees */
.route {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.route-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 650;
  color: var(--text-muted);
  background: var(--surface);
}

.route-step.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.route-step.is-next {
  background: #fff3dc;
  border-color: #f59e0b;
  color: #8a5a00;
}

.route-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.85;
}

.route-arrow { color: #a1a1aa; display: inline-flex; }
.route-arrow svg { width: 18px; height: 18px; }

/* Commentaire bien visible */
.of-comment {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: #fff8db;
  border: 1px solid #f5d76e;
  font-size: 16px;
  font-weight: 600;
  white-space: pre-wrap;
}

.of-comment-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a07800;
  margin-bottom: 2px;
}

.of-comment svg { width: 20px; height: 20px; flex: 0 0 auto; color: #a07800; }

.info-empty {
  color: var(--text-muted);
}

.info-product {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 8px;
  color: var(--text);
}

.info-product-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
}

.info-product-name svg { width: 18px; height: 18px; color: var(--accent); }

.info-product li { font-size: 14px; line-height: 1.6; }

.info-product ul {
  margin: 0;
  padding-left: 18px;
}

.of-card:hover {
  border-color: var(--accent);
}

/* Couleur de ligne selon l'etat (memes teintes que l'ancien planning) */
.of-card.etat-reprise,
.of-card.etat-urgent,
.of-card.etat-bloque {
  color: #fff;
}

.of-card.etat-reprise {
  background: #f59e0b;
  border-color: #d97f06;
}

.of-card.etat-urgent {
  background: #d63384;
  border-color: #b02a6c;
  font-weight: 600;
}

.of-card.etat-bloque {
  background: #ef4444;
  border-color: #c93434;
}

.of-card[class]:hover {
  border-color: var(--accent);
}

/* Sur une ligne coloree, la machine suivante garde la couleur du texte */
.of-card.etat-reprise .of-next,
.of-card.etat-urgent .of-next,
.of-card.etat-bloque .of-next {
  color: inherit;
  text-decoration: underline;
}

/* Note operateurs : badge de nouveau message */
.nav-badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.5;
  animation: badge-pulse 1.6s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.45); }
  50% { box-shadow: 0 0 0 4px rgba(229, 72, 77, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .nav-badge { animation: none; }
}

.new-pill {
  display: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
}

#noteCard.is-new {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

#noteCard.is-new .new-pill {
  display: inline-block;
}

#noteCardBody {
  white-space: pre-wrap;
}

/* Selection multiple (admin) : Ctrl+clic / Maj+clic */
.of-card {
  user-select: none;
}

/* Selection : contour violet ; la couleur d'etat est conservee (fond violet clair seulement en direct) */
.of-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.of-card.is-selected:not(.etat-reprise):not(.etat-urgent):not(.etat-bloque) {
  background: var(--accent-soft);
}

.selection-bar {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 6px 8px 6px 14px;
}

.selection-count {
  font-size: 13px;
  font-weight: 650;
  color: var(--accent);
  margin-right: 4px;
}

/* Recherche du planning */
.search-input {
  width: 260px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.tab-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}

.tab.is-dim {
  opacity: 0.5;
}

/* OF fini : ligne grisee et barree (le bouton reste lisible pour pouvoir annuler) */
.of-card.is-done {
  background: #f4f4f5;
  border-color: var(--border);
  font-weight: normal;
  transition: background 0.3s ease;
}

.of-card.is-done .of-cell:not(.of-cell-action) {
  color: #a1a1aa;
  text-decoration: line-through;
}

.of-card.is-dragging {
  opacity: 0.4;
}

.of-ref {
  font-weight: 650;
}

/* Pastille machine precedente : verte = terminee, rouge = pas encore, grise = verification */
.etat-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.55);
}

.etat-dot.is-ok { background: #22c55e; }
.etat-dot.is-ko { background: #ef4444; }
.etat-dot.is-none { background: #ffffff; border-color: #cbd5e1; }

.of-client {
  font-weight: 500;
}

.of-next {
  color: var(--warning);
  font-weight: 600;
}

/* Depot : OF en attente de planification, en tete de machine */
.day-col.is-depot {
  background: var(--warning-soft);
  border-style: dashed;
  border-color: var(--warning);
  /* Reste visible en haut pendant le defilement du planning */
  position: sticky;
  top: 8px;
  z-index: 5;
  max-height: 40vh;
  overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.day-col.is-depot .day-col-date {
  color: #8a5a00;
}

/* ---- Dialogs ---- */
dialog.panel {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: 440px;
  max-width: 92vw;
  box-shadow: var(--shadow-md);
}

dialog.panel::backdrop {
  background: rgba(15, 15, 20, 0.4);
}

.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
}

.panel-close {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
}

.panel-body {
  padding: 16px 20px;
  max-height: 65vh;
  overflow-y: auto;
}

.panel-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* ---- Forms ---- */
.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.etat-group {
  display: flex;
  gap: 6px;
}

.etat-pill {
  flex: 1;
  padding: 6px 0;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
}

.etat-pill.is-active[data-etat="direct"] {
  background: #f4f4f5;
  color: var(--text);
  border-color: #d4d4d8;
}

.etat-pill.is-active[data-etat="reprise"] {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: var(--warning);
}

.etat-pill.is-active[data-etat="urgent"] {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

.etat-pill.is-active[data-etat="bloque"] {
  background: var(--danger-soft);
  color: #b3261e;
  border-color: #b3261e;
}

/* ---- Table ---- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table th {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table input {
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  width: 100%;
}

.table select {
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
  background: var(--surface);
  width: 100%;
}

.table-scroll {
  overflow-x: auto;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 6px 10px;
  align-items: center;
  font-size: 13px;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}

.check-item:hover {
  background: #f4f4f5;
}

.field .check-item input {
  width: auto;
}

.check-note {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.form-hint code {
  background: #f4f4f5;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

/* ---- Horaires de travail ---- */
.hc-toolbar {
  flex-wrap: wrap;
}

.hc-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hc-week-label {
  font-weight: 600;
  min-width: 210px;
  text-align: center;
}

.hc-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
  background: var(--surface);
}

.hc-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.hc-table th,
.hc-table td {
  border: 1px solid var(--border);
}

.hc-center {
  text-align: center !important;
  white-space: nowrap;
}

.hc-date {
  font-weight: 500;
  text-transform: none;
}

.hc-name {
  font-weight: 600;
  white-space: nowrap;
}

.hc {
  text-align: center !important;
  font-size: 12px;
  line-height: 1.5;
  min-width: 96px;
}

.hc.is-editable {
  cursor: pointer;
}

.hc.is-editable:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.hc-empty { color: var(--text-muted); }
.hc-default { background: #fafafa; color: var(--text-muted); }
.hc-filled { background: #ecfdf3; }
.hc-over { background: var(--danger-soft); color: var(--danger); font-weight: 650; }
.hc-note { background: var(--warning-soft); font-style: italic; }
.hc-note-text { font-style: italic; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.hc-vacation { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.hc-absence { background: #f4f4f5; color: var(--text-muted); font-style: italic; }

.hc-diff {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.hc-diff.is-over { background: var(--danger-soft); color: var(--danger); }
.hc-diff.is-under { background: #f4f4f5; color: var(--text-muted); }
.hc-diff.is-ok { background: #ecfdf3; color: #1f8a4c; }

.hc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.hc-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hc-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* ---- Misc ---- */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 999;
  max-width: 360px;
}

.toast.is-error {
  background: var(--danger);
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.15s ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .page {
    padding: 20px;
  }
}

/* Icone commentaire a cote du n° d'OF */
.of-comment-flag {
  display: inline-flex;
  vertical-align: -2px;
  margin-left: 5px;
  color: #c08a00;
}

.of-comment-flag svg { width: 14px; height: 14px; }

.of-card.etat-reprise .of-comment-flag,
.of-card.etat-urgent .of-comment-flag,
.of-card.etat-bloque .of-comment-flag { color: inherit; }

/* Menu du clic droit sur un OF (admin) */
.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 230px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.context-title {
  padding: 6px 10px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.context-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.context-item svg { width: 16px; height: 16px; color: var(--text-muted); flex: 0 0 auto; }
.context-item:hover { background: var(--accent-soft); }
.context-item:hover svg { color: var(--accent); }
.context-item[data-danger] { color: var(--danger); }
.context-item[data-danger] svg { color: var(--danger); }
.context-item[data-danger]:hover { background: var(--danger-soft); }

.context-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}

.context-label {
  padding: 6px 10px 2px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.context-etats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px 6px 6px;
}

.context-etat {
  padding: 5px 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
  background: var(--surface);
}

.context-etat.etat-reprise { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.context-etat.etat-urgent { background: #d63384; border-color: #d63384; color: #fff; }
.context-etat.etat-bloque { background: #ef4444; border-color: #ef4444; color: #fff; }
.context-etat:hover { filter: brightness(0.92); }

/* Fiche OF admin : titre de groupe de champs */
.field-group-title {
  margin: 14px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}


/* Carte Conditionnement : dessin de la bobine + chiffres */
.packaging {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.reel-drawing {
  /* largeur fixee par le dessin (echelle constante) ; jamais plus large que la carte */
  max-width: 100%;
  height: auto;
  flex: 0 0 auto;
}

/* Bobine d'etiquettes en 3D : support jaune, etiquettes blanches, mandrin carton */
.reel3d-shadow { fill: rgba(0, 0, 0, 0.08); }
.reel3d-body { fill: #ecd98e; stroke: #a8904a; stroke-width: 1.5; }
.reel3d-band { fill: #ffffff; stroke: none; }
.reel3d-gap { stroke: #ecd98e; stroke-width: 2.5; }
.reel3d-strip { fill: #ecd98e; stroke: #a8904a; stroke-width: 1.5; stroke-linejoin: round; }
.reel3d-label { fill: #ffffff; stroke: #d9c477; stroke-width: 0.8; }
.reel3d-top { fill: #f6ebbd; stroke: #a8904a; stroke-width: 1.5; }
.reel3d-top.is-unknown { stroke-dasharray: 4 4; }
.reel3d-min { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-dasharray: 5 4; }
.reel3d-core { fill: #b8946a; stroke: #6b4f2a; stroke-width: 1.5; }
.reel3d-hole { fill: #5e452a; }
.reel-dim path { fill: none; stroke: var(--text-muted); stroke-width: 1.2; }
.reel-dim .reel-dim-guide { stroke-dasharray: 2 3; stroke-width: 1; }

.packaging-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 180px;
  flex: 1 1 180px;
}

.packaging-count {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.packaging-count-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent);
}

.packaging-count-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.reel-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Pastille | libelle (toute la place, sur une ligne) | valeur alignee a droite */
.reel-legend li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.3;
  color: var(--text-muted);
  font-weight: 600;
}

.reel-legend li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.reel-legend strong {
  white-space: nowrap;
  text-align: right;
  color: var(--text);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.reel-key {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.reel-key.is-max { background: #f6ebbd; border: 2px solid #a8904a; }
.reel-key.is-min { border: 2px dashed var(--accent); }
.reel-key.is-core { background: #b8946a; border: 2px solid #6b4f2a; }

.reel-dim text {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  fill: var(--text);
}
