/*
 * components.css — six .rp-* DSGN-03 components + rehomed .rp-badge.
 *
 * Purpose: DSGN-03 (reusable component library: buttons, inputs, cards,
 * tactical chips, data tables, status indicators — 8px radii, 1px borders,
 * tonal-layer elevation) and D-05 (semantic rp-prefixed BEM-ish classes).
 * References tokens.css var(--rp-*) exclusively, except the two documented
 * rgba() bronze values (chip background + pulse box-shadow) — DSGN-04.
 *
 * Cascade order (must match base.html <link> order):
 *   tokens.css -> base.css -> components.css
 */

/* ---------------------------------------------------------------------
 * Buttons
 * --------------------------------------------------------------------- */
.rp-btn {
  display: inline-block;
  font-family: var(--rp-font-sans);
  font-weight: 600;
  font-size: var(--rp-body-md-size);
  line-height: var(--rp-body-md-lh);
  border-radius: var(--rp-radius); /* 8px, never var(--rp-radius-full) */
  border: 1px solid transparent;
  padding: var(--rp-space-sm) var(--rp-space-md);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.rp-btn--primary {
  background: var(--rp-primary);
  color: var(--rp-on-primary);
}

.rp-btn--primary:hover {
  background: var(--rp-primary-container);
}

.rp-btn--secondary {
  background: transparent;
  color: var(--rp-primary);
  border-color: var(--rp-primary);
}

.rp-btn--secondary:hover {
  background: var(--rp-surface-container-high);
}

.rp-btn:focus-visible {
  outline: 2px solid var(--rp-primary);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
 * Input
 * --------------------------------------------------------------------- */
.rp-input {
  background: var(--rp-surface);
  color: var(--rp-on-surface);
  font-family: var(--rp-font-sans);
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius); /* 8px */
  padding: var(--rp-space-sm) var(--rp-space-md);
  transition: border-color 0.15s ease;
}

.rp-input:focus,
.rp-input:active {
  border-color: var(--rp-primary);
}

.rp-input:focus-visible {
  outline: 2px solid var(--rp-primary);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
 * Card
 * --------------------------------------------------------------------- */
.rp-card {
  background: var(--rp-surface-container-low); /* L1 tonal surface */
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius-xl); /* 16px for major containers */
}

.rp-card__header {
  border-bottom: 1px solid var(--rp-outline-variant);
  padding: var(--rp-space-md);
}

/* ---------------------------------------------------------------------
 * Tactical chip
 * --------------------------------------------------------------------- */
.rp-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--rp-font-mono);
  font-size: var(--rp-mono-label-size);
  font-weight: var(--rp-mono-label-weight);
  line-height: var(--rp-mono-label-lh);
  letter-spacing: var(--rp-mono-label-ls);
  border-radius: var(--rp-radius-sm); /* 4px */
  padding: 2px var(--rp-space-sm);
  background: rgba(238, 189, 142, 0.1); /* 10% bronze (--rp-primary) — documented rgba exception */
  color: var(--rp-primary);
}

/* ---------------------------------------------------------------------
 * Data table
 * --------------------------------------------------------------------- */
.rp-table {
  border-collapse: collapse;
  width: 100%;
}

.rp-table-wrap {
  overflow-x: auto;
  width: 100%;
}

.rp-table th,
.rp-table td {
  padding: var(--rp-space-sm);
  text-align: left;
  border-bottom: 1px solid var(--rp-surface-container-high); /* horizontal-only divider, no vertical lines */
}

.rp-table th.rp-table__num,
.rp-table td.rp-table__num,
.rp-table td[data-mono] {
  font-family: var(--rp-font-mono);
  font-size: var(--rp-mono-data-size);
  text-align: left;
}

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

/* ---------------------------------------------------------------------
 * Shared filter controls
 * --------------------------------------------------------------------- */
.rp-filter-control {
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  color: var(--rp-ref-text);
  background: var(--rp-ref-search-surface);
  border: 1px solid var(--rp-ref-search-border);
  border-radius: 7px;
  outline: 0;
  font-family: var(--rp-font-sans);
  font-size: var(--rp-body-md-size);
  line-height: var(--rp-body-md-lh);
}

.rp-filter-control:focus,
.rp-filter-control:focus-within {
  border-color: var(--rp-ref-bronze);
}

.rp-filter-control::placeholder,
.rp-filter-control__input::placeholder {
  color: var(--rp-ref-search-placeholder);
}

.rp-filter-control__input {
  min-width: 0;
  width: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: 0;
  font: inherit;
}

.rp-filter-control__input:focus,
.rp-filter-control__input:focus-visible,
.rp-filter-control__input:active {
  border-color: transparent;
  outline: 0;
  box-shadow: none;
}

.rp-filter-action {
  height: 40px;
  white-space: nowrap;
}

.rp-members-page {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.rp-members-page__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.rp-members-page__filters {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin: 0;
  width: 100%;
}

.rp-members-page__search {
  width: min(280px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
}

.rp-members-page__search svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: var(--rp-ref-muted);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.rp-members-page__search input {
  flex: 1 1 auto;
}

.rp-members-page__select {
  min-width: 132px;
}

.rp-members-page__power-input {
  width: 136px;
}

.rp-members-panel {
  overflow: hidden;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--rp-ref-surface), var(--rp-surface));
  border: 1px solid var(--rp-ref-border);
  border-radius: 16px;
}

.rp-members-panel .rp-table-wrap {
  overflow-x: auto;
  flex: 0 0 auto;
}

.rp-members-table {
  min-width: 1100px;
  color: var(--rp-ref-text);
  border-collapse: collapse;
}

.rp-villages-table {
  min-width: 1480px;
}

.rp-reports-table {
  min-width: 900px;
}

.rp-reports-filters {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) auto auto;
  grid-template-rows: repeat(2, 40px);
  flex: 0 0 auto;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--rp-ref-border);
}

.rp-reports-filters__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 680px;
}

.rp-reports-filters__row--defender {
  grid-column: 1;
  grid-row: 1;
}

.rp-reports-filters__row--attacker {
  grid-column: 1;
  grid-row: 2;
}

.rp-reports-filters input {
  width: 100%;
}

.rp-reports-filters input[type="datetime-local"] {
  color-scheme: dark;
}

.rp-reports-filters__date {
  display: contents;
  color: var(--rp-ref-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.rp-reports-filters__date span {
  width: 48px;
  text-align: right;
}

.rp-reports-filters__apply,
.rp-reports-filters__clear {
  height: 40px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.rp-reports-filters__apply {
  grid-column: 2;
  grid-row: 1 / 3;
  height: auto;
  align-self: stretch;
  padding-inline: 16px;
}

.rp-reports-filters__clear {
  display: inline-flex;
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  align-items: center;
  padding: 0 6px;
  color: var(--rp-ref-muted);
  text-decoration: none;
}

.rp-reports-filters__clear:hover {
  color: var(--rp-ref-heading);
  text-decoration: none;
}

.rp-reports-table__row {
  cursor: pointer;
}

.rp-reports-table__row:hover,
.rp-reports-table__row:focus-visible {
  background: color-mix(in srgb, var(--rp-ref-bronze) 8%, transparent);
  outline: none;
}

.rp-reports-table__alliance,
.rp-reports-table__alliance:hover {
  text-decoration: none;
}

.rp-reports-table__operation {
  min-width: 180px;
}

.rp-report-operation__body {
  padding: 16px;
}

.rp-report-operation__select {
  width: 100%;
  height: 40px;
  padding: 0 32px 0 10px;
  color: var(--rp-ref-text);
  background: var(--rp-ref-search-surface);
  border: 1px solid var(--rp-ref-search-border);
  border-radius: 7px;
}

.rp-report-operation__select:focus {
  border-color: var(--rp-ref-bronze);
  outline: none;
}

.rp-report-operation__select:disabled {
  cursor: wait;
  opacity: 0.7;
}

.rp-report-operation__status {
  display: block;
  min-height: 14px;
  margin-top: 5px;
  color: var(--rp-ref-muted);
  font-size: 11px;
  line-height: 1.2;
}

.rp-report-operation__status.is-error {
  color: var(--rp-error);
}

.rp-reports-table__timestamp,
.rp-report-time {
  white-space: nowrap;
  font-family: var(--rp-font-mono);
}

.rp-report-shell {
  overflow: hidden;
  background: linear-gradient(180deg, var(--rp-ref-surface), var(--rp-surface));
  border: 1px solid var(--rp-ref-border);
  border-radius: 16px;
}

.rp-report-topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
}

.rp-report-back {
  display: inline-block;
  margin-bottom: 22px;
  color: var(--rp-ref-bronze-bright);
  text-decoration: none;
}

.rp-report-back:hover,
.rp-report-back:focus-visible {
  text-decoration: underline;
}

.rp-report-title-row {
  display: flex;
  align-items: center;
  gap: 18px;
}

.rp-report-title-row h1 {
  margin: 0;
  color: var(--rp-ref-heading);
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  letter-spacing: .025em;
}

.rp-report-title-icon {
  color: var(--rp-ref-bronze-bright);
  font-size: 2.75rem;
  line-height: 1;
}

.rp-report-subject,
.rp-report-section__identity {
  margin: 8px 0 0;
  color: var(--rp-ref-muted);
}

.rp-report-game-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.rp-report-game-link:hover,
.rp-report-game-link:focus-visible {
  color: var(--rp-ref-bronze-bright);
  border-bottom-color: currentColor;
}

.rp-report-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: 150px;
  padding: 24px 40px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--rp-error) 15%, transparent), transparent 42%),
    linear-gradient(270deg, color-mix(in srgb, var(--rp-tertiary) 13%, transparent), transparent 42%),
    var(--rp-surface-container-low);
  border-block: 1px solid var(--rp-ref-border);
}

.rp-report-hero__party h2,
.rp-report-hero__party p,
.rp-report-section h2 {
  margin: 0;
}

.rp-report-hero__party h2 {
  margin-top: 10px;
  color: var(--rp-ref-heading);
  font-size: 1.2rem;
}

.rp-report-hero__party h2 + p {
  margin-top: 6px;
  color: var(--rp-ref-muted);
}

.rp-report-hero__party--defender {
  text-align: right;
}

.rp-report-hero__role {
  color: var(--rp-error);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.rp-report-hero__party--defender .rp-report-hero__role {
  color: var(--rp-tertiary);
}

.rp-report-emblem {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  color: var(--rp-ref-heading);
  background: var(--rp-surface-container-high);
  border: 2px solid var(--rp-ref-bronze);
  border-radius: 50%;
  box-shadow: 0 8px 28px color-mix(in srgb, var(--rp-shadow) 70%, transparent);
  font-size: 2rem;
}

.rp-report-content {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(310px, 1fr);
  gap: 18px;
  padding: 18px;
}

.rp-report-content__troops,
.rp-report-content__details {
  min-width: 0;
}

.rp-report-section {
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--rp-surface-container-low);
  border: 1px solid var(--rp-ref-border);
  border-radius: 10px;
}

.rp-report-section > header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rp-ref-border);
}

.rp-report-section > header h2 {
  color: var(--rp-ref-bronze-bright);
  font-size: 14px;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.rp-report-section--attacker > header h2 {
  color: var(--rp-error);
}

.rp-report-section--defender > header h2 {
  color: var(--rp-tertiary);
}

.rp-report-information article {
  padding: 16px;
}

.rp-report-information article + article {
  border-top: 1px solid var(--rp-ref-border);
}

.rp-report-information h3 {
  margin: 0 0 10px;
  color: var(--rp-ref-bronze-bright);
}

.rp-report-information__item {
  display: grid;
  grid-template-columns: minmax(100px, 140px) 1fr;
  gap: 12px;
}

.rp-report-information__item + .rp-report-information__item {
  margin-top: 10px;
}

.rp-report-information__item p {
  margin: 0;
}

.rp-report-troops {
  width: 100%;
  min-width: 520px;
  table-layout: auto;
}

.rp-report-troops th,
.rp-report-troops td {
  padding: 6px 7px;
  white-space: nowrap;
}

.rp-report-troops th:first-child,
.rp-report-troops td:first-child {
  width: 32px;
  min-width: 32px;
  text-align: center;
}

.rp-report-troops th:not(:first-child),
.rp-report-troops td:not(:first-child) {
  width: calc((100% - 32px) / 11);
  min-width: 38px;
}

.rp-report-troop-icon,
.rp-report-line-icon {
  display: block;
  margin: 0 auto;
  object-fit: contain;
}

.rp-report-troop-icon {
  width: 16px;
  height: 16px;
}

.rp-report-line-icon {
  width: auto;
  height: 16px;
}

.rp-report-troops th:not(:first-child),
.rp-report-troops td:not(:first-child) {
  text-align: center;
  font-family: var(--rp-font-mono);
}

.rp-report-statistics td {
  text-align: right;
  font-family: var(--rp-font-mono);
}

@media (max-width: 1040px) {
  .rp-report-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .rp-report-topbar {
    align-items: start;
    flex-direction: column;
    padding: 20px;
  }

  .rp-report-hero {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 24px 20px;
  }

  .rp-report-emblem {
    display: none;
  }

  .rp-report-hero__party--defender {
    text-align: left;
  }

  .rp-report-content {
    padding: 12px;
  }

  .rp-report-information__item {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.rp-villages-table__coord {
  white-space: nowrap;
  font-family: var(--rp-font-mono);
}

.rp-villages-page__coords {
  width: 166px;
}

.rp-villages-page__distance {
  width: 142px;
}

.rp-villages-page__apply {
  min-width: 126px;
}

.rp-villages-table__note {
  min-width: 180px;
  max-width: 280px;
  color: var(--rp-ref-muted);
}

.rp-villages-table__tags {
  min-width: 240px;
}

.rp-members-table th,
.rp-members-table td,
.rp-members-table th.rp-table__num,
.rp-members-table td.rp-table__num,
.rp-members-table td[data-mono] {
  text-align: center;
}

.rp-members-table th {
  padding: 10px 12px;
  color: var(--rp-ref-bronze-bright);
  border-bottom: 1px solid var(--rp-ref-border);
  font-family: var(--rp-font-sans);
  font-size: var(--rp-mono-label-size);
  font-weight: 700;
  letter-spacing: var(--rp-mono-label-ls);
  line-height: var(--rp-mono-label-lh);
  text-align: center;
  vertical-align: middle;
  text-transform: uppercase;
}

.rp-members-table th a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}

.rp-members-table th a:hover {
  color: var(--rp-ref-bronze-bright);
}

.rp-members-table__sort-icon {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  stroke-width: 2.4;
}

.rp-members-table td {
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rp-ref-border-soft);
  color: var(--rp-ref-text);
  font-size: 14px;
  vertical-align: middle;
}

.rp-members-table__last-update {
  min-width: 142px;
  white-space: nowrap;
}

.rp-members-table tbody tr:last-child td {
  border-bottom: 0;
}

.rp-members-table tbody tr:hover {
  background: rgb(238 189 142 / 4%);
}

.rp-members-table__tribe-cell {
  width: 84px;
}

.rp-members-table__tribe-icon {
  width: auto;
  height: 26px;
  margin: 0 auto;
  display: block;
  image-rendering: auto;
}

.rp-members-table__tribe-fallback {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  color: var(--rp-ref-muted);
  border: 1px solid var(--rp-ref-search-border);
  border-radius: 50%;
  font-family: var(--rp-ref-display-font);
  font-size: 16px;
  font-weight: 700;
}

.rp-members-table__account {
  color: var(--rp-ref-bronze-bright);
  text-decoration: none;
}

.rp-members-table__account:hover {
  color: var(--rp-primary-fixed);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.rp-members-table .rp-badge {
  padding: 3px 10px;
  color: var(--rp-ref-heading);
  background: var(--rp-ref-search-surface);
  border-color: var(--rp-ref-search-border);
  font-family: var(--rp-ref-ui-font);
  font-size: 12px;
  line-height: 16px;
}

.rp-members-table__classification form {
  margin: 0;
}

.rp-members-table__classification-button {
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.rp-members-table__classification-button:focus-visible {
  outline: 2px solid var(--rp-primary);
  outline-offset: 3px;
}

.rp-members-table__note {
  min-width: 176px;
}

.rp-members-table__note form {
  display: grid;
  gap: var(--rp-space-xs);
  justify-items: center;
  margin: 0;
}

.rp-members-table__note-input {
  width: 100%;
  min-height: 32px;
  resize: vertical;
  color: var(--rp-ref-text);
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
}

.rp-members-panel > p,
.rp-members-panel > section {
  margin: 0;
  padding: 28px 32px;
  color: var(--rp-ref-muted);
}

.rp-members-panel > section h2 {
  margin: 0 0 8px;
  color: var(--rp-ref-heading);
  font-family: var(--rp-ref-display-font);
  font-size: 24px;
}

.rp-members-pagination {
  min-height: 58px;
  margin-top: auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--rp-ref-muted);
  border-top: 1px solid var(--rp-ref-border);
}

.rp-members-pagination p {
  margin: 0;
  font-size: 14px;
}

.rp-members-pagination nav {
  display: flex;
  gap: 10px;
}

.rp-members-pagination a,
.rp-members-pagination span {
  min-width: 88px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--rp-ref-heading);
  border: 1px solid var(--rp-ref-search-border);
  border-radius: 8px;
  text-decoration: none;
}

.rp-members-pagination span {
  color: var(--rp-ref-muted);
  opacity: .55;
}

@media (max-width: 900px) {
  .rp-members-page__toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .rp-members-page__filters {
    flex-wrap: wrap;
  }

  .rp-members-page__filters,
  .rp-members-page__search,
  .rp-members-page__select,
  .rp-members-page__power-input {
    width: 100%;
  }

  .rp-members-pagination {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }
}

.rp-table tfoot th,
.rp-table tfoot td {
  font-weight: 600;
}

/* ---------------------------------------------------------------------
 * Status dot (accessible pulse — WCAG 2.3.3 / vestibular safety, T-08-04)
 * --------------------------------------------------------------------- */
.rp-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--rp-radius-full);
  background: var(--rp-outline); /* idle */
}

.rp-status-dot--active {
  background: var(--rp-primary);
}

.rp-status-dot--priority {
  background: var(--rp-error);
}

.rp-status-dot--active,
.rp-status-dot--priority {
  animation: rp-pulse 1.6s ease-out infinite;
}

@keyframes rp-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(238, 189, 142, 0.5); /* --rp-primary @ 50% — documented rgba exception */
  }
  70% {
    box-shadow: 0 0 0 6px rgba(238, 189, 142, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(238, 189, 142, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rp-status-dot--active,
  .rp-status-dot--priority {
    animation: none;
  }
}

/* ---------------------------------------------------------------------
 * Badge (rehomed from base.html:29-35 — VERIFIED consumer:
 * collection_health.html:23,28)
 * --------------------------------------------------------------------- */
.rp-badge {
  display: inline-block;
  border: 1px solid var(--rp-outline-variant);
  color: var(--rp-on-surface-variant);
  border-radius: var(--rp-radius-sm); /* 4px */
  padding: 2px var(--rp-space-sm);
  font-family: var(--rp-font-mono);
  font-size: var(--rp-mono-label-size);
}

/* ---------------------------------------------------------------------
 * Village tags cell — a searchable multi-select combobox (native <details>)
 * with removable chips, a checkbox option list, and "Create new tag". Auto
 * tags (arti / cata point) render as read-only chips alongside manual ones.
 * --------------------------------------------------------------------- */
.rp-village-tags {
  display: block;
}

.rp-village-tags__badges {
  display: inline-flex;
  align-items: center;
  gap: var(--rp-space-xs);
  flex-wrap: wrap;
}

.rp-tag-select {
  position: relative;
  display: block;
}

.rp-tag-select__control {
  display: flex;
  align-items: center;
  gap: var(--rp-space-xs);
  min-height: 34px;
  padding: var(--rp-space-xs) var(--rp-space-sm);
  background: var(--rp-surface-container);
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius-sm);
  cursor: pointer;
  list-style: none;
}

.rp-tag-select__control::-webkit-details-marker {
  display: none;
}

.rp-tag-select[open] .rp-tag-select__control {
  border-color: var(--rp-primary);
}

.rp-tag-select__chips {
  display: flex;
  align-items: center;
  gap: var(--rp-space-xs);
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

.rp-tag-select__placeholder {
  color: var(--rp-on-surface-variant);
  font-size: var(--rp-mono-label-size);
}

.rp-tag-select__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--rp-space-xs);
  padding: 2px var(--rp-space-sm);
  background: var(--rp-surface-container-highest);
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius-sm);
  color: var(--rp-on-surface);
  font-family: var(--rp-font-mono);
  font-size: var(--rp-mono-label-size);
  white-space: nowrap;
}

.rp-tag-select__chip--auto {
  color: var(--rp-on-surface-variant);
  border-style: dashed;
}

.rp-tag-select__chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--rp-on-surface-variant);
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
}

.rp-tag-select__chip-remove:hover {
  color: var(--rp-on-surface);
}

.rp-tag-select__chevron {
  flex: 0 0 auto;
  color: var(--rp-on-surface-variant);
  transition: transform 0.15s ease;
}

.rp-tag-select[open] .rp-tag-select__chevron {
  transform: rotate(180deg);
}

.rp-tag-select__panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  padding: var(--rp-space-sm);
  background: var(--rp-surface);
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius-sm);
  box-shadow: var(--rp-shadow-1);
}

.rp-tag-select__options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--rp-space-xs) var(--rp-space-sm);
}

.rp-tag-select__option {
  display: flex;
  align-items: center;
  gap: var(--rp-space-xs);
  font-size: var(--rp-mono-label-size);
  white-space: nowrap;
  cursor: pointer;
}

.rp-tag-select__option--auto {
  color: var(--rp-on-surface-variant);
  font-style: italic;
  cursor: default;
}

/* ---------------------------------------------------------------------
 * Troops Overview (Phase 30 — VISL-01/03, dark bronze/serif visual table)
 *
 * Scoped `.rp-troops-overview*` block. Token-only colors (no raw hex),
 * a compact horizontally scrollable table (824px min-width) with native
 * 16px local icon headers, and strong dividers before the Total and Ts
 * columns only.
 * --------------------------------------------------------------------- */
.rp-troops-overview {
  background: var(--rp-ref-surface);
  border: 1px solid var(--rp-ref-bronze);
  border-radius: var(--rp-radius);
  padding: var(--rp-space-lg);
}

.rp-troops-overview__scroll {
  overflow-x: auto;
  width: 100%;
}

.rp-troops-overview__scroll:focus-visible {
  outline: 2px solid var(--rp-ref-bronze-bright);
  outline-offset: 2px;
}

.rp-troops-overview__table {
  min-width: 824px;
  width: auto;
  table-layout: fixed;
  border-collapse: collapse;
  font-family: var(--rp-display-font);
  color: var(--rp-ref-text);
}

.rp-troops-overview__table th,
.rp-troops-overview__table td {
  padding: 4px var(--rp-space-sm);
  border-bottom: 1px solid var(--rp-ref-border-soft);
  text-align: left;
}

.rp-troops-overview__table thead th {
  color: var(--rp-ref-heading);
  font-weight: 600;
}

.rp-troops-overview__village-header,
.rp-troops-overview__village {
  width: 128px;
}

.rp-troops-overview__village-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.rp-troops-overview__village-link:hover,
.rp-troops-overview__village-link:focus-visible {
  border-bottom-color: var(--rp-ref-bronze-bright);
}

.rp-troops-overview__troop-header {
  width: 56px;
  height: 25px;
  padding-left: 2px;
  padding-right: 2px;
  text-align: center;
}

.rp-troops-overview__num {
  width: 56px;
  height: 25px;
  padding-left: 2px;
  padding-right: 2px;
  text-align: center;
  font-size: var(--rp-body-md-size);
  font-variant-numeric: tabular-nums lining-nums;
}

.rp-troops-overview__num.rp-troops-overview__total {
  width: 80px;
  text-align: center;
}

.rp-troops-overview__num.rp-troops-overview__ts,
.rp-troops-overview__num.rp-troops-overview__treasury {
  width: 56px;
  text-align: center;
}

.rp-troops-overview__icon {
  width: 16px;
  height: 16px;
  display: inline-block;
}

.rp-troops-overview__building-icon {
  image-rendering: auto;
}

.rp-troops-overview__ts-form,
.rp-troops-overview__treasury-form {
  display: flex;
  justify-content: center;
  margin: 0;
}

.rp-troops-overview__ts-input,
.rp-troops-overview__treasury-input {
  width: 28px;
  height: 21px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--rp-ref-text);
  font: inherit;
  font-variant-numeric: tabular-nums lining-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.rp-troops-overview__ts-input::-webkit-outer-spin-button,
.rp-troops-overview__ts-input::-webkit-inner-spin-button,
.rp-troops-overview__treasury-input::-webkit-outer-spin-button,
.rp-troops-overview__treasury-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rp-troops-overview__ts-input:focus,
.rp-troops-overview__treasury-input:focus {
  border-color: var(--rp-ref-crest-border);
  background: var(--rp-ref-surface-raised);
  outline: none;
}

.rp-troops-overview__ts-input.is-saved,
.rp-troops-overview__treasury-input.is-saved {
  border-color: var(--rp-ref-success);
  background: color-mix(in srgb, var(--rp-ref-success) 18%, transparent);
}

.rp-troops-overview__ts-input.is-error,
.rp-troops-overview__treasury-input.is-error {
  border-color: var(--rp-ref-danger);
  background: color-mix(in srgb, var(--rp-ref-danger) 18%, transparent);
}

/* ---------------------------------------------------------------------
 * Push Calls (quick slice — workspace-scoped browser state)
 * --------------------------------------------------------------------- */
.rp-push-calls {
  min-height: 100%;
  color: var(--rp-ref-heading);
  font-family: var(--rp-display-font);
}

.rp-push-calls__card {
  background: linear-gradient(180deg, var(--rp-ref-surface), var(--rp-surface));
  border: 1px solid var(--rp-ref-border);
  border-radius: var(--rp-radius);
  overflow: hidden;
}

.rp-push-calls__scroll {
  width: 100%;
  overflow-x: auto;
}

.rp-push-calls__table {
  width: 100%;
  min-width: 900px;
  color: var(--rp-ref-text);
  font-family: var(--rp-font-sans);
  border-collapse: collapse;
}

.rp-push-calls__table th {
  padding: 10px 12px;
  color: var(--rp-ref-bronze-bright);
  border-bottom: 1px solid var(--rp-ref-border);
  font-family: var(--rp-font-sans);
  font-size: var(--rp-mono-label-size);
  font-weight: 700;
  letter-spacing: var(--rp-mono-label-ls);
  line-height: var(--rp-mono-label-lh);
  text-align: center;
  vertical-align: middle;
  text-transform: uppercase;
}

.rp-push-calls__table td {
  height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid var(--rp-ref-border-soft);
  color: var(--rp-ref-text);
  font-size: 14px;
  text-align: center;
  vertical-align: middle;
}

.rp-push-calls__table tbody tr:last-child td {
  border-bottom: 0;
}

.rp-push-calls__table tbody tr:hover {
  background: rgb(238 189 142 / 4%);
}

.rp-push-calls__table tbody tr.rp-push-calls__row--snipe {
  background: rgb(180 40 40 / 14%);
}

.rp-push-calls__table tbody tr.rp-push-calls__row--snipe:hover {
  background: rgb(180 40 40 / 22%);
}

.rp-push-calls__name,
.rp-push-calls__village {
  color: var(--rp-ref-heading);
}

.rp-push-calls__entity-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.rp-push-calls__entity-link:hover,
.rp-push-calls__entity-link:focus-visible {
  color: var(--rp-ref-bronze-bright);
  border-bottom-color: var(--rp-ref-bronze-bright);
}

.rp-push-calls__push-info {
  min-width: 220px;
  margin: 6px auto;
}

.rp-push-calls__push-value {
  display: block;
  margin-bottom: 5px;
  color: var(--rp-ref-text);
  font-size: 14px;
}

.rp-push-calls__progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: var(--rp-radius-full);
  background: var(--rp-surface-bright);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 50%);
}

.rp-push-calls__progress-bar {
  height: 100%;
  border-radius: var(--rp-radius-full);
}

.rp-push-calls__progress-bar.tan {
  background: linear-gradient(90deg, var(--rp-primary-container), var(--rp-primary));
}

.rp-push-calls__progress-bar.green {
  background: linear-gradient(90deg, var(--rp-secondary-fixed-dim), var(--rp-secondary-container));
}

.rp-push-calls__progress-bar.blue {
  background: linear-gradient(90deg, var(--rp-tertiary-fixed-dim), var(--rp-tertiary-container));
}

.rp-push-calls__progress-bar.purple {
  background: linear-gradient(90deg, var(--rp-primary-fixed-dim), var(--rp-on-primary-fixed-variant));
}

.rp-push-calls__progress-bar.orange {
  background: linear-gradient(90deg, var(--rp-primary-container), var(--rp-inverse-primary));
}

.rp-push-calls__coords {
  font-family: var(--rp-font-mono);
  font-size: 14px;
}

.rp-push-calls__link {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--rp-ref-bronze-bright);
  border: 1px solid var(--rp-ref-bronze);
  border-radius: var(--rp-radius);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.rp-push-calls__link svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.rp-push-calls__link:hover {
  background: rgb(238 189 142 / 10%);
  border-color: var(--rp-primary-container);
  transform: translateY(-1px);
}

.rp-push-calls__snipe {
  width: 40px;
  text-align: center;
}

.rp-push-calls__snipe-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--rp-ref-bronze-bright);
}

.rp-push-calls__snipe-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.rp-push-calls__update-action {
  min-width: 72px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--rp-space-md);
  background: transparent;
  color: var(--rp-ref-bronze-bright);
  border: 1px solid var(--rp-ref-bronze);
  border-radius: var(--rp-radius);
  font-family: var(--rp-font-sans);
  font-size: 14px;
  font-weight: 700;
  line-height: var(--rp-body-md-lh);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.rp-push-calls__update-action:hover {
  background: rgb(238 189 142 / 10%);
  border-color: var(--rp-primary-container);
  transform: translateY(-1px);
}

.rp-push-calls__delete-action {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  color: var(--rp-error);
  border: 1px solid var(--rp-outline);
  border-radius: var(--rp-radius);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.rp-push-calls__delete-action svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.rp-push-calls__delete-action:hover {
  background: rgb(255 180 171 / 10%);
  border-color: var(--rp-error);
  transform: translateY(-1px);
}

.rp-push-calls__empty {
  margin: 0;
  padding: var(--rp-space-lg);
  color: var(--rp-ref-muted);
  font-family: var(--rp-font-sans);
}

.rp-dispatch {
  margin-top: var(--rp-space-xl);
}

.rp-dispatch__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--rp-space-md);
  margin-bottom: var(--rp-space-md);
}

.rp-dispatch__title {
  margin: 0;
  font-family: var(--rp-font-mono);
  font-size: 1.05rem;
  color: var(--rp-ref-heading);
}

.rp-dispatch__account-field {
  display: flex;
  flex-direction: column;
  gap: var(--rp-space-xs);
  font-family: var(--rp-font-sans);
  font-size: 0.85rem;
  color: var(--rp-ref-muted);
}

.rp-dispatch__account {
  min-width: 200px;
}

.rp-dispatch__filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rp-space-sm);
  margin-bottom: var(--rp-space-md);
}

.rp-dispatch__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--rp-space-sm);
  flex: 1 1 auto;
}

.rp-dispatch__tag {
  display: inline-flex;
  align-items: center;
  gap: var(--rp-space-xs);
  padding: 4px 8px;
  font-family: var(--rp-font-sans);
  font-size: 0.85rem;
  color: var(--rp-ref-heading);
  background: var(--rp-ref-surface);
  border: 1px solid var(--rp-ref-bronze);
  border-radius: var(--rp-radius);
}

.rp-dispatch__tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--rp-ref-muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease;
}

.rp-dispatch__tag:hover .rp-dispatch__tag-remove,
.rp-dispatch__tag:focus-within .rp-dispatch__tag-remove {
  opacity: 1;
}

.rp-dispatch__tag-remove:hover {
  color: var(--rp-ref-heading);
}

.rp-dispatch__add {
  min-width: 180px;
  flex: 0 0 auto;
}

.rp-dispatch__deff-field {
  display: inline-flex;
  align-items: center;
  gap: var(--rp-space-xs);
  flex: 0 0 auto;
  font-family: var(--rp-font-sans);
  font-size: 0.85rem;
  color: var(--rp-ref-muted);
  white-space: nowrap;
}

.rp-dispatch__deff {
  width: 100px;
}

.rp-dispatch__timer {
  font-family: var(--rp-font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rp-dispatch__impact {
  white-space: nowrap;
}

.rp-dispatch__troops {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--rp-space-sm) var(--rp-space-md);
}

.rp-dispatch__troop {
  display: inline-flex;
  align-items: center;
  gap: var(--rp-space-xs);
}

.rp-dispatch__troop-icon {
  display: block;
  width: 18px;
  height: 18px;
}

.rp-dispatch__troop-count {
  font-family: var(--rp-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--rp-ref-body);
}

.rp-push-calls__dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  color: var(--rp-ref-heading);
  background: var(--rp-ref-surface);
  border: 1px solid var(--rp-ref-bronze);
  border-radius: var(--rp-radius);
}

.rp-push-calls__dialog--compact {
  width: min(420px, calc(100vw - 32px));
}

.rp-push-calls__dialog::backdrop {
  background: rgb(0 0 0 / 64%);
}

/* New Def Call modal — bespoke design (matches approved mockup), sized to
   match the app's other modals. */
.rp-defcall-modal {
  width: min(520px, calc(100vw - 32px));
  color: var(--rp-ref-text);
  background: linear-gradient(180deg, #151515 0%, #121212 100%);
  border: 1px solid var(--rp-ref-bronze);
  border-radius: var(--rp-radius-md);
}

.rp-defcall-form {
  padding: var(--rp-space-lg);
  font-family: var(--rp-font-sans);
}

.rp-defcall-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rp-space-md);
  margin-bottom: var(--rp-space-lg);
}

.rp-defcall-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--rp-space-sm);
}

.rp-defcall-crest {
  width: 34px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--rp-ref-bronze-bright);
  border: 1px solid rgb(184 137 90 / 60%);
  border-radius: 8px 8px 12px 12px;
  background: rgb(184 137 90 / 8%);
}

.rp-defcall-crest svg {
  width: 19px;
  height: 19px;
}

.rp-defcall-title {
  margin: 0;
  font-family: var(--rp-display-font);
  font-size: var(--rp-headline-md-size);
  line-height: var(--rp-headline-md-lh);
  letter-spacing: -0.01em;
  color: #f0ebe4;
}

.rp-defcall-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius);
  color: var(--rp-ref-muted);
  cursor: pointer;
  transition: 0.18s ease;
}

.rp-defcall-close svg {
  width: 17px;
  height: 17px;
}

.rp-defcall-close:hover {
  color: white;
  border-color: #57514b;
  background: rgb(255 255 255 / 3%);
}

.rp-defcall-group {
  margin-bottom: var(--rp-space-md);
}

.rp-defcall-label-row {
  display: flex;
  align-items: center;
  gap: var(--rp-space-xs);
  margin-bottom: var(--rp-space-xs);
}

.rp-defcall-label-row label {
  font-size: var(--rp-body-md-size);
  font-weight: 600;
  color: #eee8df;
}

.rp-defcall-info {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #716b64;
  border-radius: 999px;
  color: #8d8780;
  font-size: 11px;
  font-weight: 700;
}

.rp-defcall-input-shell {
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius);
  background: #111;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.rp-defcall-input-shell:focus-within {
  border-color: var(--rp-ref-bronze);
  box-shadow: 0 0 0 3px rgb(184 137 90 / 9%);
}

.rp-defcall-input-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #8f8983;
  border-right: 1px solid #292724;
  background: rgb(255 255 255 / 1.5%);
  flex: 0 0 40px;
}

.rp-defcall-input-icon svg {
  width: 16px;
  height: 16px;
}

.rp-defcall-input-shell input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
  padding: 0 var(--rp-space-md);
  color: var(--rp-ref-text);
  background: transparent;
  font: inherit;
  font-size: var(--rp-body-md-size);
}

.rp-defcall-input-shell input::placeholder {
  color: #716c66;
}

.rp-defcall-calendar-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #dad5cf;
  cursor: pointer;
}

.rp-defcall-calendar-btn svg {
  width: 17px;
  height: 17px;
}

.rp-defcall-snipe-card {
  margin-top: var(--rp-space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rp-space-md);
  padding: var(--rp-space-md);
  border: 1px solid #322f2c;
  border-radius: var(--rp-radius);
  background:
    radial-gradient(circle at 16% 50%, rgb(184 137 90 / 6%), transparent 32%),
    #131313;
}

.rp-defcall-snipe-info {
  display: flex;
  align-items: center;
  gap: var(--rp-space-sm);
  min-width: 0;
}

.rp-defcall-snipe-icon {
  width: 26px;
  height: 26px;
  color: var(--rp-ref-bronze-bright);
  flex: 0 0 auto;
}

.rp-defcall-snipe-copy {
  min-width: 0;
}

.rp-defcall-snipe-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}

.rp-defcall-snipe-title strong {
  font-size: var(--rp-body-lg-size);
  color: #ece6de;
}

.rp-defcall-snipe-title span,
.rp-defcall-snipe-copy p {
  color: var(--rp-ref-muted);
}

.rp-defcall-snipe-copy p {
  margin: 0;
  font-size: var(--rp-body-md-size);
}

.rp-defcall-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex: 0 0 44px;
}

.rp-defcall-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rp-defcall-toggle-track {
  position: absolute;
  inset: 0;
  border: 1px solid #4a4642;
  border-radius: 999px;
  background: #181818;
  cursor: pointer;
  transition: 0.2s ease;
}

.rp-defcall-toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f3f1ed;
  box-shadow: 0 2px 8px rgb(0 0 0 / 35%);
  transition: 0.2s ease;
}

.rp-defcall-toggle input:checked + .rp-defcall-toggle-track {
  background: rgb(184 137 90 / 26%);
  border-color: var(--rp-ref-bronze);
}

.rp-defcall-toggle input:checked + .rp-defcall-toggle-track::after {
  transform: translateX(20px);
  background: #d9aa76;
}

.rp-defcall-error {
  margin: var(--rp-space-md) 0 0;
}

.rp-defcall-divider {
  height: 1px;
  margin: var(--rp-space-lg) 0 var(--rp-space-md);
  background: #2d2925;
}

.rp-defcall-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rp-space-md);
}

.rp-defcall-btn {
  min-height: 40px;
  border-radius: var(--rp-radius);
  padding: 0 var(--rp-space-md);
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  font-size: var(--rp-body-md-size);
  font-weight: 600;
  transition: 0.18s ease;
}

.rp-defcall-btn-cancel {
  background: transparent;
  color: var(--rp-ref-bronze-bright);
}

.rp-defcall-btn-cancel:hover {
  background: rgb(184 137 90 / 6%);
}

.rp-defcall-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rp-space-sm);
  min-width: 130px;
  color: #211407;
  background: linear-gradient(180deg, #be905f, #a8794d);
  border-color: #c49a70;
  box-shadow: inset 0 1px rgb(255 255 255 / 16%);
}

.rp-defcall-btn-primary svg {
  width: 16px;
  height: 16px;
}

.rp-defcall-btn-primary:hover {
  background: linear-gradient(180deg, #c99a69, #b28051);
  transform: translateY(-1px);
}

.rp-defcall-btn-primary:active {
  transform: translateY(0);
}

@media (max-width: 640px) {
  .rp-defcall-crest {
    display: none;
  }

  .rp-defcall-snipe-card,
  .rp-defcall-snipe-info {
    align-items: flex-start;
  }

  .rp-defcall-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .rp-defcall-btn {
    width: 100%;
  }
}

.rp-push-calls__form {
  display: grid;
  gap: var(--rp-space-md);
  padding: var(--rp-space-lg);
  font-family: var(--rp-font-sans);
}

.rp-push-calls__dialog-head,
.rp-push-calls__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rp-space-md);
}

.rp-push-calls__dialog-head h2 {
  margin: 0;
  font-family: var(--rp-display-font);
  font-size: var(--rp-headline-md-size);
  line-height: var(--rp-headline-md-lh);
}

.rp-push-calls__icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--rp-ref-muted);
  background: transparent;
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius);
  cursor: pointer;
}

.rp-push-calls__field {
  display: grid;
  gap: var(--rp-space-xs);
  color: var(--rp-ref-muted);
  font-size: var(--rp-body-md-size);
}

.rp-push-calls__field .rp-input {
  width: 100%;
}

.rp-push-calls__update-target {
  margin: 0;
  color: var(--rp-ref-text);
  font-family: var(--rp-display-font);
  font-size: var(--rp-body-lg-size);
  line-height: var(--rp-body-lg-lh);
}

.rp-push-calls__error {
  margin: 0;
  color: var(--rp-error);
  font-size: var(--rp-body-md-size);
}

.rp-incoming-attacks {
  min-height: 100%;
  color: var(--rp-ref-heading);
  font-family: var(--rp-display-font);
}

.rp-incoming-attacks__toolbar {
  display: flex;
  align-items: center;
  gap: var(--rp-space-sm);
  margin-bottom: var(--rp-space-md);
}

.rp-incoming-attacks__group-label {
  color: var(--rp-ref-bronze-bright);
  font-family: var(--rp-font-sans);
  font-size: var(--rp-mono-label-size);
  font-weight: 700;
  letter-spacing: var(--rp-mono-label-ls);
  text-transform: uppercase;
}

.rp-incoming-attacks__group-select {
  cursor: pointer;
}

.rp-incoming-attacks__card {
  background: linear-gradient(180deg, var(--rp-ref-surface), var(--rp-surface));
  border: 1px solid var(--rp-ref-border);
  border-radius: var(--rp-radius);
  overflow: hidden;
}

.rp-incoming-attacks__scroll {
  width: 100%;
  overflow-x: auto;
}

.rp-incoming-attacks__table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.rp-incoming-attacks__table th {
  padding: 10px 14px;
  color: var(--rp-ref-bronze-bright);
  border-bottom: 1px solid var(--rp-ref-border);
  font-family: var(--rp-font-sans);
  font-size: var(--rp-mono-label-size);
  font-weight: 700;
  letter-spacing: var(--rp-mono-label-ls);
  line-height: var(--rp-mono-label-lh);
  text-align: center;
  text-transform: uppercase;
}

.rp-incoming-attacks__sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 auto;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.rp-incoming-attacks__sort:hover,
.rp-incoming-attacks__sort--active {
  color: var(--rp-ref-heading);
}

.rp-incoming-attacks__sort-arrow {
  font-size: 11px;
  line-height: 1;
}

.rp-incoming-attacks__group-row {
  cursor: pointer;
  user-select: none;
}

.rp-incoming-attacks__group-row:hover td {
  background: rgb(238 189 142 / 14%);
}

.rp-incoming-attacks__group-row td {
  padding: 6px 14px;
  background: rgb(238 189 142 / 8%);
  border-bottom: 1px solid var(--rp-ref-border);
  color: var(--rp-ref-bronze-bright);
  font-family: var(--rp-font-sans);
  font-size: var(--rp-mono-label-size);
  font-weight: 700;
  letter-spacing: var(--rp-mono-label-ls);
  text-align: left;
  text-transform: uppercase;
}

.rp-incoming-attacks__group-chevron {
  display: inline-block;
  width: 12px;
  margin-right: 8px;
  font-size: 9px;
}

.rp-incoming-attacks__table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--rp-ref-border-soft);
  color: var(--rp-ref-text);
  font-size: 14px;
  text-align: center;
  vertical-align: middle;
}

.rp-incoming-attacks__table tbody tr:last-child td {
  border-bottom: 0;
}

.rp-incoming-attacks__table tbody tr:hover {
  background: rgb(238 189 142 / 4%);
}

.rp-incoming-attacks__account,
.rp-incoming-attacks__village {
  color: var(--rp-ref-heading);
}

.rp-incoming-attacks__account--link,
.rp-incoming-attacks__village {
  color: var(--rp-ref-bronze-bright);
  text-decoration: none;
}

.rp-incoming-attacks__account--link:hover,
.rp-incoming-attacks__village:hover {
  text-decoration: underline;
}

.rp-incoming-attacks__tag {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 2px solid rgb(255 255 255 / 25%);
  border-radius: var(--rp-radius-full);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rp-incoming-attacks__tag:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgb(238 189 142 / 18%);
}

.rp-incoming-attacks__impact {
  font-family: var(--rp-font-mono);
}

.rp-incoming-attacks__countdown {
  display: block;
  font-size: var(--rp-body-md-size);
  font-weight: 700;
  color: var(--rp-ref-heading);
}

.rp-incoming-attacks__countdown--now {
  color: var(--rp-error);
}

.rp-incoming-attacks__impact-abs {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--rp-ref-muted);
}

.rp-incoming-attacks__type {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--rp-outline);
  color: var(--rp-ref-muted);
}

.rp-incoming-attacks__type--attack {
  color: var(--rp-error);
  border-color: var(--rp-error);
}

.rp-incoming-attacks__type--raid {
  color: var(--rp-ref-heading);
}

.rp-incoming-attacks__delete-action {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  color: var(--rp-error);
  border: 1px solid var(--rp-outline);
  border-radius: var(--rp-radius);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.rp-incoming-attacks__delete-action svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

.rp-incoming-attacks__delete-action:hover {
  background: rgb(255 180 171 / 10%);
  border-color: var(--rp-error);
  transform: translateY(-1px);
}

.rp-incoming-attacks__empty {
  margin: 0;
  padding: var(--rp-space-lg);
  color: var(--rp-ref-muted);
  font-family: var(--rp-font-sans);
}

.rp-troops-overview__total {
  color: var(--rp-ref-bronze-bright);
  font-weight: 600;
}

.rp-troops-overview__table tfoot th,
.rp-troops-overview__table tfoot td {
  font-weight: 600;
}

.rp-troops-overview__table tfoot .rp-troops-overview__total {
  color: var(--rp-ref-bronze-bright);
}

.rp-troops-overview__divider {
  border-left: 2px solid var(--rp-ref-crest-border);
}

@media (max-width: 480px) {
  .rp-troops-overview {
    padding: var(--rp-space-md);
  }
}

/* ---------------------------------------------------------------------
 * Permissions
 * --------------------------------------------------------------------- */
.rp-permissions {
  display: grid;
  gap: var(--rp-space-lg);
}

.rp-permissions__table th,
.rp-permissions__table td {
  vertical-align: middle;
}

.rp-permissions__table th:not(:first-child),
.rp-permissions__table td:not(:first-child) {
  text-align: center;
}

.rp-permissions__account {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
}

.rp-permissions__badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: var(--rp-space-xs);
  padding: 0 var(--rp-space-sm);
  border: 1px solid var(--rp-outline-variant);
  border-radius: var(--rp-radius);
  color: var(--rp-ref-muted);
  font-size: var(--rp-label-md-size);
}

.rp-permissions__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
}

.rp-permissions__status {
  margin: 0;
  color: var(--rp-ref-muted);
}

/* ---------------------------------------------------------------------
 * Canonical application table contract
 * --------------------------------------------------------------------- */
.rp-members-table,
.rp-troops-overview__table,
.rp-push-calls__table,
.rp-incoming-attacks__table,
.rp-permissions__table,
.rp-report-troops {
  font-family: var(--rp-font-sans);
}

.rp-members-table *,
.rp-troops-overview__table *,
.rp-push-calls__table *,
.rp-incoming-attacks__table *,
.rp-permissions__table *,
.rp-report-troops * {
  font-family: var(--rp-font-sans);
}

.rp-members-table th,
.rp-troops-overview__table th,
.rp-troops-overview__table thead th,
.rp-push-calls__table th,
.rp-incoming-attacks__table th,
.rp-permissions__table th,
.rp-report-troops th {
  padding: var(--rp-space-sm);
  font-family: var(--rp-font-sans);
  font-size: var(--rp-mono-label-size);
  font-weight: 700;
  line-height: var(--rp-mono-label-lh);
  text-align: left;
  text-transform: uppercase;
}

.rp-members-table td,
.rp-members-table td.rp-table__num,
.rp-members-table td[data-mono],
.rp-troops-overview__table td,
.rp-troops-overview__table td.rp-troops-overview__num,
.rp-push-calls__table td,
.rp-incoming-attacks__table td,
.rp-permissions__table td,
.rp-report-troops td,
.rp-report-troops td.rp-table__num,
.rp-report-statistics td {
  padding: var(--rp-space-sm);
  font-family: var(--rp-font-sans);
  font-size: var(--rp-mono-data-size);
  line-height: var(--rp-mono-data-lh);
  text-align: left;
}

.rp-members-table th.rp-table__num,
.rp-troops-overview__table th.rp-troops-overview__troop-header,
.rp-troops-overview__table th.rp-troops-overview__num,
.rp-permissions__table th:not(:first-child),
.rp-permissions__table td:not(:first-child),
.rp-report-troops th:not(:first-child),
.rp-report-troops td:not(:first-child),
.rp-report-troops th:first-child,
.rp-report-troops td:first-child {
  text-align: left;
}

.rp-incoming-attacks__sort {
  margin-right: 0;
  margin-left: 0;
}

.rp-members-table__account,
.rp-troops-overview__village-link,
.rp-push-calls__entity-link,
.rp-incoming-attacks__account--link,
.rp-incoming-attacks__village,
.rp-report-game-link {
  color: var(--rp-ref-bronze-bright);
  text-decoration: none;
  border-bottom: 0;
}

.rp-members-table__account:hover,
.rp-troops-overview__village-link:hover,
.rp-troops-overview__village-link:focus-visible,
.rp-push-calls__entity-link:hover,
.rp-push-calls__entity-link:focus-visible,
.rp-incoming-attacks__account--link:hover,
.rp-incoming-attacks__village:hover,
.rp-report-game-link:hover,
.rp-report-game-link:focus-visible {
  color: var(--rp-primary-fixed);
  text-decoration: underline;
  text-underline-offset: 4px;
  border-bottom: 0;
}

/* Hero equipment history */
.rp-hero-equipment-table {
  min-width: 960px;
}

.rp-hero-equipment-table__account-row th {
  padding: 0;
  text-transform: none;
}

.rp-hero-equipment-table__toggle {
  display: flex;
  width: 100%;
  align-items: center;
  gap: var(--rp-space-sm);
  padding: var(--rp-space-md) var(--rp-space-sm);
  color: inherit;
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.rp-hero-equipment-table__toggle:hover,
.rp-hero-equipment-table__toggle:focus-visible {
  color: var(--rp-ref-bronze-bright);
}

.rp-hero-equipment-table__chevron {
  display: inline-block;
  font-size: 1.4em;
  transition: transform 120ms ease;
}

.rp-hero-equipment-table__toggle[aria-expanded="true"]
  .rp-hero-equipment-table__chevron {
  transform: rotate(90deg);
}

.rp-hero-equipment-table__period {
  white-space: nowrap;
}
