/* ==========================================================================
   Residencia Universitaria de Jaca — Design system
   Sobre, clair, lisible. Couleurs désaturées, pas de néon.
   ========================================================================== */

:root {
    --bg: #eceff3;               /* fond de la coquille (autour du canevas) */
    --canvas: #f7f8fa;           /* zone de contenu principale */
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --border: #e3e6eb;
    --border-strong: #cbd1d8;

    --text: #1c2430;
    --text-2: #445063;
    --muted: #667080;            /* contraste ≥ 4,5:1 sur blanc */

    --brand: #2d4a68;            /* couleur de marque fixe (logo, connexion) */
    --primary: #2e5a8f;
    --primary-hover: #264b77;
    --primary-soft: #eaf0f7;
    --on-primary: #ffffff;
    --ring: 0 0 0 3px rgba(46, 90, 143, .18);

    /* Plans */
    --wall: #8d96a1;
    --wall-thin: #bfc5cc;
    --corridor-a: #f6f7f8;
    --corridor-b: #eff1f3;
    --off-hatch: rgba(156, 82, 72, .16);

    --toast-bg: #1c2430;
    --toast-text: #ffffff;
    --overlay: rgba(16, 24, 40, .38);

    /* États (tons désaturés) */
    --ok: #4a7657;      --ok-bg: #e4efe7;   --ok-border: #bcd4c3;
    --warn: #8f6f34;    --warn-bg: #f5ecda; --warn-border: #e0cd9f;
    --off: #9c5248;     --off-bg: #f3e2df;  --off-border: #ddb6ae;
    --info: #3e5f86;    --info-bg: #e7edf5; --info-border: #c3d1e2;
    --neutral: #6b7380; --neutral-bg: #eef0f3;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .03);
    --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, .10), 0 2px 4px -2px rgba(16, 24, 40, .05);
    --shadow-lg: 0 20px 44px -12px rgba(16, 24, 40, .22);
    --ease: cubic-bezier(.2, .8, .2, 1);

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    color-scheme: light;
}

/* Thème sombre : appliqué via data-theme (choix manuel ou préférence système) */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0d10;
    --canvas: #101317;
    --surface: #161a1f;
    --surface-2: #1b2026;
    --border: #262c34;
    --border-strong: #363e48;

    --text: #e5e8ec;
    --text-2: #bac1ca;
    --muted: #8e97a3;

    --primary: #8fb3e0;
    --primary-hover: #a8c5ea;
    --primary-soft: #1b2636;
    --on-primary: #0d1522;
    --ring: 0 0 0 3px rgba(143, 179, 224, .25);

    --ok: #8fbf9c;      --ok-bg: #1d2a22;   --ok-border: #34503d;
    --warn: #d4b77a;    --warn-bg: #2c2618; --warn-border: #574a2a;
    --off: #dc9d93;     --off-bg: #2e1f1d;  --off-border: #5a3832;
    --info: #9ab4d4;    --info-bg: #1c2532; --info-border: #33445a;
    --neutral: #9aa2ad; --neutral-bg: #232830;

    --wall: #5d6672;
    --wall-thin: #343b44;
    --corridor-a: #1b1f24;
    --corridor-b: #20252b;
    --off-hatch: rgba(220, 157, 147, .14);

    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, .5);
    --shadow-lg: 0 20px 44px -12px rgba(0, 0, 0, .65);
    --toast-bg: #e5e8ec;
    --toast-text: #111418;
    --overlay: rgba(0, 0, 0, .55);
}

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

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 600; letter-spacing: -0.01em; font-family: var(--font-display); }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p { margin: 0; }

.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.mono { font-family: var(--mono); font-feature-settings: 'tnum'; }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.xsmall { font-size: 11px; }
.strong { font-weight: 600; }
.right, .table .right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------------------
   Layout utilitaire
   -------------------------------------------------------------------------- */
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.grid-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }

@media (max-width: 1280px) {
    .grid-main-side { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main-side, .grid-7-5 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Coquille de l'application
   -------------------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; background: var(--bg); }

.sidebar {
    width: 262px;
    flex-shrink: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: block; box-shadow: var(--shadow-md); }
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.2; font-family: var(--font-display); letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--muted); }

.nav { padding: 12px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; border-radius: 10px; margin-bottom: 2px;
    color: var(--text-2); font-weight: 500;
    transition: background .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.nav-link i {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 12px; transition: inherit;
}
.nav-link:hover { background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.nav-link.active i { background: var(--primary-soft); color: var(--primary); }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); font-variant-numeric: tabular-nums; }

.sidebar-foot { padding: 12px; }
.sidebar-foot .user-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 10px 10px 12px; box-shadow: var(--shadow); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--neutral-bg); color: var(--text-2);
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Canevas : la zone de travail flotte au-dessus du fond, avec un léger halo en haut */
.app > .main {
    margin: 10px 10px 10px 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: radial-gradient(1100px 260px at 50% -110px, var(--primary-soft), transparent 70%), var(--canvas);
    box-shadow: var(--shadow); overflow: clip;
}
.main-public { background: radial-gradient(1200px 300px at 50% -80px, var(--primary-soft), transparent 70%), var(--canvas); }
.content { flex: 1; padding: 32px 36px 44px; max-width: 1440px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 6px; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--primary); letter-spacing: .02em; margin-bottom: 6px; display: inline-flex; align-items: center; gap: 6px; }

.app-footer { padding: 16px 36px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: transparent; }

/* Barre supérieure (résidents + mobile admin) */
.topbar {
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 28px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { padding: 7px 12px; border-radius: 9px; color: var(--text-2); font-weight: 500; transition: background .15s var(--ease); }
.topnav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.topnav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.topnav a.active i { color: var(--primary); }
.content-narrow { max-width: 1200px; margin: 0 auto; padding: 28px 24px 48px; width: 100%; flex: 1; }

.mobile-bar { display: none; }
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: none; }
    .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: color-mix(in srgb, var(--surface) 85%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
    .app > .main { margin: 0; border: 0; border-radius: 0; }
    .sidebar { background: var(--surface); }
    .content { padding: 20px 16px 32px; }
    .topnav a span { display: none; }
}

/* Sélecteur de langue */
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.lang-switch button {
    border: 0; background: transparent; padding: 3px 8px; font: inherit; font-size: 11px; font-weight: 600;
    color: var(--muted); cursor: pointer;
}
.lang-switch button + button { border-left: 1px solid var(--border); }
.lang-switch button.active { background: var(--primary-soft); color: var(--primary); }

/* --------------------------------------------------------------------------
   Cartes
   -------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s var(--ease); }
a.card:hover, .card.hoverable:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); text-decoration: none; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* Indicateurs clés */
.kpi { padding: 18px 20px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }
.kpi-icon.ok { background: var(--ok-bg); color: var(--ok); }
.kpi-icon.warn { background: var(--warn-bg); color: var(--warn); }
.kpi-icon.off { background: var(--off-bg); color: var(--off); }
.kpi-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-value .unit { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi-note { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Liste clé / valeur */
.kv { display: grid; grid-template-columns: 1fr auto; row-gap: 10px; column-gap: 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Onglets
   -------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; position: relative; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-ink { position: absolute; bottom: 0; height: 2px; border-radius: 2px; background: var(--primary); transition: left .3s var(--ease), width .3s var(--ease); pointer-events: none; }
.tab {
    appearance: none; border: 0; background: none; font: inherit; cursor: pointer;
    padding: 10px 14px; color: var(--muted); font-weight: 500; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; }
.tabs:not(.has-ink) .tab.active { border-bottom-color: var(--primary); }
.tab .count { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--neutral-bg); color: var(--text-2); font-weight: 600; }
.tab.active .count { background: var(--primary-soft); color: var(--primary); }

.segmented { display: inline-flex; background: var(--neutral-bg); border-radius: 10px; padding: 3px; gap: 2px; border: 1px solid var(--border); }
.segmented button {
    border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
    padding: 5px 12px; border-radius: 5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px;
}
.segmented button { border-radius: 7px !important; transition: background .15s var(--ease), color .15s var(--ease); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--border); font-weight: 600; }

/* --------------------------------------------------------------------------
   Boutons & formulaires
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
    transition: background .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease), border-color .15s var(--ease);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, #fff), var(--primary));
    border-color: var(--primary); color: var(--on-primary);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 1px 2px rgba(16, 24, 40, .14), 0 2px 6px -2px color-mix(in srgb, var(--primary) 50%, transparent);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost, .btn-ghost:hover { box-shadow: none; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--neutral-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.input, .select {
    font: inherit; font-size: 14px; color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: 8px 10px; background: var(--surface); width: 100%;
}
.input, .select { transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.input:hover, .select:hover { border-color: var(--muted); }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input-sm { padding: 4px 6px; font-size: 13px; width: 70px; text-align: right; }

/* Interrupteur */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; cursor: pointer; transition: background .15s; }
.switch .track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--surface); border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::before { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--primary-soft); }

/* Options sélectionnables (cartes radio) */
.choice { display: block; position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice .choice-box { border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); height: 100%; transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease); }
.choice .choice-box:hover { border-color: var(--muted); }
.choice input:checked + .choice-box { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--primary-soft); }
.choice input:focus-visible + .choice-box { box-shadow: 0 0 0 3px var(--primary-soft); }
.choice-title { font-weight: 600; font-size: 14px; }
.choice-desc { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* --------------------------------------------------------------------------
   Badges & états
   -------------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge-off { background: var(--off-bg); color: var(--off); border-color: var(--off-border); }
.badge-info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); border-color: var(--border); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-off { background: var(--off); } .dot-info { background: var(--info); } .dot-neutral { background: var(--neutral); }

.alert { padding: 12px 16px; border-radius: var(--radius); border: 1px solid; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.alert-off { background: var(--off-bg); border-color: var(--off-border); color: var(--off); }
.alert-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }

/* Barre de progression */
.progress { height: 6px; background: var(--neutral-bg); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
.progress.ok > span { background: var(--ok); }
.progress.warn > span { background: var(--warn); }
.progress.off > span { background: var(--off); }

/* --------------------------------------------------------------------------
   Tableaux
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table tfoot td { padding: 11px 16px; border-top: 1px solid var(--border); font-weight: 600; background: var(--surface-2); }

/* --------------------------------------------------------------------------
   Plans d'étage
   -------------------------------------------------------------------------- */
.legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 12px; color: var(--text-2); align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid; }
.sw-ok { background: var(--ok-bg); border-color: var(--ok-border); }
.sw-partial { background: var(--warn-bg); border-color: var(--warn-border); }
.sw-off { background: repeating-linear-gradient(135deg, var(--off-bg) 0 3px, var(--off-hatch) 3px 5px), var(--off-bg); border-color: var(--off-border); }
.sw-na { background: var(--surface-2); border-color: var(--border-strong); }
.sw-sel { background: var(--surface); border: 2px solid var(--primary); }
.sw-space { background: var(--neutral-bg); border-color: var(--border-strong); }

.plan-wrap { overflow-x: auto; padding: 4px 2px 8px; }
.plan { min-width: 620px; }
.plan-orient { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 2px 6px; }
.plan-building { border: 1.5px solid var(--wall); border-radius: 10px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow-md); }
.plan-row { display: flex; }
.plan-row + .plan-row { border-top: 1px solid var(--wall-thin); }

.space {
    flex: var(--w, 1);
    min-height: 74px; padding: 10px 12px;
    background: var(--neutral-bg);
    border-right: 1px solid var(--wall-thin);
    display: flex; flex-direction: column; justify-content: space-between;
}
.space:last-child { border-right: 0; }
.space-code { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.space-name { font-size: 12px; font-weight: 500; color: var(--text-2); }

.patio {
    margin: 0; height: 34px; display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
    border-left: 2px dashed var(--wall-thin); border-right: 2px dashed var(--wall-thin);
    margin-left: 18%; margin-right: 18%;
}

.corridor {
    height: 30px; display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
    background: repeating-linear-gradient(135deg, var(--corridor-a) 0 6px, var(--corridor-b) 6px 12px);
    border-top: 1px solid var(--wall-thin); border-bottom: 1px solid var(--wall-thin);
}
.plan-row.rooms + .corridor, .corridor + .plan-row.rooms { border-top: 0; }

.room {
    flex: 1; min-width: 0;
    appearance: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
    min-height: 80px; padding: 7px 7px;
    border: 0; border-right: 1px solid var(--wall-thin);
    display: flex; flex-direction: column; justify-content: space-between;
    position: relative; transition: filter .1s;
}
.room:last-child { border-right: 0; }
.room:hover { filter: brightness(0.97); }
.room:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }
.room.selected { box-shadow: inset 0 0 0 2px var(--primary), inset 0 0 0 5px color-mix(in srgb, var(--primary) 18%, transparent); }
.room.dimmed { opacity: .35; }

.room.st-ok { background: var(--ok-bg); }
.room.st-partial { background: var(--warn-bg); }
.room.st-off { background: repeating-linear-gradient(135deg, var(--off-bg) 0 7px, var(--off-hatch) 7px 9px), var(--off-bg); }
.room.st-na { background: var(--surface-2); color: var(--muted); cursor: default; }
.room.st-na:hover { filter: none; }
.room.st-match { background: var(--ok-bg); }

.room-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 4px; }
.room-num { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.room-type { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.room-occ { width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; }
.room-occ.occ-occupee { background: var(--primary); }
.room-occ.occ-reservee { border: 1.5px solid var(--primary); }
.room-occ.occ-libre { display: none; }

.room-utils { display: flex; gap: 7px; font-size: 11px; }
.room-utils i { width: 12px; text-align: center; }
.u-on { color: var(--text-2); }
.u-off { color: var(--off); position: relative; }
.u-off::after { content: ''; position: absolute; left: -1px; right: -1px; top: 50%; height: 1.5px; background: var(--off); transform: rotate(-45deg); }

/* Panneau latéral de détail */
.panel-empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.panel-empty i { font-size: 22px; color: var(--border-strong); margin-bottom: 10px; display: block; }
.util-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.util-row:last-child { border-bottom: 0; }
.util-icon { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.util-icon.on { background: var(--ok-bg); color: var(--ok); }
.util-icon.off { background: var(--off-bg); color: var(--off); }
.section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }

.log-list { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.log-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; }
.log-list li:last-child { border-bottom: 0; }

/* --------------------------------------------------------------------------
   Calendrier (résident)
   -------------------------------------------------------------------------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 11px; color: var(--muted); text-align: center; padding: 6px 0; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.cal-day { aspect-ratio: 1.6; border-radius: var(--radius-sm); display: flex; align-items: flex-start; justify-content: flex-end; padding: 6px 8px; font-size: 13px; font-variant-numeric: tabular-nums; border: 1px solid transparent; color: var(--text-2); }
.cal-day.out { color: var(--border-strong); }
.cal-day.booked { background: var(--info-bg); color: var(--info); font-weight: 600; }
.cal-day.today { border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* Assistant de réservation */
.stepper { display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.step { flex: 1; padding: 12px 16px; display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.step + .step { border-left: 1px solid var(--border); }
.step-num { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.step.active { color: var(--text); }
.step.active .step-num { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.step.done .step-num { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }

.room-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }

/* --------------------------------------------------------------------------
   Connexion
   -------------------------------------------------------------------------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-aside {
    position: relative; overflow: hidden; color: #dfe7f0; padding: 44px 52px;
    display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
    background:
        radial-gradient(620px 420px at 90% 0%, rgba(143, 179, 224, .30), transparent 60%),
        radial-gradient(520px 420px at 0% 100%, rgba(143, 191, 156, .20), transparent 60%),
        linear-gradient(160deg, #27466f, #172a44);
}
.login-aside::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 32px 32px;
    -webkit-mask-image: radial-gradient(ellipse at 60% 40%, #000 30%, transparent 75%); mask-image: radial-gradient(ellipse at 60% 40%, #000 30%, transparent 75%);
}
.login-aside > * { position: relative; }
.login-aside h2 { color: #fff; font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -0.03em; max-width: 460px; }
.login-hero { display: flex; flex-direction: column; gap: 14px; }
.login-hero > p { color: #b9c7d6; font-size: 15px; }
.login-illus { width: 100%; max-width: 460px; margin: 18px 0 6px; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .25)); animation: rise .6s var(--ease) both .1s; }
.login-features { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 460px; }
.login-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #dfe7f0; }
.login-features li span { width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .14); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; flex-shrink: 0; }
.login-main .input { padding: 10px 12px; }
.login-main h1 { font-size: 28px; }
.login-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.login-box { width: 100%; max-width: 380px; }
@media (max-width: 900px) { .login-page { grid-template-columns: 1fr; } .login-aside { display: none; } }

/* --------------------------------------------------------------------------
   Notifications
   -------------------------------------------------------------------------- */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--toast-bg); color: var(--toast-text); padding: 11px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: toast-in .18s ease-out; max-width: 360px; }
.toast.error { background: var(--off); color: var(--surface); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 240px; }
input[type=range] { accent-color: var(--primary); width: 100%; }
input[type=checkbox] { accent-color: var(--primary); }

/* --------------------------------------------------------------------------
   Infobulle des plans
   -------------------------------------------------------------------------- */
.plan-tip {
    position: fixed; z-index: 90; pointer-events: none;
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    padding: 10px 12px; font-size: 12px; line-height: 1.5; min-width: 180px; max-width: 260px;
}
.plan-tip .tip-title { font-weight: 600; font-size: 13px; }
.plan-tip .tip-utils { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin-top: 6px; }
.plan-tip .tip-off { color: var(--off); font-weight: 500; }

/* Plan compact (vue bâtiment) */
.plan.compact { min-width: 560px; }
.plan.compact .room { min-height: 34px; padding: 4px 6px; justify-content: center; }
.plan.compact .room-num { font-size: 11px; }
.plan.compact .space { min-height: 30px; padding: 4px 8px; justify-content: center; }
.plan.compact .space-code { display: none; }
.plan.compact .space-name { font-size: 11px; }
.plan.compact .corridor { height: 16px; font-size: 9px; }
.plan.compact .patio { height: 16px; font-size: 9px; }
.plan.compact .plan-orient { display: none; }
.building-floor + .building-floor { margin-top: 18px; }

/* Rangées sélectionnables */
.row-pick { appearance: none; border: 0; background: none; font: inherit; color: var(--primary); cursor: pointer; padding: 0; text-transform: inherit; letter-spacing: inherit; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* Liste mobile des chambres (remplace le plan sur petit écran) */
.plan-mobile { display: none; }
.plan-mobile .pm-row + .pm-row { margin-top: 14px; }
.plan-mobile .pm-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.plan-mobile .pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.plan-mobile .room { border: 1px solid var(--wall-thin); border-radius: var(--radius-sm); min-height: 58px; }
@media (max-width: 700px) {
    .plan-wrap { display: none; }
    .plan-wrap.keep { display: block; }
    .plan-mobile { display: block; }
}

.selection-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--neutral-bg); color: var(--text-2); font-variant-numeric: tabular-nums; }
.btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.freshness { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }

/* --------------------------------------------------------------------------
   Dialogues et palette de recherche
   -------------------------------------------------------------------------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 120; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; animation: fade-in .12s ease-out; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.dialog { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); animation: pop .18s var(--ease); box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; }
.dialog-body { padding: 20px 22px 8px; }
.dialog-body p { color: var(--text-2); margin-top: 8px; font-size: 13px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 18px; }
.btn-danger { background: var(--off); border-color: var(--off); color: var(--surface); }
.btn-danger:hover { filter: brightness(.95); background: var(--off); }

.palette { max-width: 560px; overflow: hidden; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 16px 18px; font: inherit; font-size: 15px; background: transparent; color: var(--text); outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.palette li i { width: 16px; text-align: center; color: var(--muted); }
.palette li .grow { color: var(--text); }
.palette li.active { background: var(--primary-soft); }
.palette .group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px 4px; cursor: default; }
.palette .empty { color: var(--muted); padding: 18px; text-align: center; cursor: default; }
.kbd { font-family: var(--mono); font-size: 10px; padding: 1px 5px; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--muted); background: var(--surface-2); }

.search-trigger { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.search-trigger:hover { border-color: var(--border-strong); }
.icon-btn { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); width: 30px; height: 30px; border-radius: 8px; box-shadow: var(--shadow); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.icon-btn:hover { background: var(--surface-2); }

/* Notification avec action (Annuler) */
.toast .toast-action { appearance: none; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 0; margin-left: auto; opacity: .9; }

/* --------------------------------------------------------------------------
   Tendances et mini-graphiques
   -------------------------------------------------------------------------- */
.trend { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.trend.down { color: var(--ok); }
.trend.up { color: var(--warn); }
.trend.flat { color: var(--muted); }
.spark { display: block; width: 100%; height: 34px; margin-top: 10px; }
.spark path.line { fill: none; stroke: var(--primary); stroke-width: 1.5; }
.spark path.area { fill: var(--primary-soft); }
.spark circle { fill: var(--primary); }

/* --------------------------------------------------------------------------
   Impression
   -------------------------------------------------------------------------- */
.print-only { display: none; }
@media print {
    :root, :root[data-theme="dark"] {
        --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --text-2: #222; --muted: #555;
        --border: #ccc; --border-strong: #999; --shadow: none;
    }
    body { background: #fff; font-size: 12px; }
    .sidebar, .topbar, .mobile-bar, .app-footer, .tabs, .no-print, #toast-container, .overlay, .plan-tip,
    .page-head .row, #room-panel { display: none !important; }
    .content, .content-narrow { padding: 0; max-width: none; }
    .grid-main-side, .grid-7-5 { grid-template-columns: 1fr; }
    .card { box-shadow: none; break-inside: avoid; }
    .plan-wrap { overflow: visible; display: block !important; }
    .plan-mobile { display: none !important; }
    .print-only { display: block; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.trend.good { color: var(--ok); }
.trend.bad { color: var(--warn); }

/* Petits écrans : rien ne doit dépasser la largeur de l'écran */
.segmented { flex-wrap: wrap; max-width: 100%; }
.grid > * { min-width: 0; }
@media (max-width: 700px) {
    .page-head .row .btn { flex: 1; }
    .segmented button { padding: 5px 9px; }
    .card-head { padding: 14px 16px; }
    .card-body { padding: 16px; }
}
.card-head .row, .page-head .row { flex-wrap: wrap; }
.grid-side-main { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .grid-side-main { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   Finitions : mouvement, focus, défilement
   -------------------------------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.content > *, .content-narrow > * { animation: rise .4s var(--ease) both; }
.content > *:nth-child(2), .content-narrow > *:nth-child(2) { animation-delay: .04s; }
.content > *:nth-child(3), .content-narrow > *:nth-child(3) { animation-delay: .08s; }
.content > *:nth-child(n+4), .content-narrow > *:nth-child(n+4) { animation-delay: .12s; }
[data-panel]:not(.hidden) { animation: rise .3s var(--ease) both; }
.room { transition: background .35s var(--ease), box-shadow .15s var(--ease), filter .1s; }
.progress > span { transition: width .6s var(--ease); }

:where(a, button, [tabindex]):focus-visible { outline: none; box-shadow: var(--ring); }
.room:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; box-shadow: none; }
::selection { background: color-mix(in srgb, var(--primary) 22%, transparent); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* Résumé du tableau de bord */
.summary-line { color: var(--text-2); font-size: 14px; margin-top: 6px; line-height: 1.7; }
.summary-line strong { color: var(--text); font-weight: 600; }
.summary-pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 20px; font-size: 13px; font-weight: 600; border: 1px solid; vertical-align: 1px; }
.summary-pill.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.summary-pill.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
a.summary-pill:hover { text-decoration: none; filter: brightness(.97); }
.nav-link { white-space: nowrap; }
/* Barre supérieure des résidents sur téléphone : icônes seulement */
@media (max-width: 700px) {
    .topbar-inner { gap: 8px; padding: 0 12px; }
    .topbar-inner > a .brand-name, .topbar-inner > a .brand-sub, .topbar .user-chip { display: none; }
    .topbar .row { gap: 6px; }
    .topbar .lang-switch button { padding: 3px 6px; }
}
@media (max-width: 700px) {
    .cal-day { padding: 4px 6px; font-size: 12px; }
    .step { padding: 10px 12px; }
    .step:not(.active) > div { display: none; }
    .step:not(.active) { flex: 0 0 auto; }
    h1 { font-size: 22px; }
}

/* --------------------------------------------------------------------------
   Listes de tâches (page Aujourd'hui, maintenance)
   -------------------------------------------------------------------------- */
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); transition: background .15s var(--ease); }
.task:last-child { border-bottom: 0; }
.task:hover { background: var(--surface-2); }
.task-title { font-weight: 500; font-size: 13.5px; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.task.is-done .task-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.task-empty { padding: 18px 20px; color: var(--muted); font-size: 13px; }
.task-check {
    width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; cursor: pointer;
    border: 1.5px solid var(--border-strong); background: var(--surface); color: transparent;
    display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
    transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .1s;
}
.task-check:hover { border-color: var(--ok); color: var(--ok-border); }
.task-check:active { transform: scale(.9); }
.task-check.done { background: var(--ok); border-color: var(--ok); color: var(--surface); }

textarea.input { resize: vertical; min-height: 80px; font-family: inherit; }
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .board { grid-template-columns: 1fr; } }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-weight: 600; font-size: 13px; }
.ticket { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); }
.ticket + .ticket { margin-top: 8px; }
.ticket-title { font-weight: 600; font-size: 13.5px; }
.ticket-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ticket-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.ticket .select { width: auto; padding: 4px 8px; font-size: 12px; }
.ticket.prio { border-left: 3px solid var(--warn); }
.room-flag { font-size: 9px; color: var(--warn); }
.ticket-actions { flex-wrap: wrap; }
.ticket-actions .select { flex: 1 1 140px; min-width: 0; }
.ticket-actions > .grow:empty { display: none; }
