/* Arkanos : thème de l'outil, posé par-dessus l'admin Django.
   Vert forêt, papier, vert d'eau ; un seul thème clair. */

html:root, html[data-theme] {
  color-scheme: light;
  --foret: #0F2A23;
  --foret-actif: #1D4237;
  --papier: #EEEDE6;
  --encre: #13211C;
  --discret: #4C5A53;
  --eau: #7FD1C0;
  --ocre: #F2B54A;
  --alerte: #A23A16;
  --trait: #ECEBE4;
  --bord: #D9D8CF;

  --primary: var(--foret);
  --secondary: var(--foret-actif);
  --accent: var(--eau);
  --primary-fg: #FFFFFF;
  --body-fg: var(--encre);
  --body-bg: var(--papier);
  --body-quiet-color: var(--discret);
  --body-medium-color: #3D4842;
  --body-loud-color: #000;
  --header-color: #CFDCD5;
  --header-branding-color: #FFFFFF;
  --header-bg: var(--foret);
  --header-link-color: #FFFFFF;
  --breadcrumbs-fg: var(--discret);
  --breadcrumbs-link-fg: #155E86;
  --breadcrumbs-bg: transparent;
  --link-fg: #155E86;
  --link-hover-color: #0D4463;
  --link-selected-fg: var(--foret);
  --hairline-color: var(--trait);
  --border-color: var(--bord);
  --error-fg: var(--alerte);
  --message-success-bg: #DCEFE6;
  --message-warning-bg: #FBEBD3;
  --message-error-bg: #F6DED4;
  --darkened-bg: #F6F5F0;
  --selected-bg: #E6EEF5;
  --selected-row: #FFF6E0;
  --button-fg: #FFFFFF;
  --button-bg: var(--foret);
  --button-hover-bg: var(--foret-actif);
  --default-button-bg: var(--foret);
  --default-button-hover-bg: var(--foret-actif);
  --close-button-bg: #8E9A93;
  --close-button-hover-bg: #6B7871;
  --delete-button-bg: var(--alerte);
  --delete-button-hover-bg: #7E2C10;
  --object-tools-fg: #FFFFFF;
  --object-tools-bg: var(--foret);
  --object-tools-hover-bg: var(--foret-actif);
  --font-family-primary: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-family-monospace: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

.theme-toggle { display: none !important; }

body { background: var(--papier); font-size: 15px; }

h1, h2, #site-name, .ak-titre {
  font-family: "Bricolage Grotesque", var(--font-family-primary);
  letter-spacing: -0.02em;
}
#content h1 { font-weight: 700; font-size: 30px; color: var(--encre); margin-bottom: 18px; }

/* En-tête */
#header { padding: 12px 24px; gap: 12px; }
#site-name a { display: inline-flex; align-items: center; gap: 10px; }
#site-name .ak-nom { font-weight: 700; font-size: 21px; color: #FFFFFF; }
#site-name .ak-sous { display: block; font-family: var(--font-family-primary); font-size: 10px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase; color: #8FA79C; }
#user-tools { font-size: 12px; text-transform: none; letter-spacing: 0; }
#logout-form button { text-transform: none; font-size: 12px; }
#user-tools a, #logout-form button { border-bottom: none; color: #FFFFFF; text-decoration: underline; text-underline-offset: 3px; }

div.breadcrumbs { padding: 14px 40px 0; font-size: 13px; }

/* Barre latérale */
#nav-sidebar { background: var(--foret); border-right: none; }
#nav-sidebar .module, #nav-sidebar .module caption, #nav-sidebar .module th, #nav-sidebar .module td { background: transparent; }
#nav-sidebar .module caption { color: #8FA79C; font-size: 11px; letter-spacing: 0.08em; }
#nav-sidebar .module caption a { color: #8FA79C; }
#nav-sidebar th a, #nav-sidebar td a { color: #CFDCD5; }
#nav-sidebar .current-model { background: var(--foret-actif); }
#nav-sidebar .current-model a { color: #FFFFFF; }
#nav-filter { background: #16332B; border-color: #2B4A40; color: #FFFFFF; }
#nav-sidebar .module { border-radius: 0; overflow: visible; }
#nav-sidebar tr, #nav-sidebar tr:nth-child(even) { background: transparent !important; }
#nav-sidebar .module caption { padding: 8px 10px; font-size: 11px; }
#nav-sidebar .current-model td, #nav-sidebar .current-model th { background: var(--foret-actif); }
#nav-sidebar th, #nav-sidebar td { border-bottom-color: #22463B; }
.toggle-nav-sidebar { background: var(--foret); border-color: var(--foret); color: var(--eau); }

/* Cartes */
.module, fieldset.module, .inline-group { background: #FFFFFF; border-radius: 16px; overflow: hidden; border: none; }
.module h2, .module caption, .inline-group h2 {
  background: #FFFFFF; color: var(--encre); font-size: 17px; font-weight: 700;
  text-transform: none; letter-spacing: -0.01em; padding: 14px 16px 8px;
}
.module caption a, .module h2 a, a.section:link, a.section:visited { color: var(--encre); }
.app-list .module caption, .dashboard .module caption { padding: 16px 16px 8px; font-size: 17px; text-align: left; }
fieldset.module h2 { border-bottom: 1px solid var(--trait); }
.module table { width: 100%; }
thead th, tfoot td { background: #F6F5F0; color: var(--discret); text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; border: none; }
tr:nth-child(odd), .row-form-errors { background: #FFFFFF; }
tr:nth-child(even), tr:nth-child(even) .errorlist, tr:nth-child(odd) + .row-form-errors { background: #FAF9F5; }
td, th { border-bottom-color: var(--trait); }

/* Boutons et champs : faits pour le doigt */
.button, input[type=submit], input[type=button], .submit-row input, a.button, button.button {
  min-height: 44px; padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
}
.submit-row { background: transparent; border: none; padding: 14px 0; gap: 10px; }
.submit-row a.deletelink { min-height: 44px; height: 44px; box-sizing: border-box; padding: 0 18px; display: inline-flex; align-items: center; border-radius: 12px; }
input[type=text], input[type=search], input[type=number], input[type=email], input[type=password], input[type=url],
input[type=date], input[type=tel], textarea, select, .vTextField {
  border-radius: 10px; border: 1px solid var(--bord); padding: 8px 10px; min-height: 40px; box-sizing: border-box; font-size: 15px;
}
select { padding: 6px 8px; }
.object-tools a:link, .object-tools a:visited { border-radius: 12px; padding: 10px 16px; font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.object-tools { display: flex; gap: 8px; margin-top: 0; }
.object-tools li { display: flex; }
.object-tools a.addlink { padding-right: 34px; background-position: right 12px center; }
#changelist #toolbar { background: transparent; border: none; }
#changelist-filter { background: #FFFFFF; border-radius: 16px; }
#changelist-filter h2 { background: #FFFFFF; color: var(--encre); }
.paginator { border-top: none; }
ul.messagelist li { border-radius: 12px; margin: 0 0 8px; color: var(--encre); }

/* ---------- Tableau de bord ---------- */
.ak { display: flex; flex-direction: column; gap: 22px; }
.ak a { text-decoration: none; }
.ak-entete { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; }
.ak-entete h1 { margin: 0 !important; font-size: 34px !important; }
.ak-date { font-size: 13px; color: var(--discret); }
.ak-scanner { display: inline-flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 20px; border-radius: 12px;
  background: var(--foret); color: #FFFFFF !important; font-weight: 600; }
.ak-scanner:hover { background: var(--foret-actif); }
.ak-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 14px; }
.ak-kpi { display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: 16px; background: #FFFFFF; color: var(--encre) !important; }
.ak-kpi .ak-l { font-size: 13px; font-weight: 500; }
.ak-kpi .ak-v { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 44px; line-height: 1; letter-spacing: -0.02em; }
.ak-kpi .ak-d { font-size: 12px; opacity: .9; }
.ak-kpi.ocre { background: var(--ocre); color: #1B1405 !important; }
.ak-kpi.foret { background: var(--foret); color: #FFFFFF !important; }
.ak-kpi.alerte { color: var(--alerte) !important; }
.ak-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 16px; }
.ak-carte { background: #FFFFFF; border-radius: 16px; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.ak-carte h2 { margin: 0; font-size: 19px; font-weight: 700; color: var(--encre); background: none; padding: 0; text-transform: none; }
.ak-carte-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ak-carte-tete a { font-size: 13px; font-weight: 500; }
.ak-liste { list-style: none; margin: 0; padding: 0; }
.ak-liste li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--trait); list-style: none; }
.ak-point { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }
.ak-point.ocre { background: #C77A10; } .ak-point.bleu { background: #155E86; }
.ak-point.rouge { background: var(--alerte); } .ak-point.vert { background: #1F7A5C; }
.ak-quoi { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ak-quoi strong { font-weight: 600; }
.ak-quoi span, .ak-vide { font-size: 13px; color: var(--discret); }
.ak-action { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 10px;
  background: #EEF4F7; color: #155E86 !important; font-weight: 600; font-size: 13px; }
.ak-of { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: 12px; background: #F6F5F0; color: var(--encre) !important; }
.ak-mono { font-family: var(--font-family-monospace); }
.ak-sous-titre { margin: 6px 0 0; font-size: 12px; font-weight: 600; color: var(--discret); text-transform: uppercase; letter-spacing: 0.06em; }
.ak-bas { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; color: var(--encre) !important; }
.ak-bas .ak-mono { color: var(--alerte); font-weight: 500; }
.ak-table { width: 100%; min-width: 600px; border-collapse: collapse; }
.ak-table th { background: none; text-align: left; padding: 8px; }
.ak-table td { padding: 12px 8px; border-top: 1px solid var(--trait); border-bottom: none; vertical-align: middle; background: #FFFFFF; }
.ak-table td small { display: block; font-size: 12px; color: var(--discret); }
.ak-pastille { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.ak-pastille.diag { background: #FBEBD3; color: #7A4306; }
.ak-pastille.piece { background: #E6EEF5; color: #155E86; }
.ak-pastille.ok { background: #DCEFE6; color: #145A42; }
.ak-pastille.rebut { background: #ECEBE4; color: #3D4842; }
.ak-defile { overflow-x: auto; }
.ak-modules { margin-top: 6px; }
.dashboard #content { width: auto; max-width: 1280px; }
.dashboard .module table th { width: auto; }

/* ---------- Écrans de scan ---------- */
.ak-scan { max-width: 480px; display: flex; flex-direction: column; gap: 18px; }
.ak-scan.sombre { background: #0A1D18; color: #FFFFFF; border-radius: 24px; padding: 24px 20px; }
.ak-scan h1 { margin: 0 !important; line-height: 1.1; }
.ak-scan.sombre h1 { color: #FFFFFF !important; }
.ak-surtitre { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: #A9BDB3; }
.ak-camera { position: relative; min-height: 260px; border-radius: 20px; background: #17302A; overflow: hidden;
  display: flex; align-items: center; justify-content: center; }
.ak-camera #camera { width: 100%; }
.ak-camera #camera video { display: block; width: 100% !important; }
.ak-camera .ak-ouvrir { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: transparent; border: none; color: #CFDCD5; font: inherit; font-size: 14px; cursor: pointer; }
.ak-viseur { width: 150px; height: 150px; border: 3px solid var(--eau); border-radius: 18px; }
.ak-scan label { font-size: 13px; color: var(--discret); font-weight: 400; }
.ak-scan.sombre label { color: #A9BDB3; }
.ak-saisie { display: flex; gap: 8px; }
.ak-saisie input[type=text] { flex-grow: 1; min-width: 0; height: 52px; padding: 0 16px; border-radius: 14px; font-family: var(--font-family-monospace); font-size: 17px; }
.ak-scan.sombre .ak-saisie input[type=text] { background: #102620; border-color: #2B4A40; color: #FFFFFF; }
.ak-saisie input[type=submit] { height: 52px; border-radius: 14px; padding: 0 18px; }
.ak-scan.sombre .ak-saisie input[type=submit] { background: var(--eau); color: #0A1D18; }
.ak-etape { margin: 0; font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 22px; }
.ak-lampe { align-self: flex-start; }
.ak-lampe[aria-pressed="true"] { background: #F2C14E; color: #0A1D18; }
.ak-retour { margin: 0; padding: 12px 14px; border-radius: 12px; font-weight: 600; }
.ak-retour.ok { background: #DDF2EA; color: #14553F; }
.ak-retour.erreur { background: #FBE3E1; color: #8E1F16; }
.ak-terminer { display: flex; align-items: center; justify-content: center; }
.ak-scan select { width: 100%; height: 48px; border-radius: 12px; }
.ak-scan .errornote { border-radius: 12px; margin: 0; }
.ak-progression { background: #FFFFFF; border-radius: 18px; padding: 4px 16px; }
.ak-ligne { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--trait); }
.ak-ligne:first-child { border-top: none; }
.ak-ligne-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ak-ligne-tete strong { font-weight: 600; }
.ak-compte { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 22px; }
.ak-compte small { font-size: 15px; color: var(--discret); font-weight: 400; }
.ak-barre { height: 8px; border-radius: 999px; background: var(--trait); overflow: hidden; }
.ak-barre span { display: block; height: 8px; border-radius: 999px; background: #C77A10; }
.ak-barre span.complet { background: #1F7A5C; }
.ak-puces { display: flex; flex-wrap: wrap; gap: 6px; }
.ak-puces a { font-family: var(--font-family-monospace); font-size: 13px; padding: 6px 10px; border-radius: 8px; background: #FFFFFF;
  border: 1px solid #DCDBD2; color: var(--encre); text-decoration: none; }

/* ---------- Bouton caméra à côté des champs ---------- */
.ak-bouton-scan { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-left: 6px;
  vertical-align: middle; border: 1px solid #DCDBD2; border-radius: 10px; background: #FFFFFF; color: var(--foret, #0F2A23); cursor: pointer; }
.ak-bouton-scan:hover { border-color: var(--eau); }
.ak-lecteur { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(10, 29, 24, 0.85); }
.ak-lecteur-boite { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 12px;
  background: #0A1D18; color: #FFFFFF; border-radius: 20px; padding: 18px 16px; }
.ak-lecteur-boite p { margin: 0; color: #CFDCD5; }
.ak-lecteur-cadre { border-radius: 12px; background: #000000; }
/* Zoom ×2 : la caméra est affichée deux fois plus grande, centrée et rognée par son cadre. */
.ak-cadre-zoom { position: relative; overflow: hidden; height: min(60vh, 420px); }
/* La bibliothèque met position: relative sur l'élément : on la force. */
.ak-zoom { position: absolute !important; left: 50%; top: 50%; width: 200% !important; transform: translate(-50%, -50%); }
.ak-zoom video { display: block; width: 100% !important; }

@media (max-width: 767px) {
  .ak-simulation { min-width: 0; }
  .ak-simulation .ak-option { display: none; }
  #header { padding: 10px 16px; }
  div.breadcrumbs { padding: 10px 16px 0; }
  #content { padding: 16px; }
  .ak-entete h1 { font-size: 28px !important; }
  .ak-kpi .ak-v { font-size: 36px; }
  .ak-scan.sombre { padding: 20px 16px; border-radius: 20px; }
}
