  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg: #f7f5f0;
    --surface: #ffffff;
    --surface2: #f0ede6;
    --border: #e2ddd5;
    --text: #1a1714;
    --text-muted: #7a746a;
    --accent: #2d6a4f;
    --accent-light: #d8f3dc;
    --danger: #c0392b;
    --danger-light: #fdecea;
    --warning: #d68910;
    --warning-light: #fef9e7;
    --info: #1a6fa8;
    --info-light: #e8f4fd;
    --gold: #b7950b;
    --gold-light: #fef9e3;
    --radius: 10px;
  }

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
  }

  /* ── HEADER ── */
  header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .logo {
    font-family: 'Libre Baskerville', serif;
    font-size: 18px;
    letter-spacing: -0.02em;
    color: var(--text);
  }
  .logo span { color: var(--accent); }
  .header-actions { display: flex; gap: 10px; align-items: center; }

  /* ── LINK ── */
  a {
    color: inherit;
    text-decoration: underline;
  }
  a:hover {
    color: var(--text-muted);
  }

  /* ── STATS BAR ── */
  .stats-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 32px;
    display: flex;
    justify-content: center;
    gap: 32px;
    overflow-x: auto;
  }
  .stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    white-space: nowrap;
  }
  .stat-value {
    font-size: 22px;
    font-weight: 600;
    line-height: 1;
  }
  .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  /* ── MAIN ── */
  main { max-width: 1200px; margin: 0 auto; padding: 28px 32px; }

  /* ── TOOLBAR ── */
  .toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
  }

  .filter-row {
    display: flex;
    gap: 10px;
    align-items: center;
  }

  .search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
  }
  .search-wrap svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
  }
  .search-input {
    width: 100%;
    padding: 9px 12px 9px 36px !important;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .2s;
  }
  .search-input:focus { border-color: var(--accent); }

  .filter-select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    cursor: pointer;
  }

  .date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
  }

  /* ── BUTTONS ── */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all .15s;
    white-space: nowrap;
  }
  .btn-primary {
    background: var(--accent);
    color: white;
  }
  .btn-primary:hover { background: #245a42; }
  .btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
  }
  .btn-ghost:hover { background: var(--surface2); color: var(--text); }
  .btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid transparent;
    padding: 6px 10px;
  }
  .btn-danger:hover { background: var(--danger-light); }
  .btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all .15s;
  }
  .btn-icon:hover { background: var(--surface2); color: var(--text); }

  .btn-delete {
    background: var(--danger);
    color: white;
    border: 1px solid var(--danger);
    padding: 6px 10px;
    display: none;
  }
  .btn-delete.open { display: inline-flex; }
  
  .btn-delete:hover { background: #c0392b; }

  /* ── EMPTY STATE ── */
  .empty-state {
    text-align: center;
    padding: 80px 32px;
    color: var(--text-muted);
  }

  /* ── Table ── */
  table {
    width: 100%;
    border-collapse: collapse;
  }
  th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border);
  }
  th {
    background: var(--surface);
    font-weight: 600;
    color: var(--text);
  }
  tbody tr:hover { 
    background: var(--surface2); 
  }

  /* ── STATUS BADGE ── */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
  }

  /* status colors */
  .s-postule   { background: var(--info-light);    color: var(--info); }
  .s-relance   { background: var(--warning-light); color: var(--warning); }
  .s-entretien { background: var(--accent-light);  color: var(--accent); }
  .s-test      { background: #f0e6ff;            color: #7c3aed; }
  .s-offre     { background: var(--gold-light);    color: var(--gold); }
  .s-refus     { background: var(--danger-light);  color: var(--danger);  }
  .s-archive   { background: var(--surface2);      color: var(--text-muted); }

  /* ── MODAL ── */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20,16,12,0.4);
    backdrop-filter: blur(3px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .modal-overlay.open {
    opacity: 1;
    pointer-events: all;
  }
  .modal {
    background: var(--surface);
    border-radius: 16px;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    transform: translateY(12px) scale(0.98);
    transition: transform .2s;
  }
  .modal-overlay.open .modal { transform: translateY(0) scale(1); }
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
  }
  .modal-title {
    font-family: 'Libre Baskerville', serif;
    font-size: 18px;
  }
  .modal-body { padding: 20px 24px 24px; }

  /* ── FORM ── */
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .form-group { display: flex; flex-direction: column; gap: 5px; }
  .form-group.full { grid-column: 1 / -1; }
  label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  input[type=text], input[type=url], input[type=date], input[type=number],
  select, textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    width: 100%;
  }
  input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
  }
  textarea { resize: vertical; min-height: 80px; }


  
  /* Mail entries */

  #mailsList {
    position: relative;
  }

  #mailsList::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
  }

  .mail-entry {
    display: flex;
    justify-content: space-between;
  }

  /* Differentiate received vs sent mails (color + alignment on either side of the timeline) Left for received mails */
  .mail-entry.received {
    color: var(--info);
    position: relative;
    text-align: right;
    width: 45%;
    margin-right: 55%;
    flex-direction: row-reverse;
  }

  .mail-entry.sent {
    color: var(--accent);
    position: relative;
    width: 45%;
    margin-left: 55%;
  }

  /* ── FOOTER / MODAL ACTIONS ── */
  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: var(--surface);
  }


  /* ── CONFIRM ── */
  .confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20,16,12,0.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
  }
  .confirm-overlay.open { opacity: 1; pointer-events: all; }
  .confirm-box {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  }
  .confirm-box h3 { font-family: 'Libre Baskerville', serif; margin-bottom: 8px; }
  .confirm-box p { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
  .confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

  .section-title {
    font-family: 'Libre Baskerville', serif;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    font-style: italic;
  }

  @media (max-width: 640px) {
    header, .stats-bar, main { padding-left: 16px; padding-right: 16px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-group.full { grid-column: auto; }
  }