:root{
  --bg:#f3f6fb;
  --bg2:#eef2ff;
  --surface:#ffffff;
  --surface-soft:#f8fafc;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;
  --primary:#1d4ed8;
  --primary-2:#0f172a;
  --success-bg:#ecfdf5;
  --success:#047857;
  --danger-bg:#fef2f2;
  --danger:#b91c1c;
  --warning-bg:#fff7ed;
  --warning:#c2410c;
  --shadow:0 12px 40px rgba(15,23,42,.08);
  --radius:22px;
  --radius-sm:14px;
  color-scheme:light;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at top left, rgba(99,102,241,.08), transparent 36%),
    radial-gradient(circle at top right, rgba(29,78,216,.08), transparent 28%),
    linear-gradient(180deg, var(--bg2) 0%, var(--bg) 160px, var(--bg) 100%);
  line-height:1.5;
}
a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}
img{max-width:100%}
.topbar{
  position:sticky;top:0;z-index:30;
  backdrop-filter:blur(18px);
  background:rgba(255,255,255,.78);
  border-bottom:1px solid rgba(226,232,240,.9);
}
.topbar-inner,.shell,.auth-shell{width:min(1180px, calc(100vw - 32px));margin:0 auto}
.topbar-inner{display:flex;justify-content:space-between;align-items:center;padding:16px 0;gap:18px}
.brand{display:flex;align-items:center;gap:14px;min-width:0}
.brand-mark{
  width:46px;height:46px;border-radius:16px;display:grid;place-items:center;
  background:linear-gradient(135deg,#2563eb,#0f172a);color:#fff;font-weight:800;
  box-shadow:0 10px 30px rgba(37,99,235,.22);
}
.brand-copy{display:flex;flex-direction:column;min-width:0}
.brand-copy strong{font-size:1.05rem}
.brand-copy small{color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar nav{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.topbar nav a,.topbar nav .ghost-link{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  padding:10px 14px;border:1px solid var(--border);border-radius:999px;
  color:var(--text);background:rgba(255,255,255,.75);text-decoration:none;font-weight:600;
}
.topbar nav a.primary-link{background:var(--primary);border-color:var(--primary);color:#fff}
.topbar nav a:hover,.topbar nav .ghost-link:hover{background:#fff;text-decoration:none}
.shell{padding:28px 0 42px}
.narrow,.auth-shell{max-width:620px}
.hero{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(300px,.8fr);gap:18px;margin-bottom:20px}
.hero-panel,.stats-card,.card,.mini-card{
  background:rgba(255,255,255,.92);
  border:1px solid rgba(226,232,240,.88);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}
.hero-panel{padding:28px}
.hero-panel h1,.card h1,.card h2,.card h3{margin:0 0 6px}
.hero-panel p,.muted,.empty{color:var(--muted)}
.hero-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:18px}
.pill-row{display:flex;gap:10px;flex-wrap:wrap;margin-top:18px}
.pill{
  display:inline-flex;align-items:center;gap:8px;
  padding:10px 14px;border-radius:999px;border:1px solid var(--border);
  background:#fff;color:var(--text);font-weight:600
}
.pill.active{background:rgba(37,99,235,.08);border-color:rgba(37,99,235,.25);color:#1d4ed8}
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}
.stats-card{padding:18px}
.stats-card span{display:block;color:var(--muted);font-size:.88rem}
.stats-card strong{display:block;margin-top:6px;font-size:1.55rem;letter-spacing:-.02em}
.card{padding:22px;margin-bottom:18px}
.card-head,.section-title{display:flex;justify-content:space-between;align-items:flex-start;gap:14px;margin-bottom:16px}
.card-head p,.section-title p{margin:4px 0 0;color:var(--muted)}
.stack,.grid,.form-fields{display:grid;gap:14px}
.grid{grid-template-columns:1fr 1fr}
label{display:grid;gap:7px;font-size:.92rem;font-weight:700;color:#1e293b}
input,select,textarea{
  width:100%;border:1px solid var(--border);border-radius:14px;
  background:#fff;padding:12px 13px;font:inherit;color:var(--text);
  outline:none;transition:border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea{min-height:110px;resize:vertical}
input:focus,select:focus,textarea:focus{border-color:#93c5fd;box-shadow:0 0 0 4px rgba(59,130,246,.12)}
.inline{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.btn,.file-trigger,input[type=file]::file-selector-button{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  min-height:46px;padding:0 16px;border-radius:14px;border:1px solid var(--border);
  background:#fff;color:var(--text);font:inherit;font-weight:700;cursor:pointer;
  text-decoration:none;transition:transform .08s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.btn:hover,.file-trigger:hover,input[type=file]::file-selector-button:hover{transform:translateY(-1px);box-shadow:0 8px 24px rgba(15,23,42,.08);text-decoration:none}
.btn:active,.file-trigger:active{transform:translateY(0)}
.btn.primary{background:linear-gradient(135deg,#2563eb,#1d4ed8);border-color:#2563eb;color:#fff}
.btn.secondary{background:#eff6ff;border-color:#bfdbfe;color:#1d4ed8}
.btn.ghost{background:#fff}
.btn.danger{background:#fff;color:var(--danger);border-color:#fecaca}
.link{background:none;border:0;padding:0;color:var(--primary);font:inherit;font-weight:700;cursor:pointer;text-decoration:none}
.link:hover{text-decoration:underline}
.capture-grid{display:grid;grid-template-columns:minmax(0,1.05fr) minmax(320px,.95fr);gap:22px}
.media-box{
  background:linear-gradient(180deg,#f8fafc,#eff6ff);
  border:1px solid var(--border);border-radius:20px;padding:16px;
}
.camera-switch{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:12px}
.file-input{display:block;width:100%;padding:10px;background:#fff;border:1px dashed #bfd2ff;border-radius:16px}
.file-input::file-selector-button{margin-right:12px;background:#eff6ff;border-color:#bfdbfe;color:#1d4ed8}
.capture-hint{margin:8px 0 0;color:var(--muted);font-size:.92rem}
.preview-stage{
  min-height:320px;border:1px dashed #cbd5e1;border-radius:18px;
  background:repeating-linear-gradient(45deg,#f8fafc,#f8fafc 14px,#f1f5f9 14px,#f1f5f9 28px);
  display:grid;place-items:center;overflow:hidden;
}
.preview-stage.empty-state{padding:24px;text-align:center;color:var(--muted)}
.preview-stage video,.preview-stage canvas{display:block;width:100%;height:auto;max-height:560px;object-fit:contain;background:#e2e8f0}
.editor.hidden,.camera-stream.hidden,.preview-tools.hidden,.camera-actions.hidden{display:none}
.editor-actions,.camera-actions,.preview-tools{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}
.section-divider{height:1px;background:linear-gradient(90deg,transparent,#e2e8f0,transparent);margin:14px 0 18px}
.form-fields{grid-template-columns:1fr 1fr;align-content:start}
.wide{grid-column:1/-1}
.helper-card{padding:18px;background:linear-gradient(180deg,#fff,#f8fafc)}
.helper-list{display:grid;gap:8px;margin:0;padding-left:18px;color:var(--muted)}
.helper-list strong{color:var(--text)}
.table-wrap{overflow:auto;border:1px solid var(--border);border-radius:18px}
table{width:100%;border-collapse:separate;border-spacing:0;min-width:840px;background:#fff}
th,td{padding:14px 12px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top}
thead th{background:#f8fafc;color:#475569;font-size:.88rem;text-transform:uppercase;letter-spacing:.03em}
tr:last-child td{border-bottom:0}
.ticket-title{font-weight:700}
.ticket-sub{display:block;color:var(--muted);font-size:.92rem;margin-top:2px}
.thumb{width:56px;height:56px;border-radius:12px;object-fit:cover;border:1px solid var(--border);background:#f8fafc}
.kpi-badge{display:inline-flex;align-items:center;padding:6px 10px;border-radius:999px;background:#eff6ff;color:#1d4ed8;font-weight:700;font-size:.82rem}
.empty{
  padding:24px;border:1px dashed #cbd5e1;border-radius:18px;background:#f8fafc;text-align:center
}
.report-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:14px}
.report-card{padding:18px;border:1px solid var(--border);border-radius:20px;background:linear-gradient(180deg,#fff,#f8fafc)}
.report-card h3{margin:0 0 10px}
.report-meta{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:12px}
.badge{display:inline-flex;align-items:center;padding:6px 10px;border-radius:999px;background:#eff6ff;color:#1d4ed8;font-size:.82rem;font-weight:700}
.badge.closed{background:#f1f5f9;color:#475569}
.alert,.success,.warning{
  padding:13px 14px;border-radius:16px;margin:0 0 14px;border:1px solid transparent
}
.alert{background:var(--danger-bg);color:var(--danger);border-color:#fecaca}
.success{background:var(--success-bg);color:var(--success);border-color:#a7f3d0}
.warning{background:var(--warning-bg);color:var(--warning);border-color:#fed7aa}
.auth-shell{padding:42px 0 60px}
.auth-card{padding:28px}
.auth-top{display:flex;align-items:center;gap:14px;margin-bottom:12px}
.auth-logo{width:54px;height:54px;border-radius:18px;background:linear-gradient(135deg,#2563eb,#0f172a);color:#fff;display:grid;place-items:center;font-weight:800;font-size:1.15rem}
.auth-card p{color:var(--muted)}
code{padding:.15rem .45rem;border-radius:8px;background:#eff6ff;color:#1d4ed8;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
.mobile-only{display:none}
@media(max-width:980px){
  .hero{grid-template-columns:1fr}
  .capture-grid{grid-template-columns:1fr}
  .stats{grid-template-columns:repeat(2,1fr)}
}
@media(max-width:720px){
  .topbar-inner{align-items:flex-start;flex-direction:column}
  .topbar nav{width:100%}
  .grid,.form-fields{grid-template-columns:1fr}
  .stats{grid-template-columns:1fr 1fr}
  .card,.hero-panel,.stats-card{padding:18px}
  .shell,.auth-shell,.topbar-inner{width:min(100vw - 22px,1180px)}
  .mobile-only{display:inline-flex}
}
@media(max-width:520px){
  .stats{grid-template-columns:1fr 1fr;gap:10px}
  .brand-copy strong{font-size:.98rem}
  .brand-mark{width:42px;height:42px}
  .preview-stage{min-height:240px}
  .hero-actions,.pill-row,.editor-actions,.camera-actions,.preview-tools,.inline{flex-direction:column;align-items:stretch}
  .btn,.file-trigger,input[type=file]::file-selector-button{width:100%}
}
.ocr-box{margin-top:14px;padding:16px;border:1px solid #bfdbfe;border-radius:18px;background:#eff6ff}
.ocr-box.hidden{display:none}.ocr-head{display:flex;justify-content:space-between;align-items:center;gap:12px}.ocr-head span{font-weight:800;color:#1d4ed8}.progress{height:9px;margin:10px 0 8px;background:#dbeafe;border-radius:999px;overflow:hidden}.progress span{display:block;height:100%;width:0;background:linear-gradient(90deg,#60a5fa,#1d4ed8);transition:width .2s ease}.ocr-box details{margin-top:8px}.ocr-box summary{cursor:pointer;font-weight:700;color:#1e40af}.ocr-box pre{white-space:pre-wrap;word-break:break-word;background:#fff;border:1px solid #dbeafe;border-radius:12px;padding:12px;max-height:220px;overflow:auto;font-size:.8rem}

/* v1.2.1 — mise en évidence des données réellement récupérées par l'OCR */
.ocr-filled{
  background:#fff3a3 !important;
  border-color:#eab308 !important;
  color:#422006 !important;
  font-weight:800 !important;
  box-shadow:0 0 0 4px rgba(250,204,21,.18) !important;
}
.ocr-filled:focus{
  border-color:#ca8a04 !important;
  box-shadow:0 0 0 4px rgba(250,204,21,.24) !important;
}
.ocr-recovered{
  display:flex;
  flex-wrap:wrap;
  gap:9px;
  margin:12px 0 4px;
}
.ocr-recovered.hidden{display:none}
.ocr-chip{
  display:inline-grid;
  grid-template-columns:auto auto;
  gap:2px 8px;
  align-items:center;
  padding:9px 12px;
  border:1px solid #eab308;
  border-radius:13px;
  background:#fef08a;
  color:#422006;
  font-weight:800;
  box-shadow:0 4px 12px rgba(161,98,7,.08);
}
.ocr-chip strong{font-weight:900}
.ocr-chip small{
  grid-column:1/-1;
  color:#854d0e;
  font-weight:700;
  font-size:.72rem;
}

/* v1.3.0 — recadrage manuel ajustable */
.editor{position:relative;width:100%;line-height:0}
.editor canvas{display:block;width:100%;height:auto}
.crop-layer{
  position:absolute;inset:0;z-index:8;touch-action:none;user-select:none;overflow:hidden;
}
.crop-layer.hidden{display:none}
.crop-shade{position:absolute;background:rgba(2,6,23,.58);pointer-events:none}
.crop-box{
  position:absolute;border:3px solid #facc15;border-radius:8px;
  box-shadow:0 0 0 1px rgba(15,23,42,.45),0 0 26px rgba(250,204,21,.35);
  cursor:move;touch-action:none;
}
.crop-box::after{
  content:"Ticket conservé";position:absolute;left:8px;top:8px;
  padding:5px 8px;border-radius:999px;background:#facc15;color:#422006;
  font-size:11px;font-weight:900;line-height:1.2;letter-spacing:.02em;
}
.crop-handle{
  position:absolute;width:28px;height:28px;border:3px solid #fff;border-radius:50%;
  background:#eab308;box-shadow:0 4px 14px rgba(15,23,42,.3);padding:0;z-index:3;
  touch-action:none;
}
.crop-handle.nw{left:-15px;top:-15px;cursor:nwse-resize}
.crop-handle.ne{right:-15px;top:-15px;cursor:nesw-resize}
.crop-handle.sw{left:-15px;bottom:-15px;cursor:nesw-resize}
.crop-handle.se{right:-15px;bottom:-15px;cursor:nwse-resize}
.crop-grid{position:absolute;background:rgba(255,255,255,.55);pointer-events:none}
.crop-grid-v1,.crop-grid-v2{top:0;bottom:0;width:1px}
.crop-grid-v1{left:33.333%}.crop-grid-v2{left:66.666%}
.crop-grid-h1,.crop-grid-h2{left:0;right:0;height:1px}
.crop-grid-h1{top:33.333%}.crop-grid-h2{top:66.666%}
.crop-workflow{
  display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:14px 0 8px;
}
.crop-step{
  display:grid;grid-template-columns:34px 1fr;grid-template-rows:auto auto;gap:1px 9px;
  align-items:center;padding:11px 12px;border:1px solid #dbeafe;border-radius:15px;background:#f8fbff;
}
.crop-step>span{
  grid-row:1/3;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;
  background:#2563eb;color:#fff;font-weight:900;line-height:1;
}
.crop-step strong{font-size:.86rem;line-height:1.2}
.crop-step small{color:#64748b;font-size:.76rem;line-height:1.25}
@media(max-width:760px){
  .crop-workflow{grid-template-columns:1fr}
  .crop-handle{width:34px;height:34px}
  .crop-handle.nw{left:-18px;top:-18px}.crop-handle.ne{right:-18px;top:-18px}
  .crop-handle.sw{left:-18px;bottom:-18px}.crop-handle.se{right:-18px;bottom:-18px}
}

/* v1.4.0 — navigation par onglets, capture HD et ergonomie */
.hidden{display:none!important}
.dashboard-head{
  display:flex;align-items:flex-end;justify-content:space-between;gap:18px;
  margin:0 0 18px;padding:6px 2px;
}
.dashboard-head h1{margin:6px 0 2px;font-size:clamp(1.45rem,2.5vw,2rem);letter-spacing:-.025em}
.dashboard-head p{margin:0}
.compact-pills{justify-content:flex-end;margin:0}
.app-tabs{
  position:sticky;top:78px;z-index:20;display:flex;gap:8px;align-items:center;
  margin:0 0 18px;padding:8px;border:1px solid var(--border);border-radius:18px;
  background:rgba(255,255,255,.92);box-shadow:0 10px 30px rgba(15,23,42,.07);backdrop-filter:blur(16px)
}
.app-tab{
  appearance:none;border:0;background:transparent;color:#475569;cursor:pointer;
  display:inline-flex;align-items:center;gap:9px;padding:11px 15px;border-radius:13px;
  font:inherit;font-weight:800;white-space:nowrap
}
.app-tab span{width:26px;height:26px;border-radius:9px;display:grid;place-items:center;background:#e2e8f0;color:#475569;font-size:.82rem}
.app-tab b{min-width:22px;height:22px;padding:0 6px;border-radius:999px;display:grid;place-items:center;background:#e2e8f0;font-size:.75rem}
.app-tab.active{background:#eff6ff;color:#1d4ed8}
.app-tab.active span,.app-tab.active b{background:#2563eb;color:#fff}
.tab-panel{display:none}
.tab-panel.active{display:block}
.quality-badge{display:inline-flex;align-items:center;padding:8px 11px;border-radius:999px;background:#f8fafc;border:1px solid var(--border);color:#475569;font-weight:800;font-size:.82rem;white-space:nowrap}
.crop-note{margin:14px 0 10px;padding:12px 14px;border:1px solid #bfdbfe;border-radius:15px;background:#eff6ff;color:#1e40af;font-size:.9rem;line-height:1.45}
.form-side{align-content:start}
.save-ticket-btn{width:100%;min-height:56px;height:56px;align-self:start;font-size:1rem}
.data-check{padding:13px 14px;border:1px solid #fde68a;border-radius:15px;background:#fffbeb;color:#78350f}
.data-check strong{display:block;margin-bottom:3px}
.data-check p{margin:0;font-size:.88rem}
#amountHt[readonly]{background:#f8fafc;color:#475569}
.export-grid{display:grid;grid-template-columns:1.2fr .8fr;gap:18px;margin-bottom:18px}
.export-card{display:grid;grid-template-columns:auto 1fr;gap:18px;padding:24px;border:1px solid var(--border);border-radius:22px;background:#fff;box-shadow:var(--shadow)}
.export-card.featured{border-color:#bfdbfe;background:linear-gradient(135deg,#fff,#eff6ff)}
.export-card h2{margin:0 0 6px}
.export-card p{color:var(--muted);margin:0 0 16px}
.export-icon{width:70px;height:70px;border-radius:20px;display:grid;place-items:center;background:#2563eb;color:#fff;font-weight:900;letter-spacing:.04em;box-shadow:0 12px 30px rgba(37,99,235,.22)}
.export-icon.zip{background:#0f172a}
.export-stats{display:flex;gap:8px;flex-wrap:wrap;margin:0 0 16px}
.export-stats span{padding:7px 10px;border-radius:999px;background:#fff;border:1px solid var(--border);font-size:.86rem;font-weight:700}
.export-advice h3{margin-top:0}.export-advice p{margin-bottom:0;color:var(--muted)}
@media(max-width:860px){
  .dashboard-head{align-items:flex-start;flex-direction:column}
  .compact-pills{justify-content:flex-start}
  .app-tabs{top:8px;overflow:auto;justify-content:flex-start;-webkit-overflow-scrolling:touch}
  .export-grid{grid-template-columns:1fr}
}
@media(max-width:560px){
  .app-tabs{margin-left:-3px;margin-right:-3px}
  .app-tab{padding:10px 12px}
  .app-tab span{display:none}
  .export-card{grid-template-columns:1fr;padding:18px}
  .export-icon{width:58px;height:58px;border-radius:17px}
  .camera-switch .btn{width:100%}
}

/* v1.5.0 — validation photo avant OCR */
.photo-review{
  margin:14px 0 10px;
  padding:14px;
  border:1px solid #bfdbfe;
  border-radius:18px;
  background:linear-gradient(135deg,#eff6ff,#ffffff);
  box-shadow:0 10px 28px rgba(37,99,235,.08);
}
.photo-review-copy{display:grid;gap:4px;margin-bottom:12px}
.photo-review-copy strong{font-size:.98rem;color:#1e3a8a}
.photo-review-copy span{font-size:.88rem;color:#475569;line-height:1.45}
.photo-review-buttons{display:flex;gap:9px;flex-wrap:wrap}
.photo-review-buttons .btn{min-height:44px}
@media(max-width:620px){
  .photo-review-buttons{display:grid;grid-template-columns:1fr}
  .photo-review-buttons .btn{width:100%}
}
