/* Dashboard */
.nav-user {
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

.dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.dashboard--with-sidebar {
  max-width: 1200px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2rem;
  align-items: start;
}

.dashboard-main {
  min-width: 0;
}

.dashboard-main-grid {
  display: grid;
  /* auto-fit so a single panel (e.g. team members/leads who only have a
     cashbook panel, no invoices) stretches to fill the main area instead of
     sitting in a half-width column. Two panels still sit side by side, and it
     collapses to one column when the space is too tight. */
  /* min(): a bare minmax(380px, …) is a floor the grid cannot honour in a
     narrower container, and the panels spill out instead of shrinking. */
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
  gap: 1.5rem;
  align-items: start;
}

.dashboard-section--full {
  grid-column: 1 / -1;
}

.dashboard-sidebar {
  position: sticky;
  top: 1rem;
}

.dashboard-section--sidebar {
  padding: 1.25rem;
}

.sidebar-projects {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sidebar-project {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.sidebar-project:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sidebar-project-link {
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sidebar-project-link:hover .sidebar-project-name {
  color: var(--md-sys-color-primary);
}

.sidebar-project-name {
  font: var(--md-sys-typescale-title-small);
  letter-spacing: var(--md-sys-typescale-title-small-tracking);
  transition: color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.sidebar-project-code {
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

.sidebar-project-action {
  font: var(--md-sys-typescale-label-medium);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-primary);
  text-decoration: none;
  margin-top: 0.15rem;
}

.sidebar-project-action:hover {
  text-decoration: underline;
}

/* ── Favourites ────────────────────────────────────────────── */
.sidebar-projects-group-label {
  font: var(--md-sys-typescale-title-small);
  letter-spacing: var(--md-sys-typescale-title-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 0.6rem;
}

/* Space the second group's label off the favourites list above it. */
.sidebar-projects + .sidebar-projects-group-label {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.sidebar-project-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-project-row .sidebar-project-link {
  flex: 1;
  min-width: 0;
}

/* button_to wraps the star in a <form>; strip its block-level chrome. */
.sidebar-project-row .button_to {
  margin: 0;
  line-height: 0;
  flex-shrink: 0;
}

.sidebar-project-fav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem;
  background: none;
  border: none;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  transition: color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.sidebar-project-fav .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.sidebar-project-fav:hover {
  color: var(--md-sys-color-primary);
}

/* Favourited: the icon swaps from the outline star to the filled one. */
.sidebar-project-fav.is-favorited {
  color: var(--md-sys-color-primary);
}

.sidebar-project-fav.is-favorited .icon .icon-outline { display: none; }
.sidebar-project-fav.is-favorited .icon .icon-filled { display: inline; }

@media (max-width: 900px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  .dashboard-sidebar {
    position: static;
  }
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.dashboard-header h1 {
  font: var(--md-sys-typescale-headline-small);
  letter-spacing: var(--md-sys-typescale-headline-small-tracking);
  color: var(--md-sys-color-on-surface);
}

.dashboard-grid {
  display: grid;
  /* Same narrow-container floor as .dashboard-main-grid above. */
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
  gap: 2rem;
  align-items: start;
}

.dashboard-section {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 1.5rem;
}

.dashboard-section h2 {
  font: var(--md-sys-typescale-title-medium);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  color: var(--md-sys-color-on-surface);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* Worded counts drop below the title in narrow columns instead of squeezing it. */
  flex-wrap: wrap;
}

.section-heading-link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.section-heading-link:hover { color: var(--md-sys-color-primary); }

/* M3 badge: a full-round label-small pill. Neutral counts sit on the
   secondary container. */
.section-count {
  font: var(--md-sys-typescale-label-small);
  letter-spacing: var(--md-sys-typescale-label-small-tracking);
  color: var(--md-sys-color-on-secondary-container);
  background: var(--md-sys-color-secondary-container);
  border-radius: var(--md-sys-shape-corner-full);
  min-height: 1rem;
  padding: 0 0.5rem;
  white-space: nowrap;
}

/* A queue count takes the status palette of the rows it counts. */
.section-count--requested {
  color: var(--requested);
  background: var(--requested-bg);
}

.section-count--review {
  color: var(--review);
  background: var(--review-bg);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  /* Unwrapped, this row pushes the page wider than a narrow viewport. */
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cashbook-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* Always inside a section card already (cashbook index, donor invoice line
     items), so plain text on that card — no box of its own. */
  margin-bottom: 1rem;
  font: var(--md-sys-typescale-body-medium);
  letter-spacing: var(--md-sys-typescale-body-medium-tracking);
  color: var(--md-sys-color-on-surface);
}

.cashbook-totals strong {
  font: var(--md-sys-typescale-title-medium);
  letter-spacing: var(--md-sys-typescale-title-medium-tracking);
  color: var(--md-sys-color-primary);
}

.lerf-build-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lerf-build-hint {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
}

@media (max-width: 760px) {
  .cashbook-totals {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .lerf-build-action {
    justify-content: flex-start;
  }

  .lerf-build-hint {
    width: 100%;
  }

  .lerf-build-hint-label {
    white-space: normal;
  }

  .btn-lerf-build {
    width: 100%;
    text-align: center;
  }
}

.lerf-build-hint-label {
  font: var(--md-sys-typescale-label-medium);
  letter-spacing: var(--md-sys-typescale-label-medium-tracking);
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
}

.lerf-build-hint ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.lerf-build-hint li {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
}

.lerf-build-hint li::before {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border: 1.5px solid var(--md-sys-color-outline);
  border-radius: 50%;
}

/* Met requirement: an M3 selected chip (secondary container, no border). */
.lerf-build-hint li.is-met {
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
  background: var(--md-sys-color-secondary-container);
}

/* Met: the empty ring becomes a Material check (M3's selected filter chip
   leads with one). */
.lerf-build-hint li.is-met::before {
  width: 18px;
  height: 18px;
  margin: -2px 0;
  border: 0;
  border-radius: 0;
  background-color: currentColor;
  -webkit-mask: var(--md-icon-check) center / contain no-repeat;
  mask: var(--md-icon-check) center / contain no-repeat;
}

/* Not-yet-ready: a disabled-looking outlined button; --active is the filled button. */
.btn-lerf-build {
  background: transparent;
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
  border: 1px solid color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
  transition:
    background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard),
    border-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
}

.btn-lerf-build--active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

.btn-lerf-build--active:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-primary), var(--md-sys-color-on-primary) 8%);
  border-color: transparent;
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-level1);
}

.btn-lerf-build:disabled {
  opacity: 1; /* override the generic disabled rule — colour tells the story */
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Dashboard view-all link ───────────────────────────────── */
.dashboard-view-all {
  display: block;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  color: var(--md-sys-color-primary);
  text-align: center;
  text-decoration: none;
}

.dashboard-view-all:hover { text-decoration: underline; }

.dashboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* .status-badge is nowrap, so in a narrow column the right-hand group has to
   wrap to its own line rather than overflow the card. M3 list item: at least
   56px tall, separated by an outline-variant hairline. */
.dashboard-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  min-height: 56px;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.dashboard-list-item:last-child {
  border-bottom: none;
}

.dashboard-list-link {
  text-decoration: none;
  color: inherit;
  transition: background-color var(--md-sys-motion-duration-short4) var(--md-sys-motion-easing-standard);
  /* Square, like M3 list items: a radius would bend the row divider. */
  margin: 0 -0.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.dashboard-list-link:hover {
  background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
}

.list-item-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  /* min-width lets a long title wrap; the basis is where the aside wraps. */
  flex: 1 1 11rem;
  min-width: 0;
}

.list-item-title {
  font: var(--md-sys-typescale-title-small);
  letter-spacing: var(--md-sys-typescale-title-small-tracking);
  color: var(--md-sys-color-on-surface);
  /* Unbroken strings (a "DE→EN" title, an email) must not push the row wider. */
  overflow-wrap: anywhere;
}

.list-item-meta {
  font: var(--md-sys-typescale-body-small);
  letter-spacing: var(--md-sys-typescale-body-small-tracking);
  color: var(--md-sys-color-on-surface-variant);
  /* An email at the end would otherwise set the row's min-content width. */
  overflow-wrap: anywhere;
}

/* An optional amount beside the status badge. Some rows put the badge straight
   on the row — same treatment: whole, right-aligned on whichever line it takes. */
.list-item-aside,
.dashboard-list-item > .status-badge {
  flex-shrink: 0;
  margin-left: auto;
}

.list-item-aside {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  /* A long status label (e.g. "Project Lead Verification Requested") must
     never push the row past a phone's width: let the aside shrink and wrap. */
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.list-item-aside .status-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-amount {
  font: var(--md-sys-typescale-label-large);
  letter-spacing: var(--md-sys-typescale-label-large-tracking);
  font-variant-numeric: tabular-nums;
  color: var(--md-sys-color-on-surface);
  white-space: nowrap;
}

/* .status-badge and the app-wide .status-* / .role-* palettes live in
   badges.css. */

