/* Dashboard: batch/round toolbar + report table (cards on phones). */

body:has(.dashboard) {
  background: #f3f5f9;
}

.dashboard {
  --db-ink: #1f2937;
  --db-muted: #6b7280;
  --db-line: #e5e7eb;
  --db-head: #1e293b;
  --db-accent: #2563eb;

  box-sizing: border-box;
  width: min(100% - 2rem, 90rem);
  margin: 1.25rem auto 2rem;
  color: var(--db-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.dashboard *,
.dashboard *::before,
.dashboard *::after {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Toolbar ---------- */

.dashboard-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1.25rem;
  background: #fff;
  border: 1px solid var(--db-line);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}

.dashboard-selected {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dashboard-round {
  margin-left: 0.5rem;
  padding: 0.15rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--db-accent);
  background: #e8efff;
  border-radius: 999px;
  white-space: nowrap;
  vertical-align: middle;
}

.dashboard-if-room {
  display: none;
}

@media (min-width: 550px) {
  .dashboard-if-room {
    display: inline;
  }
}

.dashboard-right-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.dashboard-switch-label {
  color: var(--db-muted);
  font-size: 0.9rem;
}

.dashboard .cell-action .review-btn {
  min-width: 5.5rem;
}

.dashboard-switch-round {
  display: inline-block;
}

.dashboard select {
  min-height: 2.25rem;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--db-ink);
  background-color: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  cursor: pointer;
}

.dashboard select:focus-visible {
  outline: 2px solid var(--db-accent);
  outline-offset: 1px;
}

/* ---------- Table card ---------- */

.table-wrapper {
  width: 100%;
}

/* Last resort: if cells can't wrap any further, scroll sideways. */
.table-scroll {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--db-line);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}

/* Bound the height (non-phone only) so the horizontal scrollbar sits at the
   bottom of the viewport instead of far below a long table. */
@media (min-width: 651px) {
  .table-scroll {
    overflow-y: auto;
    max-height: calc(100vh - 14rem);
  }
  .dashboard-row {
    cursor: pointer;
  }
  .dashboard .cell-action {
    display: none;
  }
}

.dashboard table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
}

.dashboard th,
.dashboard td {
  padding: 0.6rem 0.5rem;
  line-height: 1.25;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--db-line);
}

.dashboard thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-block: 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #e2e8f0;
  background: var(--db-head); /* opaque, so rows don't show through */
  border-bottom: 0;
}

.dashboard tbody tr:last-child td {
  border-bottom: 0;
}

.dashboard tbody tr:nth-of-type(even) {
  background: #f8fafc;
}

.dashboard tbody tr:hover {
  background: #eef4ff;
}

.cell-bird {
  font-weight: 600;
}

/* Keep id and date on one line so the bird/town columns absorb the wrapping. */
.dashboard td:nth-child(1),
.dashboard td:nth-child(3) {
  white-space: nowrap;
}

/* Vote and status columns are centered; the signed-in user's votes are
   highlighted. */
.dashboard th:nth-child(n+5),
.cell-vote,
.cell-status {
  text-align: center;
}

.cell-me {
  background: rgb(37 99 235 / 0.07);
}

/* ---------- Vote + status pills ---------- */

.vote,
.status {
  display: inline-block;
  min-width: 4ch;
  margin: 0;
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  border-radius: 999px;
}

.vote {
  color: #374151;
  background: #eef0f3;
}

.cell-me .vote:not(.vote-pending) {
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.cell-me .vote-pending {
  font-weight: 600;
}

.vote-accept  { color: #166534; background: #dcfce7; }
.vote-reject  { color: #991b1b; background: #fee2e2; }
.vote-defer   { color: #854d0e; background: #fef9c3; }
.vote-nsu     { color: #1e40af; background: #dbeafe; }
.vote-pending { color: #9ca3af; background: transparent; font-weight: 500; }
.vote-voted   { color: #475569; background: #e2e8f0; }

.status {
  min-width: 7ch;
  padding-inline: 0.8rem;
  color: #475569;
  background: #e2e8f0;
}

.status_accept { color: #166534; background: #bbf7d0; }
.status_reject { color: #991b1b; background: #fecaca; }
.status_defer  { color: #854d0e; background: #fef08a; }
.status_nsu    { color: #1e40af; background: #bfdbfe; }

/* ---------- Review button ---------- */

.dashboard .cell-action,
.dashboard .col-action {
  width: 1%;
  white-space: nowrap;
}

.dashboard form.button_to {
  margin: 0;
}

.review-btn {
  display: block;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  background: var(--db-accent);
  border: 0;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

.review-btn:hover {
  background: #1d4ed8;
}

.review-btn:active {
  transform: translateY(1px);
}

.review-btn:focus-visible {
  outline: 2px solid var(--db-accent);
  outline-offset: 2px;
}

/* ---------- Footer summary ---------- */

.dashboard-summary {
  margin: 0.9rem 0.25rem 0;
  color: var(--db-muted);
  font-size: 0.9rem;
}

/* ---------- Phone: each report becomes a card ---------- */

@media (max-width: 650px) {
  .dashboard {
    width: min(100% - 1rem, 40rem);
    margin-top: 0.75rem;
  }

  .dashboard-status {
    padding: 0.75rem 1rem;
  }

  .dashboard-right-group {
    margin-left: auto;
  }

  /* Cards supply their own surface; drop the outer table card. */
  .table-scroll {
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .dashboard table,
  .dashboard tbody {
    display: block;
  }

  .dashboard thead {
    display: none;
  }

  .dashboard tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    padding: 0.4rem 0;
    background: #fff;
    border: 1px solid var(--db-line);
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
  }

  .dashboard tbody tr:nth-of-type(even),
  .dashboard tbody tr:hover {
    background: #fff;
  }

  /* Label and value sit side by side; the fixed label width keeps the
     values lined up in a column just right of the labels. */
  .dashboard td {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem;
    text-align: left;
    border-bottom: 0;
  }

  .dashboard td::before {
    content: attr(data-cell);
    flex: 0 0 4.5rem;
    color: var(--db-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* Id, bird name, date and town flow on one line when they fit and wrap
     item by item when they don't. Every other cell takes a full row. The
     row supplies the side padding so wrapped items line up at the left. */
  .dashboard tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.6rem;
    padding: 0.4rem 1rem;
  }

  .dashboard tbody td {
    flex: 0 0 100%;
    padding-left: 0;
    padding-right: 0;
  }

  .dashboard td.cell-id,
  .dashboard td.cell-bird {
    display: block;
    padding-top: 0.6rem;
    font-size: 1.1rem;
    text-align: left;
  }

  .dashboard td.cell-date,
  .dashboard td.cell-town {
    display: block;
  }

  .dashboard td.cell-id,
  .dashboard td.cell-bird,
  .dashboard td.cell-date,
  .dashboard td.cell-town {
    flex: 0 1 auto;
    width: auto;
  }

  .dashboard td.cell-id {
    color: var(--db-muted);
  }

  .dashboard td.cell-id::before,
  .dashboard td.cell-bird::before,
  .dashboard td.cell-date::before,
  .dashboard td.cell-town::before {
    content: none;
  }

  .dashboard td.cell-action {
    display: block;
    width: auto;
    padding: 0.6rem 0 0.5rem;
  }

  .dashboard td.cell-action::before {
    content: none;
  }

  .dashboard td.cell-action form,
  .dashboard .cell-action .review-btn {
    width: 100%;
  }

  .review-btn {
    padding: 0.65rem 1rem;
    font-size: 1rem;
  }
}
