/* =========================================================
   WIRTZ HUB · RECURSOS · DINERO
   Finanzas operativas · ingresos · egresos · cuentas · flujo
   ========================================================= */

.money-page {
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 7px;
  min-height: calc(100vh - var(--topbar-height) - 44px);
  animation: fadeUp 0.2s ease both;
}

/* =========================================================
   HEADER COMPACTO
   ========================================================= */

.money-head {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 56px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.money-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.money-brand__icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text-strong);
}

.money-brand__icon .icon {
  width: 15px;
  height: 15px;
}

.money-brand h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.055em;
}

.money-brand p {
  margin: 2px 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 760;
  line-height: 1.25;
}

.money-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

/* =========================================================
   BOTONES
   ========================================================= */

.money-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    transform var(--transition),
    opacity var(--transition);
}

.money-btn .icon {
  width: 11px;
  height: 11px;
  stroke-width: 2;
}

.money-btn:active {
  transform: scale(0.98);
}

.money-btn--light {
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text-strong);
}

.money-btn--light:hover {
  border-color: var(--line-strong);
  background: var(--panel-hover);
}

.money-btn--dark {
  border: 1px solid var(--text-strong);
  background: var(--text-strong);
  color: var(--white);
}

.money-btn--dark:hover {
  opacity: 0.88;
}

html[data-theme="dark"] .money-btn--dark {
  color: #090b10;
}

/* =========================================================
   MÉTRICAS COMPACTAS
   ========================================================= */

.money-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.money-metric {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 45px;
  padding: 7px 8px;
  border-right: 1px solid var(--line);
}

.money-metric:last-child {
  border-right: 0;
}

.money-metric span {
  color: var(--muted);
  font-size: 7.2px;
  font-weight: 950;
  letter-spacing: 0.085em;
  line-height: 1;
  text-transform: uppercase;
}

.money-metric strong {
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.06em;
}

.money-metric small {
  color: var(--muted-2);
  font-size: 7px;
  font-weight: 820;
  line-height: 1;
}

/* =========================================================
   PANEL PRINCIPAL
   ========================================================= */

.money-panel,
.money-flow {
  display: grid;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.money-toolbar {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px;
  border-bottom: 1px solid var(--line);
}

.money-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.money-title span {
  color: var(--muted);
  font-size: 7.4px;
  font-weight: 950;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.money-title strong {
  color: var(--text-strong);
  font-size: 11.5px;
  font-weight: 950;
  line-height: 1.1;
  letter-spacing: -0.045em;
}

/* =========================================================
   FILTROS
   ========================================================= */

.money-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  flex-wrap: wrap;
}

.money-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(390px, 100%);
  min-width: 240px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--muted);
  transition:
    background var(--transition),
    border-color var(--transition);
}

.money-search:focus-within {
  border-color: var(--line-strong);
  background: var(--panel-hover);
}

.money-search .icon {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.money-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-strong);
  outline: none;
  font-size: 9px;
  font-weight: 780;
}

.money-search input::placeholder {
  color: var(--muted-2);
}

.money-filters select {
  height: 28px;
  min-width: 96px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--text-strong);
  outline: none;
  font-size: 8.5px;
  font-weight: 850;
}

/* =========================================================
   TABLA
   ========================================================= */

.money-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
}

.money-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  background: var(--panel-solid);
}

.money-table th,
.money-table td {
  height: 31px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 8.6px;
  font-weight: 720;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.money-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-solid);
  color: var(--muted);
  font-size: 7px;
  font-weight: 950;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.money-table tbody tr {
  transition:
    background var(--transition),
    color var(--transition);
}

.money-table tbody tr:hover {
  background: var(--panel-hover);
}

.money-table strong {
  color: var(--text-strong);
  font-weight: 950;
}

.money-concept {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  color: var(--text-strong);
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.money-date,
.money-account,
.money-method {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-strong);
  font-weight: 870;
}

.money-date .icon,
.money-account .icon,
.money-method .icon {
  width: 11px;
  height: 11px;
  color: var(--muted);
}

.money-pill,
.money-status,
.money-currency {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 18px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text-strong);
  font-size: 7.5px;
  font-weight: 950;
}

.money-pill::before,
.money-status::before,
.money-currency::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--muted);
}

.money-pill.is-income::before,
.money-status.is-confirmed::before {
  background: var(--success);
}

.money-pill.is-expense::before,
.money-status.is-pending::before,
.money-status.is-scheduled::before {
  background: var(--warning);
}

.money-pill.is-expense {
  color: var(--text-strong);
}

.money-amount {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 86px;
  color: var(--text-strong);
  font-weight: 950;
}

.money-amount.is-income {
  color: var(--success);
}

.money-amount.is-expense {
  color: var(--danger);
}

.money-table td:nth-child(8),
.money-table th:nth-child(8) {
  text-align: right;
}

/* =========================================================
   FLUJO ABAJO
   ========================================================= */

.money-flow {
  align-content: start;
}

.money-flow__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}

.money-flow__head span {
  color: var(--muted);
  font-size: 7.4px;
  font-weight: 950;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.money-flow__head strong {
  display: block;
  margin-top: 2px;
  color: var(--text-strong);
  font-size: 11.5px;
  font-weight: 950;
  line-height: 1;
  letter-spacing: -0.04em;
}

.money-flow__head .icon {
  width: 14px;
  height: 14px;
  color: var(--text-strong);
}

.money-timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.money-event {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 7px;
  min-height: 62px;
  padding: 8px;
  border-right: 1px solid var(--line);
}

.money-event:last-child {
  border-right: 0;
}

.money-event__icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text-strong);
}

.money-event__icon .icon {
  width: 12px;
  height: 12px;
}

.money-event__body {
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 0;
}

.money-event__body strong {
  color: var(--text-strong);
  font-size: 9px;
  font-weight: 950;
  line-height: 1.1;
}

.money-event__body p {
  margin: 0;
  color: var(--muted);
  font-size: 7.8px;
  font-weight: 760;
  line-height: 1.3;
}

.money-event__body small {
  color: var(--muted-2);
  font-size: 7px;
  font-weight: 850;
  line-height: 1;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1380px) {
  .money-head {
    grid-template-columns: 1fr;
  }

  .money-actions {
    justify-content: flex-start;
  }

  .money-toolbar {
    grid-template-columns: 1fr;
  }

  .money-filters {
    justify-content: flex-start;
  }

  .money-timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .money-event:nth-child(2n) {
    border-right: 0;
  }

  .money-event:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 1100px) {
  .money-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .money-metric:nth-child(3n) {
    border-right: 0;
  }

  .money-metric:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .money-page {
    gap: 6px;
  }

  .money-actions,
  .money-filters {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .money-search {
    width: 100%;
    min-width: 0;
  }

  .money-btn,
  .money-filters select {
    width: 100%;
  }

  .money-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .money-metric {
    border-right: 1px solid var(--line);
    border-top: 1px solid var(--line);
  }

  .money-metric:nth-child(1),
  .money-metric:nth-child(2) {
    border-top: 0;
  }

  .money-metric:nth-child(2n) {
    border-right: 0;
  }

  .money-timeline {
    grid-template-columns: 1fr;
  }

  .money-event {
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .money-event:first-child {
    border-top: 0;
  }

  .money-brand {
    align-items: flex-start;
  }
}