[data-page="settlements"] {
  display: block;
  min-height: 100%;
}

.settlements-page {
  width: min(58rem, 100%);
  min-height: 28rem;
  margin: 0 auto;
  padding: 1rem;
  color: var(--ps-text-primary, #f5f5f5);
}

.settlements-loading {
  min-height: 22rem;
  display: grid;
  place-items: center;
}

.settlements-loading .ps-spinner {
  width: 2rem;
  height: 2rem;
  color: var(--ps-success, #22c55e);
}

.settlements-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settlements-header h1 {
  margin: 0;
  font-family: Poppins, sans-serif;
  font-size: 1.25rem;
}

.settlements-header p {
  margin: 0.125rem 0 0;
  color: var(--ps-text-secondary, #a3a3a3);
  font-size: 0.875rem;
}

.settlements-header > button {
  min-height: 2.25rem;
  padding: 0.45rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--ps-border-light, #3a3a3a);
  border-radius: 0.5rem;
  color: var(--ps-text-primary, #f5f5f5);
  background: var(--ps-bg-elevated, #202020);
  font-size: 0.875rem;
}

.settlements-header > button:hover:not(:disabled) {
  background: var(--ps-bg-hover, #292929);
}

.settlements-header > button .ps-icon,
.settlements-header > button .ps-spinner {
  width: 1rem;
  height: 1rem;
}

.settlement-summary {
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.settlement-summary-card {
  min-height: 6.25rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 0.75rem;
  color: var(--ps-text-secondary, #a3a3a3);
  background: var(--ps-bg-surface, #171717);
  text-align: center;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.settlement-summary-card:hover,
.settlement-summary-card.is-active {
  transform: scale(1.02);
  border-color: currentColor;
}

.settlement-summary-card.is-active {
  box-shadow: 0 0 0 2px var(--ps-bg-base, #0a0a0a), 0 0 0 4px currentColor;
}

.settlement-summary-card.is-positive { color: var(--ps-success, #22c55e); }
.settlement-summary-card.is-warning { color: var(--ps-warning, #f59e0b); }
.settlement-summary-card.is-negative { color: var(--ps-error, #ef4444); }

.settlement-summary-card span,
.settlement-summary-card small,
.settlement-summary-card strong {
  display: block;
}

.settlement-summary-card span {
  font-size: 0.875rem;
  font-weight: 600;
}

.settlement-summary-card strong {
  font-size: 1.5rem;
  letter-spacing: -0.025em;
}

.settlement-summary-card small {
  margin-top: 0.25rem;
  color: var(--ps-text-muted, #737373);
  font-size: 0.75rem;
}

.settlement-filter-note {
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0.5rem;
  color: var(--ps-text-secondary, #a3a3a3);
  background: var(--ps-bg-elevated, #202020);
  font-size: 0.875rem;
}

.settlement-filter-note b { color: var(--ps-text-primary, #f5f5f5); }
.settlement-filter-note button { padding: 0.25rem 0.5rem; border: 0; color: var(--ps-text-secondary, #a3a3a3); background: transparent; font-size: 0.75rem; }
.settlement-filter-note button:hover { color: var(--ps-text-primary, #fff); }

.settlement-groups,
.settlement-group,
.settlement-group > div {
  display: grid;
  gap: 0.75rem;
}

.settlement-group {
  margin-bottom: 1rem;
}

.settlement-group h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ps-text-primary, #f5f5f5);
  font-family: Poppins, sans-serif;
  font-size: 1rem;
}

.settlement-group h2 .ps-icon { width: 1.25rem; height: 1.25rem; }
.settlement-group.is-positive h2 { color: var(--ps-success, #22c55e); }
.settlement-group.is-warning h2 { color: var(--ps-warning, #f59e0b); }
.settlement-group.is-muted h2 { color: var(--ps-text-secondary, #a3a3a3); }

.settlement-card {
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--ps-warning, #f59e0b) 50%, transparent);
  border-radius: 0.75rem;
  background: var(--ps-bg-surface, #171717);
}

.settlement-card--winner,
.settlement-card.is-confirmed {
  border-color: color-mix(in srgb, var(--ps-success, #22c55e) 55%, transparent);
}

.settlement-card__summary {
  display: grid;
  grid-template-columns: 2.5rem minmax(12rem, 1fr) minmax(12rem, auto);
  align-items: start;
  gap: 0.75rem;
}

.settlement-card__money-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--ps-warning, #f59e0b);
  background: color-mix(in srgb, var(--ps-warning, #f59e0b) 20%, transparent);
}

.settlement-card--winner .settlement-card__money-icon {
  color: var(--ps-success, #22c55e);
  background: color-mix(in srgb, var(--ps-success, #22c55e) 20%, transparent);
}

.settlement-card__money-icon .ps-icon { width: 1.25rem; height: 1.25rem; }

.settlement-card__details > p {
  margin: 0;
  color: var(--ps-text-primary, #f5f5f5);
  font-weight: 500;
}

.settlement-card__details > strong {
  display: block;
  color: var(--ps-text-primary, #f5f5f5);
  font-size: 1.5rem;
}

.settlement-card__meta {
  margin-top: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.settlement-card__meta > b {
  color: var(--ps-text-secondary, #a3a3a3);
  font-size: 0.75rem;
}

.settlement-game-type,
.settlement-guest {
  padding: 0.125rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.settlement-game-type {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.2);
}

.settlement-game-type--stroke { color: #c084fc; background: rgba(168, 85, 247, 0.2); }
.settlement-game-type--game { color: var(--ps-text-secondary, #a3a3a3); background: var(--ps-bg-elevated, #252525); }
.settlement-game-type .ps-icon { width: 0.75rem; height: 0.75rem; }
.settlement-guest { color: #fbbf24; background: rgba(245, 158, 11, 0.2); }

.settlement-date {
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--ps-text-muted, #737373);
  font-size: 0.75rem;
}

.settlement-date .ps-icon { width: 0.75rem; height: 0.75rem; }

.settlement-card__state {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.settlement-status {
  width: fit-content;
  padding: 0.25rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.2);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.settlement-status--requested_venmo { color: #60a5fa; background: rgba(59, 130, 246, 0.2); }
.settlement-status--requested_zelle { color: #c084fc; background: rgba(168, 85, 247, 0.2); }
.settlement-status--requested_cash,
.settlement-status--paid,
.settlement-status--confirmed { color: var(--ps-success, #22c55e); background: color-mix(in srgb, var(--ps-success, #22c55e) 20%, transparent); }
.settlement-status--confirmed { background: color-mix(in srgb, var(--ps-success, #22c55e) 30%, transparent); }
.settlement-status .ps-icon { width: 0.75rem; height: 0.75rem; }

.settlement-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.settlement-actions--wrap { flex-wrap: wrap; }

.settlement-actions button {
  min-height: 2rem;
  padding: 0.375rem 0.625rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--ps-border-light, #3a3a3a);
  border-radius: 0.45rem;
  color: var(--ps-text-primary, #f5f5f5);
  background: transparent;
  font-size: 0.75rem;
  font-weight: 600;
}

.settlement-actions button:hover { background: var(--ps-bg-hover, #292929); }
.settlement-actions button.is-venmo { border-color: rgba(59, 130, 246, 0.5); color: #60a5fa; }
.settlement-actions button.is-zelle { border-color: rgba(168, 85, 247, 0.5); color: #c084fc; }
.settlement-actions button.is-cash { border-color: color-mix(in srgb, var(--ps-success, #22c55e) 50%, transparent); color: var(--ps-success, #22c55e); }
.settlement-actions button.is-confirm { border-color: transparent; color: #fff; background: #16a34a; }
.settlement-actions button .ps-icon { width: 1rem; height: 1rem; }

.settlement-payment-info {
  max-width: 19rem;
  display: grid;
  justify-items: end;
  gap: 0.5rem;
}

.settlement-payment-info > small {
  padding: 0.25rem 0.5rem;
  border-radius: 0.4rem;
  color: var(--ps-text-muted, #737373);
  font-size: 0.75rem;
}

.settlement-payment-info > small:first-child:not(:last-child) {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.2);
}

.settlements-empty {
  padding: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px dashed var(--ps-border, #2a2a2a);
  border-radius: 0.75rem;
  color: var(--ps-text-secondary, #a3a3a3);
  background: var(--ps-bg-surface, #171717);
  text-align: center;
}

.settlements-empty > .ps-icon {
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  color: var(--ps-text-muted, #737373);
}

.settlements-empty h2 { margin: 0 0 0.5rem; font-family: Poppins, sans-serif; font-size: 1.125rem; color: var(--ps-text-primary, #f5f5f5); }
.settlements-empty p { margin: 0; font-size: 0.875rem; }
.settlements-empty--small { padding: 2rem; }

@media (max-width: 720px) {
  .settlement-card__summary { grid-template-columns: 2.5rem 1fr; }
  .settlement-card__state { grid-column: 1 / -1; padding-top: 0.5rem; align-items: stretch; }
  .settlement-status { align-self: flex-end; }
  .settlement-actions { justify-content: flex-end; }
}

@media (max-width: 480px) {
  .settlements-page { padding: 0.875rem; }
  .settlement-summary { gap: 0.5rem; }
  .settlement-summary-card { min-height: 5.5rem; padding: 0.75rem 0.35rem; }
  .settlement-summary-card strong { font-size: 1.18rem; }
  .settlement-summary-card small { font-size: 0.65rem; }
  .settlement-card { padding: 0.875rem; }
  .settlement-card__summary { grid-template-columns: 2.25rem 1fr; gap: 0.65rem; }
  .settlement-card__money-icon { width: 2.25rem; height: 2.25rem; }
  .settlement-actions button { flex: 1 1 auto; justify-content: center; }
}
