/* Portail abonnés LPConnect
   Polices auto-hébergées (aucun appel à Google : pas de fuite d'IP des abonnés, conforme RGPD). */
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque-latin-standard-normal.woff2") format("woff2-variations");
  font-weight: 200 800; font-stretch: 75% 100%; font-style: normal; font-display: swap;
}

:root {
  --bg: #e9f0f2;
  --surface: #ffffff;
  --surface-2: #f4f8f9;
  --ink: #0f2a3a;
  --muted: #557080;
  --line: #cfdce1;
  --accent: #1667a0;
  --accent-ink: #ffffff;
  --accent-soft: #dcebf6;
  --ok: #12805a;
  --ok-soft: #dcf2e8;
  --bad: #b83a26;
  --bad-soft: #f8e2dd;
  --pending: #9a6a12;
  --pending-soft: #f6ecd4;
  --fibre: #2a8fd6;
  --focus: #f2a20c;

  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bricolage Grotesque", var(--font);
  --r-sm: 6px;
  --r-md: 12px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1820;
    --surface: #11232e;
    --surface-2: #162c39;
    --ink: #e2edf1;
    --muted: #93abb7;
    --line: #24404f;
    --accent: #5aaee8;
    --accent-ink: #06202f;
    --accent-soft: #163a52;
    --ok: #4cc795;
    --ok-soft: #133628;
    --bad: #f07b66;
    --bad-soft: #3d1c16;
    --pending: #e3b558;
    --pending-soft: #3a2d12;
    --fibre: #5aaee8;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
img, svg { display: block; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* Barre du haut */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__inner {
  max-width: 1000px; margin: 0 auto; padding: 10px var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { border-radius: 8px; background: #fff; }
.brand__name { font: 700 1.05rem/1 var(--display); }
.brand__sub { color: var(--muted); font-size: .9rem; border-left: 1px solid var(--line); padding-left: 10px; }
.account { display: flex; align-items: center; gap: 12px; }
.account__name { font-weight: 600; font-size: .95rem; }
.account form { margin: 0; }
@media (max-width: 560px) {
  .brand__sub, .account__name { display: none; }
}

.page { width: 100%; max-width: 1000px; margin: 0 auto; padding: 28px var(--gutter) 48px; flex: 1; }
.page__title { font-size: clamp(1.9rem, 5vw, 2.6rem); font-weight: 700; font-stretch: 88%; }
.page > .page__title { margin-bottom: 24px; }

.footer { color: var(--muted); font-size: .88rem; text-align: center; padding: 24px var(--gutter) 32px; }
.footer p + p { margin-top: 4px; }

/* Boutons */
.btn {
  --b: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--b); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: 600 .95rem/1 var(--font); text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--quiet { background: transparent; }
.btn--small { min-height: 36px; padding: 0 14px; font-size: .88rem; }
.btn--block { width: 100%; }

/* Messages */
.notice {
  border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 20px;
  border: 1px solid; font-weight: 500;
}
.notice--success { background: var(--ok-soft); border-color: var(--ok); }
.notice--error { background: var(--bad-soft); border-color: var(--bad); }
.notice--info { background: var(--accent-soft); border-color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px;
  border-radius: 999px; font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--bad { background: var(--bad-soft); color: var(--bad); }
.pill--pending { background: var(--pending-soft); color: var(--pending); }

/* Le fil : box → fibre → Internet */
.strand { display: flex; align-items: center; gap: 0; --c: var(--fibre); width: 100%; }
.strand--offline { --c: var(--bad); }
.strand--unknown { --c: var(--muted); }
.strand__node { display: flex; flex-direction: column; align-items: center; text-align: center; flex: none; }
.strand__icon {
  width: 40px; height: 40px; padding: 8px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--c);
  fill: none; stroke: var(--c); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.strand__line {
  position: relative; flex: 1; height: 4px; min-width: 40px; margin: 0 -2px;
  background: var(--c); border-radius: 2px; overflow: hidden;
}
.strand--offline .strand__line {
  background: repeating-linear-gradient(90deg, var(--c) 0 8px, transparent 8px 14px);
}
.strand--unknown .strand__line {
  background: repeating-linear-gradient(90deg, var(--c) 0 3px, transparent 3px 9px);
}
.strand__pulse {
  position: absolute; inset: 0 auto 0 0; width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .95), transparent);
  transform: translateX(-100%);
}
.strand--online .strand__pulse { animation: pulse 2.6s cubic-bezier(.45, 0, .2, 1) infinite; }
.strand--offline .strand__pulse, .strand--unknown .strand__pulse { display: none; }
.strand__break {
  position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%) rotate(45deg);
  background: linear-gradient(var(--c), var(--c)) center / 100% 3px no-repeat,
              linear-gradient(var(--c), var(--c)) center / 3px 100% no-repeat;
}
.strand__line:has(.strand__break) { overflow: visible; }
@keyframes pulse { to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) {
  .strand--online .strand__pulse { animation: none; display: none; }
}
.strand--large .strand__icon { width: 64px; height: 64px; padding: 14px; border-width: 3px; }
.strand--large .strand__line { height: 6px; border-radius: 3px; align-self: flex-start; margin-top: 29px; }
.strand--large .strand__node { min-width: 96px; }
.strand__label { font-weight: 700; margin-top: 10px; }
.strand__sub { color: var(--muted); font-size: .88rem; }

/* Connexion */
.guest { background:
  radial-gradient(1200px 500px at 85% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.guest__main { flex: 1; display: grid; place-items: center; padding: 32px var(--gutter); }
.login { width: 100%; max-width: 920px; display: grid; gap: 36px; align-items: center; }
@media (min-width: 820px) { .login { grid-template-columns: 1.1fr 1fr; gap: 56px; } }
.login__intro img { border-radius: 12px; margin-bottom: 20px; }
.login__title { font-size: clamp(2rem, 5.5vw, 3.2rem); font-weight: 700; font-stretch: 82%; max-width: 14ch; }
.login__lead { color: var(--muted); margin: 14px 0 28px; max-width: 42ch; }
.login__intro .strand { max-width: 340px; }
.login__help { text-align: center; margin-top: 16px; font-size: .92rem; color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 28px 24px;
}
.card__title { font-size: 1.4rem; margin-bottom: 20px; }

/* Champs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; min-width: 0; }
.field label { font-weight: 600; font-size: .93rem; }
.field__hint { color: var(--muted); font-size: .84rem; }
.field__error { color: var(--bad); font-size: .86rem; font-weight: 600; }
input[type="text"], input[type="password"], select {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
[aria-invalid="true"] { border-color: var(--bad) !important; background: var(--bad-soft) !important; }
.secret { position: relative; }
.secret input { padding-right: 92px; }
.secret__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--accent); font: 600 .86rem var(--font);
  padding: 8px 10px; cursor: pointer; border-radius: var(--r-sm);
}
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; margin-bottom: 20px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 46px; height: 28px; margin: 0; cursor: pointer; }
.switch__track { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; transition: background-color .15s; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--focus); outline-offset: 2px; }

.form__grid { display: grid; gap: 0 20px; }
@media (min-width: 640px) {
  .form__grid { grid-template-columns: 1fr 1fr; }
  .form__grid--3 { grid-template-columns: repeat(3, 1fr); }
}
.form__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }

/* Tableau de bord */
.sub {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 24px; margin-bottom: 20px;
}
.sub__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.sub__name { font-size: 1.5rem; font-weight: 650; font-stretch: 90%; }
.sub__note { color: var(--muted); margin-top: 16px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; margin: 20px 0 0; }
.facts__item { margin: 0; }
.facts__item--wide { grid-column: 1 / -1; }
.facts dt { color: var(--muted); font-size: .86rem; }
.facts dd { margin: 2px 0 0; }
.facts__big { font: 700 clamp(1.35rem, 4vw, 1.8rem)/1.1 var(--display); font-stretch: 85%; font-variant-numeric: tabular-nums; }
.tags { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; font-size: .9rem; }
.boxrow {
  display: grid; grid-template-columns: 1fr; gap: 14px; align-items: center;
  margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line);
}
.boxrow .strand { max-width: 220px; }
.boxrow__title { font-weight: 700; }
.boxrow__meta { color: var(--muted); font-size: .92rem; }
@media (min-width: 720px) {
  .boxrow { grid-template-columns: 200px 1fr auto; gap: 24px; }
}

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-md); padding: 28px 24px; }
.empty h2 { font-size: 1.25rem; margin-bottom: 8px; }
.empty--inline { padding: 16px 18px; color: var(--muted); background: var(--surface-2); }
.empty--page { max-width: 560px; margin: 40px auto; text-align: left; }
.empty--page .page__title { margin-bottom: 12px; font-size: 2rem; }
.empty--page p + p { margin-top: 20px; }
.debug { white-space: pre-wrap; font-size: .8rem; background: var(--surface-2); padding: 10px; margin-top: 12px; }

/* Page box */
.crumb { color: var(--muted); font-size: .92rem; margin-bottom: 14px; }
.hero {
  position: relative; display: grid; gap: 28px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 28px 24px;
}
@media (min-width: 820px) { .hero { grid-template-columns: 1fr 1fr; padding: 32px; } }
.hero__status { font-size: 1.1rem; font-weight: 600; margin-top: 10px; }
.hero__status--ok { color: var(--ok); }
.hero__status--bad { color: var(--bad); }
.hero__help { margin-top: 8px; max-width: 52ch; }
.hero__meta { color: var(--muted); font-size: .9rem; margin-top: 10px; }
.hero__refresh { margin-top: 16px; }

.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 4px; overflow-x: auto; margin: 20px 0;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  scrollbar-width: none;
}
@media (max-width: 560px) {
  .tabs { position: static; flex-wrap: wrap; border-radius: var(--r-md); }
  .tabs a { padding: 8px 12px; }
}
.tabs a {
  flex: none; padding: 8px 16px; border-radius: 999px; color: var(--ink);
  text-decoration: none; font-weight: 600; font-size: .93rem;
}
.tabs a:hover { background: var(--surface-2); }
.tabs__count { color: var(--muted); font-weight: 500; margin-left: 2px; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 24px; margin-bottom: 20px; scroll-margin-top: 72px;
}
.panel__head { margin-bottom: 20px; }
.panel__head h2 { font-size: 1.45rem; font-weight: 650; font-stretch: 90%; }
.panel__head p { color: var(--muted); margin-top: 6px; max-width: 64ch; }

/* Appareils */
.devices, .rules { width: 100%; border-collapse: collapse; font-size: .95rem; }
.devices th, .devices td, .rules th, .rules td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.devices thead th, .rules thead th { color: var(--muted); font-weight: 600; font-size: .84rem; }
.devices tbody th { font-weight: 600; }
.devices td { font-variant-numeric: tabular-nums; }
.mac { font-size: .88rem; letter-spacing: .02em; }
@media (max-width: 720px) {
  .devices thead { display: none; }
  .devices tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .devices th, .devices td { border: 0; padding: 2px 0; }
  .devices tbody th { grid-column: 1 / -1; font-size: 1rem; }
  .devices td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .78rem; }
}

/* Règles de ports */
.rules input[type="text"], .rules select { min-height: 40px; padding: 6px 10px; font-size: .95rem; }
.rules td:first-child { width: 56px; text-align: center; }
.rule__errors td { border-bottom: 1px solid var(--line); padding-top: 0; text-align: left !important; }
@media (max-width: 860px) {
  .rules thead { display: none; }
  .rules, .rules tbody { display: block; }
  .rules tr.rule {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px;
    padding: 16px 0; border-bottom: 1px solid var(--line);
  }
  .rules tr.rule td { border: 0; padding: 0; width: auto; text-align: left; }
  .rules tr.rule td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .8rem; margin-bottom: 4px; }
  .rules tr.rule td:first-child { display: flex; align-items: center; gap: 8px; }
  .rules tr.rule td:first-child::before { margin: 0; order: 2; font-size: .9rem; color: var(--ink); }
  .rules tr.rule td:last-child { display: flex; justify-content: flex-end; align-items: center; }
  .rules tr.rule td[data-label="Nom"] { grid-column: 1 / -1; }
  .rule__errors { display: block; }
}

/* QR code */
.qr {
  border: 0; border-radius: var(--r-md); padding: 28px; width: min(360px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); text-align: center;
}
.qr::backdrop { background: rgba(5, 20, 30, .55); }
.qr h3 { font-size: 1.3rem; }
.qr p { color: var(--muted); margin-top: 6px; }
.qr__code { background: #fff; border-radius: var(--r-sm); padding: 14px; margin: 18px auto 10px; width: fit-content; }
.qr__code img { width: 220px; height: 220px; image-rendering: pixelated; }
.qr__ssid { font-weight: 700; color: var(--ink) !important; margin-bottom: 18px !important; }

/* ---------- Portail conciergeries ---------- */
.listhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.segmented {
  display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); max-width: 100%; overflow-x: auto;
}
.segmented a {
  flex: none; padding: 8px 14px; border-radius: 999px; text-decoration: none;
  color: var(--ink); font-weight: 600; font-size: .93rem;
}
.segmented a span { color: var(--muted); font-weight: 500; margin-left: 4px; font-variant-numeric: tabular-nums; }
.segmented a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.segmented a[aria-current="page"] span { color: inherit; opacity: .85; }
.segmented a.segmented--alert:not([aria-current]) span { color: var(--bad); font-weight: 700; }
.search { flex: 1 1 240px; max-width: 360px; }
input[type="search"] {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit;
}

.apts { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.apt + .apt { border-top: 1px solid var(--line); }
.apt__link {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; align-items: center;
  padding: 14px 18px; color: var(--ink); text-decoration: none;
}
.apt__link:hover { background: var(--surface-2); }
.apt__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); grid-row: span 2; }
.apt--online .apt__dot { background: var(--ok); }
.apt--offline .apt__dot { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.apt__main { display: flex; flex-direction: column; min-width: 0; }
.apt__name { font-weight: 700; }
.apt__addr { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apt__state { grid-column: 2; color: var(--muted); font-size: .92rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.apt--offline .apt__state { color: var(--bad); font-weight: 600; }
.apt__go { grid-column: 3; grid-row: 1 / span 2; color: var(--accent); font-weight: 700; font-size: .92rem; }
.apt__go::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border: solid currentColor; border-width: 2px 2px 0 0; transform: rotate(45deg) translateY(-1px); }
@media (min-width: 760px) {
  .apt__link { grid-template-columns: auto minmax(0, 1fr) 260px auto; }
  .apt__dot { grid-row: auto; }
  .apt__state { grid-column: 3; }
  .apt__go { grid-column: 4; grid-row: auto; }
}

.apthead { margin-bottom: 20px; }
.apthead__addr { color: var(--muted); margin-top: 6px; }
.apthead p + p { margin-top: 10px; }

.wifi {
  display: grid; gap: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 28px 24px; margin-bottom: 20px;
}
@media (min-width: 860px) { .wifi { grid-template-columns: 1fr 1.2fr; padding: 32px; } }
.wifi__status { display: flex; flex-direction: column; gap: 18px; }
.wifi__warn { color: var(--bad); font-weight: 500; }
.creds { margin: 0; display: grid; gap: 18px; }
.creds dt { color: var(--muted); font-size: .88rem; }
.creds dd { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.creds__value {
  font: 700 clamp(1.35rem, 4.5vw, 1.8rem)/1.2 var(--display); font-stretch: 90%;
  overflow-wrap: anywhere; user-select: all;
}
.creds__value--key { letter-spacing: .03em; font-variant-ligatures: none; }
.qrinline { margin: 24px 0 0; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.qrinline .qr__code { margin: 0; border: 1px solid var(--line); }
.qrinline .qr__code img { width: 180px; height: 180px; image-rendering: pixelated; }
.qrinline figcaption { color: var(--muted); font-size: .92rem; max-width: 28ch; }
.wifi__print { margin-top: 20px; }

@media print {
  .topbar, .footer, .crumb, .notice, .wifi__status, .wifi__print, [data-copy], .apthead .pill { display: none !important; }
  body { background: #fff; color: #000; }
  .page { padding: 0; }
  .wifi { border: 2px solid #000; break-inside: avoid; grid-template-columns: 1fr; }
  .creds__value { font-size: 26pt; }
  .qrinline .qr__code img { width: 6cm; height: 6cm; }
  .qrinline figcaption { color: #000; font-size: 12pt; }
}
