/* CAP Deploy V0.2 — feuille de style (identité CAP : vert canard, sobre, lisible, responsive). */

:root {
  --teal: #0f6e65;
  --teal-dark: #0b514a;
  --teal-soft: #e7f3ef;
  --navy: #10262d;
  --navy-2: #173640;
  --bg: #f3f6f6;
  --surface: #ffffff;
  --ink: #18333b;
  --muted: #5d7279;
  --line: #e0e8e7;
  --ok: #1d7a4a;
  --ok-bg: #e5f4ec;
  --warning: #8a5a14;
  --warning-bg: #fff3df;
  --danger: #a8333a;
  --danger-bg: #fbeaea;
  --admin: #6b3fa0;
  --admin-bg: #f1eafa;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(16, 38, 45, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--ink); background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-top: 1rem; }
p { margin: .35rem 0; }
a { color: var(--teal); }
code, pre { font-family: var(--mono); font-size: .85em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #4fb3a7; outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.block { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip-link:focus { left: 8px; }
.stack > * + * { margin-top: .75rem; }

/* ---------------------------------------------------------------- écrans */
.screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(circle at top, #e3f1ee, var(--bg) 60%); }
.brand-line { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; margin-bottom: 18px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--teal);
  color: #fff; font-weight: 800; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; }
.login-card { width: min(440px, 100%); }
.eyebrow { display: block; text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; font-weight: 700; color: var(--teal); }

/* ----------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #cfe0dd; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; margin-bottom: 14px; }
.sidebar-brand small { display: block; color: #8fb3ad; font-size: .72rem; }
.nav-heading { display: block; margin: 14px 8px 4px; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #7ea29c; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: #dbe8e6; text-decoration: none; }
.nav-link:hover { background: var(--navy-2); }
.nav-link[aria-current="page"] { background: var(--teal); color: #fff; }
.nav-icon { width: 18px; text-align: center; opacity: .85; }
.nav-count { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .72rem; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: .8rem; color: #9dbab5; padding: 8px; }
.sidebar-foot small { margin-left: auto; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #3bb58d; }
.is-admin .status-dot { background: #b38bf0; }
.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; }
.crumb { color: var(--muted); }
.crumb strong { color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--teal-soft);
  color: var(--teal-dark); font-weight: 700; }
.menu-toggle { display: none; }
main { padding: 22px 24px 40px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-tools { display: flex; align-items: center; gap: 10px; }
.footer { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; padding: 12px 24px; color: var(--muted);
  font-size: .78rem; border-top: 1px solid var(--line); background: var(--surface); }
.overlay { position: fixed; inset: 0; background: rgba(16, 38, 45, .45); z-index: 19; }

/* --------------------------------------------------------------- grilles */
.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.grid.metrics { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* -------------------------------------------------------------- panneaux */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head p { font-size: .82rem; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.panel-body { padding: 14px 16px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.metric-title { color: var(--muted); font-size: .8rem; }
.metric-value { font-size: 1.45rem; }
.metric-detail { color: var(--muted); font-size: .78rem; }
.bar { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: var(--teal); }
.bar.warning span { background: #c98a1b; }
.bar.danger span { background: var(--danger); }
.kv { display: grid; grid-template-columns: minmax(130px, 34%) 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row small { display: block; color: var(--muted); }

/* ------------------------------------------------------------- éléments */
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;
  background: var(--teal-soft); color: var(--teal-dark); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warning { background: var(--warning-bg); color: var(--warning); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.neutral { background: #eef2f2; color: var(--muted); }
.pill.admin { background: var(--admin-bg); color: var(--admin); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; }
.button:hover { border-color: #b9cdca; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.button.primary:hover { background: var(--teal-dark); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.small { padding: 5px 10px; font-size: .8rem; }
.button.full { width: 100%; }
.icon-button { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; width: 34px; height: 34px; cursor: pointer; }
.link-button { background: none; border: 0; color: var(--teal); cursor: pointer; padding: 0; text-decoration: underline; }
.link { font-weight: 600; text-decoration: none; }
.callout { border-left: 4px solid var(--teal); background: var(--teal-soft); padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.callout.warning { border-color: #c98a1b; background: var(--warning-bg); }
.callout.danger { border-color: var(--danger); background: var(--danger-bg); }
.callout.success { border-color: var(--ok); background: var(--ok-bg); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px 12px; color: var(--muted); text-align: center; }
.empty strong { color: var(--ink); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px 4px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--teal);
  animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ------------------------------------------------------------ formulaires */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: .85rem; }
input, select, textarea { border: 1px solid #c9d7d5; border-radius: 9px; padding: 8px 10px; background: #fff; min-width: 0; }
input[type="checkbox"] { width: 18px; height: 18px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.otp { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }

/* --------------------------------------------------------------- tableaux */
.table-wrap { overflow-x: auto; margin: 6px 0; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.cell-primary strong, .cell-primary span { display: block; overflow-wrap: anywhere; }

/* ------------------------------------------------------- tuyaux d'orgue */
.transverse { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border: 1px dashed var(--teal);
  border-radius: 10px; background: var(--teal-soft); }
.proxy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0 0; padding: 8px 14px; border-radius: 10px;
  background: #eef2f2; }
.pipes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; position: relative; }
.pipe { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px 12px; border: 1px solid var(--line);
  border-radius: 12px 12px 30px 30px; background: linear-gradient(#fff, #f6faf9); cursor: pointer; min-height: 150px; }
.pipe[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(15, 110, 101, .2); }
.pipe-symbol { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--teal-soft);
  color: var(--teal-dark); font-weight: 800; }
.pipe-detail { border-top: 1px solid var(--line); padding-top: 10px; }
.app-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; min-width: 0; }
.app-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.app-card-head .pills { margin-left: auto; justify-content: flex-end; }
.findings { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-direction: column; gap: 6px; }
.finding { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.steps { padding-left: 1.2rem; }

/* ------------------------------------------------------------ graphiques */
.chart { margin: 0; }
.chart svg { width: 100%; height: 180px; display: block; }
.chart .gridline { stroke: #e2ebe9; stroke-dasharray: 4 4; }
.chart .line { fill: none; stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.chart .s1 { stroke: var(--teal); fill: var(--teal); }
.chart .s2 { stroke: #5e86b0; fill: #5e86b0; }
.chart .s3 { stroke: #c98a1b; fill: #c98a1b; }
.chart polyline.line { fill: none; }
.legend { display: flex; gap: 14px; font-size: .8rem; margin-bottom: 6px; }
.legend .key::before { content: ""; display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle;
  background: currentColor; }
.legend .s1 { color: var(--teal); }
.legend .s2 { color: #5e86b0; }
.legend .s3 { color: #c98a1b; }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; }

/* -------------------------------------------------- journaux, codes, QR */
pre.logs { background: #0f1f24; color: #d6e6e3; padding: 12px; border-radius: 10px; max-height: 520px; overflow: auto; white-space: pre-wrap;
  overflow-wrap: anywhere; }
pre.small-pre { margin: 0; max-height: 160px; overflow: auto; white-space: pre-wrap; background: #f4f7f7; padding: 6px; border-radius: 6px; }
code.phrase { display: block; font-size: 1.05rem; padding: 10px; background: #f4f7f7; border: 1px dashed var(--teal); border-radius: 8px;
  margin: 6px 0 10px; user-select: all; }
.method { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 12px; }
.qr-zone { text-align: center; margin-top: 10px; }
img.qr { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
.match { font-size: 1rem; }
.match.big { font-size: 1.4rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }

/* ----------------------------------------------------- fenêtres, toasts */
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  box-shadow: 0 20px 60px rgba(16, 38, 45, .3); }
dialog.modal.wide { width: min(880px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(16, 38, 45, .5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-body { padding: 14px 18px 20px; overflow-y: auto; }
.notifications { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60;
  max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--navy); color: #fff; padding: 10px 12px; border-radius: 10px;
  box-shadow: var(--shadow); }
.toast.danger { background: var(--danger); }
.toast.warning { background: #8a5a14; }
.toast-close { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1rem; }

/* ------------------------------------------------------------- mobile */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s;
    z-index: 20; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-block; }
  .crumb { display: none; }
  main { padding: 16px; }
  .topbar { padding: 8px 16px; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
}
@media (max-width: 520px) {
  .topbar-actions .avatar { display: none; }
  #session-pill { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .card { padding: 20px; }
  h1 { font-size: 1.35rem; }
}
