/* ============================================================
   Domaine des Allées — back-office
   Thème clair, sobre & élégant. Accent vert « domaine ».
   ============================================================ */

:root {
    --bg:            #f6f5f0;
    --surface:       #ffffff;
    --surface-2:     #fbfaf7;
    --ink:           #1b211d;
    --ink-soft:      #3c443e;
    --muted:         #828a82;
    --line:          #e7e4da;
    --line-strong:   #d8d4c8;

    --accent:        #2f6b53;
    --accent-deep:   #245540;
    --accent-soft:   #e9f1ec;
    --accent-ink:    #1f4a39;

    --danger:        #b1473b;
    --danger-soft:   #f7e9e7;
    --warn:          #9a6b18;
    --warn-soft:     #f6eedb;
    --ok:            #2f6b53;

    --radius:        14px;
    --radius-sm:     9px;
    --shadow-sm:     0 1px 2px rgba(27, 33, 29, .05), 0 1px 1px rgba(27, 33, 29, .04);
    --shadow:        0 6px 24px -12px rgba(27, 33, 29, .22), 0 2px 6px -4px rgba(27, 33, 29, .12);

    --font-sans:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif:    "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;

    --sidebar-w:     264px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
h1 { font-size: 1.7rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.block { display: block; }
.nowrap { white-space: nowrap; }
.ta-r { text-align: right; }
.ta-c { text-align: center; }

/* ---------- Focus accessible ---------- */
:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, white);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================================
   Connexion / pages publiques
   ============================================================ */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-shell { width: 100%; max-width: 410px; }

.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px 32px 28px;
    text-align: center;
}
.auth-head h1 { font-size: 1.45rem; margin: 14px 0 2px; }
.auth-head .muted { font-size: .92rem; }
.auth-card .form { margin-top: 26px; text-align: left; }
.auth-foot { margin: 22px 0 0; font-size: .82rem; }
.error-card h1 { font-size: 3rem; margin: 14px 0 4px; }
.error-card .btn { margin-top: 18px; }

/* ============================================================
   Marque
   ============================================================ */
.brand-mark {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(150deg, var(--accent), var(--accent-deep));
    color: #fff; font-family: var(--font-serif); font-weight: 700;
    font-size: .92rem; letter-spacing: .02em;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}
.brand-mark-lg { width: 56px; height: 56px; font-size: 1.3rem; border-radius: 14px; }

/* ============================================================
   App shell
   ============================================================ */
body.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 22px 16px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-family: var(--font-serif); font-size: 1.02rem; }
.brand-text small { color: var(--muted); font-size: .76rem; letter-spacing: .03em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--ink-soft); font-weight: 500; font-size: .92rem;
    transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.nav-ico { width: 18px; height: 18px; flex: none; opacity: .85;
    background: currentColor;
    -webkit-mask: var(--ico) center / contain no-repeat;
            mask: var(--ico) center / contain no-repeat; }
.i-grid  { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='7' height='7'/><rect x='14' y='3' width='7' height='7'/><rect x='14' y='14' width='7' height='7'/><rect x='3' y='14' width='7' height='7'/></svg>"); }
.i-users { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/><circle cx='9' cy='7' r='4'/><path d='M23 21v-2a4 4 0 0 0-3-3.87'/><path d='M16 3.13a4 4 0 0 1 0 7.75'/></svg>"); }
.i-list  { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='8' y1='6' x2='21' y2='6'/><line x1='8' y1='12' x2='21' y2='12'/><line x1='8' y1='18' x2='21' y2='18'/><line x1='3' y1='6' x2='3.01' y2='6'/><line x1='3' y1='12' x2='3.01' y2='12'/><line x1='3' y1='18' x2='3.01' y2='18'/></svg>"); }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.me-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.me-text strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); font-size: .76rem; }
.logout-form { padding: 0 2px; }

.avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent-ink);
    font-weight: 600; font-size: .9rem;
}
.avatar-sm { width: 30px; height: 30px; font-size: .82rem; }

/* ---------- Main ---------- */
.main { padding: 34px 40px 60px; max-width: 1100px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 4px; font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 600; }
.back-link { color: var(--accent); font-weight: 600; }

/* ============================================================
   Cartes & sections
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.section { padding: 24px 26px; }
.section-title { margin-bottom: 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { padding: 20px 22px; }
.stat-label { margin: 0 0 6px; color: var(--muted); font-size: .85rem; }
.stat-value { margin: 0; font-family: var(--font-serif); font-size: 2.1rem; font-weight: 600; color: var(--accent-ink); }

.module-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.module-list li { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); }
.module-list em { color: var(--muted); font-style: normal; font-size: .85rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot-ok { background: var(--accent); }

/* ============================================================
   Tableaux
   ============================================================ */
.table-card { overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table thead th {
    text-align: left; font-weight: 600; font-size: .76rem; letter-spacing: .04em;
    text-transform: uppercase; color: var(--muted);
    padding: 13px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.table tbody td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.row-off { opacity: .62; }

.u-cell { display: flex; align-items: center; gap: 11px; }
.u-cell small { font-size: .82rem; }
.details code { font-size: .8rem; color: var(--ink-soft); background: var(--surface-2); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); }

.actions { display: inline-flex; gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }

/* ============================================================
   Badges & tags
   ============================================================ */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .76rem; font-weight: 600; line-height: 1.5;
    background: #eef0ec; color: var(--ink-soft); border: 1px solid var(--line);
}
.badge-ok, .badge-owner { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 20%, white); }
.badge-admin { background: #eaf0f6; color: #2a4c6b; border-color: #d4e1ee; }
.badge-off, .badge-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 18%, white); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, white); }
.badge-neutral { background: #eef0ec; }
.tag-soft { display: inline-block; font-size: .68rem; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); padding: 1px 7px; border-radius: 6px; margin-left: 4px; vertical-align: middle; }

/* ============================================================
   Boutons
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font: inherit; font-weight: 600; font-size: .9rem;
    padding: 9px 16px; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
    white-space: nowrap; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-deep); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-soft:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 16%); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, white); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ============================================================
   Formulaires
   ============================================================ */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-card { padding: 28px 30px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.hint { color: var(--muted); font-size: .8rem; }

input[type=text], input[type=email], input[type=password], input[type=tel], .select {
    font: inherit; color: var(--ink);
    padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong); background: var(--surface);
    transition: border-color .15s ease, box-shadow .15s ease;
    width: 100%;
}
input:focus, .select:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23828a82' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; cursor: pointer; }
.select-sm { padding: 6px 28px 6px 10px; font-size: .85rem; border-radius: 8px; background-position: right 9px center; }

.field-check { gap: 8px; }
.check { display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--ink-soft); font-weight: 500; cursor: pointer; padding: 9px 0; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ============================================================
   Flash messages
   ============================================================ */
.flashes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.flashes:empty { margin: 0; }
.flash { padding: 11px 16px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 22%, white); }
.flash-error   { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, white); }
.auth-shell .flashes { margin-bottom: 14px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
    body.app { grid-template-columns: 1fr; }
    .sidebar {
        position: static; height: auto; flex-direction: row; flex-wrap: wrap;
        align-items: center; gap: 8px 14px; padding: 12px 16px;
        border-right: 0; border-bottom: 1px solid var(--line);
    }
    .brand { padding: 0; flex: 1 1 auto; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-link { padding: 7px 11px; }
    .sidebar-foot { margin: 0; padding: 0; border: 0; flex-direction: row; align-items: center; gap: 12px; }
    .main { padding: 24px 18px 48px; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .grid-2 { grid-template-columns: 1fr; }
    .table-card { overflow-x: auto; }
    .actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
