/* ========================================================================
   Interface de l'application
   Page d'accueil, panneau d'options, tableaux d'aperçu, barre
   d'édition, personnalisation. La fiche client elle-même est décrite
   dans fiche.css.
   ======================================================================== */

:root {
  --bg: #EEF1F8;
  --card: #fff;
  --ink: #1B2147;
  --mute: #5E6584;
  --line: #DCE1EE;
  --brand: #2B3A8C;
  --brand-ink: #fff;
  --teal: #0E8F80;
  --head: #F3F5FB;
  --shadow: 0 1px 2px rgba(27, 33, 71, .06), 0 8px 24px rgba(27, 33, 71, .06);
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px)
}

@media (prefers-color-scheme:dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12162B;
    --card: #1B2140;
    --ink: #EAEDFA;
    --mute: #A3AACB;
    --line: #2D3560;
    --brand: #8E9CFF;
    --brand-ink: #12162B;
    --teal: #4FD1BE;
    --head: #222A52;
    --shadow: none
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12162B;
  --card: #1B2140;
  --ink: #EAEDFA;
  --mute: #A3AACB;
  --line: #2D3560;
  --brand: #8E9CFF;
  --brand-ink: #12162B;
  --teal: #4FD1BE;
  --head: #222A52;
  --shadow: none
}

* {
  box-sizing: border-box
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px)
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 Manrope, system-ui, sans-serif
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 20px 64px
}

h1,
h2,
h3 {
  font-family: Fraunces, Georgia, serif;
  margin: 0;
  line-height: 1.15
}

h1 {
  font-size: clamp(32px, 5.5vw, 52px);
  font-weight: 700;
  letter-spacing: -.02em;
  max-width: 16ch
}

.lead {
  color: var(--mute);
  max-width: 56ch;
  margin: 14px 0 28px;
  font-size: 17px
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow)
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 36px 20px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: var(--card);
  text-align: center;
  cursor: pointer
}

.drop:hover,
.drop.over {
  border-color: var(--brand);
  background: var(--head)
}

.drop span {
  color: var(--mute);
  font-size: 14px
}

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  background: var(--brand);
  color: var(--brand-ink)
}

button.ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line)
}

button:disabled {
  opacity: .55;
  cursor: wait
}

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

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center
}

.sp {
  justify-content: space-between
}

#work {
  display: none;
  margin-top: 28px
}

.panel {
  padding: 20px;
  margin-bottom: 20px
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0 14px
}

.tab {
  background: var(--head);
  color: var(--ink);
  padding: 6px 12px;
  font-size: 14px;
  border: 1px solid var(--line)
}

.tab[aria-selected="true"] {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand)
}

.meta {
  color: var(--mute);
  font-size: 14px
}

.scroll {
  overflow-x: auto
}

.panel .scroll {
  border: 1px solid var(--line);
  border-radius: 10px
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px
}

th,
td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap
}

th {
  background: var(--head);
  font-weight: 700
}

tr:last-child td {
  border-bottom: 0
}

td.n,
th.n {
  text-align: right;
  font-variant-numeric: tabular-nums
}

.feats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: -8px 0 26px
}

.feats div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-size: 14px;
  color: var(--mute)
}

.feats b {
  display: block;
  color: var(--ink);
  font-size: 15px;
  margin-bottom: 2px
}

.opts select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink)
}

.opts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line)
}

.opts label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--mute)
}

.opts input[type=text] {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink)
}

.sw {
  display: flex;
  gap: 8px;
  align-items: center
}

.sw button {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid var(--card);
  box-shadow: 0 0 0 1px var(--line)
}

.sw button[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--ink)
}

.sw {
  flex-wrap: wrap
}

.sw input[type=color] {
  width: 42px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  cursor: pointer
}

.sw .opts input[type=text],
.sw #o-hex {
  width: 92px;
  padding: 6px 8px;
  font-size: 13px
}

.note {
  background: var(--head);
  color: var(--mute);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px
}

.dup {
  margin-bottom: 20px;
  padding: 16px 20px;
  border-radius: 14px;
  color: var(--ink);
  background: color-mix(in srgb, #E8A100 14%, var(--card));
  border: 1px solid color-mix(in srgb, #E8A100 55%, var(--line))
}

.dup.ok {
  background: color-mix(in srgb, var(--teal) 12%, var(--card));
  border-color: color-mix(in srgb, var(--teal) 50%, var(--line))
}

.dup h3 {
  font-size: 19px;
  margin-bottom: 6px
}

.dup p {
  margin: 4px 0
}

.dup details {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px
}

.dup summary {
  cursor: pointer;
  font-size: 14px
}

.dup .scroll {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px
}

.tag {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--head);
  margin-left: 6px
}

.tag.w {
  background: color-mix(in srgb, #E8A100 35%, var(--card))
}

td.df {
  background: color-mix(in srgb, #E8A100 30%, transparent);
  font-weight: 700
}

#edbar select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink)
}

.fiche.editing [contenteditable=true]:hover {
  outline: 1px dashed var(--acc);
  outline-offset: 3px
}

.fiche.editing [contenteditable=true]:focus {
  outline: 2px solid var(--acc)
}

.fiche.editing .bd>div,
.fiche.editing .gr>.cc,
.fiche.editing .kp>.k {
  position: relative;
  outline: 1px dashed color-mix(in srgb, var(--acc) 40%, transparent);
  outline-offset: 6px
}

.ed {
  position: absolute;
  top: -14px;
  right: 6px;
  display: flex;
  gap: 3px;
  z-index: 3
}

.ed button {
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--brand);
  color: var(--brand-ink)
}

.ed button[data-a=del] {
  background: #B4234A;
  color: #fff
}

.ed button[data-a=drag] {
  cursor: grab;
  touch-action: none;
  background: var(--ink);
  color: var(--card)
}

.fiche.editing .rz2 {
  position: absolute;
  right: -9px;
  bottom: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
  cursor: nwse-resize;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  z-index: 4;
  touch-action: none
}

.fiche.dragging-on {
  user-select: none
}

.fiche .blk-drag {
  opacity: .55;
  outline: 2px solid var(--acc) !important
}

#fiche .lw {
  cursor: grab;
  touch-action: none
}

#fiche .lw:hover {
  outline: 2px dashed rgba(127, 127, 127, .8);
  outline-offset: 3px
}

#fiche .rz {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand);
  cursor: nwse-resize;
  display: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3)
}

#fiche .lw:hover .rz,
#fiche[data-lgpos=free] .rz {
  display: block
}

#perso {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line)
}

#perso>summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px
}

#perso .grp {
  margin-top: 14px
}

#perso .grp>b {
  font-size: 13px;
  color: var(--mute)
}

#perso .opts {
  margin-top: 8px;
  padding-top: 0;
  border-top: 0
}

#perso .ck {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ink)
}

#perso input[type=range] {
  width: 100%;
  accent-color: var(--brand)
}

.fiche .ax {
  position: static !important;
  display: flex !important;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--mute);
  opacity: 1 !important;
  transform: none !important
}

.fiche .ax label {
  display: flex;
  gap: 6px;
  align-items: center
}

.fiche .ax select {
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  max-width: 150px
}

body {
  background: radial-gradient(1100px 480px at 88% -8%, color-mix(in srgb, var(--brand) 15%, transparent), transparent), radial-gradient(800px 420px at -8% 8%, color-mix(in srgb, var(--teal) 13%, transparent), transparent), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased
}

h1 {
  background: linear-gradient(120deg, var(--ink), var(--brand));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent
}

.card,
.panel {
  border-radius: 20px
}

.panel {
  box-shadow: var(--shadow)
}

button {
  transition: transform .15s, box-shadow .15s, background .15s
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 32%, transparent)
}

button:active {
  transform: none
}

button.ghost:hover:not(:disabled) {
  background: var(--head);
  box-shadow: none
}

.up {
  display: flex;
  flex-wrap: wrap;
  gap: 14px
}

.up-i {
  flex: 1 1 260px;
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--mute)
}

.up-d {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  background: #fff;
  transition: border-color .15s, background .15s
}

.up-d:hover,
.up-d.drag {
  border-color: var(--brand);
  background: var(--head)
}

.opts .up-l {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink, #1B2147)
}

.up-l small {
  display: block;
  font-weight: 500;
  font-size: 12px;
  color: var(--mute);
  margin-top: 2px
}

.up-t {
  width: 46px;
  height: 46px;
  border-radius: 11px;
  background: var(--head);
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 24px;
  font-weight: 700;
  overflow: hidden;
  flex: none
}

.up-t img {
  width: 100%;
  height: 100%;
  object-fit: contain
}

.up-x {
  border: 0;
  background: transparent;
  color: var(--mute);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 9px;
  box-shadow: none
}

.up-x:hover {
  background: var(--head);
  color: var(--brand)
}

.tab {
  border-radius: 99px
}

.drop {
  border-radius: 24px;
  padding: 52px 20px;
  background: linear-gradient(180deg, var(--card), var(--head));
  transition: transform .2s, border-color .2s
}

.drop:hover,
.drop.over {
  transform: translateY(-2px)
}

input[type=range] {
  accent-color: var(--brand)
}

#perso-body .grp {
  background: var(--head);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px
}

#perso-body .grp>b {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--mute)
}

.themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px
}

button.th {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px
}

button.th i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c);
  flex: none
}

button.th:hover:not(:disabled) {
  border-color: var(--c);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--c) 25%, transparent)
}

/* ========================================================================
   Contrôle des données et analyse IA
   ======================================================================== */
.diag {
  margin-bottom: 20px;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.diag h3 {
  font-size: 19px;
}

.diag-l,
.ia-l {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
}

.diag-l li {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--head);
  border-left: 4px solid var(--teal);
}

.diag-l li span {
  color: var(--mute);
  font-size: 14px;
}

.diag-l li button {
  justify-self: start;
  margin-top: 6px;
  padding: 5px 12px;
  font-size: 13px;
}

.diag-l li.d-haute {
  border-left-color: #B4234A;
}

.diag-l li.d-moyenne {
  border-left-color: #E8A100;
}

#ia {
  margin-bottom: 20px;
}

.ia-card {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--head);
  border: 1px solid var(--line);
}

.ia-card h4 {
  margin: 16px 0 4px;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--mute);
}

.ia-card .diag-l li {
  background: var(--card);
}

.sum-ia {
  margin: 8px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--brand);
}

.ia-l li span {
  color: var(--mute);
}
/* Édition ligne par ligne : croix de suppression sur chaque puce / point d'attention, bouton d'ajout */
.fiche.editing .facts>li,
.fiche.editing .bd [data-sec=al] .al {
  position: relative;
  padding-right: 44px
}

.ed.ed-l {
  top: 50%;
  right: 10px;
  transform: translateY(-50%)
}

.ed.ed-l button {
  background: #B4234A;
  color: #fff;
  padding: 2px 8px
}

.edadd {
  margin: 8px 0 0;
  padding: 6px 14px;
  font-size: 13px
}

/* Panneau « Ce que j'ai compris de votre classeur » */
.cl-ctl {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px
}

.cl-ctl summary {
  cursor: pointer;
  font-weight: 700
}

/* Indicateur de chargement */
.chargement {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid color-mix(in srgb, var(--brand, #2B3A8C) 25%, transparent);
  border-top-color: var(--brand, #2B3A8C);
  border-radius: 50%;
  animation: tourne .8s linear infinite
}

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

.drop.busy {
  opacity: .6;
  pointer-events: none
}

@media (prefers-reduced-motion: reduce) {
  .chargement {
    animation-duration: 2.4s
  }
}


/* ---- Essai gratuit / abonnement (js/23-acces.js) ---- */
.acces-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px
}
.acces-bar.fini { border-left-color: #C0392B }
.acces-bar button { padding: 6px 14px; font-size: 13px }
body.essai #dl::after, body.essai #dlall::after, body.essai #save-prj::after { content: " \1F512"; font-size: .85em }
body.essai-fini #go { opacity: .8 }

/* Filigrane de l'aperçu pendant l'essai */
body.essai #fiche { position: relative }
body.essai #fiche::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='380' height='240'%3E%3Ctext x='190' y='125' text-anchor='middle' transform='rotate(-28 190 120)' font-family='Arial,sans-serif' font-size='22' font-weight='700' fill='rgba(30,40,70,0.08)'%3EAPER%C3%87U %E2%80%94 ESSAI GRATUIT%3C/text%3E%3C/svg%3E") repeat
}

/* Impression bloquée pendant l'essai */
@media print {
  body.essai #out, body.essai #work { display: none !important }
  body.essai::before { content: "Impression réservée aux abonnés."; display: block; padding: 40px; font: 600 18px sans-serif }
}

/* Fenêtre « Abonnez-vous » */
dialog.abo {
  border: 0;
  border-radius: 14px;
  padding: 0;
  max-width: min(460px, calc(100vw - 32px));
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3)
}
dialog.abo::backdrop { background: rgba(15, 20, 40, .55) }
.abo-c { padding: 22px 22px 18px }
.abo-c h2 { margin: 0 0 8px; font-size: 21px }
.abo-c p { margin: 0 0 10px; color: var(--mute); line-height: 1.5 }
.abo-c ul { margin: 0 0 18px; padding-left: 20px; line-height: 1.7 }
.abo-prix { font-size: 20px; font-weight: 700; color: var(--ink) !important }
