/* S2EE — Espace devis TRA-SE-104 */
:root {
  --p: #0B4F8A;
  --p-dark: #083b68;
  --p-light: #e7f0f9;
  --ok: #158a4b;
  --ok-light: #e6f5ec;
  --warn: #b7791f;
  --warn-light: #fff6e0;
  --err: #c53030;
  --err-light: #fdecec;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #d9dee5;
  --bg: #f3f5f8;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--p); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ---- Layout ---- */
.topbar { background: var(--p); color: #fff; }
.topbar .inner { max-width: 1100px; margin: 0 auto; padding: .7rem 1.2rem; display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.topbar .brand { font-weight: 700; font-size: 1.1rem; color: #fff; text-decoration: none; display: flex; align-items: center; gap: .6rem; }
.topbar .brand img { height: 30px; background: #fff; border-radius: 6px; padding: 3px; }
.topbar nav { display: flex; gap: .2rem; margin-left: auto; align-items: center; flex-wrap: wrap; }
.topbar nav a, .topbar nav button { color: #fff; text-decoration: none; padding: .45rem .8rem; border-radius: 8px; background: transparent; border: 0; font: inherit; cursor: pointer; opacity: .9; }
.topbar nav a:hover, .topbar nav a.active, .topbar nav button:hover { background: rgba(255, 255, 255, .16); opacity: 1; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.wrap.narrow { max-width: 780px; }
.page-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.4rem 1.5rem; margin-bottom: 1.2rem; }
.card.narrow { width: 100%; max-width: 440px; }
.card h2 { margin-bottom: 1rem; }
.err-code { font-size: 3rem; font-weight: 800; color: var(--p); opacity: .35; }
footer.site { text-align: center; color: var(--muted); font-size: .82rem; padding: 1rem; }

/* ---- Flash ---- */
.flash { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash.success { background: var(--ok-light); color: #0f5c33; border-color: #b7e2c7; }
.flash.error { background: var(--err-light); color: #8a1c1c; border-color: #f3b8b8; }
.flash.warn { background: var(--warn-light); color: #7a4c0a; border-color: #f2d58a; }
.flash.info { background: var(--p-light); color: var(--p-dark); border-color: #bcd4ec; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=url], select, textarea {
  width: 100%; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 9px; font: inherit; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--p); box-shadow: 0 0 0 3px rgba(11, 79, 138, .15); }
input.invalid, select.invalid { border-color: var(--err); background: #fff8f8; }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 1rem; }
.field .help { font-size: .82rem; color: var(--muted); margin-top: .3rem; }
.field .error { font-size: .82rem; color: var(--err); margin-top: .3rem; font-weight: 600; }
.row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0 1rem; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }
@media (max-width: 720px) { .row > * { grid-column: span 12; } }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: .15rem; flex: none; }
.radios { display: grid; gap: .5rem; }
.radio-card { display: flex; gap: .7rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 400; background: #fff; }
.radio-card:has(input:checked) { border-color: var(--p); background: var(--p-light); }
.radio-card input { margin-top: .2rem; flex: none; }
.radio-card b { display: block; }
.inline-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.input-group { display: flex; gap: .5rem; }
.input-group input { flex: 1; }
.suggest { position: relative; }
.suggest-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); max-height: 240px; overflow: auto; margin-top: 3px; }
.suggest-list div { padding: .5rem .75rem; cursor: pointer; font-size: .92rem; }
.suggest-list div:hover, .suggest-list div.active { background: var(--p-light); }
.siren-ok { color: var(--ok); font-size: .86rem; margin-top: .3rem; font-weight: 600; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .62rem 1.1rem; border-radius: 9px; border: 1px solid var(--p); background: var(--p); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--p-dark); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--p); }
.btn.secondary:hover { background: var(--p-light); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #fff; }
.btn.danger { background: #fff; color: var(--err); border-color: #f0b4b4; }
.btn.danger:hover { background: var(--err-light); }
.btn.success { background: var(--ok); border-color: var(--ok); }
.btn.success:hover { background: #0f6b3a; }
.btn.sm { padding: .38rem .7rem; font-size: .86rem; }
.btn.lg { padding: .8rem 1.5rem; font-size: 1.05rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.actions .spacer { flex: 1; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th, table.list td { padding: .65rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
table.list tr:hover td { background: #fafbfd; }
table.list td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.badge.brouillon { background: #eef0f3; color: #4b5563; }
.badge.envoye { background: var(--p-light); color: var(--p-dark); }
.badge.rempli { background: var(--warn-light); color: #7a4c0a; }
.badge.signe { background: var(--ok-light); color: #0f5c33; }
.badge.annule { background: var(--err-light); color: #8a1c1c; }
.badge.type { background: #eef0f3; color: #374151; }

/* ---- Stats / filters ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.stat { background: var(--card); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); border: 2px solid transparent; }
.stat.active { border-color: var(--p); }
.stat .n { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.stat .l { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar form { display: flex; gap: .5rem; flex: 1; min-width: 240px; }
.toolbar input { flex: 1; }

/* ---- Détails dossier ---- */
.kv { width: 100%; font-size: .93rem; border-collapse: collapse; }
.kv td { padding: .35rem 0; vertical-align: top; border-bottom: 1px dashed #eceff3; }
.kv td:first-child { color: var(--muted); width: 42%; padding-right: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.linkbox { display: flex; gap: .5rem; align-items: center; background: var(--p-light); border-radius: 9px; padding: .6rem .7rem; }
.linkbox input { flex: 1; border: 0; background: transparent; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86rem; color: var(--p-dark); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.timeline li { padding: .4rem 0 .4rem 1.1rem; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .8rem; width: 10px; height: 10px; border-radius: 50%; background: var(--p); }
.timeline .t { color: var(--muted); font-size: .78rem; }
.total-line { display: flex; justify-content: space-between; padding: .3rem 0; }
.total-line.grand { font-weight: 800; font-size: 1.1rem; border-top: 2px solid var(--ink); margin-top: .3rem; padding-top: .5rem; }
.total-line.prime { color: var(--ok); }
.total-line.reste { background: var(--p-light); padding: .5rem .6rem; border-radius: 8px; font-weight: 700; margin-top: .3rem; }

/* ---- Formulaire client (étapes) ---- */
.hero { background: linear-gradient(135deg, var(--p) 0%, var(--p-dark) 100%); color: #fff; padding: 1.6rem 1.2rem 3.4rem; }
.hero .inner { max-width: 860px; margin: 0 auto; }
.hero h1 { font-size: 1.45rem; margin-bottom: .3rem; }
.hero p { opacity: .9; margin: 0; }
.hero .ref { font-size: .85rem; opacity: .8; margin-bottom: .6rem; }
.hero img { height: 40px; background: #fff; border-radius: 8px; padding: 4px; margin-bottom: .8rem; }
.form-wrap { max-width: 860px; margin: -2.4rem auto 3rem; padding: 0 1.2rem; }
.steps { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.steps .step { flex: 1; min-width: 120px; background: #fff; border-radius: 10px; padding: .55rem .7rem; font-size: .8rem; font-weight: 600; color: var(--muted); box-shadow: var(--shadow); display: flex; gap: .5rem; align-items: center; }
.steps .step .n { width: 22px; height: 22px; border-radius: 50%; background: #e5e7eb; color: #374151; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; flex: none; }
.steps .step.active { color: var(--p-dark); }
.steps .step.active .n { background: var(--p); color: #fff; }
.steps .step.done .n { background: var(--ok); color: #fff; }
.panel { display: none; }
.panel.active { display: block; }
.station { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1rem .2rem; margin-bottom: 1rem; position: relative; background: #fbfcfd; }
.station .st-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.station .st-head h3 { margin: 0; font-size: 1rem; color: var(--p-dark); }
.type-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
@media (max-width: 720px) { .type-cards { grid-template-columns: 1fr; } }
.type-card { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; cursor: pointer; font-weight: 400; font-size: .85rem; background: #fff; }
.type-card:has(input:checked) { border-color: var(--p); background: var(--p-light); }
.type-card b { display: block; font-size: .95rem; }
.type-card input { margin-right: .35rem; }
.type-card .prix { display: block; color: var(--p-dark); font-weight: 700; margin-top: .25rem; }
.recap h3 { margin-top: 1rem; color: var(--p-dark); font-size: .95rem; text-transform: uppercase; letter-spacing: .03em; }
.recap .kv td:first-child { width: 36%; }
.overlay { position: fixed; inset: 0; background: rgba(255, 255, 255, .85); display: none; align-items: center; justify-content: center; z-index: 50; flex-direction: column; gap: 1rem; text-align: center; padding: 1rem; }
.overlay.show { display: flex; }
.spinner { width: 46px; height: 46px; border: 5px solid var(--p-light); border-top-color: var(--p); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-steps { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .6rem; }
.status-steps li { display: flex; gap: .8rem; align-items: flex-start; padding: .7rem .9rem; border-radius: 10px; background: #fbfcfd; border: 1px solid var(--line); }
.status-steps .n { width: 28px; height: 28px; border-radius: 50%; background: var(--p); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 1.2rem; text-align: center; background: #fbfcfd; }
.dropzone input { display: block; margin: .6rem auto 0; }
.files-list { list-style: none; padding: 0; margin: .5rem 0 0; font-size: .9rem; }
.files-list li { padding: .3rem 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 1rem; }
.qr { background: #fff; padding: 8px; display: inline-block; border: 1px solid var(--line); border-radius: 8px; }
code.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f1f3f5; padding: .2rem .4rem; border-radius: 5px; letter-spacing: .08em; }
details summary { cursor: pointer; font-weight: 600; color: var(--p-dark); }
.section-title { display: flex; align-items: center; gap: .6rem; margin: 1.6rem 0 .8rem; padding-bottom: .4rem; border-bottom: 2px solid var(--p-light); color: var(--p-dark); font-size: 1.05rem; }
.print-hint { background: var(--warn-light); border: 1px solid #f2d58a; border-radius: 10px; padding: .8rem 1rem; font-size: .92rem; }
