:root {
  color-scheme: light;
  --red: #7f1d18;
  --red-dark: #5f1411;
  --blue: #1a2744;
  --blue-soft: #eef3fb;
  --ink: #181818;
  --muted: #5f6673;
  --line: #d8dde5;
  --soft: #f4f5f7;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 4px clamp(10px, 2vw, 18px);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: var(--red);
  font-size: 15px;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-menu a {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 9px;
  color: var(--blue);
  background: var(--white);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.header-menu a:hover {
  border-color: var(--red);
  color: var(--red);
}

main {
  width: min(1220px, calc(100% - 24px));
  margin: 0 auto;
}

.search-shell {
  padding: 8px 0 6px;
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.15;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(96px, 0.55fr) minmax(126px, 0.65fr) minmax(110px, 0.55fr) minmax(148px, 0.7fr) auto auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  padding: 8px;
  background: var(--soft);
}

.top-notice {
  margin: 6px 0 0;
  border-left: 4px solid var(--red);
  padding: 6px 8px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 800;
}

.search-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.search-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-field input,
.search-field select {
  width: 100%;
  min-height: 32px;
  border: 1px solid #cfd6df;
  border-radius: 3px;
  padding: 0 9px;
  color: var(--ink);
  background: var(--white);
}

.state-filter {
  position: relative;
}

.state-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 32px;
  border: 1px solid #cfd6df;
  border-radius: 3px;
  padding: 0 9px;
  color: var(--ink);
  background: var(--white);
  cursor: pointer;
}

.state-toggle::after {
  content: "";
  border-color: var(--muted) transparent transparent;
  border-style: solid;
  border-width: 5px 4px 0;
  margin-left: 8px;
}

.state-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  width: min(280px, 86vw);
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(24, 24, 24, 0.16);
  padding: 6px;
  background: var(--white);
}

.state-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 4px 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.state-option:hover {
  background: var(--blue-soft);
}

.state-option input {
  width: auto;
  min-height: 0;
}

.state-option-all {
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  color: var(--red);
}

.search-field input:focus,
.search-field select:focus,
.state-toggle:focus {
  outline: 2px solid rgba(127, 29, 24, 0.16);
  border-color: var(--red);
}

.primary-button,
.secondary-button {
  min-height: 32px;
  border-radius: 3px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--red);
  color: var(--white);
  background: var(--red);
}

.primary-button:hover {
  background: var(--red-dark);
}

.secondary-button {
  border: 1px solid #cfd6df;
  color: var(--ink);
  background: var(--white);
}

.secondary-button:hover {
  border-color: var(--red);
  color: var(--red);
}

.results-shell {
  margin: 4px auto 26px;
}

.status {
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  padding: 6px 8px;
  color: var(--muted);
  background: var(--white);
  font-size: 13px;
  font-weight: 700;
}

.status.error {
  border-left-color: var(--red);
  color: var(--red);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 6px;
}

.pagination-bar[hidden] {
  display: none;
}

.pagination-bar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pagination-bar button {
  min-height: 28px;
}

.pagination-bar button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.pagination-bar-bottom {
  margin-top: 6px;
  margin-bottom: 0;
}

.results-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--white);
}

.results-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.results-table th,
.results-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
}

.results-table th {
  color: var(--white);
  background: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

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

.results-table tbody tr:hover {
  background: #fbfcff;
}

.results-table th:nth-child(1),
.results-table td:nth-child(1) {
  width: 178px;
}

.results-table th:nth-child(2),
.results-table td:nth-child(2) {
  width: 24%;
}

.results-table th:nth-child(3),
.results-table td:nth-child(3),
.results-table th:nth-child(4),
.results-table td:nth-child(4) {
  width: 20%;
}

.results-table th:nth-child(5),
.results-table td:nth-child(5) {
  width: 128px;
}

.results-table th:nth-child(6),
.results-table td:nth-child(6) {
  width: 128px;
}

.ffl-number {
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.ffl-title {
  margin-bottom: 3px;
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.ffl-detail,
.ffl-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.status-pill {
  display: inline-block;
  margin: 4px 4px 0 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 11px;
  font-weight: 800;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.row-actions a {
  border: 1px solid var(--red);
  border-radius: 3px;
  padding: 6px 8px;
  color: var(--white);
  background: var(--red);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.row-actions a.secondary {
  border-color: #cfd6df;
  color: var(--ink);
  background: var(--white);
}

.empty-row td {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 12px clamp(12px, 3vw, 28px);
  color: var(--muted);
  background: var(--soft);
}

.site-footer p {
  max-width: 1220px;
  margin: 0 auto;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 980px) {
  .search-panel {
    grid-template-columns: 1fr 1fr;
  }

  .search-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .site-header {
    align-items: stretch;
    flex-direction: column;
  }

  .search-panel {
    grid-template-columns: 1fr;
  }

  .results-table-wrap {
    overflow-x: visible;
    border: 0;
    background: transparent;
  }

  .results-table,
  .results-table thead,
  .results-table tbody,
  .results-table tr,
  .results-table th,
  .results-table td {
    display: block;
  }

  .results-table {
    min-width: 0;
    border-collapse: separate;
  }

  .results-table thead {
    display: none;
  }

  .results-table tbody {
    display: grid;
    gap: 8px;
  }

  .results-table tbody tr {
    border: 1px solid var(--line);
    background: var(--white);
  }

  .results-table th:nth-child(n),
  .results-table td:nth-child(n) {
    width: auto;
  }

  .results-table td {
    border-bottom: 1px solid var(--line);
    padding: 7px 9px;
  }

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

  .results-table td::before {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .results-table td:nth-child(1)::before {
    content: "FFL";
  }

  .results-table td:nth-child(2)::before {
    content: "Business";
  }

  .results-table td:nth-child(3)::before {
    content: "Premises";
  }

  .results-table td:nth-child(4)::before {
    content: "Mailing";
  }

  .results-table td:nth-child(5)::before {
    content: "Contact";
  }

  .results-table td:nth-child(6)::before {
    content: "Action";
  }

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

  .row-actions a {
    padding: 8px;
  }

  .empty-row td {
    border: 1px solid var(--line);
  }
}
