/* DB Services — Vidéosurveillance. Couleurs tirées du logo. */
:root {
    --green-900: #2f5a3c;
    --green-700: #447854;
    --green-600: #4f9142;
    --green-500: #5aa748;
    --green-300: #aed266;
    --green-100: #eaf4e3;
    --green-50:  #f4f9f0;
    --ink:       #4a5170;
    --text:      #262b3a;
    --muted:     #6b7288;
    --bg:        #f6f8f5;
    --card:      #ffffff;
    --border:    #e2e8de;
    --danger:    #c94444;
    --danger-bg: #fdeeee;
    --warn-bg:   #fff6e0;
    --warn:      #8a6100;
    --gradient:  linear-gradient(135deg, var(--green-700) 0%, var(--green-500) 55%, var(--green-300) 100%);
    --radius:    14px;
    --shadow:    0 1px 2px rgba(38, 43, 58, .04), 0 4px 16px rgba(38, 43, 58, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
body.bare { background: #fff; }
a { color: var(--green-700); }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0; }
h1 { font-size: 1.7rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -3px; }

/* --- Barre du haut --- */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar::after { content: ""; display: block; height: 3px; background: var(--gradient); }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex: none; }
.brand img { height: 46px; width: auto; }
.brand-tag { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--green-700); background: var(--green-100); padding: 3px 10px; border-radius: 99px; }
.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav > a { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 500; font-size: .92rem; white-space: nowrap; }
.nav > a:hover { background: var(--green-50); color: var(--green-700); }
.nav > a.on { background: var(--green-100); color: var(--green-700); }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--border); }
.nav-user form { margin: 0; }
.nav-user-txt { display: flex; flex-direction: column; line-height: 1.2; }
.nav-user-txt strong { font-size: .88rem; color: var(--text); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; padding: 8px; color: var(--ink); cursor: pointer; }
.nav-toggle .ic { width: 24px; height: 24px; }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gradient); color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }

.role { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.role-admin { background: var(--ink); color: #fff; }
.role-syndic { background: #e6ecf8; color: #34508a; }
.role-proprietaire { background: var(--green-100); color: var(--green-700); }

/* --- Structure --- */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 32px 24px 48px; flex: 1; }
.footer { border-top: 1px solid var(--border); background: #fff; padding: 18px 24px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: .82rem; color: var(--muted); }
.footer a { color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 4px 0 0; }
.page-head p .ic { width: 15px; height: 15px; margin-right: 4px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; text-decoration: none; margin-bottom: 6px; font-weight: 500; }
.section-title { font-size: 1.1rem; margin: 32px 0 14px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; margin-bottom: 18px; }
.card-title .ic { color: var(--green-600); }

/* --- Boutons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: .92rem; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s, transform .05s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green-500); color: #fff; box-shadow: 0 2px 8px rgba(90, 167, 72, .3); }
.btn-primary:hover { background: var(--green-600); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--green-500); color: var(--green-700); }
.btn-block { width: 100%; padding: 12px; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.icon-btn:hover { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
:focus-visible { outline: 3px solid rgba(90, 167, 72, .45); outline-offset: 2px; }

/* --- Alertes --- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .92rem; border: 1px solid; }
.alert-success { background: var(--green-50); border-color: #cfe5c3; color: var(--green-900); }
.alert-error { background: var(--danger-bg); border-color: #f3caca; color: #8f2c2c; }
.alert-warning { background: var(--warn-bg); border-color: #f1dea6; color: var(--warn); }

/* --- Formulaires --- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-layout { display: flex; flex-direction: column; gap: 20px; max-width: 900px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 20px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { font-weight: 500; font-size: .88rem; color: var(--ink); }
.field small { color: var(--muted); font-size: .8rem; }
fieldset.field { margin-bottom: 16px; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], input[type=tel], textarea, select {
    font: inherit; width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(90, 167, 72, .18); }
.input-group { display: flex; gap: 8px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; }

.role-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.role-option { position: relative; cursor: pointer; }
.role-option input { position: absolute; opacity: 0; }
.role-option > span { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: 12px; transition: border-color .15s, background .15s; }
.role-option strong { color: var(--ink); font-size: .92rem; }
.role-option small { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.role-option input:checked + span { border-color: var(--green-500); background: var(--green-50); box-shadow: 0 0 0 3px rgba(90, 167, 72, .12); }
.role-option input:focus-visible + span { outline: 3px solid rgba(90, 167, 72, .45); }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; color: var(--ink); }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 42px; height: 24px; border-radius: 99px; background: #cfd5cc; position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--green-500); }
.switch input:checked + span::after { transform: translateX(18px); }

.check-group { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.check-group-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--green-50); cursor: pointer; }
.check-group-head strong { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: .92rem; }
.check-group-head small { margin-left: auto; color: var(--muted); }
.check-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; padding: 12px 16px; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; font-size: .9rem; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green-500); flex: none; }
.admin-note { display: none; align-items: center; gap: 8px; background: var(--green-50); color: var(--green-900); padding: 12px 16px; border-radius: 10px; margin: 0; }
.is-admin .admin-note { display: flex; }
.is-admin [data-cameras-list] { display: none; }

/* --- Tags, puces --- */
.tag { display: inline-block; font-size: .75rem; font-weight: 500; padding: 2px 10px; border-radius: 99px; background: #eef1f4; color: var(--ink); font-style: normal; white-space: nowrap; }
.tag-on { background: var(--green-100); color: var(--green-700); }
.tag-off { background: var(--danger-bg); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.page-head .chips { margin-bottom: 0; }
.chip { font: inherit; font-size: .85rem; font-weight: 500; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--border); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.chip:hover { border-color: var(--green-500); }
.chip.on { background: var(--green-500); border-color: var(--green-500); color: #fff; }

/* --- Tableaux --- */
.table-card { padding: 0; overflow: hidden; margin-bottom: 24px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 12px 18px; background: #fafbf9; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfdf9; }
.cell-user { display: flex; align-items: center; gap: 12px; }
.cell-user > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.cell-user small { color: var(--muted); font-size: .8rem; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions form { margin: 0; }

/* --- Tableau de bord --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.stat:hover { border-color: var(--green-500); transform: translateY(-2px); }
.stat-icon { grid-row: span 2; width: 48px; height: 48px; border-radius: 12px; background: var(--green-100); color: var(--green-700); display: grid; place-items: center; flex: none; }
.stat-icon .ic { width: 22px; height: 22px; }
.stat-icon.sm { width: 36px; height: 36px; border-radius: 10px; }
.stat-icon.sm .ic { width: 18px; height: 18px; }
.stat-num { font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat-num small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.stat-label { color: var(--muted); font-size: .85rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.list-main small { color: var(--muted); font-size: .8rem; }
.info-list { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; margin: 0 0 16px; }
.info-list dt { color: var(--muted); font-size: .88rem; }
.info-list dd { margin: 0; font-weight: 500; }

/* --- Caméras --- */
.residence { margin-bottom: 32px; }
.residence[hidden] { display: none; }
.residence-title { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; margin: 8px 0 14px; }
.residence-title .ic { color: var(--green-600); }
.count { font-size: .75rem; background: var(--green-100); color: var(--green-700); padding: 2px 9px; border-radius: 99px; font-weight: 600; }
.cam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.cam-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s; }
.cam-card:hover { box-shadow: 0 8px 28px rgba(38, 43, 58, .1); transform: translateY(-2px); }
.cam-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.cam-meta > div { display: flex; flex-direction: column; min-width: 0; }
.cam-meta strong { color: var(--ink); }
.cam-meta .muted { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cam-frame { position: relative; aspect-ratio: 16 / 9; background: #151a17; overflow: hidden; }
.cam-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 0; display: block; }
.live-badge { position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .55); color: #fff; font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px; backdrop-filter: blur(4px); opacity: 0; transition: opacity .3s; }
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: #ff4d4d; animation: pulse 1.6s infinite; }
.cam-frame[data-state=ok] .live-badge { opacity: 1; }
@keyframes pulse { 50% { opacity: .3; } }
.cam-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #cfd8cc; font-size: .85rem; background: radial-gradient(circle at center, #1f2a22, #111512); text-align: center; padding: 16px; }
.cam-frame[data-state=ok] .cam-status { display: none; }
.cam-frame[data-state=error] .spinner { border-color: #c94444; animation: none; border-width: 0; }
.cam-frame[data-state=error] .spinner::before { content: "!"; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: rgba(201, 68, 68, .2); color: #ff8a8a; font-weight: 700; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid rgba(174, 210, 102, .25); border-top-color: var(--green-300); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.cam-view .cam-frame { border-radius: var(--radius); box-shadow: var(--shadow); }
.cam-view:fullscreen { background: #000; display: grid; place-items: center; }
.cam-view:fullscreen .cam-frame { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 0; }
.cam-view + .muted { margin-top: 10px; display: flex; align-items: center; gap: 6px; }
.cam-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.cam-links a { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--ink); }
.cam-links a:hover { border-color: var(--green-500); background: var(--green-50); }
.cam-links a > .ic { color: var(--green-600); }
.cam-links span { display: flex; flex-direction: column; min-width: 0; }
.cam-links small { color: var(--muted); font-size: .8rem; }

.empty { text-align: center; padding: 64px 24px; background: #fff; border: 1px dashed #cfdcc7; border-radius: var(--radius); }
.empty-icon { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 50%; background: var(--green-100); color: var(--green-600); display: grid; place-items: center; }
.empty-icon .ic { width: 32px; height: 32px; }
.empty h2 { margin-bottom: 8px; }
.empty p { color: var(--muted); margin: 0 0 20px; }

/* --- Connexion --- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-hero { background: var(--gradient); color: #fff; display: flex; align-items: center; padding: 64px; position: relative; overflow: hidden; }
.auth-hero::before, .auth-hero::after { content: ""; position: absolute; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .18); }
.auth-hero::before { width: 520px; height: 520px; right: -180px; bottom: -200px; }
.auth-hero::after { width: 320px; height: 320px; right: -60px; bottom: -80px; background: rgba(255, 255, 255, .06); }
.auth-hero-inner { position: relative; z-index: 1; max-width: 520px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .18); padding: 6px 14px; border-radius: 99px; font-size: .8rem; font-weight: 600; letter-spacing: .04em; margin-bottom: 24px; }
.auth-hero h1 { color: #fff; font-size: 2.4rem; margin-bottom: 18px; }
.auth-hero p { font-size: 1.05rem; opacity: .92; margin: 0 0 28px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 14px; font-weight: 500; }
.auth-points .ic { width: 38px; height: 38px; padding: 9px; border-radius: 10px; background: rgba(255, 255, 255, .18); }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; gap: 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { width: 100%; max-width: 300px; height: auto; display: block; margin: 0 auto 32px; }
.auth-card h2 { font-size: 1.5rem; }
.auth-card > .muted { margin: 4px 0 24px; }
.auth-help { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 24px; }
.auth-back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; text-decoration: none; }
.auth-back:hover { color: var(--green-700); }

/* --- Mobile --- */
@media (max-width: 1360px) {
    .nav-toggle { display: block; }
    .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff; flex-direction: column; align-items: stretch; padding: 12px 16px 16px; border-bottom: 1px solid var(--border); box-shadow: 0 12px 24px rgba(0, 0, 0, .08); }
    .nav.open { display: flex; }
    .nav-user { margin: 8px 0 0; padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--border); }
    .nav-user-txt { flex: 1; }
    .topbar-inner { position: relative; }
}
@media (max-width: 860px) {
    .auth { grid-template-columns: 1fr; }
    .auth-hero { padding: 40px 24px; }
    .auth-hero h1 { font-size: 1.7rem; }
    .auth-points { display: none; }
    .auth-hero p { margin: 0; }
}
@media (max-width: 700px) {
    .container { padding: 24px 16px 40px; }
    .topbar-inner { padding: 10px 16px; }
    .brand img { height: 38px; }
    .brand-tag { display: none; }
    h1 { font-size: 1.4rem; }
    .cam-grid { grid-template-columns: 1fr; }
    .two-col { grid-template-columns: 1fr; }
    .card { padding: 18px; }
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .table td { border: 0; padding: 4px 0; }
    .table td[data-label]:not(:first-child)::before { content: attr(data-label) " : "; color: var(--muted); font-size: .8rem; }
    .row-actions { justify-content: flex-start; padding-top: 8px !important; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .input-group { flex-direction: column; }
}

/* --- Import Synology --- */
.import-list { grid-template-columns: 1fr; gap: 0; padding: 4px 16px; }
.import-row { display: grid; grid-template-columns: auto minmax(160px, 1fr) auto auto; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.import-row:last-child { border-bottom: 0; }
.import-row.is-done { opacity: .6; }
@media (max-width: 700px) { .import-row { grid-template-columns: auto 1fr; } .import-row small, .import-row .tag { grid-column: 2; } }

/* --- Commun (v3) --- */
.switches { display: flex; flex-direction: column; gap: 12px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a5170' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 36px !important; cursor: pointer; }
input[type=date] { font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text); }
.tag .ic { width: 14px; height: 14px; vertical-align: -2px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; color: var(--muted); }
.flip .ic { transform: rotate(180deg); }
.section-title.first { margin-top: 0; }
.chip-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: rgba(0, 0, 0, .08); font-size: .75rem; text-align: center; }
.chip.on .chip-count { background: rgba(255, 255, 255, .25); }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; }

/* --- Journal --- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { display: flex; align-items: center; gap: 8px; padding: 10px 18px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--green-700); }
.tab.on { color: var(--green-700); border-bottom-color: var(--green-500); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; padding: 18px; margin-bottom: 14px; }
.filters .field { flex: 1 1 170px; }
.live-now { margin-bottom: 20px; border-color: #cfe5c3; background: linear-gradient(0deg, #fff, var(--green-50)); }
.live-now .card-title { margin-bottom: 12px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #e53935; box-shadow: 0 0 0 4px rgba(229, 57, 53, .15); animation: pulse 1.6s infinite; }
.live-list { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .9rem; }
.act-login { background: var(--green-100); color: var(--green-700); }
.act-ptz { background: #fff1dc; color: #8a5a00; }
.act-recording, .act-recordings { background: #e6ecf8; color: #34508a; }
.act-admin { background: #eceaf6; color: #4d3f8f; }

/* --- Direct + PTZ --- */
.live-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.ptz .card-title { margin-bottom: 14px; }
.ptz-pad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 64px); gap: 6px; justify-content: center; margin: 4px auto 16px; }
.ptz-btn { display: grid; place-items: center; border: 1px solid var(--border); background: #fff; border-radius: 14px; color: var(--ink); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; transition: background .1s, color .1s, transform .05s; }
.ptz-btn:hover { border-color: var(--green-500); color: var(--green-700); }
.ptz-btn.pressed { background: var(--green-500); border-color: var(--green-500); color: #fff; transform: scale(.96); }
.ptz-btn .ic { width: 26px; height: 26px; }
.ptz-btn.up { grid-area: 1 / 2; }
.ptz-btn.left { grid-area: 2 / 1; } .ptz-btn.left .ic { transform: rotate(-90deg); }
.ptz-btn.right { grid-area: 2 / 3; } .ptz-btn.right .ic { transform: rotate(90deg); }
.ptz-btn.down { grid-area: 3 / 2; } .ptz-btn.down .ic { transform: rotate(180deg); }
.ptz-center { grid-area: 2 / 2; display: grid; place-items: center; border-radius: 50%; background: var(--gradient); color: #fff; }
.ptz-zoom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); font-weight: 500; color: var(--ink); }
.ptz-zoom .btn { touch-action: none; user-select: none; }
.ptz-zoom .btn.pressed { background: var(--green-500); color: #fff; border-color: var(--green-500); }
.ptz-sub { font-size: .9rem; margin: 16px 0 10px; }
.ptz-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.ptz-msg { color: var(--danger); margin: 10px 0 0; }

/* --- Enregistrements : lecteur + frise à gauche, liste repliable à hauteur fixe à droite --- */
.day-picker { display: flex; align-items: center; gap: 8px; }
.rec-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.rec-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rec-player { padding: 0; overflow: hidden; }
.rec-player .cam-frame { max-height: 62vh; }
.rec-player .cam-frame[data-state=idle] .spinner { display: none; }
.rec-player .cam-status .ic { width: 36px; height: 36px; opacity: .6; }
.cam-frame[data-state=idle] .cam-status { display: flex; }
.rec-now { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.rec-now-txt { display: flex; flex-direction: column; min-width: 0; }
.rec-now strong { color: var(--ink); }
.rec-nav { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }

.timeline { padding: 14px 16px 10px; }
.tl-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; font-size: .88rem; }
.tl-head strong { color: var(--ink); }
.tl-legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8rem; }
.tl-legend i { width: 12px; height: 8px; border-radius: 2px; margin-left: 8px; }
.tl-legend i.kind-continuous { background: var(--green-500); }
.tl-legend i.kind-motion { background: #f08c00; }
.tl-track { position: relative; height: 44px; border-radius: 8px; background: repeating-linear-gradient(90deg, #eef2eb 0 1px, transparent 1px calc(100% / 24)), #f7f9f5; border: 1px solid var(--border); }
.tl-lane { position: absolute; left: 0; right: 0; }
.lane-rec { top: 22px; height: 16px; }
.lane-motion { top: 5px; height: 14px; }
.tl-seg { position: absolute; top: 0; bottom: 0; min-width: 3px; padding: 0; border: 0; border-radius: 3px; background: var(--green-300); cursor: pointer; transition: filter .1s, box-shadow .1s; }
.tl-seg.kind-continuous { background: var(--green-500); opacity: .55; }
.tl-seg.kind-motion { background: #f08c00; }
.tl-seg.kind-alarm { background: var(--danger); }
.tl-seg.kind-manual { background: #3d6bd6; }
.tl-seg:hover { filter: brightness(1.1); opacity: 1; z-index: 2; }
.tl-seg.on { opacity: 1; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); z-index: 3; }
.only-motion .lane-rec { opacity: .25; }
.tl-now { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #e53935; border-radius: 2px; }
.tl-scale { position: relative; height: 18px; margin-top: 4px; font-size: .72rem; color: var(--muted); }
.tl-scale span { position: absolute; transform: translateX(-50%); }
.tl-scale span:first-child { transform: none; }
.tl-scale span:last-child { transform: translateX(-100%); }

.rec-side { padding: 0; display: flex; flex-direction: column; position: sticky; top: 90px; max-height: calc(100vh - 110px); }
.rec-side-head { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.rec-side-head .chips { margin: 0; }
.rec-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 6px 8px 10px; }
.rec-empty { padding: 24px 8px; }
.rec-hour { border-bottom: 1px solid var(--border); }
.rec-hour:last-child { border-bottom: 0; }
.rec-hour summary { display: flex; align-items: center; gap: 10px; padding: 10px 8px; cursor: pointer; list-style: none; border-radius: 8px; font-size: .88rem; }
.rec-hour summary::-webkit-details-marker { display: none; }
.rec-hour summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
.rec-hour[open] summary::before { transform: rotate(45deg); }
.rec-hour summary:hover { background: var(--green-50); }
.rec-hour-label { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.rec-hour-count { color: var(--muted); font-size: .8rem; flex: 1; }
.rec-items { display: flex; flex-direction: column; gap: 2px; padding: 0 0 8px 20px; }
.rec-item { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 10px; width: 100%; font: inherit; font-size: .84rem; text-align: left; padding: 7px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); cursor: pointer; }
.rec-item:hover { background: var(--green-50); }
.rec-item.on { background: var(--green-100); box-shadow: inset 3px 0 0 var(--green-500); }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa3b5; }
.kind-motion .rec-dot { background: #f08c00; }
.kind-alarm .rec-dot { background: var(--danger); }
.kind-continuous .rec-dot { background: var(--green-500); }
.kind-manual .rec-dot { background: #3d6bd6; }
.rec-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.rec-reason { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-dur { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }

@media (max-width: 1000px) {
    .live-layout, .rec-layout { grid-template-columns: 1fr; }
    .rec-side { position: static; max-height: none; }
    .rec-scroll { max-height: 50vh; }
}
@media (max-width: 700px) {
    .rec-player .cam-frame { max-height: none; }
    .rec-nav .btn span { display: none; }
    .tl-scale span:nth-child(even) { visibility: hidden; }
    .day-picker { width: 100%; }
    .day-picker input { flex: 1; }
}


/* --- Menu déroulant (Effacer le journal) --- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 300px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(38, 43, 58, .14); padding: 6px; }
.menu-panel form { margin: 0; }
.menu-item { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; font: inherit; padding: 10px 12px; border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--text); }
.menu-item small { color: var(--muted); font-size: .78rem; }
.menu-item:hover { background: var(--green-50); }
.menu-item.danger strong { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-bg); }
@media (max-width: 700px) { .menu-panel { right: auto; left: 0; width: min(300px, calc(100vw - 32px)); } }

/* --- Vidéo fluide (go2rtc) --- */
div.cam-media video-stream, div.cam-media video-stream video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
div.cam-media video { object-fit: contain; background: #000; }

/* --- Résidences, inscriptions --- */
.role-en_attente { background: var(--warn-bg); color: var(--warn); }
.nav-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px; border-radius: 99px; background: #e53935; color: #fff; font-size: .7rem; font-weight: 700; }
.pending-card { margin-bottom: 20px; border-color: #f1dea6; background: linear-gradient(0deg, #fff, var(--warn-bg)); }
.signup-note { margin-bottom: 16px; }
.signup-note p { margin: 6px 0 0; color: var(--muted); }
.auth-signup { margin-top: 12px; }
.res-items { padding: 0; }
.nvr-assign .check-group-head small { margin-left: auto; }
.check .other-res { font-size: .75rem; color: var(--muted); }
.res-stats { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.res-stats span { display: inline-flex; align-items: center; gap: 6px; }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
textarea { resize: vertical; min-height: 70px; }
.consent { align-items: flex-start; font-size: .82rem; color: var(--muted); }
.consent input { margin-top: 2px; }
.auth-card .empty-icon { margin-bottom: 12px; }
.is-pending [data-cameras-list] { display: none; }
.pending-note { display: none; align-items: center; gap: 8px; background: var(--warn-bg); color: var(--warn); padding: 12px 16px; border-radius: 10px; margin: 0; }
.is-pending .pending-note { display: flex; }

.tl-track { cursor: pointer; }
.tl-cursor { position: absolute; top: -4px; bottom: -4px; width: 3px; margin-left: -1px; background: var(--ink); border-radius: 2px; pointer-events: none; z-index: 4; box-shadow: 0 0 0 2px #fff; }

/* --- Mur d'images : vignette sans flux --- */
a.cam-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #cfd8cc; text-decoration: none; font-size: .9rem; background: radial-gradient(circle at center, #1f2a22, #111512); }
a.cam-placeholder .ic { width: 36px; height: 36px; color: var(--green-300); }
a.cam-placeholder:hover { color: #fff; }
.cam-frame[data-wall] .live-badge i { background: var(--green-300); animation: none; }

/* --- Multivue --- */
.mv-toolbar { align-items: center; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn { font: inherit; font-size: .85rem; font-weight: 500; padding: 7px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; white-space: nowrap; }
.seg-btn:hover { background: var(--green-50); }
.seg-btn.on { background: var(--green-500); color: #fff; }
.mv-grid { display: grid; gap: 8px; background: #0d110e; padding: 8px; border-radius: var(--radius); margin-bottom: 12px; }
.mv-grid.mv-n1 { grid-template-columns: 1fr; }
.mv-grid.mv-n4 { grid-template-columns: repeat(2, 1fr); }
.mv-grid.mv-n9, .mv-grid.mv-n6 { grid-template-columns: repeat(3, 1fr); }
.mv-grid.mv-n16 { grid-template-columns: repeat(4, 1fr); }
.mv-grid.mv-n6 .mv-tile:first-of-type { grid-column: span 2; grid-row: span 2; }
.mv-tile { position: relative; background: #151a17; border-radius: 8px; overflow: hidden; min-width: 0; }
.mv-body .cam-frame { border-radius: 0; }
.mv-body { cursor: zoom-in; }
.mv-tile.on .mv-body { cursor: zoom-out; }
.mv-empty { aspect-ratio: 16 / 9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #7f8b82; font-size: .85rem; }
.mv-empty span { font-size: 2rem; line-height: 1; color: var(--green-300); }
.mv-bar { position: absolute; left: 6px; right: 6px; top: 6px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; z-index: 5; }
.mv-tile:hover .mv-bar, .mv-tile:focus-within .mv-bar, .mv-body:has(.mv-empty) + .mv-bar { opacity: 1; }
.mv-bar select { flex: 1; min-width: 0; padding: 6px 30px 6px 10px !important; font-size: .82rem; background-color: rgba(255, 255, 255, .95); }
.mv-bar .icon-btn { width: 32px; height: 32px; flex: none; background: rgba(255, 255, 255, .95); font-size: 1rem; }
.mv-grid .live-badge { top: auto; bottom: 8px; left: 8px; }
.mv-grid.mv-focus { grid-template-columns: 1fr !important; }
.mv-grid.mv-focus .mv-tile:not(.on) { display: none; }
.mv-grid.mv-focus .mv-tile.on { grid-column: auto; grid-row: auto; }
.mv-grid:fullscreen { display: grid; align-content: center; border-radius: 0; height: 100vh; overflow: auto; }
@media (max-width: 700px) {
    .mv-grid.mv-n9, .mv-grid.mv-n16, .mv-grid.mv-n6 { grid-template-columns: repeat(2, 1fr); }
    .mv-grid.mv-n6 .mv-tile:first-of-type { grid-column: span 2; grid-row: auto; }
    .mv-bar { opacity: 1; }
    .seg-btn { padding: 7px 9px; }
}

/* --- Configuration groupée --- */
.bulk { margin-bottom: 20px; }
.bulk-bar { position: sticky; top: 72px; z-index: 6; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); }
.bulk-count { color: var(--muted); font-size: .88rem; flex: 1; }
.bulk-panel { margin-top: 12px; }
.bulk-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 12px; max-height: 190px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.col-check { width: 44px; padding-right: 0 !important; }
.residence-title .bulk-group { display: inline-flex; padding: 0; }
.danger-text { color: var(--danger); margin-right: auto; }
.danger-text:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
@media (max-width: 700px) { .table td.col-check { padding: 0 0 4px !important; } .bulk-bar { top: 64px; } }

/* =============================================================================================
   Téléphones et tablettes
   ============================================================================================= */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.footer { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
html.no-scroll, html.no-scroll body { overflow: hidden; }

/* Plein écran de secours (iPhone) */
.pseudo-fs { position: fixed !important; inset: 0; z-index: 1000; margin: 0 !important; border-radius: 0 !important; background: #000;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) !important;
    display: grid; align-content: center; overflow: auto; }
.pseudo-fs .cam-frame { border-radius: 0; }
.pseudo-fs-close { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); z-index: 1001;
    width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 1.8rem; line-height: 1; cursor: pointer; }

/* Écrans tactiles : pas de survol, cibles plus grandes, pas de zoom automatique sur les champs (iPhone) */
@media (hover: none) {
    .mv-bar { opacity: 1; }
    .cam-card:hover, .stat:hover { transform: none; }
    input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], input[type=tel], input[type=date], textarea, select { font-size: 16px; }
    .icon-btn { width: 40px; height: 40px; }
}

/* Tablettes */
@media (max-width: 1100px) {
    .container { padding-left: 20px; padding-right: 20px; }
    .cam-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

/* Téléphones */
@media (max-width: 700px) {
    .page-head { margin-bottom: 18px; }
    .page-head .actions { width: 100%; }
    .page-head .actions .btn { flex: 1 1 auto; }

    /* Tableau de bord : compteurs sur 2 colonnes */
    .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat { padding: 14px; grid-template-columns: 1fr; row-gap: 6px; }
    .stat-icon { grid-row: auto; width: 38px; height: 38px; }
    .stat-num { font-size: 1.4rem; }

    /* Mur d'images : 2 colonnes, légendes compactes */
    .cam-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .cam-meta { padding: 8px 10px; gap: 6px; }
    .cam-meta strong { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .cam-meta .muted { display: none; }
    .cam-meta .row-actions { padding-top: 0 !important; gap: 4px; }
    .cam-meta .icon-btn { width: 32px; height: 32px; }
    .cam-meta .icon-btn .ic { width: 16px; height: 16px; }
    .live-badge { top: 6px; left: 6px; padding: 3px 7px; font-size: .62rem; }
    .cam-grid .cam-status-msg { display: none; }

    /* Page caméra : autres caméras en bandeau horizontal */
    .cam-links { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
    .cam-links a { flex: 0 0 auto; scroll-snap-align: start; padding: 10px 14px; }

    /* Listes admin : lignes compactes (nom + infos sur une ligne, actions à droite) */
    .table tr { display: grid !important; grid-template-columns: auto 1fr auto; column-gap: 10px; row-gap: 4px; align-items: center; padding: 12px 14px; }
    .table td { padding: 0 !important; }
    .table td[data-label]:not(:first-child)::before { content: none; }
    .table td.col-check { grid-row: span 2; }
    .table td[data-label]:first-of-type, .table td.col-check + td { grid-column: 2; }
    .table td.row-actions { grid-column: 3; grid-row: 1 / span 2; justify-content: flex-end; padding-top: 0 !important; flex-wrap: nowrap; }
    .table td:not(.col-check):not(.row-actions):not(:first-child):not(.col-check + td):not([data-label="Type"]) { grid-column: 2; display: inline-flex !important; width: auto; font-size: .8rem; color: var(--muted); }
    .table tr > td:not(.col-check):not(.row-actions) + td:not(.row-actions) { margin-right: 6px; }
    .table .cell-user .stat-icon.sm { display: none; }
    .table .cell-user small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
    .table-card .table tbody { display: block; }
    .table-card .table td.mono { font-size: .72rem; }

    /* Barre de sélection groupée */
    .bulk-bar { gap: 8px 12px; }
    .bulk-count { order: 3; flex-basis: 100%; }

    /* Multivue : petites cases lisibles */
    .mv-grid { gap: 4px; padding: 4px; }
    .mv-bar { left: 4px; right: 4px; top: 4px; }
    .mv-bar select { font-size: 13px !important; padding: 4px 24px 4px 8px !important; height: 30px; }
    .mv-bar .icon-btn { width: 30px; height: 30px; }
    .mv-grid .cam-status-msg { display: none; }
    .mv-grid .live-badge { display: none; }
    .mv-toolbar { width: 100%; }
    .mv-toolbar .seg { flex: 1; justify-content: space-between; }
    .mv-toolbar .btn { flex: 1; }

    /* Journal */
    .filters .field { flex-basis: calc(50% - 7px); }
    .tabs { overflow-x: auto; }
    .live-list { flex-direction: column; gap: 6px; }
}
@media (max-width: 380px) {
    .cam-grid { grid-template-columns: 1fr; }
    .cam-meta .muted { display: block; }
}
@media (max-width: 700px) {
    .table td { width: auto !important; }
    .table td.row-actions { display: flex !important; gap: 4px; align-self: start; }
    .table td[data-label="Type"] { display: none !important; }
}
@media (max-width: 700px) {
    .table td.row-actions .icon-btn { width: 34px; height: 34px; }
    .table td.row-actions .icon-btn .ic { width: 16px; height: 16px; }
    .table tr { grid-template-columns: auto minmax(0, 1fr) auto; }
}

/* --- Frise zoomable --- */
.tl-zoom { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.tl-zoom .icon-btn { width: 32px; height: 32px; }
.tl-viewport { overflow-x: auto; overflow-y: hidden; touch-action: none; padding: 4px 0 2px; scrollbar-width: thin; cursor: grab; }
.tl-viewport:active { cursor: grabbing; }
.tl-inner { position: relative; width: 100%; min-width: 100%; }
.tl-viewport.zoomed .tl-track { background: repeating-linear-gradient(90deg, #e3eadf 0 1px, transparent 1px calc(100% / 96)), repeating-linear-gradient(90deg, #cfdcc7 0 1px, transparent 1px calc(100% / 24)), #f7f9f5; }
.tl-scale span { white-space: nowrap; }
@media (max-width: 700px) { .tl-scale span:nth-child(even) { visibility: visible; } .tl-zoom { width: 100%; justify-content: flex-end; } }

/* --- Zoom numérique sur l'image --- */
[data-zoomable] .cam-frame { touch-action: pan-x pan-y; }
[data-zoomable] .cam-frame .cam-media { will-change: transform; }
.cam-frame.zoomed { cursor: grab; }
.cam-frame.zoomed:active { cursor: grabbing; }
.zoom-hud { position: absolute; right: 10px; bottom: 10px; z-index: 6; display: none; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; background: rgba(0, 0, 0, .6); color: #fff; backdrop-filter: blur(4px); font-size: .8rem; }
.cam-frame.zoomed .zoom-hud { display: inline-flex; }
.zoom-hud button { min-width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.zoom-hud button:hover { background: rgba(255, 255, 255, .15); }
.zoom-hud [data-z-label] { min-width: 36px; text-align: center; font-variant-numeric: tabular-nums; }
.mv-grid .zoom-hud { right: 4px; bottom: 4px; transform: scale(.85); transform-origin: bottom right; }

/* --- Inscriptions en attente --- */
.nav-toggle { position: relative; }
.toggle-badge { position: absolute; top: 2px; right: 0; box-shadow: 0 0 0 2px #fff; }
.table tr.row-pending { background: #fff6e0; box-shadow: inset 4px 0 0 #e53935; }
.table tr.row-pending:hover { background: #fdeccc; }

/* =============================================================================================
   Page caméra tout-en-un
   ============================================================================================= */
.player-card { padding: 0; overflow: hidden; }
.player-card .cam-view .cam-frame { border-radius: 0; box-shadow: none; }
.player-card .cam-view { background: #151a17; }
.player-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; }
.player-bar-txt { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; flex-wrap: wrap; }
.player-info { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-bar-actions { display: flex; align-items: center; gap: 6px; }
.mode-pill { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 4px 10px; border-radius: 99px; background: var(--green-100); color: var(--green-700); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.mode-pill i { width: 8px; height: 8px; border-radius: 50%; background: #e53935; animation: pulse 1.6s infinite; }
.mode-pill.rec { background: #e6ecf8; color: #34508a; }
.mode-pill.rec i { background: #34508a; animation: none; }
.dot-live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .3); }
.rec-badge i { background: #7aa2ff !important; animation: none !important; }
.cam-frame[data-state=idle] .cam-status { display: flex; }

.rec-panel { margin-top: 20px; padding: 18px 20px; }
.rec-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rec-panel-head .card-title { margin: 0; }
.rec-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.rec-summary strong { color: var(--ink); }
.rec-summary .chips { margin: 0; }
.rec-panel .timeline { padding: 0; }
.rec-panel .tl-head { justify-content: space-between; }
.rec-list-wrap { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.rec-list-wrap > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-weight: 500; color: var(--ink); font-size: .9rem; padding: 6px 0; }
.rec-list-wrap > summary::-webkit-details-marker { display: none; }
.rec-list-wrap > summary .ic { color: var(--green-600); }
.rec-list-wrap .rec-scroll { max-height: 360px; margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; }
.only-motion .lane-rec { opacity: .25; }
.rec-loading { display: flex; align-items: center; gap: 10px; padding: 14px 0; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; border-color: rgba(90, 167, 72, .25); border-top-color: var(--green-500); }
.rec-empty { padding: 18px 0; }

/* Mur d'images : toute la vignette est cliquable */
a.cam-card { display: block; color: inherit; text-decoration: none; }
a.cam-card .cam-frame { pointer-events: none; }
.cam-open { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--border); color: var(--ink); flex: none; }
a.cam-card:hover .cam-open { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }
div.cam-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #cfd8cc; font-size: .9rem; background: radial-gradient(circle at center, #1f2a22, #111512); }
div.cam-placeholder .ic { width: 36px; height: 36px; color: var(--green-300); }

@media (max-width: 700px) {
    .rec-panel { padding: 14px; }
    .player-bar { padding: 8px 10px; }
    .player-bar-actions { width: 100%; justify-content: flex-end; }
    .player-bar-actions [data-go-live] { margin-right: auto; order: -1; }
    .cam-open { width: 28px; height: 28px; }
    .cam-open .ic { width: 15px; height: 15px; }
}
/* La vidéo ne pousse pas la frise hors de l'écran sur les grands écrans */
.player-card .cam-view .cam-frame { max-height: 64vh; margin: 0 auto; }
.player-card .cam-view:fullscreen .cam-frame, .player-card .cam-view.pseudo-fs .cam-frame { max-height: none; }

/* --- Caméras masquées du mur --- */
.tag-wall-off { background: #eef1f4; color: var(--muted); }
.icon-btn.is-off { color: var(--muted); background: #eef1f4; }

.table tr.row-disabled td:not(.row-actions) { opacity: .55; }

.notify-card { padding: 16px 20px; }
.notify-card p { margin: 8px 0 0; }

/* =============================================================================================
   Accueil syndics / propriétaires
   ============================================================================================= */
.welcome { position: relative; overflow: hidden; background: var(--gradient); color: #fff; border-radius: 24px; padding: 44px 40px; margin-bottom: 20px; box-shadow: 0 20px 44px rgba(47, 90, 60, .22); }
.welcome::before, .welcome::after { content: ""; position: absolute; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .16); pointer-events: none; }
.welcome::before { width: 520px; height: 520px; right: -170px; top: -250px; }
.welcome::after { width: 300px; height: 300px; right: 60px; bottom: -200px; background: rgba(255, 255, 255, .06); }
.welcome-inner { position: relative; z-index: 1; max-width: 640px; }
.welcome-eyebrow { display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .18); padding: 6px 14px; border-radius: 99px; font-size: .8rem; font-weight: 600; margin-bottom: 16px; }
.welcome h1 { color: #fff; font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 8px; }
.welcome p { margin: 0; font-size: 1.05rem; opacity: .95; }
.welcome p strong { color: #fff; }
.welcome-ctas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.btn-white { background: #fff; color: var(--green-700); box-shadow: 0 6px 20px rgba(0, 0, 0, .12); }
.btn-white:hover { color: var(--green-900); }
.btn-glass { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn-glass:hover { background: rgba(255, 255, 255, .26); color: #fff; }

.closure { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; background: #fff6e0; border: 1px solid #f1dea6; border-radius: 18px; padding: 22px 24px; margin-bottom: 24px; }
.closure-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: #fff; color: #8a6100; }
.closure-ico .ic { width: 24px; height: 24px; }
.closure h2 { font-size: 1.1rem; color: #6d4c00; margin-bottom: 6px; }
.closure p { margin: 0 0 6px; color: #5b4a1d; font-size: .93rem; }
.closure p.muted { color: #8a7440; margin: 0; }

.home-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 8px; }
.home-tile { display: flex; flex-direction: column; gap: 4px; padding: 22px; border-radius: 18px; background: #fff; border: 1px solid var(--border); text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.home-tile:hover { transform: translateY(-3px); border-color: var(--green-300); }
.home-tile-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--green-100); color: var(--green-700); margin-bottom: 10px; }
.home-tile.green .home-tile-ico { background: var(--gradient); color: #fff; box-shadow: 0 8px 18px rgba(90, 167, 72, .3); }
.home-tile.ink .home-tile-ico { background: linear-gradient(135deg, #3a4260, var(--ink) 60%, #6d759a); color: #fff; }
.home-tile-ico .ic { width: 22px; height: 22px; }
.home-tile strong { color: var(--ink); font-size: 1.02rem; }
.home-tile > span:last-child { color: var(--muted); font-size: .85rem; }

.home-res { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.home-res-card h3 { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; margin-bottom: 14px; }
.home-res-card h3 .ic { color: var(--green-600); }
.home-cams { display: flex; flex-wrap: wrap; gap: 8px; }
.home-cam { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--border); background: #fff; color: var(--ink); text-decoration: none; font-size: .88rem; font-weight: 500; }
.home-cam:hover { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }
.home-cam .ic { width: 16px; height: 16px; color: var(--green-600); }

@media (max-width: 1000px) { .home-tiles { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) {
    .welcome { padding: 30px 22px; border-radius: 20px; }
    .welcome-ctas .btn { flex: 1 1 auto; }
    .closure { grid-template-columns: 1fr; padding: 18px; gap: 10px; }
    .home-tiles { gap: 10px; }
    .home-tile { padding: 16px; }
    .home-tile > span:last-child { font-size: .8rem; }
}

.home-residence { margin-bottom: 26px; }
.home-cams-more { margin-top: 12px; }

.home-tiles.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1000px) { .home-tiles.three { grid-template-columns: 1fr 1fr; } }

/* --- Adresse des résidences --- */
.res-address { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -6px 0 14px; color: var(--muted); font-size: .88rem; }
.res-address .ic { width: 16px; height: 16px; color: var(--green-600); }
.res-address a { font-weight: 500; font-size: .82rem; }

/* --- Détection automatique --- */
.detect-card { margin-bottom: 20px; max-width: 900px; border-color: #cfe5c3; background: linear-gradient(0deg, #fff, var(--green-50)); }
.detect-grid { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 12px; align-items: end; margin-top: 10px; }
.detect-grid .btn { height: 44px; }
.detect-result { margin-top: 16px; padding: 14px 16px; border-radius: 12px; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.detect-result.ok { background: #fff; border: 1px solid #cfe5c3; }
.detect-result.ok strong { color: var(--green-700); }
.detect-result.ko { background: #fff6e0; border: 1px solid #f1dea6; color: #6d4c00; }
.detect-result .warn { color: var(--danger); }
.detect-result .btn { align-self: flex-start; margin-top: 4px; }
@media (max-width: 800px) { .detect-grid { grid-template-columns: 1fr; } }

/* --- Afficher le mot de passe --- */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.pw-toggle:hover, .pw-toggle.on { color: var(--green-700); background: var(--green-50); }

/* --- Accès en lecture seule (fiches caméra et résidence) --- */
.viewers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.viewers li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.viewers a { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.viewers a:hover strong { color: var(--green-700); text-decoration: underline; }
.readonly-value { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 6px 0 0; min-height: 40px; }
/* Fiche utilisateur : caméra déjà incluse par une résidence cochée */
.check .via-res { display: none; margin-left: 6px; }
.check.covered { opacity: .6; }
.check.covered .via-res { display: inline-block; }

/* --- Vitesse de lecture des enregistrements --- */
.seg-sm { padding: 2px; }
.seg-sm .seg-btn { font-size: .78rem; padding: 5px 9px; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .player-bar-actions { flex-wrap: wrap; justify-content: flex-end; } }

/* --- Téléchargement d'une période --- */
.rec-export { margin: 0 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--green-50); }
.rec-export > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 8px; list-style: none; color: var(--green-700); }
.rec-export > summary::-webkit-details-marker { display: none; }
.rec-export-body { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 0 14px 12px; }
.rec-export-body .field { margin: 0; min-width: 210px; }
.rec-export-body .field span { font-size: .78rem; }
.rec-export-info { flex-basis: 100%; margin: 0; display: flex; align-items: center; gap: 6px; }
[data-export-select].on { background: var(--green-500); color: #fff; border-color: var(--green-500); }
.tl-sel { position: absolute; top: 0; bottom: 0; background: rgba(90, 167, 72, .22); border-left: 2px solid var(--green-600); border-right: 2px solid var(--green-600); pointer-events: none; z-index: 3; }
.tl-viewport.selecting, .tl-viewport.selecting .tl-seg { cursor: crosshair; }
.tl-viewport.selecting { touch-action: none; outline: 2px dashed var(--green-500); outline-offset: 2px; }
@media (max-width: 560px) { .rec-export-body .field { min-width: 0; flex: 1 1 100%; } }

/* Détections à leur vraie durée : un minimum en pixels pour rester visibles et cliquables sans se recouvrir quand on zoome. */
.tl-seg { min-width: 3px; }
.lane-motion .tl-seg:hover { z-index: 2; filter: brightness(1.15); }

/* Menu admin (8 entrées) sur écrans d'ordinateur moyens : plus compact pour ne pas déborder. */
@media (min-width: 1361px) {
    .topbar-inner:has(.nav-admin) .brand-tag { display: none; }
    .nav-admin .nav-user-txt { display: none; }
    .nav-admin > a { padding: 8px 10px; font-size: .88rem; }
    .topbar-inner:has(.nav-admin) { gap: 14px; max-width: 1440px; }
    .nav-admin { gap: 2px; }
}
input[type=datetime-local], input[type=date] {
    font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--text);
}
.rec-export-body input[type=datetime-local] { width: 100%; }

/* État des caméras */
.cam-frame.is-offline .cam-media { filter: grayscale(1) brightness(.45); }
.cam-frame.is-offline .live-badge { display: none; }
.off-badge { position: absolute; top: 12px; left: 12px; z-index: 3; background: #b3261e; color: #fff; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px; }
.mv-grid .off-badge, .cam-frame[data-wall] .off-badge { top: 6px; left: 6px; padding: 3px 8px; font-size: .62rem; }
.stat.has-offline .stat-num { color: #b3261e; }
.offline-box { margin-bottom: 18px; border-left: 4px solid #b3261e; }
.offline-box ul { margin: 6px 0 0; padding-left: 18px; }
