/* Components: cards, badges, review queue, tables, detail page, dialogs, toasts. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card > h2:first-child { margin-top: 0; }
details > summary { cursor: pointer; font-weight: 600; padding: .15rem 0; }
details[open] > summary { margin-bottom: .5rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }
.loading { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.spinner {
  width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon { display: inline-block; line-height: 1; }
.plain { list-style: none; padding: 0; margin: 0 0 .75rem; }
.plain li { margin-bottom: .35rem; }
.inline-list { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: 0; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: .75rem 0; }
.toolbar .search-wrap { flex: 1; min-width: 12rem; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: .2rem;
  font-size: .75rem; font-weight: 650; letter-spacing: .01em;
  padding: .1rem .5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent; vertical-align: middle;
}
.badge-muted { background: var(--surface-2); color: var(--muted); }
.decision-pending { background: var(--warn-bg); color: var(--warn); border: 1px dashed var(--onsale-border); }
.decision-approved { background: var(--ok-bg); color: var(--ok); }
.decision-rejected { background: var(--bad-bg); color: var(--bad); }
.decision-excluded { background: var(--surface-2); color: var(--muted); }
.status-on_sale, .status-ok { background: var(--ok-bg); color: var(--ok); }
.status-sold_out, .status-cancelled, .status-error { background: var(--bad-bg); color: var(--bad); }
.status-postponed, .status-rescheduled { background: var(--warn-bg); color: var(--warn); }
.status-announced { background: var(--accent-soft); color: var(--text); }
.badge-tracked { background: var(--onsale-bg); color: var(--onsale-fg); border-color: var(--onsale-border); }
.kind-badge-onsale { background: var(--onsale-bg); color: var(--onsale-fg); }
.kind-badge-presale { background: var(--presale-bg); color: var(--presale-fg); }
.kind-badge-event { background: var(--event-bg); color: var(--event-fg); }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; }

.chip-list { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: 0 0 .75rem; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: .25rem .75rem; cursor: pointer; font-size: .88rem; }
.chip:hover { background: var(--accent-soft); }
.review-groups .chip[aria-pressed="true"],
.review-groups .chip[aria-pressed="mixed"] { background: var(--accent-soft); border-color: var(--accent); }
.review-groups .chip[aria-pressed="true"] { font-weight: 700; }
.review-groups .chip[aria-pressed="mixed"] { border-style: dashed; }
.review-filters { display: block; }
.review-filters .filter-grid { margin-top: .5rem; align-items: end; }

/* filter bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-start; margin: .5rem 0 1rem; }
.filter-bar .search-wrap { flex: 1 1 18rem; }
.filter-more { flex: 1 1 100%; }
.filter-more > summary { font-size: .92rem; color: var(--muted); }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .5rem; align-items: center; }
.filter select { min-height: 2.3rem; padding: .3rem .5rem; }

/* review queue */
.review-list { display: flex; flex-direction: column; gap: 1rem; }
.review-card {
  display: grid; grid-template-columns: auto 9rem 1fr; gap: 1rem; margin: 0;
  scroll-margin-top: 8rem; outline: none; transition: border-color .15s;
}
.review-card.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.review-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.review-card.is-selected { background: var(--accent-soft); }
.review-card.is-fav-source { border-left: 5px solid var(--tracked); }
.fav-source-flag { color: var(--tracked); font-size: .82rem; font-weight: 650; margin: 0 0 .2rem; }
.review-select { padding-top: .2rem; }
.review-select input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.review-img { width: 9rem; height: 9rem; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.review-img.placeholder { display: grid; place-items: center; font-size: 2rem; opacity: .6; }
.review-title { font-size: 1.15rem; margin-bottom: .2rem; }
.review-title a { color: var(--text); text-decoration: none; }
.review-title a:hover { text-decoration: underline; }
.performers { font-weight: 600; margin-bottom: .2rem; }
.meta { color: var(--muted); margin-bottom: .2rem; font-size: .93rem; }
.why { background: var(--warn-bg); color: var(--warn); display: inline-block; padding: .2rem .6rem; border-radius: var(--radius-sm); font-size: .9rem; }
.why-label { font-weight: 650; }
.desc { font-size: .92rem; color: var(--muted); max-width: 75ch; }
.review-actions { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: flex-start; margin-top: .5rem; }
.decision-controls { display: flex; flex-direction: column; gap: .5rem; }
.remember-row { font-size: .88rem; }
.remember-label { color: var(--muted); font-size: .85rem; }
.ticket-line { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .9rem; margin-bottom: .3rem; }
.ticket-onsale { color: var(--onsale-fg); background: var(--onsale-bg); padding: .05rem .45rem; border-radius: var(--radius-sm); }
.ticket-presale { color: var(--presale-fg); background: var(--presale-bg); padding: .05rem .45rem; border-radius: var(--radius-sm); }

.bulk-bar {
  position: sticky; top: 6.5rem; z-index: 10;
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius);
  padding: .5rem .75rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.bulk-count { font-weight: 650; margin-right: .5rem; }
.excluded { margin-top: 2rem; }
.excluded-list { list-style: none; padding: 0; margin: 0; }
.excluded-list li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .5rem 0; border-top: 1px solid var(--border); }

@media (max-width: 700px) {
  .review-card { grid-template-columns: auto 1fr; }
  .review-img { grid-column: 2; width: 100%; height: 10rem; }
  .review-img.placeholder { display: none; }
  .review-body { grid-column: 1 / -1; }
  .bulk-bar { top: 7.5rem; }
}

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { text-align: left; vertical-align: top; padding: .55rem .6rem; border-bottom: 1px solid var(--border); }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tbody tr:hover { background: var(--surface-2); }
.row-failing td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.row-inactive { opacity: .8; }
.error-text { color: var(--bad); font-size: .85rem; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }
.pref-favourite { border-color: var(--tracked); }
.pref-rejected { border-color: var(--bad); }

/* stacked tables on phones */
@media (max-width: 700px) {
  .events-table thead, .sources-table thead, .table-wrap .table thead { display: none; }
  .table-wrap .table, .table-wrap .table tbody, .table-wrap .table tr, .table-wrap .table td { display: block; width: 100%; }
  .table-wrap .table tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; padding: .4rem .2rem; background: var(--surface); }
  .table-wrap .table td { border: 0; padding: .3rem .6rem; }
  .table-wrap .table td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
}

/* event detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 1rem; align-items: start; }
.detail-img { width: 100%; max-height: 22rem; object-fit: cover; border-radius: var(--radius); margin-bottom: 1rem; }
.detail-actions h2.small-head, .small-head { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 1rem 0 .4rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 .75rem; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; }
.description { white-space: pre-line; max-width: 75ch; border-top: 1px solid var(--border); padding-top: .75rem; }
.occ-list, .rem-list, .digest-events, .digest-list, .outbox { list-style: none; padding: 0; margin: 0; }
.occ-list li, .rem-list li { display: flex; justify-content: space-between; gap: .75rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.occ-list li:last-child, .rem-list li:last-child { border-bottom: 0; }
.rem-cancelled, .rem-sent { opacity: .7; }
.tickets-box { border-top: 4px solid var(--onsale-border); }
.ticket-row { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; padding: .6rem .75rem; border-radius: var(--radius-sm); margin-bottom: .5rem; }
.ticket-row.kind-onsale { background: var(--onsale-bg); color: var(--onsale-fg); }
.ticket-row.kind-presale { background: var(--presale-bg); color: var(--presale-fg); }
.ticket-row a { color: inherit; }
.add-to-cal .btn { flex: 1 1 auto; }
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { order: -1; }
}

/* event form */
.event-form { max-width: 52rem; }
.occ-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0 .75rem; align-items: end; border-style: dashed; }
.tickets-fieldset { border-color: var(--onsale-border); }

/* digest */
.digest-section { margin-top: 1rem; }
.digest-section h3 { border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.digest-events li, .digest-list li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.digest-events li:last-child, .digest-list li:last-child { border-bottom: 0; }
.digest-summary { margin: 0 0 1rem; padding: .75rem 1rem; border-left: 4px solid var(--accent); background: var(--surface); white-space: pre-line; }

/* outbox */
.outbox li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.outbox-body { background: var(--surface-2); padding: .5rem; border-radius: var(--radius-sm); margin-top: .35rem; font-size: .85rem; max-height: 12rem; overflow: auto; }

/* dialog */
.dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0;
  width: min(32rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem);
  background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgb(0 0 0 / 30%);
}
.dialog-wide { width: min(46rem, calc(100vw - 2rem)); }
.dialog::backdrop { background: rgb(10 5 25 / 55%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; }
.dialog-body { padding: 1rem; overflow: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--border); }
.feed-url { display: block; word-break: break-all; background: var(--surface-2); padding: .5rem; border-radius: var(--radius-sm); }

/* toasts */
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .5rem; width: min(34rem, calc(100vw - 2rem)); }
.toast {
  display: flex; align-items: center; gap: .75rem;
  background: var(--text); color: var(--bg); padding: .7rem 1rem; border-radius: var(--radius);
  box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
}
.toast-msg { flex: 1; }
.toast-success { border-left: 5px solid #22c55e; }
.toast-error { border-left: 5px solid #ef4444; }
.toast-close { background: none; border: 0; color: inherit; font-size: 1.3rem; cursor: pointer; line-height: 1; }
.toast .btn { color: var(--text); }
