/* Phoning — la fiche bristol au centre, tout le reste en retrait. */
:root {
  --ink: #1b2b3a;
  --ink-2: #4a5a69;
  --ink-3: #7a8896;
  --desk: #dde3e8;
  --desk-2: #cfd7de;
  --card: #ffffff;
  --rule-red: #c8423b;
  --rule-blue: #c9d9e8;
  --line: #d6dde3;
  --go: #17804f;
  --go-2: #126a41;
  --stop: #b9322b;
  --focus: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;

  --s-nouveau: #5b6b7a;
  --s-injoignable: #8a6d1d;
  --s-a_rappeler: #2a63b8;
  --s-rdv_pris: #17804f;
  --s-rdv_annule: #a3471b;
  --s-pas_interesse: #7a4b8c;
  --s-hors_cible: #6b6b6b;
  --s-mauvais_numero: #9c2f2f;
  --s-deja_client: #0f6b6b;

  --ui: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --slab: 'Bitter', Georgia, serif;
  --r: 6px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 16px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------ boutons & champs */
.btn {
  display: inline-flex; align-items: center; gap: .45em;
  border: 1px solid var(--line); background: var(--card);
  padding: .5em .9em; border-radius: var(--r); cursor: pointer;
  font-weight: 700; font-size: .95rem; line-height: 1.2; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2a3f52; }
.btn.go { background: var(--go); border-color: var(--go); color: #fff; }
.btn.go:hover { background: var(--go-2); }
.btn.stop { background: var(--stop); border-color: var(--stop); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(27,43,58,.06); }
.btn.small { font-size: .85rem; padding: .35em .65em; }
kbd {
  font: 700 .72rem/1 var(--ui); padding: .2em .4em; border-radius: 4px;
  border: 1px solid currentColor; opacity: .75; min-width: 1.5em; text-align: center;
}

label.field { display: grid; gap: .25rem; font-size: .88rem; color: var(--ink-2); }
input:not([type]), input[type=file], input[type=text], input[type=email], input[type=password], input[type=search], input[type=number],
input[type=datetime-local], input[type=tel], select, textarea {
  width: 100%; padding: .5em .65em; border: 1px solid var(--line); border-radius: var(--r);
  background: #fff; color: var(--ink); font-size: .95rem;
}
textarea { resize: vertical; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }

/* ------------------------------------------------ connexion */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
}
.login form {
  width: min(380px, 100%); background: var(--card); padding: 0 28px 28px;
  border-radius: var(--r); box-shadow: 0 1px 0 var(--desk-2), 0 12px 30px rgba(27,43,58,.12);
  display: grid; gap: 14px; border-top: 3px solid var(--rule-red);
}
.login h1 { font: 700 1.6rem/1.2 var(--slab); margin: 22px 0 2px; }
.login .err { color: var(--stop); font-size: .9rem; min-height: 1.2em; margin: 0; }

/* ------------------------------------------------ coque */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100%; }
.nav {
  background: var(--ink); color: #dfe7ee; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.nav .brand { font: 700 1.25rem/1.1 var(--slab); color: #fff; padding: 4px 10px 16px; }
.nav .brand small { display: block; font: 400 .8rem/1.3 var(--ui); color: #9fb1c1; margin-top: 4px; }
.nav a {
  color: #dfe7ee; text-decoration: none; padding: .55em .7em; border-radius: var(--r);
  display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: .95rem;
}
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a[aria-current=page] { background: #fff; color: var(--ink); }
.nav a .count { font-size: .78rem; background: var(--rule-red); color: #fff; border-radius: 99px; padding: 0 .5em; }
.nav .spacer { flex: 1; }
.nav .who { font-size: .85rem; color: #9fb1c1; padding: 0 10px 6px; }
.nav .line-status { font-size: .8rem; padding: 6px 10px; color: #9fb1c1; display: flex; gap: 6px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9fb1c1; display: inline-block; flex: none; }
.dot.ok { background: #46c28b; }
.dot.demo { background: #e0b04a; }
.dot.err { background: #ef6b62; }

main { padding: 20px 24px 40px; min-width: 0; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font: 700 1.5rem/1.2 var(--slab); margin: 0; }
.panel { background: var(--card); border-radius: var(--r); padding: 16px 18px; box-shadow: 0 1px 0 var(--desk-2); }
.panel + .panel { margin-top: 14px; }
.panel h2 { font: 700 1.05rem/1.3 var(--ui); margin: 0 0 10px; }

/* ------------------------------------------------ session d'appels */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; margin-bottom: 14px;
}
.toolbar label.field { min-width: 150px; }
.toolbar .today { margin-left: auto; display: flex; gap: 18px; color: var(--ink-2); font-size: .9rem; }
.today b { color: var(--ink); font-size: 1.15rem; display: block; line-height: 1.1; }

.session { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

.queue-line { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; font-size: .88rem; color: var(--ink-2); }
.queue-line span { background: rgba(255,255,255,.55); border-radius: 99px; padding: .15em .7em; }
.queue-line span b { color: var(--ink); }

/* La fiche : un bristol ligné, liseré rouge en tête. */
.fiche-stage { perspective: 1200px; }
.fiche {
  background: var(--card); border-radius: 4px; position: relative;
  box-shadow: 0 1px 0 var(--desk-2), 0 18px 40px -18px rgba(27,43,58,.35);
  padding: 0 28px 22px;
}
.fiche::before { content: ''; display: block; height: 3px; background: var(--rule-red); margin: 0 -28px 18px; border-radius: 4px 4px 0 0; }
.fiche.leaving { animation: fiche-out .28s ease-in forwards; }
.fiche.arriving { animation: fiche-in .32s ease-out; }
@keyframes fiche-out { to { transform: translateY(-18px) rotate(-1.2deg); opacity: 0; } }
@keyframes fiche-in { from { transform: translateY(26px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fiche.leaving, .fiche.arriving { animation: none; } }

.fiche-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: .85rem; color: var(--ink-3); }
.fiche h2.company { font: 700 clamp(1.6rem, 2.6vw, 2.15rem)/1.15 var(--slab); margin: 10px 0 4px; letter-spacing: -.01em; }
.fiche .contact { font-size: 1.1rem; margin: 0; }
.fiche .meta { color: var(--ink-2); margin: 2px 0 0; font-size: .95rem; }
.fiche .meta a { color: inherit; }

.dial {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  margin: 20px 0 6px; padding: 14px 0; border-top: 1px solid var(--rule-blue); border-bottom: 1px solid var(--rule-blue);
}
.number { font-size: clamp(1.7rem, 3.2vw, 2.4rem); font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.number .cc { font-size: .9rem; vertical-align: middle; border: 1.5px solid var(--ink); border-radius: 4px; padding: .05em .35em; margin-right: .5em; letter-spacing: 0; }
.dial .call-btn { font-size: 1.1rem; padding: .7em 1.3em; border-radius: 99px; }
.dial .call-state { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.dial .timer { font-variant-numeric: tabular-nums; font-size: 1.3rem; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--go); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.caller-from { font-size: .85rem; color: var(--ink-3); width: 100%; margin-top: -6px; }
.keypad { display: grid; grid-template-columns: repeat(3, 44px); gap: 6px; margin-top: 8px; }
.keypad button { height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-weight: 700; cursor: pointer; }

.notes-ruled {
  width: 100%; min-height: 96px; border: none; padding: 6px 2px 0; margin-top: 6px;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 27px, var(--rule-blue) 27px, var(--rule-blue) 28px);
  line-height: 28px; font-size: 1rem; resize: vertical; border-radius: 0;
}
.notes-ruled:focus-visible { outline-offset: 4px; }
.prev-notes { white-space: pre-wrap; color: var(--ink-2); font-size: .92rem; margin: 10px 0 0; }

/* Clavier des issues d'appel */
.outcomes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 16px; }
.outcome {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left;
  padding: .7em .85em; border-radius: var(--r); border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-weight: 700; font-size: .95rem; border-left: 5px solid var(--c, var(--ink-3));
}
.outcome:hover { background: #f4f7f9; }
.outcome[aria-pressed=true] { background: var(--c); color: #fff; border-color: var(--c); }
.outcome[aria-pressed=true] kbd { color: #fff; }
.after { margin-top: 14px; padding: 14px; background: #f3f6f8; border-radius: var(--r); display: grid; gap: 12px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: .3em .8em; cursor: pointer; font-size: .88rem; }
.quick button[aria-pressed=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
.validate-row { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

.rec { display: inline-flex; gap: 6px; align-items: center; font-size: .88rem; color: var(--ink-2); }
.rec.on { color: var(--stop); font-weight: 700; }

/* Colonne historique */
.side .panel { padding: 14px 16px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { font-size: .9rem; display: grid; gap: 2px; padding-left: 12px; border-left: 2px solid var(--line); }
.timeline li .when { color: var(--ink-3); font-size: .8rem; }
.timeline audio { width: 100%; height: 32px; margin-top: 4px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; font-weight: 700; color: var(--c, var(--ink-2));
  border: 1.5px solid currentColor; padding: .05em .55em; border-radius: 99px; white-space: nowrap;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.empty { text-align: center; padding: 48px 20px; }
.empty h2 { font: 700 1.4rem/1.2 var(--slab); margin: 0 0 8px; }
.empty p { color: var(--ink-2); margin: 0 auto 18px; max-width: 46ch; }

/* Appel entrant */
.incoming {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; width: min(360px, calc(100% - 32px));
  background: var(--ink); color: #fff; border-radius: var(--r); padding: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.3);
  display: grid; gap: 10px;
}
.incoming h3 { margin: 0; font: 700 1.2rem/1.2 var(--slab); }

/* ------------------------------------------------ tableaux */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 700; color: var(--ink-2); font-size: .82rem; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid #edf1f4; vertical-align: top; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: #f5f8fa; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: .9rem; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters label.field { min-width: 160px; }
.filters .grow { flex: 1; min-width: 220px; }

/* Tiroir de détail */
.drawer-bg { position: fixed; inset: 0; background: rgba(27,43,58,.35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--desk); z-index: 41;
  overflow-y: auto; padding: 18px; box-shadow: -10px 0 40px rgba(0,0,0,.2);
}
.drawer { padding-top: 0; }
.drawer-head {
  position: sticky; top: 0; z-index: 2; background: var(--desk);
  display: flex; justify-content: space-between; align-items: center; padding: 12px 0;
}

dialog { border: none; border-radius: var(--r); padding: 0; width: min(560px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(27,43,58,.4); }
dialog form { padding: 20px; display: grid; gap: 12px; }
dialog h2 { font: 700 1.25rem/1.2 var(--slab); margin: 0; }

/* ------------------------------------------------ bilan */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 14px 16px; box-shadow: 0 1px 0 var(--desk-2); }
.kpi .v { font: 700 1.9rem/1.1 var(--slab); }
.kpi .l { color: var(--ink-2); font-size: .88rem; }
.charts { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; align-items: start; }
.charts > .panel + .panel { margin-top: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .legend { display: flex; gap: 14px; font-size: .85rem; color: var(--ink-2); margin-bottom: 6px; }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--ui); }
.chart .grid line { stroke: #edf1f4; }
.chart .bar:hover, .chart .bar.hot { filter: brightness(.88); }
.tip {
  position: fixed; pointer-events: none; z-index: 60; background: var(--ink); color: #fff; font-size: .85rem;
  padding: 6px 9px; border-radius: 5px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px));
}
.bars-h { display: grid; gap: 8px; }
.bars-h .r { display: grid; grid-template-columns: 130px 1fr 40px; gap: 8px; align-items: center; font-size: .88rem; }
.bars-h .track { height: 12px; background: #edf1f4; border-radius: 4px; overflow: hidden; }
.bars-h .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--c, var(--series-1)); }
.quote { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; margin: 0 0 10px; font-size: .92rem; }
.quote .muted { font-size: .8rem; }

/* ------------------------------------------------ RDV */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { border: none; background: transparent; padding: .5em .9em; border-radius: var(--r); font-weight: 700; cursor: pointer; color: var(--ink-2); }
.tabs button[aria-selected=true] { background: var(--card); color: var(--ink); box-shadow: 0 1px 0 var(--desk-2); }
.rdv-card { display: grid; grid-template-columns: 120px 1fr auto; gap: 14px; padding: 14px 0; border-bottom: 1px solid #edf1f4; align-items: start; }
.rdv-card:last-child { border-bottom: none; }
.rdv-date b { display: block; font: 700 1.15rem/1.15 var(--slab); }
.rdv-card h3 { margin: 0; font-size: 1.05rem; }
.rdv-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

/* ------------------------------------------------ toast */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 70;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r); font-weight: 700; font-size: .92rem;
  transition: opacity .18s, transform .18s; pointer-events: none; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--stop); }

/* ------------------------------------------------ petits écrans */
@media (max-width: 980px) {
  .session { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; }
  .nav .brand { width: 100%; padding-bottom: 6px; }
  .nav .spacer, .nav .who { display: none; }
  main { padding: 16px; }
  .fiche { padding: 0 16px 18px; }
  .fiche::before { margin: 0 -16px 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .rdv-card { grid-template-columns: 1fr; }
  .toolbar .today { margin-left: 0; }
}
