/* ============================================================
   SupportDesk — Design System v2
   Palette : #2596be (primaire) + tons neutres
   Icons    : Font Awesome 6 Free
   Usage    : tous les fichiers HTML via <link rel="stylesheet">
   ============================================================ */

/* ── IMPORTS ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

/* ── VARIABLES ───────────────────────────────────────────── */
:root {
  /* Palette principale */
  --primary:       #2596be;
  --primary-dark:  #1a7a9e;
  --primary-light: #4aadce;
  --primary-pale:  #e8f5fb;
  --primary-10:    rgba(37,150,190,.10);
  --primary-20:    rgba(37,150,190,.20);

  /* Neutrals */
  --ink:           #111827;
  --ink-2:         #374151;
  --ink-3:         #6b7280;
  --ink-4:         #9ca3af;
  --border:        #e5e7eb;
  --border-2:      #d1d5db;
  --bg:            #f9fafb;
  --surface:       #ffffff;
  --surface-2:     #f3f4f6;

  /* Statuts */
  --success:       #059669;
  --success-bg:    #ecfdf5;
  --warn:          #d97706;
  --warn-bg:       #fffbeb;
  --danger:        #dc2626;
  --danger-bg:     #fef2f2;
  --info:          var(--primary);
  --info-bg:       var(--primary-pale);

  /* Layout */
  --sidebar-w:     260px;
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     14px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:     0 10px 30px rgba(0,0,0,.10);

  /* Typo */
  --font:          'Inter', system-ui, -apple-system, sans-serif;
  --font-head:     'Space Grotesk', 'Inter', sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', monospace;
}

/* ── DARK MODE sidebar (agent panel) ─────────────────────── */
:root[data-panel="agent"] {
  --sidebar-bg:    #0f172a;
  --sidebar-text:  #94a3b8;
  --sidebar-hover: rgba(37,150,190,.08);
  --sidebar-active:rgba(37,150,190,.15);
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── LAYOUT ──────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ── SIDEBAR CLIENT (clair) ──────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100; overflow-y: auto;
  box-shadow: var(--shadow);
}
.sidebar-brand {
  padding: 1.25rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--primary); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px; flex-shrink: 0;
}
.sidebar-brand .brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1rem; color: var(--ink); }
.sidebar-brand .brand-sub  { font-size: .7rem; color: var(--ink-4); margin-top: 1px; }
.sidebar-user {
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: .9rem; flex-shrink: 0;
}
.user-info .uname { font-size: .85rem; font-weight: 600; color: var(--ink); }
.user-info .urole { font-size: .72rem; color: var(--ink-4); }
.sidebar-nav { flex: 1; padding: .75rem .75rem; overflow-y: auto; }
.nav-section { font-size: .65rem; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-4); padding: .6rem .5rem .3rem; margin-top: .3rem; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-3); font-size: .85rem; font-weight: 500;
  transition: all .15s; border: none; background: none;
  width: 100%; text-align: left; margin-bottom: 2px;
}
.nav-item:hover { background: var(--primary-pale); color: var(--primary-dark); }
.nav-item.active { background: var(--primary-10); color: var(--primary-dark); font-weight: 600; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 14px; opacity: .8; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--primary); color: white;
  font-size: .62rem; padding: 1px 7px; border-radius: 20px; font-weight: 600;
}
.sidebar-footer { padding: .9rem 1.2rem; border-top: 1px solid var(--border); }

/* ── SIDEBAR AGENT (sombre) ──────────────────────────────── */
.sidebar-dark {
  background: #0f172a;
  border-right: none;
}
.sidebar-dark .sidebar-brand { border-color: rgba(255,255,255,.07); }
.sidebar-dark .sidebar-brand .brand-name { color: #f1f5f9; }
.sidebar-dark .sidebar-brand .brand-sub  { color: #64748b; }
.sidebar-dark .sidebar-user { border-color: rgba(255,255,255,.07); }
.sidebar-dark .user-info .uname { color: #e2e8f0; }
.sidebar-dark .user-info .urole { color: #64748b; }
.sidebar-dark .nav-section { color: #475569; }
.sidebar-dark .nav-item { color: #94a3b8; }
.sidebar-dark .nav-item:hover { background: rgba(37,150,190,.08); color: #e2e8f0; }
.sidebar-dark .nav-item.active { background: rgba(37,150,190,.15); color: #7dd3f0; }
.sidebar-dark .sidebar-footer { border-color: rgba(255,255,255,.07); }

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.topbar-title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── PAGE CONTENT ────────────────────────────────────────── */
.page-content { padding: 1.5rem; flex: 1; }
.view { display: none; }
.view.active { display: block; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: .84rem; font-weight: 500; border: none;
  transition: all .15s; white-space: nowrap; cursor: pointer;
  font-family: var(--font);
}
.btn-sm  { padding: 6px 12px; font-size: .8rem; }
.btn-xs  { padding: 4px 9px;  font-size: .75rem; }
.btn-lg  { padding: 10px 20px; font-size: .9rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(.9); }
.btn-danger  { background: var(--danger-bg); color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover  { background: #fee2e2; }
.btn-ghost   { background: none; color: var(--ink-3); border: 1px solid var(--border); }
.btn-ghost:hover   { color: var(--ink); border-color: var(--border-2); background: var(--surface-2); }
.btn-link    { background: none; border: none; color: var(--primary); padding: 0; font-size: .84rem; }
.btn-link:hover { color: var(--primary-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn i, .btn svg { font-size: .9em; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
/* Statuts tickets */
.badge-ouvert     { background: var(--primary-10); color: var(--primary-dark); }
.badge-en_cours   { background: var(--warn-bg); color: var(--warn); }
.badge-en_attente { background: #f5f3ff; color: #7c3aed; }
.badge-résolu     { background: var(--success-bg); color: var(--success); }
.badge-fermé      { background: var(--surface-2); color: var(--ink-3); }
/* Priorités */
.badge-urgente    { background: var(--danger-bg); color: var(--danger); }
.badge-haute      { background: var(--warn-bg); color: var(--warn); }
.badge-normale    { background: var(--primary-10); color: var(--primary-dark); }
.badge-faible     { background: var(--surface-2); color: var(--ink-4); }
/* Commandes */
.badge-en_cours_cmd { background: var(--warn-bg); color: var(--warn); }
.badge-livrée     { background: var(--success-bg); color: var(--success); }
.badge-facturée   { background: var(--primary-10); color: var(--primary-dark); }
.badge-annulée    { background: var(--danger-bg); color: var(--danger); }
/* Interventions */
.badge-int-ouvert  { background: var(--primary-10); color: var(--primary-dark); }
.badge-int-en_cours{ background: var(--warn-bg); color: var(--warn); }
.badge-int-résolu  { background: var(--success-bg); color: var(--success); }
.badge-int-facturé { background: #f5f3ff; color: #7c3aed; }
.badge-sc  { background: var(--success-bg); color: var(--success); }
.badge-hc  { background: var(--warn-bg); color: var(--warn); }
.badge-ia  { background: #f5f3ff; color: #7c3aed; font-size: .65rem; padding: 1px 6px; }
/* Contrats */
.badge-actif    { background: var(--success-bg); color: var(--success); }
.badge-expiré   { background: var(--danger-bg); color: var(--danger); }
.badge-suspendu { background: var(--warn-bg); color: var(--warn); }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1rem;
  transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-4); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-family: var(--font-head); font-weight: 700; font-size: 1.8rem; color: var(--ink); line-height: 1; }
.stat-card.primary   .stat-value { color: var(--primary); }
.stat-card.success   .stat-value { color: var(--success); }
.stat-card.warn      .stat-value { color: var(--warn); }
.stat-card.danger    .stat-value { color: var(--danger); }
.stat-card.purple    .stat-value { color: #7c3aed; }

/* ── TABLES ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .5px; color: var(--ink-4); font-weight: 600;
  padding: .65rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .84rem; vertical-align: middle; color: var(--ink-2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s; cursor: pointer; }
.data-table tbody tr:hover td { background: var(--primary-pale); }
.mono { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-3); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

/* ── FILTERS BAR ─────────────────────────────────────────── */
.filters-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.filter-btn {
  padding: 5px 13px; border-radius: 20px; font-size: .78rem; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-3); transition: all .15s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.search-box {
  margin-left: auto; position: relative;
}
.search-box input {
  padding: 6px 12px 6px 34px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: .82rem; width: 210px; outline: none; color: var(--ink);
  transition: border-color .2s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box .search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ink-4); font-size: 12px; pointer-events: none;
}

/* ── FORMS ───────────────────────────────────────────────── */
.form-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 1.75rem;
}
.form-section-title {
  font-family: var(--font-head); font-weight: 600; font-size: .82rem;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px;
  padding: .8rem 0 .5rem; margin-top: .5rem;
  border-top: 1px solid var(--border); margin-bottom: .75rem;
}
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: .82rem; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.form-label .req { color: var(--danger); }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  font-size: .85rem; color: var(--ink); background: var(--surface);
  outline: none; transition: border-color .2s, box-shadow .2s;
  font-family: var(--font);
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-10); }
.form-control:disabled { background: var(--surface-2); color: var(--ink-4); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-hint { font-size: .75rem; color: var(--ink-4); margin-top: 4px; }

/* ── MESSAGES / CHAT ──────────────────────────────────────── */
.messages-wrap { display: flex; flex-direction: column; gap: 10px; margin-bottom: 1.25rem; }
.message {
  max-width: 80%; padding: 11px 15px; border-radius: var(--radius-lg);
  font-size: .85rem; line-height: 1.6;
}
.message-client {
  background: var(--primary); color: white;
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.message-agent {
  background: var(--surface); color: var(--ink);
  align-self: flex-start; border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.message-ia {
  background: linear-gradient(135deg, var(--primary-pale), #f0ebff);
  color: var(--ink); align-self: flex-start;
  border: 1px solid var(--primary-20); border-bottom-left-radius: 4px;
}
.message-internal {
  background: var(--warn-bg); color: var(--ink);
  align-self: flex-start; border: 1px dashed #fbbf24;
  border-radius: var(--radius-sm);
}
.message-meta {
  font-size: .7rem; margin-bottom: 5px;
  display: flex; align-items: center; gap: 6px;
  opacity: .75;
}
.message-client .message-meta { color: rgba(255,255,255,.85); opacity: 1; }
.message-ia .message-meta { color: var(--primary-dark); opacity: 1; }
.message-text { white-space: pre-wrap; }

/* ── REPLY BOX ───────────────────────────────────────────── */
.reply-box {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 1.1rem;
}
.reply-tabs { display: flex; gap: 4px; margin-bottom: .75rem; }
.reply-tab {
  padding: 5px 13px; border-radius: var(--radius-sm); font-size: .78rem;
  font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: none; color: var(--ink-3); transition: all .15s;
}
.reply-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.reply-tab.warn.active { background: var(--warn); border-color: var(--warn); }
.reply-actions { display: flex; gap: 8px; margin-top: .6rem; align-items: center; flex-wrap: wrap; }
.reply-tip {
  margin-top: .6rem; padding: 9px 12px;
  background: var(--primary-pale); border: 1px solid var(--primary-20);
  border-radius: var(--radius-sm); font-size: .78rem; color: var(--primary-dark);
  display: flex; align-items: flex-start; gap: 7px;
}

/* ── PIECES JOINTES ──────────────────────────────────────── */
.pj-zone { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.pj-zone h5 { font-size: .82rem; font-weight: 600; color: var(--ink-3); margin-bottom: .5rem; display: flex; align-items: center; gap: 7px; }
.pj-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 20px; }
.pj-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .76rem; color: var(--ink-2);
}
.pj-item a { color: var(--primary); text-decoration: none; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-item a:hover { text-decoration: underline; }
.pj-item .pj-size { color: var(--ink-4); font-size: .7rem; }
.pj-item .pj-del { color: var(--danger); cursor: pointer; padding: 0 2px; font-size: .75rem; }
.pj-upload { display: flex; align-items: center; gap: 8px; margin-top: .5rem; }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.card-title { font-family: var(--font-head); font-weight: 700; font-size: .95rem; color: var(--ink); margin-bottom: .9rem; display: flex; align-items: center; gap: 8px; }
.ticket-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  cursor: pointer; transition: all .15s; margin-bottom: .5rem;
  display: flex; justify-content: space-between; align-items: flex-start;
}
.ticket-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px var(--primary-10); }
.ticket-number { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-4); margin-bottom: 4px; }
.ticket-subject { font-weight: 600; font-size: .9rem; color: var(--ink); margin-bottom: 5px; }
.ticket-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .76rem; color: var(--ink-4); }
.ticket-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }

/* ── MODALS ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 1.75rem; width: 90%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px); transition: transform .2s;
}
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; }
.modal-close { background: none; border: none; font-size: 1.2rem; color: var(--ink-4); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); transition: background .15s; }
.modal-close:hover { background: var(--surface-2); color: var(--ink); }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .84rem; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: 9px; }
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: var(--danger-bg); color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: var(--primary-pale); color: var(--primary-dark); border: 1px solid var(--primary-20); }
.alert-warn    { background: var(--warn-bg); color: #92400e; border: 1px solid #fde68a; }

/* ── NOTIFICATIONS ───────────────────────────────────────── */
.notif-bell { position: relative; cursor: pointer; padding: 6px; border-radius: var(--radius-sm); color: var(--ink-3); transition: background .15s; }
.notif-bell:hover { background: var(--surface-2); }
.notif-badge {
  position: absolute; top: 1px; right: 1px;
  background: var(--danger); color: white;
  font-size: .6rem; font-weight: 700; padding: 1px 4px;
  border-radius: 20px; min-width: 16px; text-align: center;
  display: none; line-height: 1.4;
}
.notif-panel {
  position: fixed; top: 58px; right: 15px; width: 340px; max-height: 440px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 200; overflow: hidden; display: none; flex-direction: column;
}
.notif-panel.show { display: flex; }
.notif-head { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notif-head span { font-weight: 600; font-size: .85rem; }
.notif-scroll { overflow-y: auto; flex: 1; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; cursor: pointer; transition: background .12s; }
.notif-item:hover { background: var(--primary-pale); }
.notif-item.unread { border-left: 3px solid var(--primary); background: rgba(37,150,190,.03); }
.notif-item .ni-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-10); display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 13px; flex-shrink: 0; }
.notif-item .ni-title { font-size: .82rem; font-weight: 500; }
.notif-item.unread .ni-title { font-weight: 600; }
.notif-item .ni-msg  { font-size: .75rem; color: var(--ink-4); margin-top: 1px; }
.notif-item .ni-time { font-size: .68rem; color: var(--ink-4); margin-top: 2px; }

/* ── CHARTS ──────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; }
.chart-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-4); margin-bottom: .75rem; }
.chart-wrap { position: relative; height: 200px; }

/* ── DETAIL LAYOUT (ticket agent) ────────────────────────── */
.detail-layout { display: grid; grid-template-columns: 1fr 270px; gap: 1rem; min-height: calc(100vh - 130px); }
.detail-main { display: flex; flex-direction: column; min-height: 0; }
.detail-header { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin-bottom: .75rem; }
.detail-title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; margin-bottom: .4rem; }
.detail-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-4); }
.msgs-container { flex: 1; overflow-y: auto; padding: .3rem 0; display: flex; flex-direction: column; gap: 9px; min-height: 180px; max-height: calc(100vh - 460px); }
.detail-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; overflow-y: auto; }
.side-section { margin-bottom: 1rem; }
.side-section h4 { font-size: .68rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; color: var(--ink-4); margin-bottom: .4rem; }
.info-row { display: flex; justify-content: space-between; font-size: .78rem; padding: 5px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border: none; }
.info-key { color: var(--ink-4); }
.info-val { color: var(--ink); font-weight: 500; text-align: right; max-width: 55%; }
.form-select { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .8rem; color: var(--ink); background: var(--surface); outline: none; cursor: pointer; margin-top: 3px; font-family: var(--font); }
.form-select:focus { border-color: var(--primary); }

/* ── PRODUCT GRID ────────────────────────────────────────── */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.product-option { border: 1.5px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: pointer; transition: all .15s; background: var(--surface); }
.product-option:hover { border-color: var(--primary); }
.product-option.selected { border-color: var(--primary); background: var(--primary-pale); }
.product-option input[type="radio"] { display: none; }
.product-opt-check { float: right; color: var(--primary); display: none; }
.product-option.selected .product-opt-check { display: block; }
.product-opt-name { font-weight: 600; font-size: .88rem; color: var(--ink); margin-bottom: 3px; }
.product-opt-contract { font-size: .74rem; color: var(--ink-4); }

/* ── LOADING ─────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(249,250,251,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; backdrop-filter: blur(3px);
}
.loading-spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mini-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); border-top-color: white; animation: spin .7s linear infinite; display: inline-block; }

/* ── TYPING INDICATOR ────────────────────────────────────── */
.ia-typing { display: none; align-items: center; gap: 8px; font-size: .8rem; color: var(--primary); padding: 8px 0; }
.ia-typing.show { display: flex; }
.typing-dot { width: 6px; height: 6px; background: var(--primary); border-radius: 50%; animation: bounce 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%,80%,100%{ transform: translateY(0) } 40%{ transform: translateY(-7px) } }

/* ── LOGOUT BUTTON ───────────────────────────────────────── */
.btn-logout {
  width: 100%; padding: 8px 12px; background: none;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--ink-3); cursor: pointer; font-size: .82rem;
  font-family: var(--font); display: flex; align-items: center; gap: 8px;
  transition: all .15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

/* ── TABLES (lignes commandes) ───────────────────────────── */
.lines-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: .5rem; }
.lines-table th { text-align: left; padding: 6px 9px; font-size: .72rem; color: var(--ink-4); background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 600; }
.lines-table td { padding: 6px 9px; border-bottom: 1px solid var(--border); }
.lines-table input, .lines-table select { width: 100%; padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .8rem; color: var(--ink); background: var(--surface); outline: none; }
.lines-table input:focus { border-color: var(--primary); }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3.5rem 2rem; color: var(--ink-4); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 1rem; color: var(--border-2); }
.empty-state p { font-size: .88rem; margin-top: .4rem; }

/* ── INFO GRID ───────────────────────────────────────────── */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1.5rem; }
.info-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.info-item { padding: 6px 0; border-bottom: 1px solid var(--border); }
.info-item:nth-last-child(-n+2) { border-bottom: none; }
.info-key-sm { font-size: .72rem; color: var(--ink-4); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 2px; }
.info-val-lg  { font-size: .88rem; font-weight: 500; color: var(--ink); }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { display: none; }
  .charts-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; }
}

/* ── COMPAT ALIASES ──────────────────────────────────────────────────────── */
.messages-container { display: flex; flex-direction: column; gap: 10px; margin-bottom: 1.25rem; }
.ticket-detail-header { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 1.5rem; margin-bottom: 1.5rem; }
.ticket-detail-title { font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; margin-bottom: .8rem; }
.ticket-info-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.ticket-info-item { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--ink-4); }
.ia-badge { background: var(--primary-10); color: var(--primary-dark); font-size: .65rem; padding: 1px 7px; border-radius: 20px; font-weight: 600; }
