:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e2e4e9;
  --text: #15171c;
  --muted: #697080;
  --accent: #e31937;
  --accent-text: #ffffff;
  --ok: #138a4b;
  --ok-bg: #e3f5eb;
  --warn: #9a6200;
  --warn-bg: #fff3d6;
  --info: #2457c5;
  --info-bg: #e5edfd;
  --idle-bg: #eceef2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 20, 30, .05), 0 6px 24px rgba(16, 20, 30, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0e;
    --surface: #15171b;
    --surface-2: #1d2025;
    --border: #2a2e35;
    --text: #eef0f3;
    --muted: #9198a5;
    --ok: #4cd18a;
    --ok-bg: #12301f;
    --warn: #f2b84b;
    --warn-bg: #352812;
    --info: #7aa5ff;
    --info-bg: #17233f;
    --idle-bg: #23262c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
code, kbd { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; word-break: break-all; }
.muted { color: var(--muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 10px 16px;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: progress; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; padding: 8px 12px; }
button.ghost:hover { background: var(--surface-2); }
button.link { background: none; border: none; padding: 0; color: var(--info); font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
button.danger { color: var(--accent); }

input, select {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.logo { width: 30px; height: 30px; border-radius: 8px; }
.top-actions { display: flex; gap: 4px; }

main { max-width: 860px; margin: 0 auto; padding: 20px 16px 64px; }
.view { display: grid; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 17px; }

.hero { padding: 16px 0 4px; }
.hero h1 { font-size: clamp(26px, 6vw, 36px); margin-bottom: 8px; }
.login-main { display: grid; gap: 14px; }
button.big { padding: 14px 20px; font-size: 16px; }
.manual { font-size: 14px; }
.row { display: flex; gap: 8px; }
.alt summary, .settings summary { cursor: pointer; font-weight: 600; }
.alt .row { margin-top: 12px; }
.error { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 10px; padding: 10px 12px; }
.install { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.install img { border-radius: 10px; flex: none; }
.install div { flex: 1; min-width: 0; font-size: 14px; }
.install p { font-size: 13px; }
.install button { flex: none; }
.pair-card { display: grid; gap: 8px; }
.pair-share { display: grid; gap: 8px; justify-items: start; padding-top: 12px; border-top: 1px solid var(--border); }
.pair-share p { margin: 0 !important; }
.pair-code { font: 700 34px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; color: var(--text); }
.banner { background: var(--info-bg); color: var(--info); border-radius: 12px; padding: 10px 14px; }
.updated { font-size: 13px; }

/* Commande */
.order.card { padding: 0; overflow: hidden; }
.order-body { display: grid; gap: 14px; padding: 16px 18px 18px; }
.order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.model { font-size: 24px; font-weight: 750; line-height: 1.1; }
.order-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.badge { flex: none; font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; padding: 5px 10px; border-radius: 99px; background: var(--idle-bg); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.tone-warn { color: var(--warn) !important; }

/* Carrousel d'images */
.car { position: relative; background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slides img { flex: 0 0 100%; width: 100%; aspect-ratio: 1150 / 500; object-fit: contain; scroll-snap-align: center; }
.slide-label { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: color-mix(in srgb, var(--surface) 80%, transparent); }
.car-dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.car-dot { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%; background: var(--muted); opacity: .45; }
.car-dot.active { opacity: 1; background: var(--text); }
.car-dot:hover { background: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 99px; background: var(--surface-2); }
.swatch { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .5); }

/* Lignes d'infos clés */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.info-row { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; padding: 6px 0; }
.info-row.fresh .info-value { color: var(--ok); }
.ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.ico svg { width: 18px; height: 18px; }
.ico-key { color: var(--warn); }
.ico-calendar { color: #2fb36b; }
.ico-pin { color: #a46bf0; }
.ico-clock { color: var(--info); }
.info-text { display: grid; min-width: 0; line-height: 1.3; }
.info-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.info-value { font-weight: 650; overflow-wrap: anywhere; }
.info-sub { font-size: 12px; color: var(--muted); }

/* Estimation */
.predict { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--info-bg); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.predict-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.predict-title { font-weight: 700; color: var(--info); }
.predict .badge { text-transform: none; letter-spacing: 0; font-size: 11px; padding: 3px 8px; }
.predict-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pred { display: grid; gap: 1px; min-width: 0; }
.pred + .pred { border-left: 1px solid color-mix(in srgb, var(--info) 25%, transparent); padding-left: 12px; }
.pred-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.pred-main { font-size: 22px; font-weight: 750; }
.pred-sub { font-size: 12px; color: var(--muted); }
.progress { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--info) 15%, transparent); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--info), var(--ok)); transition: width .4s ease; }
.progress-label { font-size: 12px; color: var(--muted); margin-top: -4px; }
.progress-label:empty { display: none; }
.why summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--info); }
.why-list { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

.last-change { padding: 10px 14px; border-radius: 12px; background: var(--warn-bg); }
.lc-date { font-size: 12px; color: var(--warn); font-weight: 600; }
.lc-text { font-weight: 650; }

/* Progression horizontale */
.progression { display: grid; gap: 10px; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); }
.st { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; }
.st::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--border); }
.st:first-child::before { display: none; }
.st.done::before, .st.current::before { background: var(--ok); }
.st-dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--idle-bg); color: var(--muted); border: 2px solid var(--border); }
.st.done .st-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.st.current .st-dot { background: var(--surface); border-color: var(--info); color: var(--info); box-shadow: 0 0 0 4px var(--info-bg); }
.st-label { font-size: 11px; font-weight: 600; color: var(--muted); }
.st.current .st-label { color: var(--text); }
.step-now { display: grid; gap: 2px; font-size: 13px; color: var(--muted); padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.step-now strong { color: var(--text); font-size: 14px; }

/* Sections repliables */
.fold { border-top: 1px solid var(--border); padding-top: 12px; }
.fold > summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; cursor: pointer; font-weight: 650; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "›"; font-size: 20px; line-height: 1; color: var(--muted); transition: transform .2s; }
.fold[open] > summary::after { transform: rotate(90deg); }
.fold > summary .fold-meta { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--muted); }
.fold[open] > :not(summary) { margin-top: 12px; }
.history-card { padding: 16px 18px; }
.history-card.fold { border-top: 1px solid var(--border); }

.specs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.spec { display: grid; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; }
.spec strong { font-size: 16px; }
.spec span { font-size: 11px; color: var(--muted); }
.codes { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tasks li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; }
.tasks .badge { font-size: 10px; padding: 3px 8px; }
.task-name { font-weight: 600; font-size: 14px; }
.task-sub { font-size: 12px; color: var(--muted); }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links:empty { display: none; }
.button-link { display: inline-block; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
.button-link:hover { background: var(--surface-2); }

.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.raw pre { max-height: 360px; overflow: auto; font-size: 12px; background: var(--surface-2); border-radius: 10px; padding: 12px; }

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.history > li { border-left: 3px solid var(--info); padding: 2px 0 2px 12px; }
.history time { font-size: 12px; color: var(--muted); }
.history ul { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.history del { color: var(--muted); }
.history ins { text-decoration: none; color: var(--ok); font-weight: 600; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(440px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.settings { display: grid; gap: 16px; padding: 20px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-row input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.field { display: grid; gap: 6px; }
.settings details p { margin: 8px 0; font-size: 13px; }
.settings-foot { display: flex; justify-content: space-between; gap: 8px; }

@media (max-width: 640px) {
  main { padding: 12px 10px 48px; }
  .view { gap: 12px; }
  .order-body { padding: 14px; gap: 12px; }
  .model { font-size: 22px; }
  .pred-main { font-size: 19px; }
  .spec { padding: 7px 9px; }
  .spec strong { font-size: 14px; }
  .st-label { font-size: 10px; }
  .row { flex-direction: column; }
  .hide-sm { display: none; }
  .card { padding: 16px; }
}
