:root {
  color-scheme: light;
  --paper: #f9f6ef;
  --white: #fff;
  --ink: #1c302a;
  --muted: #505d54;
  --green: #23533e;
  --green-hover: #163d2c;
  --line: #a9b5ab;
  font: 100%/1.5 system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: var(--green); text-underline-offset: .22em; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .61; }
:focus-visible { outline: 3px solid #376c9b; outline-offset: 3px; }

.site-header, main { width: min(100% - 2rem, 71rem); margin-inline: auto; }
.site-header { padding-block: 1.1rem; border-bottom: 1px solid var(--line); }
.site-header a { font-weight: 740; }
main { padding-block: clamp(1.6rem, 3.5vw, 3rem); }
.intro { margin-bottom: 1.7rem; }
h1 { font: 600 clamp(2.15rem, 5.3vw, 4.25rem)/1.04 Georgia, serif; letter-spacing: -.045em; }
.intro p { max-width: 60ch; margin-top: .8rem; color: var(--muted); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.14fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
form, .preview { min-width: 0; border: 1px solid var(--line); border-radius: .75rem; padding: clamp(.85rem, 2.2vw, 1.5rem); }
form { background: var(--white); }
.preview { background: #ecefe7; }
.panel-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem; margin-bottom: 1rem; }
h2 { font-size: 1.15rem; line-height: 1.2; }
.mode { padding: .15rem .54rem; border: 1px solid var(--line); border-radius: .4rem; font-size: .87rem; font-weight: 650; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.full { grid-column: 1 / -1; }
label { display: block; min-width: 0; font-size: .92rem; font-weight: 650; }
.optional { color: var(--muted); font-size: .82rem; font-weight: 450; }
input { color: var(--ink); display: block; min-width: 0; width: 100%; min-height: 2.75rem; margin-top: .2rem; padding: .46rem .57rem; border: 1px solid #87988b; border-radius: .4rem; background: var(--white); font-size: 1rem; line-height: 1.5; }
input[type="date"] { appearance: none; }
.retouches { margin-top: 1.05rem; }
legend { padding: 0; margin-bottom: .28rem; font-weight: 710; }
#lignes { display: grid; gap: .6rem; }
.retouche { display: grid; grid-template-columns: minmax(0, 1fr) minmax(4.7rem, 6rem) auto; gap: .5rem; align-items: end; }
.retouche:has(button[hidden]) { grid-template-columns: minmax(0, 1fr) minmax(4.7rem, 6rem); }
.primary, .secondary, .remove { padding: .43rem .72rem; min-height: 2.75rem; border: 1px solid transparent; border-radius: .4rem; font-size: .92rem; font-weight: 660; }
.primary { color: var(--white); background: var(--green); }
.primary:hover { background: var(--green-hover); }
.secondary { border-color: var(--line); color: var(--green); background: var(--white); }
.secondary:hover:not(:disabled), .remove:hover { background: #e9f0e9; }
.remove { padding-inline: .35rem; color: var(--ink); background: transparent; text-decoration: underline; text-underline-offset: .2em; }
#ajouter { margin-top: .62rem; }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1.05rem; }
.privacy, .preview-note { margin-top: .85rem; color: var(--muted); font-size: .86rem; }

.ticket { padding: 1rem; border: 1px solid var(--line); background: var(--white); overflow-wrap: anywhere; }
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding-bottom: .8rem; border-bottom: 1px solid currentColor; }
.ticket-kind { color: var(--green); font-size: .77rem; font-weight: 750; letter-spacing: .055em; text-transform: uppercase; }
.ticket h3 { font: 600 1.75rem/1.22 Georgia, serif; }
.ticket-head p[data-bon="atelier"] { margin-top: .14rem; color: var(--muted); }
.ticket-head p[data-bon="atelier"]:empty { display: none; }
.ticket-number { max-width: 35%; text-align: right; }
.ticket-details { display: grid; grid-template-columns: 1fr 1.1fr; gap: .7rem; margin-block: .75rem .9rem; }
.ticket-details dt { color: var(--muted); font-size: .84em; }
.ticket-details dd { font-weight: 650; }
.ticket table { width: 100%; border-collapse: collapse; text-align: left; }
.ticket th, .ticket td { padding: .35em 0; }
.ticket tr > :last-child { padding-left: .6em; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ticket thead th { border-bottom: 1px solid var(--line); color: var(--muted); font-size: .87em; }
.ticket tfoot { border-top: 1px solid currentColor; font-weight: 740; }
.ticket-note, .ticket-states { margin: .65em 0 0; font-size: .87em; }
.ticket-states { display: flex; flex-wrap: wrap; gap: 1.1em; padding: 0; list-style: none; }
.ticket-states li::before { content: ""; display: inline-block; width: .85em; height: .85em; margin-right: .35em; border: 1px solid currentColor; vertical-align: -.06em; }
.workshop, .cut { display: none; }

@media (max-width: 55rem) {
  .workspace { grid-template-columns: 1fr; gap: 1rem; }
}
@media (max-width: 26rem) {
  .fields { grid-template-columns: 1fr; }
  .ticket { padding: .75rem; }
  .ticket-details { grid-template-columns: 1fr; gap: .35rem; }
}

@page { size: A4 portrait; margin: 12mm; }
@media print {
  :root { font: 10pt/1.28 system-ui, sans-serif; background: #fff; color: #000; }
  .site-header, .intro, form, .panel-heading, .preview-note { display: none; }
  main, .workspace, .preview { display: block; width: auto; max-width: none; padding: 0; margin: 0; border: 0; background: #fff; }
  .ticket, .workshop { display: block; color: #000; padding: 4mm; border: 1px solid #000; break-inside: avoid; }
  .cut { display: block; margin-block: 5mm; border-top: 1px dashed #555; }
  .ticket h3 { font-size: 17pt; }
  .ticket-head { padding-bottom: .5em; }
  .ticket-kind, .ticket-head p[data-bon="atelier"], .ticket-details dt, .ticket thead th { color: #000; }
  .ticket-details { grid-template-columns: 1fr 1fr; margin-block: .55em; }
  .ticket th, .ticket td { padding-block: .25em; }
  .ticket thead th { border-color: #666; }
}
