/* ---------------------------------------------------------------------------
   Lutrimo — feuille de style unique (site public + espace privé)
   Thème clair par défaut, thème sombre automatique ou forcé via data-theme.
   Aucune ressource externe : polices système, icônes textuelles.
   --------------------------------------------------------------------------- */

:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --bg-soft: #eaf0f8;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef3fa;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #5b677a;
    --border: #d8e0eb;
    --border-strong: #b9c6d8;
    --primary: #1d4ed8;
    --primary-strong: #1e3a8a;
    --primary-soft: #dbeafe;
    --primary-contrast: #ffffff;
    --accent: #0f766e;
    --accent-soft: #ccfbf1;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #a16207;
    --warning-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
    --shadow: 0 12px 30px rgb(15 23 42 / 8%);
    --shadow-lg: 0 24px 60px rgb(15 23 42 / 12%);
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 22px;
    --container: 1140px;
    --header-height: 72px;
    --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #070d19;
        --bg-soft: #0b1424;
        --surface: #101b2d;
        --surface-2: #0d1727;
        --surface-3: #162338;
        --text: #e6eef9;
        --text-soft: #c7d4e5;
        --muted: #94a6bd;
        --border: #223249;
        --border-strong: #334863;
        --primary: #60a5fa;
        --primary-strong: #93c5fd;
        --primary-soft: #172d4d;
        --primary-contrast: #08111f;
        --accent: #2dd4bf;
        --accent-soft: #10312e;
        --success: #4ade80;
        --success-soft: #10301f;
        --warning: #fbbf24;
        --warning-soft: #33270b;
        --danger: #f87171;
        --danger-soft: #3a1518;
        --shadow-sm: 0 1px 2px rgb(0 0 0 / 35%);
        --shadow: 0 16px 38px rgb(0 0 0 / 38%);
        --shadow-lg: 0 28px 70px rgb(0 0 0 / 48%);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #070d19;
    --bg-soft: #0b1424;
    --surface: #101b2d;
    --surface-2: #0d1727;
    --surface-3: #162338;
    --text: #e6eef9;
    --text-soft: #c7d4e5;
    --muted: #94a6bd;
    --border: #223249;
    --border-strong: #334863;
    --primary: #60a5fa;
    --primary-strong: #93c5fd;
    --primary-soft: #172d4d;
    --primary-contrast: #08111f;
    --accent: #2dd4bf;
    --accent-soft: #10312e;
    --success: #4ade80;
    --success-soft: #10301f;
    --warning: #fbbf24;
    --warning-soft: #33270b;
    --danger: #f87171;
    --danger-soft: #3a1518;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 35%);
    --shadow: 0 16px 38px rgb(0 0 0 / 38%);
    --shadow-lg: 0 28px 70px rgb(0 0 0 / 48%);
}

/* ---------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
}

img,
svg {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--primary-strong);
}

h1,
h2,
h3,
h4 {
    margin: 0 0 0.55em;
    color: var(--text);
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2rem, 4.2vw, 3.35rem);
}

h2 {
    font-size: clamp(1.35rem, 2.3vw, 1.85rem);
}

h3 {
    font-size: 1.18rem;
}

p {
    margin: 0 0 1rem;
}

ul,
ol {
    margin: 0 0 1rem;
    padding-left: 1.35rem;
}

li + li {
    margin-top: 0.25rem;
}

code,
pre,
kbd,
samp {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

code {
    padding: 0.12em 0.38em;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--text-soft);
    overflow-wrap: anywhere;
}

pre code {
    padding: 0;
    border: 0;
    background: none;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

::selection {
    background: var(--primary);
    color: var(--primary-contrast);
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 1000;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--primary-contrast);
    font-weight: 700;
    text-decoration: none;
}

.skip-link:focus {
    top: 1rem;
}

.container {
    width: min(100% - 2.5rem, var(--container));
    margin-inline: auto;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.875rem;
}

.nowrap {
    white-space: nowrap;
}

.break-all {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.block {
    display: block;
}

.text-link {
    font-weight: 650;
    text-decoration: none;
}

.text-link:hover {
    text-decoration: underline;
}

.required {
    color: var(--danger);
}

/* ---------------------------------------------------------------------------
   Marque et navigation publique
   --------------------------------------------------------------------------- */

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

.brand:hover {
    color: var(--text);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(140deg, var(--primary), var(--accent));
    color: #fff;
    font-size: 1.35rem;
    font-weight: 800;
    box-shadow: var(--shadow-sm);
}

.brand-text {
    display: grid;
    line-height: 1.15;
}

.brand-text strong {
    font-size: 1.08rem;
    letter-spacing: 0.02em;
}

.brand-text small {
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
}

.site-header-inner {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    min-height: var(--header-height);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin-left: auto;
}

.site-nav a {
    position: relative;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: 0.94rem;
    font-weight: 600;
    text-decoration: none;
}

.site-nav a:hover {
    background: var(--surface-3);
    color: var(--text);
}

.site-nav a.is-active {
    color: var(--primary);
}

.site-nav a.is-active::after {
    content: "";
    position: absolute;
    right: 0.7rem;
    bottom: 0.22rem;
    left: 0.7rem;
    height: 2px;
    border-radius: 2px;
    background: var(--primary);
}

.site-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 650;
    cursor: pointer;
}

.theme-toggle:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.theme-toggle-icon {
    font-size: 1rem;
    line-height: 1;
}

/* ---------------------------------------------------------------------------
   Boutons
   --------------------------------------------------------------------------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.05rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--text);
    font: inherit;
    font-size: 0.94rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.button:hover {
    transform: translateY(-1px);
    color: var(--text);
}

.button:active {
    transform: translateY(0);
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.button-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-contrast);
}

.button-primary:hover {
    background: var(--primary-strong);
    border-color: var(--primary-strong);
    color: var(--primary-contrast);
}

.button-ghost {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-soft);
}

.button-ghost:hover {
    background: var(--surface-3);
    border-color: var(--primary);
    color: var(--text);
}

.button-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.button-danger:hover {
    filter: brightness(0.92);
    color: #fff;
}

.button-small {
    padding: 0.42rem 0.7rem;
    border-radius: 8px;
    font-size: 0.82rem;
}

.button-block {
    width: 100%;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

/* ---------------------------------------------------------------------------
   Site public — sections
   --------------------------------------------------------------------------- */

.site-main {
    min-height: 50vh;
}

.hero {
    position: relative;
    overflow: hidden;
    padding: clamp(3rem, 7vw, 6rem) 0;
    background:
        radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 34%),
        radial-gradient(circle at 88% 8%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 30%),
        linear-gradient(180deg, var(--bg-soft), var(--bg));
}

.hero-inner {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    align-items: center;
    gap: clamp(2rem, 5vw, 4rem);
}

.hero-copy h1 {
    max-width: 18ch;
}

.lead {
    max-width: 62ch;
    color: var(--text-soft);
    font-size: clamp(1.02rem, 1.6vw, 1.18rem);
    line-height: 1.7;
}

.eyebrow {
    margin-bottom: 0.85rem;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1.4rem;
}

.hero-points {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.2rem;
    margin: 1.5rem 0 0;
    padding: 0;
    list-style: none;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.hero-points li {
    margin: 0;
}

.hero-points li::before {
    content: "✓";
    margin-right: 0.35rem;
    color: var(--success);
    font-weight: 800;
}

.hero-card {
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    box-shadow: var(--shadow-lg);
}

.hero-card-title {
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hero-card-list {
    display: grid;
    gap: 0.65rem;
    margin: 0 0 1.1rem;
    padding: 0;
    list-style: none;
}

.hero-card-list li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.hero-card-list li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.hero-card-list span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--surface-3);
    font-size: 1.05rem;
}

.section {
    padding: clamp(3rem, 6vw, 5rem) 0;
}

.section-alt {
    border-block: 1px solid var(--border);
    background: var(--surface-2);
}

.section-heading {
    max-width: 760px;
    margin-bottom: 2rem;
}

.section-heading h2 {
    margin-bottom: 0.6rem;
}

.page-hero {
    padding: clamp(2.6rem, 5vw, 4.2rem) 0;
    border-bottom: 1px solid var(--border);
    background:
        radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 32%),
        var(--bg-soft);
}

.page-hero h1 {
    max-width: 24ch;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.1rem;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
    box-shadow: var(--shadow);
}

.card h2,
.card h3 {
    margin-bottom: 0.25rem;
}

.card h2 a {
    color: inherit;
    text-decoration: none;
}

.card h2 a:hover {
    color: var(--primary);
}

.card p:last-child {
    margin-bottom: 0;
}

.card-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 0.55rem;
    border-radius: 12px;
    background: var(--surface-3);
    font-size: 1.3rem;
}

.card-accent {
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    background: linear-gradient(160deg, var(--primary-soft), var(--surface));
}

.agent-card {
    justify-content: space-between;
}

.agent-card .button-group {
    margin-top: auto;
    padding-top: 0.75rem;
}

.public-body {
    background: var(--bg);
}

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.steps li {
    position: relative;
    margin: 0;
    padding: 1.3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.steps h3 {
    margin-top: 0.6rem;
}

.steps p {
    margin-bottom: 0;
    color: var(--muted);
}

.step-number {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-contrast);
    font-size: 0.9rem;
    font-weight: 800;
}

.cta-section {
    padding: clamp(2.5rem, 5vw, 4rem) 0;
    border-top: 1px solid var(--border);
    background:
        radial-gradient(circle at 85% 20%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 34%),
        linear-gradient(120deg, var(--surface-3), var(--surface));
}

.cta-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.cta-inner h2 {
    margin-bottom: 0.4rem;
}

.cta-inner p:last-child {
    margin-bottom: 0;
}

.cta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.service-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem;
}

.service-item {
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.service-item-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.service-item-head .card-icon {
    margin: 0;
    flex: 0 0 auto;
}

.service-item-head h2 {
    margin: 0;
    font-size: 1.25rem;
}

.check-list {
    display: grid;
    gap: 0.35rem;
    margin: 0.8rem 0 0;
    padding: 0;
    list-style: none;
}

.check-list li {
    position: relative;
    margin: 0;
    padding-left: 1.35rem;
    color: var(--text-soft);
}

.check-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 800;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: start;
}

.info-card {
    padding: 1.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.info-card h2 {
    font-size: 1.15rem;
}

.info-card:not(:last-child) {
    margin-bottom: 1rem;
}

.contact-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: start;
}

.contact-form-wrap {
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.contact-aside {
    display: grid;
    gap: 1rem;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0;
    padding: 0;
    list-style: none;
}

.tag {
    margin: 0;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 650;
}

.prose {
    max-width: 72ch;
}

.prose h2 {
    margin-top: 1.8rem;
}

.prose h2:first-child {
    margin-top: 0;
}

.prose p,
.prose li {
    color: var(--text-soft);
}

.prose-small {
    font-size: 0.94rem;
}

.legal-prose {
    max-width: 80ch;
}

/* ---------------------------------------------------------------------------
   Pied de page public
   --------------------------------------------------------------------------- */

.site-footer {
    padding-top: 3rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.site-footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 2rem;
    padding-bottom: 2rem;
}

.footer-brand {
    margin-bottom: 0.35rem;
    font-size: 1.25rem;
    font-weight: 800;
}

.footer-heading {
    margin-bottom: 0.6rem;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.footer-links {
    margin: 0;
    padding: 0;
    list-style: none;
}

.footer-links li {
    margin: 0 0 0.35rem;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.site-footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    padding-block: 1.2rem;
    border-top: 1px solid var(--border);
}

.site-footer-bottom p {
    margin: 0;
}

/* ---------------------------------------------------------------------------
   Authentification
   --------------------------------------------------------------------------- */

.auth-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 32%),
        radial-gradient(circle at 90% 90%, color-mix(in srgb, var(--accent) 15%, transparent), transparent 34%),
        var(--bg);
}

.auth-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: var(--header-height);
}

.auth-main {
    display: grid;
    place-items: center;
    flex: 1;
    width: min(100% - 2rem, 560px);
    margin: 1rem auto 2rem;
}

.auth-card {
    width: 100%;
    padding: clamp(1.4rem, 4vw, 2.4rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.auth-title {
    margin-bottom: 0.35rem;
    font-size: clamp(1.6rem, 4vw, 2.1rem);
}

.auth-subtitle {
    margin-bottom: 1.4rem;
    color: var(--muted);
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 1.1rem;
    font-size: 0.9rem;
}

.auth-note {
    margin: 1.2rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.auth-help {
    margin-top: 1rem;
    text-align: center;
}

.auth-cancel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.auth-footer {
    padding: 1rem;
    text-align: center;
}

.auth-footer p {
    margin: 0;
}

.setup-steps {
    display: grid;
    gap: 1.4rem;
}

.setup-step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.9rem;
    align-items: start;
}

.setup-step h2 {
    font-size: 1.12rem;
}

.secret-box {
    display: grid;
    gap: 0.3rem;
    margin: 0.8rem 0;
    padding: 0.9rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.secret-label {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.secret-value {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
}

.backup-codes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.backup-codes li {
    margin: 0;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    text-align: center;
}

.backup-codes code {
    padding: 0;
    border: 0;
    background: none;
    font-size: 0.95rem;
    font-weight: 700;
}

/* ---------------------------------------------------------------------------
   Espace privé
   --------------------------------------------------------------------------- */

.app-body {
    background: var(--bg);
}

.app-shell {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    height: 100vh;
    padding: 1.2rem 1rem;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
}

.app-brand {
    padding: 0.2rem 0.35rem 1rem;
    border-bottom: 1px solid var(--border);
}

.app-nav {
    display: grid;
    gap: 0.25rem;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.62rem 0.7rem;
    border-radius: 10px;
    color: var(--text-soft);
    font-size: 0.92rem;
    font-weight: 650;
    text-decoration: none;
}

.app-nav-link:hover {
    background: var(--surface-3);
    color: var(--text);
}

.app-nav-link.is-active {
    background: var(--primary-soft);
    color: var(--primary-strong);
}

:root[data-theme="dark"] .app-nav-link.is-active,
@media (prefers-color-scheme: dark) {
    /* géré par les variables : conserve un contraste correct */
}

.app-nav-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: 8px;
    background: color-mix(in srgb, currentColor 10%, transparent);
    font-size: 0.95rem;
}

.app-sidebar-footer {
    display: grid;
    gap: 0.7rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.app-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem;
    border-radius: 10px;
    background: var(--surface-2);
}

.app-user-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 800;
}

.app-user-meta {
    display: grid;
    min-width: 0;
    line-height: 1.25;
}

.app-user-meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-user-meta small {
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: capitalize;
}

.app-logout {
    margin: 0;
}

.app-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem clamp(1rem, 3vw, 2rem);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(14px);
}

.app-topbar-kicker {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.app-topbar-title {
    margin: 0;
    font-size: clamp(1.15rem, 2.2vw, 1.55rem);
}

.app-main {
    flex: 1;
    padding: clamp(1rem, 3vw, 2rem);
}

.app-main > * + * {
    margin-top: 1.1rem;
}

.app-footer {
    padding: 1rem clamp(1rem, 3vw, 2rem);
    border-top: 1px solid var(--border);
}

.app-footer p {
    margin: 0;
}

/* ---------------------------------------------------------------------------
   Composants de l'espace privé
   --------------------------------------------------------------------------- */

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.page-actions h2 {
    margin-bottom: 0.2rem;
}

.page-actions p:last-child {
    margin-bottom: 0;
}

.title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}

.title-row h2,
.title-row h1 {
    margin-bottom: 0;
}

.panel {
    padding: clamp(1rem, 2.4vw, 1.5rem);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.panel > h2:first-child {
    margin-top: 0;
}

.panel-warning {
    border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
    background: linear-gradient(160deg, var(--warning-soft), var(--surface));
}

.panel-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.panel-heading h2 {
    margin-bottom: 0.15rem;
}

.panel-heading p:last-child {
    margin-bottom: 0;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem;
    align-items: start;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.9rem;
}

.stat-card {
    display: grid;
    gap: 0.15rem;
    padding: 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat-card-warning {
    border-color: color-mix(in srgb, var(--warning) 55%, var(--border));
    background: linear-gradient(160deg, var(--warning-soft), var(--surface));
}

.stat-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
}

.stat-meta {
    color: var(--muted);
    font-size: 0.82rem;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.alert-icon {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: color-mix(in srgb, currentColor 14%, transparent);
    font-size: 0.8rem;
    font-weight: 900;
}

.alert a {
    color: inherit;
    font-weight: 700;
}

.alert-success {
    border-color: color-mix(in srgb, var(--success) 40%, var(--border));
    background: var(--success-soft);
    color: var(--success);
}

.alert-warning {
    border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
    background: var(--warning-soft);
    color: var(--warning);
}

.alert-danger {
    border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
    background: var(--danger-soft);
    color: var(--danger);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 750;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-success {
    border-color: color-mix(in srgb, var(--success) 40%, var(--border));
    background: var(--success-soft);
    color: var(--success);
}

.badge-warning {
    border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-danger {
    border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
    background: var(--danger-soft);
    color: var(--danger);
}

.badge-muted {
    background: var(--surface-3);
    color: var(--muted);
}

.empty-state {
    display: grid;
    justify-items: start;
    gap: 0.4rem;
    max-width: 720px;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.empty-state h2 {
    margin-bottom: 0;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 0.4rem;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 1.5rem;
}

.empty-state p:last-of-type {
    margin-bottom: 0.4rem;
}

/* Tableaux */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

.table-wrap.panel {
    padding: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: color-mix(in srgb, var(--primary) 4%, transparent);
}

.data-table p {
    margin: 0;
}

.cell-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

/* Listes d'informations */

.info-list {
    display: grid;
    gap: 0.6rem;
    margin: 0 0 1rem;
}

.info-list > div {
    display: grid;
    grid-template-columns: minmax(130px, 0.4fr) minmax(0, 1fr);
    gap: 0.8rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--border);
}

.info-list > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.info-list dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.info-list dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.info-list-inline {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.info-list-inline > div {
    display: block;
    border: 0;
    padding: 0;
}

.info-list-inline dt {
    margin-bottom: 0.1rem;
}

.simple-list {
    display: grid;
    gap: 0.55rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.simple-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin: 0;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--border);
}

.simple-list li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.simple-list p {
    margin: 0;
}

.simple-list-compact li {
    padding-bottom: 0.35rem;
}

.simple-list-compact li > span {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.action-list {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.action-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.9rem;
    margin: 0;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.action-item > div {
    min-width: 0;
    flex: 1 1 260px;
}

.action-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.action-title strong {
    font-size: 1rem;
}

.code-block {
    max-width: 100%;
    max-height: 420px;
    margin: 0 0 0.6rem;
    padding: 0.9rem;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 0.86rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.code-block-small {
    max-height: 240px;
    font-size: 0.8rem;
}

.metadata-details summary {
    color: var(--primary);
    font-weight: 650;
    cursor: pointer;
}

.metadata-details .code-block {
    margin-top: 0.4rem;
}

/* Mini-cartes et automatisations */

.card-grid-compact {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.mini-card {
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.mini-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

.mini-card h3 {
    margin: 0;
    font-size: 1rem;
}

.mini-card h3 a {
    color: inherit;
    text-decoration: none;
}

.mini-card h3 a:hover {
    color: var(--primary);
}

.mini-card p {
    margin: 0.25rem 0 0;
}

.automation-list {
    display: grid;
    gap: 1rem;
}

.automation-card .panel-heading {
    margin-bottom: 0.75rem;
}

/* Pagination */

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------------
   Formulaires
   --------------------------------------------------------------------------- */

.form {
    display: grid;
    gap: 1rem;
}

.form-panel {
    max-width: 980px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    align-items: start;
}

.field {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
}

.field > label,
.field > legend {
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 750;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.58rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.4;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field textarea {
    min-height: 120px;
    resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
    border-color: var(--primary);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent);
    outline-offset: 0;
}

.field input::placeholder,
.field textarea::placeholder {
    color: color-mix(in srgb, var(--muted) 75%, transparent);
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
    border-color: var(--danger);
}

.field-error {
    margin: 0;
    color: var(--danger);
    font-size: 0.82rem;
    font-weight: 650;
}

.field-help {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.field-checkbox {
    gap: 0.3rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    color: var(--text-soft);
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 0;
    margin-top: 0.2rem;
    flex: 0 0 auto;
    accent-color: var(--primary);
}

.checkbox-card {
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.checkbox-card + .checkbox-card {
    margin-top: 0.45rem;
}

.checkbox-card:hover {
    border-color: var(--primary);
}

.field-group {
    min-width: 0;
    margin: 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.field-group legend {
    padding-inline: 0.35rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding-top: 0.25rem;
}

.filter-form {
    margin-bottom: 1rem;
}

.filter-form .form-row {
    align-items: end;
}

.hp-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.turnstile-wrap {
    margin: 0.25rem 0;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 1020px) {
    .hero-inner,
    .split-layout,
    .contact-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .hero-card {
        max-width: 520px;
    }

    .service-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .content-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-shell {
        grid-template-columns: 230px minmax(0, 1fr);
    }
}

@media (max-width: 840px) {
    .site-header-inner {
        flex-wrap: wrap;
        padding-block: 0.7rem;
    }

    .site-nav {
        order: 3;
        width: 100%;
        margin-left: 0;
        overflow-x: auto;
        padding-bottom: 0.2rem;
    }

    .site-actions {
        margin-left: auto;
    }

    .site-footer-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .cta-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: static;
        height: auto;
        padding: 0.9rem;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        overflow: visible;
    }

    .app-brand {
        padding-bottom: 0.7rem;
    }

    .app-nav {
        display: flex;
        gap: 0.35rem;
        overflow-x: auto;
        padding-bottom: 0.25rem;
    }

    .app-nav-link {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .app-sidebar-footer {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.6rem;
        margin-top: 0.7rem;
    }

    .app-user {
        flex: 1 1 180px;
    }

    .app-topbar {
        position: static;
    }
}

@media (max-width: 620px) {
    .container {
        width: min(100% - 1.5rem, var(--container));
    }

    .brand-text small {
        display: none;
    }

    .site-footer-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .site-footer-bottom {
        flex-direction: column;
    }

    .info-list > div {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.15rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.6rem 0.55rem;
    }

    .action-item {
        padding: 0.75rem;
    }

    .theme-toggle-label {
        display: none;
    }

    .stat-value {
        font-size: 1.7rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .site-header,
    .site-footer,
    .app-sidebar,
    .app-topbar,
    .theme-toggle,
    .button,
    .form-actions {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .app-shell {
        display: block;
    }

    .panel,
    .card {
        box-shadow: none;
        border-color: #ccc;
    }
}
