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

html {
  height: 100%;
}

body {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #EDEDED;
  padding: 0;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: #222;
}

/* Header / Brand */
.site-header {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 16px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #222;
}

.site-brand:hover {
  text-decoration: none;
  color: #000;
}

.site-logo {
  height: auto;
  max-width: 70px;
  flex-shrink: 0;
}

.site-tagline {
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

/* Navigation */
#menu {
  width: 100%;
  background-color: #161616;
  background-image: linear-gradient(to bottom, #383838, #000);
  color: #fff;
  padding: 8px 12px;
}

.menu-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 960px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 24px;
}

.menuItem {
  font-size: 15px;
  text-transform: uppercase;
  display: inline-block;
  margin: 0;
}

.menuItem a {
  display: inline-block;
  padding: 8px 12px;
  color: #DDD;
  text-decoration: none;
  border-radius: 3px;
}

.menuItem a:hover,
.menuItem a:focus,
.menuItem a.selected {
  color: #FFF;
  background-color: rgba(255, 255, 255, 0.12);
}

/* Main Content Container */
#container {
  flex: 1 0 auto;
  width: calc(100% - 24px);
  max-width: 960px;
  margin: 20px auto 32px;
  padding: 20px 24px;
  background-color: #FFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

#content h1 {
  font-size: 28px;
  line-height: 1.25;
  margin: 0 0 8px;
}

.subtitle {
  color: #555;
  margin: 0 0 16px;
}

/* Screen-reader only label */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Search Form */
.search-form {
  margin-bottom: 20px;
}

.search-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
  max-width: 520px;
}

.search-bar .search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  font-size: 16px;
  padding: 6px 12px;
  margin: 0;
}

.search-bar .search-submit {
  flex-shrink: 0;
  height: 40px;
  padding: 0 18px;
  font-size: 15px;
}

#hamSearch {
  background-color: #F9F9F9;
  border: 1px solid #DDD;
  border-radius: 4px;
  margin: 0 0 12px;
  padding: 10px 14px;
}

.search-options-legend {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  border: 0;
  width: auto;
  margin: 0 0 8px;
  padding: 0;
  line-height: 1.3;
}

.search-options-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
}

.search-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}

.search-option input[type="checkbox"],
.search-option input[type="radio"] {
  margin: 0;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.hamCheck {
  display: inline;
  margin: 0;
  padding: 0;
  width: auto;
  float: none;
  font-weight: normal;
  cursor: pointer;
}

/* Database stats & solar propagation banner */
.db-stats {
  margin: 16px 0;
}

.db-stats p {
  margin: 0 0 6px;
}

.solar-banner-wrap {
  margin-top: 16px;
}

.solar-banner {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Responsive Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
}

table.callsign_search_results {
  width: 100%;
  min-width: 540px;
  border: 0;
  margin-bottom: 0;
}

.sortable-header {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.results-heading {
  font-size: 22px;
  margin: 12px 0;
}

.results-count {
  color: #555;
  margin: 8px 0 0;
}

/* Callsign Profile Page */
.ham-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid #EEE;
}

.ham-header h1 {
  margin: 0;
  font-size: 32px;
}

.ham-class {
  margin: 0;
  font-size: 20px;
  color: #444;
  font-weight: 500;
}

.ham-details {
  width: 100%;
  table-layout: fixed;
}

.ham-details th {
  width: 220px;
  font-weight: 600;
  color: #333;
  vertical-align: top;
}

.ham-details td {
  word-wrap: break-word;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.map-embed {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 4 / 3;
}

.map-frame {
  width: 100%;
  height: 100%;
  min-height: 240px;
  border: 0;
  display: block;
}

.map-link-wrap {
  margin: 6px 0 0;
  font-size: 13px;
}

.map-link {
  color: #0055cc;
  text-align: left;
}

/* Exam Selection Page */
.exam-selection {
  padding: 4px 0;
}

.exam-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.exam-link {
  display: block;
  padding: 16px 20px;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  background-color: #F7F7F7;
  border: 1px solid #DDD;
  border-radius: 6px;
  text-decoration: none;
  color: #0055cc;
}

.exam-link:hover,
.exam-link:focus {
  background-color: #EAEAEA;
  text-decoration: none;
}

/* Footer */
#footer {
  flex-shrink: 0;
  width: 100%;
  text-align: center;
  color: #DDD;
  font-size: 13px;
  background-color: #161616;
  padding: 14px 16px;
  line-height: 1.4;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .site-header {
    padding: 8px 12px;
  }

  .site-logo {
    max-width: 48px;
  }

  .site-tagline {
    font-size: 15px;
  }

  .menu-list {
    gap: 4px 10px;
  }

  .menuItem {
    font-size: 14px;
  }

  .menuItem a {
    padding: 8px 10px;
  }

  #container {
    width: calc(100% - 16px);
    margin: 12px auto 20px;
    padding: 14px;
  }

  #content h1,
  .ham-header h1 {
    font-size: 24px;
  }

  .ham-class {
    font-size: 17px;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-bar .search-submit {
    width: 100%;
  }

  .search-options-grid {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* Stack callsign profile rows cleanly on small screens */
  .ham-details,
  .ham-details tbody,
  .ham-details tr,
  .ham-details th,
  .ham-details td {
    display: block;
    width: 100%;
  }

  .ham-details tr {
    padding: 8px 0;
    border-bottom: 1px solid #E5E5E5;
  }

  .ham-details th,
  .ham-details td {
    border-top: 0;
    padding: 2px 6px;
  }

  .ham-details th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #666;
  }

  .ham-details td {
    font-size: 15px;
  }
}
