:root {
    /* Charte Pictav'Énergie */
    --canard: #036666;
    --turquoise: #04A29A;
    --vert: #B1CB21;
    --bleu-clair: #4FBCC1;
    --vert-lichen: #61B87A;
    --vert-arsenic: #A7D4BA;

    --bg: #0f172a;
    --card: #ffffff;
    --primary: #036666;          /* bleu canard */
    --primary-dark: #024e4e;
    --accent: #04A29A;           /* turquoise */
    --text: #1e293b;
    --muted: #64748b;
    --border: #cbd5e1;
    --ok: #61B87A;               /* vert lichen */
    --danger: #dc2626;
    --radius: 12px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: #f1f5f9;
    font-size: 16px;
    line-height: 1.4;
}

/* ---------- Login ---------- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(160deg, var(--turquoise), var(--canard) 70%, #023b3b);
    padding: 20px;
}
.brand-wordmark { font-weight: 800; letter-spacing: .3px; }
.brand-wordmark .pe-vert { color: var(--vert); }
.subhead {
    margin: 22px 0 6px; padding: 8px 12px; border-radius: 8px;
    background: var(--vert-arsenic); color: #0b3b3b; font-weight: 700; font-size: 14px;
}
.login-card {
    background: var(--card); border-radius: var(--radius);
    padding: 28px 24px; width: 100%; max-width: 380px;
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.subtitle { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

/* ---------- App shell ---------- */
.app-header {
    position: sticky; top: 0; z-index: 10;
    background: var(--primary); color: #fff;
    padding: calc(10px + var(--safe-top)) 16px 10px;
    display: flex; align-items: center; justify-content: space-between;
}
.app-header .title { font-weight: 600; font-size: 15px; }
.app-header a { color: #eafffb; font-size: 13px; text-decoration: none; }
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-left .logo { height: 28px; width: auto; flex: 0 0 auto; }
.header-left .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.login-logo { display: block; width: 104px; height: auto; margin: 0 auto 14px; }

/* Menu hamburger */
.menu-btn {
    background: rgba(255,255,255,.18); border: none; color: #fff;
    font-size: 20px; width: 44px; height: 38px; border-radius: 9px; cursor: pointer;
}
.menu-backdrop { position: fixed; inset: 0; z-index: 40; display: none; }
.menu-backdrop.open { display: block; }
.menu-panel {
    position: fixed; top: calc(52px + var(--safe-top)); right: 10px; z-index: 50;
    background: #fff; border: 1px solid var(--border); border-radius: 14px;
    box-shadow: 0 12px 34px rgba(0,0,0,.22); display: none; flex-direction: column;
    min-width: 220px; overflow: hidden;
}
.menu-panel.open { display: flex; }
.menu-panel a {
    padding: 16px 18px; color: var(--text); text-decoration: none;
    border-bottom: 1px solid #eef2f6; font-size: 16px; display: flex; gap: 12px; align-items: center;
}
.menu-panel a:last-child { border-bottom: none; color: var(--danger); }
.menu-panel a:active { background: #f1f5f9; }

.progress-bar { height: 4px; background: #e2e8f0; }
.progress-bar > span { display: block; height: 100%; background: var(--ok); width: 0; transition: width .3s; }

.step-tabs {
    display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px;
    background: #fff; border-bottom: 1px solid var(--border); scrollbar-width: none;
}
.step-tabs::-webkit-scrollbar { display: none; }
.step-tab {
    flex: 0 0 auto; font-size: 12px; color: var(--muted);
    padding: 4px 10px; border-radius: 999px; background: #f1f5f9; white-space: nowrap;
}
.step-tab.active { background: var(--primary); color: #fff; }
.step-tab.done { background: #dcfce7; color: #166534; }
.step-tab.clickable { cursor: pointer; }
.step-tab.clickable:active { transform: scale(.96); }

.wizard { padding: 16px; max-width: 640px; margin: 0 auto 120px; }
.step-title { font-size: 18px; margin: 4px 0 2px; }
.step-hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* ---------- Fields ---------- */
label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
input, select, textarea {
    width: 100%; padding: 12px 14px; margin-top: 6px;
    border: 1px solid var(--border); border-radius: 10px;
    font-size: 16px; font-family: inherit; background: #fff; color: var(--text);
}
/* Les cases et radios ne doivent JAMAIS prendre toute la largeur */
input[type=checkbox], input[type=radio] { width: auto; margin-top: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }

.field-inline { display: flex; align-items: center; gap: 12px; font-weight: 500;
    padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.field-inline input[type=checkbox], .field-inline input[type=radio] {
    width: 22px; height: 22px; margin: 0; flex: 0 0 auto; }

/* Groupes d'options empilés verticalement : case collée au libellé */
.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.radio-group label, .checkbox-group label {
    width: 100%; margin: 0; padding: 12px; border: 1px solid var(--border);
    border-radius: 10px; display: flex; align-items: center; gap: 12px; font-weight: 400;
}
.radio-group input[type=radio], .radio-group input[type=checkbox],
.checkbox-group input { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; }
.radio-group label:has(input:checked) { border-color: var(--primary); background: #eff6ff; }
.field-error input, .field-error select, .field-error textarea { border-color: var(--danger); }
.error-msg { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* ---------- Nav ---------- */
.wizard-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-bottom));
    background: #fff; border-top: 1px solid var(--border); z-index: 10;
}
.btn-primary, .btn-secondary {
    flex: 1; padding: 14px; border-radius: 10px; border: none;
    font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-primary:disabled { opacity: .5; }

.alert { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.notice { background: #eff6ff; color: var(--primary-dark); border: 1px solid #bfdbfe; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }

/* ---------- Signature ---------- */
.sig-block { margin-bottom: 20px; }
.sig-label { font-weight: 600; margin-bottom: 6px; }
.sig-pad-wrap { position: relative; border: 2px dashed var(--border); border-radius: 10px; background: #fff; }
.sig-pad { display: block; width: 100%; height: 180px; touch-action: none; border-radius: 8px; }
.sig-actions { display: flex; gap: 8px; margin-top: 8px; }
.sig-actions button { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: #f8fafc; font-size: 14px; }
.sig-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); pointer-events: none; font-size: 14px; }

/* ---------- Fullscreen landscape signature overlay ---------- */
.sig-fullscreen {
    position: fixed; inset: 0; z-index: 1000; background: #fff;
    display: none; flex-direction: column;
}
.sig-fullscreen.open { display: flex; }
.sig-fs-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--primary); color: #fff; }
.sig-fs-canvas { flex: 1; touch-action: none; }
.sig-fs-actions { display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-bottom)); }
.rotate-hint { display:none; }
