/* ==========================================================================
   Auto Xpress — Gestion
   Même ADN que le site (bleu du logo, orange d'action, Plus Jakarta Sans + Inter),
   en version outil : dense, lisible, contrastes renforcés.
   ========================================================================== */
:root {
	--ink: #14213d; --ink-soft: #3d4a63; --muted: #66728a;
	--brand: #004d9e; --brand-deep: #002e63; --brand-light: #5b9bec;
	--accent: #e8590c; --soft: #e8f0fb; --paper: #f4f6fa; --white: #fff; --line: #dfe5ee;
	--green: #1f7a3d; --green-bg: #e3f4e8; --blue: #1856a8; --blue-bg: #e4eefb;
	--amber: #8a5300; --amber-bg: #fdf1d8; --red: #b42318; --red-bg: #fdeceb;
	--violet: #5b3fa0; --violet-bg: #eee9fa; --grey: #535d70; --grey-bg: #eceff4;
	--serif: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
	--sans: "Inter", "Segoe UI", system-ui, sans-serif;
	--r: 8px; --side: 236px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 15px/1.5 var(--sans); color: var(--ink); background: var(--paper); }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; font-weight: 500; }
h1 { font: 700 1.75rem/1.15 var(--serif); letter-spacing: -.01em; }
h2 { font: 700 1.1rem/1.25 var(--serif); margin-bottom: .9rem; }
h3 { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1rem 0 .3rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.gi { width: 18px; height: 18px; flex: none; }
.r { text-align: right; }
.g-muted { color: var(--muted); }
.g-red { color: var(--red); }

/* ---------- Coquille ---------- */
.g-side {
	position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 30; overflow-y: auto;
	background: var(--brand-deep); color: rgba(232, 240, 251, .82);
	display: flex; flex-direction: column; padding: 18px 12px;
}
.g-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: var(--soft); text-decoration: none; }
.g-brand img { width: 44px; height: auto; }
.g-brand span { font: 700 1.05rem/1.1 var(--serif); letter-spacing: .02em; }
.g-brand small { display: block; font: 500 .66rem/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--brand-light); margin-top: 4px; }
.g-nav, .g-side__foot { display: flex; flex-direction: column; gap: 2px; }
.g-nav a, .g-side__foot a {
	display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r);
	color: inherit; text-decoration: none; font-size: .95rem;
}
.g-nav a:hover, .g-side__foot a:hover { background: rgba(255, 255, 255, .06); color: var(--white); }
.g-nav a[aria-current], .g-side__foot a[aria-current] { background: var(--brand); color: var(--white); box-shadow: inset 3px 0 0 var(--accent); }
.g-count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 11px; background: var(--accent); color: var(--white); font-size: .75rem; text-align: center; }
.g-side__foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 10px; }
.g-user { font-size: .75rem; color: rgba(232, 240, 251, .55); padding: 8px 12px 0; margin: 0; }
.g-main { margin-left: var(--side); min-height: 100vh; }
.g-top { display: none; }
.g-content { padding: 28px clamp(16px, 3vw, 40px) 80px; max-width: 1320px; }
.g-flash { padding: 0 clamp(16px, 3vw, 40px); max-width: 1320px; }
.g-flash .g-msg:first-child { margin-top: 20px; }

/* ---------- En-têtes d'écran ---------- */
.g-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.g-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.g-sub { margin: 4px 0 0; color: var(--muted); }
.g-back { display: inline-block; font-size: .85rem; color: var(--muted); text-decoration: none; margin-bottom: 6px; }
.g-back:hover { color: var(--brand); }
.g-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.g-actions form { margin: 0; }

/* ---------- Boutons ---------- */
.g-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	padding: 9px 16px; border-radius: var(--r); border: 1px solid var(--line);
	background: var(--white); color: var(--ink); font: 500 .9rem/1.2 var(--sans);
	text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s;
}
.g-btn:hover { border-color: var(--ink-soft); }
.g-btn--primary { background: var(--brand); border-color: var(--brand); color: var(--white); }
.g-btn--primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.g-btn--danger { color: var(--red); border-color: transparent; background: transparent; }
.g-btn--danger:hover { background: var(--red-bg); border-color: var(--red-bg); }
.g-btn--sm { padding: 6px 10px; font-size: .82rem; }
.g-btn--block { width: 100%; }
.g-btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.g-btn-row form { margin: 0; }
.g-icon-btn { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 6px; cursor: pointer; }
.g-icon-btn:hover { color: var(--red); background: var(--red-bg); }
.g-link { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; text-decoration: none; }

/* ---------- Messages ---------- */
.g-msg { padding: 11px 14px; border-radius: var(--r); background: var(--grey-bg); margin: 0 0 12px; }
.g-msg--ok { background: var(--green-bg); color: var(--green); }
.g-msg--err { background: var(--red-bg); color: var(--red); }
.g-alert { padding: 14px 16px; border-radius: var(--r); background: var(--amber-bg); color: var(--amber); margin-bottom: 20px; border-left: 4px solid var(--amber); }

/* ---------- Cartes & grilles ---------- */
.g-card { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; margin-bottom: 18px; }
.g-card--accent { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 77, 158, .06); }
.g-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.g-cols--doc { grid-template-columns: 1fr 1.4fr; }
.g-cols--view { grid-template-columns: minmax(0, 1fr) 340px; }
.g-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.g-narrow { max-width: 760px; }
.g-empty { color: var(--muted); padding: 10px 0; margin: 0; }
td.g-empty { padding: 28px 14px; text-align: center; }

.g-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.g-kpi { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.g-kpi:hover { border-color: var(--brand); }
.g-kpi span { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.g-kpi strong { font: 700 1.7rem/1.1 var(--serif); color: var(--brand); }
.g-kpi small { color: var(--muted); }

.g-list { list-style: none; margin: 0; padding: 0; }
.g-list li + li { border-top: 1px solid var(--line); }
.g-list a { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 2px; text-decoration: none; color: var(--ink); }
.g-list a:hover strong { color: var(--brand); }
.g-list strong { font-weight: 500; }
.g-list span { flex: none; color: var(--muted); font-size: .9rem; display: flex; gap: 8px; align-items: center; }
.g-dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; }
.g-dl dt { color: var(--muted); font-size: .88rem; }
.g-dl dd { margin: 0; }
.g-message { white-space: normal; background: var(--paper); border-radius: var(--r); padding: 16px; margin-bottom: 16px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font: 500 .75rem/1.6 var(--sans); white-space: nowrap; vertical-align: middle; }
.badge--grey { background: var(--grey-bg); color: var(--grey); }
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--blue { background: var(--blue-bg); color: var(--blue); }
.badge--amber { background: var(--amber-bg); color: var(--amber); }
.badge--red { background: var(--red-bg); color: var(--red); }
.badge--violet { background: var(--violet-bg); color: var(--violet); }

/* ---------- Tables ---------- */
.g-table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.g-table { width: 100%; border-collapse: collapse; }
.g-table th { text-align: left; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--paper); white-space: nowrap; }
.g-table th.r { text-align: right; }
.g-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.g-table tbody tr:last-child td { border-bottom: 0; }
.g-table tbody tr:hover { background: #f8fafd; }
.g-table--plain td { padding: 9px 4px; }
.g-total td { font-weight: 600; border-top: 2px solid var(--ink); }
.g-strong { font-weight: 500; color: var(--ink); text-decoration: none; }
.g-strong:hover { color: var(--brand); text-decoration: underline; }
.g-thumb { width: 64px; }
.g-thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--soft); display: block; }
.g-ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-inline { display: flex; gap: 6px; align-items: center; margin: 0; }
.g-stock { width: 64px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.g-stock.is-low { border-color: var(--amber); background: var(--amber-bg); }

/* ---------- Onglets & filtres ---------- */
.g-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.g-tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.g-tabs a:hover { color: var(--ink); }
.g-tabs a[aria-current] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }
.g-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.g-filters input, .g-filters select { padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r); font: inherit; background: var(--white); min-width: 240px; }

/* ---------- Formulaires ---------- */
.g-field { display: flex; flex-direction: column; gap: 5px; font-size: .82rem; color: var(--ink-soft); margin-bottom: 14px; min-width: 0; }
.g-field input, .g-field select, .g-field textarea,
.g-line input, .g-line select, .g-line textarea {
	width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r);
	background: var(--white); font: 400 .95rem/1.4 var(--sans); color: var(--ink);
}
.g-field input:focus, .g-field select:focus, .g-field textarea:focus, .g-line input:focus, .g-line select:focus, .g-line textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(0, 77, 158, .08); }
.g-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.g-row--3 { grid-template-columns: 1fr 2fr 1fr; }
.g-check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-size: .92rem; cursor: pointer; }
.g-check input { margin-top: 3px; accent-color: var(--brand); }
.g-hint { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.g-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 16px; }
.g-seg label { padding: 8px 16px; cursor: pointer; }
.g-seg input { accent-color: var(--brand); margin-right: 6px; }
.g-seg label:has(input:checked) { background: var(--soft); color: var(--brand); }
.g-bar {
	position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 10px;
	padding: 14px 0; margin-top: 4px; background: linear-gradient(to top, var(--paper) 70%, transparent);
}
.g-bar .g-btn--danger { margin-right: auto; }
.g-photo img { width: 140px; border-radius: 8px; background: var(--soft); margin-bottom: 10px; }
.g-form-inline { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 12px; align-items: end; }
.g-form-inline .g-field { margin: 0; }

/* ---------- Éditeur de lignes ---------- */
.g-lines__head, .g-line { display: grid; grid-template-columns: minmax(0, 3fr) 70px 80px 110px 80px 110px 36px; gap: 8px; align-items: start; }
.g-lines[data-franchise="1"] .g-lines__head, .g-lines[data-franchise="1"] .g-line { grid-template-columns: minmax(0, 3fr) 70px 80px 110px 110px 36px; }
.g-lines__head { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.g-line { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.g-line__desig { display: flex; flex-direction: column; gap: 6px; }
.g-line__desig textarea { font-size: .85rem; color: var(--ink-soft); resize: vertical; }
.g-line__tot { padding-top: 9px; font-weight: 500; white-space: nowrap; }
[data-add] { margin-top: 12px; }
.g-totals { margin: 16px 0 0 auto; max-width: 320px; }
.g-totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.g-totals__ttc { border-top: 2px solid var(--ink); margin-top: 4px; font-size: 1.1rem; }
.g-totals__ttc strong { color: var(--brand); }

/* ---------- Aperçu document ---------- */
.g-preview { background: #e3e8f0; border-radius: 12px; padding: 20px; overflow-x: auto; }
.g-preview .doc { background: var(--white); padding: 34px 38px; box-shadow: 0 8px 30px rgba(0, 0, 0, .08); min-width: 620px; }
.g-panel .g-card { padding: 18px; }
.g-panel .g-card p { margin: 0 0 10px; }
.g-panel h2 { font-size: 1.15rem; }

/* ---------- Connexion ---------- */
.g-login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 70% 30%, #0b4f9e, var(--brand-deep) 60%, #001a3a); }
.g-login__box { width: 100%; max-width: 380px; background: var(--paper); border-radius: 16px; padding: 34px 30px 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); display: flex; flex-direction: column; gap: 14px; }
.g-login__box img { width: 170px; margin: 0 auto 4px; }
.g-login__box h1 { text-align: center; font-size: 1.6rem; margin-bottom: 4px; }
.g-login__box label:not(.g-check) { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--ink-soft); }
.g-login__box input:not([type="checkbox"]) { padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r); font: inherit; }
.g-login__box .g-btn { padding: 12px; }
.g-login__lost { text-align: center; font-size: .85rem; color: var(--muted); }

/* ---------- Page client publique ---------- */
.g-public { background: #e8edf4; padding: 0 0 50px; }
.g-public__bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; background: var(--brand-deep); color: var(--soft); }
.g-public__accept { max-width: 800px; margin: 24px auto 0; padding: 0 16px; }
.g-accept { background: var(--white); border: 2px solid var(--brand); border-radius: 12px; padding: 18px 20px; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; }
.g-public__doc { max-width: 800px; margin: 24px auto 0; padding: 0 16px; overflow-x: auto; }
.g-public__doc .doc { background: var(--white); padding: 40px 44px; box-shadow: 0 10px 40px rgba(0, 0, 0, .08); min-width: 620px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
	.g-kpis { grid-template-columns: repeat(2, 1fr); }
	.g-cols--view { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
	.g-side { transform: translateX(-100%); transition: transform .25s; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
	.g-side.is-open { transform: none; }
	.g-main { margin-left: 0; }
	.g-top { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: var(--brand-deep); }
	.g-top__brand { color: var(--soft); text-decoration: none; letter-spacing: .16em; text-transform: uppercase; font-size: .85rem; }
	.g-burger { background: none; border: 0; color: var(--soft); padding: 6px; cursor: pointer; }
	.g-cols, .g-cols--doc, .g-grid2 { grid-template-columns: 1fr; }
	.g-form-inline { grid-template-columns: 1fr; }
	.g-content { padding-top: 20px; }
	.g-lines__head { display: none; }
	.g-line, .g-lines[data-franchise="1"] .g-line { grid-template-columns: 1fr 1fr 1fr; }
	.g-line__desig { grid-column: 1 / -1; }
	.g-line__tot { grid-column: 1 / 3; }
}
@media (max-width: 560px) {
	h1 { font-size: 1.6rem; }
	.g-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
	.g-kpi strong { font-size: 1.45rem; }
	.g-row, .g-row--3 { grid-template-columns: 1fr; }
	.g-filters input, .g-filters select { min-width: 0; width: 100%; }
	.g-head .g-actions { width: 100%; }
	.g-dl { grid-template-columns: 1fr; gap: 2px; }
	.g-dl dd { margin-bottom: 8px; }
	.g-accept { flex-direction: column; align-items: stretch; }
}

.g-chip-check { position: relative; cursor: pointer; }
.g-chip-check input { position: absolute; opacity: 0; inset: 0; }
.g-chip-check span { display: inline-block; padding: 7px 13px; border: 1px solid var(--line); border-radius: 99px; font-size: .88rem; background: var(--white); transition: background .15s, border-color .15s; }
.g-chip-check input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--white); }
.g-chip-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
