/* Lecture automatique des tickets (scan.js) : message d'état et panneau de correction. */
.scan-status {
  margin: .4rem 0 0;
  font-size: .9rem;
  color: #555;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .8rem;
  align-items: baseline;
}
.scan-status[hidden] { display: none; }
.scan-status[data-state="busy"]::before {
  content: "";
  width: .8em;
  height: .8em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: scan-spin .8s linear infinite;
  align-self: center;
}
.scan-status[data-state="error"] { color: #777; font-style: italic; }
@keyframes scan-spin { to { transform: rotate(360deg); } }

.scan-show {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: #1f5fbf;
  text-decoration: underline;
  cursor: pointer;
}

.scan-panel {
  margin: .6rem 0 1rem;
  padding: .6rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fafafa;
}
.scan-help { margin: 0 0 .5rem; font-size: .85rem; color: #555; }

.scan-stage {
  position: relative;
  width: 100%;
  line-height: 0;
  user-select: none;
  -webkit-user-select: none;
}
.scan-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scan-stage.is-multi { width: max(100%, calc(var(--pages) * min(80vw, 460px))); }
.scan-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.scan-box {
  position: absolute;
  box-sizing: border-box;
  border: 3px solid;
  border-radius: 4px;
  touch-action: none;
  cursor: move;
  line-height: normal;
}
.scan-box-total { border-color: #d62828; background: rgba(214, 40, 40, .08); }
.scan-box-vat { border-color: #1b8a3a; background: rgba(27, 138, 58, .08); }
.scan-box.is-active { box-shadow: 0 0 0 3px rgba(0, 0, 0, .15); }

.scan-box-label {
  position: absolute;
  left: -3px;
  bottom: 100%;
  padding: 1px 6px;
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  border-radius: 4px 4px 0 0;
  pointer-events: none;
}
.scan-box-total .scan-box-label { background: #d62828; }
.scan-box-vat .scan-box-label { background: #1b8a3a; }

.scan-box-handle {
  position: absolute;
  right: -14px;
  bottom: -14px;
  width: 28px;
  height: 28px;
  cursor: nwse-resize;
  touch-action: none;
}
.scan-box-handle::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid;
}
.scan-box-total .scan-box-handle::after { border-color: #d62828; }
.scan-box-vat .scan-box-handle::after { border-color: #1b8a3a; }

.scan-box-basis {
  position: absolute;
  left: calc(100% + 6px);
  top: -3px;
  display: flex;
  gap: 2px;
  padding: 2px;
  min-height: 0;
  border: 0;
  border-radius: 4px;
  background: #d62828;
  cursor: pointer;
  font: inherit;
}
.scan-box-basis span {
  padding: 0 6px;
  border-radius: 3px;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.5;
  color: rgba(255, 255, 255, .75);
}
.scan-box-basis span.is-on { background: #fff; color: #d62828; }

.scan-box-remove {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #1b8a3a;
  color: #fff;
  font-size: 18px;
  line-height: 28px;
  cursor: pointer;
}

.scan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: space-between;
  margin-top: .8rem;
}
.scan-actions button {
  min-height: 44px;
  padding: .4rem 1rem;
  font: inherit;
  border-radius: 6px;
  cursor: pointer;
}
.scan-add { background: #fff; color: #1b8a3a; border: 1px solid #1b8a3a; }
.scan-done { background: #1f5fbf; color: #fff; border: 1px solid #1f5fbf; }

@media (prefers-color-scheme: dark) {
  .scan-status { color: #bbb; }
  .scan-panel { background: #1e1e1e; border-color: #444; }
  .scan-help { color: #bbb; }
  .scan-show { color: #7fb0ff; }
  .scan-add { background: transparent; color: #5fd07f; border-color: #5fd07f; }
}

/* Cadrage de la photo : 4 coins reliés, détectés automatiquement (comme le scan de Notes sur iPhone). */
html.crop-open, html.crop-open body { overflow: hidden; }
.crop-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: #111;
  color: #fff;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.crop-head {
  margin: 0;
  padding: 14px 16px 6px;
  text-align: center;
  font-size: .95rem;
  line-height: 1.35;
}
.crop-head.is-warning { color: #ffcc00; }
.crop-area {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.crop-stage {
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.crop-image { display: block; width: 100%; height: 100%; }
.crop-svg {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.crop-shade { fill: rgba(0, 0, 0, .55); fill-rule: evenodd; }
.crop-outline {
  fill: rgba(255, 204, 0, .08);
  stroke: #ffcc00;
  stroke-width: 2.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.crop-handle {
  position: absolute;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}
.crop-handle::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 3px solid #ffcc00;
  background: rgba(255, 255, 255, .3);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
}
.crop-handle.is-active::after { background: rgba(255, 204, 0, .5); transform: scale(1.2); }
.crop-handle:focus-visible { outline: 2px solid #fff; outline-offset: -6px; border-radius: 50%; }
.crop-loupe {
  position: absolute;
  top: 8px;
  left: 12px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .6);
  pointer-events: none;
}
.crop-loupe.is-right { left: auto; right: 12px; }
.crop-loupe[hidden] { display: none; }
.crop-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
}
.crop-actions button {
  min-height: 46px;
  padding: .4rem 1rem;
  font: inherit;
  border-radius: 23px;
  cursor: pointer;
}
.crop-secondary { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .45); }
.crop-done { flex: 1; max-width: 12rem; margin-left: auto; background: #ffcc00; color: #111; border: 0; font-weight: 600; }
