/* pmad — portail. Clair et calme pour les clients ; l'ambre est réservé à ce qui est « en direct ». */
:root {
  --mist: #e9edf3;      /* fond */
  --paper: #ffffff;     /* surfaces */
  --rail: #1c2433;      /* navigation (même ardoise que le Viewer) */
  --ink: #182030;       /* texte */
  --muted: #5b6577;
  --line: #d8dee8;
  --soft: #f3f5f9;
  --live: #f2a53a;      /* session en cours */
  --ok: #23885b;
  --bad: #c53b4e;
  --focus: #3d6fd8;
  --r-panel: 12px;
  --r-ctl: 8px;
  font-family: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--mist); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-underline-offset: 3px; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 17px; font-weight: 650; margin: 0 0 4px; }
p { margin: 0 0 12px; max-width: 70ch; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 14px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- formulaires ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(61, 111, 216, .18); }
textarea { min-height: 200px; resize: vertical; }
button {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
}
button:hover { background: var(--soft); }
button.primary { background: var(--rail); border-color: var(--rail); color: #fff; }
button.primary:hover { background: #2a3447; }
button.danger { color: var(--bad); }
button.danger:hover { background: #fbeef0; border-color: #efc5cc; }
button.small { padding: 5px 10px; font-size: 13px; }
button.link { border: none; background: none; padding: 0; color: var(--muted); font-weight: 500; }
button.link:hover { color: var(--ink); text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
.full { width: 100%; justify-content: center; margin-top: 20px; padding: 11px; }
.err { color: var(--bad); margin-top: 12px; font-size: 14px; }
.err:empty { display: none; }
.okmsg { color: var(--ok); margin-top: 12px; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- écrans d'accueil (connexion…) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 46%); }
.auth-side { background: var(--rail); color: #c9d1de; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { color: #fff; }
.auth-side blockquote { margin: 0; font-size: 26px; line-height: 1.3; color: #fff; font-weight: 600; letter-spacing: -0.01em; max-width: 18ch; }
.auth-side .lamp { margin-top: 20px; }
.auth-main { background: var(--paper); padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.auth-main h1 { margin-bottom: 6px; }
.auth-foot { margin-top: 24px; display: flex; justify-content: space-between; font-size: 14px; }
.brand { font-weight: 750; font-size: 20px; letter-spacing: -0.03em; display: inline-flex; align-items: center; gap: 8px; }
.brand .mark { width: 22px; height: 22px; border-radius: 6px; background: var(--live); position: relative; }
.brand .mark::after { content: ""; position: absolute; inset: 6px; border-radius: 2px; background: var(--rail); }

/* lampe « en direct » */
.lamp { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #8a5a10; background: #fdf1de; border: 1px solid #f6d7a6; padding: 3px 10px 3px 8px; border-radius: 999px; }
.lamp::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px rgba(242, 165, 58, .25); }
.auth-side .lamp { color: #ffd79c; background: rgba(242, 165, 58, .12); border-color: rgba(242, 165, 58, .35); }
@media (prefers-reduced-motion: no-preference) {
  .lamp::before { animation: pulse 2.4s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(242, 165, 58, 0); } }
}

/* ---------- application ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--rail); color: #c9d1de; padding: 22px 14px; display: flex; flex-direction: column; gap: 2px; }
.side .brand { color: #fff; padding: 0 10px 22px; }
.side a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-ctl); color: #c9d1de; text-decoration: none; font-size: 14.5px; }
.side a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side a.on { background: #fff; color: var(--ink); font-weight: 600; }
.side .group { margin: 18px 10px 6px; font-size: 13px; color: #7f8aa0; }
.side .who { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13.5px; }
.side .who strong { color: #fff; display: block; font-weight: 600; }
.side .who button.link { color: #9aa5ba; margin-top: 8px; }
.side .who button.link:hover { color: #fff; }
main { padding: 36px 44px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head .sub { margin-top: 4px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 22px 24px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

/* listes (remplacent les tableaux) */
.list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.item { display: grid; align-items: center; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--line); }
.item:first-child { border-top: none; }
.item .title { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 13.5px; }
.item .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.item.head { padding-top: 10px; padding-bottom: 10px; background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 600; }
.cols-devices { grid-template-columns: minmax(220px, 1.6fr) 1fr 0.8fr 290px; }
.cols-tickets { grid-template-columns: 64px minmax(220px, 2fr) 1fr 1fr 230px; }
.cols-users { grid-template-columns: minmax(200px, 1fr) 140px 170px 430px; }
.cols-sessions { grid-template-columns: 130px 1fr 1.3fr 1.2fr 110px 90px; }
.cols-audit { grid-template-columns: 130px 180px 1fr 1.6fr 120px; font-size: 14px; }
.cols-keys { grid-template-columns: 1fr 1fr 1fr 130px; }
.num { color: var(--muted); font-variant-numeric: tabular-nums; }

.state { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #b5bdca; }
.state.ok::before { background: var(--ok); }
.state.wait::before { background: #c9a227; }
.state.bad::before { background: var(--bad); }
.tag { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--soft); border: 1px solid var(--line); color: var(--muted); }
.tag.bad { color: var(--bad); background: #fbeef0; border-color: #efc5cc; }

/* code en tuiles : enrôlement, device-flow */
.code-tiles { display: inline-flex; gap: 6px; margin: 10px 0 14px; }
.code-tiles span { width: 40px; height: 52px; display: grid; place-items: center; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 8px; font-size: 26px; font-weight: 650; background: var(--paper); font-variant-numeric: tabular-nums; }
.code-tiles span.gap { width: 10px; border: none; background: none; }
.cmd { font-family: "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace; font-size: 13px; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; display: block; overflow-x: auto; white-space: nowrap; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); }

.steps { margin: 6px 0 18px; padding-left: 20px; }
.steps li { margin-bottom: 8px; padding-left: 4px; }
.split { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }

.qr { background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 8px; width: 184px; height: 184px; }
.codes { font-family: "Cascadia Mono", Consolas, monospace; display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 28px; margin: 12px 0 16px; font-size: 15px; }
select.inline { width: auto; padding: 6px 10px; font-size: 14px; }

#toast { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
#toast div { background: var(--rail); color: #fff; padding: 11px 16px; border-radius: 10px; max-width: 380px; font-size: 14px; box-shadow: 0 8px 24px rgba(24, 32, 48, .25); }
#toast div.bad { background: var(--bad); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .side .brand { padding: 6px 10px; width: 100%; }
  .side .group, .side .who { display: none; }
  main { padding: 24px 18px; }
  .item { grid-template-columns: 1fr !important; gap: 6px; }
  .item.head { display: none; }
  .item .actions { justify-content: flex-start; }
  .split { grid-template-columns: 1fr; }
}

.alert-line { color: #9a5b07; font-size: 13.5px; margin-top: 4px; display: flex; gap: 6px; }
.alert-line::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--live); margin-top: 7px; flex: none; }
.danger-panel { border-color: #efc5cc; background: #fdf3f5; }
.stars { display: flex; gap: 6px; margin: 8px 0 4px; }
.star { font-size: 30px; line-height: 1; padding: 4px 6px; border: none; background: none; color: #c8cfda; }
.star.on { color: var(--live); }
.star:hover { background: var(--soft); }

/* ---------- entreprise ---------- */
a.button { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--paper); color: var(--ink); text-decoration: none; }
a.button:hover { background: var(--soft); }
a.button.small { padding: 5px 10px; font-size: 13px; }
a.button.full { width: 100%; justify-content: center; margin-top: 12px; padding: 11px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 22px 0 4px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.ms { display: inline-grid; grid-template-columns: 8px 8px; gap: 2px; }
.ms i { width: 8px; height: 8px; display: block; }
.ms i:nth-child(1) { background: #f25022; } .ms i:nth-child(2) { background: #7fba00; } .ms i:nth-child(3) { background: #00a4ef; } .ms i:nth-child(4) { background: #ffb900; }

dialog.modal { border: 1px solid var(--line); border-radius: var(--r-panel); padding: 24px 26px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); color: var(--ink); box-shadow: 0 24px 60px rgba(24, 32, 48, .28); }
dialog.modal::backdrop { background: rgba(24, 32, 48, .45); }
label.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; font-size: 14px; }
label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--rail); }
.checks { gap: 6px 18px; margin-top: 6px; }
.checks.col { display: flex; flex-direction: column; gap: 8px; }
label.select-label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.policy .sub { font-weight: 600; color: var(--ink); }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; margin-bottom: 18px; }
.figures > div { background: var(--paper); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.figures strong { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figures span { color: var(--muted); font-size: 13px; }
svg.bars { width: 100%; height: auto; margin-top: 10px; }
svg.bars rect { fill: var(--rail); }
svg.bars rect:hover { fill: var(--live); }
svg.bars text { font-size: 11px; fill: var(--muted); }
.meters { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.meter .track { height: 6px; background: var(--soft); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.meter .track div { height: 100%; background: var(--rail); border-radius: 3px; }
.live-panel { border-color: #f6d7a6; background: #fffaf2; }
.swatch { width: 14px; height: 38px; border-radius: 4px; flex: none; }
.logo-sm { height: 26px; max-width: 90px; object-fit: contain; }
.logo-prev { margin-top: 10px; height: 52px; display: flex; align-items: center; }
.logo-prev img { max-height: 48px; max-width: 240px; }
.cols-orgs { grid-template-columns: minmax(220px, 1.4fr) 90px 1.4fr 400px; }
.cols-groups { grid-template-columns: minmax(200px, 1fr) 1.4fr 200px; }
.cols-approvals { grid-template-columns: 110px 160px 1fr 220px; }
.cols-report { grid-template-columns: 130px 1fr 1fr 80px 1.4fr; font-size: 14px; }
.report { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 32px 36px; }
.report header { display: flex; gap: 24px; align-items: center; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.report .list { border-radius: 0; border-left: 0; border-right: 0; }
.report footer { margin-top: 24px; }
@media print {
  body { background: #fff; font-size: 12px; }
  .side, .no-print, #toast { display: none !important; }
  .layout { display: block; }
  main { padding: 0; max-width: none; }
  .report { border: none; padding: 0; }
  .item { padding: 6px 4px; break-inside: avoid; }
}
.webview { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.webview .screen { background: #10141d; border-radius: var(--r-panel); padding: 8px; min-height: 360px; display: grid; place-items: center; }
canvas.remote { max-width: 100%; height: auto; display: block; cursor: default; border-radius: 4px; background: #10141d; }
canvas.remote:focus { outline: 2px solid var(--live); }
.webview .chat { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.chat-log { height: 340px; overflow-y: auto; font-size: 14px; display: flex; flex-direction: column; gap: 8px; }
button.on { background: var(--rail); color: #fff; border-color: var(--rail); }
@media (max-width: 1100px) { .webview { grid-template-columns: 1fr; } }
.panel-head:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- v2.3 : exploitation */
.cols-scripts { grid-template-columns: minmax(240px, 2fr) 110px 300px; }
.cols-jobs { grid-template-columns: minmax(220px, 1.6fr) 160px 1.4fr 230px; }
.cols-patches { grid-template-columns: minmax(220px, 1.6fr) 170px 150px 130px 110px; }
.cols-oncall { grid-template-columns: 180px 1.4fr 1fr 110px; }
.cols-time { grid-template-columns: minmax(200px, 1.4fr) 140px 120px 130px 120px; }
.cols-contracts { grid-template-columns: minmax(200px, 1.4fr) 140px 140px 120px; }
.cols-sla { grid-template-columns: minmax(160px, 1fr) 110px 150px 150px 130px; }
.cols-guests { grid-template-columns: minmax(200px, 1fr) 1.4fr 150px 120px; }
.cols-vault { grid-template-columns: minmax(220px, 1.4fr) 1fr 150px 120px; }
.cols-alerts { grid-template-columns: minmax(260px, 2.2fr) 150px 130px 180px; }
.cols-channels { grid-template-columns: minmax(200px, 1.2fr) 1.6fr 130px 200px; }
h2.section { font-size: 17px; margin: 28px 0 10px; }
.mono, textarea.mono { font-family: "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace; font-size: 13px; }
.pre { white-space: pre-wrap; }

/* Priorité : seule l'urgence prend la couleur d'alerte ; « basse » s'efface */
.prio { font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); color: var(--muted); }
.prio-urgent { color: #fff; background: var(--bad); border-color: var(--bad); }
.prio-high { color: #8a5a00; background: #fdf3df; border-color: #f0d49c; }
.prio-low { background: transparent; }

/* Onglets des coulisses et tableaux denses */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 9px 14px; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--rail); font-weight: 600; }
table.grid { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
table.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 7px 8px; border-bottom: 1px solid var(--soft); vertical-align: top; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid td.actions { text-align: right; white-space: nowrap; }
pre.log { font-family: "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace; font-size: 12.5px; background: #10141d; color: #d7dce5; border-radius: 8px; padding: 12px 14px; max-height: 460px; overflow: auto; white-space: pre-wrap; margin: 8px 0 0; }
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.job-runs details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.job-runs summary { cursor: pointer; display: flex; gap: 10px; align-items: center; }
.modal { min-width: min(560px, 92vw); max-width: min(860px, 96vw); }
.activity { max-height: 60vh; overflow: auto; }

/* Demande détaillée : conversation à gauche, suivi à droite */
.ticket { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; }
.msgs { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 10px; background: var(--soft); border: 1px solid var(--line); }
.msg.mine { align-self: flex-end; background: #eef3fb; border-color: #cfdcf2; }
.msg.internal { background: #fdf8ea; border-color: #eedfae; border-style: dashed; }
.msg-text { white-space: pre-wrap; margin-top: 4px; }
.reply { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; display: grid; gap: 10px; }
.ticket-side label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.ticket-side label:first-child { margin-top: 0; }
.attach { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: var(--paper); font-size: 13px; }
.attach img { max-width: 220px; max-height: 140px; display: block; border-radius: 5px; }
.switch { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

/* Base de connaissances */
.kb { display: grid; gap: 10px; }
.kb-item { margin: 0; }
.kb-item summary { cursor: pointer; display: flex; gap: 10px; align-items: center; }
.kb-body { margin-top: 12px; line-height: 1.6; }

/* Page d'état publique */
.status-page { max-width: 640px; margin: 48px auto; padding: 0 20px; }
.status-page header { margin-bottom: 24px; }
.status-banner { padding: 16px 18px; border-radius: var(--r-panel); font-weight: 600; margin-bottom: 16px; color: #fff; background: var(--ok); }
.status-banner.bad { background: var(--bad); }
.status-list { list-style: none; padding: 6px 18px; margin: 0 0 12px; }
.status-line { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--soft); }
.status-line:last-child { border-bottom: 0; }

/* Viewer mobile : le doigt pilote l'écran distant, le défilement de la page ne doit pas s'en mêler */
canvas.remote { touch-action: none; -webkit-user-select: none; user-select: none; }
.vkbd { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.webview .screen { position: relative; }
.touch-only { display: none; }
@media (pointer: coarse) {
  .touch-only { display: inline-flex; }
  button.small, .button.small { min-height: 40px; padding: 8px 14px; }
}
@media (max-width: 900px) {
  .ticket { grid-template-columns: 1fr; }
  .msg { max-width: 100%; }
  dl.kv { grid-template-columns: 1fr; }
  .webview .screen { padding: 0; min-height: 0; border-radius: 0; margin: 0 -16px; }
  .page-head { flex-wrap: wrap; gap: 8px; }
}
@media (max-width: 900px) {
  .side { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .side a { white-space: nowrap; flex: none; }
  .side .brand { width: auto; flex: none; }
}
