@font-face { font-family: Manrope; font-weight: 200 800; font-display: swap; src: url(fonts/manrope-latin-wght-normal.woff2) format("woff2"); }
@font-face { font-family: Manrope; font-weight: 200 800; font-display: swap; src: url(fonts/manrope-latin-ext-wght-normal.woff2) format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF; }

:root {
  --bg: #edf1fa; --surface: #fff; --soft: #f5f7fc; --ink: #2d3847; --emph: #223650; --muted: #747a96; --line: #e0e5ed;
  --blue: #1991ee; --blue-dark: #0f76c5; --blue-soft: #e4f1fd; --dark: #0c273a;
  --green: #39a243; --green-soft: #e3f4e5; --red: #ce312d; --red-soft: #fbe6e5; --yellow: #f7b525; --yellow-soft: #fdf2d9;
  --grad: linear-gradient(40deg, #1865e0 0%, #199ef2 50%, #16b6f5 100%);
  --grad-btn: linear-gradient(51deg, #1865e0 50%, #199ef2 80%, #16b6f5 100%);
  --stripes: linear-gradient(90deg, #2ab3dd 0 25%, #ce312d 25% 50%, #f7b525 50% 75%, #39a243 75% 100%);
  --r: 16px; --shadow: 0 1px 2px rgba(34,54,80,.05), 0 8px 24px rgba(34,54,80,.06);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: Manrope, system-ui, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
.stripes { height: 4px; background: var(--stripes); position: sticky; top: 0; z-index: 20; }
h1 { font-size: 1.7rem; font-weight: 800; color: var(--emph); margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; font-weight: 800; color: var(--emph); margin: 0 0 .8rem; }
h3 { font-size: .95rem; font-weight: 800; color: var(--emph); margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Structure */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 4px); }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 4px; height: calc(100vh - 4px); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand img { height: 38px; }
.brand span { font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #fff; background: var(--grad); padding: 3px 8px; border-radius: 99px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 12px; color: var(--ink); font-weight: 600; font-size: .93rem; }
.side nav a svg { width: 19px; height: 19px; fill: var(--muted); flex: none; }
.side nav a:hover { background: var(--soft); }
.side nav a.on { background: var(--blue-soft); color: var(--blue-dark); }
.side nav a.on svg { fill: var(--blue); }
.side-foot { margin-top: auto; font-size: .8rem; color: var(--muted); padding: 0 8px; }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; }

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head .kicker { font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--blue); margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

/* KPI */
.kpi { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi .l { font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .v { font-size: 1.6rem; font-weight: 800; color: var(--emph); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: .82rem; color: var(--muted); }
.kpi.hl { background: var(--grad); color: #fff; }
.kpi.hl .l, .kpi.hl .s { color: rgba(255,255,255,.85); }
.kpi.hl .v { color: #fff; }

/* Boutons */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: .9rem;
  padding: 9px 18px; border-radius: 99px; background: var(--grad-btn); color: #fff; box-shadow: 0 6px 16px rgba(24,101,224,.22); white-space: nowrap; }
.btn:hover { color: #fff; filter: brightness(1.05); }
.btn.ghost { background: var(--surface); color: var(--emph); box-shadow: none; border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn.danger { background: var(--surface); color: var(--red); box-shadow: none; border: 1px solid var(--red-soft); }
.btn.sm { padding: 6px 12px; font-size: .82rem; }
.btn.green { background: var(--green); box-shadow: 0 6px 16px rgba(57,162,67,.22); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; }
.linkbtn.red { color: var(--red); }

/* Formulaires */
label { display: block; font-size: .8rem; font-weight: 700; color: var(--emph); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: .93rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(25,145,238,.25); border-color: var(--blue); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }
.help { font-size: .78rem; color: var(--muted); margin-top: 3px; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--soft); }
table.list .num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list tfoot td { font-weight: 800; color: var(--emph); border-top: 2px solid var(--line); }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }

.badge { display: inline-block; font-size: .74rem; font-weight: 800; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.badge.grey { background: #eef0f5; color: var(--muted); }
.badge.blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge.green { background: var(--green-soft); color: #23772c; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.yellow { background: var(--yellow-soft); color: #9a6a00; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 14px; border-radius: 99px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: .85rem; border: 1px solid var(--line); }
.tabs a.on { background: var(--emph); color: #fff; border-color: var(--emph); }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; }
.flash.ok { background: var(--green-soft); color: #23772c; }
.flash.error { background: var(--red-soft); color: var(--red); }

/* Éditeur de lignes */
.lines { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.lines th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: left; padding: 0 6px; }
.lines td { padding: 0 3px; vertical-align: top; }
.lines tr.line > td { background: var(--soft); padding-top: 8px; padding-bottom: 8px; }
.lines tr.line > td:first-child { border-radius: 12px 0 0 12px; padding-left: 8px; }
.lines tr.line > td:last-child { border-radius: 0 12px 12px 0; padding-right: 8px; }
.lines input, .lines textarea, .lines select { font-size: .88rem; padding: 7px 9px; }
.lines textarea { min-height: 38px; margin-top: 5px; }
.lines .w-qty { width: 70px; } .lines .w-unit { width: 90px; } .lines .w-price { width: 100px; } .lines .w-disc { width: 64px; } .lines .w-amt { width: 100px; }
.lines td.grow { min-width: 260px; }
.lines .amt { font-weight: 800; color: var(--emph); padding-top: 8px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines tr.title > td { background: var(--blue-soft); }
.lines tr.title input { font-weight: 800; }
.lines .tools { white-space: nowrap; }
.lines .tools button { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 6px 4px; }
.lines .tools button:hover { color: var(--blue); }
.totals { margin-left: auto; width: min(360px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 5px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.25rem; font-weight: 800; color: var(--emph); border-top: 2px solid var(--line); margin-top: 6px; padding-top: 10px; }
.addbar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* Graphique simple */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 170px; padding-top: 10px; }
.bars .m { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .b { width: 40%; max-width: 16px; border-radius: 5px 5px 0 0; min-height: 2px; }
.bars .in { background: var(--grad); }
.bars .out { background: #c9d2e3; }
.bars .lab { font-size: .7rem; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 30px; }
.login img { height: 46px; margin-bottom: 18px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav a { padding: 6px 10px; font-size: .85rem; }
  .side-foot { margin: 0; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .lines thead { display: none; }
  .lines tr.line { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--soft); border-radius: 12px; padding: 8px; margin-bottom: 8px; }
  .lines tr.line > td { background: none !important; padding: 0 !important; border-radius: 0 !important; width: auto !important; }
  .lines tr.line > td.grow { grid-column: span 2; }
}
