/* ============================================================================
   home.css — Welcome dashboard
   Light, fixed-shape landing page. Six KPI tiles + two charts.
   Added 2026-04-26.
   ============================================================================ */

.home-page {
  max-width: 1340px;
  margin: 0 auto;
  padding: 24px 28px 48px;
  color: #0f172a;
}

/* ---------- Header ---------- */
.home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.home-title {
  margin: 0 0 4px 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #0f172a;
}
.home-subtitle {
  margin: 0;
  color: #64748b;
  font-size: 14px;
}
.home-company-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}
.home-company-filter select {
  width: 100%;
  border: 1px solid #dbe3ef;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 34px 8px 12px;
}
.home-company-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 280px;
  border: 1px solid #dbe3ef;
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  padding: 0 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Range buttons ---------- */
.home-range {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.home-range-btn {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.home-range-btn:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.home-range-btn.is-active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}
.home-range-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ---------- KPI tiles ---------- */
.home-tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.home-tile {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: opacity 0.2s ease;
}
.home-tile.is-loading .home-tile-value {
  opacity: 0.35;
}
.home-tile-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 8px;
}
.home-tile-value {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
  letter-spacing: -0.01em;
  /* Long money values shouldn't wrap awkwardly */
  word-break: keep-all;
}

/* Responsive: collapse tiles to 3 cols on tablet, 2 on phone */
@media (max-width: 1100px) {
  .home-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .home-header {
    flex-direction: column;
    align-items: stretch;
  }
  .home-company-filter {
    min-width: 0;
  }
  .home-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-page  { padding: 16px; }
  .home-title { font-size: 26px; }
}

/* ---------- Charts ---------- */
.home-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 1100px) {
  .home-charts { grid-template-columns: 1fr; }
}
.home-chart-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 22px 24px;
  min-height: 320px;
}
.home-chart-title {
  margin: 0 0 14px 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}
.home-chart-body {
  display: flex;
  align-items: center;
  gap: 24px;
}
.home-chart-graphic {
  flex: 0 0 auto;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-chart-graphic svg {
  width: 100%;
  height: 100%;
  display: block;
}
.home-chart-legend {
  flex: 1 1 auto;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.home-chart-legend li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  color: #1e293b;
}
.home-chart-legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.home-chart-legend .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-chart-legend .value {
  font-weight: 700;
  color: #0f172a;
}

@media (max-width: 640px) {
  .home-chart-body { flex-direction: column; align-items: stretch; }
  .home-chart-graphic { width: 100%; height: 200px; }
}

/* ---------- Sales by associate ---------- */
.home-associate-card {
  margin-top: 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}
.home-associate-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 22px 24px 14px;
}
.home-associate-subtitle {
  margin: 4px 0 0;
  color: #64748b;
  font-size: 13px;
}
.home-associate-summary {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.home-associate-table-wrap,
.home-drilldown-table-wrap {
  overflow-x: auto;
}
.home-associate-table,
.home-drilldown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.home-associate-table th,
.home-drilldown-table th {
  padding: 13px 18px;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.home-associate-table td,
.home-drilldown-table td {
  padding: 16px 18px;
  border-bottom: 1px solid #eef2f7;
  color: #0f172a;
  vertical-align: middle;
}
.home-associate-table tr:last-child td,
.home-drilldown-table tr:last-child td {
  border-bottom: 0;
}
.home-associate-table strong {
  display: block;
  font-weight: 800;
}
.home-associate-role {
  display: block;
  margin-top: 3px;
  color: #64748b;
  font-size: 13px;
}
.home-associate-rank {
  width: 70px;
}
.home-associate-empty {
  color: #64748b;
  text-align: center;
}
.home-associate-deferred {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.45;
}
.home-associate-fetch-btn {
  appearance: none;
  border: 1px solid #99f6e4;
  background: #ccfbf1;
  color: #0f766e;
  min-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
}
.home-associate-fetch-btn:hover {
  background: #99f6e4;
  border-color: #5eead4;
}
.home-associate-table .is-unassigned td {
  background: #f8fafc;
}
.home-score-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #dff4f2;
  border: 1px solid #a8d8d4;
  color: #087f7b;
  font-weight: 800;
}
.home-drilldown-btn {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
}
.home-drilldown-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}
.home-drilldown-modal[hidden] {
  display: none;
}
.home-drilldown-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.home-drilldown-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}
.home-drilldown-panel {
  position: relative;
  width: min(1040px, 100%);
  max-height: min(760px, calc(100vh - 56px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}
.home-drilldown-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid #e2e8f0;
}
.home-drilldown-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}
.home-drilldown-header p {
  margin: 4px 0 0;
  color: #64748b;
}
.home-drilldown-close {
  width: 36px;
  height: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  font-weight: 800;
}
.home-drilldown-summary {
  padding: 14px 22px;
  color: #0f172a;
  font-weight: 800;
  border-bottom: 1px solid #e2e8f0;
}
.home-drilldown-table-wrap {
  overflow: auto;
}
.home-drilldown-table a {
  color: #2563eb;
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 760px) {
  .home-associate-header {
    flex-direction: column;
  }
  .home-associate-summary {
    white-space: normal;
  }
  .home-drilldown-modal {
    padding: 12px;
  }
}

/* ---------- Skeleton (shown until first data arrives) ---------- */
.home-chart-skeleton {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 200%;
  animation: home-shimmer 1.4s linear infinite;
}
[data-chart="carriers"] .home-chart-skeleton {
  border-radius: 8px;
  width: 100%;
  height: 160px;
}
@keyframes home-shimmer {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 200%; }
}

/* ---------- Error banner ---------- */
.home-error {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 14px;
}
