/* Relais by FDME — charte commune Vigie / Essor */
:root {
  --navy: #0a3466;
  --navy-2: #0f4580;
  --navy-soft: #e7edf5;
  --red: #c8102e;
  --red-soft: #fbe9ec;
  --orange: #c2610c;
  --orange-soft: #fbf0e3;
  --green: #15803d;
  --green-soft: #e7f4ec;
  --bg: #f3f1ed;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --border: #e4e0d9;
  --border-strong: #cfc9bf;
  --text: #1c2230;
  --muted: #5d6372;
  --faint: #8a8f9a;
  --note: #fff8e1;
  --note-border: #ecd98f;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05);
  --radius: 10px;
  --serif: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --sans: "Outfit", "Segoe UI", system-ui, -apple-system, sans-serif;
  --sidebar: 258px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #6f9fd8; --navy-2: #8fb5e3; --navy-soft: #1b2a40;
    --red: #ef5a6f; --red-soft: #3a1a20; --orange: #e9964a; --orange-soft: #3a2816;
    --green: #4fbf7a; --green-soft: #15301f;
    --bg: #12161d; --surface: #1a1f28; --surface-2: #161b23; --border: #2a313d; --border-strong: #3a4250;
    --text: #e7e9ee; --muted: #a3a9b6; --faint: #7d8492; --note: #2d2814; --note-border: #5a4e1f;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --navy: #6f9fd8; --navy-2: #8fb5e3; --navy-soft: #1b2a40;
  --red: #ef5a6f; --red-soft: #3a1a20; --orange: #e9964a; --orange-soft: #3a2816;
  --green: #4fbf7a; --green-soft: #15301f;
  --bg: #12161d; --surface: #1a1f28; --surface-2: #161b23; --border: #2a313d; --border-strong: #3a4250;
  --text: #e7e9ee; --muted: #a3a9b6; --faint: #7d8492; --note: #2d2814; --note-border: #5a4e1f;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--navy); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; font-family: var(--sans); }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
code { font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* --- Structure --------------------------------------------------------- */
.svc-line { display: block; padding: 10px 0; text-decoration: none; color: inherit; }
.svc-line + .svc-line { border-top: 1px solid var(--border); }
.svc-line .n { font-size: 13.5px; margin-top: 4px; display: block; }
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { background: #0a3466; border-bottom: 3px solid #c8102e; padding: 16px 18px; display: flex; align-items: center; gap: 12px;
  color: #fff; text-decoration: none; }
.brand-icon { width: 44px; height: 44px; background: #fff; border-radius: 9px; display: grid; place-items: center; flex: none; }
.brand-name { font-family: var(--serif); font-size: 26px; font-weight: 700; line-height: 1; display: block; }
.brand-sub { font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; opacity: .85; display: block; margin-top: 5px; }
.nav { padding: 10px 12px; flex: 1; }
.nav-title { font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  padding: 18px 10px 8px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 14px; margin: 2px 0;
  border-radius: 8px; color: var(--text); text-decoration: none; font-size: 15px; border-left: 3px solid transparent; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--navy-soft); border-left-color: var(--navy); font-weight: 600; }
.count { background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 11px; display: inline-grid; place-items: center; }
.who { border-top: 1px solid var(--border); padding: 16px 18px; font-size: 13px; }
.who strong { font-size: 14px; display: block; }
.who .email { color: var(--muted); font-size: 12.5px; word-break: break-all; }
.who form { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--navy); text-decoration: underline; font: inherit; cursor: pointer; font-weight: 600; }
.who-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.theme-toggle { background: none; border: 1px solid var(--border); border-radius: 50%; width: 30px; height: 30px; cursor: pointer;
  color: var(--muted); display: grid; place-items: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 18px 36px 16px; border-bottom: 1px solid var(--border); }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.topbar .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.menu-btn { display: none; width: 38px; height: 38px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  cursor: pointer; color: var(--navy); }
.content { padding: 24px 36px 48px; flex: 1; }
.demo-banner { background: var(--orange-soft); color: var(--orange); border-bottom: 1px solid var(--border); padding: 8px 36px;
  font-size: 13px; font-weight: 600; }

/* --- Cartes ------------------------------------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.card-body { padding: 18px 20px; }
.grid { display: grid; gap: 18px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.grid-main { grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); align-items: start; }
.kpi { padding: 14px 20px 16px; border-left: 4px solid var(--navy); }
.kpi .value { font-family: var(--serif); font-size: 34px; line-height: 1.15; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi.red { border-left-color: var(--red); }
.kpi.orange { border-left-color: var(--orange); }
.kpi.grey { border-left-color: var(--border-strong); }
.kpi a { color: inherit; text-decoration: none; display: block; }

/* --- Listes de tickets --------------------------------------------------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 13px 20px;
  border-top: 1px solid var(--border); border-left: 4px solid var(--navy); text-decoration: none; color: inherit; }
.rows .row:first-child { border-top: 0; }
a.row:hover { background: var(--surface-2); }
.row .ref { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.row > * { min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .meta { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-family: var(--serif); font-size: 17px; margin-bottom: 4px; }

table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table .ref { font-weight: 600; font-size: 12.5px; letter-spacing: .04em; white-space: nowrap; }
.table .title a { color: var(--text); font-weight: 600; text-decoration: none; }
.table .title a:hover { text-decoration: underline; }
.table-wrap { overflow-x: auto; }
.table .sel { width: 38px; padding-right: 0; }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); font-size: 14px; }
.bulk-bar.active { background: var(--red-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* --- Badges -------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  white-space: nowrap; border: 1px solid transparent; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-soft { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.badge-red { background: var(--red); color: #fff; }
.badge-orange { background: var(--orange-soft); color: var(--orange); border-color: color-mix(in srgb, var(--orange) 35%, transparent); }
.badge-navy { background: var(--navy-soft); color: var(--navy); }
.badge-green { background: var(--green-soft); color: var(--green); }
.tag { font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 8px; }
.svc { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; padding: 3px 8px; border-radius: 6px; color: #fff; }

/* --- Boutons et formulaires ---------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14.5px var(--sans); padding: 10px 18px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
  text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--navy); }
.btn-primary { background: #0a3466; border-color: #0a3466; color: #fff; }
.btn-primary:hover { background: #0f4580; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-block { width: 100%; }
.btn-ms { background: #fff; color: #1f1f1f; border-color: #8c8c8c; padding: 12px 20px; font-size: 15px; }
.btn-ms:hover { background: #f5f5f5; border-color: #5e5e5e; }

label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 5px; }
.req { color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
select, textarea {
  width: 100%; font: 15px var(--sans); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 9px 12px; }
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--navy) 40%, transparent); border-color: var(--navy); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: #0a3466; vertical-align: middle; }
.field { margin-bottom: 18px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.fields-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 0; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters .f { min-width: 150px; }
.filters .f.grow { flex: 1; min-width: 200px; }
.filters label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.filters select, .filters input { padding: 8px 10px; font-size: 14px; }
.seg { display: inline-flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.seg a { padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 8px; text-decoration: none; color: var(--text);
  font-weight: 600; font-size: 14px; background: var(--surface); }
.seg a.on { background: #0a3466; border-color: #0a3466; color: #fff; }

/* --- Messages flash -------------------------------------------------------- */
.flashes { margin-bottom: 18px; display: grid; gap: 8px; }
.flash { padding: 11px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 14px;
  border-left: 4px solid var(--navy); }
.flash.success { border-left-color: var(--green); }
.flash.error { border-left-color: var(--red); background: var(--red-soft); }
.flash.info { border-left-color: var(--orange); }

/* --- Choix du service -------------------------------------------------------- */
.services-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.svc-card { display: block; text-decoration: none; color: inherit; padding: 22px; border-top: 4px solid var(--c, var(--navy)); transition: transform .1s; }
.svc-card:hover { border-color: var(--c); transform: translateY(-1px); }
.svc-card h2 { font-size: 20px; margin: 10px 0 6px; }
.svc-card p { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.svc-card .go { font-weight: 600; color: var(--navy); font-size: 14px; }
.welcome { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--red); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 20px; color: var(--muted); }

/* --- Fiche ticket ------------------------------------------------------------ */
.ticket-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.thread { display: grid; gap: 14px; }
.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--navy-soft); color: var(--navy); font-weight: 700; font-size: 14px;
  display: grid; place-items: center; }
.avatar.staff { background: #0a3466; color: #fff; }
.bubble { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.bubble .who-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.bubble .who-line strong { color: var(--text); font-size: 14px; }
.bubble .text { white-space: normal; word-wrap: break-word; }
.bubble.first { border-left: 4px solid var(--navy); }
/* Contenu HTML des e-mails reçus */
.mail-html { overflow-x: auto; line-height: 1.45; }
.mail-html p { margin: 0; }
.mail-html img { max-width: 100%; height: auto; }
.mail-html table { border-collapse: collapse; max-width: 100%; }
.mail-html td, .mail-html th { vertical-align: top; padding: 2px 6px; }
.mail-html blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.mail-html hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.mail-html a { word-break: break-all; }
.mail-html .mail-img-off { color: var(--faint); font-size: 12px; }
:root[data-theme="dark"] .mail-html [style*="color"] { color: inherit !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mail-html [style*="color"] { color: inherit !important; } }
:root[data-theme="dark"] .mail-html [style*="background"] { background: transparent !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mail-html [style*="background"] { background: transparent !important; } }
.bubble.note { background: var(--note); border-color: var(--note-border); }
.change { font-size: 13px; color: var(--muted); padding: 2px 0 2px 52px; display: flex; gap: 8px; }
.change::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); margin-top: 7px; flex: none; }
.files { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.file { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
  font-size: 13px; text-decoration: none; color: var(--text); background: var(--surface-2); }
.file:hover { border-color: var(--navy); }
.info dl { margin: 0; display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; font-size: 14px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.side-stack { display: grid; gap: 18px; }
.reply-tools { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.reply-tools select, .reply-tools input[type=number] { width: auto; padding: 7px 10px; font-size: 14px; }
.notice { padding: 12px 16px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }
.notice.green { background: var(--green-soft); border-color: transparent; }

/* --- Login ------------------------------------------------------------------ */
.login-wrap { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.login-top { background: #0a3466; border-bottom: 3px solid #c8102e; }
.login-top .brand { background: none; border: 0; max-width: 1100px; margin: 0 auto; }
.login-box { width: 100%; max-width: 440px; margin: 64px auto; padding: 0 16px; }
.login-box .card-body { padding: 32px; }
.login-box h1 { margin-bottom: 8px; }
.login-box p.lead { color: var(--muted); margin: 0 0 24px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; margin: 22px 0; text-transform: uppercase; letter-spacing: .1em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.pager { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 14px; font-size: 14px; }
.section-gap { margin-top: 18px; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tree-child td:first-child { padding-left: 38px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.opt { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--surface-2); }
.opt label { margin-bottom: 8px; }
.opt select { padding: 7px 10px; font-size: 14px; }

@media (max-width: 1100px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .menu-btn { display: grid; place-items: center; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .topbar { flex-wrap: wrap; align-items: flex-start; }
  .topbar > div:nth-child(2) { flex: 1; min-width: 0; }
  .topbar .actions { margin-left: 0; width: 100%; }
  .demo-banner { padding: 8px 16px; }
  .fields-2, .fields-3 { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .row .right { justify-content: flex-start; }
  h1 { font-size: 23px; }
  .info dl { grid-template-columns: 100px 1fr; }
}
