* { box-sizing: border-box; }

:root {
    --navy: #071b36;
    --navy-2: #102c50;
    --blue: #0878ff;
    --cyan: #15c8f4;
    --green: #19a968;
    --red: #d74343;
    --amber: #e49b18;
    --background: #f3f6fa;
    --surface: #ffffff;
    --text: #10243f;
    --muted: #718096;
    --border: #dce4ee;
    --shadow: 0 14px 34px rgba(7, 27, 54, .09);
}

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--background);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 12px clamp(18px, 4vw, 48px);
    background: var(--navy);
    color: white;
    box-shadow: 0 8px 30px rgba(7, 27, 54, .18);
}

.brand-link img {
    display: block;
    width: 150px;
    max-height: 50px;
    object-fit: contain;
    background: white;
    border-radius: 8px;
}

.topbar-client {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: auto;
}

.topbar-client img {
    width: 48px;
    height: 48px;
    border-radius: 9px;
    object-fit: contain;
    background: white;
}

.topbar-client strong,
.topbar-client small {
    display: block;
}

.topbar-client small { color: #b9cbe1; margin-top: 3px; }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 14px;
}

.topbar-nav a { color: #c9d8eb; }
.topbar-nav a:hover { color: white; }

.page {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 60px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.page-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); }
.page-heading p { margin: 7px 0 0; color: var(--muted); }

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.room-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.room-card {
    padding: 22px;
    transition: opacity .2s ease, transform .2s ease;
}

.room-card.is-loading { opacity: .52; pointer-events: none; }

.room-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.room-header h2 { margin: 0; font-size: 23px; }
.room-header small { display: block; margin-top: 5px; color: var(--muted); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 11px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .5px;
}

.status-pill i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
}

.status-on { background: #e2f7ed; color: #087444; }
.status-off { background: #fbe7e7; color: #9d3030; }
.status-warning { background: #fff2d5; color: #9a6200; }

.timer-panel {
    display: grid;
    gap: 4px;
    margin: 22px 0;
    padding: 18px;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--navy), var(--navy-2));
    color: white;
}

.timer-caption { font-size: 12px; color: #b9cbe1; }
.timer-value {
    font-size: clamp(32px, 7vw, 52px);
    line-height: 1.05;
    letter-spacing: -1px;
}
.timer-detail { color: #b9cbe1; }

.duration-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.btn {
    border: 0;
    border-radius: 11px;
    padding: 12px 15px;
    font-weight: 800;
    transition: transform .15s ease, filter .15s ease;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.03); }
.btn-primary { background: var(--blue); color: white; }
.btn-secondary { background: #e9eff6; color: var(--text); }
.btn-on { background: var(--green); color: white; }
.btn-off { background: var(--red); color: white; }
.btn-block { width: 100%; }
.btn-danger-small { background: #fbe7e7; color: #9d3030; padding: 9px 12px; }
.duration-button { background: #eaf3ff; color: #075bb7; border: 1px solid #cce1fb; }

.room-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.alert {
    padding: 13px 15px;
    border-radius: 11px;
    margin-bottom: 18px;
    font-weight: 700;
}
.alert-error { background: #fbe7e7; color: #8e2828; border: 1px solid #efc6c6; }
.alert-success { background: #e2f7ed; color: #087444; border: 1px solid #bde9d3; }

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(21, 200, 244, .22), transparent 34%),
        linear-gradient(135deg, #06172e, #0d315b);
}

.login-shell {
    width: min(900px, 100%);
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    overflow: hidden;
    border-radius: 24px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, .32);
    background: white;
}

.login-brand {
    display: grid;
    place-content: center;
    padding: 50px;
    background: #f6f9fd;
    text-align: center;
}

.login-brand img {
    width: min(360px, 100%);
    mix-blend-mode: multiply;
}

.login-brand p {
    letter-spacing: 5px;
    font-size: 11px;
    color: var(--muted);
}

.login-card { padding: 48px 42px; }
.login-card h1 { margin: 0 0 5px; font-size: 34px; }

form { display: grid; gap: 14px; }

label {
    display: grid;
    gap: 7px;
    font-size: 13px;
    font-weight: 750;
}

input, select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #cfd9e5;
    border-radius: 10px;
    background: white;
    color: var(--text);
}

input:focus, select:focus {
    outline: 3px solid rgba(8, 120, 255, .15);
    border-color: var(--blue);
}

.check { display: flex; align-items: center; gap: 9px; }
.check input { width: auto; min-height: 0; }

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

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.panel { padding: 22px; }
.panel h2 { margin-top: 0; }
.panel h3 { margin-top: 28px; }
.panel-wide { grid-column: 1 / -1; }

.client-list, .user-list { display: grid; gap: 10px; }
.client-list article {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 13px;
    border-radius: 11px;
    background: #f5f8fc;
}
.client-list strong, .client-list small, .user-list strong, .user-list small { display: block; }
.client-list small, .user-list small { margin-top: 3px; color: var(--muted); }
.inline-actions { display: flex; gap: 8px; }

.room-admin-list { display: grid; gap: 12px; }
.room-admin-card {
    grid-template-columns: 1.4fr 1fr 1.3fr .5fr auto auto;
    align-items: end;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 13px;
}
.delete-form { margin: -6px 0 10px; display: flex; justify-content: flex-end; }

.client-logo-preview {
    max-width: 220px;
    max-height: 110px;
    object-fit: contain;
    display: block;
    margin-bottom: 18px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(4, 17, 34, .68);
}

.modal-backdrop[hidden] { display: none; }

.modal {
    width: min(460px, 100%);
    padding: 24px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
}

.modal h3 { margin-top: 0; font-size: 24px; }
.modal-summary {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 9px 18px;
    padding: 15px;
    background: #f4f7fb;
    border-radius: 12px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1100;
    max-width: min(420px, calc(100% - 40px));
    padding: 14px 17px;
    border-radius: 12px;
    color: white;
    font-weight: 800;
    box-shadow: 0 15px 38px rgba(0,0,0,.2);
}
.toast-success { background: #087444; }
.toast-error { background: #a82929; }

@media (max-width: 900px) {
    .rooms-grid, .admin-grid, .login-shell { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .room-admin-card { grid-template-columns: 1fr 1fr; }
    .topbar { flex-wrap: wrap; }
    .topbar-client { order: 3; width: 100%; }
}

@media (max-width: 620px) {
    .page { width: min(100% - 20px, 1320px); padding-top: 20px; }
    .topbar-nav { width: 100%; overflow-x: auto; }
    .duration-grid { grid-template-columns: repeat(2, 1fr); }
    .room-actions, .page-heading { grid-template-columns: 1fr; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .room-admin-card { grid-template-columns: 1fr; }
    .login-card { padding: 34px 24px; }
}


.oauth-device-list {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.oauth-device-list > div {
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f5f8fc;
}

.oauth-device-list strong,
.oauth-device-list small {
    display: block;
}

.oauth-device-list small {
    margin-top: 3px;
    color: var(--muted);
}

.legacy-note {
    margin-top: 18px;
    font-size: 12px;
}


.oauth-device-assignment {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) minmax(180px, 1fr) auto;
    align-items: end;
    gap: 12px;
}

.oauth-device-assignment > div {
    align-self: center;
}

@media (max-width: 760px) {
    .oauth-device-assignment {
        grid-template-columns: 1fr;
    }
}


.system-check-list {
    display: grid;
    gap: 10px;
}

.system-check-list > div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 13px 14px;
    border-radius: 10px;
}

.check-ok {
    color: #087444;
    background: #e2f7ed;
}

.check-error {
    color: #9d3030;
    background: #fbe7e7;
}


/* V0.4 — interface tactile PopKfé */
.control-body{background:linear-gradient(180deg,#eef4fb 0,#f7f9fc 48%,#eef2f7 100%)}
.control-topbar{position:sticky;top:0;z-index:50}.control-page{width:min(1800px,calc(100% - 28px));padding-top:24px}
.control-heading{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:20px}.control-heading h1{margin:4px 0 0;font-size:clamp(28px,3vw,46px)}.eyebrow{font-size:12px;font-weight:900;letter-spacing:1.8px;color:#0878ff}
.connection-badges{display:flex;gap:8px;flex-wrap:wrap}.connection-badge{padding:9px 12px;border-radius:999px;background:#dcf7e9;color:#087444;font-size:11px;font-weight:900;letter-spacing:.5px}.connection-badge.cloud{background:#e5efff;color:#075bb7}.connection-badge.offline{background:#fbe7e7;color:#9d3030}
.rooms-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.room-card{padding:18px;border-radius:20px}.room-header h2{font-size:clamp(20px,2vw,28px)}.timer-panel{margin:16px 0;padding:15px}.timer-value{font-size:clamp(34px,5vw,58px)}.duration-grid .btn,.room-actions .btn{min-height:52px;font-size:15px}.room-card.is-loading{opacity:.55;pointer-events:none}
.setup-panel{position:fixed;left:20px;right:20px;bottom:20px;z-index:1200;max-width:760px;margin:auto;padding:22px 52px 22px 22px;border-radius:18px;background:#071b36;color:#fff;box-shadow:0 24px 70px rgba(0,0,0,.35)}.setup-panel[hidden]{display:none}.setup-panel h2{margin:0 0 6px}.setup-panel p{color:#c9d8eb}.setup-steps{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:16px 0}.setup-close{position:absolute;right:14px;top:10px;border:0;background:transparent;color:white;font-size:30px}.setup-panel small{color:#b9cbe1}
.device-row,.user-admin-card,.inline-form{display:grid;grid-template-columns:1fr 1fr auto;gap:10px;align-items:end;margin-top:12px}.user-admin-card{grid-template-columns:1fr 1fr 1fr auto auto auto;padding:14px;border:1px solid var(--border);border-radius:12px}.role-tag{align-self:center;padding:8px 10px;border-radius:999px;background:#edf3fa;font-size:12px;font-weight:800}.user-admin-list{display:grid;gap:10px}
@media (orientation:landscape) and (min-width:900px){.rooms-grid.grid-default{grid-template-columns:repeat(4,minmax(0,1fr))}.rooms-grid.grid-multiple-3{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (orientation:portrait){.rooms-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:760px){.rooms-grid{grid-template-columns:1fr}.setup-steps,.device-row,.user-admin-card,.inline-form{grid-template-columns:1fr}.control-heading{align-items:flex-start;flex-direction:column}.control-page{width:min(100% - 18px,1800px)}}

/* V0.5 — synchronisation, cartes fixes et sécurité locale */
.sync-line {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.rooms-grid {
    align-items: stretch;
}

.room-card {
    min-width: 0;
    height: 472px;
    min-height: 472px;
    display: grid;
    grid-template-rows: 58px 116px minmax(0, 1fr) 54px;
    align-content: stretch;
    overflow: hidden;
}

.room-header {
    min-width: 0;
    height: 58px;
    align-items: flex-start;
}

.room-title-zone {
    min-width: 0;
    flex: 1 1 auto;
    height: 52px;
    overflow: hidden;
}

.room-header h2 {
    max-width: 100%;
    margin: 0;
    font-size: clamp(18px, 1.55vw, 24px);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-header h2.room-title-long {
    font-size: clamp(17px, 1.35vw, 21px);
}

.room-header h2.room-title-very-long {
    font-size: clamp(15px, 1.15vw, 19px);
}

.room-title-zone small {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transport-warning {
    color: #a46500 !important;
    font-weight: 850;
}

.room-card .status-pill {
    flex: 0 0 auto;
    max-width: 112px;
    white-space: nowrap;
}

.room-card .timer-panel {
    height: 104px;
    min-height: 104px;
    margin: 10px 0 12px;
    align-content: center;
    overflow: hidden;
}

.room-card .timer-value {
    font-size: clamp(32px, 3.3vw, 49px);
    white-space: nowrap;
}

.room-card .timer-detail {
    min-height: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-card .duration-grid {
    align-content: center;
}

.room-card .duration-grid .btn,
.room-card .room-actions .btn {
    min-height: 48px;
}

.room-card .room-actions {
    align-self: end;
    margin-top: 6px;
}

.choice-panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.choice-panel {
    display: grid;
    gap: 7px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #f5f8fc;
}

.choice-panel strong { font-size: 16px; }
.choice-panel small { color: var(--muted); }
.choice-panel span { color: var(--navy); font-size: 13px; }
.modal-actions-three { justify-content: stretch; }
.modal-actions-three .btn { flex: 1; }

.agent-status-line {
    padding: 12px 14px;
    border-radius: 11px;
    background: #edf3fa;
    color: var(--navy);
    font-weight: 800;
}

.agent-status-line.is-ready {
    background: #e2f7ed;
    color: #087444;
}

.agent-status-line.is-error {
    background: #fbe7e7;
    color: #9d3030;
}

.local-alert-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.local-empty-state {
    padding: 14px;
    border: 1px dashed #c7d3e1;
    border-radius: 11px;
    color: var(--muted);
    background: #f8fafc;
}

.local-ip-alert {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 16px;
    border: 1px solid #efc981;
    border-radius: 13px;
    background: #fff8e8;
}

.local-ip-alert.is-muted { opacity: .62; }
.local-ip-alert p { margin: 7px 0 4px; }
.local-ip-alert small { color: #806230; }
.local-alert-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.room-admin-wrapper {
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
}

.room-admin-wrapper .room-admin-card {
    border: 0;
    border-radius: 0;
}

.room-security-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 15px;
    border-top: 1px solid var(--border);
    background: #f7f9fc;
}

.security-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #9d3030;
    font-size: 12px;
    font-weight: 900;
}

.security-state::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
}

.security-state.is-secure { color: #087444; }

@media (orientation: landscape) and (min-width: 900px) {
    .rooms-grid.grid-default {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .rooms-grid.grid-multiple-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .rooms-grid.grid-default > .room-card:last-child:nth-child(4n + 1) {
        grid-column: 2;
    }
}

@media (orientation: portrait) and (min-width: 640px) {
    .rooms-grid,
    .rooms-grid.grid-default,
    .rooms-grid.grid-multiple-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .room-card {
        height: 450px;
        min-height: 450px;
    }
}

@media (max-width: 980px) {
    .room-card .status-pill {
        padding: 7px 9px;
        font-size: 10px;
    }
    .local-ip-alert {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 639px) {
    .rooms-grid,
    .rooms-grid.grid-default,
    .rooms-grid.grid-multiple-3 {
        grid-template-columns: 1fr;
    }
    .room-card {
        height: auto;
        min-height: 450px;
    }
    .choice-panels { grid-template-columns: 1fr; }
    .modal-actions-three { flex-direction: column; }
    .room-security-row { align-items: stretch; flex-direction: column; }
}


/* V0.6 — gestionnaire, ajout libre de temps et coupures */
.room-actions-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.room-actions-three .btn {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 13px;
    white-space: nowrap;
}
.room-actions-three .add-time-button:disabled {
    opacity: .42;
    cursor: not-allowed;
}
.modal-compact { max-width: 520px; }
.modal label { display: grid; gap: 7px; margin-top: 14px; font-weight: 800; }
.modal input { width: 100%; box-sizing: border-box; }
.outage-summary {
    margin-top: 14px;
    padding: 13px 14px;
    border-radius: 11px;
    background: #fff8e8;
    color: #795b20;
    font-weight: 750;
}
.advanced-field {
    align-self: stretch;
    padding: 9px 11px;
    border: 1px dashed #c8d4e1;
    border-radius: 10px;
    background: #f8fafc;
}
.advanced-field summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
}
.advanced-field[open] summary { margin-bottom: 10px; }
@media(max-width:980px) {
    .room-actions-three .btn { font-size: 12px; }
}
@media(max-width:639px) {
    .room-actions-three { grid-template-columns: 1fr; }
    .room-card { min-height: 560px; }
}

.local-agent-actions { margin: 12px 0 14px; }


.security-state.has-secret {
    color: #8a5b00;
}

.security-state.has-secret::before {
    background: #e3a008;
}


/* V0.6.6 candidate V1 — cartes compactes, historique et états hors ligne */
.control-topbar { min-height: 62px; padding-top: 7px; padding-bottom: 7px; }
.control-topbar .brand-link img { max-height: 42px; }
.control-page { padding-top: 10px; padding-bottom: 18px; }
.control-heading { margin-bottom: 10px; }
.control-heading h1 { font-size: clamp(23px, 2.3vw, 34px); }
.sync-line { margin-top: 3px; }
.rooms-grid { gap: 10px; }
.room-card {
    position: relative;
    height: 310px;
    min-height: 310px;
    padding: 10px;
    border-radius: 15px;
    grid-template-rows: 43px 82px minmax(0, 1fr) 38px;
}
.room-header { height: 43px; gap: 8px; }
.room-title-zone { height: 42px; }
.room-header h2 { font-size: clamp(16px, 1.35vw, 20px); }
.room-header h2.room-title-long { font-size: clamp(15px, 1.18vw, 18px); }
.room-header h2.room-title-very-long { font-size: clamp(14px, 1.02vw, 17px); }
.room-title-zone small { margin-top: 2px; font-size: 9px; line-height: 1.15; }
.room-card .status-pill { max-width: 96px; padding: 6px 8px; font-size: 9px; }
.timer-history-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
    gap: 7px;
    height: 78px;
    min-height: 78px;
    margin: 3px 0 6px;
}
.room-card .timer-panel {
    height: 78px;
    min-height: 78px;
    margin: 0;
    padding: 8px 10px;
    border-radius: 11px;
    gap: 1px;
}
.room-card .timer-caption { font-size: 9px; }
.room-card .timer-value { font-size: clamp(25px, 2.45vw, 37px); line-height: 1; }
.room-card .timer-detail { min-height: 11px; font-size: 9px; }
.recent-actions-panel {
    min-width: 0;
    height: 78px;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #f7f9fc;
    overflow: hidden;
}
.recent-actions-title {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .4px;
    text-transform: uppercase;
}
.recent-actions-list { display: grid; gap: 1px; }
.recent-action {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 4px;
    min-width: 0;
    font-size: 9px;
    line-height: 1.2;
}
.recent-action time { color: var(--muted); font-variant-numeric: tabular-nums; }
.recent-action span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 800; }
.recent-action-empty { color: var(--muted); font-size: 9px; }
.room-card .duration-grid { gap: 5px; align-content: center; }
.room-card .duration-grid .btn,
.room-card .room-actions .btn {
    min-height: 31px;
    padding: 5px 5px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1;
}
.room-card .duration-grid .btn { white-space: nowrap; word-break: keep-all; }
.room-card .room-actions { margin-top: 4px; gap: 5px; }
.room-actions-three .btn { font-size: 10px; }
.power-offline-banner {
    display: none;
    position: absolute;
    z-index: 4;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
    gap: 7px;
    min-width: 190px;
    padding: 6px 10px;
    border: 1px solid #9fa9b6;
    border-radius: 999px;
    background: #eef1f4;
    color: #566170;
    box-shadow: 0 5px 16px rgba(39, 49, 61, .2);
}
.power-offline-banner strong,
.power-offline-banner small { display: block; white-space: nowrap; }
.power-offline-banner strong { font-size: 10px; letter-spacing: .45px; }
.power-offline-banner small { font-size: 8px; }
.power-offline-icon { position: relative; font-size: 21px; line-height: 1; filter: grayscale(1); }
.power-offline-icon::after {
    content: '';
    position: absolute;
    left: 50%; top: -2px;
    width: 2px; height: 27px;
    background: #b32626;
    transform: rotate(43deg);
    transform-origin: center;
}
.room-card.is-device-offline {
    background: #e7eaee;
    border-color: #b9c0c9;
    box-shadow: none;
}
.room-card.is-device-offline > :not(.power-offline-banner) { opacity: .43; filter: grayscale(1); }
.room-card.is-device-offline .power-offline-banner { display: flex; opacity: 1; filter: none; }
.room-card.is-device-offline button { cursor: not-allowed; }
.agent-recovery-note {
    margin: 14px 0;
    padding: 11px 13px;
    border-radius: 10px;
    background: #eaf3ff;
    color: #075bb7;
    font-weight: 750;
}
.agent-installer-link {
    display: block;
    margin-top: 13px;
    color: #075bb7;
    text-align: center;
    text-decoration: underline;
    font-weight: 800;
}
@media (orientation: landscape) and (min-width: 900px) and (max-height: 820px) {
    .topbar-nav { font-size: 12px; }
    .control-heading { min-height: 45px; }
    .room-card { height: 300px; min-height: 300px; }
}
@media (max-width: 980px) {
    .recent-actions-panel { padding-left: 6px; padding-right: 6px; }
    .recent-action { grid-template-columns: 27px minmax(0, 1fr); font-size: 8px; }
    .room-actions-three .btn { font-size: 9px; }
}
@media (orientation: portrait) and (min-width: 640px) {
    .room-card { height: 330px; min-height: 330px; }
}
@media (max-width: 639px) {
    .room-card { height: auto; min-height: 420px; }
    .timer-history-panel { height: auto; grid-template-columns: 1fr; }
    .recent-actions-panel { height: 78px; }
    .room-actions-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}


/* V0.6.7 — statut local rapide, relance agent et dates d’historique */
.connection-restart-button {
    appearance: none;
    border: 1px solid #efb2b2;
    border-radius: 999px;
    background: #fff0f0;
    color: #a12626;
    padding: 8px 11px;
    font: inherit;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .25px;
    cursor: pointer;
    white-space: nowrap;
}
.connection-restart-button:hover { background: #ffe4e4; }
.connection-restart-button:disabled { opacity: .55; cursor: wait; }

.recent-action {
    grid-template-columns: 63px minmax(0, 1fr);
}
.recent-action time {
    white-space: nowrap;
    font-size: 8px;
}

.power-offline-banner {
    min-width: min(345px, calc(100% - 22px));
    border-radius: 13px;
}
.power-offline-banner > span:last-child {
    min-width: 0;
}
.power-offline-banner strong,
.power-offline-banner small {
    white-space: normal;
}
.power-offline-banner small {
    max-width: 285px;
    line-height: 1.2;
}

@media (max-width: 980px) {
    .recent-action {
        grid-template-columns: 58px minmax(0, 1fr);
    }
    .connection-restart-button {
        padding: 7px 9px;
        font-size: 9px;
    }
}

/* V0.6.8 — coordination multi-agent */
.agent-role-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 10px 0;
}
.agent-role-choice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    border: 1px solid #d9e3ef;
    border-radius: 13px;
    padding: 12px;
    background: #f8fbff;
    cursor: pointer;
}
.agent-role-choice input { margin-top: 3px; }
.agent-role-choice span { display: grid; gap: 3px; }
.agent-role-choice small { color: #63758b; }

.panel-wide { grid-column: 1 / -1; }
.panel-title-row,
.agent-registry-head,
.agent-registry-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}
.agent-counts,
.agent-registry-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.agent-counts span {
    border-radius: 999px;
    padding: 7px 10px;
    background: #eef4fb;
    font-size: 12px;
    font-weight: 800;
}
.agent-registry-list { display: grid; gap: 12px; margin-top: 14px; }
.agent-registry-card {
    border: 1px solid #dce5ef;
    border-radius: 15px;
    padding: 14px;
    background: #fff;
}
.agent-registry-card.is-controller {
    border-color: #65b78d;
    box-shadow: inset 0 0 0 1px #65b78d;
}
.agent-registry-head strong,
.agent-registry-head small { display: block; }
.agent-registry-head small { color: #65768a; margin-top: 3px; }
.agent-state {
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 900;
    background: #edf1f5;
    white-space: nowrap;
}
.agent-state-online { background: #e7f7ee; color: #17683e; }
.agent-state-offline { background: #fff4d8; color: #7b5700; }
.agent-state-stale,
.agent-state-revoked { background: #ffe7e7; color: #952828; }
.agent-registry-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 150px 110px auto;
    gap: 10px;
    align-items: end;
    margin: 13px 0;
}
.agent-registry-form label { margin: 0; }
.agent-registry-foot small { color: #67788c; overflow-wrap: anywhere; }

@media (max-width: 900px) {
    .agent-role-choices { grid-template-columns: 1fr; }
    .agent-registry-form { grid-template-columns: 1fr 1fr; }
    .agent-registry-head,
    .agent-registry-foot,
    .panel-title-row { align-items: flex-start; flex-direction: column; }
}
.btn-danger {
    background: #b82c2c;
    color: #fff;
    border-color: #b82c2c;
}
.btn-danger:hover { background: #9f2020; }


/* V0.7.1 — état physique externe, nettoyage et identifiants locaux */
.settings-block {
    margin: 16px 0;
    padding: 13px 14px;
    border: 1px solid #dbe5f0;
    border-radius: 14px;
    background: #f8fbff;
}
.settings-block legend {
    padding: 0 7px;
    font-weight: 900;
    color: #173653;
}
.status-external {
    background: #fff1c7;
    color: #7a5200;
    border-color: #e3ad23;
}
.status-danger {
    background: #ffe1e1;
    color: #9a2222;
    border-color: #d94a4a;
}
.status-cleaning {
    background: #e8e1ff;
    color: #5b36a5;
    border-color: #8d70d7;
}
.room-card.has-external-state {
    box-shadow: inset 0 0 0 2px rgba(222, 153, 22, .45);
}
.room-security-row {
    gap: 10px;
    flex-wrap: wrap;
}
.credentials-modal { max-width: 560px; }
.credentials-grid { display: grid; gap: 12px; }
.credential-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}
.credential-line code {
    display: block;
    min-width: 0;
    padding: 11px 12px;
    border-radius: 10px;
    background: #eef4fa;
    color: #122a42;
    overflow-wrap: anywhere;
    user-select: all;
}
.credentials-warning {
    margin: 14px 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff4d8;
    color: #775400;
    font-weight: 750;
}
@media (max-width: 620px) {
    .credential-line { grid-template-columns: 1fr; }
}

/* V0.7.3 — déploiement et erreurs du secours Shelly */
.emergency-deploy-row {display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border-top:1px solid #e5e7eb;background:#f8fafc}
.emergency-deploy-row>div {display:flex;flex-direction:column;gap:2px;min-width:0}
.emergency-deploy-row small {color:#64748b}
.emergency-deploy-row.has-error {background:#fff1f2;border-color:#fecdd3}
.emergency-deploy-row .error-text {color:#b42318;font-weight:800}
.inline-download-form {margin:0;flex:0 0 auto}
.status-emergency {background:#fff3cd;color:#744f00;border-color:#ffd66b}
.room-card.is-emergency {box-shadow:0 0 0 3px rgba(255,181,0,.22)}
@media(max-width:760px){.emergency-deploy-row{align-items:stretch;flex-direction:column}.inline-download-form .btn{width:100%}}
