/* === AHTES Rentabilité Dashboard - styles globaux === */

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, 'Segoe UI', 'Aptos', sans-serif;
  background: #f5f7fa;
  color: #1a2733;
  padding: 24px;
  font-size: 14px;
}

/* === LOGIN === */
.login-container {
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(9, 65, 85, 0.1);
  width: 100%;
  max-width: 420px;
}
.login-header {
  text-align: center;
  margin-bottom: 32px;
}
.login-header .logo-mark {
  width: 56px;
  height: 56px;
  background: #094155;
  color: white;
  font-size: 24px;
  font-weight: 700;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.login-header h1 { color: #094155; font-size: 22px; margin-bottom: 6px; }
.login-header p { color: #6b7785; font-size: 13px; }
.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #094155;
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 12px;
  border: 1px solid #d4dde6;
  border-radius: 6px;
  font-size: 15px;
  margin-bottom: 16px;
}
.login-form input:focus {
  outline: none;
  border-color: #1482AB;
}
.login-form button {
  width: 100%;
  padding: 12px;
  background: #094155;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.login-form button:hover { background: #1482AB; }
.login-error {
  background: #ffd4d4;
  color: #b73a3a;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* === HEADER DASHBOARD === */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #094155;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 36px; height: 36px;
  background: #094155;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px;
}
.logo-text { font-size: 18px; font-weight: 600; color: #094155; }
.logo-sub { font-size: 12px; color: #6b7785; }
.header-right { display: flex; gap: 16px; align-items: center; font-size: 13px; color: #6b7785; }
.refresh-btn {
  background: #1482AB; color: white; border: none;
  padding: 8px 16px; border-radius: 6px;
  cursor: pointer; font-weight: 500;
}
.refresh-btn:hover { background: #094155; }
.refresh-btn:disabled { background: #d4dde6; cursor: not-allowed; }
.logout-link {
  color: #6b7785; text-decoration: none;
  font-size: 12px; padding: 4px 8px;
}
.logout-link:hover { color: #094155; }

/* === FILTERS === */
.filters {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap;
  background: white; padding: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.filter-label { font-weight: 500; color: #094155; }
.filter-btn {
  padding: 6px 14px; background: white;
  border: 1px solid #d4dde6; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: #1a2733;
}
.filter-btn.active { background: #094155; color: white; border-color: #094155; }
.filter-btn:hover:not(.active) { border-color: #1482AB; }
.filter-btn-apply {
  padding: 6px 14px; background: #1482AB; color: white;
  border: none; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.filter-btn-apply:hover { background: #094155; }
.filter-dates { display: flex; gap: 8px; align-items: center; color: #6b7785; font-size: 13px; }
.filter-dates input {
  padding: 5px 10px; border: 1px solid #d4dde6;
  border-radius: 5px; font-size: 13px;
}
.filter-comparison { display: flex; gap: 8px; align-items: center; color: #6b7785; font-size: 13px; }
.filter-comparison select {
  padding: 5px 10px; border: 1px solid #d4dde6;
  border-radius: 5px; font-size: 13px;
}
.filter-manager { display: flex; gap: 8px; align-items: center; color: #6b7785; font-size: 13px; }
.filter-manager select {
  padding: 5px 10px; border: 1px solid #d4dde6;
  border-radius: 5px; font-size: 13px;
  min-width: 180px;
}
.filter-manager select[multiple] {
  min-width: 220px;
  padding: 4px;
  font-size: 12px;
}
.filter-manager select[multiple] option {
  padding: 3px 6px;
}
.filter-manager select[multiple] option:checked {
  background: #1482AB linear-gradient(0deg, #1482AB 0%, #1482AB 100%);
  color: white;
}
.filter-btn-export {
  padding: 7px 14px; border: none;
  background: #1d8348; color: white;
  border-radius: 5px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
  display: inline-flex; align-items: center; gap: 5px;
}
.filter-btn-export:hover { background: #145a32; }
.filter-btn-export:disabled { opacity: 0.5; cursor: not-allowed; }

/* === HERO === */
.hero {
  background: linear-gradient(135deg, #094155 0%, #1482AB 100%);
  color: white;
  padding: 32px; border-radius: 12px;
  margin-bottom: 24px;
  min-height: 200px;
}
.hero-loading { padding: 40px; text-align: center; opacity: 0.85; }
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 32px;
}
.hero-main h2 {
  font-size: 13px; font-weight: 500; opacity: 0.85;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.hero-value { font-size: 56px; font-weight: 700; line-height: 1; }
.hero-trend {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 4px 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px; font-size: 13px; font-weight: 500;
}
.hero-trend.up { background: rgba(29, 131, 72, 0.4); }
.hero-trend.down { background: rgba(183, 58, 58, 0.4); }
.hero-sub { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.hero-sub-item { border-left: 2px solid rgba(255,255,255,0.3); padding-left: 14px; }
.hero-sub-label { font-size: 11px; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.5px; }
.hero-sub-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.hero-sub-detail { font-size: 12px; opacity: 0.8; margin-top: 2px; }

/* === SECTION TITLE === */
.section-title {
  font-size: 16px; font-weight: 600; color: #094155;
  margin: 32px 0 16px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::before {
  content: ''; width: 4px; height: 18px;
  background: #43B6D3; border-radius: 2px;
}

/* === AXES === */
.axes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin-bottom: 16px;
}
.axe-loading {
  grid-column: 1 / -1;
  background: white; padding: 30px;
  border-radius: 10px; text-align: center; color: #6b7785;
}
.axe {
  background: white; padding: 20px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-top: 3px solid #43B6D3;
}
.axe-title {
  font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.5px; color: #6b7785;
  font-weight: 600; margin-bottom: 12px;
}
.kpi-row {
  display: flex; justify-content: space-between;
  align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid #eef2f6;
}
.kpi-row:last-child { border-bottom: none; }
.kpi-label { font-size: 13px; color: #1a2733; }
.kpi-value { font-weight: 600; color: #094155; font-size: 14px; }
.kpi-value .unit { font-weight: 400; color: #6b7785; font-size: 12px; margin-left: 3px; }
.kpi-value .pct { color: #1482AB; font-size: 12px; margin-left: 6px; }

/* === TABLE === */
.table-wrap {
  background: white; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  overflow: hidden; margin-bottom: 24px;
}
.table-header-bar {
  padding: 16px 20px;
  border-bottom: 1px solid #eef2f6;
  display: flex; justify-content: space-between;
  align-items: center; gap: 16px; flex-wrap: wrap;
}
.table-header-bar h3 { font-size: 15px; color: #094155; }
.table-controls { display: flex; gap: 10px; align-items: center; }
.table-search {
  padding: 6px 12px; border: 1px solid #d4dde6;
  border-radius: 6px; font-size: 13px; width: 240px;
}
.table-filter-select {
  padding: 6px 12px; border: 1px solid #d4dde6;
  border-radius: 6px; font-size: 13px;
}
table { width: 100%; border-collapse: collapse; }
thead { background: #f5f7fa; }
th {
  padding: 12px 10px; text-align: left;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; color: #6b7785;
  font-weight: 600; border-bottom: 1px solid #eef2f6;
  cursor: pointer; user-select: none;
}
th:hover { color: #094155; }
th.num { text-align: right; }
th.sortable::after { content: ' ↕'; opacity: 0.4; }
th.sort-asc::after { content: ' ↑'; opacity: 1; color: #1482AB; }
th.sort-desc::after { content: ' ↓'; opacity: 1; color: #1482AB; }
td {
  padding: 11px 10px; font-size: 13px;
  border-bottom: 1px solid #f0f3f7;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: #f5fafd; }
.client-name { font-weight: 500; color: #094155; }
.client-meta { font-size: 11px; color: #6b7785; margin-top: 2px; }
.pct-cell {
  display: inline-block; padding: 3px 8px;
  border-radius: 4px; font-weight: 600;
  font-size: 12px; min-width: 50px; text-align: center;
}
.pct-high { background: #d4f4dd; color: #1d8348; }
.pct-mid { background: #fff4d4; color: #946a00; }
.pct-low { background: #ffd4d4; color: #b73a3a; }
.solde-neg { color: #b73a3a; font-weight: 600; }
.solde-pos { color: #1d8348; }
.badge {
  display: inline-block; padding: 2px 7px;
  background: #eef2f6; color: #094155;
  border-radius: 10px; font-size: 11px; font-weight: 500;
}
.variation {
  display: block; font-size: 10px;
  margin-top: 2px; font-weight: 400;
}
.variation.up { color: #1d8348; }
.variation.down { color: #b73a3a; }
.variation.new { color: #1482AB; }

/* === FOOTER === */
.footer {
  text-align: center; color: #6b7785;
  font-size: 12px; padding: 16px 0;
}

/* === MODAL === */
.modal-overlay {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(9, 65, 85, 0.6);
  z-index: 100;
  align-items: center; justify-content: center;
  padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: white; border-radius: 12px;
  padding: 28px;
  max-width: 950px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 2px solid #094155;
}
.modal-header h3 { color: #094155; font-size: 22px; margin-bottom: 4px; }
.modal-header-meta { font-size: 12px; color: #6b7785; }
.modal-close {
  background: none; border: none;
  font-size: 28px; cursor: pointer;
  color: #6b7785; line-height: 1; padding: 0;
}
.modal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 24px;
}
.modal-stat {
  background: linear-gradient(135deg, #094155 0%, #1482AB 100%);
  color: white; padding: 14px;
  border-radius: 8px;
}
.modal-stat-label {
  font-size: 11px; opacity: 0.85;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.modal-stat-value { font-size: 20px; font-weight: 600; margin-top: 4px; }
.modal-stat-detail { font-size: 11px; opacity: 0.8; margin-top: 2px; }
.modal-section { margin-top: 24px; }
.modal-section h4 {
  color: #094155; font-size: 14px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.modal-section h4::before {
  content: ''; width: 3px; height: 14px;
  background: #43B6D3; border-radius: 2px;
}
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th {
  background: #f5f7fa; padding: 8px 10px;
  text-align: left; font-size: 10px; color: #6b7785;
}
.mini-table th.num { text-align: right; }
.mini-table td { padding: 8px 10px; border-bottom: 1px solid #f0f3f7; }
.mini-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mini-table tbody tr:hover { background: #f5fafd; }
