/* ==========================================================
   Financial Dashboard — Executive KPI Layout
   Clean, data-dense dashboard for decision-making
   ========================================================== */

/* --- Page layout: header + one panel that fills the viewport --- */
.fd-layout {
  display: flex;
  flex-direction: column;
}

.fd-layout__frame {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* Desktop (sidebar layout): pin the dashboard to the viewport so the panel
   grows to the bottom edge and the client list scrolls inside it. 48px is
   the vertical padding of .app-main. Phones keep normal document flow. */
@media (min-width: 768px) {
  .fd-layout {
    height: calc(100vh - 48px);
  }
}

/* --- Detail Panels --- */
.fd-panel {
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  overflow: hidden;
}

.fd-panel--fill {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.fd-panel--fill .fd-panel__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.fd-panel__header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.fd-panel__title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-body-emphasis-color);
  margin: 0;
  white-space: nowrap;
}

/* Right-hand cluster (exchange rate, drill-down link). Drops to its own
   right-aligned line when the header is too narrow to hold everything. */
.fd-panel__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  white-space: nowrap;
}

.fd-panel__body {
  padding: 1.25rem;
}

/* --- Per-Client Breakdown List --- */
.fd-clients {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .fd-clients {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
}

.fd-clients__head {
  grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  background: #fafafa;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b919a;
  position: sticky;
  top: 0;
  z-index: 1;
}

.fd-clients__sort {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  justify-content: flex-end;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.fd-clients__sort:hover {
  color: var(--bs-body-emphasis-color);
}

.fd-clients__sort-icon {
  font-size: 0.7rem;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}

.fd-clients__sort:hover .fd-clients__sort-icon {
  opacity: 0.85;
}

.fd-clients__sort--active {
  color: var(--bs-body-emphasis-color);
}

.fd-clients__sort--active .fd-clients__sort-icon {
  opacity: 1;
  color: var(--bs-primary);
}

@media (min-width: 768px) {
  .d-md-grid.fd-clients__head {
    display: grid !important;
  }
}

.fd-clients__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s ease;
}

.fd-clients__rows .fd-clients__row:hover {
  background: rgba(var(--bs-primary-rgb), 0.03);
  color: inherit;
}

.fd-clients__rows .fd-clients__row:last-child {
  border-bottom: 0;
}

/* Pinned totals footer row */
.fd-clients__row--total {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: #fafafa;
  border-top: 2px solid rgba(0, 0, 0, 0.08);
  border-bottom: 0;
}

.fd-clients__row--total .fd-clients__name,
.fd-clients__row--total .fd-clients__value,
.fd-clients__row--total .fd-clients__rate-value {
  font-weight: 700;
}

@media (min-width: 768px) {
  .fd-clients__row {
    grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    align-items: center;
  }
}

.fd-clients__cell {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (min-width: 768px) {
  .fd-clients__cell--num {
    justify-content: flex-end;
  }
}

.fd-clients__cell--name {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
}

.fd-clients__name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bs-body-color);
}

.fd-clients__icon {
  color: var(--bs-primary);
  flex-shrink: 0;
  font-size: 0.875rem;
}

.fd-clients__name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.fd-clients__count {
  font-size: 0.7rem;
  color: #8b919a;
  padding-left: 1.375rem;
}

.fd-clients__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b919a;
}

.fd-clients__value {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.fd-clients__rate {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  width: 100%;
  max-width: 110px;
}

.fd-clients__rate-value {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--bs-body-color);
}

.fd-clients__rate-bar {
  height: 4px;
  width: 100%;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.fd-clients__rate-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* --- Responsive --- */
@media (max-width: 767.98px) {
  .fd-panel__body {
    padding: 1rem;
  }

  .fd-panel__body.p-0 {
    padding: 0 !important;
  }

  .fd-clients__row {
    padding: 0.875rem 1rem;
  }

  .fd-clients__rate {
    max-width: 140px;
  }
}
