@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('../fonts/archivo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('../fonts/archivo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --paper: #ffffff;
  --ink: #14233a;
  --ink-2: #4d5e72;
  --rule: #d8dfe7;
  --line: #b9c4d0;
  --wash: #f3f6fa;
  --z1: #9ab2db;
  --z2: #7592cb;
  --z3: #5374bb;
  --z4: #3a59a2;
  --z5: #213574;
  --good: #2f8a57;
  --watch: #c7880f;
  --limit: #c2412d;
  --focus: #3a59a2;
  --font: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--wash);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea { font: inherit; color: inherit; }

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

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#error-banner {
  position: fixed; inset: auto 16px 16px 16px; z-index: 50;
  padding: 12px 16px; border-radius: 8px;
  background: var(--limit); color: #fff; font-weight: 600;
}

/* Barre d'outils */

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  min-height: 60px; padding: 10px 20px;
  background: var(--z5); color: #fff;
}

.brand { display: flex; align-items: center; gap: 10px; margin: 0 8px 0 0; }
.brand-name { font-size: 17px; font-weight: 750; font-stretch: 80%; letter-spacing: 0.01em; white-space: nowrap; }
.brand-ramp { display: flex; gap: 2px; }
.brand-ramp span { width: 6px; height: 18px; border-radius: 1px; }
.brand-ramp span:nth-child(1) { background: var(--z1); }
.brand-ramp span:nth-child(2) { background: var(--z2); }
.brand-ramp span:nth-child(3) { background: var(--z3); }
.brand-ramp span:nth-child(4) { background: #5d79bd; }
.brand-ramp span:nth-child(5) { background: #fff; }

.saved { display: flex; align-items: center; gap: 8px; min-width: 0; }
.saved label { font-size: 13px; opacity: 0.85; white-space: nowrap; }
.saved select {
  max-width: 280px; padding: 7px 10px; border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.08); color: #fff;
}
.saved select option { color: var(--ink); }

.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

.tbtn {
  display: inline-flex; align-items: center; min-height: 36px; padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 6px;
  background: transparent; color: #fff; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.tbtn:hover { background: rgba(255, 255, 255, 0.12); }
.tbtn.primary { background: #fff; color: var(--z5); border-color: #fff; }
.tbtn.primary:hover { background: var(--wash); }
.tbtn[data-armed='true'] { background: var(--limit); border-color: var(--limit); }
.tbtn:focus-visible { outline-color: #fff; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 2px solid #fff; outline-offset: 2px; }

.status {
  flex-basis: 100%; margin: 0; min-height: 18px;
  font-size: 12.5px; color: rgba(255, 255, 255, 0.85);
}
.status[data-tone='error'] { color: #ffd9d2; font-weight: 600; }

/* Mise en page à deux volets */

.tabs { display: none; }

.split {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(380px, 460px) 1fr;
}

.entry-pane {
  overflow-y: auto; background: var(--paper); border-right: 1px solid var(--rule);
}

.report-pane { overflow-y: auto; padding: 28px 32px 64px; }

@media screen and (max-width: 999px) {
  body { display: block; height: auto; }
  .split { display: block; }
  .tabs {
    display: flex; gap: 4px; padding: 8px 16px; background: var(--paper); border-bottom: 1px solid var(--rule);
    position: sticky; top: 0; z-index: 5;
  }
  .tabs button {
    flex: 1; padding: 9px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper);
    font-weight: 650; cursor: pointer;
  }
  .tabs button[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
  body[data-view='entry'] .report-pane { display: none; }
  body[data-view='report'] .entry-pane { display: none; }
  .entry-pane { border-right: 0; }
  .report-pane { padding: 16px; }
  .tools { margin-left: 0; }
  .saved { flex-basis: 100%; }
  .saved select { flex: 1; min-width: 0; max-width: none; }
}

/* Formulaire */

#entry details { border-bottom: 1px solid var(--rule); }
#entry summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; cursor: pointer; list-style: none;
  font-size: 16px; font-weight: 720; font-stretch: 88%;
}
#entry summary::-webkit-details-marker { display: none; }
#entry summary::after {
  content: ''; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2);
  transform: rotate(45deg); transition: transform 0.15s ease;
}
#entry details[open] > summary::after { transform: rotate(-135deg); }
#entry summary:hover { background: var(--wash); }
.sec-body { padding: 2px 20px 22px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.half { grid-column: auto; }
.field label, .sub { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.sub { margin: 20px 0 8px; font-size: 13px; color: var(--ink); }

.control {
  display: flex; align-items: center; min-width: 0;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
}
.control:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.control:has(.invalid) { border-color: var(--limit); box-shadow: 0 0 0 1px var(--limit); }
.control input, .control select, .control textarea {
  flex: 1; min-width: 0; width: 100%; padding: 8px 10px; border: 0; background: transparent; outline: none;
}
.control select { padding-right: 4px; }
.control textarea { resize: vertical; line-height: 1.45; }
.control .unit { padding: 0 10px 0 2px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.field > textarea, .prio-edit textarea, .prio-edit input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); resize: vertical;
}

.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-2); }
.hint:empty { display: none; }

.grid-input { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.grid-input th { padding: 4px 3px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); text-align: left; }
.grid-input td { padding: 2px 3px; }
.grid-input td.wide { width: 42%; }
.grid-input td.narrow { width: 14%; }
.grid-input input {
  width: 100%; min-width: 0; padding: 6px 7px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 5px; background: var(--paper);
}
.grid-input input.invalid { border-color: var(--limit); box-shadow: 0 0 0 1px var(--limit); }
.grid-input .empty { padding: 10px 3px; color: var(--ink-2); font-size: 12.5px; }

.icon-btn {
  width: 28px; height: 28px; border: 1px solid transparent; border-radius: 5px;
  background: transparent; color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { border-color: var(--rule); color: var(--limit); }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn {
  min-height: 34px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn:hover { border-color: var(--ink-2); }

.ov-row {
  display: grid; grid-template-columns: 16px 1fr minmax(150px, 46%); align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 13px;
}
.ov-row select { padding: 5px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); font-size: 12.5px; }

.prio-edit { display: grid; grid-template-columns: 26px 1fr; gap: 8px; margin-top: 14px; }
.prio-edit > div { display: grid; gap: 6px; }
.prio-num { margin: 6px 0 0; font-size: 20px; font-weight: 800; font-stretch: 75%; color: var(--z4); }
.prio-edit input { font-weight: 650; }
.prio-edit ::placeholder { color: #8796a8; font-weight: 400; }

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