:root {
  --navy: #0c335c;
  --blue: #1565b8;
  --gold: #d98200;
  --paper: #eef3f8;
  --card: #ffffff;
  --ink: #1b2838;
  --muted: #5b6b7c;
  --line: #d7e1ec;
  --ok: #157a3f;
  --shadow: 0 10px 30px rgba(12, 51, 92, 0.08);
  --tap: 44px;
}

* { box-sizing: border-box; }
html {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: clip;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}
body {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "Liberation Sans", Calibri, sans-serif;
  background:
    radial-gradient(1200px 420px at 0 -80px, rgba(21, 101, 184, 0.18), transparent),
    var(--paper);
  color: var(--ink);
}
img, svg, video {
  max-width: 100%;
  height: auto;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  flex-shrink: 0;
  gap: 12px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(90deg, var(--navy), #13487f);
  color: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand > div { min-width: 0; }
.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.brand p {
  margin: 2px 0 0;
  color: #cfe3f7;
  font-size: 13px;
}
.brand-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 56px;
  height: 44px;
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 12px;
}
.catalog-meta {
  margin: 0;
  color: #cfe3f7;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.top-right {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
}
.site-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  min-height: var(--tap);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  touch-action: manipulation;
}
.site-nav a:hover {
  background: rgba(255,255,255,0.12);
}
.site-nav a[aria-current="page"] {
  background: var(--gold);
  color: #2b1a00;
  border-color: var(--gold);
}

.layout {
  flex: 1 0 auto;
  align-content: start;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

.search-panel, .detail {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.search-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-bottom: 4px;
}
.search-tabs {
  display: inline-flex;
  align-items: stretch;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f7fb;
  gap: 2px;
}
.search-tab {
  appearance: none;
  border: 0;
  margin: 0;
  min-height: 34px;
  padding: 6px 16px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
}
.search-tab[aria-selected="true"] {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(12, 51, 92, 0.12);
}
.search-tab:focus-visible {
  outline: 2px solid rgba(21, 101, 184, 0.35);
  outline-offset: 1px;
}
.combobox {
  position: relative;
  z-index: 5;
  isolation: isolate;
  min-width: 0;
}
#q {
  width: 100%;
  max-width: 100%;
  font: inherit;
  font-size: 16px;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
#q:focus {
  outline: 2px solid rgba(21, 101, 184, 0.35);
  border-color: var(--blue);
}
.subitens-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.subitens-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}
.subitens-toggle.is-disabled,
.subitens-toggle:has(input:disabled) {
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}
.subitens-toggle:has(input:disabled) input {
  cursor: not-allowed;
}
.hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.results {
  position: static;
  z-index: 30;
  margin: 8px 0 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: min(55vh, 380px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}
.results[hidden] { display: none; }
.results li {
  margin: 0;
}
.results button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  min-height: var(--tap);
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  pointer-events: auto;
  touch-action: manipulation;
}
.results button:hover,
.results button.active {
  background: #e7f1fb;
}
.results .code {
  font-weight: 700;
  color: var(--navy);
  margin-right: 8px;
  overflow-wrap: anywhere;
}
.results .page-range {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.results .row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
}
.results .title {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.results .file {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.results .empty {
  padding: 14px 12px;
  color: var(--muted);
}

.detail.hidden { display: none; }
.detail-head {
  display: flex;
  gap: 8px 10px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}
.kind {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #e7f1fb;
  color: var(--blue);
}
.kind.anexo { background: #fff3de; color: #b35b00; }
.kind.insumo { background: #e8f7f1; color: #0f6b4c; }
.detail-head strong {
  color: var(--navy);
  font-size: 18px;
  overflow-wrap: anywhere;
}
.detail-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.online-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ok);
  background: #e4f6ea;
}
.online-badge.hidden { display: none; }
.download-slice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--gold);
  color: #2b1a00;
  font-weight: 700;
  text-decoration: none;
  font-size: 13px;
  touch-action: manipulation;
}
.download-slice:hover { filter: brightness(1.05); }
.download-slice.hidden { display: none; }
.download-all {
  background: var(--navy);
  color: #fff;
}
.kind.composicao-filho { background: #e7f1fb; color: var(--blue); }
.subitens {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  min-width: 0;
  max-width: 100%;
}
.subitens.hidden { display: none; }
/* Same family/size vibe as #detail-title; stronger weight; ALL CAPS; centered. */
.subitens > .subitens-title {
  margin: 10px 0 14px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--ink);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
}
.subitens-child-heading {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
}
.subitens-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  /* Shorter visual break on phones; full viewport on desktop (see media query). */
  min-height: min(48vh, 22rem);
  align-content: start;
}
.subitens-list > .empty {
  padding: 10px 0;
  color: var(--muted);
  font-size: 13px;
}
.subitens-table-wrap {
  margin: 0;
  padding: 0;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.subitens-table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-size: 13px;
}
.subitens-table th,
.subitens-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.subitens-table th {
  background: #f4f7fb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.subitens-table tbody tr:last-child td {
  border-bottom: 0;
}
.subitens-table .col-tipo {
  width: 3.2rem;
  color: var(--muted);
  font-weight: 700;
}
.subitens-table .col-code {
  width: 5.5rem;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}
.subitens-table .col-und,
.subitens-table .col-coef {
  width: 4.5rem;
  color: var(--muted);
  white-space: nowrap;
}
.subitens-table .col-desc {
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.subitens-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.subitens-pages {
  min-width: 0;
  max-width: 100%;
}
.subitens-pages figure {
  margin: 0 0 14px;
  max-width: 100%;
}
.detail h1 {
  margin: 10px 0 6px;
  font-size: 17px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.detail #detail-file {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.pages {
  display: grid;
  gap: 16px;
  max-width: 100%;
  min-width: 0;
}
.pages figure {
  margin: 0;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  max-width: 100%;
}
.pages figcaption {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.pages img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  background: #fff;
}

.site-footer {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin-top: auto;
  width: 100%;
  border-top: 1px solid var(--line);
  background: #f7fafc;
  pointer-events: auto;
}
.footer-inner {
  width: min(calc(100% - 32px), 980px);
  margin-inline: auto;
  padding-block: 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px 16px;
  min-width: 0;
}
.footer-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  min-width: 0;
  overflow-wrap: anywhere;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-links a {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  touch-action: manipulation;
}
.footer-links a:hover,
.footer-links a:focus-visible {
  background: #e7f1fb;
  color: var(--blue);
}

@media (min-width: 721px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 28px;
  }
  .brand { gap: 14px; }
  .brand strong { font-size: inherit; }
  .brand-mark {
    width: 64px;
    height: 48px;
    font-size: 13px;
  }
  .top-right {
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 8px;
    margin-left: auto;
  }
  .site-nav {
    justify-content: flex-end;
    width: auto;
  }
  .site-nav a {
    flex: 0 0 auto;
    min-height: 0;
    padding: 8px 12px;
  }
  .catalog-meta {
    text-align: right;
    max-width: 28rem;
  }
  .layout {
    padding: 28px 24px 48px;
    gap: 18px;
  }
  .search-panel, .detail {
    padding: 20px 22px;
  }
  #q {
    font-size: 18px;
    padding: 14px 16px;
  }
  .results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    margin: 0;
    max-height: 420px;
  }
  .results button {
    min-height: 0;
    padding: 10px 12px;
  }
  .detail-head strong { font-size: 20px; }
  .detail h1,
  .subitens > .subitens-title { font-size: 18px; }
  .subitens-list {
    min-height: 100vh;
    min-height: 100dvh;
  }
  .subitens-table {
    min-width: 0;
  }
  .download-slice {
    min-height: 28px;
    padding: 4px 12px;
  }
  .footer-inner {
    width: min(calc(100% - 48px), 980px);
    padding-block: 18px 24px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
