:root {
  --blue: #27aae1; --blue-d: #1a86b5; --ink: #1f1f1f; --muted: #6b7280; --line: #e5e7eb;
  --bg: #f4f7fa; --card: #fff; --pink: #d91e63; --green: #8cc63f; --orange: #f7941d; --brown: #a67c52;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue-d); }
h1 { font-size: 26px; margin: 8px 0 18px; }
h2.sec { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }
h3 { margin: 0 0 14px; font-size: 17px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; } .r { text-align: right; }

/* ---- barre du haut */
.topbar { display: flex; align-items: center; gap: 18px; background: #161616; color: #fff; padding: 10px 22px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px;
  background: linear-gradient(90deg, var(--blue) 0 40%, var(--brown) 40% 55%, var(--pink) 55% 70%, var(--green) 70% 85%, var(--orange) 85%); }
.brand img { height: 40px; display: block; }
#nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
#nav a { color: #ddd; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
#nav a:hover { background: #2a2a2a; color: #fff; }
#nav a.active { background: var(--blue); color: #fff; }
#nav a.cta { border: 1px solid var(--blue); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #ccc; }
main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---- éléments */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.cards2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.cards2.tight { gap: 28px; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #fff; color: var(--ink); border: 1px solid #cfd5dc;
  border-radius: 9px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.ghost { background: transparent; }
.topbar .btn.ghost { color: #ddd; border-color: #444; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 14px 30px; font-size: 17px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: wait; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 12px; }
input, select, textarea { font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid #cfd5dc; border-radius: 9px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(39,170,225,.35); border-color: var(--blue); }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: auto; }
.row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.row > label { margin-bottom: 0; }
.row .grow { flex: 1; min-width: 220px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; margin-top: 14px; }
.span2 { grid-column: span 2; }
.alert { background: #fdecef; color: #9f1239; border: 1px solid #fbc6d1; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.alert.warn { background: #fff7e6; color: #92400e; border-color: #fcd9a5; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, white); border: 1px solid color-mix(in srgb, var(--c) 35%, white); white-space: nowrap; }
[hidden] { display: none !important; }
i.req { color: #be123c; font-style: normal; font-weight: 700; }
.req-note { margin: 0 0 8px; }

/* ---- tuiles du tableau de bord */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 8px; }
.tile { background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: 12px; padding: 16px 18px; }
.tile-n { font-size: 34px; font-weight: 800; line-height: 1; }
.tile-l { font-weight: 600; margin-top: 6px; }
.tile-s { color: var(--muted); font-size: 13px; margin-top: 2px; }
.cards2 .card { margin-bottom: 0; }
main > .cards2 { margin: 18px 0; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: 6px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar .stack { flex: 1; width: 100%; display: flex; flex-direction: column-reverse; background: #f3f5f8; border-radius: 4px 4px 0 0; overflow: hidden; }
.bar .stack i { display: block; width: 100%; }
.bar span { font-size: 10px; color: var(--muted); margin-top: 3px; }
.bar.now span { color: var(--blue-d); font-weight: 800; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
table.kv td:nth-child(2) { text-align: center; font-weight: 700; }
table.kv td:last-child { text-align: right; }

/* ---- tableaux */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr.cancelled td { opacity: .5; }
table.list tr.cancelled td:first-child b { text-decoration: line-through; }
td.actions { white-space: nowrap; text-align: right; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px; }
.filters > * { width: auto; flex: 1; min-width: 160px; }
.summary { font-size: 14px; color: var(--muted); margin-bottom: 10px; }

/* ---- nouveau document */
.seg { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.seg label { margin: 0; cursor: pointer; position: relative; }
.seg input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 12px 20px; border: 2px solid var(--line); border-radius: 12px; font-size: 15px; font-weight: 700; color: #444; background: #fff; }
.seg.small span { padding: 8px 14px; font-size: 14px; }
.seg input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); color: #111; }
.seg input:focus-visible + span { outline: 2px solid var(--c); }
.carousel-wrap { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.carousel { min-width: 0; display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 10px; flex: 1; scrollbar-width: thin; }
.prog { flex: 0 0 210px; scroll-snap-align: start; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; text-align: left;
  min-height: 112px; padding: 14px; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; transition: transform .15s, box-shadow .15s; }
.prog:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.prog.picked { background: #e8f7fd; }
.prog-name { font-weight: 600; font-size: 14px; }
.prog-price { font-weight: 800; color: var(--blue-d); font-size: 17px; }
.prog-tag { font-size: 11px; color: var(--muted); }
.car-btn { flex: 0 0 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
table.lines { width: 100%; border-collapse: collapse; margin-top: 14px; }
table.lines th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; padding: 6px; border-bottom: 2px solid var(--line); }
table.lines td { padding: 6px; border-bottom: 1px solid var(--line); }
table.lines td.r { font-weight: 600; white-space: nowrap; }
.x { border: none; background: #fdecef; color: #be123c; width: 30px; height: 30px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.quick { font-size: 13px; color: var(--muted); margin: -6px 0 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.totals { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; align-self: start; }
.totals div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed #dde3ea; }
.totals div:last-child { border-bottom: none; }
.totals .big { font-size: 19px; }
.totals .paid b { color: #15803d; }
.totals .rest b { color: var(--pink); }
.actions-bar { display: flex; justify-content: flex-end; position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 35%); }
.user-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.user-row .badge { align-self: center; }

/* ---- connexion */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #161616 0%, #161616 55%, var(--blue) 55%, var(--blue) 100%); }
.login-card { background: #fff; width: 100%; max-width: 400px; padding: 34px 30px; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card.wide { max-width: 860px; }
.login-card h1 { font-size: 21px; margin: 10px 0 4px; }
.login-logo { height: 70px; display: block; }
.login-card fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 14px; padding: 12px 16px 0; }
.login-card legend { font-weight: 700; padding: 0 6px; }
.login-card .grid3 { margin-top: 0; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111; color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
#toast.bad { background: #be123c; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .cards2 { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  main { padding: 16px; }
  .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .who span { display: none; }
  .tile-n { font-size: 26px; }
  .car-btn { display: none; }
}
