
    :root {
      --bg: #f5f6fa;
      --s1: #ffffff;
      --s2: #f0f1f5;
      --s3: #e8e9f0;
      --s4: #dcdee8;
      --border: #d8dae5;
      --accent: #4f46e5;
      --green: #10b981;
      --red: #ef4444;
      --blue: #3b82f6;
      --text: #1e293b;
      --t2: #64748b;
      --t3: #94a3b8;
      --r: 10px;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box
    }

    body {
      font-family: 'DM Sans', sans-serif;
      background: var(--bg);
      color: var(--text);
      height: 100vh;
      display: flex;
      overflow: hidden
    }

    /* LOGIN */
    #login-screen {
      position: fixed;
      inset: 0;
      background: var(--bg);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000
    }

    .lcard {
      width: 380px;
      background: var(--s1);
      border: 1px solid var(--border);
      border-radius: 16px;
      padding: 40px 36px
    }

    .llogo {
      font-family: 'Syne', sans-serif;
      font-size: 26px;
      font-weight: 800;
      color: var(--accent);
      margin-bottom: 4px
    }

    .lsub {
      color: var(--t2);
      font-size: 13px;
      margin-bottom: 32px
    }

    .ltabs {
      display: flex;
      gap: 3px;
      background: var(--s2);
      border-radius: 7px;
      padding: 3px;
      margin-bottom: 24px
    }

    .ltab {
      flex: 1;
      padding: 7px;
      text-align: center;
      border-radius: 5px;
      cursor: pointer;
      font-size: 13px;
      color: var(--t2);
      border: none;
      background: none;
      font-family: 'DM Sans', sans-serif;
      transition: .15s
    }

    .ltab.active {
      background: var(--s3);
      color: var(--text)
    }

    .fg {
      margin-bottom: 14px
    }

    label {
      display: block;
      font-size: 11px;
      color: var(--t2);
      margin-bottom: 5px;
      text-transform: uppercase;
      letter-spacing: .5px;
      font-weight: 500
    }

    input,
    textarea,
    select {
      width: 100%;
      background: var(--s2);
      border: 1px solid var(--border);
      border-radius: 7px;
      padding: 9px 12px;
      color: var(--text);
      font-size: 14px;
      font-family: 'DM Sans', sans-serif;
      outline: none;
      transition: border-color .15s
    }

    input:focus,
    textarea:focus,
    select:focus {
      border-color: var(--accent)
    }

    select option {
      background: var(--s2)
    }

    textarea {
      resize: vertical
    }

    .btn {
      padding: 9px 18px;
      border-radius: 7px;
      border: none;
      cursor: pointer;
      font-family: 'DM Sans', sans-serif;
      font-size: 13px;
      font-weight: 600;
      transition: .15s;
      display: inline-flex;
      align-items: center;
      gap: 5px
    }

    .bp {
      background: var(--accent);
      color: #fff;
      justify-content: center
    }

    .bp:hover {
      background: #6366f1;
      transform: translateY(-1px)
    }

    .bp:disabled {
      opacity: .4;
      cursor: not-allowed;
      transform: none
    }

    .bg {
      background: transparent;
      color: var(--t2);
      border: 1px solid var(--border)
    }

    .bg:hover {
      background: var(--s2);
      color: var(--text)
    }

    .bd {
      background: rgba(239, 68, 68, .08);
      color: var(--red);
      border: 1px solid rgba(239, 68, 68, .2)
    }

    .bd:hover {
      background: rgba(239, 68, 68, .15)
    }

    .bgreen {
      background: rgba(16, 185, 129, .08);
      color: var(--green);
      border: 1px solid rgba(16, 185, 129, .2)
    }

    .bgreen:hover {
      background: rgba(16, 185, 129, .15)
    }

    .bblue {
      background: rgba(59, 130, 246, .08);
      color: var(--blue);
      border: 1px solid rgba(59, 130, 246, .2)
    }

    .bblue:disabled {
      opacity: .4;
      cursor: not-allowed;
      transform: none
    }

    .err {
      color: var(--red);
      font-size: 12px;
      margin-top: 10px;
      text-align: center
    }

    /* APP */
    #app {
      display: flex;
      width: 100%;
      height: 100vh
    }

    .sidebar {
      width: 210px;
      background: var(--s1);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      flex-shrink: 0;
      box-shadow: 2px 0 8px rgba(0, 0, 0, .04)
    }

    .slogo {
      padding: 18px 16px 14px;
      font-family: 'Syne', sans-serif;
      font-size: 18px;
      font-weight: 800;
      color: var(--accent);
      border-bottom: 1px solid var(--border);
      letter-spacing: -.3px
    }

    .slogo small {
      color: var(--t3);
      font-family: 'DM Sans', sans-serif;
      font-size: 11px;
      font-weight: 400;
      display: block;
      margin-top: 1px
    }

    .snav {
      flex: 1;
      padding: 12px 10px;
      display: flex;
      flex-direction: column;
      gap: 2px
    }

    .ni {
      display: flex;
      align-items: center;
      gap: 9px;
      padding: 8px 10px;
      border-radius: 7px;
      cursor: pointer;
      color: var(--t2);
      font-size: 13px;
      border: none;
      background: none;
      font-family: 'DM Sans', sans-serif;
      width: 100%;
      text-align: left;
      transition: .12s
    }

    .ni:hover {
      background: var(--s2);
      color: var(--text)
    }

    .ni.active {
      background: rgba(79, 70, 229, .08);
      color: var(--accent)
    }

    .ni-icon {
      font-size: 15px;
      width: 18px;
      text-align: center
    }

    .nbadge {
      margin-left: auto;
      background: var(--red);
      color: #fff;
      font-size: 10px;
      padding: 2px 6px;
      border-radius: 8px;
      font-weight: 700
    }

    .suser {
      padding: 14px;
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 8px
    }

    .uavatar {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background: var(--accent);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 800;
      font-size: 12px;
      flex-shrink: 0
    }

    .uname {
      font-size: 12px;
      font-weight: 600
    }

    .urole {
      font-size: 10px;
      color: var(--t3)
    }

    .logout {
      margin-left: auto;
      background: none;
      border: none;
      color: var(--t3);
      cursor: pointer;
      font-size: 15px;
      padding: 3px;
      border-radius: 4px;
      transition: color .15s
    }

    .logout:hover {
      color: var(--red)
    }

    /* MAIN */
    .main {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden
    }

    .topbar {
      height: 70px;
      padding: 14px 20px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 12px;
      background: var(--s1)
    }

    .ptitle {
      font-family: 'Syne', sans-serif;
      font-size: 18px;
      font-weight: 700
    }

    .tactions {
      margin-left: auto;
      display: flex;
      gap: 7px
    }

    .pcontent {
      flex: 1;
      overflow-y: auto;
      padding: 20px;
      min-height: 0
    }

    /* STATS */
    .sgrid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 14px;
      margin-bottom: 20px
    }

    @media(max-width:900px) {
      .sgrid {
        grid-template-columns: repeat(2, 1fr)
      }
    }

    @media(max-width:540px) {
      .sgrid {
        grid-template-columns: 1fr
      }
    }

    .scard {
      background: var(--s1);
      border: 1px solid var(--border);
      border-radius: var(--r);
      padding: 18px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, .04)
    }

    .slabel {
      font-size: 10px;
      color: var(--t3);
      text-transform: uppercase;
      letter-spacing: .7px;
      margin-bottom: 6px
    }

    .sval {
      font-family: 'DM Mono', monospace;
      font-size: 22px;
      font-weight: 500
    }

    .sval.ya {
      color: var(--accent)
    }

    .sval.yg {
      color: var(--green)
    }

    .sval.yr {
      color: var(--red)
    }

    .ssub {
      font-size: 11px;
      color: var(--t3);
      margin-top: 3px
    }

    /* TABLE */
    .twrap {
      background: var(--s1);
      border: 1px solid var(--border);
      border-radius: var(--r);
      overflow: hidden;
      box-shadow: 0 1px 3px rgba(0, 0, 0, .04)
    }

    .tfilters {
      display: flex;
      gap: 8px;
      margin-bottom: 14px;
      flex-wrap: wrap;
      align-items: center
    }

    /* Invoice filter bar */
    .inv-filters {
      display: flex;
      align-items: center;
      gap: 16px;
      padding: 10px 20px;
      flex-shrink: 0;
      border-bottom: 1px solid var(--border);
      background: var(--s1);
      overflow-x: auto
    }

    .sinput {
      position: relative;
      min-width: 160px;
      max-width: 220px
    }

    .sinput input {
      padding-left: 28px;
      padding-right: 26px;
      height: 32px;
      font-size: 12px;
      border-radius: 7px;
      background: var(--s2);
      border: 1px solid var(--border)
    }

    .sinput input:focus {
      border-color: var(--accent);
      outline: none
    }

    .sicon {
      position: absolute;
      left: 9px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--t3);
      font-size: 11px;
      pointer-events: none
    }

    .sclear {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--t3);
      font-size: 14px;
      cursor: pointer;
      display: none;
      line-height: 1;
      padding: 2px 4px;
      border-radius: 50%;
    }

    .sclear:hover {
      color: var(--text);
      background: var(--s3);
    }

    .sinput input:not(:placeholder-shown) ~ .sclear {
      display: block
    }

    /* Primary tabs — status */
    .ftabs {
      display: inline-flex;
      background: var(--s2);
      border-radius: 8px;
      padding: 2px;
      border: 1px solid var(--border)
    }

    .ftab {
      padding: 5px 14px;
      border: none;
      background: none;
      border-radius: 6px;
      cursor: pointer;
      font-size: 12px;
      font-family: 'DM Sans', sans-serif;
      color: var(--t2);
      transition: all .12s;
      white-space: nowrap
    }

    .ftab:hover {
      color: var(--text)
    }

    .ftab.on {
      background: var(--s1);
      color: var(--accent);
      font-weight: 600;
      box-shadow: 0 1px 3px rgba(0, 0, 0, .06)
    }

    .ftab .tc {
      font-size: 10px;
      font-family: 'DM Mono', monospace;
      opacity: .6;
      margin-left: 2px
    }

    .ftab.on .tc {
      opacity: .85
    }

    /* Separator */
    .fsep2 {
      width: 1px;
      height: 24px;
      background: var(--border);
      flex-shrink: 0;
      margin: 0 2px
    }

    /* Filter selects */
    .fsel {
      height: 32px;
      padding: 0 28px 0 10px;
      border-radius: 7px;
      border: 1px solid var(--border);
      background: var(--s2);
      color: var(--t2);
      font-size: 12px;
      font-family: 'DM Sans', sans-serif;
      cursor: pointer;
      appearance: none;
      -webkit-appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 9px center;
      transition: all .15s
    }

    .fsel:hover {
      border-color: var(--accent);
      color: var(--text)
    }

    .fsel:focus {
      border-color: var(--accent);
      outline: none;
      box-shadow: 0 0 0 2px rgba(79, 70, 229, .1)
    }

    .fsel.fsel-warn {
      border-color: rgba(245, 158, 11, .5);
      color: #92400e;
      background-color: rgba(245, 158, 11, .06);
      font-weight: 500
    }

    .fsel.fsel-green {
      border-color: rgba(16, 185, 129, .4);
      color: #065f46;
      background-color: rgba(16, 185, 129, .06);
      font-weight: 500
    }

    .fsel.fsel-red {
      border-color: rgba(239, 68, 68, .4);
      color: #991b1b;
      background-color: rgba(239, 68, 68, .06);
      font-weight: 500
    }

    .fsel.fsel-blue {
      border-color: rgba(59, 130, 246, .4);
      color: #1e40af;
      background-color: rgba(59, 130, 246, .06);
      font-weight: 500
    }

    /* Result count */
    .finfo {
      margin-left: auto;
      font-size: 11px;
      color: var(--t3);
      font-family: 'DM Mono', monospace;
      white-space: nowrap;
      padding-left: 8px
    }

    /* Legacy fbtn for other pages */
    .fbtn {
      padding: 7px 12px;
      border-radius: 7px;
      border: 1px solid var(--border);
      background: var(--s2);
      color: var(--t2);
      cursor: pointer;
      font-size: 12px;
      font-family: 'DM Sans', sans-serif;
      transition: .12s;
      white-space: nowrap
    }

    .fbtn:hover,
    .fbtn.active {
      background: var(--s3);
      color: var(--text);
      border-color: var(--accent)
    }

    .fbtn.active {
      color: var(--accent)
    }

    .fcnt {
      display: inline-block;
      background: var(--s3);
      border-radius: 8px;
      padding: 0 5px;
      font-size: 10px;
      font-family: 'DM Mono', monospace;
      color: var(--t2);
      margin-left: 2px;
      min-width: 18px;
      text-align: center;
      line-height: 16px;
      vertical-align: middle
    }

    .fbtn.active .fcnt {
      background: rgba(79, 70, 229, .15);
      color: var(--accent)
    }

    table {
      width: 100%;
      border-collapse: collapse
    }

    th {
      padding: 9px 14px;
      text-align: left;
      font-size: 10px;
      color: var(--t3);
      text-transform: uppercase;
      letter-spacing: .5px;
      font-weight: 600;
      background: var(--s2);
      border-bottom: 1px solid var(--border);
      position: sticky;
      top: 0;
      z-index: 2
    }

    th[data-sort] {
      cursor: pointer;
      user-select: none;
      padding-right: 20px
    }

    th[data-sort]:hover {
      color: var(--text)
    }

    th[data-sort]::after {
      content: '⇅';
      position: absolute;
      right: 4px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 9px;
      opacity: .3
    }

    th[data-sort].asc::after {
      content: '↑';
      opacity: .8;
      color: var(--accent)
    }

    th[data-sort].desc::after {
      content: '↓';
      opacity: .8;
      color: var(--accent)
    }

    th[data-sort] .sort-rank {
      font-size: 8px;
      color: var(--accent);
      margin-left: 2px;
      font-weight: 700
    }

    td {
      padding: 10px 14px;
      font-size: 13px;
      border-bottom: 1px solid var(--border);
      vertical-align: middle
    }

    tr:last-child td {
      border-bottom: none
    }

    tr:hover td {
      background: rgba(0, 0, 0, .02)
    }

    .iref {
      font-family: 'DM Mono', monospace;
      font-size: 12px;
      color: var(--t2)
    }

    .iamt {
      font-family: 'DM Mono', monospace;
      font-weight: 500
    }

    .badge {
      display: inline-flex;
      align-items: center;
      padding: 2px 7px;
      border-radius: 5px;
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: .4px
    }

    .bpend {
      background: rgba(79, 70, 229, .08);
      color: var(--accent);
      border: 1px solid rgba(79, 70, 229, .18)
    }

    .bpaid {
      background: rgba(16, 185, 129, .08);
      color: var(--green);
      border: 1px solid rgba(16, 185, 129, .18)
    }

    .rovr .act-wrap {
      display: flex;
      align-items: center;
      gap: 5px;
      flex-wrap: wrap
    }

    .ab {
      width: 26px;
      height: 26px;
      border-radius: 5px;
      border: 1px solid var(--border);
      background: var(--s2);
      color: var(--t2);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 12px;
      transition: .12s;
      flex-shrink: 0
    }

    .ab:hover {
      background: var(--s3);
      color: var(--text)
    }

    .ab.ag:hover {
      background: rgba(16, 185, 129, .1);
      color: var(--green);
      border-color: rgba(16, 185, 129, .3)
    }

    .ab.ar:hover {
      background: rgba(239, 68, 68, .1);
      color: var(--red);
      border-color: rgba(239, 68, 68, .3)
    }

    .cb {
      width: 40px
    }

    input[type="checkbox"] {
      width: 14px;
      height: 14px;
      accent-color: var(--accent);
      cursor: pointer
    }

    .selrow {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 14px;
      border-bottom: 1px solid var(--border);
      background: var(--s2);
      font-size: 12px;
      color: var(--t2)
    }

    /* BULK BAR */
    .bbar {
      background: var(--s1);
      border-top: 1px solid var(--border);
      padding: 11px 18px;
      display: none;
      align-items: center;
      gap: 10px;
      box-shadow: 0 -4px 12px rgba(0, 0, 0, .06);
      flex-wrap: wrap;
      justify-content: center;
      flex-shrink: 0
    }

    .bbar.on {
      display: flex
    }

    .bcnt {
      font-family: 'DM Mono', monospace;
      font-size: 12px;
      color: var(--accent);
      font-weight: 500
    }

    /* MODAL */
    .mover {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, .3);
      backdrop-filter: blur(4px);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 500;
      opacity: 0;
      pointer-events: none;
      transition: opacity .18s
    }

    .mover.open {
      opacity: 1;
      pointer-events: all
    }

    .modal {
      background: var(--s1);
      border: 1px solid var(--border);
      border-radius: 14px;
      padding: 28px;
      max-width: 95vw;
      max-height: 88vh;
      overflow-y: auto;
      transform: translateY(16px);
      transition: transform .18s;
      box-shadow: 0 12px 40px rgba(0, 0, 0, .12)
    }

    .mover.open .modal {
      transform: translateY(0)
    }

    .mlg {
      width: 560px
    }

    .mxl {
      width: 800px
    }

    .mtitle {
      font-family: 'Syne', sans-serif;
      font-size: 16px;
      font-weight: 700;
      margin-bottom: 20px;
      display: flex;
      align-items: center;
      justify-content: space-between
    }

    .mclose {
      background: none;
      border: none;
      color: var(--t3);
      cursor: pointer;
      font-size: 18px;
      line-height: 1;
      padding: 0
    }

    .mclose:hover {
      color: var(--text)
    }

    .frow {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 14px
    }

    .factions {
      display: flex;
      gap: 7px;
      justify-content: flex-end;
      margin-top: 20px
    }

    /* CHAT */
    .ccontainer {
      display: flex;
      flex: 1;
      min-height: 0;
      overflow: hidden
    }

    .clist-wrap {
      width: 280px;
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      overflow: hidden;
      flex-shrink: 0
    }

    .clist-head {
      padding: 14px 14px 10px;
      border-bottom: 1px solid var(--border)
    }

    .clist-title {
      font-family: 'Syne', sans-serif;
      font-weight: 700;
      font-size: 15px;
      margin-bottom: 8px
    }

    .clist-search {
      position: relative
    }

    .clist-search input {
      padding-left: 28px;
      font-size: 12px;
      padding-top: 7px;
      padding-bottom: 7px
    }

    .clist-search .sicon {
      font-size: 12px
    }

    .clist {
      flex: 1;
      overflow-y: auto
    }

    .citem {
      padding: 11px 14px;
      cursor: pointer;
      border-bottom: 1px solid var(--border);
      transition: .12s
    }

    .citem:hover {
      background: var(--s2)
    }

    .citem.active {
      background: rgba(79, 70, 229, .05);
      border-left: 2px solid var(--accent)
    }

    .citem-name {
      font-size: 13px;
      font-weight: 600;
      margin-bottom: 2px;
      display: flex;
      align-items: center;
      gap: 6px
    }

    .citem-preview {
      font-size: 11px;
      color: var(--t2);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis
    }

    .citem-meta {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 3px
    }

    .citem-date {
      font-size: 10px;
      color: var(--t3)
    }

    .citem-pending {
      background: var(--accent);
      color: #fff;
      font-size: 9px;
      padding: 1px 5px;
      border-radius: 8px;
      font-weight: 800
    }

    /* CHAT MAIN */
    .cmain {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      min-width: 0
    }

    .cheader {
      padding: 14px 18px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 10px;
      background: var(--s1);
      flex-shrink: 0
    }

    .cheader-avatar {
      width: 38px;
      height: 38px;
      border-radius: 50%;
      background: var(--s3);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      font-weight: 800;
      color: var(--accent);
      flex-shrink: 0
    }

    .cheader-name {
      font-weight: 700;
      font-size: 15px
    }

    .cheader-meta {
      font-size: 11px;
      color: var(--t2)
    }

    /* INVOICE STRIP — vue synthétique des factures dans le compose */
    .inv-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 5px
    }

    .ichip {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 9px;
      border-radius: 20px;
      font-size: 11px;
      font-family: 'DM Mono', monospace;
      border: 1px solid var(--border);
      background: var(--s3);
      transition: .12s
    }

    .ichip.unpaid {
      border-color: rgba(79, 70, 229, .3);
      background: rgba(79, 70, 229, .06);
      color: var(--accent)
    }

    .ichip.paid {
      border-color: rgba(16, 185, 129, .3);
      background: rgba(16, 185, 129, .06);
      color: var(--green);
      opacity: .7
    }

    .ichip-mark {
      cursor: pointer;
      color: var(--t3);
      font-size: 13px;
      padding: 0 1px;
      border: none;
      background: none;
      line-height: 1;
      transition: .12s
    }

    .ichip-mark:hover {
      color: var(--green)
    }

    .ichip.paid .ichip-mark {
      color: var(--green);
      cursor: default
    }

    .msgs-area {
      flex: 1;
      overflow-y: auto;
      padding: 18px;
      display: flex;
      flex-direction: column;
      gap: 14px
    }

    .mgrp {
      display: flex;
      gap: 8px
    }

    .mgrp.out {
      flex-direction: row-reverse
    }

    .mavatar {
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background: var(--s3);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 11px;
      font-weight: 700;
      flex-shrink: 0;
      color: var(--accent);
      border: 1px solid var(--border)
    }

    .mavatar.in {
      color: var(--blue)
    }

    .mcontent {
      max-width: 62%
    }

    .mbubble {
      padding: 9px 13px;
      border-radius: 10px;
      font-size: 13px;
      line-height: 1.5
    }

    .mgrp.out .mbubble {
      background: rgba(79, 70, 229, .06);
      border: 1px solid rgba(79, 70, 229, .15);
      border-top-right-radius: 3px
    }

    .mgrp.in .mbubble {
      background: var(--s2);
      border: 1px solid var(--border);
      border-top-left-radius: 3px
    }

    .mmeta {
      font-size: 10px;
      color: var(--t3);
      margin-top: 3px;
      display: flex;
      align-items: center;
      gap: 6px
    }

    .mgrp.out .mmeta {
      justify-content: flex-end
    }

    .mtype-chip {
      font-size: 9px;
      padding: 1px 5px;
      border-radius: 4px;
      background: var(--s3);
      color: var(--t2)
    }

    .email-sent-badge {
      font-size: 9px;
      padding: 1px 6px;
      border-radius: 4px;
      background: rgba(16, 185, 129, .1);
      color: var(--green);
      font-weight: 600
    }

    .email-fail-badge {
      font-size: 9px;
      padding: 1px 6px;
      border-radius: 4px;
      background: rgba(239, 68, 68, .1);
      color: var(--red);
      font-weight: 600;
      cursor: help
    }

    .mattach {
      display: flex;
      flex-direction: column;
      gap: 3px;
      margin-top: 5px
    }

    .mattach-link {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 4px 9px;
      background: var(--s3);
      border-radius: 5px;
      font-size: 11px;
      color: var(--accent);
      text-decoration: none;
      border: 1px solid var(--border)
    }

    .minv-list {
      display: flex;
      flex-wrap: wrap;
      gap: 3px;
      margin-top: 5px
    }

    .minv-chip {
      padding: 2px 7px;
      background: rgba(79, 70, 229, .06);
      border-radius: 4px;
      font-size: 10px;
      font-family: 'DM Mono', monospace;
      color: var(--t2);
      border: 1px solid rgba(79, 70, 229, .15)
    }

    /* INVOICE TABLE inside bubble */
    .inv-table-wrap {
      margin-top: 8px;
      border: 1px solid rgba(79, 70, 229, .18);
      border-radius: 6px;
      overflow: hidden
    }

    .inv-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 11px;
      font-family: 'DM Mono', monospace
    }

    .inv-table th {
      background: rgba(79, 70, 229, .06);
      padding: 5px 8px;
      text-align: left;
      color: var(--t2);
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: .4px;
      border-bottom: 1px solid rgba(79, 70, 229, .12)
    }

    .inv-table td {
      padding: 5px 8px;
      border-bottom: 1px solid var(--border);
      color: var(--text)
    }

    .inv-table tr:last-child td {
      border-bottom: none
    }

    .inv-table .amt {
      text-align: right;
      font-weight: 500;
      color: var(--accent)
    }

    .inv-table .total-row td {
      background: rgba(79, 70, 229, .04);
      font-weight: 700;
      color: var(--accent);
      border-top: 1px solid rgba(79, 70, 229, .18)
    }

    .inv-table .total-row .amt {
      font-size: 12px
    }

    /* CHAT LIST grouped */
    .cgroup {
      border-bottom: 1px solid var(--border)
    }

    .cgroup-header {
      padding: 6px 14px 4px;
      font-size: 9px;
      color: var(--t3);
      text-transform: uppercase;
      letter-spacing: .7px;
      font-weight: 700;
      background: var(--s2)
    }

    .citem-amount {
      font-family: 'DM Mono', monospace;
      font-size: 10px;
      color: var(--accent);
      font-weight: 700
    }

    /* COMPOSE — barre compacte, expansible */
    .compose {
      border-top: 1px solid var(--border);
      background: var(--s1);
      flex-shrink: 0
    }

    .compose-toggle {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 18px;
      cursor: pointer;
      user-select: none;
      transition: background .12s
    }

    .compose-toggle:hover {
      background: var(--s2)
    }

    .compose-toggle-label {
      font-size: 12px;
      font-weight: 600;
      color: var(--t2);
      flex: 1
    }

    .compose-toggle-label.has-unpaid {
      color: var(--accent)
    }

    .compose-toggle-icon {
      font-size: 10px;
      color: var(--t3);
      transition: transform .22s
    }

    .compose-toggle-icon.open {
      transform: rotate(180deg)
    }

    .compose-body {
      display: grid;
      grid-template-rows: 0fr;
      transition: grid-template-rows .25s ease;
      overflow: hidden
    }

    .compose-body.open {
      grid-template-rows: 1fr
    }

    .compose-body-inner {
      min-height: 0;
      padding: 0 18px;
      transition: padding .25s ease
    }

    .compose-body.open .compose-body-inner {
      padding: 12px 18px
    }

    /* Résumé factures impayées — compact, pliable */
    .compose-auto-strip {
      background: rgba(79, 70, 229, .04);
      border: 1px solid rgba(79, 70, 229, .15);
      border-radius: 8px;
      margin-bottom: 10px;
      flex-shrink: 0;
      overflow: hidden
    }

    .cas-header {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      user-select: none;
      padding: 8px 12px
    }

    .cas-header:hover {
      background: rgba(79, 70, 229, .06)
    }

    .cas-header-label {
      font-size: 11px;
      font-weight: 700;
      color: var(--accent);
      flex: 1
    }

    .cas-header-total {
      font-family: 'DM Mono', monospace;
      font-size: 12px;
      font-weight: 700;
      color: var(--accent)
    }

    .cas-header-toggle {
      font-size: 10px;
      color: var(--t3);
      transition: transform .22s
    }

    .cas-header-toggle.open {
      transform: rotate(180deg)
    }

    .cas-body {
      display: grid;
      grid-template-rows: 0fr;
      transition: grid-template-rows .22s ease
    }

    .cas-body.open {
      grid-template-rows: 1fr
    }

    .cas-body-inner {
      overflow-y: auto;
      min-height: 0;
      max-height: 160px
    }

    .cas-invoices {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      padding: 6px 12px 2px
    }

    .cas-chip {
      padding: 2px 8px;
      background: rgba(79, 70, 229, .08);
      border-radius: 5px;
      font-size: 11px;
      font-family: 'DM Mono', monospace;
      color: var(--accent);
      border: 1px solid rgba(79, 70, 229, .2);
      display: flex;
      align-items: center;
      gap: 4px
    }

    .cas-chip .cas-x {
      cursor: pointer;
      color: var(--t3);
      font-size: 13px;
      line-height: 1;
      margin-left: 2px
    }

    .cas-chip .cas-x:hover {
      color: var(--red)
    }

    .cas-total {
      font-size: 11px;
      color: var(--t2);
      padding: 2px 12px 8px
    }

    .cas-empty {
      font-size: 12px;
      color: var(--green);
      padding: 4px 12px 8px
    }

    /* Ligne de type + actions */
    .ctype-row {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 10px;
      flex-wrap: wrap
    }

    .ctype {
      padding: 5px 14px;
      border-radius: 20px;
      border: 1px solid var(--border);
      background: var(--s2);
      color: var(--t2);
      font-size: 12px;
      cursor: pointer;
      transition: all .15s ease;
      font-family: 'DM Sans', sans-serif;
      user-select: none;
      display: inline-flex;
      align-items: center;
      gap: 5px
    }

    .ctype:hover {
      background: var(--s3);
      border-color: var(--t3)
    }

    .ctype.active {
      border-color: var(--accent);
      color: var(--accent);
      background: rgba(79, 70, 229, .08);
      font-weight: 600;
      box-shadow: 0 0 0 1px rgba(79, 70, 229, .15)
    }

    .ctype.inbound-type {
      border-color: var(--blue);
      color: var(--blue);
      background: rgba(59, 130, 246, .06)
    }

    .ctype.inbound-type.active {
      border-color: var(--blue);
      color: var(--blue);
      background: rgba(59, 130, 246, .1);
      box-shadow: 0 0 0 1px rgba(59, 130, 246, .2)
    }

    .ctype-hint {
      font-size: 10px;
      color: var(--t3);
      margin-bottom: 8px;
      padding-left: 2px;
      transition: color .15s
    }

    .csubject {
      width: 100%;
      background: var(--s2);
      border: 1px solid var(--border);
      border-radius: 7px;
      padding: 7px 12px;
      color: var(--text);
      font-size: 13px;
      font-family: 'DM Sans', sans-serif;
      outline: none;
      transition: border-color .15s;
      margin-bottom: 6px
    }

    .csubject:focus {
      border-color: var(--accent)
    }

    .csubject.hidden-field {
      display: none
    }

    .crow {
      display: flex;
      flex-direction: column;
      gap: 0
    }

    .crow textarea {
      border-radius: 8px 8px 0 0;
      border-bottom: none;
      resize: vertical;
      min-height: 60px
    }

    .crow textarea:focus {
      border-color: var(--accent);
      z-index: 1;
      border-bottom: none
    }

    .crow-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 6px 10px;
      background: var(--s2);
      border: 1px solid var(--border);
      border-radius: 0 0 8px 8px;
      gap: 8px
    }

    .crow-toolbar-left {
      display: flex;
      align-items: center;
      gap: 6px
    }

    .crow-toolbar-right {
      display: flex;
      align-items: center;
      gap: 6px
    }

    .cattach {
      background: none;
      border: none;
      color: var(--t3);
      cursor: pointer;
      padding: 4px 8px;
      font-size: 16px;
      border-radius: 6px;
      display: flex;
      align-items: center;
      transition: .12s;
      line-height: 1
    }

    .cattach:hover {
      background: var(--s3);
      color: var(--text)
    }

    .csend {
      background: var(--accent);
      color: #fff;
      border: none;
      border-radius: 6px;
      padding: 6px 14px;
      cursor: pointer;
      font-weight: 600;
      font-size: 12px;
      font-family: 'DM Sans', sans-serif;
      display: flex;
      align-items: center;
      gap: 5px;
      transition: .15s;
      white-space: nowrap
    }

    .csend:hover {
      background: #6366f1;
      transform: translateY(-1px)
    }

    .csend:active {
      transform: translateY(0)
    }

    .cfiles-list {
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      margin-top: 6px
    }

    .cfile-chip {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 10px;
      background: rgba(79, 70, 229, .06);
      border: 1px solid rgba(79, 70, 229, .15);
      border-radius: 14px;
      font-size: 11px;
      font-family: 'DM Sans', sans-serif;
      color: var(--accent)
    }

    .cfile-chip .cfile-x {
      cursor: pointer;
      color: var(--t3);
      font-size: 14px;
      line-height: 1;
      margin-left: 2px;
      font-weight: 700
    }

    .cfile-chip .cfile-x:hover {
      color: var(--red)
    }

    /* FILE AREA */
    .fupload {
      border: 2px dashed var(--border);
      border-radius: 7px;
      padding: 16px;
      text-align: center;
      cursor: pointer;
      color: var(--t3);
      font-size: 12px;
      transition: .15s
    }

    .fupload:hover {
      border-color: var(--accent);
      color: var(--t2)
    }

    .fupload.has {
      border-color: var(--green);
      color: var(--green)
    }

    /* CONTACTS GRID */
    .cgrid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
      gap: 14px
    }

    .ccard {
      background: var(--s1);
      border: 1px solid var(--border);
      border-radius: var(--r);
      padding: 18px;
      cursor: pointer;
      transition: .18s;
      position: relative
    }

    .ccard:hover {
      border-color: var(--accent);
      transform: translateY(-2px);
      box-shadow: 0 6px 24px rgba(0, 0, 0, .08)
    }

    .ccard-name {
      font-family: 'Syne', sans-serif;
      font-weight: 700;
      font-size: 15px;
      margin-bottom: 3px
    }

    .ccard-type {
      font-size: 11px;
      color: var(--t3);
      margin-bottom: 10px
    }

    .ccard-info {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      color: var(--t2);
      margin-bottom: 3px
    }

    .ccard-stats {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 7px;
      margin-top: 10px;
      padding-top: 10px;
      border-top: 1px solid var(--border)
    }

    .ccs {
      text-align: center
    }

    .ccv {
      font-family: 'DM Mono', monospace;
      font-size: 15px;
      font-weight: 500
    }

    .ccl {
      font-size: 9px;
      color: var(--t3);
      text-transform: uppercase;
      margin-top: 1px;
      letter-spacing: .5px
    }

    /* EMPTY */
    .empty {
      text-align: center;
      padding: 50px 20px;
      color: var(--t3)
    }

    .eicon {
      font-size: 40px;
      margin-bottom: 12px
    }

    .etitle {
      font-size: 16px;
      color: var(--t2);
      margin-bottom: 6px
    }

    .edesc {
      font-size: 13px
    }

    /* SCROLL */
    ::-webkit-scrollbar {
      width: 5px;
      height: 5px
    }

    ::-webkit-scrollbar-track {
      background: transparent
    }

    ::-webkit-scrollbar-thumb {
      background: var(--s4);
      border-radius: 3px
    }

    /* TOAST */
    .tcontainer {
      position: fixed;
      bottom: 70px;
      right: 20px;
      z-index: 999;
      display: flex;
      flex-direction: column;
      gap: 6px
    }

    .toast {
      padding: 10px 14px;
      background: var(--s3);
      border: 1px solid var(--border);
      border-radius: 7px;
      font-size: 13px;
      animation: tin .25s ease;
      display: flex;
      align-items: center;
      gap: 7px
    }

    .toast.ok {
      border-color: rgba(16, 185, 129, .3)
    }

    .toast.err {
      border-color: rgba(239, 68, 68, .3)
    }

    @keyframes tin {
      from {
        opacity: 0;
        transform: translateX(16px)
      }

      to {
        opacity: 1;
        transform: translateX(0)
      }
    }

    @keyframes spin {
      from {
        transform: rotate(0deg)
      }

      to {
        transform: rotate(360deg)
      }
    }

    /* CALL BUTTON */
    .call-btn {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 9px;
      border-radius: 14px;
      background: rgba(16, 185, 129, .08);
      border: 1px solid rgba(16, 185, 129, .25);
      color: var(--green);
      font-size: 11px;
      font-weight: 600;
      cursor: pointer;
      transition: .15s;
      text-decoration: none;
      font-family: 'DM Sans', sans-serif
    }

    .call-btn:hover {
      background: rgba(16, 185, 129, .15);
      transform: scale(1.03)
    }

    .call-btn.calling {
      background: rgba(16, 185, 129, .2);
      animation: pulse .8s infinite
    }

    @keyframes pulse {

      0%,
      100% {
        opacity: 1
      }

      50% {
        opacity: .5
      }
    }

    .call-btn.disabled {
      opacity: .35;
      cursor: not-allowed;
      pointer-events: none
    }

    .hidden {
      display: none !important
    }

    .page {
      display: none
    }

    .page.active {
      display: flex;
      flex-direction: column;
      flex: 1;
      min-height: 0
    }

    .divider {
      border: none;
      border-top: 1px solid var(--border);
      margin: 14px 0
    }

    /* GROUPE FILTERS */
    .gfilters {
      display: flex;
      gap: 7px;
      flex-wrap: wrap;
      align-items: center
    }

    .gfbtn {
      padding: 5px 11px;
      border-radius: 20px;
      border: 1px solid var(--border);
      background: var(--s2);
      color: var(--t2);
      cursor: pointer;
      font-size: 11px;
      font-family: 'DM Sans', sans-serif;
      transition: .12s;
      white-space: nowrap;
      font-weight: 500
    }

    .gfbtn:hover {
      border-color: var(--accent);
      color: var(--accent);
      background: rgba(79, 70, 229, .05)
    }

    .gfbtn.active {
      border-color: var(--accent);
      color: var(--accent);
      background: rgba(79, 70, 229, .1);
      font-weight: 700
    }

    /* PDF PREVIEW PANEL */
    .pdf-panel {
      width: 0;
      background: var(--s1);
      border-left: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      transition: width .2s;
      overflow: hidden;
      flex-shrink: 0
    }

    .pdf-panel.open {
      width: 420px
    }

    .pdf-panel-head {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0
    }

    .pdf-panel-title {
      font-family: 'Syne', sans-serif;
      font-weight: 700;
      font-size: 13px;
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap
    }

    .pdf-panel-body {
      flex: 1;
      overflow: hidden;
      display: flex;
      flex-direction: column
    }

    .pdf-panel-body iframe {
      flex: 1;
      border: none;
      width: 100%;
      height: 100%
    }

    /* BADGE INCOMPLET */
    .binc {
      background: rgba(245, 158, 11, .1);
      color: #d97706;
      border: 1px solid rgba(245, 158, 11, .3);
      display: inline-flex;
      align-items: center;
      padding: 2px 7px;
      border-radius: 5px;
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: .4px
    }

    /* INLINE EDIT */
    .editable-cell {
      cursor: pointer;
      border-radius: 4px;
      padding: 2px 5px;
      transition: .12s
    }

    .editable-cell:hover {
      background: rgba(79, 70, 229, .07);
      outline: 1px dashed var(--accent)
    }

    .editable-cell.editing {
      background: var(--s1);
      outline: 2px solid var(--accent);
      border-radius: 4px
    }

    .editable-cell input {
      background: transparent;
      border: none;
      outline: none;
      font-size: 12px;
      font-family: 'DM Sans', sans-serif;
      color: var(--text);
      width: 100%;
      min-width: 80px;
      padding: 0
    }

    /* DASHBOARD GROUPES */
    .db-groups {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      gap: 10px;
      margin-bottom: 20px
    }

    .db-gcard {
      background: var(--s1);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 14px;
      cursor: pointer;
      transition: .15s;
      position: relative;
      overflow: hidden
    }

    .db-gcard:hover {
      border-color: var(--accent);
      transform: translateY(-1px);
      box-shadow: 0 4px 16px rgba(0, 0, 0, .07)
    }

    .db-gcard:hover .db-gcard-cta {
      opacity: 1
    }

    .db-gcard.active {
      border-color: var(--accent);
      background: rgba(79, 70, 229, .04)
    }

    .db-gcard-name {
      font-weight: 700;
      font-size: 13px;
      margin-bottom: 6px
    }

    .db-gcard-amt {
      font-family: 'DM Mono', monospace;
      font-size: 17px;
      color: var(--accent);
      font-weight: 500
    }

    .db-gcard-sub {
      font-size: 10px;
      color: var(--t3);
      margin-top: 3px
    }

    .db-gcard-cta {
      display: block;
      margin-top: 10px;
      font-size: 10px;
      color: var(--accent);
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: .5px;
      opacity: 0;
      transition: opacity .15s
    }

    /* BANDEAU FILTRE GROUPE ACTIF (page Factures) */
    .inv-group-banner {
      background: rgba(79, 70, 229, .06);
      border-bottom: 1px solid rgba(79, 70, 229, .18);
      padding: 8px 20px;
      display: flex;
      align-items: center;
      gap: 10px;
      flex-shrink: 0;
      font-size: 13px
    }

    .inv-group-banner-label {
      color: var(--accent);
      font-weight: 700
    }

    .inv-group-banner-info {
      color: var(--t2);
      font-size: 12px
    }

    .inv-group-banner-close {
      margin-left: auto;
      background: none;
      border: 1px solid rgba(79, 70, 229, .3);
      border-radius: 5px;
      color: var(--accent);
      cursor: pointer;
      font-size: 11px;
      padding: 3px 9px;
      font-family: 'DM Sans', sans-serif;
      transition: .12s
    }

    .inv-group-banner-close:hover {
      background: rgba(79, 70, 229, .1)
    }

    /* CONTACT CHIP clickable in import */
    .imp-contact-chip {
      background: var(--s2);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 8px 12px;
      font-size: 12px;
      min-width: 160px;
      cursor: pointer;
      transition: .15s
    }

    .imp-contact-chip:hover {
      border-color: var(--accent);
      background: rgba(79, 70, 229, .05)
    }

    .imp-contact-chip.active {
      border-color: var(--accent);
      background: rgba(79, 70, 229, .08)
    }

    /* TABLE overflow scroll */
    .table-scroll {
      overflow-x: auto
    }