/* CRM OneMobilier — feuille de style unique, sans étape de build */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #e0e9ff;
  --sidebar: #0f1b2d;
  --sidebar-text: #c4cfde;
  --sidebar-active: #1c2c45;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);

  --red-bg: #fee2e2;    --red-fg: #b91c1c;
  --amber-bg: #fef3c7;  --amber-fg: #a16207;
  --green-bg: #dcfce7;  --green-fg: #15803d;
  --blue-bg: #dbeafe;   --blue-fg: #1d4ed8;
  --violet-bg: #ede9fe; --violet-fg: #6d28d9;
  --orange-bg: #ffedd5; --orange-fg: #c2410c;
  --gray-bg: #f1f5f9;   --gray-fg: #475569;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ---------- Mise en page ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; color: #fff; font-weight: 650; font-size: 15px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.brand small { display: block; font-weight: 400; font-size: 11.5px; color: var(--sidebar-text); }
.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7c8ba1; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--sidebar-text); font-weight: 500;
}
.nav a:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .count { margin-left: auto; background: #dc2626; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.sidebar-user { border-top: 1px solid #1f2f47; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who strong { display: block; color: #fff; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user button { background: none; border: 0; color: var(--sidebar-text); cursor: pointer; padding: 6px; border-radius: 6px; }
.sidebar-user button:hover { background: var(--sidebar-active); color: #fff; }

.main { min-width: 0; }
.topbar { display: none; }
.content { padding: 28px 32px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: #334766; color: #fff; font-size: 12px; font-weight: 600;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; }

/* ---------- Cartes / grilles ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 16px; }

.stat { padding: 16px 18px; display: block; color: inherit; }
.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 28px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.red { background: #ef4444; } .dot.amber { background: #f59e0b; } .dot.green { background: #22c55e; }
.dot.blue { background: #3b82f6; } .dot.violet { background: #8b5cf6; } .dot.orange { background: #f97316; } .dot.gray { background: #94a3b8; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 550; white-space: nowrap; line-height: 1.6;
}
.badge.red { background: var(--red-bg); color: var(--red-fg); }
.badge.amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge.green { background: var(--green-bg); color: var(--green-fg); }
.badge.blue { background: var(--blue-bg); color: var(--blue-fg); }
.badge.violet { background: var(--violet-bg); color: var(--violet-fg); }
.badge.orange { background: var(--orange-bg); color: var(--orange-fg); }
.badge.gray { background: var(--gray-bg); color: var(--gray-fg); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 1px 8px 1px 6px; border-radius: 6px; background: var(--gray-bg); }
.chip .swatch { width: 8px; height: 8px; border-radius: 2px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); 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 tbody tr:hover { background: #fafbfd; }
.table .title-cell a { color: var(--text); font-weight: 550; }
.table .title-cell .muted { font-size: 12.5px; }
.row-link { cursor: pointer; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field, .form-row + .field, .field + .form-row, .form-row + .form-row { margin-top: 14px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
label, .label { font-weight: 550; font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); }
.req::after { content: " *"; color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
  font: inherit; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 140px; resize: vertical; }
input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; }
.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 450; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.check-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.invalid { border-color: var(--danger) !important; }
.error-text { color: var(--danger); font-size: 12.5px; }
.counter { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 600; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-bg); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.recording { background: #dc2626; border-color: #dc2626; color: #fff; animation: pulse 1.4s infinite; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(220, 38, 38, .2); } }
form.inline { display: inline; }

/* ---------- Onglets / filtres ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.filters input[type=search] { flex: 1 1 220px; min-width: 180px; }
.filters select { width: auto; flex: 0 1 170px; }

/* ---------- Alertes ---------- */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert ul { margin: 0; padding-left: 18px; }

/* ---------- Ticket ---------- */
.ticket-meta { display: grid; grid-template-columns: 120px 1fr; gap: 10px 12px; font-size: 13.5px; }
.ticket-meta dt { color: var(--muted); }
.ticket-meta dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.status-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.status-steps button {
  border: 1px solid var(--border-strong); background: #fff; border-radius: 8px; padding: 9px 6px; cursor: pointer;
  font: inherit; font-weight: 550; font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.status-steps button:hover { border-color: var(--accent); color: var(--text); }
.status-steps button.current.red { background: var(--red-bg); border-color: #fca5a5; color: var(--red-fg); }
.status-steps button.current.amber { background: var(--amber-bg); border-color: #fcd34d; color: var(--amber-fg); }
.status-steps button.current.green { background: var(--green-bg); border-color: #86efac; color: var(--green-fg); }
.description { font-size: 14.5px; line-height: 1.65; }

.timeline { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: 0; }
.comment .bubble { flex: 1; min-width: 0; }
.comment .meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
.activity { display: flex; gap: 10px; font-size: 12.5px; color: var(--muted); padding: 7px 0; }
.activity::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); margin-top: 6px; flex: none; }

.attachments { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 10px; }
.attachment { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--surface-2); min-width: 0; }
.attachment video, .attachment img { width: 100%; max-height: 220px; border-radius: 6px; background: #000; display: block; object-fit: contain; }
.attachment img { background: #fff; }
.attachment audio { width: 100%; display: block; }
.attachment .att-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.attachment .att-foot .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Zone de saisie média (fichiers + enregistrements) */
.media-input { border: 1px dashed var(--border-strong); border-radius: 8px; padding: 12px; background: var(--surface-2); }
.media-input .media-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.media-input .timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--danger); }
.media-input .preview-live { margin-top: 10px; max-width: 360px; border-radius: 8px; background: #000; display: none; }
.media-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.media-list li { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.media-list li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-list li audio { height: 32px; max-width: 220px; }
.media-list li button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 0 4px; }
.media-list li button:hover { color: var(--danger); }
.dropzone-active { border-color: var(--accent); background: var(--accent-soft); }

/* Autocomplétion client */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 10px 30px rgba(15, 23, 42, .12); max-height: 320px; overflow-y: auto; display: none; }
.combo-list.open { display: block; }
.combo-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; cursor: pointer; font: inherit; border-bottom: 1px solid var(--border); }
.combo-list button:last-child { border-bottom: 0; }
.combo-list button:hover, .combo-list button.hl { background: var(--accent-soft); }
.combo-list .sub { display: block; font-size: 12px; color: var(--muted); }
.combo-selected { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); }
.combo-selected .grow { flex: 1; min-width: 0; }

/* BC */
.bc-lines { width: 100%; border-collapse: collapse; }
.bc-lines td { padding: 4px 4px 4px 0; vertical-align: top; }
.bc-doc { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
details.disclosure > summary { cursor: pointer; font-weight: 550; color: var(--accent); list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure[open] > summary { margin-bottom: 10px; }

/* Pagination */
.pagination { display: flex; gap: 4px; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination a, .pagination span.page { min-width: 32px; padding: 5px 9px; border-radius: 6px; text-align: center; border: 1px solid var(--border); color: var(--text); background: #fff; font-size: 13px; }
.pagination a:hover { text-decoration: none; background: var(--surface-2); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .disabled { color: var(--border-strong); }

/* Connexion */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #dbe7ff, transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 32px; }
.login-card .brand { color: var(--text); padding: 0 0 24px; }
.login-card .brand small { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout-side { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .4); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--sidebar); color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
  .content { padding: 18px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .ticket-meta { grid-template-columns: 1fr; gap: 2px 0; }
  .ticket-meta dd { margin-bottom: 8px; }
}
