:root {
    --bg: #ffffff;
    --soft: #f4f7f8;
    --text: #13232d;
    --muted: #5f6f7a;
    --teal: #008c8c;
    --border: #dbe3e7;
    --shadow: rgba(19, 35, 45, .08);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}
.topbar {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.brand img {
    height: 74px;
    max-width: 420px;
    object-fit: contain;
    display: block;
}
.menu {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.menu a {
    color: var(--text);
    text-decoration: none;
    padding: 10px 13px;
    border-radius: 999px;
    font-weight: 700;
}
.menu a:hover, .menu a.active {
    background: var(--soft);
    color: var(--teal);
}
.menu-toggle {
    display: none;
    border: 1px solid var(--border);
    background: white;
    border-radius: 12px;
    padding: 10px 13px;
    font-size: 1.3rem;
}
main {
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px;
}
.hero {
    min-height: 520px;
    display: grid;
    grid-template-columns: 1.45fr .85fr;
    gap: 34px;
    align-items: center;
}
.eyebrow {
    color: var(--teal);
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}
h1 {
    font-size: clamp(2.2rem, 6vw, 4.6rem);
    line-height: .98;
    margin: 0 0 22px;
    letter-spacing: -0.055em;
}
h2 { margin: 0 0 12px; }
.lead {
    color: var(--muted);
    font-size: 1.18rem;
    max-width: 740px;
}
.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 28px;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 800;
    background: white;
    cursor: pointer;
}
.btn.primary {
    background: var(--teal);
    border-color: var(--teal);
    color: white;
}
.hero-card, article, .contact-card, .brand-item {
    border: 1px solid var(--border);
    background: white;
    border-radius: 24px;
    padding: 26px;
    box-shadow: 0 18px 50px var(--shadow);
}
.hero-icon {
    width: 110px;
    height: 110px;
    margin-bottom: 20px;
}
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin: 34px 0;
}
article p { color: var(--muted); }
.page { padding: 50px 0 80px; }
.narrow { max-width: 620px; }
.login-form {
    display: grid;
    gap: 18px;
    margin-top: 28px;
}
label {
    display: grid;
    gap: 8px;
    font-weight: 700;
}
input, select {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    font: inherit;
    background: white;
}
.alert {
    background: #fff3f3;
    color: #8a1f1f;
    border: 1px solid #ffd0d0;
    padding: 12px 14px;
    border-radius: 12px;
    margin: 16px 0;
}
.success {
    background: #eefaf6;
    color: #126b4f;
    border: 1px solid #bde9dc;
    padding: 12px 14px;
    border-radius: 12px;
    margin: 16px 0;
}
.footer {
    border-top: 1px solid var(--border);
    max-width: 1180px;
    margin: 40px auto 0;
    padding: 24px 22px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    flex-wrap: wrap;
}
.brand-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-top: 34px;
}
.brand-item.large { grid-column: 1 / -1; }
.brand-item img {
    max-width: 100%;
    height: auto;
    display: block;
}
.favicon-preview {
    width: 96px;
    height: 96px;
}
.admin-panel {
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 24px;
    margin: 28px 0;
    background: var(--soft);
}
.user-form {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: end;
}
.users-list {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}
.user-card {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr 1fr 1.3fr auto auto auto;
    gap: 14px;
    align-items: end;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    background: white;
}
.user-card small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}
.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}
.checkbox input { width: auto; }
.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn.danger {
    color: #8a1f1f;
    border-color: #ffd0d0;
    background: #fff3f3;
}
.btn.success-btn {
    background: #126b4f;
    border-color: #126b4f;
    color: white;
}
.badge {
    display: inline-flex;
    width: fit-content;
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
}
.badge.pending { background: #fff7df; color: #856000; border: 1px solid #ffe6a3; }
.badge.active { background: #eefaf6; color: #126b4f; border: 1px solid #bde9dc; }
.badge.inactive { background: #f2f4f5; color: #60707a; border: 1px solid #dce4e8; }
code {
    background: var(--soft);
    padding: 2px 6px;
    border-radius: 6px;
}

@media (max-width: 1050px) {
    .user-form, .user-card { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .topbar { flex-wrap: wrap; }
    .brand img { height: 54px; max-width: 300px; }
    .menu-toggle { display: inline-flex; }
    .menu {
        display: none;
        width: 100%;
        flex-direction: column;
    }
    .menu-open .menu { display: flex; }
    .hero, .grid, .brand-grid { grid-template-columns: 1fr; }
    .brand-item.large { grid-column: auto; }
}


.roles-form {
    margin-top: 28px;
}

.roles-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: white;
    box-shadow: 0 18px 50px var(--shadow);
}

.roles-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 850px;
}

.roles-table th,
.roles-table td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.roles-table th:first-child,
.roles-table td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: white;
    z-index: 1;
}

.roles-table th {
    background: var(--soft);
    font-size: .92rem;
}

.roles-table td small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.perm-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.perm-check input {
    width: 20px;
    height: 20px;
}

.hint {
    color: var(--muted);
    margin: 18px 0;
}


.domotic-layout {
    display: grid;
    grid-template-columns: 1.5fr .7fr;
    gap: 22px;
    align-items: start;
    margin-top: 32px;
}

.plan-card img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 16px;
}

.control-panel {
    border: 1px solid var(--border);
    background: white;
    border-radius: 24px;
    padding: 26px;
    box-shadow: 0 18px 50px var(--shadow);
}

.control-placeholder {
    border: 1px dashed var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    margin-top: 12px;
    color: var(--muted);
    background: var(--soft);
    font-weight: 700;
}

@media (max-width: 900px) {
    .domotic-layout {
        grid-template-columns: 1fr;
    }
}


.floor-plan {
    position: relative;
    width: 100%;
}

.floor-plan img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 16px;
}

.lamp-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    z-index: 5;
    font: inherit;
}

.lamp-marker .bulb {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255,255,255,.95);
    color: #a9a9a9;
    font-size: 29px;
    box-shadow: 0 10px 25px rgba(19,35,45,.25);
    border: 2px solid rgba(255,255,255,.9);
    transition: transform .15s ease, background .15s ease, color .15s ease;
}

.lamp-marker:hover .bulb,
.lamp-marker.selected .bulb {
    transform: scale(1.08);
}

.lamp-marker.on .bulb {
    color: #ffb000;
    background: #fff7dc;
    box-shadow: 0 0 0 5px rgba(255,176,0,.22), 0 10px 28px rgba(19,35,45,.28);
}

.lamp-marker.off .bulb {
    filter: grayscale(.55);
}

.lamp-label {
    display: grid;
    gap: 3px;
    margin-top: 8px;
    padding: 7px 9px;
    background: rgba(19,35,45,.88);
    color: white;
    border-radius: 8px;
    font-size: .78rem;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(19,35,45,.22);
}

.lamp-label small {
    color: rgba(255,255,255,.74);
    font-size: .68rem;
    letter-spacing: .04em;
}

.mqtt-box {
    margin: 14px 0;
    display: grid;
    gap: 6px;
}

.mqtt-box code {
    display: block;
    overflow-wrap: anywhere;
}

@media (max-width: 700px) {
    .lamp-marker .bulb {
        width: 42px;
        height: 42px;
        font-size: 23px;
    }

    .lamp-label {
        font-size: .68rem;
        padding: 5px 7px;
    }
}


.mqtt-status {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 7px 10px;
    margin: 0 0 14px;
    border-radius: 999px;
    background: #fff3f3;
    color: #8a1f1f;
    border: 1px solid #ffd0d0;
    font-size: .85rem;
    font-weight: 800;
}

.mqtt-status.ok {
    background: #eefaf6;
    color: #126b4f;
    border-color: #bde9dc;
}

.mqtt-status.ko {
    background: #fff3f3;
    color: #8a1f1f;
    border-color: #ffd0d0;
}


/* Menu avec icônes ProgHard */
.menu a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.menu a img {
    width: 19px;
    height: 19px;
    display: inline-block;
    flex: 0 0 auto;
    transition: transform .15s ease, filter .15s ease, opacity .15s ease;
    opacity: .92;
}

.menu a:hover img,
.menu a.active img {
    transform: translateY(-1px);
    opacity: 1;
}

/* Variante optionnelle : menu un peu plus compact si beaucoup d’entrées */
@media (min-width: 861px) {
    .menu a {
        padding: 9px 11px;
    }
}

.menu-dropdown{position:relative}
.menu-dropbtn{background:none;border:0;cursor:pointer;display:flex;gap:6px;align-items:center}
.submenu{display:none;position:absolute;background:white;padding:8px;border-radius:10px;box-shadow:0 10px 30px rgba(0,0,0,0.1)}
.menu-dropdown:hover .submenu{display:block}
.submenu a{display:flex;gap:6px;padding:5px}
