:root {
    --navy: #020885;
    --navy-dark: #181c32;
    --blue: #0087cc;
    --blue-soft: #e8f5fb;
    --gold: #0087cc;
    --ink: #3f4254;
    --muted: #7e8299;
    --line: #e4e6ef;
    --surface: #ffffff;
    --background: #f3f6f9;
    --success: #16805c;
    --danger: #b43a47;
    --warning: #9a6815;
    --shadow: 0 22px 55px rgba(20, 48, 77, .13);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--background);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
    min-height: 82px;
    padding: 14px clamp(22px, 5vw, 76px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    background: rgba(255, 255, 255, .95);
    border-bottom: 1px solid rgba(199, 211, 224, .8);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(145deg, var(--blue), var(--navy-dark));
    border-radius: 13px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .04em;
    box-shadow: 0 9px 20px rgba(18, 55, 95, .22);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.login-page {
    background:
        radial-gradient(circle at 4% 18%, rgba(48, 133, 196, .13), transparent 31%),
        radial-gradient(circle at 88% 76%, rgba(233, 173, 55, .11), transparent 30%),
        var(--background);
}

.login-layout {
    width: min(1180px, calc(100% - 40px));
    min-height: calc(100vh - 150px);
    margin: 0 auto;
    padding: 64px 0;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(390px, .78fr);
    gap: clamp(55px, 8vw, 110px);
    align-items: center;
}

.welcome-panel { padding: 18px 0 35px; }

.eyebrow {
    margin: 0 0 13px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.welcome-panel h1 {
    max-width: 700px;
    margin: 0;
    color: var(--navy-dark);
    font-size: clamp(38px, 5vw, 64px);
    line-height: 1.04;
    letter-spacing: -.045em;
}

.welcome-copy {
    max-width: 610px;
    margin: 25px 0 0;
    color: var(--muted);
    font-size: clamp(17px, 2vw, 20px);
    line-height: 1.65;
}

.benefits {
    margin: 32px 0 0;
    padding: 0;
    display: grid;
    gap: 14px;
    list-style: none;
    color: #405166;
    font-size: 15px;
}

.benefits span {
    width: 25px;
    height: 25px;
    margin-right: 10px;
    display: inline-grid;
    place-items: center;
    color: var(--success);
    background: #ddf4ea;
    border-radius: 50%;
    font-weight: 900;
}

.auth-card {
    padding: clamp(28px, 4vw, 43px);
    background: rgba(255, 255, 255, .98);
    border: 1px solid rgba(209, 220, 230, .9);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.auth-heading h2 { margin: 0; font-size: 30px; letter-spacing: -.025em; }
.auth-heading > p:last-child { margin: 8px 0 27px; color: var(--muted); }

.method-tabs {
    padding: 4px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    background: #edf2f6;
    border-radius: 12px;
}

.method-tab {
    padding: 10px 7px;
    color: #627184;
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 750;
}

.method-tab.is-active {
    color: var(--navy);
    background: white;
    box-shadow: 0 3px 9px rgba(25, 52, 80, .08);
}

.method-panel { padding-top: 25px; }
.method-panel[hidden] { display: none; }

label {
    margin: 0 0 7px;
    display: block;
    color: #33465b;
    font-size: 13px;
    font-weight: 750;
}

input {
    width: 100%;
    min-height: 48px;
    margin: 0 0 18px;
    padding: 11px 14px;
    color: var(--ink);
    background: white;
    border: 1px solid #cbd6e1;
    border-radius: 10px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(23, 105, 170, .12);
}

.primary-button, .secondary-button, .card-action, .text-button, .link-button {
    border: 0;
    cursor: pointer;
    text-decoration: none;
}

.primary-button {
    width: 100%;
    min-height: 49px;
    padding: 12px 18px;
    color: white;
    background: linear-gradient(135deg, var(--blue), var(--navy));
    border-radius: 10px;
    font-weight: 800;
    box-shadow: 0 9px 18px rgba(19, 79, 129, .19);
}

.primary-button:hover { filter: brightness(1.06); }
.primary-button:focus-visible, .secondary-button:focus-visible, .method-tab:focus-visible, .card-action:focus-visible { outline: 3px solid rgba(23, 105, 170, .25); outline-offset: 2px; }

.secondary-button {
    padding: 10px 14px;
    color: var(--blue);
    background: var(--blue-soft);
    border-radius: 9px;
    font-weight: 750;
}

.form-note { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }

.badge-reader {
    margin-bottom: 20px;
    padding: 19px;
    color: var(--muted);
    background: #f5f8fb;
    border: 1px dashed #bac9d8;
    border-radius: 13px;
    text-align: center;
}

.badge-reader p { margin: 0 0 13px; font-size: 13px; line-height: 1.45; }
.camera-frame { position: relative; margin: 0 auto 14px; overflow: hidden; aspect-ratio: 4 / 3; background: #07121f; border-radius: 10px; }
.camera-frame video { width: 100%; height: 100%; display: block; object-fit: cover; }
.camera-guide { position: absolute; inset: 14%; border: 3px solid rgba(255,255,255,.9); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.18); }

.code-panel {
    margin-bottom: 25px;
    padding: 22px;
    background: #f2f8fc;
    border: 1px solid #cfe2f0;
    border-radius: 14px;
    text-align: center;
}

.code-panel h3 { margin: 8px 0 4px; }
.code-panel p { margin: 0 0 19px; color: var(--muted); font-size: 13px; }
.mail-icon { width: 42px; height: 42px; display: inline-grid; place-items: center; color: var(--blue); background: white; border-radius: 50%; font-size: 21px; }
.code-input { text-align: center; font-size: 24px; font-weight: 850; letter-spacing: .32em; }
.link-button { margin-top: 13px; color: var(--blue); background: transparent; font-size: 13px; font-weight: 700; }
.auth-methods.is-secondary { padding-top: 6px; border-top: 1px solid var(--line); }

.flash {
    position: fixed;
    z-index: 20;
    top: 92px;
    left: 50%;
    width: min(660px, calc(100% - 30px));
    padding: 13px 17px;
    transform: translateX(-50%);
    background: white;
    border: 1px solid var(--line);
    border-left: 4px solid var(--blue);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(20, 48, 77, .13);
    font-size: 14px;
}

.flash-success { border-left-color: var(--success); }
.flash-danger { border-left-color: var(--danger); }
.flash-warning { border-left-color: var(--warning); }

.dashboard-page { background: #f4f7fa; }

.user-menu { display: flex; align-items: center; gap: 11px; }
.user-avatar { width: 40px; height: 40px; display: grid; place-items: center; color: white; background: var(--navy); border-radius: 50%; font-weight: 800; text-transform: uppercase; }
.user-label strong, .user-label small { display: block; }
.user-label strong { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.user-label small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.text-button { padding: 8px 11px; color: var(--navy); background: #edf2f6; border-radius: 8px; font-size: 12px; font-weight: 750; }

.dashboard-layout { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 62px 0 80px; }
.dashboard-heading { margin-bottom: 31px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.dashboard-heading h1 { margin: 0; color: var(--navy-dark); font-size: clamp(32px, 4vw, 47px); letter-spacing: -.035em; }
.dashboard-heading p:last-child { margin: 9px 0 0; color: var(--muted); }
.security-pill { padding: 8px 12px; color: var(--success); background: #e4f5ee; border-radius: 999px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.security-pill span { margin-right: 4px; }

.app-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.app-card {
    min-height: 255px;
    padding: 27px;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(25, 53, 81, .07);
}
.app-card-tickets { border-top: 4px solid #2886c3; }
.app-card-devis { border-top: 4px solid #df9c24; }
.app-card.is-disabled { opacity: .68; }
.app-icon { width: 49px; height: 49px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, #2886c3, #15588d); border-radius: 13px; font-size: 21px; font-weight: 850; }
.app-card-devis .app-icon { background: linear-gradient(145deg, #e8ad3e, #bd7413); }
.app-copy { margin: 19px 0 21px; }
.app-kind { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.app-copy h2 { margin: 5px 0 7px; color: var(--navy-dark); font-size: 23px; }
.app-copy p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.app-card form { margin-top: auto; }
.card-action { width: 100%; margin-top: auto; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; color: var(--navy); background: #edf4f9; border-radius: 9px; font-size: 13px; font-weight: 800; }
.card-action:hover { background: #e2eff8; }
.access-state { margin: auto 0 0; padding: 11px 13px; color: var(--muted); background: #f2f4f6; border-radius: 9px; font-size: 12px; }

.section-heading { margin: 55px 0 22px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 0; color: var(--navy-dark); font-size: 27px; }
.section-heading > p { max-width: 430px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; text-align: right; }
.external-card { min-height: 230px; }
.wordpress-icon { background: linear-gradient(145deg, #495e71, #253746); }

footer { padding: 25px clamp(22px, 5vw, 76px); display: flex; justify-content: space-between; color: #8190a0; border-top: 1px solid #dce4ec; font-size: 11px; }

.handoff-page { display: grid; place-items: center; background: var(--background); }
.handoff-card { width: min(450px, calc(100% - 35px)); padding: 45px; background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); text-align: center; }
.handoff-card h1 { margin: 17px 0 8px; color: var(--navy-dark); font-size: 25px; }
.handoff-card p { margin: 0 0 25px; color: var(--muted); }
.spinner { width: 42px; height: 42px; margin: auto; border: 4px solid #dce8f1; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 850px) {
    .login-layout { grid-template-columns: 1fr; gap: 30px; padding: 42px 0; }
    .welcome-panel { padding-bottom: 0; }
    .welcome-panel h1 { font-size: clamp(34px, 10vw, 49px); }
    .welcome-copy { font-size: 17px; }
    .benefits { display: none; }
    .app-grid { grid-template-columns: 1fr; }
    .section-heading { align-items: start; flex-direction: column; }
    .section-heading > p { text-align: left; }
}

@media (max-width: 600px) {
    .topbar { min-height: 70px; padding: 11px 16px; }
    .brand-mark { width: 43px; height: 43px; }
    .brand strong { font-size: 13px; }
    .brand small, .user-label { display: none; }
    .text-button { padding: 7px 9px; }
    .login-layout, .dashboard-layout { width: min(100% - 26px, 1180px); }
    .login-layout { padding: 32px 0 45px; }
    .welcome-panel h1 { font-size: 35px; }
    .welcome-copy { margin-top: 17px; font-size: 15px; }
    .auth-card { padding: 23px 18px; border-radius: 17px; }
    .method-tab { font-size: 11px; }
    .flash { top: 78px; }
    .dashboard-layout { padding-top: 39px; }
    .dashboard-heading { align-items: start; flex-direction: column; }
    .app-card { min-height: 235px; padding: 22px; }
    footer { padding: 20px 15px; gap: 15px; }
}

/* Les règles compactes restent en fin de fichier pour primer sur le thème historique. */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 15%, rgba(0, 135, 204, .12), transparent 34%),
        radial-gradient(circle at 85% 85%, rgba(2, 8, 133, .08), transparent 32%),
        #f3f6f9;
}
.login-layout { width: min(430px, 100%); min-height: 0; margin: 0; padding: 0; display: block; }
.auth-card { width: 100%; padding: 30px; border: 1px solid #e4e6ef; border-radius: 14px; box-shadow: 0 16px 42px rgba(24, 28, 50, .12); }
.login-brand { margin-bottom: 24px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--navy-dark); font-size: 15px; }
.login-brand .brand-mark { width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(145deg, var(--blue), var(--navy)); box-shadow: 0 8px 18px rgba(0, 135, 204, .22); }
.auth-heading { margin-bottom: 21px; text-align: center; }
.auth-heading h1 { margin: 0; color: var(--navy-dark); font-size: 27px; letter-spacing: -.02em; }
.method-panel { padding-top: 18px; }
.method-tab { padding: 9px 6px; }
input { min-height: 46px; margin-bottom: 15px; }
.primary-button { min-height: 46px; background: var(--blue); box-shadow: 0 8px 17px rgba(0, 135, 204, .2); }
.primary-button:hover { background: #0078b6; filter: none; }
.code-panel { margin: 0; padding: 20px; }
.has-pending .auth-heading { margin-bottom: 16px; }
.has-pending .auth-methods.is-secondary { display: none; }
.badge-reader { margin-bottom: 15px; padding: 14px; }
.camera-frame { max-height: 205px; }
.login-page .flash { top: 18px; }

.dashboard-page { min-height: 100vh; display: flex; flex-direction: column; background: #f3f6f9; }
.topbar { min-height: 68px; padding: 9px clamp(20px, 4vw, 58px); }
.topbar .brand-mark { width: 43px; height: 43px; border-radius: 10px; }
.dashboard-layout { width: min(1320px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 24px; flex: 1; display: flex; flex-direction: column; }
.dashboard-heading { margin-bottom: 20px; align-items: center; }
.dashboard-heading h1 { font-size: clamp(28px, 3vw, 40px); }
.dashboard-heading p:last-child { margin-top: 4px; }
.app-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; flex: 1; align-items: stretch; }
.app-card,
.external-card {
    min-height: 210px;
    padding: 21px;
    color: var(--ink);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(24, 28, 50, .07);
    text-decoration: none;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.app-card-tickets { border-top: 4px solid var(--blue); }
.app-card-devis { border-top: 4px solid var(--navy); }
.app-card-devis .app-icon { background: linear-gradient(145deg, #2730a4, var(--navy)); }
.app-card.is-clickable { cursor: pointer; }
.app-card.is-clickable:hover { border-color: #b8dbea; box-shadow: 0 13px 30px rgba(24, 28, 50, .12); transform: translateY(-2px); text-decoration: none; }
.app-card.is-clickable:focus-visible { outline: 3px solid rgba(0, 135, 204, .25); outline-offset: 3px; }
.app-icon { width: 46px; height: 46px; border-radius: 10px; background: linear-gradient(145deg, #16a1df, var(--blue)); }
.app-copy { margin: 17px 0 18px; }
.app-copy h2 { margin: 5px 0 0; font-size: 21px; }
.app-card form { width: 100%; margin-top: auto; }
.card-action { padding: 10px 13px; color: #006fa8; background: var(--blue-soft); }
.external-card .card-action { margin-top: auto; }
.wordpress-icon { background: linear-gradient(145deg, #596274, #34394d); }
footer { padding: 13px clamp(20px, 4vw, 58px); }

@media (max-width: 1100px) {
    .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-card, .external-card { min-height: 170px; }
    .app-copy { margin: 11px 0 12px; }
}
@media (max-height: 700px) and (min-width: 701px) {
    .dashboard-layout { padding-top: 18px; padding-bottom: 16px; }
    .dashboard-heading { margin-bottom: 14px; }
    .app-card, .external-card { min-height: 158px; padding: 16px; }
    .app-icon { width: 40px; height: 40px; }
    .app-copy { margin: 9px 0 10px; }
}
@media (max-width: 700px) {
    .login-page { padding: 16px; }
    .login-layout { width: min(430px, 100%); padding: 0; }
    .auth-card { padding: 23px 18px; }
    .login-brand { margin-bottom: 19px; }
    .method-tab { font-size: 11px; }
    .dashboard-layout { width: min(100% - 26px, 1320px); padding-top: 24px; }
    .dashboard-heading { align-items: flex-start; flex-direction: column; }
    .app-grid { grid-template-columns: 1fr; }
    .app-card, .external-card { min-height: 175px; }
}
