/* Rachat Motoculture - styles (mobile d'abord) */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #2e7d32; --primary-dark: #1b5e20; --dark: #2c3e50;
    --bg: #f4f6f5; --card: #fff; --border: #dde3e0; --muted: #6b7a74;
    --danger: #c0392b; --warn: #b9770e;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--dark); line-height: 1.5; font-size: 15px; }
a { color: var(--primary-dark); }
h1 { font-size: 1.45rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
.card h2 { margin-top: 0; }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-weight: 600; }
.lbl { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

/* Navigation */
.navbar { background: var(--dark); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; flex-wrap: wrap; }
.nav-brand { font-weight: 700; }
.nav-links { display: flex; gap: .25rem; flex: 1; }
.nav-links a { color: #cfd8dc; text-decoration: none; padding: .35rem .75rem; border-radius: 6px; }
.nav-links a.active, .nav-links a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-user { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.nav-user .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }

.container { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 5rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Boutons */
.btn { display: inline-block; padding: .55rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--dark); text-decoration: none; cursor: pointer; font-size: .95rem; font-family: inherit; }
.btn:hover { background: #f0f3f1; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e6b0aa; }
.btn-danger:hover { background: #fdecea; }
.btn-ghost { background: transparent; }
.btn-small { padding: .3rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* Cartes, formulaires */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem; margin-bottom: 1rem; }
.form label { display: block; font-size: .85rem; font-weight: 600; color: #455a64; margin-bottom: .8rem; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=password], input[type=search], select, textarea {
    display: block; width: 100%; margin-top: .25rem; padding: .55rem .65rem; border: 1px solid #c8d1cd; border-radius: 7px;
    font-size: 1rem; font-family: inherit; background: #fff; color: var(--dark); }
input:focus, select:focus, textarea:focus { outline: 2px solid #a5d6a7; border-color: var(--primary); }
fieldset { border: none; border-top: 1px solid var(--border); padding-top: .8rem; margin-top: .4rem; }
legend { font-weight: 700; padding-right: .5rem; color: var(--dark); }
.grid-2, .grid-3 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr 1.2fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; align-items: center; margin-top: .5rem; }
.danger-zone { margin-top: 2rem; text-align: right; }
.w-date { max-width: 220px; }

.type-switch { display: flex; gap: .5rem; margin-bottom: 1rem; }
.type-switch label { flex: 1; display: flex; align-items: center; justify-content: center; gap: .5rem; border: 1px solid var(--border); border-radius: 8px; padding: .7rem; cursor: pointer; margin: 0; font-size: 1rem; }
.type-switch label:has(input:checked) { border-color: var(--primary); background: #e8f5e9; color: var(--primary-dark); }
.is-part .only-pro, .is-pro .only-part { display: none; }

/* Recherche */
.search { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search input { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: #fff; }
.card .table { background: transparent; }
.table th, .table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { font-size: .78rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
.table .num { text-align: right; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table tfoot th { border-bottom: none; }
.table-wrap > .table { border: 1px solid var(--border); border-radius: 10px; }
.table-form input { margin: 0; }
.w-num { width: 7rem !important; margin-left: auto !important; text-align: right; }
.w-small { width: 5rem !important; margin-left: auto !important; text-align: right; }
tr.inactive td { opacity: .5; }
tr.has-qty td { background: #f1f8f2; font-weight: 600; }
.total-row th { font-size: 1.05rem; }

/* Quantité +/- */
.qty { display: inline-flex; align-items: center; gap: .25rem; }
.qty input { width: 4.5rem; text-align: center; margin: 0; }
.qty-btn { width: 2.2rem; height: 2.2rem; border: 1px solid var(--border); border-radius: 7px; background: #fff; font-size: 1.15rem; cursor: pointer; }
.qty-btn:active { background: #e8f5e9; }

/* Prix */
.prix-grid input { font-size: 1.15rem; font-weight: 600; }
.montant-box { background: #e8f5e9; border-radius: 10px; padding: .6rem .9rem; margin-bottom: .8rem; }
.montant { font-size: 1.7rem; font-weight: 800; color: var(--primary-dark); }
.totaux { display: flex; justify-content: flex-end; gap: 2rem; align-items: end; margin-top: 1rem; text-align: right; flex-wrap: wrap; }
.montant-final { font-size: 1.5rem; font-weight: 800; color: var(--primary-dark); }

.sticky-actions { position: sticky; bottom: 0; background: rgba(244,246,245,.96); padding: .7rem 0; border-top: 1px solid var(--border); }
.sticky-summary { margin-right: auto; font-size: 1.05rem; }

/* Infos */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem 1.2rem; }
.client-strip { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .8rem 1rem; }
.stat strong { font-size: 1.35rem; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; vertical-align: middle; }
.badge-pro { background: #e3f2fd; color: #1565c0; }
.badge-part { background: #fff3e0; color: #e65100; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-ok { background: #e8f5e9; color: var(--primary-dark); }
.alert-error { background: #fdecea; color: var(--danger); }
.alert-warn { background: #fff8e1; color: #7a5300; margin: .5rem 0 0; }
.empty { color: var(--muted); padding: 2rem; text-align: center; background: #fff; border: 1px dashed var(--border); border-radius: 10px; }

/* Connexion */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2e7d32, #2c3e50); padding: 1rem; }
.login-card { background: #fff; padding: 2rem; border-radius: 12px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card h1 { justify-content: center; color: var(--primary-dark); }
.login-card .muted { text-align: center; margin-bottom: 1.2rem; }
.login-card label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 1rem; }

@media (max-width: 640px) {
    .table th, .table td { padding: .5rem .35rem; }
    .navbar { gap: .5rem; }
    .nav-links { order: 3; flex-basis: 100%; }
}

/* Paramètres : logo */
.logo-zone { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 220px; min-height: 110px; border: 1px dashed var(--border); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: .5rem; background: #fff; gap: .3rem; text-align: center; }
.logo-preview img { max-width: 100%; max-height: 110px; }
