/* ============================================================================
   Suivi de mission — Design system
   Palette brand PA : accent #FF5A2C · encre #1C1C1C · fond #FCFCFA
   Cible d'affichage : écran 15" (~1440×900). Sobre, dense, "finance".
============================================================================ */

:root {
  --accent: #FF5A2C;
  --accent-ink: #C6410F;
  --ink: #1C1C1C;
  --bg: #FCFCFA;
  --panel: #FFFFFF;
  --muted: #6B7280;
  --line: #E7E5E1;
  --line-strong: #D8D5CF;
  --ok: #0F766E;
  --ok-bg: #E6F4F1;
  --warn: #B45309;
  --warn-bg: #FBF0DD;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(28,28,28,.04), 0 8px 24px rgba(28,28,28,.05);
  --shadow-lift: 0 2px 4px rgba(28,28,28,.06), 0 18px 44px rgba(28,28,28,.10);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --t-h1: clamp(1.5rem, 1.1rem + 1.1vw, 2.1rem);
  --t-kpi: clamp(1.7rem, 1.2rem + 1.4vw, 2.4rem);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
a { color: var(--accent-ink); }
button { font-family: inherit; }

/* ---------- Utility ---------- */
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ============================================================================
   LOGIN
============================================================================ */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(255,90,44,.07), transparent 60%),
    var(--bg);
}
.login__card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  padding: 34px 32px 30px;
}
.login__brand {
  display: flex; align-items: center; gap: 11px; margin-bottom: 22px;
}
.login__logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--ink);
  display: grid; place-items: center; flex: none;
}
.login__logo svg { width: 22px; height: 22px; }
.login__brand-name { font-weight: 700; font-size: .98rem; letter-spacing: -.01em; }
.login__brand-sub { font-size: .78rem; color: var(--muted); }
.login h1 { font-size: 1.28rem; margin: 4px 0 4px; letter-spacing: -.02em; }
.login p.hint { font-size: .86rem; color: var(--muted); margin: 0 0 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 6px; color: #374151; }
.field input {
  width: 100%; padding: 12px 13px; font-size: .95rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,90,44,.14);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; font-size: .92rem; font-weight: 700; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; width: 100%; }
.btn--primary:hover { background: var(--accent-ink); }
.btn--ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--sm { padding: 7px 12px; font-size: .82rem; font-weight: 600; }
.login__error {
  color: #B91C1C; background: #FEF2F2; border: 1px solid #FECACA;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: .84rem; margin-bottom: 14px;
}

/* ============================================================================
   APP SHELL
============================================================================ */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 13px 26px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar__logo {
  width: 36px; height: 36px; border-radius: 9px; background: var(--ink);
  display: grid; place-items: center; flex: none;
}
.topbar__logo svg { width: 20px; height: 20px; }
.topbar__id { line-height: 1.25; }
.topbar__id b { font-size: .96rem; letter-spacing: -.01em; }
.topbar__id span { display: block; font-size: .77rem; color: var(--muted); }
.topbar__spacer { flex: 1; }
.topbar__client {
  font-size: .82rem; color: var(--muted);
}
.topbar__client b { color: var(--ink); font-size: .92rem; }
.select {
  padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; font-size: .85rem; font-weight: 600; color: var(--ink); cursor: pointer;
}
.pill-admin {
  font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--accent-ink); background: rgba(255,90,44,.10);
  padding: 4px 9px; border-radius: 999px;
}

.main { flex: 1; padding: 24px 26px 60px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* Header of mission */
.mhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.mhead__logo { max-height: 42px; max-width: 220px; width: auto; object-fit: contain; display: block; margin-bottom: 12px; }
.mhead h1 { font-size: var(--t-h1); margin: 0 0 3px; letter-spacing: -.025em; }
.mhead .sub { color: var(--muted); font-size: .92rem; }
.mhead .period-nav { display: flex; align-items: center; gap: 6px; }
.iconbtn {
  width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; border-radius: var(--radius-sm);
  color: var(--ink); font-size: 1.05rem; line-height: 1;
}
.iconbtn:hover { border-color: var(--ink); }
.period-label { font-weight: 700; font-size: 1rem; min-width: 148px; text-align: center; text-transform: capitalize; }

/* ---------- KPI row ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent);
  opacity: .0;
}
.kpi--accent::before { opacity: 1; }
.kpi__label { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.kpi__value { font-size: var(--t-kpi); font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.kpi__value small { font-size: .5em; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.kpi__foot { font-size: .78rem; color: var(--muted); margin-top: 7px; }

/* ---------- Content grid ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.card__head h2 { font-size: 1rem; margin: 0; letter-spacing: -.01em; }
.card__head .hint { font-size: .78rem; color: var(--muted); }
.card__body { padding: 16px 18px; }

/* ---------- Calendar ---------- */
.cal { padding: 14px 16px 18px; }
.cal__dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal__dow span { font-size: .72rem; font-weight: 700; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .03em; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cell {
  position: relative; aspect-ratio: 1 / 1; border: 1px solid var(--line);
  border-radius: 9px; overflow: hidden; background: #fff;
  display: flex; flex-direction: column;
}
.cell--out { background: #FAFAF8; border-color: transparent; }
.cell--today { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.cell--weekend .cell__num { color: #B9B6B0; }
.cell__num { position: absolute; top: 5px; left: 7px; font-size: .74rem; font-weight: 700; color: #9A968F; z-index: 2; pointer-events: none; }
.cell__halves { flex: 1; display: flex; flex-direction: column; }
.half {
  flex: 1; position: relative; display: grid; place-items: center;
  transition: background .12s;
}
.half--am { border-bottom: 1px dashed var(--line); }
.half--filled { color: #fff; }
.half__dot { display: none; }
.half__tag { font-size: .6rem; font-weight: 700; opacity: 0; }
.cell.is-editable .half { cursor: pointer; }
.cell.is-editable .half:hover { outline: 2px solid rgba(255,90,44,.55); outline-offset: -2px; z-index: 3; }
.half--filled .half__tag { opacity: .92; }
.cell__badge { position: absolute; bottom: 4px; right: 5px; z-index: 2; font-size: .6rem; }

/* note indicator */
.half[data-note="1"]::after {
  content: ""; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px;
  border-radius: 50%; background: rgba(255,255,255,.85);
}

/* ---------- Legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 14px 18px; border-top: 1px solid var(--line); }
.legend__item { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; color: #374151; }
.swatch { width: 13px; height: 13px; border-radius: 4px; flex: none; }
.legend__item.is-nb { color: var(--muted); }

/* ---------- Right rail: billing ---------- */
.rail { display: flex; flex-direction: column; gap: 18px; }
.bill-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 18px; }
.bill-summary .b { }
.bill-summary .b span { display: block; font-size: .76rem; color: var(--muted); font-weight: 600; }
.bill-summary .b b { font-size: 1.15rem; letter-spacing: -.02em; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.tbl th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; padding: 9px 18px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 11px 18px; border-bottom: 1px solid var(--line); }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.num, table.tbl th.num { text-align: right; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.status--paid { color: var(--ok); background: var(--ok-bg); }
.status--sent { color: #1D4ED8; background: #E5EDFF; }
.status--draft { color: var(--warn); background: var(--warn-bg); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* breakdown bars */
.brk { padding: 6px 18px 16px; }
.brk__row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-top: 12px; font-size: .82rem; }
.brk__row:first-child { margin-top: 4px; }
.brk__label { display: flex; align-items: center; gap: 8px; }
.brk__bar { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: #F0EEEA; overflow: hidden; margin-top: 3px; }
.brk__fill { height: 100%; border-radius: 4px; }

/* ---------- Editor popover ---------- */
.pop-backdrop { position: fixed; inset: 0; background: rgba(28,28,28,.28); z-index: 40; display: grid; place-items: center; padding: 20px; }
.pop {
  width: 100%; max-width: 360px; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-lift); overflow: hidden;
}
.pop__head { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.pop__head b { font-size: .95rem; }
.pop__body { padding: 16px 18px; }
.pop__slots { display: flex; gap: 8px; margin-bottom: 14px; }
.pop__slot { flex: 1; text-align: center; padding: 7px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: .8rem; font-weight: 700; cursor: pointer; }
.pop__slot.is-on { border-color: var(--ink); background: var(--ink); color: #fff; }
.cat-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.cat-opt { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-size: .82rem; font-weight: 600; }
.cat-opt:hover { border-color: var(--ink); }
.cat-opt.is-sel { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.cat-opt .swatch { width: 15px; height: 15px; }
.pop textarea { width: 100%; min-height: 54px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-family: inherit; font-size: .85rem; resize: vertical; }
.pop__foot { display: flex; gap: 8px; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--line); background: #FBFBF9; }

/* admin toolbar */
.adminbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: #FFF7F3; border: 1px solid #FFD9CB; border-radius: var(--radius); margin-bottom: 18px; font-size: .84rem; }
.adminbar b { color: var(--accent-ink); }
.adminbar .grow { flex: 1; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.toggle input { display: none; }
.toggle__track { width: 38px; height: 22px; border-radius: 999px; background: #D8D5CF; position: relative; transition: background .15s; }
.toggle__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + .toggle__track { background: var(--accent); }
.toggle input:checked + .toggle__track::after { transform: translateX(16px); }

/* ---------- NPS ---------- */
.nps-h { display: flex; justify-content: space-between; align-items: baseline; font-size: .84rem; font-weight: 600; color: #374151; margin-bottom: 10px; }
.nps-scale { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.nps-dot { flex: 1 1 auto; min-width: 26px; padding: 8px 0; border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; font-weight: 700; font-size: .82rem; cursor: pointer; color: var(--ink); transition: background .1s, border-color .1s, color .1s; }
.nps-dot:hover { border-color: var(--ink); }
.nps-dot.is-sel { background: var(--accent); border-color: var(--accent); color: #fff; }
.nps-comment { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-family: inherit; font-size: .85rem; resize: vertical; margin-bottom: 10px; }
.nps-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nps-status { font-size: .8rem; color: var(--muted); }
.nps-locked { font-size: .85rem; color: var(--muted); background: #F7F6F3; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.nps-other { display: flex; align-items: baseline; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .84rem; color: #374151; }
.nps-other > span:first-child { flex: 1; font-weight: 600; }
.nps-other b { font-size: 1.05rem; letter-spacing: -.01em; }
.nps-histhead { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.nps-leg { display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.nps-leg i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.nps-leg .d1 { background: var(--accent); } .nps-leg .d2 { background: #9AA3AF; }
.nps-hist { margin-top: 8px; }
.nps-hrow { display: grid; grid-template-columns: 1fr 32px 32px; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: .82rem; }
.nps-hrow:last-child { border-bottom: none; }
.nps-hw { color: var(--muted); }
.nps-hv { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; border-radius: 6px; background: #F0EEEA; color: var(--accent-ink); }
.nps-hv--o { background: #EEF0F2; color: #475569; }

.demo-banner { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 11px 16px; background: #EEF6FF; border: 1px solid #CFE3FB; border-radius: var(--radius); margin-bottom: 18px; font-size: .84rem; color: #1E40AF; }
.demo-banner b { color: #1D4ED8; }
.demo-banner span { color: #3B5B93; }

.editable-hint { font-size: .78rem; color: var(--muted); }
.inline-edit { border: 1px dashed transparent; border-radius: 6px; padding: 1px 4px; cursor: text; }
.is-editing .inline-edit { border-color: var(--line-strong); }

.footer-note { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 30px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: .85rem; font-weight: 600; box-shadow: var(--shadow-lift); z-index: 60; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================================
   RESPONSIVE (dessous du 15")
============================================================================ */
@media (max-width: 1080px) {
  .grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px 14px 50px; }
  .topbar { padding: 11px 14px; }
}

/* ============================================================================
   PRINT (récapitulatif de facturation propre en PDF)
============================================================================ */
@media print {
  .topbar, .adminbar, .mhead .period-nav, .card__head .hint, .footer-note, .btn, .iconbtn { display: none !important; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; border-color: #ccc; }
  .grid { grid-template-columns: 1fr; }
  .main { padding: 0; }
}
