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

/* ════════════════════════════════════════════════════════════════
   VARIABLES DE THÈME
════════════════════════════════════════════════════════════════ */
html {
    /* Fond */
    --bg-body:     #0f1e30;
    --bg-grad-1:   rgba(39,69,102,0.60);
    --bg-grad-2:   rgba(20,50,80,0.50);
    /* Surfaces verre */
    --sf-1:        rgba(255,255,255,0.06);
    --sf-2:        rgba(255,255,255,0.10);
    --sf-3:        rgba(255,255,255,0.08);
    --sf-sub:      rgba(255,255,255,0.04);
    --sf-accent:   rgba(39,69,102,0.50);
    --sf-accent-h: rgba(39,69,102,0.85);
    --sf-panel:    #1a1e2e;
    /* Bordures */
    --bd:          rgba(255,255,255,0.09);
    --bd-2:        rgba(255,255,255,0.15);
    --bd-hover:    rgba(255,255,255,0.18);
    --bd-accent:   rgba(59,130,196,0.35);
    --bd-accent-h: rgba(59,130,196,0.70);
    --bd-focus:    rgba(255,255,255,0.40);
    /* Texte */
    --tx-1:        #ffffff;
    --tx-2:        rgba(255,255,255,0.75);
    --tx-3:        rgba(255,255,255,0.55);
    --tx-4:        rgba(255,255,255,0.40);
    --tx-5:        rgba(255,255,255,0.25);
    --tx-accent:   #93c5fd;
    /* Scrollbar */
    --sb-thumb:    rgba(255,255,255,.18);
    --sb-thumb-h:  rgba(255,255,255,.35);
}
html[data-theme="light"] {
    --bg-body:     #eef3f9;
    --bg-grad-1:   rgba(147,197,253,0.45);
    --bg-grad-2:   rgba(96,165,250,0.30);
    --sf-1:        rgba(255,255,255,0.68);
    --sf-2:        rgba(255,255,255,0.85);
    --sf-3:        rgba(255,255,255,0.75);
    --sf-sub:      rgba(15,25,45,0.04);
    --sf-accent:   rgba(37,99,235,0.08);
    --sf-accent-h: rgba(37,99,235,0.15);
    --sf-panel:    #ffffff;
    --bd:          rgba(15,30,50,0.10);
    --bd-2:        rgba(15,30,50,0.18);
    --bd-hover:    rgba(15,30,50,0.22);
    --bd-accent:   rgba(37,99,235,0.22);
    --bd-accent-h: rgba(37,99,235,0.45);
    --bd-focus:    rgba(37,99,235,0.55);
    --tx-1:        #0f1e30;
    --tx-2:        rgba(15,25,45,0.80);
    --tx-3:        rgba(15,25,45,0.55);
    --tx-4:        rgba(15,25,45,0.42);
    --tx-5:        rgba(15,25,45,0.28);
    --tx-accent:   #1d4ed8;
    --sb-thumb:    rgba(15,30,50,.18);
    --sb-thumb-h:  rgba(15,30,50,.32);
}

/* ── Transition douce lors du changement de thème ─────────────── */
body,
.app-tile, .login-card, .office-dropdown-panel,
.customize-bar, .dash-logout, .dash-admin-link,
.dash-settings-link, .btn-customize, .hidden-tray-item,
.tile-action-btn, .field input, .theme-toggle {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

/* ════════════════════════════════════════════════════════════════
   UTILITAIRES COULEUR — thème-aware via variables CSS
   Utilisés pour remplacer les styles inline hardcodés
════════════════════════════════════════════════════════════════ */
.c-1  { color: var(--tx-1) !important; }
.c-2  { color: var(--tx-2) !important; }
.c-3  { color: var(--tx-3) !important; }
.c-4  { color: var(--tx-4) !important; }
.c-5  { color: var(--tx-5) !important; }
.c-accent { color: var(--tx-accent) !important; }
.c-ok     { color: #4caf82 !important; }
.c-warn   { color: #f59e0b !important; }
.c-danger { color: #ef4444 !important; }
.bg-sub   { background: var(--sf-sub) !important; }
.bg-1     { background: var(--sf-1) !important; }
.bd-top   { border-top: 1px solid var(--bd) !important; }
.bd-b     { border-bottom: 1px solid var(--bd) !important; }

/* ════════════════════════════════════════════════════════════════
   CLASSES DE TUILES — éléments communs, thème-aware
   (remplacent les styles inline hardcodés dans les tile.php)
════════════════════════════════════════════════════════════════ */

/* Lien de config commun à toutes les tuiles */
.tile-cfg-link {
    position: relative; z-index: 3;
    text-decoration: none; flex-shrink: 0;
    display: inline-flex; align-items: center; gap: 4px; font-size: 11px;
    color: var(--tx-5);
    transition: color .15s;
}
.tile-cfg-link:hover { color: var(--tx-3); }

/* Ligne/carte d'item générique dans une tuile */
.tile-item-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 7px; flex-shrink: 0;
    background: var(--sf-sub); border: 1px solid var(--bd);
    transition: background .15s;
}
.tile-item-row:hover { background: var(--sf-2); }

.tile-item-card {
    display: flex; flex-direction: column; gap: 5px;
    padding: 8px 10px; border-radius: 8px;
    background: var(--sf-sub); border: 1px solid var(--bd);
    transition: background .15s; min-width: 0;
}
.tile-item-card:hover { background: var(--sf-2); }

/* Barre de progression (track) dans les tuiles */
.tile-bar-track {
    background: var(--bd);
    border-radius: 2px; overflow: hidden;
}

/* Tuile infos — état vide */
.tile-infos-empty {
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 10px;
    background: var(--sf-accent);
}
.tile-infos-manage {
    display: inline-block;
    margin-top: 4px; padding: 6px 14px;
    border-radius: 8px; font-size: 12px;
    background: var(--sf-1); border: 1px solid var(--bd);
    color: var(--tx-3); text-decoration: none;
}
.tile-infos-manage:hover { background: var(--sf-2); color: var(--tx-1); }

/* Tuile infos — bouton edit overlay */
.tile-infos-edit {
    position: absolute; top: 10px; right: 10px; z-index: 10;
    background: rgba(0,0,0,.45); backdrop-filter: blur(6px);
    border: 1px solid var(--bd-2); border-radius: 7px;
    padding: 5px 10px; font-size: 11px; color: var(--tx-2);
    text-decoration: none; display: flex; align-items: center; gap: 5px;
}
.tile-infos-edit:hover { color: var(--tx-1); }

/* Tuile livraison — carte */
.livraison-tile-card {
    background: var(--sf-sub);
    border: 1px solid var(--bd);
    border-radius: 16px;
    padding: 20px 24px;
    display: flex; align-items: center;
    justify-content: space-between; gap: 16px;
    margin-top: 24px;
}
.livraison-tile-title { font-weight: 600; font-size: 15px; color: var(--tx-1); margin-bottom: 4px; }
.livraison-tile-sub   { font-size: 13px; color: var(--tx-3); }
.livraison-tile-btn {
    background: #274566; color: #fff;
    text-decoration: none; padding: 8px 16px;
    border-radius: 8px; font-size: 13px; font-weight: 500;
    white-space: nowrap; transition: background .2s;
}
.livraison-tile-btn:hover { background: #1d4ed8; }
html[data-theme="light"] .livraison-tile-btn { background: #1d4ed8; }
html[data-theme="light"] .livraison-tile-btn:hover { background: #1e40af; }

.tile-item-more {
    display: flex; align-items: center; justify-content: center;
    padding: 7px; border-radius: 7px; font-size: 11px; text-decoration: none;
    background: var(--sf-sub); border: 1px solid var(--bd); color: var(--tx-5);
    flex-shrink: 0; transition: background .15s;
}
.tile-item-more:hover { background: var(--sf-1); color: var(--tx-3); }
.tile-item-more--wide { grid-column: 1 / -1; border-radius: 9px; font-size: 12px; padding: 9px; }

.infos-dot {
    width: 7px; height: 7px; border-radius: 50%; cursor: pointer;
    background: var(--tx-5); opacity: .35; transition: opacity .3s, background .3s; display: block;
}
.infos-dot.active { opacity: .95; background: var(--tx-1); }

/* ── Twemoji — sizing global ─────────────────────────────────── */
img.emoji {
    height: 1em !important;
    width: 1em !important;
    vertical-align: -0.15em !important;
    display: inline-block;
}
/* Dans les app-icon : aligner avec les icônes SVG */
.app-icon img.emoji    { width: 22px !important; height: 22px !important; margin: 0 !important; vertical-align: middle !important; }
.app-icon--lg img.emoji{ width: 26px !important; height: 26px !important; margin: 0 !important; vertical-align: middle !important; }

code {
    font-family: 'Consolas', 'SF Mono', monospace;
    font-size: .9em;
    background: var(--sf-3);
    border: 1px solid var(--bd);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--tx-2);
}

body {
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    background: var(--bg-body);
    color: var(--tx-2);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Background décoratif ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, var(--bg-grad-1) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, var(--bg-grad-2) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ════════════════════════════════
   ÉCRAN LOGIN
════════════════════════════════ */
#screen-login {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.login-logo {
    margin-bottom: 32px;
    text-align: center;
}

.login-logo .logo-text {
    font-size: 28px;
    font-weight: 800;
    color: var(--tx-1);
    letter-spacing: 0.12em;
}

.login-logo .logo-sub {
    font-size: 13px;
    color: var(--tx-4);
    letter-spacing: 0.06em;
    margin-top: 4px;
}

.login-card {
    background: var(--sf-1);
    border: 1px solid var(--bd);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 36px 40px;
    width: 100%;
    max-width: 380px;
}

.login-card h2 {
    font-size: 18px;
    color: var(--tx-1);
    font-weight: 600;
    margin-bottom: 6px;
}

.login-card p {
    font-size: 13px;
    color: var(--tx-4);
    margin-bottom: 28px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--tx-3);
    letter-spacing: 0.04em;
}

.field input {
    background: var(--sf-3);
    border: 1px solid var(--bd-2);
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 14px;
    color: var(--tx-1);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    font-family: inherit;
    width: 100%;
}

.field input::placeholder {
    color: var(--tx-5);
}

.field input:focus {
    border-color: var(--bd-focus);
    background: var(--sf-2);
}

.login-btn {
    width: 100%;
    margin-top: 8px;
    background: #274566;
    border: none;
    border-radius: 10px;
    padding: 13px;
    font-size: 15px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    font-family: inherit;
    letter-spacing: 0.02em;
}

.login-btn:hover { background: #1e3654; }
.login-btn:active { transform: scale(0.98); }

/* Toggle « Se souvenir de moi » */
.login-remember {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}
.login-remember-label {
    font-size: 13px;
    color: var(--tx-3);
    cursor: pointer;
    margin: 0;
}
.login-remember-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}
.login-remember-cb {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.login-remember-track {
    position: absolute;
    inset: 0;
    background: var(--bd-2);
    border-radius: 22px;
    transition: background .2s;
    display: block;
}
.login-remember-track.is-on { background: #274566; }
.login-remember-thumb {
    position: absolute;
    left: 3px;
    top: 3px;
    width: 16px;
    height: 16px;
    background: var(--tx-2);
    border-radius: 50%;
    transition: transform .2s;
    pointer-events: none;
}
.login-remember-thumb.is-on {
    transform: translateX(18px);
    background: white;
}

/* ════════════════════════════════
   ÉCRAN DASHBOARD
════════════════════════════════ */
#screen-dashboard {
    display: flex;
    position: relative;
    z-index: 1;
    flex: 1;
    flex-direction: column;
}

/* Header */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
    border-bottom: 1px solid var(--bd);
}

.dash-header .logo-text {
    font-size: 18px;
    font-weight: 800;
    color: var(--tx-1);
    letter-spacing: 0.1em;
}

.dash-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dash-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--tx-2);
}

.dash-logout {
    background: var(--sf-3);
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--tx-3);
    cursor: pointer;
    transition: background 0.18s;
    font-family: inherit;
}

.dash-logout:hover {
    background: var(--sf-2);
    color: var(--tx-1);
}

.dash-admin-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--tx-accent);
    text-decoration: none;
    background: var(--sf-accent);
    border: 1px solid var(--bd-accent);
    border-radius: 8px;
    padding: 6px 14px;
    transition: background .15s, border-color .15s, color .15s;
}
.dash-admin-link:hover {
    background: var(--sf-accent-h);
    border-color: var(--bd-accent-h);
    color: var(--tx-1);
}
.dash-admin-link svg { opacity: .8; flex-shrink: 0; }

.dash-settings-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--tx-3);
    text-decoration: none;
    background: var(--sf-sub);
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 6px 14px;
    transition: background .15s, border-color .15s, color .15s;
}
.dash-settings-link:hover {
    background: var(--sf-2);
    border-color: var(--bd-2);
    color: var(--tx-2);
}
.dash-settings-link svg { opacity: .7; flex-shrink: 0; }

/* ── Toggle thème ──────────────────────────────────────────── */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--sf-3);
    border: 1px solid var(--bd);
    border-radius: 8px;
    color: var(--tx-3);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    font-family: inherit;
    padding: 0;
}
.theme-toggle:hover {
    background: var(--sf-2);
    color: var(--tx-1);
}

/* Grille apps */
.dash-body {
    flex: 1;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dash-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 900px;
    width: 100%;
    margin-bottom: 24px;
}

.dash-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--tx-5);
}

/* Bouton "Personnaliser" */
.btn-customize {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--sf-1);
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tx-4);
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    font-family: inherit;
}
.btn-customize:hover {
    background: var(--sf-2);
    color: var(--tx-2);
    border-color: var(--bd-2);
}

/* Bannière mode personnalisation */
.customize-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: var(--sf-accent);
    border-bottom: 1px solid var(--bd-accent);
    padding: 10px 40px;
    font-size: 13px;
    color: var(--tx-2);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
    gap: 16px;
}
.customize-bar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}
.btn-customize-done {
    background: #274566;
    border: 1px solid var(--bd-accent);
    border-radius: 8px;
    padding: 6px 18px;
    font-size: 13px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.18s;
    white-space: nowrap;
}
.btn-customize-done:hover { background: #1e3654; }

/* Mode actif */
body.customizing .customize-bar { display: flex; }
body.customizing #btn-customize  { display: none; }

body.customizing .app-tile {
    cursor: default;
    outline: 1px dashed var(--bd-accent);
    outline-offset: -1px;
}

/* Poignées de drag et bouton resize — invisibles hors mode */
.tile-controls {
    position: absolute;
    top: 8px; left: 8px; right: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 20;
}
body.customizing .tile-controls {
    pointer-events: auto;
    opacity: 1;
}
.tile-controls-btns { display: flex; gap: 4px; }

.drag-handle {
    width: 28px; height: 28px;
    background: rgba(0,0,0,0.3);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.7);
    cursor: grab;
    backdrop-filter: blur(4px);
}
.drag-handle:active { cursor: grabbing; }

.btn-resize {
    width: 28px; height: 28px;
    background: rgba(0,0,0,0.3);
    border: none;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    backdrop-filter: blur(4px);
    padding: 0;
}
.btn-resize:hover { background: rgba(39,69,102,0.7); color: white; }

.btn-hide-tile {
    width: 28px; height: 28px;
    background: rgba(0,0,0,0.3);
    border: none;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    backdrop-filter: blur(4px);
    padding: 0;
}
.btn-hide-tile:hover { background: rgba(180,30,30,0.5); color: white; }

/* ── Bandeau tuiles masquées ─────────────────────────────────── */
#hidden-tray {
    width: 100%;
    max-width: 900px;
    background: var(--sf-sub);
    border: 1px dashed var(--bd);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    flex-direction: column;
    gap: 8px;
}
.hidden-tray-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--tx-5);
}
#hidden-tray-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.hidden-tray-item {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--sf-1);
    border: 1px solid var(--bd);
    border-radius: 9px;
    padding: 6px 12px 6px 8px;
    cursor: pointer;
    color: var(--tx-3);
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.hidden-tray-item:hover { background: var(--sf-2); color: var(--tx-1); }
.tray-icon { display: flex; align-items: center; font-size: 16px; line-height: 1; }
.tray-icon svg { width: 16px; height: 16px; }

/* Afficher expand ou compress selon la taille et les formats disponibles
   Tuiles avec 2×2 : 1×1→expand, 1×2→expand, 2×2→compress
   Tuiles sans 2×2 : 1×1→expand, 1×2→compress                          */
.app-tile[data-size="2x2"] .btn-resize .icon-expand                          { display: none; }
.app-tile:not([data-size="2x2"]) .btn-resize .icon-compress                  { display: none; }
/* Override pour 1×2 sans 2×2 : montrer compress (retour vers 1×1) */
.app-tile[data-size="1x2"]:not([data-sizes*="2x2"]) .btn-resize .icon-compress { display: inline-flex; }
.app-tile[data-size="1x2"]:not([data-sizes*="2x2"]) .btn-resize .icon-expand   { display: none; }

/* États drag & drop */
.tile-ghost {
    opacity: 0 !important;
    border: 2px dashed var(--bd-hover) !important;
    background: var(--sf-sub) !important;
    box-shadow: none !important;
    animation: none !important;
}
/* L'élément source reste dans le flux mais on le cache :
   le setDragImage (clone stylé) le remplace visuellement */
body.is-dragging .tile-chosen {
    opacity: 0 !important;
}
/* Stopper le wiggle pendant le drag */
body.is-dragging .app-tile {
    animation: none !important;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-auto-rows: 200px;
    gap: 16px;
    width: 100%;
    max-width: 900px;
}

/* Scrollbar fine dans les tuiles */
.task-scroll::-webkit-scrollbar { width: 3px; height: 3px; }
.task-scroll::-webkit-scrollbar-track { background: transparent; }
.task-scroll::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 99px; }

.empty-dashboard {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--tx-5);
    font-size: 14px;
    padding: 48px;
    line-height: 1.8;
}

/* Tuile app */
.app-tile {
    background: var(--sf-1);
    border: 1px solid var(--bd);
    border-radius: 16px;
    padding: 24px 20px 12px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.app-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
    background: var(--accent);
    opacity: 0.7;
}

.app-tile:hover {
    background: var(--sf-2);
    border-color: var(--bd-hover);
    transform: translateY(-2px);
}

.app-tile:active {
    transform: translateY(0);
}


.app-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    aspect-ratio: 1;
    border-radius: 12px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
}
.app-icon svg { width: 22px; height: 22px; }
.app-icon--lg svg { width: 26px; height: 26px; }

.app-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.app-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--tx-1);
}

.app-desc {
    font-size: 12px;
    color: var(--tx-4);
    line-height: 1.4;
}

.app-badge {
    align-self: flex-start;
    background: var(--sf-3);
    border: 1px solid var(--bd);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--tx-4);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── Dropdown Office (vue 1×1) ───────────────────────────────── */
.office-dropdown {
    position: relative;
    z-index: 3;
    width: 100%;
}
.office-dropdown-btn {
    width: 100%;
    background: var(--sf-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255%2C255%2C255%2C.4)' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 9px center;
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 7px 28px 7px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tx-3);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background-color .15s, border-color .15s;
}
.office-dropdown-btn:hover {
    background-color: var(--sf-2);
    border-color: var(--bd-hover);
    color: var(--tx-1);
}
.office-dropdown-panel {
    display: none;
    flex-direction: column;
    position: fixed;
    background: var(--sf-panel);
    border: 1px solid var(--bd-2);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    z-index: 9999;
}
.office-dropdown-panel a {
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tx-3);
    text-decoration: none;
    transition: background .1s, color .1s;
}
.office-dropdown-panel a:hover {
    background: var(--sf-3);
    color: var(--tx-1);
}

/* ── Icône du bouton resize selon la taille courante ─────────── */

/* Tuile Office étendue avec sous-apps */
.app-tile.wide {
    grid-column: span 2;
}

.app-tile.big {
    grid-column: span 2;
    grid-row: span 2;
}

.office-apps {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.office-app-btn {
    background: var(--sf-1);
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--tx-3);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
}

.office-app-btn:hover {
    background: var(--sf-2);
    color: var(--tx-1);
}

/* Overlay link — covers entire tile for single-click tiles */
.tile-overlay-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}

/* Raise sub-elements above the overlay link */
.app-icon, .app-info, .app-badge, .office-apps, .no-auth-dot, .ext-dot {
    position: relative;
    z-index: 2;
}

/* Dans les tile-view-*, lever tous les enfants directs au-dessus de l'overlay (z-index:1). */
.tile-view-narrow > *:not(.tile-overlay-link),
.tile-view-wide   > *:not(.tile-overlay-link),
.tile-view-big    > *:not(.tile-overlay-link) {
    position: relative;
    z-index: 2;
}
/* pointer-events:none pour les enfants directs NON interactifs uniquement */
.tile-view-narrow > *:not(.tile-overlay-link):not(a):not(button):not(input):not(select):not(textarea):not(.tile-scroll):not(.task-scroll),
.tile-view-wide   > *:not(.tile-overlay-link):not(a):not(button):not(input):not(select):not(textarea):not(.tile-scroll):not(.task-scroll),
.tile-view-big    > *:not(.tile-overlay-link):not(a):not(button):not(input):not(select):not(textarea):not(.tile-scroll):not(.task-scroll) {
    pointer-events: none;
}
/* Réactiver les pointer-events pour les éléments interactifs et les zones scrollables */
.tile-view-narrow a, .tile-view-narrow button, .tile-view-narrow input, .tile-view-narrow [onclick],
.tile-view-wide   a, .tile-view-wide   button, .tile-view-wide   input, .tile-view-wide   [onclick],
.tile-view-big    a, .tile-view-big    button, .tile-view-big    input, .tile-view-big    [onclick],
.tile-view-narrow .tile-scroll, .tile-view-narrow .task-scroll,
.tile-view-wide   .tile-scroll, .tile-view-wide   .task-scroll,
.tile-view-big    .tile-scroll, .tile-view-big    .task-scroll { pointer-events: auto; }

/* Badge is decorative — let clicks fall through to the overlay link */
.app-badge { pointer-events: none; }

/* ── Responsive tile views ──────────────────────────────────────────────────
   Modules can wrap content in .tile-view-narrow / .tile-view-wide
   to show different layouts depending on the tile's current size.
   Both wrappers fill the tile and handle their own internal layout.
   Usage:
     <div class="tile-view-narrow"> … compact vertical layout … </div>
     <div class="tile-view-wide">   … expanded horizontal layout … </div>
───────────────────────────────────────────────────────────────────────────── */
.tile-view-narrow {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column; gap: 12px;
    position: relative; z-index: 2;
    pointer-events: none;
}
.tile-view-wide {
    flex: 1; min-height: 0;
    display: flex; flex-direction: row; align-items: center; gap: 16px;
    position: relative; z-index: 2;
    pointer-events: none;
}
.tile-view-big {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column; gap: 10px;
    position: relative; z-index: 2;
    pointer-events: none;
}

/* ── Scrollbars uniformes et discrètes dans toutes les tuiles ─────────────── */
.app-tile *::-webkit-scrollbar          { width: 3px; height: 3px; }
.app-tile *::-webkit-scrollbar-track   { background: transparent; }
.app-tile *::-webkit-scrollbar-thumb   { background: var(--sb-thumb); border-radius: 99px; }
.app-tile *::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-h); }
.app-tile * { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }

/* Curseur pointer sur le contenu des tuiles clicables */
.tile-view-narrow input, .tile-view-wide input, .tile-view-big input { cursor: text; }
.tile-view-narrow button, .tile-view-wide button, .tile-view-big button { cursor: pointer; }

/* 1×1 : masquer wide et big */
.app-tile:not(.wide):not(.big) .tile-view-wide { display: none; }
.app-tile:not(.wide):not(.big) .tile-view-big  { display: none; }
/* 1×2 : masquer narrow et big */
.app-tile.wide:not(.big) .tile-view-narrow { display: none; }
.app-tile.wide:not(.big) .tile-view-big    { display: none; }
/* 2×2 : masquer narrow et wide */
.app-tile.big .tile-view-narrow { display: none; }
.app-tile.big .tile-view-wide   { display: none; }

/* ── Icône large (vue large des tuiles) ──────────────────────── */
.app-icon--lg {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    aspect-ratio: 1;
    font-size: 26px;
    border-radius: 14px;
    flex-shrink: 0;
}

/* ── Boutons d'action dans les tuiles ────────────────────────── */
.tile-action-btn {
    position: relative;
    z-index: 3;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    background: var(--sf-1);
    border: 1px solid var(--bd);
    color: var(--tx-3);
    text-decoration: none;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.tile-action-btn:hover {
    background: var(--sf-2);
    color: var(--tx-1);
}
.tile-action-btn--accent {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    color: #fff;
}
.tile-action-btn--accent:hover {
    background: color-mix(in srgb, var(--accent) 35%, transparent);
}
/* office-dropdown-btn a width:100% par défaut, à annuler quand c'est un tile-action-btn */
.tile-action-btn.office-dropdown-btn {
    width: auto;
    background-image: none;
    padding-right: 12px;
}

/* ── Puces de stats dans les tuiles ──────────────────────────── */
.tile-stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--sf-sub);
    border: 1px solid var(--bd);
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--tx-4);
    white-space: nowrap;
    position: relative;
    z-index: 2;
}

/* ── Mode personnalisation : effet "wiggle" iOS ──────────────── */
@keyframes tile-wiggle {
    0%   { transform: rotate(0deg); }
    25%  { transform: rotate(-0.7deg); }
    75%  { transform: rotate(0.7deg); }
    100% { transform: rotate(0deg); }
}
body.customizing .app-tile {
    animation: tile-wiggle 0.35s ease-in-out infinite;
    transform-origin: center center;
}
body.customizing .app-tile:hover { transform: none; }
body.customizing .app-tile:nth-child(3n+2) { animation-delay: -0.12s; }
body.customizing .app-tile:nth-child(3n)   { animation-delay: -0.24s; }


/* Tuile sans auth */
.no-auth-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4caf82;
    position: absolute;
    top: 14px;
    right: 14px;
}

/* Tuile extension */
.ext-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #818cf8;
    position: absolute;
    top: 14px;
    right: 14px;
}

/* Badge extension manquante */
.ext-missing-badge {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(251,191,36,.15);
    border: 1px solid rgba(251,191,36,.35);
    color: #fbbf24;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    z-index: 3;
    transition: background .15s;
}
.ext-missing-badge:hover { background: rgba(251,191,36,.25); }

/* Alerte dans le dashboard */
.dash-alert { max-width: 900px; width: 100%; margin-bottom: 16px; }

/* Alerte login */
.alert-error {
    background: rgba(220,60,60,0.12);
    border: 1px solid rgba(220,60,60,0.25);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    color: #ff9999;
    margin-bottom: 16px;
}

/* Footer */
.dash-footer {
    text-align: center;
    padding: 16px;
    font-size: 11px;
    color: var(--tx-5);
}

/* ════════════════════════════════════════════════════════════════
   THÈME LIGHT — overrides spécifiques
════════════════════════════════════════════════════════════════ */

/* Tuiles : backdrop-filter pour l'effet verre sur fond clair */
html[data-theme="light"] .app-tile {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(15,30,50,0.06);
}

/* Dropdown : flèche sombre sur fond clair */
html[data-theme="light"] .office-dropdown-btn {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(15%2C30%2C50%2C.45)' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
}

/* Dropdown panel : ombre plus légère */
html[data-theme="light"] .office-dropdown-panel {
    box-shadow: 0 8px 24px rgba(15,30,50,0.12);
}

/* Contrôles de drag : fond clair semi-transparent */
html[data-theme="light"] .drag-handle,
html[data-theme="light"] .btn-resize,
html[data-theme="light"] .btn-hide-tile {
    background: rgba(15,25,45,0.18);
    color: rgba(15,25,45,0.75);
}
html[data-theme="light"] .btn-resize:hover  { background: rgba(37,99,235,0.5); color: white; }
html[data-theme="light"] .btn-hide-tile:hover { background: rgba(180,30,30,0.5); color: white; }

/* Alerte : texte lisible sur fond clair */
html[data-theme="light"] .alert-error { color: #b91c1c; }

/* Login remember thumb : visible sur fond clair */
html[data-theme="light"] .login-remember-thumb { background: rgba(15,25,45,0.65); }

/* Customize bar : texte foncé sur fond accent léger */
html[data-theme="light"] .customize-bar { color: var(--tx-2); }

/* Scrollbar tiles : teinte sombre sur fond clair */
html[data-theme="light"] .app-tile *::-webkit-scrollbar-thumb { background: var(--sb-thumb); }
html[data-theme="light"] .app-tile *::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-h); }
html[data-theme="light"] .app-tile * { scrollbar-color: var(--sb-thumb) transparent; }
html[data-theme="light"] .task-scroll::-webkit-scrollbar-thumb { background: var(--sb-thumb); }

/* Boutons primaires dark-blue : restent cohérents en light */
html[data-theme="light"] .login-btn,
html[data-theme="light"] .btn-customize-done { background: #1d4ed8; }
html[data-theme="light"] .login-btn:hover,
html[data-theme="light"] .btn-customize-done:hover { background: #1e40af; }
html[data-theme="light"] .login-remember-track.is-on { background: #1d4ed8; }

/* Ext / no-auth dots : visibles sur fond clair */
html[data-theme="light"] .ext-missing-badge {
    background: rgba(180,120,0,.12);
    border-color: rgba(180,120,0,.30);
    color: #92600a;
}
html[data-theme="light"] .ext-missing-badge:hover { background: rgba(180,120,0,.22); }

/* Footer */
html[data-theme="light"] .dash-footer { color: var(--tx-5); }

/* Code inline */
html[data-theme="light"] code { color: var(--tx-2); }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE — Dashboard
════════════════════════════════════════════════════════════════ */

/* ── Tablet (≤ 900px) ──────────────────────────────────────── */
@media (max-width: 900px) {
    .dash-body { padding: 32px 20px; }
    .apps-grid { max-width: 100%; }
}

/* ── Mobile (≤ 640px) ──────────────────────────────────────── */
@media (max-width: 640px) {
    /* Header */
    .dash-header { padding: 12px 16px; gap: 8px; }
    .dash-header .logo-text { font-size: 15px; }
    .dash-user { gap: 6px; }
    .dash-user-name { display: none; }
    .dash-admin-link,
    .dash-settings-link { padding: 5px 10px; font-size: 11px; }

    /* Corps */
    .dash-body { padding: 16px 12px; }
    .dash-title-row { margin-bottom: 12px; }
    .dash-title { font-size: 11px; }
    .btn-customize { display: none; }

    /* Barre personnalisation */
    .customize-bar { padding: 8px 12px; font-size: 12px; gap: 8px; }
    .customize-bar-info { font-size: 11px; }

    /* Grille */
    .apps-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 200px;
        gap: 10px;
        max-width: 100%;
    }

    /* Tuiles wide : déjà span 2 → pleine largeur, garder tile-view-wide */

    /* Tuiles big : 2 cols, 1 seule rangée → montrer vue wide */
    .app-tile.big { grid-row: span 1; }
    .app-tile.big .tile-view-wide { display: flex !important; }
    .app-tile.big .tile-view-big  { display: none  !important; }

    /* Padding tuile réduit */
    .app-tile { padding: 18px 14px 10px; border-radius: 12px; }

    /* Bandeau tuiles masquées */
    #hidden-tray { max-width: 100%; }
}

/* ── Très petit mobile (≤ 400px) ──────────────────────────── */
@media (max-width: 400px) {
    .apps-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 190px;
        gap: 8px;
    }
    /* Annuler les spans */
    .app-tile.wide { grid-column: span 1; }
    .app-tile.big  { grid-column: span 1; grid-row: span 1; }

    /* Toutes les tuiles → vue narrow */
    .app-tile.wide:not(.big) .tile-view-narrow { display: flex !important; }
    .app-tile.wide:not(.big) .tile-view-wide   { display: none  !important; }
    .app-tile.big .tile-view-narrow { display: flex !important; }
    .app-tile.big .tile-view-wide   { display: none  !important; }
}
