:root {
  --bg: #f5f6f8;
  --surface: #fff;
  --text: #1d2330;
  --muted: #6b7385;
  --border: #e1e4ea;
  --primary: #2f5bea;
  --primary-soft: #e8eefd;
  --ok: #18865a;
  --ok-soft: #e3f4ec;
  --warn: #b26b00;
  --warn-soft: #fdf1dc;
  --danger: #c8323a;
  --danger-soft: #fdeaea;
  --surface-2: #f8f9fb;      /* fonds secondaires : survol de ligne, zones, encadrés */
  --hover: #f0f2f5;
  --primary-hover: #2549c4;
  --neutral-soft: #eef0f3;
  --track: #e6e9ef;          /* fond des barres de progression */
  --info: #5b7fe8;           /* acomptes */
  --info-soft: #eef4ff;
  --info-border: #c9d8fb;
  --late-border: #f3c7c9;
  --topbar: #151a26;
  --dot-border: rgba(0,0,0,.15);
  --shadow: rgba(0,0,0,.1);
  --radius: 8px;
  /* photos / vidéos : mêmes couleurs dans les deux thèmes (posées sur l'image) */
  --media-bg: #000;
  --on-media: #fff;
  --media-overlay: rgba(0, 0, 0, .55);
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Thème sombre (data-theme posé par theme.js) ---------- */
:root[data-theme=dark] {
  --bg: #0f131a;
  --surface: #171c26;
  --text: #e4e8f0;
  --muted: #9aa3b5;
  --border: #2c3446;
  --primary: #5b84ff;
  --primary-soft: #1f2b4d;
  --ok: #3fbf86;
  --ok-soft: #16352a;
  --warn: #e0a040;
  --warn-soft: #3a2c14;
  --danger: #ef6b72;
  --danger-soft: #3d1d21;
  --surface-2: #1c2230;
  --hover: #252c3c;
  --primary-hover: #4a73ee;
  --neutral-soft: #262d3b;
  --track: #2c3446;
  --info: #7b9bff;
  --info-soft: #1c2640;
  --info-border: #33457a;
  --late-border: #5a2a2f;
  --topbar: #0a0d13;
  --dot-border: rgba(255,255,255,.35);
  --shadow: rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }

/* ---------- Layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 2rem; flex-wrap: wrap;
  background: var(--topbar); color: #fff; padding: .6rem 1.5rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; display: inline-flex; align-items: center; gap: .55rem; }
.brand-logo { width: 30px; height: 30px; flex: none; border-radius: 7px; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.brand span { font-weight: 400; opacity: .7; }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: .25rem; flex-wrap: wrap; }
nav a { color: #c7cdd9; padding: .4rem .7rem; border-radius: 6px; }
nav a:hover { background: #262d3d; text-decoration: none; color: #fff; }
nav a.active { background: var(--primary); color: #fff; }
nav a[hidden] { display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid #39414f; border-radius: 6px; color: #c7cdd9; padding: .3rem .45rem; cursor: pointer; }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; display: block; }
.theme-toggle:hover { background: #262d3d; color: #fff; }
.session { display: flex; align-items: center; gap: .5rem; color: #c7cdd9; font-size: .9rem; }
.session a, .session button { color: #c7cdd9; background: none; border: 1px solid #39414f; border-radius: 6px; padding: .3rem .65rem; font: inherit; cursor: pointer; }
.session a:hover, .session button:hover { background: #262d3d; color: #fff; text-decoration: none; }
.login-card { max-width: 380px; margin: 2rem auto; }
.login-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.2rem; font-size: 1.15rem; }
.login-brand img { border-radius: 14px; box-shadow: 0 2px 8px rgba(31,63,179,.3); }
.login-card label { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.readonly-note { color: var(--muted); font-size: .85rem; }

main { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: .25rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 650; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 1.5rem; text-align: center; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tfoot td { font-weight: 650; border-bottom: none; }
tr.archived td { opacity: .5; }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: .45rem .6rem; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=color] { padding: .1rem; height: 2.2rem; }
textarea { min-height: 4rem; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; }
.form-grid .full { grid-column: 1 / -1; }
.help { font-size: .75rem; color: var(--muted); }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.filters label { min-width: 140px; }

.btn {
  font: inherit; cursor: pointer; border-radius: 6px; padding: .5rem .9rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: .25rem .55rem; font-size: .85rem; }
.actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.row-actions { display: flex; gap: .3rem; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.planned { background: var(--warn-soft); color: var(--warn); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.learned { background: var(--primary-soft); color: var(--primary); }
.badge.neutral { background: var(--neutral-soft); color: var(--muted); }
.dot { display: inline-block; width: .9rem; height: .9rem; border-radius: 50%; border: 1px solid var(--dot-border); vertical-align: -2px; margin-right: .35rem; }
.dots .dot { margin-right: .15rem; }
.err-pos { color: var(--danger); }
.err-neg { color: var(--ok); }

/* ---------- Job lines ---------- */
.line-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: .9rem; background: var(--surface-2); }
.line-card .line-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.line-card .form-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.line-card .form-grid .wide { grid-column: span 2; }
.estimate { margin-top: .8rem; padding: .6rem .8rem; background: var(--primary-soft); border-radius: 6px; font-size: .9rem; }
.estimate strong { font-size: 1.1rem; }
.estimate.error { background: var(--danger-soft); color: var(--danger); }
.total-bar { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; background: var(--topbar); color: #fff; border-radius: var(--radius); margin-bottom: 1rem; }
.total-bar strong { font-size: 1.3rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.density-help { font-size: .85rem; background: var(--surface-2); border-radius: 6px; padding: .5rem .8rem; }
.density-help summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.density-help ul { margin: .5rem 0 0; padding-left: 1.1rem; display: grid; gap: .4rem; }
.measure { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .3rem; }
.measure input { width: 6.5rem; padding: .25rem .4rem; }

.dropzone {
  display: block; margin-top: 1rem; padding: 1.4rem 1rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: .95rem;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.loading { opacity: .6; cursor: progress; }
.art-preview { margin-top: 1rem; text-align: center; background: repeating-conic-gradient(#f0f1f4 0 25%, #fff 0 50%) 0 0 / 16px 16px; border: 1px solid var(--border); border-radius: 6px; padding: .5rem; }
.art-preview canvas { max-width: 100%; height: auto; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.art-info { line-height: 1.6; }
.warn { color: var(--warn); font-weight: 600; }
details.options { margin-top: 1rem; }
details.options summary { cursor: pointer; color: var(--primary); font-weight: 600; margin-bottom: .75rem; }

.art-controls { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.artwork.compact .dropzone { margin-top: 0; padding: .9rem .6rem; font-size: .85rem; }
.artwork.compact .art-preview { margin-top: .6rem; }
.artwork.compact .art-info { font-size: .82rem; }
.artwork.compact .art-controls label { font-size: .78rem; }
.artwork.compact .art-controls select { font-size: .82rem; padding: .3rem .4rem; }
.line-body { display: grid; grid-template-columns: 280px 1fr; gap: 1.1rem; align-items: start; }
@media (max-width: 900px) { .line-body { grid-template-columns: 1fr; } }
.file-link { font-size: .8rem; }
/* ---------- Acomptes ---------- */
.progress { height: 6px; background: var(--track); border-radius: 999px; overflow: hidden; margin-top: .35rem; }
.progress > div { height: 100%; background: var(--ok); border-radius: 999px; }
.delivery-progress { min-width: 220px; text-align: right; font-size: .9rem; }
.delivery-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.delivery-form h3 { margin-bottom: .6rem; }
.d-table { margin-top: .6rem; }

/* ---------- Planning ---------- */
.week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, .75fr)); gap: .6rem; margin-bottom: .75rem; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 320px; transition: background .15s, border-color .15s; }
.day.weekend { background: var(--surface-2); }
.day.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.day.drop { background: var(--primary-soft); border-color: var(--primary); }
.day-head { padding: .6rem .7rem; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .15rem; }
.day.today .day-head { background: var(--primary); color: #fff; border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.day.today .day-sum { color: #dbe4ff; }
.day-name { font-weight: 650; }
.day-num { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.day-sum { font-size: .75rem; color: var(--muted); }
.day-body { padding: .5rem; display: flex; flex-direction: column; gap: .45rem; flex: 1; }
.day-add { display: block; text-align: center; padding: .4rem; font-size: .82rem; color: var(--muted); border-top: 1px dashed var(--border); }
.day-add:hover { color: var(--primary); background: var(--primary-soft); text-decoration: none; }

.plan-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: 6px; padding: .5rem .55rem; cursor: pointer; font-size: .85rem; box-shadow: 0 1px 2px var(--shadow); }
.plan-card:hover { box-shadow: 0 3px 10px var(--shadow); }
.plan-card.done { border-left-color: var(--ok); opacity: .75; cursor: pointer; }
.plan-card[draggable="true"] { cursor: grab; }
.plan-card.delivery { background: var(--info-soft); border-color: var(--info-border); border-left-color: var(--info); }
.badge.delivery { background: var(--info); color: #fff; }
.plan-legend { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.plan-legend .lg { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; border-left: 4px solid; background: var(--surface); border-top: 1px solid var(--border); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.lg.planned { border-left-color: var(--warn) !important; }
.lg.late { border-left-color: var(--danger) !important; }
.lg.done { border-left-color: var(--ok) !important; }
.lg.delivery { border-left-color: var(--info) !important; background: var(--info-soft) !important; }
.plan-card.late { border-left-color: var(--danger); }
.plan-card.dragging { opacity: .4; }
.plan-card[draggable="true"] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.plan-ghost { position: fixed; z-index: 1000; pointer-events: none; margin: 0; opacity: .95;
  box-shadow: 0 10px 28px var(--shadow), 0 0 0 2px var(--primary); rotate: 2deg; }
.plan-card-head { display: flex; justify-content: space-between; gap: .3rem; align-items: flex-start; }
.plan-card-head strong { line-height: 1.25; word-break: break-word; }
.plan-meta { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.plan-foot { display: flex; justify-content: space-between; align-items: center; margin-top: .35rem; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.badge.late { background: var(--danger-soft); color: var(--danger); }
.late-box { border-color: var(--late-border); }
.late-list { display: flex; gap: .6rem; flex-wrap: wrap; }
.late-item { width: 210px; }
.late-date { font-size: .75rem; color: var(--danger); margin-bottom: .2rem; font-weight: 600; }
@media (max-width: 1000px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .day-head { flex-direction: row; justify-content: space-between; align-items: center; }
}

.notice { background: var(--warn-soft); color: var(--warn); padding: .6rem .8rem; border-radius: 6px; font-size: .9rem; }
.face { margin-top: 1rem; }
.line-card .face { border-top: 1px dashed var(--border); padding-top: .8rem; }
.face-title { margin: 0 0 .6rem; font-size: .95rem; }
.face-title:empty { display: none; }
.price-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0 0 1rem; }
.price-box > div { background: var(--surface-2); border-radius: 6px; padding: .55rem .7rem; display: flex; flex-direction: column; gap: .15rem; }
.price-box span { font-size: .78rem; }
.price-box strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.result-big { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Dialog / toast ---------- */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem; width: min(720px, 95vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 20, 30, .45); }
.error { color: var(--danger); }
#toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--topbar); color: #fff; border: 1px solid var(--border);
  padding: .7rem 1.1rem; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 100;
  display: flex; align-items: center; gap: .6rem; max-width: min(460px, calc(100vw - 2rem));
  opacity: 0; transform: translateY(calc(100% + 2rem)); pointer-events: none;
  transition: opacity .2s ease, transform .3s cubic-bezier(.2, .9, .3, 1.2);
}
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
.toast-icon { flex: none; display: inline-grid; place-items: center; width: 1.35rem; height: 1.35rem; border-radius: 50%;
  background: var(--ok); color: #fff; font-size: .8rem; font-weight: 800; }
#toast.error .toast-icon { background: #fff; color: var(--danger); }
#toast.error { background: var(--danger); }

/* ---------- Téléphone ---------- */
@media (max-width: 600px) {
  main { padding: 1rem .75rem; }
  .topbar { padding: .5rem .75rem; gap: .4rem; }
  nav a { padding: .35rem .5rem; font-size: .9rem; }
  .card { padding: .9rem; }
  .grid.stats { grid-template-columns: 1fr 1fr; }
  .stat .value { font-size: 1.25rem; }
  .form-grid, .line-card .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid input, .form-grid select { width: 100%; }
  .line-card .form-grid .wide, .form-grid label.full { grid-column: 1 / -1; }
  .page-head h1 { font-size: 1.3rem; }
  .result-big { font-size: 1.8rem; }
  .page-head .row-actions { flex-wrap: wrap; justify-content: flex-start; }
  td strong { white-space: nowrap; }
}

@media print {
  .topbar, .actions, .btn { display: none !important; }
  main { padding: 0; }
  .card { border: none; }
}

/* Encre à préparer (formulaire de job) */
.estimate .prepare { display: inline-block; margin-top: .3rem; }

/* ---------- Visualiseur de fichiers ---------- */
button.file-link { background: none; border: 0; padding: 0; font: inherit; font-size: .8rem; color: var(--primary); cursor: pointer; text-align: left; }
button.file-link:hover { text-decoration: underline; }
.art-preview { cursor: zoom-in; }
#file-viewer { width: min(1400px, 96vw); height: 92vh; max-width: none; padding: 0; display: none; flex-direction: column; overflow: hidden; }
#file-viewer[open] { display: flex; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.viewer-title { word-break: break-all; }
.viewer-tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.viewer-page { flex-direction: row; align-items: center; gap: .4rem; }
.viewer-zoom { display: flex; gap: .3rem; align-items: center; }
/* flex + margin:auto : centré quand le fichier est plus petit que la fenêtre, défilement complet quand il est plus grand */
.viewer-body { position: relative; flex: 1; display: flex; overflow: auto; background: repeating-conic-gradient(#eceef2 0 25%, #f8f9fb 0 50%) 0 0 / 18px 18px;
  padding: 16px; overscroll-behavior: contain; touch-action: none; cursor: grab; }
.viewer-body.dragging { cursor: grabbing; user-select: none; }
.viewer-canvas { display: block; flex: none; margin: auto; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.25); image-rendering: auto; }
.viewer-pct { min-width: 3.6rem; text-align: center; font-variant-numeric: tabular-nums; font-size: .85rem; }
.viewer-msg { margin: 3rem auto; text-align: center; color: var(--muted); }
.viewer-info { padding: .45rem 1rem; border-top: 1px solid var(--border); }

/* =====================================================================
   Fluidité : transitions, animations et indications de ce qui est cliquable
   ===================================================================== */
:root { --ease: cubic-bezier(.2, .7, .2, 1); --focus: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }
html { -webkit-tap-highlight-color: transparent; }

/* Tout ce qui réagit change en douceur */
a, .btn, button, input, select, textarea, .card, .stat, .plan-card, .day, .dropzone, tr, .theme-toggle {
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease),
    box-shadow .2s var(--ease), transform .15s var(--ease), opacity .2s var(--ease);
}

/* Focus clavier bien visible (pas au clic souris) */
a:focus-visible, button:focus-visible, .btn:focus-visible, .plan-card:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus); }
tr.clickable:focus-visible { outline: none; background: var(--primary-soft); }

/* Boutons : léger relief au survol, enfoncement au clic */
.btn { position: relative; }
.btn:hover:not(:disabled) { box-shadow: 0 2px 6px var(--shadow); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.97); box-shadow: none; }
.btn.primary { box-shadow: 0 1px 3px color-mix(in srgb, var(--primary) 40%, transparent); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 40%, transparent); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn.ok:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled, button:disabled { opacity: .55; cursor: not-allowed; }
/* action en cours : petite roue à la place du texte */
.btn.busy { color: transparent !important; cursor: progress; opacity: .85; }
.btn.busy::after { content: ''; position: absolute; inset: 0; margin: auto; width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid; border-color: var(--muted) transparent var(--muted) transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after, .btn.ok.busy::after { border-color: #fff transparent #fff transparent; }

/* Liens texte : soulignement qui se dessine */
main a:not(.btn):not(.day-add) { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .2s var(--ease), color .15s; }
main a:not(.btn):not(.day-add):hover { text-decoration: none; background-size: 100% 1px; }

/* Barre du haut */
nav a:active { transform: scale(.96); }
nav a.active { box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 45%, transparent); }
.theme-toggle svg { transition: transform .3s var(--ease); }
.theme-toggle:hover svg { transform: rotate(25deg); }
.brand-logo { transition: transform .25s var(--ease); }
.brand:hover .brand-logo { transform: rotate(-8deg) scale(1.06); }

/* Barre de chargement (requêtes de plus de 150 ms) */
#loadbar { position: absolute; left: 0; bottom: -1px; height: 3px; width: 100%; transform: scaleX(0); transform-origin: left;
  background: linear-gradient(90deg, var(--primary), #8fb0ff); opacity: 0; pointer-events: none; }
#loadbar.active { opacity: 1; animation: loadbar 8s cubic-bezier(.1, .7, .2, 1) forwards; }
#loadbar.done { opacity: 0; transform: scaleX(1); transition: transform .2s ease, opacity .3s ease .15s; }
@keyframes loadbar { from { transform: scaleX(0); } to { transform: scaleX(.9); } }
main.is-loading { opacity: .55; pointer-events: none; transition: opacity .2s ease; }

/* Changement de page : apparition en fondu, éléments en cascade */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
main.page-in > * { animation: rise .28s var(--ease) backwards; }
main.page-in > :nth-child(2) { animation-delay: .04s; }
main.page-in > :nth-child(3) { animation-delay: .08s; }
main.page-in > :nth-child(4) { animation-delay: .12s; }
main.page-in > :nth-child(n+5) { animation-delay: .16s; }
main.page-in .grid.stats > .stat, main.page-in .week > .day { animation: rise .3s var(--ease) backwards; }
main.page-in .grid.stats > :nth-child(2), main.page-in .week > :nth-child(2) { animation-delay: .04s; }
main.page-in .grid.stats > :nth-child(3), main.page-in .week > :nth-child(3) { animation-delay: .08s; }
main.page-in .grid.stats > :nth-child(4), main.page-in .week > :nth-child(4) { animation-delay: .12s; }
main.page-in .week > :nth-child(n+5) { animation-delay: .16s; }

/* Lignes de tableau qui s'ouvrent : barre de couleur à gauche et flèche « › » à droite */
tr.clickable { cursor: pointer; }
tr.clickable > td:first-child { transition: box-shadow .15s var(--ease); }
tr.clickable:hover > td:first-child, tr.clickable:focus-visible > td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
tr.clickable > td:last-child { position: relative; padding-right: 1.6rem; }
tr.clickable > td:last-child::after { content: '›'; position: absolute; right: .5rem; top: 50%; translate: -4px -55%;
  font-size: 1.3rem; line-height: 1; color: var(--primary); opacity: 0; transition: opacity .15s, translate .2s var(--ease); }
tr.clickable:hover > td:last-child::after, tr.clickable:focus-visible > td:last-child::after { opacity: .9; translate: 0 -55%; }
tr.clickable:active { background: var(--primary-soft); }

/* Cartes : légère profondeur */
.card, .stat { box-shadow: 0 1px 2px color-mix(in srgb, var(--shadow) 50%, transparent); }

/* Planning : cartes qui se soulèvent, poignée sur ce qui se déplace, cadenas sur ce qui est figé */
.plan-card { position: relative; }
.plan-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.plan-card:active { transform: translateY(0) scale(.98); }
.plan-card.done:hover, .plan-card.delivery:hover { transform: translateY(-1px); }
.plan-card .grip { position: absolute; left: -4px; top: 50%; translate: 0 -50%; width: 10px; height: 22px; border-radius: 3px; opacity: 0;
  background: radial-gradient(circle, var(--muted) 1.2px, transparent 1.6px) 0 0 / 5px 5px; transition: opacity .15s; }
.plan-card[draggable="true"]:hover .grip { opacity: .8; }
.badge .lock { width: .72rem; height: .72rem; vertical-align: -1px; margin-right: .25rem; }
.plan-card.dragging { transform: scale(.97); }
body.plan-dragging .day:not(.drop) { border-style: dashed; border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
body.plan-dragging .day.drop { box-shadow: 0 0 0 3px var(--primary-soft); transform: scale(1.01); }
.plan-ghost { animation: lift .18s var(--ease); }
@keyframes lift { from { transform: scale(1); rotate: 0deg; } }
.plan-card.flash { animation: flash 1.4s var(--ease); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--primary), 0 6px 18px var(--shadow); } }

/* Écrans tactiles (pas de survol) : on montre d'emblée ce qui est cliquable / déplaçable */
@media (hover: none) {
  tr.clickable > td:last-child::after { opacity: .5; translate: 0 -55%; }
  .plan-card[draggable="true"] .grip { opacity: .55; }
  .btn:hover:not(:disabled), .plan-card:hover { transform: none; }
  .btn:active:not(:disabled) { transform: scale(.96); }
  .plan-card:active { transform: scale(.98); }
}

/* Champs : survol, focus et saisie invalide */
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--focus); }
input:user-invalid, select:user-invalid { border-color: var(--danger); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
select:not(:disabled), input[type=checkbox], input[type=color], label.check { cursor: pointer; }
input[type=checkbox] { accent-color: var(--primary); width: 1rem; height: 1rem; }

/* Zone d'import : invite au dépôt */
.dropzone:hover { transform: translateY(-1px); }
.dropzone.over { transform: scale(1.01); box-shadow: 0 0 0 4px var(--primary-soft); }
.dropzone.loading { position: relative; overflow: hidden; }
.dropzone.loading::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--primary);
  animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%) scaleX(.4); } 100% { transform: translateX(100%) scaleX(.4); } }
.art-preview { position: relative; transition: box-shadow .2s var(--ease), border-color .15s; }
.art-preview:hover { border-color: var(--primary); box-shadow: 0 4px 14px var(--shadow); }
.art-preview::after { content: 'Afficher en grand'; position: absolute; right: .5rem; bottom: .5rem; font-size: .75rem; padding: .2rem .55rem;
  border-radius: 999px; background: var(--topbar); color: #fff; opacity: 0; transition: opacity .15s; pointer-events: none; }
.art-preview:hover::after { opacity: .9; }
@media (hover: none) { .art-preview::after { opacity: .75; } }

/* Lien vers un fichier : icône de document */
button.file-link { display: inline-flex; align-items: center; gap: .3rem; margin-top: .15rem; padding: .1rem .35rem; border-radius: 4px; }
button.file-link::before { content: ''; width: .75rem; height: .9rem; flex: none; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14'%3E%3Cpath d='M1 .7h6.3L11.3 4.6V13a.7.7 0 0 1-.7.7H1A.7.7 0 0 1 .3 13V1.4A.7.7 0 0 1 1 .7Zm6 0v4h4.3' fill='none' stroke='black' stroke-width='1.4'/%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 12 14'%3E%3Cpath d='M1 .7h6.3L11.3 4.6V13a.7.7 0 0 1-.7.7H1A.7.7 0 0 1 .3 13V1.4A.7.7 0 0 1 1 .7Zm6 0v4h4.3' fill='none' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E") center / contain no-repeat; }
button.file-link:hover { background: var(--primary-soft); text-decoration: none; }

/* Sections dépliables : flèche qui tourne */
details > summary { list-style: none; display: flex; align-items: center; gap: .4rem; user-select: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '›'; display: inline-block; font-size: 1.2em; line-height: 1; transition: transform .2s var(--ease); }
details[open] > summary::before { transform: rotate(90deg); }
details[open] > :not(summary) { animation: rise .2s var(--ease); }

/* Barres de progression : se remplissent à l'affichage */
.progress > div { transform-origin: left; animation: grow .6s var(--ease) .1s backwards; }
@keyframes grow { from { transform: scaleX(0); } }

/* Fenêtres : ouverture en douceur */
dialog[open] { animation: pop .2s var(--ease); }
dialog[open]::backdrop { animation: fade .2s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

@keyframes spin { to { transform: rotate(360deg); } }

/* Respect du réglage « réduire les animations » du système */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Champ avec suggestions (clients) ---------- */
.combo { position: relative; display: block; }
.combo input { width: 100%; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .3rem; list-style: none;
  max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 28px var(--shadow); color: var(--text); font-size: .92rem; animation: pop .14s var(--ease); }
.combo-list li { padding: .45rem .6rem; border-radius: 5px; cursor: pointer; }
.combo-list li:hover, .combo-list li.active { background: var(--primary-soft); }
.combo-list mark { background: none; color: var(--primary); font-weight: 700; }
.combo-list .combo-new { color: var(--ok); font-weight: 600; border-top: 1px dashed var(--border); margin-top: .2rem; border-radius: 0 0 5px 5px; }
.combo-list li.combo-new:first-child { border-top: 0; margin-top: 0; }
.combo-list .combo-new:hover { background: var(--ok-soft); }
.combo-list .combo-empty { color: var(--muted); cursor: default; }
.combo-list .combo-empty:hover { background: none; }
.new-hint { color: var(--ok); font-weight: 600; }
/* Boutons en fin de ligne de tableau : la cellule reste une cellule (display:flex la sortait de la grille du tableau) */
td.row-actions { display: table-cell; text-align: right; white-space: nowrap; }
td.row-actions > * + * { margin-left: .3rem; }

/* ---------- À propos d'un job : informations, photos, vidéos, documents ---------- */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.about-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.about-text p.muted { white-space: normal; margin: .2rem 0 .6rem; }
.about-text textarea { width: 100%; min-height: 8rem; resize: vertical; font: inherit; }
.about-text .actions { margin-top: .5rem; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; margin-top: .9rem; }
.att-grid:empty { display: none; }
.att { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2);
  display: flex; flex-direction: column; transition: opacity .2s var(--ease), transform .2s var(--ease); }
.att.flash { animation: flash 1.4s var(--ease); }
.att.removing { opacity: 0; transform: scale(.95); }
.att-media { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem;
  aspect-ratio: 4 / 3; width: 100%; padding: 0; border: 0; background: var(--neutral-soft); color: var(--text);
  cursor: pointer; overflow: hidden; text-decoration: none; font: inherit; }
.att-media img, .att-media video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s var(--ease); }
.att-media:hover img, .att-media:hover video { transform: scale(1.04); }
.att-media:focus-visible { outline: none; box-shadow: inset var(--focus); }
.att-play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.att-play svg { width: 46px; height: 46px; padding: 10px 8px 10px 12px; border-radius: 50%; color: var(--on-media); background: var(--media-overlay); }
.att-doc { padding: .6rem; text-align: center; }
.att-doc audio { width: 100%; }
.att-ext { font-weight: 700; font-size: .85rem; letter-spacing: .04em; color: var(--primary); background: var(--primary-soft);
  border-radius: 6px; padding: .45rem .6rem; }
.att-name { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.att figcaption { display: flex; align-items: center; gap: .3rem; padding: .35rem .3rem .35rem .6rem; font-size: .85rem; min-height: 2.4rem; }
.att-caption { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-actions { display: flex; gap: .1rem; opacity: .55; transition: opacity .15s var(--ease); }
.att:hover .att-actions, .att:focus-within .att-actions { opacity: 1; }
.att-actions .btn { padding: .15rem .45rem; }
.about-uploads:not(:empty) { margin-top: .8rem; display: grid; gap: .4rem; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) 2fr auto; align-items: center; gap: .6rem; font-size: .85rem; }
.upload-row .upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .progress { margin: 0; }
.upload-row .progress > div { background: var(--primary); animation: none; transition: width .2s linear; }
.upload-row.failed .progress > div { background: var(--danger); }
.upload-row.failed .upload-pct { color: var(--danger); }
.upload-pct { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 6.5rem; text-align: right; }
.about-add { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .6rem; margin-top: .9rem; padding: .9rem; }
.about.drag-over { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.about.drag-over .about-add { border-color: var(--primary); background: var(--primary-soft); }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline-flex; } .att-actions { opacity: 1; } }
@media (max-width: 560px) {
  .att-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .upload-row { grid-template-columns: minmax(0, 1fr) auto; }
  .upload-row .progress { grid-column: 1 / -1; grid-row: 2; }
}
.video-dialog { width: min(1100px, 96vw); max-width: none; padding: 0; background: var(--surface); overflow: hidden; }
.video-dialog .video-body { background: var(--media-bg); display: grid; place-items: center; }
.video-dialog video { width: 100%; max-height: 80vh; display: block; }
@media print { .about-add, .about-uploads, .att-actions { display: none !important; } .att-grid { grid-template-columns: repeat(3, 1fr); } }

/* Historique des prix d'une encre */
.price-up { color: var(--danger); }
.price-down { color: var(--ok); }

/* Graphique de l'historique des prix (src : drawPriceChart dans app.js) */
.price-chart { position: relative; margin: .4rem 0 1rem; touch-action: pan-y; }
.price-chart svg { display: block; overflow: visible; font-size: 12px; }
.pc-grid line { stroke: var(--border); stroke-width: 1; }
.pc-axis text { fill: var(--muted); font-variant-numeric: tabular-nums; }
.pc-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pc-dot { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.pc-last { fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.pc-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.pc-focus { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.pc-cross, .pc-focus { display: none; pointer-events: none; }
.pc-cross.on, .pc-focus.on { display: inline; }
.pc-hit { fill: transparent; cursor: crosshair; }
.pc-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 9rem; padding: .45rem .6rem; font-size: .82rem; line-height: 1.35;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px var(--shadow); }
.pc-tip-date { color: var(--muted); font-size: .76rem; margin-bottom: .15rem; }
