/* Sipolia — console de flotte VoIP
   Palette : encre bleu-vert, papier froid, voyants (signal, ambre, rouge) comme sur un standard téléphonique. */
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/figtree-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/figtree-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/figtree-latin-ext-500-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/figtree-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/figtree-latin-ext-600-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/figtree-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/figtree-latin-ext-700-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/figtree-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --paper: #f3f6f5;
  --surface: #ffffff;
  --sunk: #e9eeec;
  --ink: #13262b;
  --ink-2: #33474c;
  --muted: #64767a;
  --rule: #d7e0de;
  --signal: #0f8a7e;
  --signal-soft: #d6efeb;
  --amber: #c98200;
  --amber-soft: #f7ead0;
  --red: #c4423a;
  --red-soft: #f6dcd9;
  --blue: #3b67a8;
  --blue-soft: #dce6f3;
  --off: #b9c4c2;
  --focus: #1d6fd6;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(19, 38, 43, 0.06), 0 4px 16px rgba(19, 38, 43, 0.05);
  --font: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #0e1a1d; --surface: #152428; --sunk: #1b2e33; --ink: #e6efed; --ink-2: #c3d1cf; --muted: #8fa3a2;
    --rule: #263b40; --signal: #3cc3b2; --signal-soft: #173f3b; --amber: #e8a93a; --amber-soft: #3d3119;
    --red: #ec7a70; --red-soft: #422523; --blue: #7ea6e6; --blue-soft: #1d2e47; --off: #3e5257; --focus: #6aa8ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #0e1a1d; --surface: #152428; --sunk: #1b2e33; --ink: #e6efed; --ink-2: #c3d1cf; --muted: #8fa3a2;
  --rule: #263b40; --signal: #3cc3b2; --signal-soft: #173f3b; --amber: #e8a93a; --amber-soft: #3d3119;
  --red: #ec7a70; --red-soft: #422523; --blue: #7ea6e6; --blue-soft: #1d2e47; --off: #3e5257; --focus: #6aa8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.5; font-feature-settings: 'tnum' 1, 'cv11' 1;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.6em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Mise en page ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow: auto; padding: 22px 14px;
  border-right: 1px solid var(--rule); background: var(--surface); display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; }
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-s);
  text-decoration: none; color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--sunk); }
.nav a[aria-current='page'] { background: var(--signal-soft); color: var(--ink); }
.nav a[aria-current='page'] .nav-ico { color: var(--signal); }
.nav-ico { width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav-sep { height: 1px; background: var(--rule); margin: 8px 10px; }
.side-foot { margin-top: auto; padding: 0 8px; display: flex; flex-direction: column; gap: 8px; }
.sync-pill { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--muted); }
.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.topbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); background: var(--surface); position: sticky; top: 0; z-index: 20; }
  .main { padding: 20px 16px 56px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Éléments ---------- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr; } }

.figures { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); margin-bottom: 16px; }
.figure { flex: 1 1 140px; padding: 14px 18px; border-right: 1px solid var(--rule); text-decoration: none; }
.figure:last-child { border-right: 0; }
.figure b { display: block; font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figure span { color: var(--muted); font-size: 0.86rem; }
a.figure:hover { background: var(--sunk); }
@media (max-width: 700px) { .figure { flex-basis: 50%; border-bottom: 1px solid var(--rule); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--rule); background: var(--surface); cursor: pointer; font-weight: 550; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.9; }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 10px; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 0.86rem; font-weight: 550; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface);
}
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
textarea.input { min-height: 90px; resize: vertical; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 180px; }
.toolbar .grow { flex: 1 1 220px; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }

/* Tableaux */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.82rem; padding: 10px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.data td { padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.data tr:last-child td { border-bottom: 0; }
.data tbody tr:hover { background: var(--sunk); }
.data tr.is-deleted td { color: var(--muted); }
.data .right { text-align: right; }
.data a.rowlink { text-decoration: none; font-weight: 550; }
.data a.rowlink:hover { text-decoration: underline; }
.data .chk { width: 32px; }

/* Numéros de téléphone : groupés par deux, comme sur une étiquette de poste */
.phone { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; white-space: nowrap; }
.phone.big { font-size: 1.05rem; color: var(--muted); }

/* Pastilles d'état */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 550; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.tag.ok { background: var(--signal-soft); color: var(--signal); }
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.tag.bad { background: var(--red-soft); color: var(--red); }
.tag.info { background: var(--blue-soft); color: var(--blue); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* Voyant */
.lamp { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; display: inline-block; }
.lamp.on { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.lamp.fwd { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.lamp.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

/* ---------- Tableau des lignes (la pièce maîtresse de l'accueil) ---------- */
.board { display: flex; flex-direction: column; gap: 18px; }
.board-group h3 { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.board-group h3 a { text-decoration: none; }
.board-group h3 a:hover { text-decoration: underline; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.key {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 10px; padding: 9px 11px; border-radius: var(--radius-s);
  background: var(--paper); border: 1px solid var(--rule); text-decoration: none; min-width: 0;
}
.key:hover { border-color: var(--ink-2); }
.key .lamp { grid-row: span 2; }
.key-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-sub { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Fil d'événements */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--off); }
.feed .dot.appeared, .feed .dot.reappeared { background: var(--signal); }
.feed .dot.removed { background: var(--red); }
.feed .dot.changed { background: var(--amber); }
.feed .dot.assigned, .feed .dot.renamed { background: var(--blue); }
.feed .when { font-size: 0.8rem; color: var(--muted); }

/* Fiche */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.inline-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-edit .input { max-width: 320px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Statistiques */
.chart-box { position: relative; height: 260px; }
.heat { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; font-size: 0.72rem; color: var(--muted); }
.heat div { aspect-ratio: 1 / 1; border-radius: 2px; min-width: 0; }
.heat .h-label { aspect-ratio: auto; display: flex; align-items: center; }
.heat .h-hour { aspect-ratio: auto; text-align: center; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1fr) 3fr auto; gap: 10px; align-items: center; font-size: 0.88rem; }
.bar-track { height: 8px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); border-radius: 4px; }
.period { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.period .input { width: auto; }

/* Messages */
.notice { padding: 12px 14px; border-radius: var(--radius-s); background: var(--amber-soft); color: var(--ink); margin-bottom: 16px; border: 1px solid transparent; }
.notice.info { background: var(--blue-soft); }
.notice.error { background: var(--red-soft); }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: var(--radius-s); box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--red); color: #fff; }

/* Dialogue */
dialog { border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 0; background: var(--surface); color: var(--ink); width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(19, 38, 43, 0.35); }
.dlg-body { padding: 20px; }
.dlg-foot { padding: 14px 20px; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; gap: 8px; }
.pick-list { max-height: 340px; overflow: auto; border: 1px solid var(--rule); border-radius: var(--radius-s); }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.pick-list label:last-child { border-bottom: 0; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); }
.login-card .brand { padding: 0; margin-bottom: 26px; }
.login-card .panel { padding: 24px; }

.mt { margin-top: 16px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; background: var(--sunk); padding: 1px 6px; border-radius: 4px; overflow-wrap: anywhere; }
details.raw summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
details.raw pre { font-size: 0.78rem; overflow: auto; max-height: 360px; background: var(--sunk); padding: 12px; border-radius: var(--radius-s); }
