/* CODA Support : styles communs a toutes les pages connectees. */
:root {
  --ink: #1b2240;
  --muted: #5a6283;
  --soft: #8a90ab;
  --line: #e3e5f0;
  --line-strong: #c9cce0;
  --ground: #f4f5fa;
  --panel: #ffffff;
  --accent: #5a3fc0;
  --accent-hover: #47309f;
  --accent-soft: #efebfb;
  --ok: #1d7f47;
  --ok-soft: #e5f4eb;
  --warn: #a56108;
  --warn-soft: #fdf1df;
  --danger: #b42f2f;
  --danger-soft: #fbeaea;
  --info: #2459a6;
  --info-soft: #e6eefa;
  --note: #fff8e1;
  --note-line: #f0d98a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(27, 34, 64, 0.07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.92em; background: var(--ground); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }

/* ---- Barre du haut ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 1.12rem; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand img { width: 34px; height: 34px; }
.nav { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--muted);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 9px;
  white-space: nowrap;
}
.nav a:hover { background: var(--ground); color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--accent); background: var(--accent-soft); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-menu { position: relative; }
.user-button {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 4px 12px 4px 4px; font: inherit; font-weight: 600; cursor: pointer;
}
.user-button:hover { border-color: var(--line-strong); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.82rem; flex: 0 0 auto;
}
.avatar.staff { background: var(--accent); color: #fff; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column;
}
.user-dropdown .who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-dropdown .who small { display: block; color: var(--muted); }
.user-dropdown a, .user-dropdown button {
  text-align: left; border: 0; background: transparent; font: inherit; color: var(--ink);
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--ground); text-decoration: none; }

/* ---- Page ---- */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 22px; }
.page.narrow { max-width: 860px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.page-head h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.crumb { font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-body { padding: 20px 22px; }
.card-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 1.05rem; }
.section-title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); padding: 26px 22px; text-align: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

/* ---- Boutons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
  background: var(--accent); color: #fff;
}
.btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.secondary { background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--ground); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--panel); color: var(--danger); border-color: #e7b9b9; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 6px 11px; font-size: 0.88rem; border-radius: 8px; }
.btn svg { width: 18px; height: 18px; }

/* ---- Formulaires ---- */
label.field { display: block; font-weight: 600; font-size: 0.92rem; }
label.field > input, label.field > select, label.field > textarea { margin-top: 6px; display: block; }
label.field .opt { color: var(--soft); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; font-weight: 400;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(90, 63, 192, 0.2); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-status { font-size: 0.92rem; color: var(--muted); }
.form-status.error { color: var(--danger); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 150px; }
.filters input[type=search] { min-width: 240px; flex: 1; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; font-size: 0.9rem; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 0.8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--ground); color: var(--muted);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.s-new { background: var(--info-soft); color: var(--info); }
.s-open { background: var(--accent-soft); color: var(--accent); }
.s-pending { background: var(--warn-soft); color: var(--warn); }
.s-resolved { background: var(--ok-soft); color: var(--ok); }
.s-closed { background: #eceef4; color: #6b7190; }
.p-critical { background: var(--danger-soft); color: var(--danger); }
.p-high { background: var(--warn-soft); color: var(--warn); }
.p-normal { background: #eef0f6; color: var(--muted); }
.p-low { background: #f2f3f7; color: var(--soft); }
.i-proposed { background: #eef0f6; color: var(--muted); }
.i-review { background: var(--info-soft); color: var(--info); }
.i-planned { background: var(--accent-soft); color: var(--accent); }
.i-progress { background: var(--warn-soft); color: var(--warn); }
.i-done { background: var(--ok-soft); color: var(--ok); }
.i-declined { background: #eceef4; color: #6b7190; }
.flag { font-size: 0.78rem; font-weight: 700; color: var(--danger); white-space: nowrap; }
.flag.wait { color: var(--info); }
.tag { display: inline-block; font-size: 0.8rem; color: var(--muted); background: var(--ground); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }

/* ---- Tableaux ---- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.list td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #fafaff; }
.num { font-family: Consolas, "Cascadia Mono", monospace; color: var(--muted); white-space: nowrap; }
.t-subject { font-weight: 700; color: var(--ink); }
.t-meta { color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.nowrap { white-space: nowrap; }

/* ---- Accueil ---- */
.hero {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px 30px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
}
.hero h1 { font-size: 1.7rem; }
.hero p { color: var(--muted); margin-top: 6px; max-width: 640px; }
.hero-search { display: flex; gap: 8px; width: min(460px, 100%); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tile {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--ink);
}
.tile:hover { border-color: var(--accent); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.tile-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center;
}
.tile-icon svg { width: 22px; height: 22px; }
.tile strong { display: block; font-size: 1.02rem; }
.tile span { color: var(--muted); font-size: 0.92rem; }
.tile .count { margin-left: auto; font-size: 1.4rem; font-weight: 700; color: var(--accent); align-self: center; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--ink); display: block; }
a.kpi:hover { border-color: var(--accent); text-decoration: none; color: var(--ink); }
.kpi small { display: block; color: var(--muted); font-weight: 600; font-size: 0.86rem; }
.kpi strong { display: block; font-size: 1.9rem; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.alert strong { color: var(--danger); }
.kpi .unit { font-size: 0.95rem; color: var(--muted); font-weight: 600; margin-left: 4px; }
.linklist { display: flex; flex-direction: column; }
.linklist a { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); color: var(--ink); }
.linklist a:last-child { border-bottom: 0; }
.linklist a:hover { background: #fafaff; text-decoration: none; }
.linklist .grow { flex: 1; min-width: 0; }
.linklist .grow strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars { display: flex; flex-direction: column; gap: 10px; padding: 18px 22px; }
.bar-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 36px; gap: 10px; align-items: center; font-size: 0.92rem; }
.bar-track { display: block; height: 9px; background: var(--ground); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }

/* ---- Ticket ---- */
.dash-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 22px; align-items: start; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.msg.staff { border-left: 4px solid var(--accent); }
.msg.internal { background: var(--note); border-color: var(--note-line); border-left: 4px solid #d9a400; }
.msg-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px 0; }
.msg-head strong { font-size: 0.98rem; }
.msg-head time { color: var(--muted); font-size: 0.86rem; margin-left: auto; white-space: nowrap; }
.msg-body { padding: 10px 18px 16px; overflow-wrap: anywhere; }
.msg-files { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 18px 16px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  border: 1px solid var(--line); background: var(--ground); border-radius: 9px; padding: 6px 10px; color: var(--ink); font-size: 0.88rem;
}
.file-chip svg { width: 16px; height: 16px; flex: 0 0 auto; }
.file-chip:hover { border-color: var(--accent); text-decoration: none; }
.file-chip small { color: var(--muted); }
.file-thumb { display: block; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.file-thumb img { display: block; max-width: 220px; max-height: 160px; }
.sysline { text-align: center; color: var(--muted); font-size: 0.86rem; display: flex; align-items: center; gap: 12px; }
.sysline::before, .sysline::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sysline.internal { color: #8a6d00; }
.composer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.composer.internal-mode { background: var(--note); border-color: var(--note-line); }
.composer textarea { min-height: 130px; }
.side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; }
.props { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; }
.prop { display: flex; flex-direction: column; gap: 4px; }
.prop > span { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.prop select, .prop input { padding: 7px 10px; }
.dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 0.92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.notes-box { background: var(--note); border: 1px solid var(--note-line); border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; white-space: pre-wrap; }
.stars { display: inline-flex; gap: 4px; }
.stars button { border: 0; background: transparent; font-size: 1.7rem; line-height: 1; color: #d4d7e5; cursor: pointer; padding: 0 2px; }
.stars button.on { color: #e3a008; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.file-list { display: flex; flex-wrap: wrap; gap: 8px; }
.file-list .file-chip button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0 2px; }
.suggest { background: var(--info-soft); border: 1px solid #c7d8f3; border-radius: 12px; padding: 14px 16px; }
.suggest ul { margin: 8px 0 0; padding-left: 18px; }

/* ---- Liste et fiche (clients) ---- */
.master-detail { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; align-items: start; }
.master-detail > .card:first-child { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto; }

/* ---- Idees ---- */
.ideas { display: flex; flex-direction: column; }
.idea { display: flex; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.idea:last-child { border-bottom: 0; }
.vote {
  flex: 0 0 auto; width: 62px; height: 66px; border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--panel); color: var(--ink); font: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.vote svg { width: 18px; height: 18px; }
.vote strong { font-size: 1.15rem; line-height: 1; }
.vote:hover { border-color: var(--accent); }
.vote.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.vote:disabled { cursor: default; opacity: 0.7; }
.idea-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.idea-main a.title { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.idea-main p { color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.idea-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); font-size: 0.86rem; }
.official { background: var(--accent-soft); border: 1px solid #d9d0f5; border-radius: 12px; padding: 14px 16px; }
.official strong { color: var(--accent); }
.comment { padding: 14px 22px; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment.staff { background: #fbfaff; }

/* ---- Base de connaissances ---- */
.cat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.article-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.article-card:hover { border-color: var(--accent); text-decoration: none; color: var(--ink); }
.article-card span { color: var(--muted); font-size: 0.9rem; }
.prose { font-size: 1.02rem; line-height: 1.7; overflow-wrap: anywhere; }
.prose h2 { font-size: 1.3rem; margin: 22px 0 8px; }
.prose h3 { font-size: 1.1rem; margin: 18px 0 6px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin: 3px 0; }
.prose > :first-child { margin-top: 0; }
.rich p { margin: 0 0 8px; }
.rich p:last-child { margin-bottom: 0; }
.rich ul { margin: 0 0 8px; padding-left: 20px; }

/* ---- Fenetres ---- */
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(27, 34, 64, 0.3); color: var(--ink); }
dialog.modal::backdrop { background: rgba(27, 34, 64, 0.45); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 1.15rem; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 200px); overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.icon-btn:hover { background: var(--ground); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---- Messages ephemeres ---- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow);
  font-weight: 600; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--danger); }

.foot { text-align: center; color: var(--soft); font-size: 0.82rem; padding: 0 0 28px; }

/* ---- Telephone et tablette ---- */
@media (max-width: 1000px) {
  .ticket-layout, .master-detail, .dash-layout { grid-template-columns: 1fr; }
  .master-detail > .card:first-child { position: static; max-height: 360px; }
  .side { position: static; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cat-grid, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .topbar-inner { padding: 0 16px; gap: 12px; flex-wrap: wrap; padding-top: 10px; }
  .brand span { display: none; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 8px; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions .btn .label { display: none; }
  .user-button .name { display: none; }
  .page { padding: 20px 16px 48px; }
  .tiles, .grid-2, .form-grid, .cat-grid, .grid-3 { grid-template-columns: 1fr; }
  .hero { padding: 22px 20px; }
  .filters select, .filters input, .filters input[type=search] { min-width: 0; width: 100%; flex: 1 1 100%; }
  .bar-row { grid-template-columns: 110px minmax(0, 1fr) 30px; }
  .idea { padding: 16px; gap: 12px; }
  .vote { width: 52px; height: 58px; }
  table.list.responsive thead { display: none; }
  table.list.responsive tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.list.responsive td { display: inline-block; border: 0; padding: 2px 8px 2px 0; }
  table.list.responsive td.main { display: block; padding-bottom: 6px; }
}
