:root {
    --pen-brown: #89623A;
    --pen-brown-deep: #3f2d1c;
    --pen-brown-dark: #2c2017;
    --pen-gold: #b9894c;
    --pen-sand: #D8C6A8;
    --pen-cream: #F9F6F3;
    --pen-cream-2: #f2eadf;
    --pen-white: #ffffff;
    --pen-ink: #2e2924;
    --pen-muted: #6f655c;
    --pen-line: rgba(63,45,28,.14);
    --pen-shadow: 0 18px 50px rgba(63,45,28,.10);

    --primary: var(--pen-brown);
    --secondary: var(--pen-brown-deep);
    --accent: #fff;
    --primary-fg: #fff;
    --body-fg: var(--pen-ink);
    --body-bg: var(--pen-cream);
    --body-quiet-color: var(--pen-muted);
    --body-loud-color: var(--pen-brown-deep);
    --header-color: #fff;
    --header-branding-color: #fff;
    --header-bg: var(--pen-brown-deep);
    --header-link-color: #fff;
    --breadcrumbs-fg: rgba(255,255,255,.78);
    --breadcrumbs-link-fg: #fff;
    --breadcrumbs-bg: #5c4028;
    --link-fg: var(--pen-brown);
    --link-hover-color: var(--pen-brown-deep);
    --link-selected-fg: var(--pen-brown-deep);
    --hairline-color: var(--pen-line);
    --border-color: rgba(63,45,28,.17);
    --error-fg: #9c342d;
    --message-success-bg: #edf4e9;
    --message-warning-bg: #fff6dc;
    --message-error-bg: #fae9e6;
    --darkened-bg: var(--pen-cream-2);
    --selected-bg: #efe3d3;
    --selected-row: #f4eadf;
    --button-fg: #fff;
    --button-bg: var(--pen-brown);
    --button-hover-bg: var(--pen-brown-deep);
    --default-button-bg: var(--pen-brown-deep);
    --default-button-hover-bg: var(--pen-brown-dark);
    --close-button-bg: #766a60;
    --close-button-hover-bg: #5f554d;
    color-scheme: light;
}

html, body { background: var(--pen-cream); }
body {
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--pen-ink);
}

#header {
    min-height: 78px;
    padding: 0 28px;
    background: rgba(47,33,24,.98);
    box-shadow: 0 8px 28px rgba(35,25,18,.12);
    display: flex;
    align-items: center;
    gap: 24px;
}

#branding { flex: 1 1 auto; }
#site-name { margin: 0; }
.pen-admin-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #fff !important;
    text-decoration: none;
}
.pen-admin-brand img {
    width: 54px;
    height: 54px;
    object-fit: contain;
    padding: 3px;
    background: #fff;
    border-radius: 12px;
}
.pen-admin-brand span { display: flex; flex-direction: column; line-height: 1.1; }
.pen-admin-brand strong { font-size: 1.22rem; letter-spacing: .04em; }
.pen-admin-brand small { margin-top: 4px; font-size: .72rem; color: rgba(255,255,255,.68); }

.pen-admin-nav { margin-left: auto; }
.pen-admin-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 15px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 10px;
    color: #fff !important;
    font-weight: 700;
    text-decoration: none;
    transition: .2s ease;
}
.pen-admin-nav a:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.32); }

#user-tools { color: rgba(255,255,255,.65); font-size: .76rem; }
#user-tools a { color: #fff; }

div.breadcrumbs {
    padding: 11px 28px;
    background: #5c4028;
    color: rgba(255,255,255,.75);
    border: 0;
}

#content { padding: 30px 34px 42px; }
#content h1 {
    color: var(--pen-brown-deep);
    font-size: clamp(1.7rem, 2.4vw, 2.35rem);
    font-weight: 800;
    letter-spacing: -.025em;
}

.module, .inline-group, #changelist-filter, .dashboard #content-related .module {
    overflow: hidden;
    border: 1px solid var(--pen-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(63,45,28,.065);
}
.module h2, .module caption, .inline-group h2 {
    padding: 13px 16px;
    background: var(--pen-brown-deep);
    color: #fff;
    font-weight: 800;
    letter-spacing: .01em;
}

.dashboard .module table th { width: 100%; }
.dashboard .module table td { white-space: nowrap; }
.dashboard .module a { font-weight: 700; }

#changelist .actions {
    padding: 12px 14px;
    background: var(--pen-cream-2);
    border-radius: 14px 14px 0 0;
}
#changelist-filter h2 { background: var(--pen-brown-deep); }
#changelist-filter h3 { color: var(--pen-brown-deep); font-weight: 800; }
#changelist-filter li.selected a { color: var(--pen-brown-deep); font-weight: 800; }

.object-tools a:link, .object-tools a:visited {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    border-radius: 9px;
    background: var(--pen-brown);
    font-weight: 800;
}
.object-tools a:hover { background: var(--pen-brown-deep); }

.button, input[type=submit], input[type=button], .submit-row input, a.button {
    min-height: 38px;
    padding: 9px 16px;
    border-radius: 9px;
    border: 0;
    background: var(--pen-brown) !important;
    color: var(--pen-white) !important;
    font-weight: 800;
    box-shadow: none;
    transition: background .2s ease, transform .2s ease;
}
.button:hover, input[type=submit]:hover, input[type=button]:hover, .submit-row input:hover, a.button:hover {
    background: var(--pen-brown-deep) !important;
    color: var(--pen-white) !important;
}
.submit-row {
    padding: 14px;
    border: 1px solid var(--pen-line);
    border-radius: 14px;
    background: var(--pen-cream-2);
}
.submit-row a.deletelink { border-radius: 9px; }

input[type=text], input[type=password], input[type=email], input[type=url], input[type=number],
textarea, select, .vTextField {
    border: 1px solid rgba(63,45,28,.20);
    border-radius: 9px;
    padding: 9px 11px;
    background: #fff;
    color: var(--pen-ink);
}
input:focus, textarea:focus, select:focus {
    border-color: var(--pen-brown) !important;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(138,98,57,.10);
}

.form-row { border-bottom-color: var(--pen-line); }
.form-row label { color: var(--pen-brown-deep); font-weight: 700; }
.help, p.help, form p.help, div.help, form div.help, div.help li { color: var(--pen-muted); }

table thead th {
    background: var(--pen-cream-2);
    color: var(--pen-brown-deep);
}
table thead th.sorted { background: #e9ddcc; }
.row1 { background: #fff; }
.row2 { background: #fdfaf6; }
tr:hover td { background: #f4eadf; }

.messagelist li {
    margin: 0 0 10px;
    border-radius: 10px;
    border: 1px solid var(--pen-line);
    box-shadow: 0 6px 18px rgba(63,45,28,.05);
}

/* Connexion */
body.pen-login {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 18%, rgba(185,137,76,.16), transparent 34%),
        linear-gradient(145deg, var(--pen-cream), #fff 58%, var(--pen-cream-2));
}
body.pen-login #header { box-shadow: none; }
body.pen-login #content {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 78px);
    padding: 34px 20px;
}
body.pen-login #content-main { width: min(100%, 470px); }
.pen-login-card {
    width: 100%;
    padding: 34px;
    background: rgba(255,255,255,.96);
    border: 1px solid var(--pen-line);
    border-radius: 22px;
    box-shadow: var(--pen-shadow);
}
.pen-login-intro { text-align: center; margin-bottom: 25px; }
.pen-login-intro img {
    width: 92px;
    height: 92px;
    margin: 0 auto 14px;
    object-fit: contain;
}
.pen-login-kicker {
    display: inline-block;
    margin-bottom: 7px;
    color: var(--pen-brown);
    font-size: .73rem;
    font-weight: 900;
    letter-spacing: .14em;
    text-transform: uppercase;
}
.pen-login-intro h1 { margin: 0 0 9px; font-size: 1.65rem !important; }
.pen-login-intro p { margin: 0; color: var(--pen-muted); line-height: 1.55; }
.pen-login-card .form-row { padding: 0 0 15px; border: 0; }
.pen-login-card .form-row label { display: block; margin-bottom: 6px; }
.pen-login-card input[type=text], .pen-login-card input[type=password] { width: 100%; min-height: 45px; }
.pen-login-card .submit-row { margin: 8px 0 0; padding: 0; border: 0; background: transparent; }
.pen-login-card .submit-row input { width: 100%; min-height: 46px; }
.password-reset-link { margin: -4px 0 15px; text-align: right; }

@media (max-width: 767px) {
    #header { min-height: 70px; padding: 8px 16px; flex-wrap: wrap; }
    .pen-admin-brand img { width: 46px; height: 46px; }
    .pen-admin-brand small { display: none; }
    .pen-admin-nav { display: none; }
    #user-tools { width: 100%; padding: 0 0 4px; }
    #content { padding: 22px 16px 34px; }
    div.breadcrumbs { padding-inline: 16px; }
    .pen-login-card { padding: 26px 22px; border-radius: 18px; }
}

/* Liens rapides PEN / MPFS dans l'en-tête de l'espace de gestion. */
.pen-admin-nav { display: flex; align-items: center; gap: 8px; }


/* =========================================================
   V12 — Connexion centrée et harmonisée
   ========================================================= */
body.pen-login #container {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    background: transparent;
}

body.pen-login #main {
    min-height: calc(100vh - 78px);
}

body.pen-login #content {
    width: 100%;
    min-height: calc(100vh - 78px);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 40px 20px;
}

body.pen-login #content-main {
    flex: 0 1 480px;
    width: min(100%, 480px);
    max-width: 480px;
    margin: 0 auto;
}

body.pen-login .pen-login-card {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 32px;
    border: 1px solid rgba(63,45,28,.16);
    border-radius: 20px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 20px 60px rgba(63,45,28,.13);
}

body.pen-login .pen-login-form {
    width: 100%;
    box-sizing: border-box;
    margin-top: 4px;
    padding: 20px;
    border: 1px solid rgba(63,45,28,.12);
    border-radius: 14px;
    background: var(--pen-cream);
}

body.pen-login .pen-login-card .form-row {
    width: 100%;
    box-sizing: border-box;
    padding: 0 0 15px;
}

body.pen-login .pen-login-card .form-row label {
    width: auto;
    display: block;
    float: none;
    margin: 0 0 7px;
    padding: 0;
    color: var(--pen-brown-deep);
    font-size: .84rem;
    font-weight: 800;
}

body.pen-login .pen-login-card input[type="email"],
body.pen-login .pen-login-card input[type="text"],
body.pen-login .pen-login-card input[type="password"] {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 46px;
    margin: 0;
    box-sizing: border-box;
    padding: 11px 13px;
    border: 1px solid rgba(63,45,28,.20);
    border-radius: 10px;
    background: #fff;
}

body.pen-login .pen-login-card .password-reset-link {
    margin: -2px 0 15px;
}

body.pen-login .pen-login-card .submit-row {
    width: 100%;
    box-sizing: border-box;
    margin: 4px 0 0;
}

body.pen-login .pen-login-card .submit-row input {
    width: 100%;
    box-sizing: border-box;
    min-height: 46px;
}

@media (max-width: 560px) {
    body.pen-login #content { padding: 24px 14px; }
    body.pen-login .pen-login-card { padding: 23px 18px; border-radius: 17px; }
    body.pen-login .pen-login-form { padding: 16px; }
    body.pen-login .pen-login-intro img { width: 78px; height: 78px; }
}

/* V14.1 — bouton de connexion aligné sur la palette PEN */
body.pen-login .pen-login-card .submit-row input[type="submit"] {
    background: var(--pen-brown) !important;
    color: var(--pen-white) !important;
    border: 1px solid var(--pen-brown) !important;
    box-shadow: 0 10px 24px rgba(138,98,57,.18) !important;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

body.pen-login .pen-login-card .submit-row input[type="submit"]:hover,
body.pen-login .pen-login-card .submit-row input[type="submit"]:focus {
    background: var(--pen-brown-deep) !important;
    border-color: var(--pen-brown-deep) !important;
    box-shadow: 0 12px 28px rgba(63,45,28,.22) !important;
}

body.pen-login .pen-login-card .submit-row input[type="submit"]:active {
    transform: translateY(1px);
}


/* =========================================================
   V15 — Pied de page de connexion et cohérence PEN
   ========================================================= */
body.pen-login #content {
    align-items: stretch;
    padding-bottom: 18px;
}
body.pen-login #content-main {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
}
.pen-login-shell {
    width: 100%;
    min-height: calc(100vh - 136px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
}
.pen-login-shell .pen-login-card { flex: 0 0 auto; }
.pen-login-footer {
    width: min(100%, 940px);
    margin-top: auto;
    padding: 16px 20px 4px;
    border-top: 1px solid var(--pen-line);
    color: var(--pen-muted);
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 18px;
    align-items: center;
    font-size: .76rem;
}
.pen-login-footer-brand { display: flex; align-items: baseline; gap: 8px; }
.pen-login-footer-brand strong { color: var(--pen-brown); letter-spacing: .06em; }
.pen-login-footer nav { display: flex; align-items: center; gap: 9px; }
.pen-login-footer a { color: var(--pen-brown-deep); font-weight: 800; text-decoration: none; }
.pen-login-footer a:hover { color: var(--pen-brown); }
.pen-login-footer small { white-space: nowrap; }

/* Les couleurs rouges/jaunes restent réservées aux alertes fonctionnelles. */
.submit-row a.deletelink,
a.deletelink { background: #9c342d !important; color: #fff !important; }
.submit-row a.deletelink:hover,
a.deletelink:hover { background: #7d2823 !important; }

@media (max-width: 760px) {
    .pen-login-shell { min-height: calc(100vh - 120px); }
    .pen-login-footer { grid-template-columns: 1fr; text-align: center; justify-items: center; gap: 8px; }
    .pen-login-footer-brand { flex-direction: column; align-items: center; gap: 2px; }
}

/* =========================================================
   V16 — Connexion admin : charte PEN forcée et footer harmonisé
   ========================================================= */
body.pen-login .pen-login-card .submit-row input[type="submit"],
body.pen-login #login-form .submit-row input[type="submit"],
body.pen-login input[type="submit"].default {
    -webkit-appearance: none !important;
    appearance: none !important;
    background: #89623A !important;
    background-color: #89623A !important;
    border-color: #89623A !important;
    color: #FFFFFF !important;
}

body.pen-login .pen-login-card .submit-row input[type="submit"]:hover,
body.pen-login .pen-login-card .submit-row input[type="submit"]:focus,
body.pen-login #login-form .submit-row input[type="submit"]:hover,
body.pen-login #login-form .submit-row input[type="submit"]:focus,
body.pen-login input[type="submit"].default:hover,
body.pen-login input[type="submit"].default:focus {
    background: #3F2D1C !important;
    background-color: #3F2D1C !important;
    border-color: #3F2D1C !important;
    color: #FFFFFF !important;
}

.pen-login-footer {
    border-top-color: #D8C6A8;
    color: #6f655c;
}

.pen-login-footer-brand {
    display: block;
    min-width: 0;
}

.pen-login-footer-brand span {
    color: #3F2D1C;
    font-weight: 800;
    line-height: 1.3;
}

body.pen-login .pen-login-footer a,
body.pen-login .pen-login-footer a:link,
body.pen-login .pen-login-footer a:visited {
    color: #89623A !important;
    text-decoration: none !important;
    font-weight: 800;
}

body.pen-login .pen-login-footer a:hover,
body.pen-login .pen-login-footer a:focus {
    color: #3F2D1C !important;
    text-decoration: underline !important;
}

body.pen-login .pen-login-footer small {
    color: #6f655c;
}

/* =========================================================
   V16.2 — Footer connexion admin centré
   ========================================================= */
body.pen-login .pen-login-footer {
    width: min(100%, 640px);
    margin: 0 auto;
    padding: 18px 20px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-align: center;
    border-top: 1px solid #D8C6A8;
    color: #6f655c;
}

body.pen-login .pen-login-footer-brand {
    width: 100%;
    display: block;
    text-align: center;
}

body.pen-login .pen-login-footer-brand span {
    display: block;
    color: #3F2D1C;
    font-size: .88rem;
    font-weight: 800;
    line-height: 1.35;
}

body.pen-login .pen-login-footer nav {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    text-align: center;
}

body.pen-login .pen-login-footer nav span {
    color: #D8C6A8;
}

body.pen-login .pen-login-footer small {
    display: block;
    width: 100%;
    color: #6f655c;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
}

@media (max-width: 560px) {
    body.pen-login .pen-login-footer {
        width: 100%;
        padding-inline: 10px;
        gap: 6px;
    }

    body.pen-login .pen-login-footer-brand span {
        font-size: .82rem;
    }
}

/* =========================================================
   V18.1 — Footer de connexion identique à la vitrine publique
   ========================================================= */
body.pen-login #content {
    padding: 34px 0 0;
}

body.pen-login .pen-login-shell {
    width: 100%;
    min-height: calc(100vh - 112px);
    gap: 30px;
}

body.pen-login .pen-login-card {
    margin-inline: 20px;
}

body.pen-login .pen-login-footer-public {
    width: 100%;
    margin-top: auto;
    box-sizing: border-box;
    padding: 14px max(24px, calc((100vw - 1680px) / 2)) 8px;
    background: #2f241c;
    border-top: 1px solid rgba(216, 198, 168, .24);
    color: #F9F6F3;
    box-shadow: 0 -8px 24px rgba(63, 45, 28, .08);
}

body.pen-login .pen-login-footer-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding-bottom: 11px;
    border-bottom: 1px solid rgba(216, 198, 168, .18);
}

body.pen-login .pen-login-footer-brand-public {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1 1 620px;
}

body.pen-login .pen-login-footer-brand-public img {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    object-fit: contain;
    padding: 4px;
    border-radius: 12px;
    background: #FFFFFF;
}

body.pen-login .pen-login-footer-brand-public strong {
    display: block;
    margin: 0 0 2px;
    color: #FFFFFF;
    font-size: .92rem;
    font-weight: 800;
    line-height: 1.25;
}

body.pen-login .pen-login-footer-brand-public p {
    margin: 0;
    color: #D8C6A8;
    font-size: .74rem;
    line-height: 1.35;
}

body.pen-login .pen-login-footer-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 9px;
    flex: 0 1 auto;
    white-space: nowrap;
}

body.pen-login .pen-login-footer-nav a,
body.pen-login .pen-login-footer-nav a:link,
body.pen-login .pen-login-footer-nav a:visited {
    color: #F9F6F3 !important;
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none !important;
}

body.pen-login .pen-login-footer-nav a:hover,
body.pen-login .pen-login-footer-nav a:focus {
    color: #D8C6A8 !important;
    text-decoration: none !important;
}

body.pen-login .pen-login-footer-nav span {
    color: rgba(216, 198, 168, .58);
}

body.pen-login .pen-login-footer-bottom {
    padding-top: 9px;
    color: #D8C6A8;
    font-size: .72rem;
    line-height: 1.3;
}

/* L'ancien footer centré n'est plus utilisé sur la page de connexion. */
body.pen-login .pen-login-footer { display: none !important; }

@media (max-width: 900px) {
    body.pen-login .pen-login-footer-top {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    body.pen-login .pen-login-footer-nav {
        justify-content: flex-start;
        white-space: normal;
    }
}

@media (max-width: 560px) {
    body.pen-login #content { padding-top: 24px; }
    body.pen-login .pen-login-card { margin-inline: 14px; }
    body.pen-login .pen-login-footer-public { padding: 13px 16px 8px; }
    body.pen-login .pen-login-footer-brand-public img { width: 48px; height: 48px; flex-basis: 48px; }
    body.pen-login .pen-login-footer-brand-public strong { font-size: .84rem; }
    body.pen-login .pen-login-footer-brand-public p { font-size: .69rem; }
    body.pen-login .pen-login-footer-nav { gap: 7px; }
    body.pen-login .pen-login-footer-nav a { font-size: .74rem; }
}
