:root {
  --bg: #F1F4EF; --panel: #F9FAF8; --white: #FFFFFF; --ink: #13270A; --text: #4F574A;
  --green: #306019; --tint: #DCE7D5; --ochre: #E19D56; --ochre-tint: #F6E3CC; --line: #C3CCBD;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; }
a { color: var(--green); }
a:hover { color: var(--ink); }
h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 500; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
h3 { margin: 0; font-size: 15px; font-weight: 600; }
p { margin: 0; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--text); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.center { text-align: center; align-self: center; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; }

/* Structure */
.shell { max-width: 1440px; margin: 0 auto; padding: 20px; display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.side { flex: 1 1 200px; max-width: 240px; background: var(--white); border-radius: 24px; padding: 24px 14px; display: flex; flex-direction: column; gap: 6px; }
.brand { font-size: 20px; font-weight: 700; padding: 0 10px 18px; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 22px; background: none; color: var(--text); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; width: 100%; text-align: left; }
.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link.is-active { background: var(--ink); color: var(--white); font-weight: 600; }
.side-end { margin-top: 28px; }
.main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.topbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px; background: var(--white); border-radius: 22px; color: var(--ink); text-decoration: none; }
.user-pill { padding-left: 6px; }
.avatar { width: 32px; height: 32px; border-radius: 16px; background: var(--green); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.user-text { display: flex; flex-direction: column; line-height: 1.2; }
.user-text small { color: var(--text); }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.round { width: 44px; height: 44px; border-radius: 22px; background: var(--white); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; }
.panel { background: var(--white); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.panel-dark { background: var(--ink); color: var(--bg); }
.panel-tint { background: var(--tint); }
.on-dark-muted { color: #C3CCBD; }
.empty { align-items: flex-start; }
.flash { padding: 12px 16px; border-radius: 16px; background: var(--tint); color: #1F4310; font-weight: 500; }
.flash-warn { background: var(--ochre-tint); color: #6B3F0E; border: 1px solid #A8672A; }

/* Boutons et champs */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 22px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn-dark { background: var(--ink); color: var(--white); }
.btn-dark:hover { background: var(--green); color: var(--white); }
.btn-accent { background: var(--ochre); color: var(--ink); font-weight: 700; }
.btn-light { background: var(--white); color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn-light:hover { background: var(--bg); color: var(--ink); }
.btn-wide { width: 100%; min-height: 48px; }
.btn-link { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--text); font: inherit; text-decoration: underline; cursor: pointer; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=file], select, textarea, .input {
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 22px; background: var(--white); color: var(--ink); font: inherit; font-weight: 400; width: 100%; min-width: 0; }
textarea { padding: 12px 16px; border-radius: 16px; resize: vertical; }
input[type=file] { padding: 9px 16px; }
input[readonly] { background: var(--bg); color: var(--text); }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { padding: 0; font-weight: 500; margin-bottom: 6px; }

/* Indicateurs */
.kpis { display: flex; flex-wrap: wrap; gap: 14px; }
.kpi { flex: 1 1 170px; background: var(--white); border-radius: 20px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; font-weight: 600; }
.kpi strong { font-size: 32px; line-height: 1; }
.kpi-tint { background: var(--tint); }
.kpi-add { background: none; border: 1.5px dashed var(--text); align-items: center; justify-content: center; color: var(--ink); text-decoration: none; }
.plus { width: 36px; height: 36px; border-radius: 18px; background: var(--ink); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 400; }
.kpi-wide { flex: 2 1 320px; }
.statuses { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.st { border-radius: 10px; padding: 6px 10px; display: flex; flex-direction: column; font-weight: 400; }
.st small { font-size: 12px; }
.st b { font-size: 18px; line-height: 1.2; }
.st-sent { background: var(--tint); }
.st-queued { background: var(--ochre); }
.st-draft { background: var(--bg); }
.st-auto { background: var(--ink); color: var(--white); }

/* Canaux : couleur, bordure et lettre, jamais la couleur seule */
.ch-email { background: var(--tint); color: #1F4310; border: 1px solid var(--green); }
.ch-auto { background: var(--white); color: var(--ink); border: 1px dashed var(--ink); }
.ch-gads { background: var(--ochre-tint); color: #6B3F0E; border: 1px solid #A8672A; }
.ch-meta { background: var(--ink); color: var(--white); border: 1px solid var(--ink); }
.ch-print { background: var(--bg); color: var(--text); border: 1px solid var(--text); }
.ch-autre { background: var(--ochre); color: var(--ink); border: 1px solid var(--ink); }

/* Frise */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters h2 { margin-right: 8px; }
.filters .input { flex: 0 1 240px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid #E3E8DF; border-radius: 22px; background: var(--panel); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; }
.chip.is-on { background: var(--ink); color: var(--white); border-color: var(--ink); font-weight: 600; }
.dot { width: 22px; height: 22px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.owner { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; font-weight: 400; }
.owner { white-space: nowrap; max-width: 100%; }
.owner select { flex: 1 1 auto; width: auto; min-width: 150px; max-width: 260px; }
.card-actions .owner { flex: 1 1 100%; }
.frise-scroll { overflow-x: auto; }
.frise { min-width: 820px; display: flex; flex-direction: column; gap: 6px; }
.frise-head { display: flex; align-items: flex-end; padding: 0 12px; }
.name-col { width: 180px; flex: none; }
.days, .bars { flex: 1; display: grid; }
.day { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0; margin: 0 1px; border-radius: 12px; font-size: 12px; color: var(--text); }
.day small { font-size: 11px; }
.day.is-today { background: var(--ochre); color: var(--ink); }
.client-row { background: var(--panel); border-radius: 18px; }
.client-row.is-open { background: var(--bg); }
.row-head { display: flex; align-items: stretch; padding: 0 12px; }
.row-btn { width: 180px; flex: none; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 8px 8px 0; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.chev { flex: none; width: 28px; height: 28px; border-radius: 14px; background: var(--white); display: inline-flex; align-items: center; justify-content: center; }
.chev svg { transition: transform .15s; }
.is-open .chev { background: var(--ink); color: var(--white); }
.is-open .chev svg { transform: rotate(90deg); }
.row-name { display: flex; flex-direction: column; }
.row-name b { font-size: 15px; font-weight: 600; }
.row-name small { color: var(--text); font-size: 12px; }
.bars { grid-auto-rows: 26px; row-gap: 4px; padding: 10px 0; align-content: center; }
.today-line { justify-self: center; width: 2px; background: var(--ochre); border-radius: 1px; }
.bar { position: relative; display: flex; align-items: center; gap: 6px; padding: 0 9px; margin: 0 1px; border-radius: 13px; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; }
.bar.is-single { justify-content: center; padding: 0; }
.bar-name { overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.m-only, .m-inline { display: none; }
.cards { padding: 4px 14px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.card { display: flex; gap: 14px; padding: 14px; background: var(--white); border-radius: 16px; }
.thumb { flex: none; position: relative; width: 104px; height: 136px; padding: 0; border: 1px solid #D5DBD0; border-radius: 8px; background: var(--white); overflow: hidden; cursor: zoom-in; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--text); font: inherit; font-size: 12px; text-decoration: none; }
.thumb iframe { position: absolute; top: 0; left: 0; width: 650px; height: 850px; border: 0; transform: scale(.16); transform-origin: 0 0; pointer-events: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { border: 1.5px dashed var(--text); cursor: pointer; padding: 8px; }
.thumb-file { cursor: pointer; }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { padding: 2px 10px; border-radius: 11px; font-size: 12px; font-weight: 600; }
.tag-status { background: var(--bg); color: var(--text); font-weight: 500; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: auto; padding-top: 6px; }

/* Bas de page */
.bottom { display: flex; flex-wrap: wrap; gap: 14px; }
.bottom .panel-dark { flex: 2 1 420px; }
.bottom .panel-tint { flex: 1 1 260px; }
.week { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.week-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: #223A18; }
.week-day { flex: none; width: 44px; height: 44px; border-radius: 22px; background: var(--bg); color: var(--ink); display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.week-day.is-today { background: var(--ochre); }
.week-day small { font-size: 10px; }
.week-text { display: flex; flex-direction: column; min-width: 0; }
.week-text small { color: #C3CCBD; font-size: 12px; }
.persons { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 6px 0 14px; border-radius: 18px; background: var(--white); font-weight: 500; }
.person.is-none { background: none; border: 1.5px dashed var(--ink); }
.person b { min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--ink); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }

/* Formulaires et listes */
.form { max-width: 720px; gap: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { flex-direction: row; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 22px; cursor: pointer; }
.choice input:checked + span { background: var(--ink); color: var(--white); border-color: var(--ink); font-weight: 600; }
.choice input:focus-visible + span { outline: 3px solid var(--ochre); outline-offset: 2px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.danger-zone { max-width: 720px; text-align: right; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-fields label { flex: 1 1 220px; }
.inline-fields .grow { flex: 2 1 320px; }
.panel-dark input { border-color: transparent; }
.tbl { display: flex; flex-direction: column; gap: 6px; }
.tbl-grid { display: grid; grid-template-columns: 1.5fr .6fr 1.2fr 1fr .7fr 1.8fr; gap: 12px; align-items: center; }
.tbl-head { padding: 0 16px 6px; color: var(--text); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.tbl-row { padding: 10px 16px; background: var(--panel); border-radius: 18px; }
.user-row, .journal-row { display: grid; grid-template-columns: 1.4fr 1.2fr 1fr 2fr; gap: 12px; align-items: center; }
.journal-row { grid-template-columns: 1fr .8fr 1.2fr 2fr; }
.cl-name { font-size: 15px; font-weight: 600; }
.row-actions, .row-actions form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.state { display: inline-block; padding: 4px 12px; border-radius: 14px; font-size: 13px; font-weight: 600; }
.state-ok { background: var(--tint); color: #1F4310; }
.state-error { background: var(--ochre-tint); color: #6B3F0E; border: 1px solid #A8672A; }
.state-paused { background: var(--white); color: var(--ink); border: 1px dashed var(--ink); }
.more { margin-top: 8px; }
.more summary { cursor: pointer; color: var(--text); min-height: 32px; display: flex; align-items: center; }
.more-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 10px 0 6px; align-items: end; }
.more-grid form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.more-grid label { width: 100%; }
.secret { background: var(--white); padding: 4px 10px; border-radius: 8px; font-size: 15px; user-select: all; }

/* Aperçu du mail */
.preview { width: min(760px, 94vw); height: 90vh; padding: 12px; border: 0; border-radius: 20px; background: var(--white); }
.preview[open] { display: flex; flex-direction: column; gap: 10px; }
.preview::backdrop { background: rgba(19, 39, 10, .6); }
.preview form { display: flex; justify-content: flex-end; }
.preview iframe { flex: 1; width: 100%; border: 1px solid #D5DBD0; border-radius: 12px; }

/* Connexion */
.auth-wrap { min-height: 100vh; padding: 20px; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; }
.auth-wrap > .flash { width: 100%; max-width: 440px; }
.auth-card { width: 100%; max-width: 440px; background: var(--white); border-radius: 24px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 26px; }
.auth-card-dark { background: var(--ink); color: var(--bg); }
.auth-card-dark .muted { color: #C3CCBD; }
.step { align-self: flex-start; padding: 4px 12px; border-radius: 14px; background: var(--tint); color: #1F4310; font-size: 12px; font-weight: 600; }
.step-accent { background: var(--ochre); color: var(--ink); }
.code-input { min-height: 56px !important; border-radius: 28px !important; font-size: 24px !important; font-weight: 600 !important; letter-spacing: .25em; }
.qr { align-self: center; width: 200px; height: 200px; padding: 8px; background: var(--white); border: 1px solid #D5DBD0; border-radius: 12px; }
.qr svg { width: 100%; height: 100%; display: block; }
.codes { list-style: none; margin: 0; padding: 16px; background: var(--bg); border-radius: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.codes code { font-size: 15px; }

@media (max-width: 920px) {
  .side { flex: 1 1 100%; max-width: none; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; border-radius: 20px; }
  .brand { padding: 0 10px; margin-right: auto; }
  .nav-link { width: auto; }
  .side-end { margin-top: 0; }
}
@media (max-width: 760px) {
  .shell { padding: 12px; }
  h1 { font-size: 24px; }
  .d-only { display: none !important; }
  .m-only { display: flex; }
  .m-inline { display: inline; }
  .frise { min-width: 0; }
  .row-head { flex-direction: column; }
  .row-btn { width: 100%; }
  .m-list { flex-direction: column; gap: 6px; padding: 0 0 12px; }
  .m-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
  .card { flex-direction: column; }
  .tbl-head { display: none; }
  .tbl-grid, .user-row, .journal-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .auth-card { padding: 24px; }
}
