/* CRA SysBlue — interface de saisie mensuelle.
   Aucun style ni script en ligne : la politique de sécurité (CSP) les interdit. */

:root {
  --paper: #f2f5f8;
  --card: #ffffff;
  --ink: #12222d;
  --muted: #5a6a76;
  --line: #d9e1e8;
  --line-strong: #b9c6d1;
  --blue: #156082;
  --blue-hover: #0f4a65;
  --on-blue: #ffffff;
  --tint: #e2eff6;
  --off: #eceff3;
  --hatch: #dfe4ea;
  --holiday-bg: #fbf1d9;
  --holiday-ink: #7a5200;
  --track: #d6e2ea;
  --danger: #a3302f;
  --danger-bg: #fbe9e8;
  --ok: #17663f;
  --ok-bg: #e4f4ea;
  --radius: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1920;
    --card: #15252e;
    --ink: #e5edf2;
    --muted: #93a5b1;
    --line: #28404c;
    --line-strong: #3b5663;
    --blue: #5db4d8;
    --blue-hover: #86c9e5;
    --on-blue: #08202b;
    --tint: #1a3441;
    --off: #121f27;
    --hatch: #1a2a33;
    --holiday-bg: #3a2f13;
    --holiday-ink: #f1c76c;
    --track: #2a424e;
    --danger: #f08a86;
    --danger-bg: #3a1f1f;
    --ok: #7fd3a1;
    --ok-bg: #173324;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1rem/1.5 var(--font); font-variant-numeric: tabular-nums;
}
h1, h2 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1.0625rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
a { color: var(--blue); }
a:hover { color: var(--blue-hover); }
small { font-size: .8125rem; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

/* ---------- en-tête ---------- */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1180px; margin: 0 auto; padding: .625rem 1rem; display: flex; align-items: center; gap: 1.25rem; }
.brand { display: flex; align-items: center; gap: .625rem; color: var(--ink); text-decoration: none; font-weight: 600; }
.brand:hover { color: var(--ink); }
.brand-mark {
  display: inline-grid; place-items: center; height: 30px; padding: 0 .5rem; border-radius: 7px;
  background: var(--blue); color: var(--on-blue); font-size: .8125rem; font-weight: 700; letter-spacing: .04em;
}
.top-nav { display: flex; gap: .25rem; margin-right: auto; }
.top-nav a { padding: .375rem .75rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.top-nav a:hover { background: var(--tint); color: var(--ink); }
.top-nav a[aria-current="page"] { background: var(--tint); color: var(--ink); font-weight: 600; }
.logout { margin: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  min-height: 40px; padding: 0 1rem; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); font: 600 .9375rem var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--tint); color: var(--ink); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); color: var(--on-blue); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { background: var(--tint); color: var(--ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled, .chip:disabled { opacity: .55; cursor: progress; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--tint); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.small { width: 32px; height: 32px; color: var(--muted); }
.icon-btn.small svg { width: 16px; height: 16px; }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn.armed { width: auto; padding: 0 .625rem; background: var(--danger); color: #fff; font: 600 .8125rem var(--font); }

/* ---------- messages ---------- */
.notice { margin: 0 0 1rem; padding: .75rem 1rem; border-radius: var(--radius); background: var(--tint); border: 1px solid var(--line); }
.notice.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.notice.error { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.notice ul { margin: 0; padding-left: 1.125rem; }
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 20;
  max-width: min(92vw, 30rem); padding: .625rem 1rem; border-radius: 8px;
  background: var(--ink); color: var(--paper); font-weight: 500; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.toast.error { background: var(--danger); color: #fff; }

/* ---------- barre du mois et onglets ---------- */
.toolbar { margin-bottom: .75rem; }
.month-nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.month-nav h1 { min-width: 11rem; text-align: center; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem; scrollbar-width: thin; }
.tab {
  display: flex; flex-direction: column; justify-content: center; flex: none; min-height: 52px; padding: .375rem 1rem;
  color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); background: var(--tint); border-radius: 8px 8px 0 0; }
.tab.is-selected { color: var(--ink); border-bottom-color: var(--blue); }
.tab-name { font-weight: 600; }
.tab-total { font-size: .8125rem; color: var(--muted); }
.tab-add { margin-left: auto; font-weight: 600; color: var(--blue); }

/* ---------- mise en page du mois ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.5rem; align-items: start; }
.side { position: sticky; top: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card h2 { margin-bottom: .125rem; }
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.figures div { margin: 0; }
.figures dt { font-size: .8125rem; color: var(--muted); }
.figures dd { margin: 0; font-size: 1.25rem; font-weight: 650; }
.money { display: grid; gap: .25rem; padding: .875rem 1rem; border-radius: 8px; background: var(--tint); margin-bottom: 1rem; }
.money-label { font-size: .8125rem; color: var(--muted); font-weight: 600; }
.money-value { font-size: 1.75rem; line-height: 1.1; letter-spacing: -0.02em; }
.money-note { display: flex; gap: .375rem; align-items: flex-start; font-size: .8125rem; color: var(--muted); }
.money-note svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.export { display: grid; gap: .5rem; margin-bottom: 1rem; }
.link { font-size: .9375rem; }
.jump { display: none; margin-left: auto; font-size: .9375rem; font-weight: 600; }

/* ---------- tableau des jours ---------- */
.days-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.days-table thead th {
  text-align: left; font-size: .8125rem; font-weight: 600; color: var(--muted);
  padding: .5rem .75rem; border-bottom: 1px solid var(--line); background: var(--card);
}
.days-table tbody tr.day > * { border-bottom: 1px solid var(--line); padding: .375rem .75rem; vertical-align: middle; }
.days-table tbody tr:last-child > * { border-bottom: 0; }
.c-day { width: 5.25rem; text-align: left; font-weight: 400; white-space: nowrap; }
.dnum { font-weight: 650; font-size: 1.0625rem; margin-right: .375rem; }
.dow { color: var(--muted); font-size: .875rem; }
.c-time { width: 8.5rem; white-space: nowrap; }
.tt { font-weight: 650; margin-left: .5rem; }
.gauge { display: inline-block; width: 44px; height: 6px; vertical-align: middle; border-radius: 3px; background: var(--track); overflow: hidden; }
.gauge i { display: block; height: 100%; background: var(--blue); border-radius: 3px; }
.f0 { width: 0; } .f1 { width: 12.5%; } .f2 { width: 25%; } .f3 { width: 37.5%; } .f4 { width: 50%; }
.f5 { width: 62.5%; } .f6 { width: 75%; } .f7 { width: 87.5%; } .f8 { width: 100%; }

tr.day.is-off { background: repeating-linear-gradient(135deg, var(--off) 0 6px, var(--hatch) 6px 7px); }
tr.day.is-holiday { background: var(--holiday-bg); }
tr.day.is-today .c-day { box-shadow: inset 4px 0 0 var(--blue); }
.tag { display: inline-block; padding: 0 .5rem; border-radius: 999px; background: var(--holiday-bg); color: var(--holiday-ink); font-size: .75rem; font-weight: 600; margin-right: .375rem; }
.clients .tag { background: var(--tint); color: var(--muted); }
.is-holiday .tag { background: transparent; padding-left: 0; }

.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: .125rem; }
.entry { display: flex; align-items: center; gap: .625rem; min-height: 32px; }
.e-qty { flex: none; min-width: 3.25rem; font-weight: 650; }
.e-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.e-actions { flex: none; display: flex; }
.others { display: block; font-size: .8125rem; color: var(--muted); }

.c-add { width: 1%; white-space: nowrap; }
.quick { display: flex; gap: .375rem; justify-content: flex-end; }
.chip {
  min-width: 42px; height: 34px; padding: 0 .625rem; border-radius: 17px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  font: 600 .875rem var(--font); font-variant-numeric: tabular-nums; cursor: pointer;
}
.chip:hover { background: var(--tint); border-color: var(--blue); }
.chip.more { color: var(--muted); display: inline-grid; place-items: center; padding: 0; width: 34px; min-width: 34px; }
.chip svg { width: 16px; height: 16px; }

/* ---------- formulaire de saisie détaillée ---------- */
tr.editor > td { padding: .75rem; background: var(--tint); border-bottom: 1px solid var(--line); }
.entry-form { display: grid; grid-template-columns: 7rem minmax(8rem, 1fr) minmax(10rem, 2fr) auto; gap: .75rem; align-items: end; }
.f-actions { display: flex; gap: .375rem; }
.form-error { grid-column: 1 / -1; margin: 0; color: var(--danger); font-weight: 600; }

.field { display: grid; gap: .25rem; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: .875rem; font-weight: 600; padding: 0; }
input[type="text"], input[type="password"], input[type="number"], input[type="month"], input:not([type]) {
  width: 100%; min-height: 40px; padding: .375rem .625rem; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font: inherit;
}
input[name="username"], input[name="password"], input[name="code"], input[name="rate"], input[name="name"], input[name="default_mission"] {
  width: 100%; min-height: 40px; padding: .375rem .625rem; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font: inherit;
}
input:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---------- récapitulatif ---------- */
.overview { margin-top: 2rem; }
.overview h2 { margin-bottom: .625rem; }
.plain { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.plain th, .plain td { padding: .625rem .875rem; text-align: left; border-bottom: 1px solid var(--line); font-weight: 400; }
.plain thead th { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.plain tbody th { font-weight: 600; }
.plain tfoot th { font-weight: 650; text-align: left; }
.plain tfoot td { font-weight: 700; }
.plain tr:last-child > * { border-bottom: 0; }
.plain .num { text-align: right; }
.is-archived { color: var(--muted); }

/* ---------- pages clients, connexion ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.empty { max-width: 32rem; margin: 3rem auto; text-align: center; }
.empty h1, .empty h2 { margin-bottom: .5rem; }
.stack { display: grid; gap: 1rem; }
.form-card { max-width: 36rem; }
.radio-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.radio { position: relative; }
.radio input { position: absolute; opacity: 0; inset: 0; }
.radio span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 .875rem; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--card); font-weight: 600; cursor: pointer;
}
.radio input:checked + span { background: var(--tint); border-color: var(--blue); color: var(--ink); box-shadow: inset 0 0 0 1px var(--blue); }
.radio input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.radio input:disabled + span { opacity: .6; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.check input { width: 18px; height: 18px; }
.form-actions { display: flex; gap: .5rem; }
.danger-zone { margin-top: 1.5rem; max-width: 36rem; }

.settings { display: grid; gap: 1rem; max-width: 36rem; }
.settings h2 { margin-bottom: 0; }
input[type="file"] { width: 100%; padding: .5rem; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; }
code { font: .875rem ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace; background: var(--tint); padding: .125rem .375rem; border-radius: 5px; overflow-wrap: anywhere; }
.secret { display: block; margin-top: .5rem; padding: .5rem .625rem; letter-spacing: .06em; user-select: all; }
.qr { display: block; width: 220px; height: 220px; margin: 0 auto; padding: .5rem; background: #fff; border-radius: 10px; border: 1px solid var(--line); }
.setup-card .stack { margin-top: 1rem; }
details { margin-top: .75rem; }
summary { cursor: pointer; color: var(--blue); font-weight: 600; }

.is-login { display: grid; min-height: 100vh; place-items: center; }
.is-login .wrap { width: 100%; max-width: 28rem; padding: 1rem; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.75rem; }
.login-brand { display: flex; align-items: center; gap: .875rem; margin-bottom: 1.5rem; }
.login-brand h1 { font-size: 1.25rem; }
.login-brand p { margin: 0; }
.login-brand .brand-mark { height: 38px; padding: 0 .75rem; font-size: .9375rem; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .entry-form { grid-template-columns: 1fr 1fr; }
  .f-mission, .f-comment, .f-actions { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .top-inner { gap: .25rem; padding: .5rem .75rem; }
  .brand-name { display: none; }
  .top-nav { margin-left: .25rem; }
  .logout .btn { padding: 0 .5rem; }
  .jump { display: inline; flex-basis: 100%; margin: .25rem 0 0 .25rem; }
  .month-nav h1 { min-width: 0; flex: 1; text-align: left; padding-left: .25rem; white-space: nowrap; }
  .days-table thead { display: none; }
  .days-table, .days-table tbody { display: block; }
  tr.day { display: grid; grid-template-columns: 4.25rem 1fr; grid-template-areas: "day time" "day detail" "add add"; align-items: center; border-bottom: 1px solid var(--line); }
  tr.day > * { border-bottom: 0 !important; }
  .c-day { grid-area: day; width: auto; }
  .c-time { grid-area: time; width: auto; }
  .c-detail { grid-area: detail; }
  .c-add { grid-area: add; width: auto; padding-top: 0 !important; }
  .quick { justify-content: flex-start; flex-wrap: wrap; }
  .chip { height: 40px; min-width: 48px; }
  .c-time:empty { display: none; }
  tr.editor { display: block; }
  tr.editor > td { display: block; }
  .figures dd { font-size: 1.125rem; }
  .overview .plain { font-size: .875rem; }
  .col-days { display: none; }
  .overview .plain th, .overview .plain td { padding: .5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in .18s ease-out; }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
}
