/* ==========================================================================
   DESIGN SYSTEM — abrt dashboard
   Modern, clean, dark + light with auto theme toggle
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- Design tokens ---------- */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;

    /* Spacing scale (4px base) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Category accents (mode-agnostic) */
    --accent-portfolio: #3b82f6;
    --accent-projet:    #10b981;
    --accent-admin:     #ef4444;
}

/* Dark theme (default) */
:root,
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg:            #08090b;
    --bg-grad:       radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99,102,241,0.10), transparent 70%);
    --surface:       #0f1115;
    --surface-2:     #15181d;
    --surface-3:     #1c2027;
    --surface-hover: #1f242c;
    --border:        #1f232b;
    --border-strong: #2a2f38;
    --border-focus:  #6366f1;

    --text:          #f4f4f5;
    --text-muted:    #a1a1aa;
    --text-subtle:   #71717a;
    --text-faint:    #52525b;

    --accent:        #6366f1;
    --accent-hover:  #818cf8;
    --accent-fg:     #ffffff;
    --accent-bg:     rgba(99,102,241,0.12);
    --accent-border: rgba(99,102,241,0.35);

    --success:       #10b981;
    --warning:       #f59e0b;
    --danger:        #ef4444;

    --shadow-sm:  0 1px 2px rgba(0,0,0,0.4);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.45);
    --shadow-lg:  0 12px 32px rgba(0,0,0,0.55);
    --shadow-glow: 0 0 0 1px rgba(99,102,241,0.3), 0 8px 32px rgba(99,102,241,0.15);

    /* Conteneur du logo brand : fond clair en dark (le SVG a des éléments très sombres) */
    --brand-icon-bg:     transparent;
    --brand-icon-border: transparent;
    --brand-icon-shadow: none;
}

/* Light theme */
:root[data-theme="light"] {
    color-scheme: light;

    --bg:            #fafafa;
    --bg-grad:       radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99,102,241,0.08), transparent 70%);
    --surface:       #ffffff;
    --surface-2:     #f4f4f5;
    --surface-3:     #e4e4e7;
    --surface-hover: #f9fafb;
    --border:        #e4e4e7;
    --border-strong: #d4d4d8;
    --border-focus:  #6366f1;

    --text:          #09090b;
    --text-muted:    #52525b;
    --text-subtle:   #71717a;
    --text-faint:    #a1a1aa;

    --accent:        #4f46e5;
    --accent-hover:  #4338ca;
    --accent-fg:     #ffffff;
    --accent-bg:     rgba(79,70,229,0.08);
    --accent-border: rgba(79,70,229,0.25);

    --success:       #059669;
    --warning:       #d97706;
    --danger:        #dc2626;

    --shadow-sm:  0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg:  0 12px 32px rgba(0,0,0,0.10);
    --shadow-glow: 0 0 0 1px rgba(79,70,229,0.2), 0 8px 32px rgba(79,70,229,0.10);

    /* Logo en mode clair : fond très subtil pour rester discret */
    --brand-icon-bg:     transparent;
    --brand-icon-border: transparent;
    --brand-icon-shadow: none;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    background-image: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--t-base), color var(--t-base);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img, svg { display: block; max-width: 100%; }

::selection { background: var(--accent-bg); color: var(--text); }

/* ---------- Header ---------- */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-8);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
}

.server-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    background: var(--brand-icon-bg);
    border: 1px solid var(--brand-icon-border);
    box-shadow: var(--brand-icon-shadow);
    overflow: hidden;
    flex-shrink: 0;
}
.server-icon img { width: 44px; height: 44px; }

.header-title { display: flex; flex-direction: column; gap: 2px; }
.header-title h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}
.header-title p {
    font-size: 0.78rem;
    color: var(--text-subtle);
    font-weight: 400;
}

/* Header actions cluster (theme toggle + session) */
.header-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.session-info {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.85rem;
}
.session-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    padding: 7px 10px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-logout,
.session-login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-muted);
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: all var(--t-fast);
    font-weight: 500;
}
.session-logout { padding: 7px 10px; }
.session-logout:hover { color: var(--danger); border-color: var(--danger); }
.session-login:hover  { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--t-fast);
    flex-shrink: 0;
    padding: 0;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun  { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun  { display: block; }

/* ---------- Main ---------- */
main {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--space-10) var(--space-8) 120px;
}

/* ---------- Dashboard tabs ---------- */
.dashboard-tabs {
    position: relative;
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-8);
    padding-bottom: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.dashboard-tabs::-webkit-scrollbar { display: none; }

.dashboard-tab {
    position: relative;
    padding: 12px 18px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: color var(--t-fast);
    white-space: nowrap;
    z-index: 1;
}
.dashboard-tab:hover { color: var(--text); }
.dashboard-tab.active { color: var(--accent); font-weight: 600; }
.dashboard-tab[data-view="admin"].active { color: var(--danger); }
.dashboard-tab[data-view="projets"].active { color: var(--success); }

.tab-underline {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    transition: transform var(--t-slow), width var(--t-slow), background var(--t-fast);
}
.tab-underline[data-view="admin"]   { background: var(--danger);  }
.tab-underline[data-view="projets"] { background: var(--success); }

.dashboard-empty {
    text-align: center;
    color: var(--text-subtle);
    padding: var(--space-16) var(--space-4);
    font-size: 0.95rem;
}

/* ---------- Section titles ---------- */
.section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-subtle);
    margin: var(--space-10) 0 var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.section-title:first-of-type { margin-top: 0; }
.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ---------- Grid ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

/* ---------- Cards ---------- */
.card {
    --accent: var(--accent-portfolio);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    cursor: pointer;
    overflow: hidden;
    transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, var(--accent), transparent 60%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--t-base);
    pointer-events: none;
}
.card:hover {
    transform: translateY(-2px);
    border-color: transparent;
    box-shadow: var(--shadow-md);
    background: var(--surface-hover);
}
.card:hover::before { opacity: 1; }

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
}
.card-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--t-fast);
}
.card:hover .card-icon {
    background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.card-title {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-badge-slot {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 22px;
}
.card-description {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 2px;
}

/* Page cards (children) */
.card.page-card {
    background: var(--surface-2);
    padding: var(--space-3) var(--space-4);
}
.card.page-card .card-icon { width: 32px; height: 32px; font-size: 1rem; }
.card.page-card .card-title { font-size: 0.88rem; }
.card.page-card .card-description { font-size: 0.76rem; }
.card.page-card[data-depth="1"] { margin-left: var(--space-6); }
.card.page-card[data-depth="2"] { margin-left: var(--space-12); }
.card.page-card[data-depth="3"] { margin-left: 72px; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
    border: 1px solid transparent;
}
.badge-portfolio {
    color: var(--accent-portfolio);
    background: color-mix(in srgb, var(--accent-portfolio) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent-portfolio) 30%, transparent);
}
.badge-projet {
    color: var(--accent-projet);
    background: color-mix(in srgb, var(--accent-projet) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent-projet) 30%, transparent);
}
.badge-admin {
    color: var(--accent-admin);
    background: color-mix(in srgb, var(--accent-admin) 12%, transparent);
    border-color: color-mix(in srgb, var(--accent-admin) 30%, transparent);
}

/* ---------- Hierarchy list (Portfolio view) ---------- */
.hl-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: var(--space-4);
}
.hl-block { border-bottom: 1px solid var(--border); }
.hl-block:last-child { border-bottom: none; }

.hl-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 12px var(--space-4);
    transition: background var(--t-fast);
    color: var(--text);
}
.hl-row:hover { background: var(--surface-hover); }

.hl-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 500;
    flex-shrink: 0;
    transition: color var(--t-fast);
}
.hl-link:hover { color: var(--accent); }

.hl-arrow {
    color: var(--text-faint);
    font-family: var(--font-mono);
    flex-shrink: 0;
}
.hl-icon { font-size: 1.05rem; flex-shrink: 0; }
.hl-name { white-space: nowrap; font-weight: 500; }
.hl-desc {
    color: var(--text-subtle);
    font-size: 0.8rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hl-expand {
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    transition: all var(--t-fast);
    flex-shrink: 0;
}
.hl-expand:hover,
.hl-block.open .hl-expand {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-bg);
}

.hl-children { display: none; background: var(--surface-2); }
.hl-block.open .hl-children { display: block; }
.hl-row.hl-child {
    padding-left: var(--space-8);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

/* Site row (header of hierarchy) */
.hl-row.hl-site {
    background: linear-gradient(135deg, var(--surface-2), var(--surface));
    border-bottom: 1px solid var(--border-strong);
    padding: var(--space-4);
    position: relative;
}
.hl-row.hl-site::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
}
.hl-row.hl-site .hl-icon-site {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-bg);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    border-radius: var(--radius-md);
    font-size: 1.2rem;
    flex-shrink: 0;
}
.hl-row.hl-site .hl-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.hl-version {
    margin-left: auto;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    flex-shrink: 0;
}

/* ---------- Footer ---------- */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: var(--space-4) var(--space-6);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    color: var(--text-subtle);
    font-size: 0.78rem;
    z-index: 40;
}
footer span { color: var(--text-muted); }
footer span:first-child { color: var(--accent); font-weight: 600; }

/* ---------- Forms (used by login etc.) ---------- */
.input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    outline: none;
}
.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.input::placeholder { color: var(--text-faint); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--t-fast);
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, black); }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    header {
        padding: var(--space-3) var(--space-4);
        gap: var(--space-2);
        align-items: center;
    }
    .header-title {
        min-width: 0;
        flex: 1 1 auto;
    }
    .header-title h1 {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .header-title p { font-size: 0.7rem; display: none; }
    .header-actions { gap: 6px; }
    .session-user {
        max-width: 110px;
        padding: 6px 10px;
        font-size: 0.78rem;
    }
    .session-logout, .session-login { padding: 6px 10px; }
    .session-login-text { display: none; }
    .theme-toggle { width: 36px; height: 36px; }
    main { padding: var(--space-6) var(--space-4) 100px; }
    .grid { grid-template-columns: 1fr; gap: var(--space-3); }
    .dashboard-tab { padding: 10px 14px; font-size: 0.82rem; }
    .card.page-card[data-depth="1"] { margin-left: var(--space-3); }
    .card.page-card[data-depth="2"] { margin-left: var(--space-6); }
    .card.page-card[data-depth="3"] { margin-left: 36px; }
    .hl-row { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
    .hl-desc { flex-basis: 100%; padding-left: 26px; font-size: 0.74rem; }
}

@media (max-width: 768px) {
    .server-icon { width: 46px; height: 46px; }
    .server-icon img { width: 32px; height: 32px; }
    .adm-brand img { width: 46px; height: 46px; padding: 6px; }
}

@media (max-width: 400px) {
    .server-icon { width: 42px; height: 42px; }
    .server-icon img { width: 28px; height: 28px; }
    .adm-brand img { width: 42px; height: 42px; padding: 5px; }
    .header-title h1 { font-size: 0.88rem; }
    .session-user { display: none; }
    .session-info { gap: 4px; }
}

@media (min-width: 1025px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

/* Hide elements helper */
.hidden { display: none !important; }

/* Access denied banner */
.access-denied-banner {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: var(--space-6);
    text-align: center;
    font-size: 0.88rem;
    font-weight: 500;
}
.access-denied-banner a {
    color: var(--danger);
    text-decoration: underline;
    margin-left: var(--space-2);
    font-weight: 600;
}

/* ==========================================================================
   ADMIN — composants partagés (header / footer / user pill / stats)
   ========================================================================== */

.adm-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
}
.adm-header-inner {
    padding: var(--space-4) var(--space-8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}
.adm-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text);
    min-width: 0;
}
.adm-brand img {
    width: 60px;
    height: 60px;
    padding: 0;
    border-radius: var(--radius-lg);
    background: var(--brand-icon-bg);
    border: 1px solid var(--brand-icon-border);
    box-shadow: var(--brand-icon-shadow);
    flex-shrink: 0;
}
.adm-brand h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    line-height: 1.2;
}
.adm-brand p {
    font-size: 0.78rem;
    color: var(--text-subtle);
    margin-top: 2px;
}

.adm-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.user-name {
    white-space: nowrap;
    font-weight: 500;
    color: var(--text);
}
.user-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    border-radius: var(--radius-full);
    transition: all var(--t-fast);
}
.user-logout:hover {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.adm-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6) 90px;
}

.adm-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: var(--space-3) var(--space-4);
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 40;
}
.adm-footer .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--t-fast);
}
.adm-footer .back-link:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    text-align: center;
    transition: border-color var(--t-fast);
}
.stat-card:hover { border-color: var(--border-strong); }
.stat-card .num {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.stat-card .num.ok   { color: var(--success); }
.stat-card .num.warn { color: var(--warning); }
.stat-card .num.err  { color: var(--danger); }
.stat-card .lbl {
    font-size: 0.78rem;
    color: var(--text-subtle);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

/* Filters */
.filter-bar {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}
.filter-btn {
    padding: 7px 14px;
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--t-fast);
    font-family: inherit;
}
.filter-btn:hover { color: var(--text); border-color: var(--border-strong); }
.filter-btn.active {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}

/* Empty state */
.empty-state {
    text-align: center;
    color: var(--text-subtle);
    padding: var(--space-12) var(--space-4);
    font-size: 0.95rem;
}

/* Messages */
.msg {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: var(--space-4);
}
.msg.success {
    background: color-mix(in srgb, var(--success) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
    color: var(--success);
}
.msg.error {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
    color: var(--danger);
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .adm-header-inner { padding: var(--space-3) var(--space-4); gap: var(--space-2); }
    .adm-main { padding: var(--space-6) var(--space-4) 80px; }
    .stat-card { padding: var(--space-4); }
    .stat-card .num { font-size: 1.3rem; }
    .adm-brand h1 { font-size: 0.95rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
    .stat-card { padding: var(--space-3) 6px; }
    .stat-card .num { font-size: 1.05rem; }
    .stat-card .lbl { font-size: 0.62rem; }
}

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


/* ==========================================================================
   STYLES LOCAUX DU SITE
   ========================================================================== */

/* Empêche le zoom double-tap iOS Safari */
html, body { touch-action: manipulation; }

/* Mappage des anciennes variables sur le design system root */
:root {
    --primary: var(--accent);
    --primary-dark: var(--accent-hover);
    --primary-light: var(--accent-bg);
    /* --success, --warning, --danger viennent déjà du root */
    --dark: var(--bg);
    --dark-2: var(--surface);
    --dark-3: var(--surface-2);
    --card-bg: var(--surface);
    --card-border: var(--border);
    /* --text et --text-muted viennent déjà du root */
    --input-bg: var(--surface-2);
    --shadow: var(--shadow-md);
    --radius: var(--radius-xl);
    /* --radius-sm vient du root */
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--dark);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--dark-2);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

/* ============================================================
   HEADER (aligné sur le dashboard)
   ============================================================ */
header {
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    padding: var(--space-4) var(--space-8);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    justify-content: space-between;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.logo-icon {
    width: 60px;
    height: 60px;
    padding: 0;
    border-radius: 12px;
    background: var(--brand-icon-bg);
    border: 1px solid var(--brand-icon-border);
    box-shadow: var(--brand-icon-shadow);
    flex-shrink: 0;
    box-sizing: border-box;
}

.logo strong {
    color: var(--text);
}

@media (max-width: 768px) {
    .logo-icon { width: 46px; height: 46px; padding: 6px; }
}

@media (max-width: 480px) {
    .logo-icon { width: 42px; height: 42px; padding: 5px; }
    .logo { font-size: 1rem; }
}

.header-stats {
    display: flex;
    gap: 2rem;
    flex: 1;
    font-size: 0.85rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ============================================================
   MAIN
   ============================================================ */
main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    flex: 1;
    min-width: 200px;
}

.search-icon {
    color: var(--text-muted);
    font-size: 1rem;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    outline: none;
    font-size: 0.9rem;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================================
   GRID & CARDS
   ============================================================ */
#sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.site-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.site-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(108, 99, 255, 0.2);
}

.site-header {
    padding: 1.2rem;
    border-bottom: 1px solid var(--card-border);
    background: rgba(0, 0, 0, 0.2);
}

.site-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.site-icon {
    font-size: 1.5rem;
}

.site-name {
    font-size: 1.1rem;
    font-weight: 700;
    flex: 1;
}

.site-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.7rem;
    background: var(--primary-light);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}

.site-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
    margin-top: 0.5rem;
}

.site-badges {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    background: rgba(108, 99, 255, 0.2);
    border-radius: 4px;
    color: var(--text-muted);
}

.site-content {
    padding: 1.2rem;
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
}

.site-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.section-title:first-child {
    margin-top: 0;
}

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 1rem;
    padding: 0 0 0.75rem 0;
}

.tab-btn {
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    font-weight: 600;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================================
   PAGES LIST
   ============================================================ */
.pages-by-category {
    margin-bottom: 1rem;
}

.category-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    margin-top: 0.75rem;
}

.category-name:first-child {
    margin-top: 0;
}

.page-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.page-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--input-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    transition: var(--transition);
    cursor: pointer;
    font-size: 0.85rem;
}

.page-item:hover {
    border-color: var(--primary);
    background: rgba(108, 99, 255, 0.1);
}

.page-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.page-info {
    flex: 1;
    min-width: 0;
}

.page-name {
    font-weight: 600;
    color: var(--text);
}

.page-url {
    font-size: 0.7rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-status {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: auto;
    white-space: nowrap;
}

.page-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 0.3rem;
    flex-shrink: 0;
}

.page-status-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.dot-online {
    background: var(--success);
}

.dot-dev {
    background: var(--warning);
}

.dot-offline {
    background: var(--danger);
}

/* ============================================================
   VERSIONS LIST
   ============================================================ */
.versions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.version-item {
    padding: 0.75rem;
    background: var(--input-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
}

.version-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    justify-content: space-between;
}

.version-tag {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.85rem;
}

.version-date {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.version-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.changelog {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 4px;
    max-height: 100px;
    overflow-y: auto;
}

.changelog li {
    margin-left: 1.2rem;
    margin-top: 0.25rem;
}

/* ============================================================
   TASKS
   ============================================================ */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.85rem;
    background: var(--input-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    transition: var(--transition);
}

.task-item:hover {
    border-color: var(--primary);
}

.task-item.done {
    opacity: 0.5;
}

.task-item.done .task-text {
    text-decoration: line-through;
}

.task-check {
    width: 18px;
    height: 18px;
    border: 2px solid var(--card-border);
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.task-check:hover {
    border-color: var(--success);
}

.task-item.done .task-check {
    background: var(--success);
    border-color: var(--success);
}

.task-item.done .task-check::after {
    content: '✓';
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
}

.task-text {
    flex: 1;
    font-size: 0.84rem;
}

.priority-badge {
    font-size: 0.68rem;
    padding: 0.12rem 0.45rem;
    border-radius: 50px;
    font-weight: 600;
    white-space: nowrap;
}

.priority-high {
    background: rgba(230, 57, 70, 0.2);
    color: var(--danger);
}

.priority-medium {
    background: rgba(244, 162, 97, 0.2);
    color: var(--warning);
}

.priority-low {
    background: rgba(76, 201, 160, 0.2);
    color: var(--success);
}

.btn-tiny {
    padding: 0.25rem 0.5rem;
    background: rgba(230, 57, 70, 0.2);
    border: none;
    border-radius: 4px;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.75rem;
    transition: var(--transition);
}

.btn-tiny:hover {
    background: var(--danger);
    color: white;
}

/* ============================================================
   ADD FORM
   ============================================================ */
.btn-add-toggle {
    padding: 0.5rem 0.75rem;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    color: var(--primary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
    width: 100%;
    margin-top: 0.5rem;
}

.btn-add-toggle:hover {
    background: var(--primary);
    color: white;
}

.add-form {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    border: 1px solid var(--card-border);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 0.5rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.changelog-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.changelog-input input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--dark);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.85rem;
}

.changelog-input input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================================
   SITE FOOTER
   ============================================================ */
.site-footer {
    padding: 1rem;
    border-top: 1px solid var(--card-border);
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
}

.btn-site-action {
    flex: 1;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-site-action:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-site-action.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-sm {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
}

.btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-add-main {
    padding: 0.6rem 1.2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-add-main:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    transition: var(--transition);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Note explicative dans un modal (ex: "valider crée une version") */
.modal-hint {
    margin-top: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.25);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.5;
}

/* ============================================================
   TOAST
   ============================================================ */
#toast {
    display: none;
    position: fixed;
    bottom: 4.2rem;
    right: 1rem;
    padding: 0.7rem 1.1rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    z-index: 2000;
    max-width: 300px;
}
#toast.show {
    display: block;
    animation: slideIn 0.25s ease;
}

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.dashboard-empty {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.icon-big {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.dashboard-empty h2 {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.dashboard-empty p {
    margin-bottom: 1.5rem;
}

.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    #sites-grid {
        grid-template-columns: 1fr;
    }

    .header-inner {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .header-stats {
        width: 100%;
        gap: 1rem;
    }

    .toolbar {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        width: 95%;
        max-height: 95vh;
    }

    #toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        max-width: none;
    }
}

/* Reserve space for fixed Dashboard footer */
body { padding-bottom: 3rem; }

/* RESPONSIVE — fine-tuning small screens */
@media (max-width: 480px) {
    .header-inner { padding: 0.5rem 0.8rem; }
    .logo span { font-size: 0.95rem; }
    .toolbar { padding: 0.5rem; }
    .site-card { padding: 0.8rem; }
    .site-badges { flex-wrap: wrap; gap: 0.3rem; }
    .modal-body { padding: 1rem; max-height: 70vh; overflow-y: auto; }
    .filter-btn { font-size: 0.75rem; padding: 0.35rem 0.6rem; }
}

/* ============================================================
   HEADER ARRANGEMENT (revised)
   ============================================================ */
.header-stats { justify-content: flex-end; }
.stat-link {
    text-decoration: none; color: inherit; cursor: pointer;
    display: flex; flex-direction: column; gap: 0.2rem;
    padding: 0.2rem 0.5rem; border-radius: 6px; transition: background 0.15s;
}
.stat-link:hover { background: rgba(108,99,255,0.08); }
.stat-link .stat-value { color: var(--primary); }

.header-actions {
    display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap;
}
.user-pill {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.3rem 0.5rem 0.3rem 0.75rem;
    background: rgba(108,99,255,0.08);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.user-name { white-space: nowrap; }
.user-logout {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.user-logout:hover { color: #e63946; border-color: #e63946; }

/* ============================================================
   DONE TASKS DROPDOWN
   ============================================================ */
.done-tasks-toggle {
    margin-top: 0.8rem;
    border-top: 1px dashed var(--card-border);
    padding-top: 0.6rem;
}
.done-tasks-toggle summary {
    cursor: pointer; color: var(--text-muted); font-size: 0.85rem;
    padding: 0.3rem 0.4rem; border-radius: 4px;
    list-style: none; user-select: none;
}
.done-tasks-toggle summary::-webkit-details-marker { display: none; }
.done-tasks-toggle summary:hover { color: var(--primary); }
.done-tasks-toggle[open] summary { color: var(--primary); }

/* ============================================================
   RESPONSIVE — improved
   ============================================================ */
@media (max-width: 768px) {
    .header-stats { width: 100%; justify-content: space-around; gap: 0.5rem; order: 3; }
    .header-stats .stat, .header-stats .stat-link { padding: 0.2rem 0.3rem; }
    .header-stats .stat-value { font-size: 1.1rem; }
    .header-actions { flex-wrap: wrap; gap: 0.4rem; }
    .toolbar { gap: 0.4rem; }
    .toolbar .search-box { flex: 1 1 100%; }
    .toolbar .filter-btn { flex: 1 1 calc(25% - 0.4rem); padding: 0.4rem 0.4rem; font-size: 0.8rem; }

    /* Items page : layout vertical comme les versions */
    .page-item {
        display: grid;
        grid-template-columns: auto 1fr auto auto;
        grid-template-areas:
            "icon name edit del"
            "info info info info"
            "status status status status";
        gap: 0.3rem 0.5rem;
        align-items: center;
    }
    .page-item .page-icon { grid-area: icon; }
    .page-item .page-name { grid-area: name; font-weight: 600; }
    .page-item .page-info { grid-area: info; display: contents; }
    .page-item .page-info .page-name { grid-area: name; }
    .page-item .page-info > *:not(.page-name) { grid-area: info; color: var(--text-muted); font-size: 0.8rem; }
    .page-item .page-status { grid-area: status; justify-self: start; }
    .page-item .btn-tiny:nth-of-type(1) { grid-area: edit; }
    .page-item .btn-tiny:nth-of-type(2) { grid-area: del; }

    /* Items task : permettre wrap, plus de place au texte */
    .task-item { flex-wrap: wrap; gap: 0.4rem; }
    .task-item .task-text { flex: 1 1 100%; order: 2; }
    .task-item .task-check { order: 1; }
    .task-item .priority-badge { order: 3; }
    .task-item .btn-tiny { order: 4; margin-left: auto; }
}

/* ============================================================
   PAGE ITEM — new vertical layout (head row + body row)
   ============================================================ */
.page-item {
    display: block !important;
    padding: 0.55rem 0.75rem;
}
.page-item .page-head {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.page-item .page-head .page-name {
    flex: 1; min-width: 0; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.page-item .page-body {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding-left: 1.7rem; /* aligned under text after icon */
}
.page-item .page-url { word-break: break-all; }
.page-item .page-status { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.2rem; }
.page-item .page-desc { margin-top: 0.2rem; }

/* ============================================================
   FINAL RESPONSIVE OVERRIDES
   ============================================================ */
@media (max-width: 768px) {
    /* Header: logo + stats on row 1, actions on row 2 */
    .header-inner { flex-wrap: wrap; padding: 0.7rem 1rem; gap: 0.7rem; }
    .logo { flex: 0 1 auto; font-size: 1.05rem; }
    .header-stats {
        flex: 1 1 auto !important; width: auto !important;
        justify-content: flex-end !important;
        gap: 0.8rem; font-size: 0.7rem;
        order: 0 !important;
    }
    .header-stats .stat, .header-stats .stat-link { padding: 0; }
    .header-stats .stat-value { font-size: 1rem; }
    .header-stats .stat-label { font-size: 0.65rem; }
    .header-actions { flex: 1 1 100%; justify-content: space-between; gap: 0.4rem; }

    /* Toolbar: search row 1, filters row 2 inline */
    .toolbar { flex-direction: row !important; flex-wrap: wrap; gap: 0.4rem; }
    .toolbar .search-box { flex: 1 1 100%; min-width: 0; }
    .toolbar .filter-btn {
        flex: 1 1 calc(25% - 0.4rem);
        padding: 0.4rem 0.4rem;
        font-size: 0.78rem;
    }
}

/* ============================================================
   TASK ITEM — new vertical layout (head + body)
   ============================================================ */
.task-item {
    display: block !important;
    padding: 0.55rem 0.75rem;
    background: var(--input-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    margin-bottom: 0.4rem;
}
.task-item .task-head {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.task-item .task-head .task-check { flex: 0 0 auto; }
.task-item .task-head .priority-badge { flex: 0 0 auto; }
.task-item .task-head .task-edit { margin-left: auto; }
.task-item .task-body {
    font-size: 0.88rem;
    word-break: break-word; line-height: 1.4;
    color: var(--text);
    padding-left: 1.6rem;
}
.task-item.done .task-body { text-decoration: line-through; opacity: 0.7; }

/* ============================================================
   ITEM ACTIONS — edit + delete groupés à droite (style identique)
   ============================================================ */
.item-actions {
    margin-left: auto;
    display: inline-flex;
    gap: 0.25rem;
    flex: 0 0 auto;
}
.item-actions .btn-tiny {
    min-width: 1.8rem;
    text-align: center;
}
/* Override neutralise l'ancienne règle .task-edit */
.task-item .task-head .task-edit { margin-left: 0 !important; }

/* ============================================================
   FIX MOBILE — ne pas réordonner les enfants de .task-head
   (annule des règles antérieures qui mettaient item-actions à gauche)
   ============================================================ */
@media (max-width: 768px) {
    .task-item .task-head .task-check     { order: 0 !important; }
    .task-item .task-head .priority-badge { order: 0 !important; }
    .task-item .task-head .item-actions   { order: 99 !important; margin-left: auto !important; }
    /* Les boutons internes au .item-actions héritent de leur ordre source */
    .task-item .task-head .item-actions .btn-tiny { order: 0 !important; margin-left: 0 !important; }
}

/* ============================================================
   IOS-STYLE SWITCH — Affiché / Caché
   ============================================================ */
.form-group-switch {
    display: flex !important;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
}

.ios-switch {
    position: relative;
    display: inline-block;
    cursor: pointer;
    user-select: none;
}
.ios-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}
.ios-track {
    position: relative;
    display: flex;
    align-items: center;
    width: 160px;
    height: 36px;
    border-radius: 999px;
    background: #21262d;
    border: 1px solid #30363d;
    overflow: hidden;
    transition: background 0.3s, border-color 0.3s;
}
.ios-thumb {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc(50% - 3px);
    border-radius: 999px;
    background: linear-gradient(135deg, #e63946, #f0883e);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    z-index: 0;
}
.ios-switch input:checked ~ .ios-track .ios-thumb {
    transform: translateX(0);
    background: linear-gradient(135deg, #2d8a4a, #3fb950);
    box-shadow: 0 2px 6px rgba(63,185,80,0.35);
}
.ios-label {
    flex: 1;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #6e7681;
    z-index: 1;
    position: relative;
    transition: color 0.25s;
    pointer-events: none;
}
/* Affiché actif (input checked) -> texte blanc à gauche */
.ios-switch input:checked ~ .ios-track .ios-label-affiche { color: #ffffff; }
.ios-switch input:not(:checked) ~ .ios-track .ios-label-affiche { color: #6e7681; }
/* Caché actif (input non checked) -> texte blanc à droite */
.ios-switch input:not(:checked) ~ .ios-track .ios-label-cache { color: #ffffff; }
.ios-switch input:checked ~ .ios-track .ios-label-cache { color: #6e7681; }

.ios-switch:hover .ios-track { border-color: var(--primary, #6c63ff); }

/* ============================================================
   SITE-CARD MOBILE — minimisée par défaut + bouton "Voir plus"
   ============================================================ */
.site-expand-btn {
    display: none; /* desktop : caché */
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.5rem;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s;
}
.site-expand-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

@media (max-width: 768px) {
    .site-expand-btn { display: block; }
    /* Par défaut sur mobile : tabs + tab-content + footer cachés */
    .site-card:not(.expanded) .site-expandable,
    .site-card:not(.expanded) .site-footer {
        display: none !important;
    }
}

/* ============================================================
   FORM ROW — garder en ligne sur mobile (icon+name, parent+switch)
   ============================================================ */
@media (max-width: 768px) {
    /* Icon+nom : icone fixe étroite + nom flexible */
    .form-row.form-row-keep.form-row-icon {
        grid-template-columns: 70px 1fr !important;
    }
    /* Parent select + switch : select flex, switch garde taille naturelle */
    .form-row.form-row-keep:not(.form-row-icon) {
        grid-template-columns: 1fr auto !important;
        gap: 0.75rem !important;
        align-items: end !important;
    }
    /* Switch plus compact sur mobile */
    .form-row.form-row-keep .ios-track {
        width: 130px;
        height: 32px;
    }
    .form-row.form-row-keep .ios-label {
        font-size: 0.7rem;
        letter-spacing: 0.2px;
    }
    .form-row.form-row-keep .form-group-switch {
        align-items: flex-end;
        justify-content: flex-end;
    }
}
@media (max-width: 380px) {
    .form-row.form-row-keep .ios-track {
        width: 110px;
        height: 30px;
    }
    .form-row.form-row-keep .ios-label { font-size: 0.62rem; }
}

/* ===========================================================================
   SITE CARDS — REFONTE MOBILE (mobile-first redesign)
   Section ajoutée en dernier pour gagner par cascade sur les @media précédents.
   Désactive le hover desktop, remplace le status-pill par dot + border-left,
   compacte le header, rend toute la card cliquable, regroupe les actions.
   =========================================================================== */

/* Chevron visible UNIQUEMENT sur mobile (le bouton "Voir plus" tout en bas
   est conservé pour rétro-compatibilité mais caché par CSS plus haut) */
.site-chevron {
    display: none;
}

@media (max-width: 768px) {

    /* ── Card racine : padding réduit, bordure gauche colorée par statut ── */
    .site-card {
        padding: 0 !important;             /* on gère le padding par section */
        border-radius: 14px;
        border-width: 1px;
        border-left-width: 4px;            /* accent vertical = statut */
        margin-bottom: 0;                  /* le grid gère le gap */
        background: var(--card-bg);
        position: relative;
        transition: border-color 0.15s ease;
    }
    .site-card:hover { transform: none; box-shadow: var(--shadow); }
    .site-card[data-status="active"]      { border-left-color: #3fb950; }
    .site-card[data-status="dev"]         { border-left-color: #f0883e; }
    .site-card[data-status="maintenance"] { border-left-color: #e63946; }
    .site-card[data-status="inactive"]    { border-left-color: #6e7681; }

    /* ── Header dense, cliquable (déplie/replie la card) ── */
    .site-header {
        padding: 0.85rem 0.9rem;
        background: transparent;
        border-bottom: 1px solid transparent;
        cursor: pointer;
        user-select: none;
        -webkit-tap-highlight-color: rgba(108,99,255,0.12);
        transition: background 0.15s ease, border-color 0.15s ease;
    }
    .site-card.expanded .site-header {
        background: rgba(255,255,255,0.02);
        border-bottom-color: var(--card-border);
    }

    /* ── Ligne 1 : icône + nom + status-dot + chevron ── */
    .site-title {
        display: grid;
        grid-template-columns: auto 1fr auto auto;
        align-items: center;
        gap: 0.6rem;
        margin-bottom: 0.5rem;
    }
    .site-title .site-icon {
        font-size: 1.35rem;
        line-height: 1;
    }
    .site-title .site-name {
        font-size: 1rem;
        font-weight: 700;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }

    /* Status pill → réduit à un dot coloré (l'emoji + label masqués
       visuellement, la couleur de l'accent gauche + dot suffisent) */
    .site-title .site-status {
        background: transparent;
        padding: 0;
        font-size: 0;          /* cache le texte */
        color: transparent;
        position: relative;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        flex-shrink: 0;
        box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
    }
    .site-card[data-status="active"]      .site-title .site-status { background: #3fb950; }
    .site-card[data-status="dev"]         .site-title .site-status { background: #f0883e; }
    .site-card[data-status="maintenance"] .site-title .site-status { background: #e63946; }
    .site-card[data-status="inactive"]    .site-title .site-status { background: #6e7681; }

    /* Chevron tappable (44x44 px target) */
    .site-chevron {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        margin: -6px -6px -6px 0;
        background: transparent;
        border: none;
        border-radius: 8px;
        color: var(--text-muted);
        cursor: pointer;
        transition: transform 0.25s ease, color 0.15s ease, background 0.15s ease;
    }
    .site-chevron:hover { color: var(--primary); background: rgba(108,99,255,0.1); }
    .site-card.expanded .site-chevron { transform: rotate(180deg); color: var(--primary); }

    /* ── Ligne 2 : URL tronquée 1 ligne (1 seul appel visuel) ── */
    .site-url {
        font-size: 0.74rem;
        color: var(--text-muted);
        word-break: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-top: 0;
        margin-bottom: 0.5rem;
        opacity: 0.8;
    }

    /* ── Ligne 3 : métriques compactes en pastilles fines ── */
    .site-badges {
        display: flex;
        gap: 0.3rem;
        margin-top: 0;
        flex-wrap: wrap;
    }
    .site-badges .badge {
        font-size: 0.66rem;
        padding: 0.18rem 0.5rem;
        font-weight: 600;
        border-radius: 999px;
        background: rgba(255,255,255,0.05);
        color: var(--text-muted);
        line-height: 1.4;
        border: 1px solid transparent;
    }
    .site-badges .badge-version {
        background: rgba(108,99,255,0.12);
        color: var(--primary);
    }
    .site-badges .badge-tasks.has-pending {
        background: rgba(240, 136, 62, 0.15);
        color: #f0883e;
        border-color: rgba(240, 136, 62, 0.3);
    }

    /* ── Contenu : caché par défaut, animation smooth via grid ── */
    .site-card .site-content {
        padding: 0;
        max-height: none;
        overflow: visible;
        display: grid;
        grid-template-rows: 0fr;
        transition: grid-template-rows 0.3s ease;
    }
    .site-card.expanded .site-content {
        grid-template-rows: 1fr;
    }
    .site-card .site-content > * {
        overflow: hidden;
        min-height: 0;
    }
    /* Reset les overrides du contenu interne après animation */
    .site-card.expanded .site-content > * {
        overflow: visible;
    }

    /* Inner padding seulement quand déplié */
    .site-card.expanded .site-content {
        padding: 0;
    }
    .site-card.expanded .site-desc,
    .site-card.expanded .site-expandable {
        padding: 0 0.9rem;
    }
    .site-card.expanded .site-desc {
        padding-top: 0.85rem;
        margin-bottom: 0.65rem;
        font-size: 0.85rem;
    }
    .site-card.expanded .site-expandable {
        padding-bottom: 0.85rem;
    }

    /* Masque le vieux bouton "Voir plus" en bas — remplacé par le chevron */
    .site-card .site-expand-btn { display: none !important; }

    /* ── Footer actions : pastilles icônes (gain de place) ── */
    .site-footer {
        display: flex;
        justify-content: flex-end;
        gap: 0.4rem;
        padding: 0.65rem 0.9rem;
        border-top: 1px solid var(--card-border);
        background: rgba(0,0,0,0.15);
    }
    .site-footer .btn-site-action {
        flex: 0 0 auto;
        width: 40px;
        height: 40px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        background: rgba(255,255,255,0.04);
        border: 1px solid var(--card-border);
        color: var(--text);
        transition: all 0.15s ease;
    }
    .site-footer .btn-site-action .btn-icon {
        font-size: 1.05rem;
        line-height: 1;
    }
    /* Sur mobile : on cache le label texte, seul l'emoji reste */
    .site-footer .btn-site-action .btn-label {
        display: none;
    }
    .site-footer .btn-site-action:hover {
        background: rgba(108,99,255,0.12);
        border-color: var(--primary);
    }
    .site-footer .btn-site-action.danger {
        border-color: rgba(230, 57, 70, 0.3);
    }
    .site-footer .btn-site-action.danger:hover {
        background: rgba(230, 57, 70, 0.15);
        border-color: #e63946;
    }

    /* ── État replié = juste header visible, footer caché ── */
    .site-card:not(.expanded) .site-footer {
        display: none !important;
    }

    /* Grid gap réduit pour densifier */
    #sites-grid { gap: 0.7rem; }
}

@media (max-width: 380px) {
    .site-card { border-left-width: 3px; }
    .site-header { padding: 0.75rem 0.75rem; }
    .site-title .site-name { font-size: 0.95rem; }
    .site-badges .badge { font-size: 0.62rem; padding: 0.15rem 0.45rem; }
    .site-footer { padding: 0.5rem 0.75rem; gap: 0.3rem; }
    .site-footer .btn-site-action { min-width: 36px; min-height: 36px; max-width: 36px; }
}

/* ============================================================================
   ALIGNEMENT SUR LE GESTIONNAIRE D'UTILISATEURS
   Header avatar+menu (mobile) · Stats cliquables · Recherche unifiée
   ============================================================================ */

/* ---------- STATS CLIQUABLES (= filtres) ---------- */
.st-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3, 12px);
    margin-bottom: var(--space-5, 20px);
}
.st-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-4, 16px) var(--space-3, 12px);
    background: var(--card-bg, var(--surface));
    border: 1px solid var(--card-border, var(--border));
    border-radius: var(--radius-lg, 12px);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.st-stat-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.st-stat-card.active {
    border-color: var(--primary);
    background: var(--primary-light, var(--accent-bg));
}
.st-stat-num {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
    letter-spacing: -0.02em;
}
.st-stat-num.ok   { color: var(--success); }
.st-stat-num.warn { color: var(--warning); }
.st-stat-num.err  { color: var(--danger); }
.st-stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.st-stat-card.active .st-stat-label { color: var(--primary); }

/* ---------- RECHERCHE UNIFIÉE ---------- */
.st-toolbar { margin-bottom: var(--space-6, 24px); }
.st-search {
    position: relative;
    display: flex;
    align-items: center;
}
.st-search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}
.st-search-input {
    width: 100%;
    padding: 11px 36px 11px 38px;
    background: var(--input-bg, var(--surface));
    border: 1px solid var(--card-border, var(--border));
    border-radius: var(--radius-md, 8px);
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.st-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light, var(--accent-bg));
}
.st-search-input::placeholder { color: var(--text-muted); }
.st-search-clear {
    position: absolute;
    right: 8px;
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--input-bg, var(--surface-2));
    border: 1px solid var(--card-border, var(--border));
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.15s ease;
}
.st-search-clear:hover { color: var(--text); border-color: var(--primary); }

/* ---------- HEADER : menu utilisateur compact (avatar + dropdown) ---------- */
.st-usermenu { display: none; position: relative; }   /* mobile only */
.st-avatar {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px 4px 4px;
    background: var(--card-bg, var(--surface));
    border: 1px solid var(--card-border, var(--border));
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.st-avatar:hover, .st-avatar.open {
    border-color: var(--primary);
    background: var(--primary-light, var(--accent-bg));
}
.st-avatar-initials {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.st-avatar-caret { color: var(--text-muted); transition: transform 0.2s ease; }
.st-avatar.open .st-avatar-caret { transform: rotate(180deg); color: var(--primary); }

.st-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--card-bg, var(--surface));
    border: 1px solid var(--border-strong, var(--card-border));
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.45);
    padding: 6px;
    z-index: 200;
    animation: st-menu-in 0.16s ease;
    transform-origin: top right;
}
@keyframes st-menu-in {
    from { opacity: 0; transform: scale(0.96) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.st-menu-head {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 10px 12px;
    border-bottom: 1px solid var(--card-border, var(--border));
    margin-bottom: 6px;
}
.st-menu-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem; font-weight: 700;
    flex-shrink: 0;
}
.st-menu-id { display: flex; flex-direction: column; min-width: 0; }
.st-menu-name {
    font-weight: 600; color: var(--text); font-size: 0.9rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.st-menu-role { font-size: 0.72rem; color: var(--text-muted); }
.st-menu-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent; border: none;
    border-radius: var(--radius-md, 8px);
    color: var(--text);
    font-size: 0.88rem; font-weight: 500; font-family: inherit;
    text-align: left; cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.st-menu-item svg { flex-shrink: 0; color: var(--text-muted); }
.st-menu-item:hover { background: var(--surface-hover, rgba(108,99,255,0.08)); }
.st-menu-item:hover svg { color: var(--primary); }
.st-menu-danger:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.st-menu-danger:hover svg { color: var(--danger); }
.st-menu-item .icon-sun { display: none; }
:root[data-theme="light"] .st-menu-item .icon-moon { display: none; }
:root[data-theme="light"] .st-menu-item .icon-sun  { display: block; }

/* ---------- BASCULE DESKTOP / MOBILE ---------- */
@media (max-width: 768px) {
    .st-theme-desktop,
    .st-pill-desktop { display: none !important; }
    .st-usermenu { display: block; }

    .header-stats { display: none; }     /* les anciennes mini-stats du header */

    .st-stats { grid-template-columns: repeat(2, 1fr); gap: var(--space-2, 8px); }
    .st-stat-num { font-size: 1.35rem; }
}

@media (max-width: 380px) {
    .st-stat-card { padding: var(--space-3, 12px) var(--space-2, 8px); }
    .st-stat-num { font-size: 1.2rem; }
    .st-stat-label { font-size: 0.66rem; }
}
/* ════════════════════════════════════════════════════════════════════
   PHASE 4 — Gating UI : masquer les actions sans permission
   Les boutons .act-* sont cachés par défaut ; révélés si <body> porte la
   classe .can-* correspondante (posée par applyPermsToBody()).
   ════════════════════════════════════════════════════════════════════ */
.act-site-create,
.act-site-edit,
.act-page-create,
.act-page-edit,
.act-version-create,
.act-version-edit,
.act-task-create,
.act-task-edit { display: none !important; }

body.can-site-create    .act-site-create,
body.can-site-edit      .act-site-edit,
body.can-page-create    .act-page-create,
body.can-page-edit      .act-page-edit,
body.can-version-create .act-version-create,
body.can-version-edit   .act-version-edit,
body.can-task-create    .act-task-create,
body.can-task-edit      .act-task-edit { display: inline-flex !important; }
