@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,600&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --ink: #142520;
    --bg: #F3F7EC;
    --paper: #FFFFFF;
    --accent: #FF6B5E;
    --accent-dark: #E85445;
    --accent-2: #FFC24D;
    --sage: #3E6259;
    --sage-light: #E7EFE3;
    --line: #DFE7D6;
    --texte: #1D2B26;
    --gris: #6B7A72;
    --radius: 20px;
    --radius-sm: 12px;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--texte);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Barre du haut ---------- */
.topbar {
    background: var(--ink);
    color: #fff;
    padding: 30px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar .brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 19px;
    letter-spacing: 0.2px;
    text-decoration: none;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar .brand .dot {
    width: 12px; height: 12px; border-radius: 4px;
    background: var(--accent);
    display: inline-block;
    transform: rotate(8deg);
}
.topbar .brand .brand-logo {
    height: 88px;
    width: auto;
    display: block;
}
.topbar .brand span {
    opacity: 0.85;
    font-weight: 500;
}

.topbar nav a {
    color: #C9DACB;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-left: 20px;
    transition: color .15s ease;
}
.topbar nav a:hover { color: #fff; }

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 24px 70px;
}

h1.page-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 32px;
    margin: 0 0 8px;
    color: var(--ink);
    letter-spacing: -0.3px;
}
p.page-subtitle {
    color: var(--gris);
    margin: 0 0 30px;
    font-size: 15.5px;
    max-width: 640px;
    line-height: 1.5;
}

/* ---------- Grille des laboratoires : carte "ticket de commande" ---------- */
.lab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 28px;
}

.lab-card {
    position: relative;
    background: var(--paper);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 30px 22px 20px;
    text-align: center;
    text-decoration: none;
    color: var(--texte);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    animation: rise-in .5s ease backwards;
}
.lab-grid .lab-card:nth-child(1) { animation-delay: .02s; }
.lab-grid .lab-card:nth-child(2) { animation-delay: .07s; }
.lab-grid .lab-card:nth-child(3) { animation-delay: .12s; }
.lab-grid .lab-card:nth-child(4) { animation-delay: .17s; }
.lab-grid .lab-card:nth-child(n+5) { animation-delay: .2s; }

@keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* encoches façon ticket perforé */
.lab-card::before, .lab-card::after {
    content: "";
    position: absolute;
    top: 68%;
    width: 20px; height: 20px;
    background: var(--bg);
    border: 1.5px solid var(--line);
    border-radius: 50%;
    transition: border-color .18s ease;
}
.lab-card::before { left: -11px; }
.lab-card::after  { right: -11px; }

.lab-card:hover {
    transform: translateY(-4px) rotate(-0.3deg);
    box-shadow: 0 16px 30px rgba(20,37,32,0.12);
    border-color: var(--sage);
}
.lab-card:hover::before, .lab-card:hover::after {
    border-color: var(--sage);
}

.lab-card img {
    max-width: 100%;
    max-height: 68px;
    object-fit: contain;
    margin-bottom: 4px;
}
.lab-card .logo-fallback {
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--sage);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 600; font-size: 19px;
}
.lab-card .lab-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 17px;
    line-height: 1.25;
}
.lab-card .lab-cta {
    font-size: 12.5px;
    color: var(--accent-dark);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-top: 1.5px dashed var(--line);
    width: 100%;
    padding-top: 12px;
    margin-top: 6px;
}

/* ---------- Cartes génériques ---------- */
.card {
    background: var(--paper);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    padding: 26px;
    margin-bottom: 22px;
}
.card h3 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
    font-size: 19px;
}

/* ---------- Formulaires ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 22px;
}
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--sage);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--texte);
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(255,107,94,0.14);
}

/* ---------- Boutons ---------- */
.btn {
    display: inline-block;
    background: var(--ink);
    color: #fff;
    border: none;
    padding: 13px 24px;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
}
.btn:hover { background: var(--sage); box-shadow: 0 6px 16px rgba(20,37,32,0.18); }
.btn:active { transform: scale(0.97); }

.btn.corail {
    background: var(--accent);
    box-shadow: 0 6px 18px rgba(255,107,94,0.35);
}
.btn.corail:hover { background: var(--accent-dark); box-shadow: 0 8px 20px rgba(255,107,94,0.4); }

.btn.secondaire {
    background: var(--paper);
    color: var(--ink);
    border: 1.5px solid var(--line);
    box-shadow: none;
}
.btn.secondaire:hover { background: var(--sage-light); border-color: var(--sage); color: var(--ink); }

.btn.small { padding: 8px 16px; font-size: 13px; }
.btn.danger { background: #D64545; }
.btn.danger:hover { background: #B93636; }

/* ---------- Tableau produits (bon de commande) ---------- */
table.produits {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-top: 4px;
}
table.produits th {
    text-align: left;
    padding: 10px 12px;
    background: var(--sage-light);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sage);
    font-weight: 700;
}
table.produits td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.produits tr.categorie-row td {
    background: var(--ink);
    color: var(--accent-2);
    font-weight: 700;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 9px 12px;
}
table.produits tbody tr:not(.categorie-row):hover {
    background: #FAFBF7;
}
table.produits input[type=number] {
    width: 72px;
    text-align: center;
    font-weight: 700;
}

/* ---------- Barre de total (sticky) ---------- */
.total-bar {
    position: sticky;
    bottom: 16px;
    background: var(--ink);
    color: #fff;
    padding: 18px 26px;
    margin-top: 26px;
    border-radius: var(--radius);
    box-shadow: 0 14px 34px rgba(20,37,32,0.28);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}
.total-bar div { color: #C9DACB; font-size: 14.5px; }
.total-bar .montant {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    color: #fff;
}

/* ---------- Badges & alertes ---------- */
.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge.ok { background: #DEF2DA; color: #2A6B3F; }
.badge.ko { background: #FBDEDA; color: #B23D2E; }

.alert {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 18px;
    font-weight: 500;
    border-left: 4px solid transparent;
}
.alert.success { background: #E9F5E5; color: #2A6B3F; border-color: #2A6B3F; }
.alert.error { background: #FBDEDA; color: #B23D2E; border-color: #B23D2E; }

/* ---------- Connexion ---------- */
.login-box {
    max-width: 380px;
    margin: 70px auto;
    background: var(--paper);
    border-radius: var(--radius);
    border: 1.5px solid var(--line);
    padding: 36px 32px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(20,37,32,0.08);
}
.login-box .page-title { text-align: center; }

/* ---------- Pied de page ---------- */
footer.site-footer {
    text-align: center;
    color: var(--gris);
    font-size: 12px;
    padding: 28px;
}

/* ---------- Administration ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
    text-align: left;
    background: var(--sage-light);
    padding: 10px 12px;
    color: var(--sage);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.admin-table tr:hover { background: #FAFBF7; }

.tag-row { display:flex; gap:10px; flex-wrap: wrap; margin-bottom: 24px; }
.tag-row a { text-decoration:none; }
