:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #637083;
  --line: #d7dde5;
  --accent: #1f7a5c;
  --accent-dark: #155b44;
  --warn: #a84b2f;
  --shadow: 0 12px 35px rgba(29, 45, 68, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.app-shell {
  width: min(1100px, calc(100% - 32px));
  margin: 32px auto;
}

.toolbar {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 190px;
  padding: 28px 30px;
  background:
    linear-gradient(90deg, rgba(9, 16, 24, 0.84), rgba(9, 16, 24, 0.46) 52%, rgba(9, 16, 24, 0.18)),
    url("/assets/clash-banner.webp") center / cover no-repeat;
  color: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: #8fe0bd;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.05;
}

.page-nav {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.page-nav a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.page-nav a[aria-current="page"] {
  background: #ffffff;
  color: #203040;
}

.stats {
  display: flex;
  gap: 12px;
}

.stat {
  min-width: 112px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(9, 16, 24, 0.56);
  backdrop-filter: blur(2px);
}

.stat span,
.stat small {
  display: block;
}

.stat span {
  font-size: 24px;
  font-weight: 800;
}

.stat small {
  margin-top: 2px;
  color: #d7e6ec;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin: 18px 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-controls {
  display: flex;
  justify-content: flex-end;
}

.compact-controls:empty {
  display: none;
}

.history-area {
  margin-top: 18px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.report-summary div,
.kpi-grid div {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.print-note {
  display: none;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.report-summary span,
.report-summary strong,
.kpi-grid span,
.kpi-grid strong {
  display: block;
}

.report-summary span,
.kpi-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.report-summary strong,
.kpi-grid strong {
  margin-top: 4px;
  color: var(--ink);
  font-size: 24px;
}

.town-hall-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 118px;
  padding: 10px 12px 12px;
}

.town-hall-card strong {
  margin-top: 0;
}

.town-hall-icon {
  display: block;
  width: min(82px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
}

.town-hall-fallback {
  display: grid;
  place-items: center;
  width: 82px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #edf1f5;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.token-field span,
.filter-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
button {
  height: 42px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

.filter-field {
  min-width: 180px;
}

button {
  border: 0;
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.table-area {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.status {
  min-height: 46px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: var(--warn);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: #edf1f5;
  color: #3b4654;
  font-size: 13px;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  width: 90px;
  text-align: center;
}

.members-table th,
.members-table td {
  text-align: center;
}

.members-table td:nth-child(2),
.members-table th:nth-child(2) {
  width: 90px;
}

.members-table td:last-child,
.members-table th:last-child {
  width: 190px;
}

tbody tr:hover {
  background: #f8fafb;
}

.member-name {
  font-weight: 700;
}

.attack-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #edf1f5;
  color: #3b4654;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.pill.unknown {
  min-width: 88px;
  background: #637083;
}

.pill.yes {
  background: #1f7a5c;
}

.pill.no {
  background: #8a4a52;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1100px);
    margin: 10px auto;
  }

  .toolbar,
  .controls {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .stats {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    min-height: 220px;
    background:
      linear-gradient(180deg, rgba(9, 16, 24, 0.74), rgba(9, 16, 24, 0.58)),
      url("/assets/clash-banner.webp") center / cover no-repeat;
  }

  .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  th,
  td {
    padding: 12px 10px;
  }

  .report-summary {
    grid-template-columns: 1fr 1fr;
  }
}

@media print {
  @page {
    margin: 12mm;
  }

  body {
    background: #ffffff;
  }

  .app-shell {
    width: 100%;
    margin: 0;
  }

  .controls,
  .page-nav,
  .history-area {
    display: none;
  }

  .print-summary-mode .print-note {
    display: grid;
    gap: 4px;
    padding: 14px 18px;
    border-bottom: 1px solid #d7dde5;
    background: #f8fafb;
    color: #17202a;
  }

  .print-note strong {
    font-size: 16px;
  }

  .print-note span {
    color: #637083;
    font-size: 13px;
  }

  .toolbar,
  .table-area,
  .report-summary div {
    box-shadow: none;
  }

  .toolbar {
    min-height: 130px;
    padding: 14px 18px;
    background:
      linear-gradient(90deg, rgba(9, 16, 24, 0.84), rgba(9, 16, 24, 0.38)),
      url("/assets/clash-banner.webp") center / cover no-repeat;
    color: #ffffff;
    border-bottom: 2px solid #203040;
    border-radius: 8px;
  }

  .eyebrow {
    color: #8fe0bd;
  }

  .stats .stat {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(9, 16, 24, 0.56);
    color: #ffffff;
  }

  .stat small {
    color: #d7e6ec;
  }

  .report-summary {
    grid-template-columns: repeat(4, 1fr);
    margin: 12px 0;
  }

  .table-area {
    border-radius: 0;
  }

  .status {
    border-bottom: 1px solid #d7dde5;
  }

  th {
    background: #edf1f5;
  }

  tr {
    break-inside: avoid;
  }
}
