/* ═══════════════════════════════════════════
   E4M Migration Intelligence Dashboard
   ═══════════════════════════════════════════ */

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

#e4m-root {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: #1a2e22;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 4px;
}

/* ── Loading & Error ── */
.e4m-loading {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 320px; gap: 16px;
  color: #5a7a6a;
}
.e4m-spinner {
  width: 44px; height: 44px;
  border: 3px solid #d0e8dc;
  border-top-color: #1a6b55;
  border-radius: 50%;
  animation: e4m-spin 0.8s linear infinite;
}
@keyframes e4m-spin { to { transform: rotate(360deg); } }

.e4m-error {
  background: #fff5f5; border: 1px solid #fca5a5;
  border-radius: 12px; padding: 24px 28px;
  color: #991b1b; font-size: .9rem;
}
.e4m-no-config {
  background: #f0f9f5; border: 2px dashed #6db89a;
  border-radius: 14px; padding: 40px;
  text-align: center; color: #2d6a4f;
}
.e4m-no-config span { font-size: 2.5rem; display: block; margin-bottom: 12px; }
.e4m-no-config a { color: #1a6b55; font-weight: 600; }

/* ── Layout ── */
.e4m-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .e4m-layout { grid-template-columns: 1fr; }
}

/* ── Sidebar / Filters ── */
.e4m-sidebar {
  background: #fff;
  border: 1px solid #e2ede8;
  border-radius: 16px;
  padding: 24px 20px;
  position: sticky;
  top: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.e4m-sidebar h3 {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: #1a6b55;
  margin: 0 0 18px;
  display: flex; align-items: center; gap: 7px;
}

.e4m-filter-group {
  margin-bottom: 18px;
}
.e4m-filter-group label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: #4a6b59;
  margin-bottom: 6px;
  letter-spacing: .3px;
}

.e4m-select {
  width: 100%;
  background: #f4f9f6;
  border: 1px solid #c8ddd4;
  border-radius: 9px;
  padding: 9px 32px 9px 12px;
  font-size: .85rem;
  color: #1a2e22;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%231a6b55' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.e4m-select:focus {
  outline: none;
  border-color: #1a6b55;
  box-shadow: 0 0 0 3px rgba(26,107,85,.13);
}

.e4m-btn-download {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  width: 100%;
  background: #1a2e22;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 24px;
  transition: background .2s, transform .1s;
  letter-spacing: .2px;
}
.e4m-btn-download:hover { background: #1a6b55; }
.e4m-btn-download:active { transform: scale(.98); }

.e4m-last-updated {
  font-size: .72rem;
  color: #8aab98;
  margin-top: 14px;
  text-align: center;
}

/* ── Main Panel ── */
.e4m-main { display: flex; flex-direction: column; gap: 20px; }

/* ── KPI Cards ── */
.e4m-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 700px) {
  .e4m-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

.e4m-kpi {
  background: #fff;
  border: 1px solid #e2ede8;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s;
}
.e4m-kpi:hover { box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.e4m-kpi::before {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #1a6b55, #4db88a);
  border-radius: 0 0 14px 14px;
}

.e4m-kpi .kpi-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: #7a9d8a;
  margin-bottom: 6px;
}
.e4m-kpi .kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: #1a2e22;
  line-height: 1;
  margin-bottom: 4px;
}
.e4m-kpi .kpi-sub {
  font-size: .75rem;
  color: #1a6b55;
  font-weight: 500;
}

/* ── Migration Pathway Banner ── */
.e4m-pathway {
  background: linear-gradient(135deg, #eef7f3 0%, #f0f9f5 100%);
  border: 1px solid #c8ddd4;
  border-radius: 16px;
  padding: 28px 32px;
  position: relative;
  overflow: hidden;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.e4m-pathway::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, #b7d8c8 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .5;
}

.e4m-pathway-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 640px;
}

.e4m-pathway-node {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.e4m-pathway-circle {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}
.e4m-pathway-circle.origin {
  background: #8ab4a0;
  color: #fff;
}
.e4m-pathway-circle.dest {
  background: #1a6b55;
  color: #fff;
}
.e4m-pathway-label {
  font-size: .78rem;
  font-weight: 600;
  color: #2d5a45;
  white-space: nowrap;
}

.e4m-pathway-line {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  position: relative;
}
.e4m-pathway-dashes {
  width: 100%;
  height: 2px;
  background: repeating-linear-gradient(90deg, #1a6b55 0, #1a6b55 8px, transparent 8px, transparent 14px);
  position: relative;
}
.e4m-pathway-dashes::after {
  content: '▶';
  position: absolute;
  right: -6px; top: 50%;
  transform: translateY(-50%);
  color: #1a6b55;
  font-size: 10px;
}
.e4m-pathway-pill {
  background: #fff;
  border: 1.5px solid #1a6b55;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: .72rem;
  font-weight: 600;
  color: #1a6b55;
  white-space: nowrap;
}

/* ── Charts Row ── */
.e4m-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 700px) {
  .e4m-charts-row { grid-template-columns: 1fr; }
}

.e4m-chart-card {
  background: #fff;
  border: 1px solid #e2ede8;
  border-radius: 16px;
  padding: 24px 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.e4m-chart-card h4 {
  font-size: .92rem;
  font-weight: 700;
  color: #1a2e22;
  margin: 0 0 18px;
  text-align: center;
}
.e4m-chart-wrap {
  position: relative;
  height: 240px;
}

/* ── Top Countries ── */
.e4m-countries-card {
  background: #fff;
  border: 1px solid #e2ede8;
  border-radius: 16px;
  padding: 24px 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.e4m-countries-card h4 {
  font-size: .92rem;
  font-weight: 700;
  color: #1a2e22;
  margin: 0 0 18px;
}
.e4m-bar-row {
  display: flex; align-items: center;
  gap: 10px; margin-bottom: 10px;
}
.e4m-bar-row .country-name {
  font-size: .78rem;
  font-weight: 500;
  color: #2d5a45;
  min-width: 90px;
  text-align: right;
}
.e4m-bar-track {
  flex: 1; height: 10px;
  background: #eef5f0;
  border-radius: 99px;
  overflow: hidden;
}
.e4m-bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #1a6b55, #4db88a);
  transition: width .6s ease;
}
.e4m-bar-row .country-val {
  font-size: .73rem;
  color: #7a9d8a;
  min-width: 50px;
}
