/* Base stylesheet of the interface. No inline style anywhere: the CSP allows style-src 'self' only.
   Page-specific styles go in static/pages.css (loaded after this file when present) and use these
   tokens instead of literal colours, so that dark mode and the white label apply everywhere:
     --fg, --muted          text, secondary text
     --bg, --surface, --surface-2, --input-bg   page, cards and tables, table heads, fields
     --line, --line-strong  borders
     --accent               brand colour (redefined by /brand.css, white label); buttons, marks
     --accent-ink           accent for text and links (lightened in dark mode)
     --on-accent            text on an --accent background
     --bad, --ok, --warn, --info and --bad-bg, --ok-bg, --warn-bg, --todo-bg   states
     --radius, --radius-sm, --shadow, --focus, --font, --mono
   Dark mode follows the system (prefers-color-scheme): only the tokens change. */
:root {
  color-scheme: light dark;
  --fg: #1b2230; --muted: #5d6675; --line: #dde1e8; --line-strong: #c4cad4;
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8f9fb; --input-bg: #ffffff;
  --accent: #1f5fae; --accent-ink: var(--accent); --on-accent: #ffffff;
  --bad: #b42318; --ok: #1d6b35; --warn: #8a5a00; --info: #1f5fae;
  --bad-bg: #fdecea; --ok-bg: #e9f6ee; --warn-bg: #fff5e0; --todo-bg: #eef0f3;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 6%);
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e9ef; --muted: #9aa3b2; --line: #2c3442; --line-strong: #3b4555;
    --bg: #0f141b; --surface: #171d26; --surface-2: #1c232e; --input-bg: #10161e;
    --accent-ink: color-mix(in srgb, var(--accent) 55%, #ffffff);
    --bad: #f0857a; --ok: #6fcf8f; --warn: #e8b44c; --info: #8bb6ef;
    --bad-bg: #3a1d1b; --ok-bg: #16301f; --warn-bg: #352a12; --todo-bg: #252c37;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--fg); background: var(--bg); }
a { color: var(--accent-ink); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: .5rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
code { font-family: var(--mono); font-size: .9em; }
.skip { position: absolute; left: -999px; top: 0; padding: .5rem 1rem; background: var(--surface); z-index: 10; }
.skip:focus { left: .5rem; top: .5rem; }

/* Header: brand, scope and account on the first row, the menu on the second. */
header.topbar { background: var(--surface); border-bottom: 1px solid var(--line); border-top: 4px solid var(--accent); }
.topbar-row { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between; padding: .6rem 1rem; max-width: 90rem; margin: 0 auto; }
header .brand { display: flex; align-items: center; gap: .5rem; font-weight: 650; }
.brand-sub { color: var(--muted); font-weight: 400; }
.brand-mark { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 1rem; }
.brand-mark.large { width: 2.75rem; height: 2.75rem; border-radius: 12px; font-size: 1.35rem; }
.mainnav { display: flex; flex-wrap: wrap; gap: .25rem; padding: 0 1rem .5rem; max-width: 90rem; margin: 0 auto; }
.mainnav a { color: var(--fg); text-decoration: none; padding: .3rem .6rem; border-radius: 999px; font-size: .9rem; }
.mainnav a:hover { background: var(--surface-2); color: var(--accent-ink); }
.mainnav a[aria-current="page"] { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-ink); font-weight: 600; }
.logout { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .9rem; }
.logout a { text-decoration: none; }
.who { color: var(--muted); }
.scope { font-weight: 600; }

main { max-width: 90rem; margin: 0 auto; padding: 1rem; }
footer { max-width: 90rem; margin: 0 auto; padding: 1rem; color: var(--muted); font-size: .9rem; }
footer a { color: var(--accent-ink); }

/* Tables, forms, buttons. */
table { width: 100%; border-collapse: collapse; background: var(--surface); margin: .5rem 0 1.5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: .9rem; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .6rem 1rem; align-items: end; background: var(--surface); padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.stack { display: grid; gap: .6rem; max-width: 22rem; }
label { display: grid; gap: .2rem; font-size: .9rem; }
input, select, textarea, button { font: inherit; padding: .4rem .55rem; }
input, select, textarea { color: var(--fg); background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-ink); box-shadow: var(--focus); }
input[aria-invalid="true"] { border-color: var(--bad); }
button { cursor: pointer; background: var(--accent); color: var(--on-accent); border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 600; }
button:hover { filter: brightness(1.08); }
button:focus-visible { box-shadow: var(--focus); outline: none; }
button.secondary { background: transparent; color: var(--fg); border-color: var(--line-strong); font-weight: 500; }
button.block { width: 100%; padding: .65rem .8rem; }
.muted { color: var(--muted); }
code.muted { font-size: .8em; }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }
.flash { padding: .55rem .8rem; border-left: 4px solid var(--ok); background: var(--surface); border-radius: var(--radius-sm); }
.flash.warn { border-color: var(--warn); }
.problem { padding: .55rem .8rem; border-left: 4px solid var(--bad); background: var(--surface); margin: .5rem 0; border-radius: var(--radius-sm); }
.tree, .tree ul { list-style: none; padding-left: 1.2rem; }
.tree > li { margin: .2rem 0; }
.kind { font-size: .75rem; padding: 0 .35rem; border: 1px solid var(--line); border-radius: 3px; }
.badge { font-size: .75rem; color: var(--bad); }
.secret code.password { font-size: 1.2rem; user-select: all; letter-spacing: .05em; }
tr.emergency td { color: var(--bad); }
form.inline { display: flex; gap: .3rem; }
form.inline input { width: 10rem; }
.pager { display: flex; gap: 1rem; }
button.danger { background: var(--bad); }
/* Billing (Lot 1). */
td.amount, th.amount { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 600; }
.rates input { width: 100%; }
.fictitious { padding: .5rem .75rem; border-left: 4px solid var(--warn); background: var(--surface); }
/* Telephony and phones (Lot 1). */
table.settings th { width: 50%; font-weight: normal; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); }
fieldset label { display: flex; gap: .4rem; align-items: center; }
td form { margin: 0 0 .25rem; }
/* Long lists and administration pages (2026-10-13). */
details.create { margin: .5rem 0 1rem; }
details.create > summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; margin-bottom: .5rem; }
form.filters { margin-bottom: .5rem; }
td pre { white-space: pre-wrap; word-break: break-all; font-size: .8rem; margin: .25rem 0; max-width: 28rem; }
/* Voicemail, voice menus, MD5 exception (Lot 1). */
.account { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-bottom: .2rem; }
button.link { background: none; color: var(--accent-ink); padding: 0; text-decoration: underline; font-size: .85rem; border: 0; font-weight: 400; }
label.check { display: flex; gap: .25rem; align-items: center; font-size: .8rem; white-space: nowrap; }
form.inline label.check input { width: auto; }
tr.unread td { font-weight: 600; }
audio { max-width: 16rem; height: 2rem; }
.digits { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .4rem; }
.digits input { width: 100%; }
.stack.wide { max-width: 40rem; background: var(--surface); padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* Login and second factor (2026-10-13): one card centred on the page. */
body.auth { min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(60rem 30rem at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
body.auth main { flex: 1; display: grid; place-items: center; width: 100%; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1.75rem; }
.auth-card.wide { max-width: 36rem; }
.auth-card h1 { font-size: 1.35rem; margin: 1.1rem 0 1rem; }
.auth-brand { display: flex; gap: .8rem; align-items: center; }
.auth-brand p { margin: 0; }
.auth-brand-name { font-weight: 700; font-size: 1.1rem; }
.auth-brand-sub { color: var(--muted); font-size: .9rem; }
.auth-form { display: grid; gap: 1rem; margin-top: .5rem; }
.field { display: grid; gap: .3rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; }
.field input { width: 100%; padding: .6rem .7rem; }
.optional { color: var(--muted); font-weight: 400; }
input.otp { font-family: var(--mono); font-size: 1.25rem; letter-spacing: .35em; text-align: center; }
input.otp::placeholder { letter-spacing: .35em; color: color-mix(in srgb, var(--muted) 50%, transparent); }
.notice { padding: .65rem .8rem; border-radius: var(--radius-sm); margin: .75rem 0; border: 1px solid transparent; font-size: .93rem; }
.notice.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.notice.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.auth-help { margin: 1.25rem 0 0; font-size: .9rem; color: var(--muted); text-align: center; }
.auth-logout { margin-top: 1rem; text-align: center; }
.steps { padding-left: 1.2rem; display: grid; gap: 1rem; }
.steps p { margin: 0 0 .4rem; }
.qr { display: inline-block; background: #ffffff; padding: .5rem; border-radius: var(--radius-sm); border: 1px solid var(--line); line-height: 0; }
.qr svg { width: 13rem; height: 13rem; max-width: 100%; }
dl.secret { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .8rem; margin: 0; }
dl.secret dt { color: var(--muted); font-size: .85rem; }
dl.secret dd { margin: 0; min-width: 0; }
code.uri { word-break: break-all; font-size: .8rem; }

/* Project progress (/avancement). */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; }
.page-head h1 { margin-bottom: .5rem; }
.live { display: flex; align-items: center; gap: .45rem; margin: 0; font-size: .85rem; color: var(--muted); }
.live-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
.live[data-state="changed"] .live-dot { background: var(--info); animation: pulse 1.6s ease-out 3; }
.live[data-state="changed"] { color: var(--info); }
.live[data-state="error"] .live-dot { background: var(--bad); }
.live[data-state="error"] { color: var(--bad); }
@keyframes pulse { to { box-shadow: 0 0 0 .6rem transparent; } }
.progress.changed .markdown { animation: flashin 2.5s ease-out; }
@keyframes flashin { from { box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 45%, transparent); } to { box-shadow: var(--shadow); } }
@media (prefers-reduced-motion: reduce) { .live-dot, .progress.changed .markdown { animation: none !important; } }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: .75rem; scrollbar-width: thin; }
.tabs a { flex: none; padding: .5rem .85rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 650; }
dl.meta { display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; margin: 0 0 1rem; font-size: .85rem; }
dl.meta div { display: flex; gap: .35rem; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; font-weight: 600; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
@media (min-width: 64rem) { .doc-layout { grid-template-columns: 15rem minmax(0, 1fr); } .toc { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; } }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; font-size: .85rem; align-self: start; }
.toc-title { margin: 0 0 .4rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.toc a { text-decoration: none; color: var(--fg); }
.toc a:hover { color: var(--accent-ink); }
.toc-l3 { padding-left: .8rem; font-size: .8rem; }
.toc-l3 a { color: var(--muted); }
.markdown { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1.5rem 1.25rem; box-shadow: var(--shadow); min-width: 0; overflow-wrap: anywhere; }
.markdown h1 { font-size: 1.45rem; margin-top: 1rem; }
.markdown h2 { border-bottom: 1px solid var(--line); padding-bottom: .3rem; scroll-margin-top: 1rem; }
.markdown h3 { scroll-margin-top: 1rem; }
.markdown .table-wrap { overflow-x: auto; margin: .5rem 0 1.2rem; }
.markdown table { margin: 0; font-size: .88rem; }
.markdown td, .markdown th { min-width: 6rem; }
.markdown tbody tr:nth-child(even) td { background: var(--surface-2); }
.markdown code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 .25em; }
.markdown blockquote { margin: .8rem 0; padding: .2rem 1rem; border-left: 4px solid var(--line-strong); color: var(--muted); }
.markdown .repo-link { text-decoration: underline dotted; text-underline-offset: 2px; }
.markdown a.external::after { content: " ↗"; font-size: .8em; }
.md-section.current { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-left: 5px solid var(--accent); border-radius: var(--radius); padding: .1rem 1rem .6rem; margin: 1rem -.5rem; }
.md-section.current > h2 { border-bottom-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.md-section.current > h2::before { content: "En direct"; display: inline-block; margin-right: .6rem; padding: .05rem .5rem; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; vertical-align: .2em; }
.st { display: inline-block; padding: 0 .3em; border-radius: 999px; line-height: 1.5; }
.st-ok { background: var(--ok-bg); }
.st-warn { background: var(--warn-bg); }
.st-bad { background: var(--bad-bg); }
.st-wait { background: color-mix(in srgb, var(--info) 18%, transparent); }
.st-todo { background: var(--todo-bg); }
.empty-state { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 1.5rem; text-align: center; }

@media (max-width: 40rem) {
  body { font-size: 16px; }
  main { padding: .75rem; }
  .auth-card { padding: 1.25rem; border-radius: 12px; }
  .markdown { padding: .25rem .9rem 1rem; }
  .md-section.current { margin: 1rem -.4rem; padding: .1rem .6rem .5rem; }
  .logout { font-size: .85rem; }
  .logout .scope { flex-basis: 100%; }
  /* Menu on one scrollable line, table of contents bounded: the content comes first. */
  .mainnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-bottom: .4rem; }
  .mainnav a { flex: none; }
  .toc { max-height: 11rem; overflow: auto; }
  dl.meta div { flex-wrap: wrap; }
  dl.secret { grid-template-columns: 1fr; }
}
