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

body {
  font-family: Arial, sans-serif;
  margin: 0;
  line-height: 1.4;
}

.container {
  width: 80%;
  margin-inline: auto;
}

.title-bar {
  background-color: #447799;
  color: white;
}

.title-bar-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-block: 1rem;
}

.site-logo {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  background-color: white;
  border-radius: 5px;
  object-fit: contain;
}

.title-bar h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: bold;
  line-height: 1.1;
}

.admin-title-bar {
  background-color: #9f2f3f;
}

main {
  padding: 1rem 0 2rem;
}

h2 {
  font-size: 1.5rem;
  margin: 0.8rem 0 0.4rem;
}

h3 {
  font-size: 1.3rem;
  margin: 0.5rem 0;
}

h4 {
  font-size: 1.1rem;
  margin: 0.35rem 0;
}

a {
  overflow-wrap: anywhere;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 1rem;
}

th,
td {
  border: 1px solid #ccc;
  padding: 0.4rem 0.8rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  background: #f0f0f0;
}

button {
  padding: 0.5rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
}

.sort-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: bold;
  text-align: inherit;
}

.sort-button::after {
  content: " \2195";
  color: #555;
  font-size: 0.85rem;
}

.sort-button[aria-sort="ascending"]::after {
  content: " \2191";
}

.sort-button[aria-sort="descending"]::after {
  content: " \2193";
}

.meta {
  color: #555;
  font-size: 0.9rem;
}

.success {
  color: #006600;
  background: #e6ffe6;
  padding: 0.5rem 1rem;
  border-radius: 4px;
}

.error {
  color: #a30000;
  background: #ffe6e6;
  padding: 0.5rem 1rem;
  border-radius: 4px;
}

.warning {
  color: #6f4c00;
  background: #fff3cd;
  padding: 0.5rem 1rem;
  border-radius: 4px;
}

.warning-panel {
  background: #fffaf0;
  border-color: #e0b94d;
}

.info-panel {
  margin-top: 0.5rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  background: #f8f8f8;
}

.admin-info-panel {
  margin-top: 0.8rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.cache-list {
  margin-top: 0.5rem;
  padding-left: 1.2rem;
}

.cache-list ul {
  margin: 0.2rem 0 0.6rem;
  padding-left: 1.4rem;
}

.cache-list li {
  margin: 0.15rem 0;
}

.section-heading {
  margin-top: 1.2rem;
}

.compact-table {
  width: auto;
  max-width: 100%;
  margin-top: 0.5rem;
}

.totals-table th:first-child,
.totals-table td:first-child {
  min-width: 20rem;
  white-space: nowrap;
}

.right {
  text-align: right;
}

.center {
  text-align: center;
}

.bold {
  font-weight: bold;
}

.entity-header {
  padding: 0.65rem 0.8rem;
}

.entity-title h3,
.entity-title h4 {
  margin: 0;
}

.entity-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 0.35rem;
  font-weight: normal;
  font-size: 0.95rem;
}

.entity-meta-item {
  min-width: 0;
}

.accordion {
  margin-top: 0.5rem;
}

.accordion summary {
  cursor: pointer;
}

.map-panel {
  width: min(100%, 700px);
  height: 460px;
  margin-top: 0.5rem;
  border: 1px solid #ccc;
  overflow: hidden;
}

.line-chart-panel {
  width: 100%;
  max-width: 70rem;
  height: 420px;
  margin-top: 0.5rem;
  border: 1px solid #ccc;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll > table {
  max-width: none;
}

.sortable-table,
.insights-table,
.recent-activity,
.country-summary {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sortable-table thead,
.sortable-table tbody,
.insights-table thead,
.insights-table tbody,
.recent-activity thead,
.recent-activity tbody,
.country-summary thead,
.country-summary tbody {
  white-space: nowrap;
}

.insights-table {
  table-layout: fixed;
  width: auto;
  min-width: 76rem;
}

.insights-table-all-time {
  min-width: 60rem;
}

.insights-table th:nth-child(1),
.insights-table td:nth-child(1) {
  width: 32rem;
  min-width: 32rem;
  white-space: normal;
}

.insights-table th:nth-child(2),
.insights-table td:nth-child(2) {
  width: 12rem;
  min-width: 12rem;
}

.insights-table th:nth-child(3),
.insights-table td:nth-child(3),
.insights-table th:nth-child(4),
.insights-table td:nth-child(4),
.insights-table th:nth-child(5),
.insights-table td:nth-child(5),
.insights-table th:nth-child(6),
.insights-table td:nth-child(6) {
  width: 8rem;
  min-width: 8rem;
}

.item-stats {
  width: 100%;
  min-width: 72rem;
  table-layout: fixed;
}

.item-stats.sortable-table {
  display: table;
  overflow-x: visible;
}

.item-stats thead,
.item-stats tbody {
  white-space: normal;
}

.item-stats th:nth-child(1),
.item-stats td:nth-child(1) {
  width: 22%;
  min-width: 20rem;
  font-size: 0.9rem;
  white-space: normal;
  line-height: 1.25;
}

.item-stats th:nth-child(2),
.item-stats td:nth-child(2) {
  width: 12%;
  min-width: 7rem;
  font-size: 0.9rem;
}

.item-stats th:nth-child(3),
.item-stats td:nth-child(3),
.item-stats th:nth-child(4),
.item-stats td:nth-child(4),
.item-stats th:nth-child(5),
.item-stats td:nth-child(5),
.item-stats th:nth-child(6),
.item-stats td:nth-child(6),
.item-stats th:nth-child(7),
.item-stats td:nth-child(7) {
  width: 4.5rem;
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.9rem;
  white-space: nowrap;
}

.item-stats td:nth-child(8),
.item-stats td:nth-child(9),
.item-stats td:nth-child(10) {
  white-space: normal;
  line-height: 1.1;
  font-size: 0.6rem;
}

.item-stats th:nth-child(8),
.item-stats td:nth-child(8),
.item-stats th:nth-child(9),
.item-stats td:nth-child(9) {
  width: 8.25rem;
  min-width: 8.25rem;
}

.item-stats th:nth-child(10),
.item-stats td:nth-child(10) {
  width: 8.75rem;
  min-width: 8.75rem;
}

.item-stats th:nth-child(8),
.item-stats th:nth-child(9),
.item-stats th:nth-child(10) {
  font-size: 0.9rem;
}

.embedded-stats {
  width: 100%;
  margin-top: 0;
  font-size: 0.7rem;
  line-height: 1.1;
  table-layout: fixed;
}

.item-stats .embedded-stats td {
  border: 0;
  padding: 0.05rem 0.2rem 0.05rem 0;
  font-size: inherit;
  white-space: normal;
  overflow-wrap: anywhere;
}

.item-stats .embedded-stats td:first-child {
  width: 70%;
}

.item-stats .embedded-stats td:last-child {
  width: 30%;
  text-align: right;
}

.country-summary th,
.country-summary td,
.recent-activity th,
.recent-activity td {
  text-align: center;
}

.recent-activity th:first-child,
.recent-activity td:first-child {
  text-align: left;
}

.site-footer {
  margin-top: 2rem;
  background-color: #1b2f52;
  color: white;
}

.admin-footer {
  background-color: #5f1e29;
}

.site-footer-inner {
  padding: 20px 0;
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p {
  margin: 0.25rem 0;
}

.site-footer a {
  color: #ffffff;
}

.site-footer .small {
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .container {
    width: min(100% - 1rem, 960px);
  }

  body {
    font-size: 0.92rem;
  }

  .title-bar-inner {
    min-height: auto;
    padding-block: 0.75rem;
    align-items: center;
  }

  .title-bar h1 {
    font-size: 1.25rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3 {
    font-size: 1.15rem;
  }

  h4 {
    font-size: 1rem;
  }

  th,
  td,
  button,
  .meta {
    font-size: 0.9rem;
  }

  .compact-table {
    width: 100%;
  }

  .item-stats.sortable-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .entity-header {
    padding: 0.55rem 0.65rem;
  }

  .entity-meta-row {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.88rem;
  }

  .entity-meta-item {
    display: block;
  }

  .entity-meta-item + .entity-meta-item {
    margin-top: 0.15rem;
  }

  .totals-table,
  .totals-table tbody,
  .totals-table tr,
  .totals-table th,
  .totals-table td {
    display: block;
    width: 100%;
  }

  .totals-table th:first-child,
  .totals-table td:first-child {
    min-width: 0;
    white-space: normal;
  }

  .totals-table tr {
    margin-bottom: 0.75rem;
    border: 1px solid #ccc;
  }

  .totals-table th,
  .totals-table td {
    border: 0;
    border-bottom: 1px solid #ddd;
    padding: 0.35rem 0.55rem;
  }

  .totals-table td:last-child {
    border-bottom: 0;
  }

  .map-panel {
    height: 320px;
  }

  .line-chart-panel {
    height: 300px;
  }
}
