/* Statistiques PROCOMM — feuille de style unique
   Palette tirée du logo : bleu marine #002a5c et bronze #9b8466.
   Chiffres en IBM Plex Sans à chasse fixe (tabular-nums) pour des colonnes alignées. */

@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #eef1f5; --surface: #ffffff; --surface-2: #f6f8fb; --ink: #12233d; --muted: #5b6b80; --line: #d8dfe8;
  --brand: #002a5c; --brand-ink: #ffffff; --accent: #9b8466; --link: #0d4a94;
  --ok: #1d8a6c; --missed: #c2413a; --ab: #c98316; --vm: #7a64b8; --out: #2f6bb3; --int: #8794a7;
  --ok-bg: #e2f3ed; --missed-bg: #f9e5e3; --ab-bg: #fbefd9; --vm-bg: #ece8f6; --int-bg: #eceff3;
  --shadow: 0 1px 2px rgba(10, 30, 60, .06);
  --radius: 10px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1424; --surface: #12203a; --surface-2: #172846; --ink: #e3e9f2; --muted: #8fa0b7; --line: #263857;
  --brand: #071a35; --brand-ink: #e3e9f2; --accent: #c4ab85; --link: #8db3e8;
  --ok: #3fbf98; --missed: #ef7a70; --ab: #e9aa45; --vm: #a993e6; --out: #6fa0e6; --int: #9aa7ba;
  --ok-bg: #12382f; --missed-bg: #43201f; --ab-bg: #42301a; --vm-bg: #2c2547; --int-bg: #22304a;
  --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1424; --surface: #12203a; --surface-2: #172846; --ink: #e3e9f2; --muted: #8fa0b7; --line: #263857;
    --brand: #071a35; --brand-ink: #e3e9f2; --accent: #c4ab85; --link: #8db3e8;
    --ok: #3fbf98; --missed: #ef7a70; --ab: #e9aa45; --vm: #a993e6; --out: #6fa0e6; --int: #9aa7ba;
    --ok-bg: #12382f; --missed-bg: #43201f; --ab-bg: #42301a; --vm-bg: #2c2547; --int-bg: #22304a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/1.5 "Plex", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -.01em; margin: 6px 0 16px; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font-size: 12px; max-height: 420px; }
[hidden] { display: none !important; }

/* --- Bandeau du haut ------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 8px 24px; background: var(--brand); color: var(--brand-ink);
  border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--brand-ink); font-weight: 600; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand img { background: #fff; border-radius: 6px; padding: 4px 8px; height: 34px; width: auto; }
.mainnav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; flex: 1; }
.mainnav > a, .menu > summary {
  color: var(--brand-ink); opacity: .82; padding: 8px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap; list-style: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: "▾"; font-size: 10px; margin-left: 5px; opacity: .7; }
.mainnav > a:hover, .menu > summary:hover { opacity: 1; text-decoration: none; background: rgba(255,255,255,.08); }
.mainnav > a[aria-current="page"], .menu.current > summary { opacity: 1; background: rgba(255,255,255,.14); box-shadow: inset 0 -2px 0 var(--accent); }
.menu { position: relative; }
.menu-list {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 230px; z-index: 30;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 6px; display: flex; flex-direction: column;
}
.menu-list.right { left: auto; right: 0; }
.menu-list a, .menu-list .linklike { padding: 8px 10px; border-radius: 6px; color: var(--ink); text-align: left; }
.menu-list a:hover, .menu-list .linklike:hover { background: var(--surface-2); text-decoration: none; }
.menu-list form { margin: 0; display: flex; }
.menu-list form .linklike { flex: 1; }
.menu-note { margin: 4px 10px 8px; font-size: 12px; color: var(--muted); }
.usermenu > summary { opacity: 1; }
.with-badge { display: inline-flex; align-items: center; gap: 6px; }
.badge { background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; display: inline-grid; place-items: center; }
.badge-alert { background: #d9473d; }
.nav-toggle { display: none; }

/* --- Mise en page --------------------------------------------------- */
.wrap { max-width: 1440px; margin: 0 auto; padding: 20px 24px 40px; }
.foot { max-width: 1440px; margin: 0 auto; padding: 12px 24px 28px; color: var(--muted); font-size: 12px; display: flex; gap: 24px; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head form { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }
.panel-head > a { margin-left: auto; font-size: 13px; }
.panel.warn { border-left: 4px solid var(--ab); }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 36px; text-align: center; color: var(--muted); }
.back { margin: 0 0 4px; font-size: 13px; }

/* --- Formulaires ---------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field > span { font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; min-height: 36px;
}
input[type="checkbox"] { min-height: 0; accent-color: var(--brand); }
:root[data-theme="dark"] input[type="checkbox"] { accent-color: var(--accent); }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 16px;
  font: inherit; font-weight: 500; border-radius: 7px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; white-space: nowrap;
}
:root[data-theme="dark"] .btn { background: #2b5ea8; border-color: #2b5ea8; }
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--missed); border-color: var(--missed); }
:root[data-theme="dark"] .btn-danger { background: #b4433b; border-color: #b4433b; }
.btn-wide { width: 100%; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.inline { display: inline-flex; gap: 8px; align-items: end; margin: 0; }
.inline-actions { margin-top: 12px; }
.danger-zone { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.confirm-pw { margin-top: 14px; display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.confirm-pw p { width: 100%; margin: 0; }

/* --- Filtres -------------------------------------------------------- */
.filters { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin-bottom: 18px; }
.filter-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: 0; }
.custom-range { display: flex; gap: 10px; }
.filter-side { display: flex; align-items: end; gap: 12px; }
.filter-side form { margin: 0; }
.auto { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); padding-bottom: 9px; white-space: nowrap; }
.period-label { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 13px; }
.drop { position: relative; }
.drop > summary {
  list-style: none; cursor: pointer; min-height: 36px; padding: 7px 30px 7px 12px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); position: relative; white-space: nowrap;
}
.drop > summary::-webkit-details-marker { display: none; }
.drop > summary::after { content: "▾"; position: absolute; right: 11px; color: var(--muted); }
.drop-panel {
  position: absolute; z-index: 15; top: calc(100% + 6px); left: 0; min-width: 260px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.16);
  display: flex; flex-direction: column; gap: 12px;
}
.drop-panel.wide { min-width: 360px; }
.drop-actions { display: flex; gap: 12px; align-items: center; }
.drop-actions input { flex: 1; min-width: 0; }
.source-list { max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.source-item { display: flex; gap: 8px; align-items: center; padding: 5px 4px; border-radius: 5px; }
.source-item:hover { background: var(--surface-2); }
.source-item small { color: var(--muted); }
.days { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.days legend { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.chip { display: inline-flex; gap: 5px; align-items: center; border: 1px solid var(--line); border-radius: 16px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.subfilters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin: -6px 0 14px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.subfilters .grow { flex: 1; min-width: 200px; }
.toolbar { display: flex; gap: 16px; align-items: end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar p { margin: 0; max-width: 640px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg a { padding: 4px 12px; color: var(--ink); font-size: 13px; }
.seg a[aria-current] { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .seg a[aria-current] { background: #2b5ea8; }

/* --- Indicateurs ---------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.small { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi h2 { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 30px; font-weight: 600; line-height: 1.15; margin: 6px 0 4px; letter-spacing: -.02em; }
.kpi-sub { margin: 0; font-size: 13px; color: var(--muted); }
.kpi-lead { grid-row: span 2; display: flex; flex-direction: column; border-top: 3px solid var(--accent); }
.kpi-lead .kpi-value { font-size: 52px; margin-top: 10px; }
.ratio { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--int-bg); margin: 16px 0 10px; }
.ratio span { display: block; height: 100%; }
.r-ok { background: var(--ok); } .r-missed { background: var(--missed); } .r-ab { background: var(--ab); } .r-vm { background: var(--vm); }
.legend { list-style: none; padding: 0; margin: auto 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.missed { background: var(--missed); } .dot.ab { background: var(--ab); } .dot.vm { background: var(--vm); }
.delta { font-size: 12px; margin-left: 4px; white-space: nowrap; }
.delta.up { color: var(--ok); } .delta.down { color: var(--missed); } .delta.flat { color: var(--muted); }
.mini-kpis { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-bottom: 12px; }
.mini-kpis div { display: flex; flex-direction: column; }
.mini-kpis span { font-size: 12px; color: var(--muted); }
.mini-kpis strong { font-size: 20px; font-weight: 600; }
.q-exc, .q-good { color: var(--ok); } .q-fair { color: var(--ab); } .q-poor { color: var(--missed); }

/* --- Tableaux ------------------------------------------------------- */
.table-scroll { overflow-x: auto; }
.table-scroll.short { max-height: 280px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.table th a { color: var(--muted); }
.table th a[aria-sort]::after { content: " ↓"; } .table th a[aria-sort="ascending"]::after { content: " ↑"; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:hover td { background: var(--surface-2); }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table .num { text-align: right; white-space: nowrap; }
.table small { color: var(--muted); }
.table tr.disabled td { opacity: .55; }
.nowrap { white-space: nowrap; }
.clip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num-tel { white-space: nowrap; }
.count { color: var(--muted); margin: 0 0 8px; }
.pager { display: flex; gap: 18px; justify-content: center; align-items: center; padding: 14px; }
.log .lvl-error td { color: var(--missed); }
.log .lvl-warning td:nth-child(2) { color: var(--ab); }

/* Statuts et sens */
.st { display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.st-answered { background: var(--ok-bg); color: var(--ok); }
.st-missed, .st-failed { background: var(--missed-bg); color: var(--missed); }
.st-abandoned, .st-busy { background: var(--ab-bg); color: var(--ab); }
.st-voicemail { background: var(--vm-bg); color: var(--vm); }
.st-no_answer { background: var(--int-bg); color: var(--int); }
.dir { font-size: 12px; white-space: nowrap; }
.dir::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.dir-inbound::before { background: var(--ok); } .dir-outbound::before { background: var(--out); } .dir-internal::before { background: var(--int); }
.err-text { color: var(--missed); }

/* --- Fiche d'appel ---------------------------------------------------- */
.call-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 16px; }
.call-head .party p { margin: 0; }
.call-head .label { font-size: 12px; color: var(--muted); }
.call-head .big { font-size: 24px; font-weight: 600; }
.call-head .arrow { display: flex; align-items: center; gap: 10px; }
.call-head .arrow::before, .call-head .arrow::after { content: ""; width: 40px; height: 2px; background: var(--line); }
.facts dl, .facts-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0; margin: 0 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.facts-list { display: block; border: 0; }
.facts dl div, .facts-list div { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.facts-list div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; }
.facts dt, .facts-list dt { font-size: 12px; color: var(--muted); }
.facts dd, .facts-list dd { margin: 2px 0 0; font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--accent); }
.timeline li { position: relative; padding: 0 0 14px 14px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline p { margin: 0; }
.raw summary { cursor: pointer; font-weight: 500; }

/* --- Graphiques ------------------------------------------------------- */
.chart { width: 100%; }

/* --- Messages ----------------------------------------------------------- */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-size: 14px; }
.flash-ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.flash-err { background: var(--missed-bg); border-color: color-mix(in srgb, var(--missed) 40%, transparent); }
.flash-info { background: var(--vm-bg); border-color: color-mix(in srgb, var(--vm) 40%, transparent); }
.secret-box { background: var(--ab-bg); border: 1px solid color-mix(in srgb, var(--ab) 45%, transparent); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.secret-box p { margin: 4px 0; }
.secret code { display: inline-block; font-size: 15px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; user-select: all; word-break: break-all; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 10px; }
.howto h3 { display: flex; gap: 8px; align-items: center; }
.plain { padding-left: 18px; margin: 6px 0; }
.journal { max-height: 300px; white-space: pre-wrap; }
.task[data-state="en_cours"] { border-left: 4px solid var(--out); }
.task[data-state="termine"] { border-left: 4px solid var(--ok); }
.task[data-state="echec"], .task[data-state="retour"] { border-left: 4px solid var(--missed); }

/* --- Connexion ---------------------------------------------------------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: var(--radius); padding: 28px 30px; box-shadow: 0 10px 30px rgba(10, 30, 60, .08); }
.login-logo { display: block; margin: 0 0 18px; height: auto; max-width: 200px; background: #fff; padding: 6px 10px; border-radius: 6px; }
.login h1 { font-size: 20px; margin: 0 0 18px; }

/* --- Écrans étroits ------------------------------------------------------ */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-lead { grid-row: auto; grid-column: 1 / -1; }
  .grid-2, .grid-side, .howto-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .topbar { padding: 8px 14px; }
  .nav-toggle { display: inline-flex; margin-left: auto; background: transparent; color: var(--brand-ink); border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 6px 12px; font: inherit; }
  .mainnav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; }
  .mainnav.open { display: flex; }
  .menu-list { position: static; box-shadow: none; margin: 4px 0; }
  .usermenu { order: 2; }
  .wrap { padding: 14px; }
  .kpis, .kpis.small { grid-template-columns: 1fr 1fr; }
  .kpi-lead .kpi-value { font-size: 40px; }
  .call-head { grid-template-columns: 1fr; }
  .call-head .arrow::before, .call-head .arrow::after { display: none; }
  .drop-panel, .drop-panel.wide { position: fixed; left: 12px; right: 12px; top: 80px; min-width: 0; max-height: 70vh; overflow: auto; }
  .custom-range { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
