/* Interface LS Consulting — une police, une couleur d'accent, le registre du CRA comme signature. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/static/fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1d2733;          /* texte */
  --ink-soft: #5b6875;     /* texte secondaire */
  --paper: #f4f6f7;        /* fond */
  --sheet: #ffffff;        /* surfaces */
  --rule: #d9e0e5;         /* traits */
  --rule-soft: #e8edf0;
  --pine: #1f5f4a;         /* accent : action, journée travaillée */
  --pine-soft: #e3efe9;
  --amber: #b7791f;        /* astreinte, verrou */
  --amber-soft: #f8eedb;
  --brick: #a53a2a;        /* suppression, erreur */
  --brick-soft: #f7e5e1;
  --radius: 8px;
  --font: "Atkinson Hyperlegible Next", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.5; font-variant-numeric: tabular-nums; }
a { color: var(--pine); }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0; font-weight: 700; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; font-weight: 700; color: var(--ink-soft); }
p { margin: 0; }
small, .muted { color: var(--ink-soft); }
.num { text-align: right; white-space: nowrap; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--pine) 45%, transparent); outline-offset: 2px; }

/* ── Cadre : menu et contenu ──────────────────────────────── */
.app { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.sidebar { padding: 1.25rem .9rem; display: flex; flex-direction: column; gap: .15rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .65rem; padding: .2rem .5rem 1.25rem; color: var(--ink); text-decoration: none; font-weight: 700; line-height: 1.2; }
.brand small { display: block; font-weight: 400; font-size: .8rem; }
.mark { display: grid; gap: 3px; width: 26px; }
.mark i { display: block; height: 6px; border-radius: 2px; background: var(--pine); }
.mark i:nth-child(1) { width: 40%; background: var(--amber); }
.mark i:nth-child(2) { width: 70%; opacity: .75; }
.nav a, .nav button { display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left; padding: .5rem .6rem; border-radius: var(--radius); color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.nav a .icon, .nav button .icon { color: var(--ink-soft); }
.nav a:hover, .nav button:hover { background: var(--rule-soft); }
.nav a.active { background: var(--sheet); font-weight: 700; box-shadow: inset 3px 0 0 var(--pine); }
.nav a.active .icon { color: var(--pine); }
.nav .section { font-size: .8rem; color: var(--ink-soft); padding: 1.1rem .6rem .3rem; }
.sidebar .bottom { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--rule); }
.user { font-size: .85rem; color: var(--ink-soft); padding: .2rem .6rem .5rem; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.version { font-size: .75rem; color: var(--ink-soft); padding: .3rem .6rem 0; font-variant-numeric: tabular-nums; }
.main { padding: 1.75rem 2.25rem 4rem; min-width: 0; background: var(--paper); }
.btn.menu-toggle { display: none; } /* .btn, déclaré plus bas, l'afficherait sinon */

/* Largeur moyenne : menu réduit aux icônes (libellés en infobulle). */
@media (max-width: 1000px) and (min-width: 601px) {
  .app { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar { padding: 1rem .5rem; align-items: center; }
  .brand { padding: .2rem 0 1rem; }
  .brand > span:last-child, .nav a span, .nav button span, .nav .section, .user, .version { display: none; }
  .nav { width: 100%; }
  .nav a, .nav button { justify-content: center; padding: .6rem 0; }
  .nav .section { display: block; height: .75rem; padding: 0; }
  .main { padding: 1.5rem 1.5rem 3rem; }
}

/* Téléphone : menu masqué, ouvert par le bouton. */
@media (max-width: 600px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app.nav-open .sidebar { display: flex; position: fixed; inset: 0 auto 0 0; width: min(280px, 85vw); z-index: 20; background: var(--paper); box-shadow: 0 0 0 100vmax rgba(29, 39, 51, .35); }
  .main { padding: 1rem 1rem 3rem; }
  .btn.menu-toggle { display: inline-flex; margin: -.25rem 0 .75rem -.4rem; color: var(--ink); }
}

/* ── En-têtes, messages, badges ───────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-header p { margin-top: .3rem; color: var(--ink-soft); max-width: 70ch; }
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.alert { border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1.25rem; border: 1px solid transparent; }
.alert-ok { background: var(--pine-soft); color: var(--pine); border-color: #c6ddd2; }
.alert-error { background: var(--brick-soft); color: var(--brick); border-color: #ecc8c0; }
.alert-warn { background: var(--amber-soft); color: #7d520f; border-color: #ecd7ad; }
.alert-info { background: var(--sheet); border-color: var(--rule); }
.notice { color: var(--ink-soft); margin: .25rem 0 1rem; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--rule-soft); color: var(--ink-soft); white-space: nowrap; }
.badge-ok { background: var(--pine-soft); color: var(--pine); }
.badge-warn { background: var(--amber-soft); color: #7d520f; }
.badge-danger { background: var(--brick-soft); color: var(--brick); }

/* ── Formulaires ─────────────────────────────────────────── */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem 1.1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field.grow { flex: 1 1 18rem; }
.field label, .label { font-size: .85rem; font-weight: 700; color: var(--ink-soft); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .95rem; font-weight: 400 !important; color: var(--ink) !important; }
input, select, textarea { font: inherit; color: inherit; padding: .5rem .6rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); min-width: 0; width: 100%; }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; accent-color: var(--pine); flex: none; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--pine-soft); border-color: var(--pine); }
input:disabled, select:disabled { background: var(--rule-soft); color: var(--ink-soft); }
textarea { resize: vertical; }
.hint { font-size: .85rem; color: var(--ink-soft); }
.suggestions { display: flex; flex-wrap: wrap; gap: .4rem; }
fieldset.flat { border: 0; border-top: 1px solid var(--rule); padding: 1rem 0 0; margin: 1.5rem 0 0; }
fieldset.flat legend { font-weight: 700; padding-right: .5rem; }
fieldset.flat .hint { margin-bottom: .8rem; }

/* ── Boutons ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); font: inherit; font-size: .93rem; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #b9c4cc; }
.btn-primary { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn-primary:hover { background: #184d3c; border-color: #184d3c; }
.btn-danger { color: var(--brick); }
.btn-danger:hover { background: var(--brick-soft); border-color: #ecc8c0; }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.btn-icon { padding: 0; width: 2.2rem; height: 2.2rem; border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-icon:hover { background: var(--rule-soft); color: var(--ink); border-color: transparent; }
.btn-icon.btn-danger:hover { background: var(--brick-soft); color: var(--brick); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1.1rem; }
.inline { display: inline; }

/* ── Tableaux ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: .6rem .75rem; border-bottom: 1px solid var(--rule-soft); text-align: left; vertical-align: middle; }
table.data th { font-size: .85rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; background: var(--sheet); }
table.data th a { color: inherit; text-decoration: none; }
table.data th a:hover { color: var(--ink); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #f8fafb; }
table.data td.actions-cell { white-space: nowrap; text-align: right; }
table.data td.actions-cell > * + * { margin-left: .25rem; }
table.data input, table.data select, table.data textarea { padding: .3rem .4rem; font-size: .88rem; }
table.data input.short { width: 6rem; }
table.data input.date { width: 8.5rem; }
tr.row-error td { background: #fcf3f1; }
tr.row-warn td { background: #fdf8ee; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem .2rem; font-size: .9rem; color: var(--ink-soft); flex-wrap: wrap; }
.pager .links { display: flex; gap: .3rem; flex-wrap: wrap; }
.empty { padding: 2rem; text-align: center; color: var(--ink-soft); }

/* ── Saisie CRA : espace de travail et registre ───────────── */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 2rem; align-items: start; }
.month-head { display: flex; align-items: center; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.month-head h1 { font-size: 2.1rem; min-width: 11ch; text-align: center; }
.month-head .badge { margin-left: .75rem; }
.selector { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: 1.25rem; }
.selector .field:not(.grow) { flex: 0 0 11rem; }

.ledger { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.ledger .head { font-size: .82rem; color: var(--ink-soft); padding: 0 .2rem .2rem; }
.day { position: relative; overflow: hidden; min-height: 5rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); padding: .35rem .5rem; cursor: pointer; user-select: none; display: flex; flex-direction: column; isolation: isolate; }
.day .n { font-weight: 700; }
.day .h { font-size: .72rem; line-height: 1.15; color: var(--ink-soft); }
.day .v { margin-top: auto; text-align: right; font-weight: 700; }
.day .fill { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--t, 0) * 100%); background: var(--pine-soft); z-index: -1; transition: height .15s ease-out; }
.day.extra .fill { background: var(--amber-soft); }
.day.extra .v { color: #7d520f; }
.day.worked .v { color: var(--pine); }
.day.off { background: repeating-linear-gradient(135deg, var(--sheet) 0 6px, var(--rule-soft) 6px 7px); color: var(--ink-soft); }
.day:hover { border-color: var(--pine); }
.day.pad { visibility: hidden; }
.ledger.readonly .day { cursor: default; }
.ledger.readonly .day:hover { border-color: var(--rule); }
.ledger-foot { margin-top: 1.25rem; }
.tally { font-size: 1.05rem; }
.tally strong { font-size: 1.35rem; }
.tally-money { display: block; color: var(--ink-soft); margin-top: .15rem; }
.tally-money strong { font-size: 1.05rem; color: var(--ink); }
.ledger-foot .hint { margin-top: .4rem; }

.rail { position: sticky; top: 1.75rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 1.1rem 1rem 1rem; }
.rail h2 { font-size: 1rem; margin-bottom: .6rem; }
.rail h3 { margin-top: 1.1rem; }
.doc-group { display: flex; flex-direction: column; gap: .15rem; }
.doc-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem; padding: .45rem .35rem; border-radius: 6px; }
.doc-row:hover { background: #f8fafb; }
.doc-row.disabled .doc-icon, .doc-row.disabled strong { opacity: .5; }
.doc-icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 6px; background: var(--pine-soft); color: var(--pine); }
.doc-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.doc-text small { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.doc-tools { display: inline-flex; gap: .1rem; align-items: center; }
.doc-tools .when-fix, .doc-row.fixing .when-new { display: none; }
.doc-row.fixing .when-fix { display: inline; }
.doc-row.fixing .doc-icon { background: var(--amber-soft); color: var(--amber); }
/* Générer (vert), régénérer une facture à corriger (ambre, écrase), télécharger (neutre). */
.doc-tools [data-open] { background: var(--pine-soft); color: var(--pine); }
.doc-tools [data-open]:hover { background: color-mix(in srgb, var(--pine) 18%, var(--sheet)); color: var(--pine); }
.doc-row.fixing [data-open] { background: var(--amber-soft); color: var(--amber); }
.doc-row.fixing [data-open]:hover { background: color-mix(in srgb, var(--amber) 22%, var(--sheet)); color: var(--amber); }
.doc-tools [data-download]:hover { color: var(--ink); }
.rail-field { margin: .35rem .35rem .5rem 3rem; }
.rail-field label { font-size: .8rem; }
.rail-link { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--rule-soft); text-decoration: none; font-weight: 700; }

@media (max-width: 1150px) {
  .workspace { grid-template-columns: 1fr; }
  .rail { position: static; }
}
@media (max-width: 560px) {
  .ledger { gap: 3px; }
  .day { min-height: 3.6rem; padding: .25rem .3rem; font-size: .85rem; }
  .day .h { display: none; }
  .month-head h1 { font-size: 1.6rem; min-width: 0; }
}

/* ── Boîte de dialogue ───────────────────────────────────── */
dialog { border: 1px solid var(--rule); border-radius: 10px; padding: 1.4rem; max-width: 28rem; width: calc(100% - 2rem); color: var(--ink); }
dialog::backdrop { background: rgba(29, 39, 51, .35); }
dialog h2 { margin-bottom: 1rem; }

/* ── Choix de fichier, visionneuse ───────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.file-pick { position: relative; display: flex; align-items: center; gap: .6rem; min-width: 0; }
.btn-outline { border-color: var(--rule); background: var(--sheet); color: var(--pine); }
.btn-outline:hover { border-color: var(--pine); background: var(--pine-soft); color: var(--pine); }
.file-pick input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--pine) 45%, transparent); outline-offset: 2px; }
.file-name { color: var(--ink-soft); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog.viewer { max-width: none; width: min(1100px, calc(100% - 2rem)); height: calc(100vh - 3rem); padding: 0; display: none; flex-direction: column; overflow: hidden; }
dialog.viewer[open] { display: flex; }
dialog.viewer header { display: flex; align-items: center; gap: .25rem; padding: .6rem .6rem .6rem 1.1rem; border-bottom: 1px solid var(--rule); }
dialog.viewer h2 { margin: 0 auto 0 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog.viewer iframe { flex: 1; width: 100%; border: 0; background: var(--rule-soft); }

/* ── Documents : classeurs ───────────────────────────────── */
.page-tools { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.year-picker { display: flex; align-items: center; gap: .5rem; }
.year-picker select { width: auto; }
.search { display: flex; align-items: center; gap: .5rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 0 .6rem; color: var(--ink-soft); width: min(22rem, 100%); }
.search input { border: 0; padding: .5rem 0; outline: none; }
.search:focus-within { border-color: var(--pine); outline: 3px solid var(--pine-soft); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.5rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; color: var(--ink-soft); text-decoration: none; font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: .45rem; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--pine); }
.tabs .count { font-size: .8rem; background: var(--rule-soft); color: var(--ink-soft); border-radius: 999px; padding: 0 .45rem; }
.doc-section { margin-bottom: 1.75rem; }
.doc-section > header { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.section-tools { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.doc-list { list-style: none; margin: 0; padding: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); }
.doc { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 1rem; align-items: center; padding: .45rem .6rem .45rem .45rem; border-bottom: 1px solid var(--rule-soft); }
.doc:last-child { border-bottom: 0; }
.doc:hover { background: #f8fafb; }
.doc-main { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); min-width: 0; }
.doc-main:hover strong { text-decoration: underline; }
.doc-main .doc-text small { white-space: nowrap; }
.doc-meta { display: flex; gap: 1rem; font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }
.doc-meta span:last-child { min-width: 4.5rem; text-align: right; }
.empty-line { padding: .25rem 0; }
@media (max-width: 700px) {
  .doc { grid-template-columns: minmax(0, 1fr) auto; }
  .doc-meta { display: none; }
}

/* ── Connexion ───────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: 100%; max-width: 24rem; padding: 1.75rem; }
.login .brand { padding: 0 0 1.5rem; }
.login h1 { font-size: 1.4rem; margin-bottom: 1.1rem; }
.login form { display: flex; flex-direction: column; gap: 1rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
