:root {
  --bg: #f5f7f8;
  --ink: #172026;
  --muted: #64717b;
  --line: #d7dee3;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #a16207;
  --bad: #9f1239;
  --ok: #166534;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #102027;
  color: #fff;
  border-bottom: 1px solid #071418;
}

.brand {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}

.topbar nav {
  display: flex;
  gap: 18px;
}

.topbar nav a {
  color: #dbe7ea;
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 24px 40px;
}

.site-footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px 22px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer p {
  margin: 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.summary-band,
.detail-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 3px;
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 16px;
  letter-spacing: 0;
}

h3 {
  margin: 16px 0 8px;
  font-size: 13px;
}

.summary-band p,
.detail-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.page-subtitle {
  max-width: 850px;
  margin-bottom: 12px;
  color: #4f5f69;
  font-size: 14px;
  line-height: 1.45;
}

.result-count {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 15px;
}

.result-count strong {
  color: #33424a;
  font-size: 16px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.metrics span,
.pill,
.mini,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.metrics strong {
  margin-right: 4px;
}

.filter-band {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.filters label:first-child {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
}

.help-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid #aebbc4;
  border-radius: 50%;
  background: #f8fafb;
  color: #51616c;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  outline: none;
}

.help-tip:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 30;
  display: none;
  width: min(320px, 78vw);
  transform: translateX(-50%);
  padding: 9px 10px;
  border: 1px solid #b9c7cf;
  border-radius: 6px;
  background: #102027;
  color: #f6fafb;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
  text-align: left;
  box-shadow: 0 8px 22px rgba(15, 32, 39, 0.2);
}

.tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #102027;
}

.table-tip .tooltip {
  left: auto;
  right: 0;
  top: calc(100% + 8px);
  bottom: auto;
  width: min(380px, calc(100vw - 48px));
  transform: none;
}

.table-tip .tooltip::after {
  left: auto;
  right: 8px;
  top: auto;
  bottom: 100%;
  transform: none;
  border-top-color: transparent;
  border-bottom-color: #102027;
}

.help-tip:hover .tooltip,
.help-tip:focus .tooltip {
  display: block;
}

input,
select,
button,
.button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0 9px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

.button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.filter-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 8px;
  justify-content: flex-start;
  padding-top: 2px;
}

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.col-company {
  width: 22%;
}

.col-uen {
  width: 112px;
}

.col-type {
  width: 190px;
}

.col-capabilities {
  width: 26%;
}

.col-expiry {
  width: 170px;
}

.col-contact {
  width: 96px;
}

.col-postal {
  width: 82px;
}

.col-web {
  width: 180px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: normal;
}

th {
  background: #eef3f5;
  color: #3d4a52;
  font-size: 12px;
  white-space: nowrap;
}

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

.company-link {
  display: inline-block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.capabilities {
  color: #30404a;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.expiry-cell {
  color: #30404a;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-line;
}

.online-cell {
  font-size: 13px;
  line-height: 1.55;
}

.online-cell a {
  overflow-wrap: anywhere;
}

.status-found {
  color: var(--ok);
  border-color: #b7dfc2;
  background: #eefaf1;
}

.status-needs_api,
.status-needs_review {
  color: var(--warn);
  border-color: #ead59b;
  background: #fff8df;
}

.status-not_found {
  color: var(--bad);
  border-color: #f0b6c3;
  background: #fff1f4;
}

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

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 18px 0;
}

.back-link {
  color: var(--muted);
  font-size: 13px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notice {
  padding: 10px 12px;
  background: #eefaf1;
  border: 1px solid #b7dfc2;
  border-radius: 6px;
}

.detail-grid,
.detail-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.detail-sections {
  grid-template-columns: 1fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
}

.panel.wide {
  padding: 0;
}

.panel.wide h2 {
  padding: 14px 16px 0;
}

dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0 16px 16px;
}

@media (max-width: 1100px) {
  .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar,
  .summary-band,
  .detail-header {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding: 12px;
  }

  .filters,
  .detail-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .filters label:first-child {
    grid-column: 1;
  }

  .filter-actions {
    flex-wrap: wrap;
  }

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

  table,
  colgroup,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  table {
    border-collapse: separate;
    table-layout: auto;
  }

  tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    overflow: hidden;
  }

  tr:last-child td {
    border-bottom: 1px solid var(--line);
  }

  td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px;
    min-height: 42px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  td[data-label="Company"] {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  td[data-label="Company"]::before {
    content: none;
  }

  .company-link {
    font-size: 15px;
  }

  .capabilities,
  .expiry-cell,
  .online-cell {
    line-height: 1.45;
  }
}
