/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 100;
}
header {
  background: #2c3e50;
  color: white;
  padding: 14px 24px;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
header h1 { font-size: 20px; font-weight: bold; }
.header-sub { font-size: 13px; color: #aab; }
.header-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #ccd; }
.btn-logout { color: #aab; text-decoration: none; font-size: 12px; border: 1px solid #4a6278; padding: 4px 10px; border-radius: 4px; white-space: nowrap; }
.btn-logout:hover { color: white; border-color: #7a9ab8; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f0f2f5; }
.login-card { background: white; border-radius: 10px; padding: 40px; width: 100%; max-width: 380px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.login-logo { font-size: 36px; text-align: center; margin-bottom: 8px; }
.login-title { font-size: 20px; color: #2c3e50; text-align: center; margin-bottom: 4px; }
.login-sub { font-size: 13px; color: #888; text-align: center; margin-bottom: 28px; }
.login-form label { display: block; font-size: 13px; color: #555; margin-bottom: 4px; font-weight: 500; }
.login-form input { width: 100%; padding: 9px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; margin-bottom: 16px; box-sizing: border-box; }
.login-form input:focus { outline: none; border-color: #2c3e50; box-shadow: 0 0 0 2px rgba(44,62,80,.1); }
.btn-login { width: 100%; padding: 11px; background: #2c3e50; color: white; border: none; border-radius: 6px; font-size: 15px; cursor: pointer; font-weight: 500; }
.btn-login:hover { background: #3d5166; }

/* ── Tabs navigation ─────────────────────────────────────────────────────── */
.tabs {
  background: white;
  border-bottom: 2px solid #e0e0e0;
  display: flex;
  gap: 0;
  padding: 0 16px;
  overflow-x: auto;
  box-shadow: 0 2px 4px rgba(0,0,0,.06);
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 13px 18px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  margin-bottom: -2px;
}
.tab-btn:hover { color: #2c3e50; }
.tab-btn.active { color: #2c3e50; border-bottom-color: #2c3e50; font-weight: bold; }

/* ── Main content ────────────────────────────────────────────────────────── */
main { flex: 1; padding: 24px; max-width: 1000px; width: 100%; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.card h2 { font-size: 17px; color: #2c3e50; margin-bottom: 16px; }

/* ── Metrics row ─────────────────────────────────────────────────────────── */
.metrics { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.metric {
  flex: 1; min-width: 130px; background: white;
  border-radius: 8px; padding: 16px; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.metric-value { font-size: 28px; font-weight: bold; color: #2c3e50; }
.metric-label { font-size: 12px; color: #999; margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #2c3e50; color: white;
  padding: 9px 10px; text-align: left; font-size: 13px;
}
tbody td {
  padding: 9px 10px; border-bottom: 1px solid #eee;
  font-size: 13px; vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 5px;
  border: none; cursor: pointer; font-size: 13px;
  text-decoration: none; transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary  { background: #2c3e50; color: white; }
.btn-success  { background: #27ae60; color: white; }
.btn-warning  { background: #e67e22; color: white; }
.btn-danger   { background: #e74c3c; color: white; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 12px; font-weight: bold; }
.badge-ok      { background: #d4edda; color: #27ae60; }
.badge-partial { background: #fde8e8; color: #e74c3c; }
.badge-pending { background: #fef3e2; color: #e67e22; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: #555; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #ddd;
  border-radius: 5px; font-size: 13px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: #2c3e50;
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* ── Alerts / flash ──────────────────────────────────────────────────────── */
/* ── Toasts ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 16px; right: 16px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  max-width: 360px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  pointer-events: all; cursor: default;
  animation: toast-in .2s ease;
  transition: opacity .3s ease, transform .3s ease;
}
.toast.hide { opacity: 0; transform: translateX(20px); }
.toast-success { background: #d4edda; color: #155724; border-left: 4px solid #28a745; }
.toast-error   { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }
.toast-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid #17a2b8; }
.toast-msg     { flex: 1; line-height: 1.4; }
.toast-close   {
  background: none; border: none; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0; color: inherit; opacity: .6;
}
.toast-close:hover { opacity: 1; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Modale confirmation ─────────────────────────────────────────────────── */
#confirm-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 10000;
  align-items: center; justify-content: center;
  animation: fade-in .15s ease;
}
#confirm-overlay.open { display: flex; }
#confirm-box {
  background: #fff; border-radius: 12px;
  padding: 28px 28px 22px; max-width: 380px; width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  animation: modal-in .18s ease;
  text-align: center;
}
#confirm-icon { font-size: 36px; margin-bottom: 12px; }
#confirm-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: #1a1a1a; }
#confirm-msg   { font-size: 13px; color: #666; margin-bottom: 22px; line-height: 1.5; }
#confirm-btns  { display: flex; gap: 10px; justify-content: center; }
#confirm-btns button {
  flex: 1; padding: 9px 0; border-radius: 7px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
#confirm-btns button:hover { opacity: .85; }
#btn-cancel  { background: #f0f2f5; color: #555; }
#btn-confirm { background: #dc3545; color: #fff; }
@keyframes fade-in  { from { opacity:0 } to { opacity:1 } }
@keyframes modal-in { from { opacity:0; transform:scale(.93) } to { opacity:1; transform:scale(1) } }

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.drop-zone {
  display: block;
  border: 2px dashed #ccc; border-radius: 8px;
  min-height: 150px; padding: 32px 20px;
  text-align: center; color: #999;
  cursor: pointer; transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: #2c3e50; background: #f7f9fc; color: #555; }
.drop-zone input[type=file] { display: none; }

/* ── Accordion ───────────────────────────────────────────────────────────── */
.accordion { padding: 0; overflow: hidden; }
.accordion-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; cursor: pointer;
  user-select: none;
}
.accordion-header:hover { background: #f7f9fc; }
.accordion-arrow { color: #aaa; font-size: 11px; transition: transform .2s; }
.accordion-arrow.open { transform: rotate(90deg); }
.accordion-body { padding: 0 20px 20px; border-top: 1px solid #f0f0f0; }

/* ── Month navigation ────────────────────────────────────────────────────── */
.month-nav {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 16px; font-size: 16px; font-weight: bold; color: #2c3e50;
}

/* ── Action bar ──────────────────────────────────────────────────────────── */
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Placeholder ─────────────────────────────────────────────────────────── */
.placeholder { color: #bbb; font-style: italic; font-size: 14px; padding: 20px 0; }

/* ── Email log count badge (sur le tab) ──────────────────────────────────── */
.email-log-count {
  display: inline-block; margin-left: 5px;
  background: #e8f4fd; color: #2980b9;
  font-size: 10px; font-weight: bold;
  padding: 1px 5px; border-radius: 8px; vertical-align: middle;
}

/* ── Documents ───────────────────────────────────────────────────────────── */
.doc-count {
  display: inline-block; margin-left: 8px;
  background: #e8f4fd; color: #2980b9;
  font-size: 11px; font-weight: bold;
  padding: 1px 7px; border-radius: 10px;
}
.doc-type-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: bold;
  background: #f0f0f0; color: #555;
  white-space: nowrap;
}
.doc-upload-form {
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 14px;
  margin-bottom: 16px;
}

/* ── Template preview box ────────────────────────────────────────────────── */
.tpl-preview {
  background: #f7f9fc; border: 1px solid #e8e8e8;
  border-radius: 6px; padding: 14px 16px; margin-top: 8px;
}
.tpl-preview-label {
  font-size: 11px; color: #aaa; text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 8px;
}
.tpl-preview-subject {
  font-weight: bold; font-size: 13px; color: #2c3e50; margin-bottom: 10px;
}
.tpl-preview-body {
  white-space: pre-wrap; font-family: Arial, sans-serif;
  font-size: 13px; margin: 0; color: #333;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  text-align: center; color: #bbb;
  font-size: 11px; padding: 16px;
  border-top: 1px solid #e0e0e0; background: white;
}
