:root {
  --bg: #F6F5F1;
  --card: #FFFFFF;
  --ink: #0F1B33;
  --ink2: #4A5568;
  --muted: #8A94A6;
  --line: #E6E4DE;
  --navy: #0F1B33;
  --navy2: #1C2B4A;
  --em: #0E9F6E;
  --em-soft: #E3F5EE;
  --warn: #C26A06;
  --warn-soft: #FDF1E1;
  --bad: #C8322B;
  --bad-soft: #FBE7E5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,27,51,.05), 0 2px 8px rgba(15,27,51,.04);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.num, td.r, .kpi b { font-variant-numeric: tabular-nums; }

#app { display: flex; min-height: 100vh; }
.side {
  width: 236px; flex: none; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; }
.brand b { display: block; font-size: 14px; letter-spacing: .02em; }
.brand small { color: #9FB0CC; font-size: 12px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--em);
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
#nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; }
#nav a {
  text-decoration: none; padding: 9px 12px; border-radius: 8px; color: #C9D3E6;
  display: flex; gap: 10px; align-items: center;
}
#nav a:hover { background: var(--navy2); color: #fff; }
#nav a.on { background: var(--navy2); color: #fff; font-weight: 600; }
#nav svg, .bottom svg { width: 18px; height: 18px; flex: none; }
.side-foot { padding: 14px 18px; font-size: 12px; color: #9FB0CC; border-top: 1px solid var(--navy2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--em); } .dot.wait { background: #F5A524; } .dot.err { background: var(--bad); }

main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
#main { max-width: 1180px; margin: 0 auto; }
.bottom { display: none; }

h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--ink2); }
.sub { color: var(--muted); font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.stack > * + * { margin-top: 14px; }

.kpi { padding: 14px 16px; }
.kpi span { display: block; color: var(--ink2); font-size: 12px; }
.kpi b { display: block; font-size: 20px; margin-top: 4px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi small { color: var(--muted); font-size: 12px; }
.pos { color: var(--em); } .neg { color: var(--bad); } .warnc { color: var(--warn); }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 9px;
  padding: 8px 14px; cursor: pointer; font-weight: 500; display: inline-flex; gap: 6px; align-items: center;
}
.btn:hover { border-color: #CFCBC2; }
.btn.pri { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.pri:hover { background: var(--navy2); }
.btn.em { background: var(--em); border-color: var(--em); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--em); cursor: pointer; font-weight: 500; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { min-width: 0; }
input, select, textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(14,159,110,.25); border-color: var(--em); }
.filters input, .filters select { width: auto; }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--ink2); font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.calc { background: var(--em-soft); border-radius: 8px; padding: 10px 12px; font-weight: 600; color: #0B6B4B; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; white-space: nowrap; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #FAF9F6; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.tbl { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: #EEF0F4; color: var(--ink2); white-space: nowrap; }
.badge.b-em { background: var(--em-soft); color: #0B6B4B; }
.badge.b-warn { background: var(--warn-soft); color: var(--warn); }
.badge.b-bad { background: var(--bad-soft); color: var(--bad); }
.badge.b-navy { background: #E4E9F3; color: var(--navy); }

.alert { border-radius: 10px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: #E4E9F3; color: var(--navy); }
#banner .alert { margin: 0 auto 14px; max-width: 1180px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--ink2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-color: var(--em); font-weight: 600; }

.bar { height: 8px; background: #EEECE6; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--em); border-radius: 99px; }
.bar i.warn { background: #F5A524; } .bar i.bad { background: var(--bad); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

.modal { position: fixed; inset: 0; background: rgba(15,27,51,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none; }
.dialog { background: #fff; border-radius: 14px; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(15,27,51,.25); }
.dialog header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dialog header h2 { margin: 0; }
.dialog .body { padding: 18px 20px; }
.dialog footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); padding: 28px; }

@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) {
  .side { display: none; }
  main { padding: 16px 16px 90px; }
  .bottom {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--navy);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40;
  }
  .bottom a { flex: 1; text-decoration: none; color: #9FB0CC; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 4px 0; }
  .bottom a.on { color: #fff; }
  .g3, .g2 { grid-template-columns: minmax(0,1fr); }
  .form { grid-template-columns: 1fr; }
  .kpi b { font-size: 18px; }
  h1 { font-size: 19px; }
  .hide-m { display: none; }
  .filters input, .filters select { flex: 1 1 140px; }
}

/* ---------- Holding : sélecteur d'entreprise, badges, validations ---------- */
.ctxbar { display: flex; gap: 6px; overflow-x: auto; max-width: 1180px; margin: 0 auto 16px; align-items: center; padding-bottom: 2px; scrollbar-width: none; }
.ctxbar::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 13px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; font-weight: 500; flex: none; }
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip:hover { border-color: #CFCBC2; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
span.chip { cursor: default; }
.badge.cob { display: inline-flex; align-items: center; gap: 5px; background: #F1F0EC; color: var(--ink); font-weight: 600; letter-spacing: .02em; }
.badge.cob i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.dotc { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.co-card { border-top: 3px solid var(--c); cursor: pointer; }
.co-card:hover { box-shadow: 0 2px 4px rgba(15,27,51,.06), 0 6px 18px rgba(15,27,51,.08); }
.stackbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: #EEECE6; }
.stackbar i { display: block; height: 100%; }
.nbadge { font-style: normal; background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 600; padding: 0 6px; line-height: 17px; margin-left: auto; }
.bottom a { position: relative; }
.bottom .nbadge { position: absolute; top: 0; left: 50%; margin-left: 6px; }
tr.hl td { background: #FFF8EC; }
.alert .spacer { flex: 1; }
.only-m { display: none; }
@media (max-width: 760px) { .only-m { display: block; } }
.co-card .kv { grid-template-columns: 1fr auto; }
.co-card .kv dd { text-align: right; white-space: nowrap; }
.co-card h2 { min-width: 0; }
