/* SCOS-sim / visuel propre — au-dessus du cadre workbench partagé (scos-ui).
   Le cadre (.wb, .wb-display, .wb-panel, .wb-float, .seg, .wb-cards, .wb-acc,
   feuille mobile…) vit dans scos-ui/components.css : INTERDIT de le redéfinir
   ici. Ce fichier ne style QUE le visuel propre de sim : le plan, l'overlay
   de replay (agents), la palette flottante, le graphe de résultats, les
   sliders, les tableaux et chips d'optimiseur/A/B.
   Chrome monochrome encre/papier ; la seule teinte de donnée est --sim-data. */

:root {
  --sim-data: #28628f;
}

/* ==========================================================================
   DISPLAY : le plan du café, centré et borné dans la zone gauche du cadre.
   Le ratio 4:3 est verrouillé (le mapping clic de l'éditeur en dépend).
   ========================================================================== */
/* Le wrap est une boîte 4:3 centrée et bornée par l'espace du display ; les
   deux SVG (éditeur + overlay) la remplissent a l'identique pour rester
   parfaitement superposés (même viewBox côté JS). */
.plan-wrap {
  position: absolute; inset: 0; margin: auto;
  aspect-ratio: 4 / 3;
  max-width: calc(100% - 32px); max-height: calc(100% - 32px);
}
.plan {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  border: 2px solid var(--ink); background: var(--paper);
}
.plan-anim {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; pointer-events: none;
}

.ed-paper { fill: var(--paper); }
.ed-grid { stroke: var(--rule-soft); stroke-width: 1; }
.ed-stroke { fill: none; stroke: var(--ink); stroke-width: 2; }
.ed-fill { fill: var(--ink); }
.ed-dashed { stroke-dasharray: 4 3; }
.ed-lab { font-size: 10px; fill: var(--ink-mid); font-family: var(--sans-kr), var(--sans-en); }
.ed-selected { fill: none; stroke: var(--ink); stroke-width: 4; }
.ed-cursor { fill: none; stroke: var(--ink-mid); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: 0; }
.plan:focus .ed-cursor, .plan:focus-visible .ed-cursor { opacity: 1; }

/* Agents du replay : la teinte de donnée ; les perdus sont creux et pointillés. */
.an-agent .an-dot { fill: var(--sim-data); stroke: var(--paper); stroke-width: 1.6; }
.an-agent .an-halo { fill: var(--sim-data); opacity: 0.12; }
.an-agent .an-n {
  fill: var(--paper); font-size: 9px; font-weight: 800;
  font-family: var(--sans-en); pointer-events: none;
}
.an-agent.seated .an-dot { opacity: 0.85; }
.an-agent.seated .an-halo { opacity: 0.07; }
.an-agent.serve .an-halo { opacity: 0.28; }
.an-agent.lost .an-dot { fill: none; stroke: var(--sim-data); stroke-width: 2; stroke-dasharray: 3 2.5; }
.an-agent.lost .an-halo { opacity: 0; }
.an-agent.lost .an-n { fill: var(--sim-data); }

/* ==========================================================================
   Barre d'outils d'édition flottante (palette + 삭제) : bande horizontale
   compacte en haut du plan, sous la bascule 편집/재생. On édite là où on voit
   sans masquer le plan (fini le gros panneau opaque).
   ========================================================================== */
.sim-edit-ov {
  position: absolute; top: 64px; left: 16px; right: 16px; z-index: 5;
  background: rgba(255, 255, 255, 0.94); border: 2px solid var(--ink);
  backdrop-filter: blur(8px); padding: 7px 8px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.palette { display: flex; gap: 6px; flex-wrap: wrap; }
.pal-btn {
  display: inline-flex; flex-direction: row; align-items: center; gap: 7px;
  min-height: 44px; padding: 6px 11px;
  background: var(--paper); border: 1px solid var(--rule-soft); color: var(--ink);
}
.pal-btn:hover { border-color: var(--ink); }
.pal-btn.armed { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.pal-btn.armed .ed-stroke { stroke: var(--paper); } .pal-btn.armed .ed-fill { fill: var(--paper); }
.pal-ico svg { width: 24px; height: 20px; display: block; }
.pal-lab { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.pal-lab .be { display: none; } /* compact : KO seul dans la barre */
.sim-edit-ov .ed-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.sim-edit-ov .btn-secondary { min-height: 44px; }
.ed-status {
  font-size: 12.5px; line-height: 1.4; color: var(--ink-soft); margin: 0;
  flex: 1 1 100%; order: 9; padding-top: 2px;
}

/* ==========================================================================
   Surcouche basse : barre de replay (horloge, play, vitesses, scrubber).
   Conteneur posé par .wb-float-bottom (scos-ui) ; ici le fond et le contenu.
   ========================================================================== */
.replay-bar {
  background: rgba(255, 255, 255, 0.94); border: 2px solid var(--ink);
  backdrop-filter: blur(8px); padding: 12px 14px;
}
.rp-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.rp-clock {
  font-family: var(--sans-en); font-variant-numeric: tabular-nums;
  font-size: 34px; font-weight: 800; color: var(--ink); line-height: 1; min-width: 104px; margin: 0;
}
.rp-play { min-width: 124px; }
.rp-speed { border: 0; margin: 0; padding: 0; display: flex; align-items: center; gap: 14px; }
.rp-legend { font-size: 13px; font-weight: 700; color: var(--ink); padding: 0; margin-right: 2px; }
.rp-legend .be { font-weight: 500; }
.rp-speed label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--ink-soft); min-height: 44px;
}
.rp-speed input[type="radio"] { width: 19px; height: 19px; accent-color: var(--ink); }
.rp-scrub { width: 100%; min-height: 34px; accent-color: var(--ink); margin: 8px 0 4px; }
.rp-counters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rp-chip {
  display: inline-flex; align-items: baseline; gap: 7px;
  border: 1px solid var(--rule-soft); background: var(--paper);
  padding: 6px 12px; font-size: 13.5px; color: var(--ink-soft);
}
.rp-chip strong {
  font-family: var(--sans-en), var(--sans-kr); font-variant-numeric: tabular-nums;
  font-size: 16px; color: var(--ink);
}
.rp-chip.lost { border-style: dashed; }
.rp-chip.lost strong { color: var(--sim-data); }

/* ==========================================================================
   PANNEAU : visuels propres de sim dans les accordéons (le cadre des cartes
   KPI et des sections vient de scos-ui ; ici seulement le contenu spécifique).
   ========================================================================== */

/* Paramètres (운영 조건) */
.wb-acc-body h3 { font-size: 15px; margin-bottom: 10px; }
.wb-acc-body h3 .be { font-size: 12px; font-weight: 600; }
.param-group { border-top: 1px solid var(--rule-soft); padding-top: 14px; margin-top: 14px; }
.param-group:first-child { border-top: 0; margin-top: 0; padding-top: 4px; }

.hours-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.staff-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px; align-items: end; margin-bottom: 12px;
}
.staff-stepper { display: flex; align-items: center; gap: 6px; height: var(--field-h); }
.stepper-btn {
  width: 44px; height: 44px; flex: none;
  background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  font-size: 22px; font-weight: 800; line-height: 1;
}
.stepper-btn:hover { background: var(--paper-soft); }
.stepper-val {
  min-width: 48px; text-align: center;
  font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.staff-actions, .scn-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }

.demand-sliders {
  display: flex; flex-direction: column; gap: 4px; margin-top: 12px;
  max-height: 300px; overflow-y: auto;
  border: 1px solid var(--rule-soft); background: var(--paper); padding: 10px 12px;
}
.dm-row { display: grid; grid-template-columns: 38px 1fr 58px; align-items: center; gap: 8px; }
.dm-row label { font-size: 13px; font-weight: 700; color: var(--ink); }
.dm-row input[type="range"] { width: 100%; min-height: 28px; accent-color: var(--ink); }
.dm-val {
  font-family: var(--sans-en); font-variant-numeric: tabular-nums;
  font-size: 13.5px; text-align: right; color: var(--ink-soft);
}
.eye-panel {
  display: flex; flex-direction: column; gap: 10px; margin-top: 12px;
  border: 1px solid var(--rule-soft); background: var(--paper); padding: 12px;
}
.field { margin-bottom: 10px; }
.form-msg.ok { color: var(--ok); }

/* Plage estimée du CA sous le grand nombre de la carte (honnêteté donnée). */
.kpi-range {
  font-family: var(--sans-en); font-variant-numeric: tabular-nums;
  font-size: 11px; color: var(--ink-mid); letter-spacing: 0; text-transform: none;
}

/* Résultats : card 놓친 매출, graphe horaire, jauges de perte */
.kpi-lostrev { border: 1px solid var(--rule-soft); background: var(--paper); padding: 12px 14px; margin-bottom: 14px; }
.kpi-label { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.kpi-label .be { display: block; font-size: 11.5px; }
.kpi-value {
  margin: 6px 0 2px; color: var(--ink);
  font-family: var(--sans-en), var(--sans-kr);
  font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: 12.5px; color: var(--ink-mid); }
.lost-detail { margin-top: 10px; border-top: 1px solid var(--rule-soft); padding-top: 4px; }
.lost-detail summary {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--ink);
}
.lost-detail summary .be { font-size: 11.5px; }

.chart-title { font-size: 15px; margin: 4px 0 10px; }
.chart-title .be { font-size: 12px; font-weight: 600; }
.res-chart { width: 100%; height: auto; display: block; }

/* La donnée du graphe porte la seule teinte de la page (--sim-data). */
.ch-served { fill: var(--sim-data); }
.ch-lost-balk { fill: url(#sim-hatch-balk); stroke: var(--sim-data); stroke-width: 1; }
.ch-lost-cap { fill: url(#sim-hatch-cap); stroke: var(--sim-data); stroke-width: 1; }
.ch-hatch-line { stroke: var(--sim-data); stroke-width: 1.5; }
.ch-grid { stroke: var(--rule-soft); stroke-width: 1; }
.ch-axis { stroke: var(--ink); stroke-width: 2; }
.ch-tick { fill: var(--ink-mid); font-size: 12px; font-family: var(--sans-en); }

.chart-caption { font-size: 13.5px; color: var(--ink-mid); margin-top: 8px; }
.ch-key { display: inline-block; width: 14px; height: 11px; vertical-align: baseline; }
.ch-key-served { background: var(--sim-data); }
.ch-key-balk {
  border: 1px solid var(--sim-data);
  background: repeating-linear-gradient(135deg, var(--sim-data) 0 1.5px, transparent 1.5px 5px);
}
.ch-key-cap {
  border: 1px solid var(--sim-data);
  background:
    repeating-linear-gradient(135deg, var(--sim-data) 0 1.5px, transparent 1.5px 5px),
    repeating-linear-gradient(45deg, var(--sim-data) 0 1.5px, transparent 1.5px 5px);
}

.assumptions { margin-top: 14px; border-top: 1px solid var(--rule-soft); padding-top: 10px; }
.assumptions summary {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--ink);
}
.assumptions summary .be { font-size: 12px; }
.assumptions ul { margin: 6px 0 4px; padding-left: 22px; }
.assumptions li { font-size: 14px; line-height: 1.6; color: var(--ink-soft); margin-bottom: 4px; }

/* Tableaux (분해, A/B, optimiseur) */
.lost-table, .ab-table, .opt-table {
  width: 100%; border-collapse: collapse; margin-top: 6px;
  font-size: 14px; color: var(--ink-soft);
}
.lost-table th, .ab-table th, .opt-table th {
  text-align: left; font-size: 13px; color: var(--ink);
  border-bottom: 1px solid var(--rule-soft); padding: 7px 10px 7px 0;
}
.lost-table th .be, .ab-table th .be, .opt-table th .be { font-size: 11px; display: block; }
.lost-table td, .ab-table td, .opt-table td {
  padding: 7px 10px 7px 0; border-bottom: 1px solid var(--rule-soft);
  font-variant-numeric: tabular-nums;
}
.lost-table tr.lost-total th, .lost-table tr.lost-total td {
  font-weight: 800; color: var(--ink); border-bottom: 0;
}

/* Optimiseur de staffing */
.opt-controls {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-top: 12px;
}
.opt-controls .field { min-width: 0; flex: 1 1 140px; margin-bottom: 0; }
.opt-run { width: 100%; flex-basis: 100%; min-height: 52px; padding: 0 26px; }
.opt-chips { display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; margin: 10px 0 4px; }
.opt-chip {
  display: inline-flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--rule-soft); background: var(--paper);
  padding: 10px 14px; font-size: 13px; color: var(--ink-soft);
}
.opt-chip strong {
  font-family: var(--sans-en), var(--sans-kr); font-variant-numeric: tabular-nums;
  font-size: 20px; color: var(--ink);
}
.opt-table td.opt-up { font-weight: 800; color: var(--ink); }
.opt-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Comparateur A/B */
.ab-actions { margin: 4px 0 12px; }
.ab-zone {
  border: 2px solid var(--ink); background: var(--paper);
  padding: 14px 16px; margin: 4px 0 6px;
}
.ab-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.ab-head h3 { font-size: 16px; }
.ab-head h3 .be { font-size: 12px; }
.ab-table th[scope="row"] { font-weight: 700; }
/* Couleur sémantique admise UNIQUEMENT sur les deltas (charte). */
.ab-delta { font-weight: 800; color: var(--ink); }
.ab-delta.good { color: var(--ok); }
.ab-delta.bad { color: var(--crit); }
.ab-zone .res-chart { margin-top: 14px; }
.ab-line-a {
  fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-dasharray: 6 4;
  stroke-linejoin: round; stroke-linecap: round;
}
.ab-line-b {
  fill: none; stroke: var(--sim-data); stroke-width: 2.5;
  stroke-linejoin: round; stroke-linecap: round;
}
.ch-key-a {
  background: repeating-linear-gradient(90deg, var(--ink) 0 6px, transparent 6px 10px);
  height: 3px; vertical-align: middle;
}
.ch-key-b { background: var(--sim-data); height: 3px; vertical-align: middle; }
.ab-verdict {
  margin-top: 12px; font-size: 16px; font-weight: 800; color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Mobile (<820px) : le display est héros plein écran (cadre scos-ui gère la
   feuille). Les surcouches restent lisibles : palette d'édition pleine largeur.
   ========================================================================== */
@media (max-width: 820px) {
  /* Le plan reste un héros 4:3 borné : la gouttière mobile est portée par
     max-width/height (pas de padding qui ferait déborder la boîte ratio). */
  .plan-wrap { max-width: calc(100% - 16px); max-height: calc(100% - 16px); }

  /* Bascule 편집/재생 : 2 boutons en pleine largeur, cibles >=44px. */
  .seg button { min-height: 44px; }

  /* Palette d'édition : bande pleine largeur en bas, posée au-dessus de la
     feuille repliée. La rangée de boutons devient un ruban défilable
     horizontalement (tactile) : chaque bouton garde icône + libellé KO sans
     être coupé, et 삭제 + statut restent accessibles dessous. */
  .sim-edit-ov {
    top: auto; bottom: 10px; left: 8px; right: 8px; width: auto;
    max-height: 50dvh; overflow-y: auto;
    flex-direction: column; align-items: stretch; gap: 8px; padding: 8px;
  }
  .palette {
    flex-wrap: nowrap; overflow-x: auto; gap: 6px;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    padding-bottom: 4px; scrollbar-width: thin;
  }
  .pal-btn { flex: 0 0 auto; }
  .sim-edit-ov .ed-actions { margin-left: 0; }
  .sim-edit-ov .btn-secondary { min-height: 44px; }
  .ed-status { flex: 1 1 auto; order: 0; }
  body.sheet-cover .sim-edit-ov { display: none; }

  /* Barre de replay : pleine largeur, tout passe à la ligne sans déborder. */
  .replay-bar { padding: 10px 12px; }
  .rp-row { gap: 10px 14px; }
  .rp-clock { font-size: 28px; min-width: 84px; }
  .rp-play { min-width: 0; flex: 1 1 110px; }
  .rp-speed { flex: 1 1 100%; gap: 10px 16px; flex-wrap: wrap; }
  .rp-speed label { min-height: 44px; }
  .rp-scrub { min-height: 44px; }
  .rp-counters { gap: 8px; }

  /* iOS ne zoome pas au focus si la police d'entrée fait >=16px. */
  input, select, textarea,
  input[type="number"], .stepper-val,
  .rp-scrub, .dm-row input[type="range"] { font-size: 16px; }
  .dm-row input[type="range"] { min-height: 44px; }
}
@media (max-width: 480px) {
  .sim-edit-ov { left: 8px; right: 8px; }
}
/* Téléphone en paysage : viewport très bas. La palette ne doit pas avaler
   l'écran ; on borne sa hauteur et on garde le ruban défilable. */
@media (max-width: 820px) and (max-height: 640px) {
  .sim-edit-ov { max-height: 64dvh; }
  .rp-clock { font-size: 24px; min-width: 72px; }
}

/* Panneau 수익성 : lignes CA / coûts / résultat, alignées et chiffrées. */
.profit-grid { margin-top: 12px; border-top: 1px solid var(--rule-soft); }
.profit-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--rule-soft);
  font-size: 13.5px; color: var(--ink);
}
.profit-line .be { display: inline; font-size: 11px; color: var(--ink-mid); margin-left: 5px; }
.profit-line b {
  font-family: var(--sans-en); font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 14.5px;
}
.profit-line.profit-net {
  border-bottom: none; border-top: 2px solid var(--ink); margin-top: 2px; padding-top: 9px;
}
.profit-line.profit-net span { font-weight: 800; }
.profit-line.profit-net b { font-size: 19px; font-weight: 800; color: var(--ok); }
.profit-line.profit-net b.is-loss { color: var(--crit); }

/* Profils de demande : libellé + rangée de presets (segmented partagé). */
.demand-presets { margin-top: 10px; }
.dm-presets-label {
  display: block; font-size: 12px; font-weight: 700; color: var(--ink-mid); margin-bottom: 5px;
}
.dm-presets-label .be { font-weight: 500; }
#preset-btns { flex-wrap: wrap; }
#preset-btns button { flex: 1 1 0; min-width: 64px; padding: 7px 6px; font-size: 12px; line-height: 1.2; }

/* Tarif : mode + éditeur de menu (produit : prix + part). */
.price-mode { margin-bottom: 10px; }
#menu-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.menu-row {
  display: grid; grid-template-columns: 1fr 76px 52px 30px; gap: 6px; align-items: center;
}
.menu-row input {
  min-height: 36px; padding: 4px 7px; border: 1px solid var(--rule);
  font-family: var(--sans-kr), var(--sans-en); font-size: 13px;
}
.menu-row .menu-price, .menu-row .menu-pct {
  font-family: var(--sans-en); font-variant-numeric: tabular-nums; text-align: right;
}
.menu-del {
  min-height: 36px; border: 1px solid var(--rule); background: var(--paper);
  color: var(--ink-mid); font-size: 16px; line-height: 1; cursor: pointer;
}
.menu-del:hover { color: var(--crit); border-color: var(--crit); }
.menu-summary { margin-top: 4px; }
.menu-summary b { font-family: var(--sans-en); font-variant-numeric: tabular-nums; }
.menu-share { color: var(--ink-mid); }
.menu-share.menu-share-warn { color: var(--crit); }

/* Salaires par rôle : libellé + saisie alignés, une ligne par rôle. */
.role-wages { display: flex; flex-direction: column; gap: 6px; }
.rw-row { display: grid; grid-template-columns: 1fr 92px; gap: 8px; align-items: center; }
.rw-label { font-size: 13px; color: var(--ink); }
.rw-label .be { font-size: 10.5px; color: var(--ink-mid); margin-left: 4px; }
.rw-row input {
  min-height: 36px; padding: 4px 8px; border: 1px solid var(--rule);
  font-family: var(--sans-en); font-variant-numeric: tabular-nums; text-align: right; font-size: 13px;
}
/* Sélecteur de rôle dans une rangée de personnel. */
.staff-row select { min-height: 40px; }
