:root {

  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #12193b;
  --muted: #4a5a97;
  --line: #d6ddf2;
  --accent: #1133af;
  --accent-strong: #0d2890;
  --soft: #eef2ff;
  --warn: #9a4b06;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 15% 10%, #e6ebff, var(--bg) 35%, #eef2ff 100%);
  color: var(--text);
  font: 16px/1.45 "Poppins", "Segoe UI", Tahoma, sans-serif;
}

.app {
  width: min(1180px, 94vw);
  margin: 28px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 12px 34px rgba(16, 42, 128, 0.08);
}

.masthead {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.logo-link {
  display: block;
}

.logo {
  width: 160px;
  max-width: 100%;
  display: block;
}

/* When embedded in an iframe (the normal case on taxpolicy.org.uk) the host
   page already shows our branding, so hide the logo and let the heading fill
   the row. */
.embedded .logo-link {
  display: none;
}

.embedded .masthead {
  grid-template-columns: 1fr;
}


h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.1;
}

.summary {
  margin: 8px 0 0;
  color: var(--muted);
}

.chart-panel {
  margin: 0 0 18px;
  padding: 14px 12px 34px;
  border: 1px solid #dde3fb;
  border-radius: 12px;
  background: linear-gradient(180deg, #fcfdff, #f5f8ff);
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 120px;
  padding: 10px 14px 0;
  border-bottom: 2px solid #9aa9e0;
}


.bucket {
  flex: 1 1 0;
  min-width: 8px;
  height: 110px;
  position: relative;
  display: flex;
  align-items: flex-end;
}

.bucket-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 0;
  background: var(--accent);
  border: 1px solid var(--accent-strong);
  border-bottom: 0;
  padding: 0;
}

.bucket-bar:hover {
  background: var(--accent-strong);
}


.bucket-label {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  color: #253d93;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.filters {
  display: grid;
  grid-template-columns: 1.6fr 1.1fr 1.2fr auto auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field span {
  color: #2f4388;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fcfdff;
  color: var(--text);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

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

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

.clear-btn {
  background: var(--soft);
  border: 1px solid #b7c6fb;
  color: var(--accent);
}

.clear-btn:hover {
  background: var(--accent);
  color: #ffffff;
}

.hint {
  margin: 0 0 14px;
  padding: 9px 12px;
  background: #fff7ec;
  border: 1px solid #f0dcbb;
  border-radius: 10px;
  color: var(--warn);
  font-size: 0.86rem;
}

.status {
  margin: 10px 0 14px;
  color: var(--muted);
}

.results {

  margin: 0;
  padding-left: 22px;
}

.results li {
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e4e9fa;
}

.result-title {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.result-title:hover,
.result-title:focus {
  text-decoration: underline;
}

.result-meta {
  margin-top: 5px;
  color: #2f4388;
  font-size: 0.84rem;
}

.result-snippet {
  margin: 7px 0 0;
  color: var(--text);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.result-actions a {
  color: var(--accent);
  background: var(--soft);
  border: 1px solid #c4cff8;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.result-actions a:hover,
.result-actions a:focus {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.pagination {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

mark {
  background: #1133af;
  color: #ffffff;
  padding: 0 2px;
  border-radius: 3px;
}

@media (max-width: 900px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .field-query {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .app {
    margin: 16px auto;
    padding: 16px;
  }

  .masthead {
    grid-template-columns: 1fr;
  }

  .logo {
    width: 145px;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}
