/* ==========================================================================
   CNAM BS1 — POSTE DE SAISIE
   Système visuel sobre et précis : bordures 1px, contrastes francs,
   aucune transparence décorative ni dégradé. Le vert est réservé à l'action
   et à l'état « complet ».
   ========================================================================== */

:root {
  /* Surfaces */
  --desk:          #E9E8E3;
  --surface:       #FFFFFF;
  --surface-2:     #F7F6F3;
  --surface-3:     #F0EFEA;

  /* Lignes */
  --line:          #E4E2DB;
  --line-strong:   #D2CFC5;
  --line-hover:    #B9B5A9;

  /* Encre */
  --ink:           #161D19;
  --ink-2:         #3B4540;
  --ink-3:         #66706A;
  --ink-4:         #969D98;

  /* Marque (vert CNAM approfondi) */
  --brand:         #0B6E3D;
  --brand-hover:   #095B32;
  --brand-ink:     #0A5C33;
  --brand-tint:    #E9F4ED;
  --brand-line:    #B9DBC6;

  /* États */
  --warn:          #8A5300;
  --warn-tint:     #FFF6E0;
  --warn-line:     #EFD08A;
  --danger:        #B42318;
  --danger-tint:   #FDF0EF;
  --danger-line:   #F1B8B3;

  --ring:          0 0 0 3px rgba(11, 110, 61, 0.16);
  --ring-danger:   0 0 0 3px rgba(180, 35, 24, 0.14);

  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius-md: 9px;
  --radius-lg: 12px;

  --shadow-sm:    0 1px 2px rgba(22, 29, 25, 0.07);
  --shadow-paper: 0 0 0 1px rgba(22, 29, 25, 0.06), 0 2px 4px rgba(22, 29, 25, 0.05), 0 14px 32px -10px rgba(22, 29, 25, 0.22);
  --shadow-pop:   0 0 0 1px rgba(22, 29, 25, 0.06), 0 12px 32px -8px rgba(22, 29, 25, 0.24);

  --font-ui:    'Geist', 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --font-mono:  'Geist Mono', 'JetBrains Mono', Consolas, monospace;
  /* Police du texte imprimé sur le BS1 : inchangée pour préserver le calibrage */
  --font-print: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* Alias utilisés par du balisage généré en JS */
  --ink-muted: var(--ink-3);
  --ink-faint: var(--ink-4);
  --border-hairline: var(--line);
  --border-strong: var(--line-strong);
}

/* ==========================================================================
   SOCLE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr);
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--line-hover); }

.mono {
  font-family: var(--font-mono);
}

.kbd {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ==========================================================================
   BARRE SUPÉRIEURE
   ========================================================================== */
.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  padding: 0 16px 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

/* Logo : même dessin que l'icône de l'application (icons/icon.svg) */
.brand-mark {
  flex: none;
  width: 32px;
  height: 32px;
  display: block;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lien vers la page d'accueil (site web uniquement) */
.header-brand {
  color: inherit;
  text-decoration: none;
}

.brand-back,
.brand-sub-home {
  display: none;
}

.header-home {
  margin-left: -6px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-sm);
  transition: background-color .15s ease;
}

.header-home .brand-back {
  display: block;
  flex: none;
  margin-right: -5px;
  color: var(--ink-4);
  transition: color .15s ease, transform .15s ease;
}

.header-home:hover {
  background: var(--surface-3);
}

.header-home:hover .brand-back {
  color: var(--brand);
  transform: translateX(-2px);
}

.header-home:hover .brand-sub {
  display: none;
}

.header-home:hover .brand-sub-home {
  display: block;
  color: var(--brand);
}

.header-home:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* Webapp installée : l'accueil la rouvrirait aussitôt (js/landing.js) */
@media (display-mode: standalone) {
  .header-home {
    pointer-events: none;
  }
  .header-home .brand-back {
    display: none;
  }
}

/* Sélecteur de face */
.page-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 11px;
}

.side-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px 0 11px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  text-align: left;
  transition: background-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.side-tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

.side-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-sm);
}

.page-glyph {
  flex: none;
  position: relative;
  border: 1.5px solid currentColor;
  border-radius: 2.5px;
  opacity: 0.75;
}

.page-glyph-portrait { width: 13px; height: 17px; }
.page-glyph-landscape { width: 18px; height: 13px; }

.page-glyph::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.side-tab.active .page-glyph {
  opacity: 1;
  color: var(--brand);
}

.side-tab-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.side-tab-title {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.side-tab-title em {
  font-style: normal;
  font-weight: 500;
  color: var(--ink-4);
  margin-left: 2px;
}

.side-tab-sub {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}

.side-tab-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--brand-tint);
  border: 1px solid var(--brand-line);
  border-radius: 10px;
}

/* Actions */
.header-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.btn-ghost svg {
  color: var(--ink-3);
}

.btn-ghost:hover svg {
  color: var(--ink);
}

.btn-ghost.active {
  background: var(--warn-tint);
  border-color: var(--warn-line);
  color: var(--warn);
}

.btn-ghost.active svg {
  color: var(--warn);
}

/* ==========================================================================
   ESPACE DE TRAVAIL
   ========================================================================== */
.workspace {
  display: grid;
  grid-template-columns: 472px minmax(0, 1fr);
  min-height: 0;
}

/* ==========================================================================
   PANNEAU DE SAISIE
   ========================================================================== */
.clinical-inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 5;
}

.inspector-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.inspector-section {
  padding: 20px 24px 24px;
  border-bottom: 1px solid var(--line);
}

.inspector-section:last-child {
  border-bottom: none;
}

/* En-tête d'étape */
.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.step-index {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.inspector-section.is-done .step-index {
  background: var(--brand);
  border-color: var(--brand);
  color: #FFFFFF;
}

.inspector-section.is-done .step-num {
  display: none;
}

.inspector-section.is-done .step-index::after {
  content: "";
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
}

.step-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.step-title {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.25;
}

.step-status {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspector-section.is-done .step-status {
  color: var(--brand-ink);
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Interrupteurs « Imprimer » */
.toggle-print-subtle,
.mini-check,
.subtle-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.mini-check {
  font-size: 11.5px;
  color: var(--ink-4);
}

.toggle-print-subtle input,
.mini-check input,
.subtle-checkbox input,
.catalog-table input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--brand);
  cursor: pointer;
}

.toggle-print-subtle:hover,
.mini-check:hover,
.subtle-checkbox:hover {
  color: var(--ink);
}

.link-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, background-color 0.12s;
}

.link-action:hover {
  border-color: var(--brand-line);
  background: var(--brand-tint);
}

/* ==========================================================================
   CHAMPS
   ========================================================================== */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.form-grid-address {
  display: grid;
  grid-template-columns: 1fr 104px;
  gap: 12px;
}

.field-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-box label,
.field-label-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}

.field-box label abbr {
  text-decoration: none;
  color: var(--brand);
  margin-left: 1px;
}

.label-note {
  font-weight: 400;
  color: var(--ink-4);
  margin-left: 3px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 18px;
}

.field-group-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.field-group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.field-input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
}

.field-input:hover {
  border-color: var(--line-hover);
}

.field-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.field-input::placeholder {
  color: var(--ink-4);
  font-weight: 400;
}

.field-input.primary-focus {
  font-weight: 600;
}

.field-input.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}

select.field-input,
.search-category-select,
.zoom-control select,
.field-input-inline,
.act-meta-section select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366706A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 12px;
  padding-right: 28px;
  cursor: pointer;
}

.field-input.is-invalid {
  border-color: var(--danger);
  background-color: var(--danger-tint);
}

.field-input.is-invalid:focus {
  box-shadow: var(--ring-danger);
}

.field-hint {
  min-height: 16px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--ink-3);
}

.field-hint.is-error {
  color: var(--danger);
}

.field-hint.is-valid {
  color: var(--brand-ink);
}

.field-hint.is-valid::first-letter {
  text-transform: uppercase;
}

.field-input-mini {
  width: 52px;
  height: 30px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 15px;
}

.field-input-mini:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.subcode-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-3);
}

.field-input-inline {
  height: 24px;
  padding-left: 7px;
  font-size: 11.5px;
  color: var(--ink);
  background-color: var(--surface);
  background-position: right 6px center;
  background-size: 10px;
  padding-right: 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
}

/* Champ date guidé : masque fantôme JJ/MM/AAAA + bouton calendrier */
.date-field {
  position: relative;
  display: block;
  min-width: 0;
}

.date-field.has-picker input[type="text"] {
  padding-right: 36px;
}

.date-field .date-input::placeholder {
  color: transparent;
}

.date-ghost {
  position: absolute;
  inset: 0 36px 0 0;
  display: flex;
  align-items: center;
  padding-left: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--line-hover);
  white-space: pre;
  pointer-events: none;
  overflow: hidden;
}

.date-ghost:empty {
  display: none;
}

.date-ghost-typed {
  color: transparent;
}

.date-picker-btn {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 26px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-3);
}

.date-picker-btn:hover {
  background: var(--brand-tint);
  color: var(--brand-ink);
}

.date-native {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}

/* Contrôle segmenté (qualité du malade) */
.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 3px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.seg-item {
  position: relative;
  cursor: pointer;
}

.seg-item input,
.cadre-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg-item span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  border-radius: 6px;
  transition: background-color 0.12s, color 0.12s, box-shadow 0.12s;
  user-select: none;
}

.seg-item:hover span {
  color: var(--ink);
}

.seg-item input:checked + span {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-sm);
}

.seg-item input:focus-visible + span,
.cadre-pill input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* Cadre des soins */
.cadre-segmented {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cadre-pill {
  position: relative;
  cursor: pointer;
}

.cadre-pill span {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}

.cadre-pill:hover span {
  border-color: var(--line-hover);
  color: var(--ink);
}

.cadre-pill input:checked + span {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}

/* Volets dépliables */
.details-disclosure > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.details-disclosure > summary::-webkit-details-marker {
  display: none;
}

.details-disclosure:not(.settings-disclosure) > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: background-color 0.12s, color 0.12s;
}

.details-disclosure:not(.settings-disclosure) > summary:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.details-disclosure:not(.settings-disclosure)[open] > summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.disclosure-chevron {
  flex: none;
  color: var(--ink-4);
  transition: transform 0.15s;
}

.details-disclosure[open] > summary .disclosure-chevron {
  transform: rotate(90deg);
}

.details-disclosure:not(.settings-disclosure) .disclosure-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.settings-disclosure > summary.step-header {
  margin-bottom: 0;
}

.settings-disclosure[open] > summary.step-header {
  margin-bottom: 18px;
}

.settings-disclosure > summary:hover .step-title {
  color: var(--brand-ink);
}

.field-inspector-box {
  padding: 12px;
  background: var(--warn-tint);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-md);
}

.field-inspector-title {
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--warn);
}

.settings-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding-top: 4px;
}

.btn-subtle-danger {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  background: var(--surface);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm);
}

.btn-subtle-danger:hover {
  background: var(--danger-tint);
}

.btn-subtle {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.btn-subtle:hover {
  border-color: var(--line-hover);
  background: var(--surface-2);
}

/* Profils d'imprimante */
.profile-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.profile-select-box {
  flex: 1 1 180px;
  min-width: 0;
}

.profile-actions {
  display: flex;
  gap: 6px;
  padding-bottom: 3px;
}

.btn-subtle:disabled,
.btn-subtle-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Bannière « nouvelle version disponible » (webapp hors ligne) */
.update-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 14px;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
}

.update-banner[hidden] {
  display: none;
}

/* ==========================================================================
   ACTES : RECHERCHE, RACCOURCIS, LISTE
   ========================================================================== */
.search-nomenclature-bar {
  position: relative;
}

.search-group {
  display: flex;
  align-items: center;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.search-group:hover {
  border-color: var(--line-hover);
}

.search-group:focus-within {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.search-icon {
  flex: none;
  margin: 0 8px 0 12px;
  color: var(--ink-4);
}

.search-field {
  flex: 1;
  min-width: 0;
  height: 100%;
  font-size: 13.5px;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
}

.search-field::placeholder {
  color: var(--ink-4);
}

.search-category-select {
  flex: none;
  height: 100%;
  padding-left: 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  background-color: var(--surface-2);
  border: none;
  border-left: 1px solid var(--line);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  outline: none;
}

.search-category-select:focus-visible {
  box-shadow: inset 0 0 0 2px var(--brand);
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  display: none;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.search-results-dropdown.open {
  display: block;
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.search-item:hover,
.search-item:first-child {
  background: var(--surface-2);
}

.search-item:hover {
  background: var(--brand-tint);
}

.search-item-code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-ink);
}

.search-item-code span {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 11.5px;
  color: var(--ink-4);
}

.search-item-label {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.search-item-price {
  flex: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.palette-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.palette-label {
  flex: none;
  padding-top: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.quick-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fav-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  line-height: 26px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, background-color 0.12s;
}

.fav-chip:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.fav-chip:active {
  transform: translateY(1px);
}

.fav-chip .chip-code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.fav-chip:hover .chip-code {
  color: var(--brand-ink);
}

.fav-chip .chip-fee {
  font-size: 11.5px;
  color: var(--ink-3);
}

.fav-chip .chip-label {
  display: none;
}

/* Liste des actes */
.ledger-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ledger-empty {
  padding: 22px 16px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.ledger-empty-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.ledger-empty-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
}

.act-row-card {
  padding: 8px 8px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.act-row-card:hover {
  border-color: var(--line-hover);
}

.act-row-card:focus-within {
  border-color: var(--brand-line);
  box-shadow: var(--shadow-sm);
}

.act-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px 28px;
  align-items: center;
  gap: 8px;
}

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

.act-row-card input,
.act-row-card select {
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--ink);
  transition: border-color 0.12s, background-color 0.12s, box-shadow 0.12s;
}

.act-row-card input:focus,
.act-row-card select:focus {
  outline: none;
}

.act-row-card .cell-code {
  width: 150px;
  max-width: 100%;
  height: 28px;
  padding: 0 7px;
  margin-left: -8px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--brand-ink);
}

.act-row-card .cell-code:hover,
.act-row-card .act-amount input:hover {
  border-color: var(--line);
}

.act-row-card .cell-code:focus,
.act-row-card .act-amount input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--ring);
}

.act-label {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.act-amount {
  display: flex;
  align-items: center;
  gap: 4px;
}

.act-row-card .cell-montant {
  width: 100%;
  height: 30px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  -moz-appearance: textfield;
}

.act-row-card .cell-montant::-webkit-outer-spin-button,
.act-row-card .cell-montant::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.act-unit {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-4);
}

.btn-remove-act {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  color: var(--ink-4);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  transition: background-color 0.12s, color 0.12s;
}

.btn-remove-act:hover {
  background: var(--danger-tint);
  color: var(--danger);
}

.act-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.act-meta-item {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding-left: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
  cursor: text;
}

.act-meta-item:hover {
  border-color: var(--line-strong);
}

.act-meta-item:focus-within {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--ring);
}

.act-meta-key {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-4);
  user-select: none;
}

.act-meta-item input {
  height: 26px;
  padding: 0 7px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  border: none;
}

.act-meta-section {
  flex: 1 1 120px;
  min-width: 0;
  padding-left: 0;
  cursor: pointer;
}

.act-meta-section select {
  width: 100%;
  height: 26px;
  padding-left: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  border: none;
  background-position: right 8px center;
  background-size: 11px;
}

.act-meta-date .date-field {
  width: 110px;
}

.act-meta-date .cell-date {
  width: 100%;
  padding-right: 24px !important;
}

.act-meta-date .date-ghost {
  inset: 0 24px 0 0;
  padding-left: 7px;
  font-size: 12.5px;
  letter-spacing: 0;
}

.act-meta-date .date-picker-btn {
  right: 2px;
  width: 22px;
  height: 22px;
}

.act-meta-date .date-picker-btn svg {
  width: 13px;
  height: 13px;
}

.act-meta-date .cell-date::placeholder {
  color: transparent;
}

.act-meta-item:has(.is-invalid) {
  border-color: var(--danger);
  background: var(--danger-tint);
}

.act-meta-item:has(.is-warning) {
  border-color: var(--warn-line);
  background: var(--warn-tint);
}

.act-meta-dent input {
  width: 44px;
}

.act-meta-cot input {
  width: 54px;
}

.act-row-card:not(.is-dental) .act-meta-dent {
  display: none;
}

/* ==========================================================================
   PIED DU PANNEAU : TOTAL & IMPRESSION
   ========================================================================== */
.inspector-footer {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 24px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 20px -18px rgba(22, 29, 25, 0.4);
}

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

.tally-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.tally-sum {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.tally-words {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-print {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 14px 0 16px;
  color: #FFFFFF;
  background: var(--brand);
  border: 1px solid var(--brand-hover);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(22, 29, 25, 0.2);
  text-align: left;
  transition: background-color 0.12s;
}

.btn-print:hover {
  background: var(--brand-hover);
}

.btn-print:active {
  transform: translateY(1px);
}

.btn-print-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.btn-print-title {
  font-size: 14.5px;
  font-weight: 650;
}

.btn-print-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
}

.kbd-on-dark {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
}

/* ==========================================================================
   PLAN DE TRAVAIL
   ========================================================================== */
.document-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--desk);
}

.stage-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 54px;
  padding: 9px 18px 9px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.stage-doc-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.stage-doc-title {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
}

.stage-doc-sub {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--line-strong);
  margin: 0 2px;
}

.view-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.view-switch-item {
  height: 28px;
  padding: 0 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  background: transparent;
  border: none;
  border-radius: 5px;
}

.view-switch-item:hover {
  color: var(--ink);
}

.view-switch-item.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow-sm);
}

.stage-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.stage-icon-btn:hover {
  border-color: var(--line-hover);
  color: var(--ink);
}

.stage-icon-btn.active {
  color: var(--brand-ink);
  background: var(--brand-tint);
  border-color: var(--brand-line);
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding-left: 10px;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.zoom-control:hover {
  border-color: var(--line-hover);
}

.zoom-control select {
  height: 30px;
  padding-left: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  background-color: transparent;
  border: none;
  outline: none;
}

/* Bannière de calibrage */
.calibration-floating-bar {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: none;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 40px);
  padding: 6px 6px 6px 14px;
  font-size: 12.5px;
  color: var(--warn);
  background: var(--warn-tint);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.calibration-floating-bar.active {
  display: flex;
}

.calib-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D98B00;
}

.btn-primary-mini {
  flex: none;
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--ink);
  border: none;
  border-radius: var(--radius-sm);
}

.btn-primary-mini:hover {
  background: #000000;
}

/* Feuille */
.a4-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 28px 24px 48px;
}

.a4-scale-wrapper {
  margin: 0 auto;
}

/* Barre d'état */
.stage-status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 32px;
  padding: 0 18px 0 22px;
  font-size: 11.5px;
  color: var(--ink-3);
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.status-item.mono {
  font-size: 11px;
}

.status-print::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
}

.status-print.with-bg {
  color: var(--warn);
}

.status-print.with-bg::before {
  background: #D98B00;
}

.status-format {
  margin-left: auto;
}

/* Crédit développeur et liens légaux */
.status-credit {
  gap: 10px;
  color: var(--ink-4);
}

.status-link {
  padding: 0;
  font-size: inherit;
  color: var(--ink-3);
  background: none;
  border: none;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 2px;
}

.status-link:hover {
  color: var(--brand-ink);
  text-decoration-color: currentColor;
}

/* ==========================================================================
   FENÊTRE « À PROPOS » (CRÉDITS, MENTIONS LÉGALES, CONFIDENTIALITÉ)
   ========================================================================== */
.about-card {
  max-width: 720px;
}

.about-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 22px 0;
  border-bottom: 1px solid var(--line);
}

.about-tab {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.about-tab:hover {
  color: var(--ink);
}

.about-tab.active {
  color: var(--brand-ink);
  border-bottom-color: var(--brand);
}

.prose {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

.prose h3 {
  margin: 18px 0 4px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
}

.prose h3:first-child {
  margin-top: 0;
}

.prose p + p {
  margin-top: 8px;
}

.prose a {
  color: var(--brand-ink);
}

.about-highlight {
  padding: 10px 12px;
  background: var(--brand-tint);
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-md);
}

.about-highlight + h3 {
  margin-top: 18px;
}

.about-updated {
  font-size: 12px;
  color: var(--ink-4);
}

/* ==========================================================================
   MODALE NOMENCLATURE & TARIFS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(22, 29, 25, 0.42);
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  overflow: hidden;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.modal-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.btn-close {
  border-color: var(--line-strong);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 22px 20px;
  overflow-y: auto;
}

.catalog-add {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.catalog-add .field-group-label {
  margin-top: 0;
}

.catalog-add-grid {
  display: grid;
  grid-template-columns: 110px 100px minmax(0, 1fr) 200px 100px auto;
  gap: 8px;
}

.btn-primary {
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--brand);
  border: 1px solid var(--brand-hover);
  border-radius: var(--radius-sm);
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.catalog-table-wrap {
  max-height: 48vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.catalog-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.catalog-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.catalog-table tr:last-child td {
  border-bottom: none;
}

.catalog-table tr:hover td {
  background: var(--surface-2);
}

.catalog-table .field-input {
  height: 30px;
  font-size: 12.5px;
}

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

.modal-footnote {
  font-size: 12px;
  color: var(--ink-4);
}

/* ==========================================================================
   ÉCRANS PLUS ÉTROITS
   ========================================================================== */
@media (max-width: 1320px) {
  .workspace { grid-template-columns: 420px minmax(0, 1fr); }
  .inspector-section, .inspector-footer { padding-left: 20px; padding-right: 20px; }
  .brand-sub, .btn-ghost .kbd { display: none; }
  .side-tab-sub { display: none; }
}

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 380px minmax(0, 1fr); }
  .btn-ghost span { display: none; }
  .btn-print .kbd { display: none; }
  .stage-doc-sub { display: none; }
}

/* ==========================================================================
   PHYSICAL BS1 SHEET (210mm x 297mm Portrait ou 297mm x 210mm Paysage)
   ========================================================================== */
.bs1-sheet {
  position: relative;
  background: #ffffff;
  box-shadow: var(--shadow-paper);
  user-select: none;
  overflow: hidden;
}

.bs1-sheet.orientation-portrait {
  width: 210mm;
  height: 297mm;
}

.bs1-sheet.orientation-landscape {
  width: 297mm;
  height: 210mm;
}

/* Formulaire officiel vectoriel (SVG en mm, généré par js/forms.js) */
.bs1-form {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bs1-form-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Mode "Texte seul" : aperçu de ce qui sort réellement de l'imprimante */
.bs1-sheet.text-only .bs1-form {
  visibility: hidden;
}

/* Grille Millimétrique */
.mm-grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
  background-image:
    linear-gradient(to right, rgba(14, 165, 233, 0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(14, 165, 233, 0.18) 1px, transparent 1px);
  background-size: 10mm 10mm;
  z-index: 10;
}

.bs1-sheet.show-grid .mm-grid-overlay {
  display: block;
}

/* Couche d'impression */
.print-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: translate(var(--offset-x, 0mm), var(--offset-y, 0mm));
}

.print-field {
  position: absolute;
  font-family: var(--font-print);
  color: #000000;
  line-height: 1.15;
  white-space: nowrap;
  pointer-events: auto;
  cursor: default;
}

/* Cases à cocher : x/y désignent le centre de la case (indépendant de la largeur du glyphe) */
.print-field[data-anchor="center"] {
  transform: translate(-50%, -50%);
  text-align: center;
}

.field-tag {
  display: none;
  position: absolute;
  bottom: calc(100% + 2px);
  left: 0;
  background: #0284c7;
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
}

.bs1-sheet.calibrate-mode .field-tag {
  display: block;
}

.bs1-sheet.calibrate-mode .print-field {
  cursor: move;
  outline: 1px dashed rgba(2, 132, 199, 0.6);
  background: rgba(2, 132, 199, 0.08);
}

.bs1-sheet.calibrate-mode .print-field.selected-field {
  outline: 2px solid #0284c7;
  background: rgba(2, 132, 199, 0.16);
  z-index: 50;
}

/* Boxed characters (Identifiant Unique 10 cases, tel, cp) */
.boxed-chars {
  display: inline-flex;
}

.boxed-char {
  display: inline-block;
  width: var(--char-box-width, 5.1mm);
  text-align: center;
  font-family: var(--font-print);
  font-weight: 700;
  letter-spacing: 0;
}

/* Tableaux du BS1 */
.bs1-table-row {
  display: flex;
  align-items: center;
}

.bs1-cell {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  font-weight: 500;
}

/* ==========================================================================
   PRINT ENGINE MEDIA QUERY (STRICT MILLIMETER CALQUE ONLY)
   ========================================================================== */
@media print {
  html, body {
    width: 100% !important;
    height: 100% !important;
    margin: 0mm !important;
    padding: 0mm !important;
    background: transparent !important;
    overflow: visible !important;
  }

  .app-header,
  .clinical-inspector,
  .calibration-floating-bar,
  .stage-toolbar,
  .stage-status,
  .inspector-footer,
  .modal-backdrop,
  .update-banner,
  .field-tag,
  .mm-grid-overlay {
    display: none !important;
  }

  body {
    display: block !important;
  }

  .workspace {
    display: block !important;
    height: 100% !important;
    overflow: visible !important;
    background: transparent !important;
  }

  .document-stage,
  .a4-viewport,
  .a4-scale-wrapper {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
    background: transparent !important;
  }

  .bs1-sheet {
    position: absolute !important;
    left: 0mm !important;
    top: 0mm !important;
    margin: 0mm !important;
    box-shadow: none !important;
    background: transparent !important;
    transform: none !important;
  }

  .bs1-sheet.orientation-portrait {
    width: 210mm !important;
    height: 297mm !important;
  }

  .bs1-sheet.orientation-landscape {
    width: 297mm !important;
    height: 210mm !important;
  }

  /* Pilote qui fait pivoter le paysage dans l'autre sens : on retourne la page 1 autour
     de son centre (la feuille fait exactement la taille de la page, rien ne déborde) */
  .bs1-sheet.orientation-landscape.flip-p1 {
    transform: rotate(180deg) !important;
    transform-origin: center center !important;
  }

  /* Cache le fond par défaut (calque pur) */
  .bs1-form {
    display: none !important;
  }

  /* Si le praticien coche 'Imprimer AUSSI le fond vert' (test sur feuille blanche) */
  .bs1-sheet.print-with-bg .bs1-form {
    display: block !important;
    visibility: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .print-layer {
    display: block !important;
    visibility: visible !important;
  }

  .print-field {
    color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
