:root {
  color-scheme: dark;
  --bg: #09131e;
  --panel: #111f2d;
  --panel-2: #152838;
  --field: #0a1824;
  --line: #294052;
  --line-strong: #3a566a;
  --text: #edf5f7;
  --muted: #a9bcc8;
  --teal: #43d6b2;
  --teal-ink: #05261f;
  --blue: #8ac7f2;
  --amber: #f2c56c;
  --red: #ff8f8f;
  --radius: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 80% 0%, #163343 0, transparent 36%),
    linear-gradient(135deg, #09131e, #0d1d2a 58%, #0c2630);
  background-attachment: fixed;
  font: 14px/1.5 Inter, system-ui, "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--teal); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.app { max-width: 1440px; margin: auto; padding: 26px; }

.skip {
  position: absolute; left: -999px; top: 8px; z-index: 10;
  background: var(--teal); color: var(--teal-ink); padding: 8px 12px; border-radius: 8px; font-weight: 700;
}
.skip:focus { left: 8px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- topo ---------- */
.top, .brand, .live, .hero, .results-head, footer, .card-top, .card-foot, .head-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.top { margin-bottom: 34px; }
.brand { justify-content: flex-start; gap: 12px; color: inherit; text-decoration: none; }
.logo {
  height: 43px; width: 43px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(140deg, #4be2ba, #147c83); color: var(--teal-ink); font-size: 22px; font-weight: 900;
}
.brand b { display: block; letter-spacing: .1em; font-size: 18px; }
.brand small { display: block; font-size: 12px; color: var(--muted); letter-spacing: .1em; }

.live {
  border: 1px solid #24584f; background: #10342f; color: #9debd8;
  border-radius: 99px; padding: 8px 12px; font-size: 12px;
}
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.live[data-state="busy"] { border-color: #6b5a2c; background: #3a3217; color: var(--amber); }
.live[data-state="busy"] i { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.live[data-state="error"] { border-color: #6b3434; background: #3a1c1c; color: var(--red); }
.live[data-state="error"] i { background: var(--red); box-shadow: 0 0 10px var(--red); }

/* ---------- hero ---------- */
.hero { align-items: flex-end; margin-bottom: 22px; }
.eyebrow { font-size: 12px; color: var(--teal); letter-spacing: .14em; font-weight: 800; }
.hero h1 { font-size: clamp(29px, 4vw, 44px); line-height: 1.07; letter-spacing: -.04em; margin: 10px 0; }
.hero h1 em { font-style: normal; color: #73d9c2; }
.hero p { max-width: 700px; color: var(--muted); margin: 0; }
.source-pill {
  white-space: nowrap; color: var(--muted); font-size: 12px; letter-spacing: .08em;
  border: 1px solid var(--line); padding: 10px 13px; border-radius: 10px;
}
.source-pill strong { color: var(--teal); margin-left: 8px; }

/* ---------- KPIs ---------- */
.stats { margin: 22px 0; }
.stats dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0; }
.stat, .filters, .card {
  background: rgba(17, 31, 45, .92); border: 1px solid var(--line); border-radius: var(--radius);
}
.stat { padding: 16px; }
.stat dt { color: var(--muted); font-size: 12px; }
.stat dd { margin: 4px 0; font-size: 27px; font-weight: 700; }
.stat small { display: block; color: var(--teal); font-size: 12px; }
.modality-counts { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 2px 0; padding: 0; color: var(--muted); font-size: 12px; }
.modality-counts b { color: var(--text); }

/* ---------- filtros ---------- */
.filters { padding: 16px; }
.filter-grid {
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: 1.1fr .8fr 1.2fr 1.3fr 1fr auto;
}
.filter-grid label { display: block; color: var(--muted); font-size: 12px; }
.filter-grid select, .filter-grid input {
  display: block; width: 100%; margin-top: 6px; min-width: 0;
  background: var(--field); color: var(--text); border: 1px solid #30485a; border-radius: 9px; padding: 11px;
  font: inherit;
}
.filter-grid select:focus-visible, .filter-grid input:focus-visible { border-color: var(--teal); outline-offset: 0; }
.primary {
  border: 0; border-radius: 9px; background: var(--teal); color: var(--teal-ink);
  font-weight: 800; padding: 12px 15px; white-space: nowrap; cursor: pointer;
}
.primary span { font-size: 17px; margin-left: 7px; }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .55; cursor: progress; }

/* ---------- abas e ferramentas ---------- */
.results-head { margin: 18px 0 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--field); }
.tabs button { background: transparent; border: 0; color: var(--muted); padding: 9px 14px; border-radius: 8px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: #194148; color: #a9f4df; }
.head-tools { gap: 8px; }
.btn-secondary {
  background: #203849; border: 1px solid #355166; color: var(--text);
  padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 12px;
}
.btn-secondary:hover:not(:disabled) { border-color: var(--teal); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary[aria-pressed="true"] { background: #194148; border-color: var(--teal); color: #a9f4df; }
.status { color: var(--muted); font-size: 12px; margin-bottom: 10px; min-height: 18px; }

/* ---------- avisos ---------- */
.banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; font-size: 12px; border: 1px solid; }
.banner-warn { background: #3a3217; border-color: #6b5a2c; color: #f6dc9c; }
.banner-dev { background: #1b2a4a; border-color: #35508a; color: #b9cdf5; }
.notice { grid-column: 1 / -1; text-align: center; padding: 38px 20px; border: 1px dashed #355166; border-radius: var(--radius); color: var(--muted); }
.notice.error { border-color: #6b3434; color: #ffc9c9; }
.notice p, .error-list { margin: 10px 0 0; font-size: 12px; }
.error-list { text-align: left; display: inline-block; }

/* ---------- cards ---------- */
.results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.results:focus { outline: none; }
.card { padding: 17px; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; }
.card:hover { border-color: #4b9188; transform: translateY(-1px); }
.card-top { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
.card-top .fav { margin-left: auto; }
.tag {
  font-size: 12px; background: #17364b; color: #a6d7f4; padding: 4px 9px; border-radius: 6px; font-weight: 600;
}
.urgency-ok { background: #103a34; color: #9debd8; }
.urgency-soon { background: #3a3217; color: var(--amber); }
.urgency-urgent { background: #4a2020; color: #ffb3b3; }
.urgency-closed, .urgency-unknown { background: #26323b; color: var(--muted); }
.fav {
  background: transparent; border: 1px solid transparent; color: var(--amber);
  font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 8px; cursor: pointer;
}
.fav:hover { border-color: var(--line-strong); }
.card-title {
  font-size: 16px; line-height: 1.4; margin: 12px 0 5px;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.buyer { font-size: 13px; color: #c3d4dc; margin: 0 0 11px; }
.meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0; }
.meta div { padding: 9px; background: #0b1925; border-radius: 8px; min-width: 0; }
.meta dt { color: var(--muted); font-size: 12px; }
.meta dd { margin: 0; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.meta-4 { grid-template-columns: repeat(4, 1fr); margin-top: 14px; }
.why { display: flex; align-items: baseline; gap: 8px; margin-top: 11px; flex-wrap: wrap; }
.why-label { color: var(--muted); font-size: 12px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.chip { font-size: 12px; background: #12303a; color: #9debd8; border: 1px solid #24584f; padding: 2px 8px; border-radius: 99px; }
.card-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: auto; flex-wrap: wrap; }
.card .meta + .why, .card .meta { margin-bottom: 0; }
.card-foot { margin-top: 14px; }
.card-foot small { color: #a5e6d5; font-size: 12px; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.link-primary { color: var(--teal); text-decoration: none; font-size: 13px; font-weight: 800; }
.link-secondary { color: var(--blue); text-decoration: none; font-size: 12px; }
.link-primary:hover, .link-secondary:hover { text-decoration: underline; }

/* ---------- carregamento ---------- */
.skeleton { min-height: 230px; gap: 14px; }
.skeleton i {
  display: block; height: 16px; border-radius: 6px;
  background: linear-gradient(90deg, #17293a 25%, #203449 50%, #17293a 75%); background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton i:nth-child(1) { width: 45%; }
.skeleton i:nth-child(2) { width: 90%; height: 54px; }
.skeleton i:nth-child(3) { width: 70%; }
.spinner {
  display: inline-block; width: 15px; height: 15px; border: 2px solid #45616f; border-top-color: var(--teal);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- paginação e rodapé ---------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 18px 0 4px; color: var(--muted); }
footer {
  margin-top: 18px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px;
  background: #0b1a26; color: var(--muted); font-size: 12px;
}
.disclaimer { color: var(--muted); font-size: 12px; }

/* ---------- detalhe ---------- */
dialog {
  width: min(860px, calc(100% - 24px)); max-height: calc(100vh - 32px); padding: 0;
  background: #102131; color: var(--text); border: 1px solid var(--line-strong); border-radius: 16px;
}
dialog::backdrop { background: rgba(0, 10, 18, .7); }
.dialog-inner { padding: 25px; }
.close {
  float: right; background: #203849; border: 1px solid #466174; color: #fff;
  border-radius: 8px; padding: 2px 11px; font-size: 22px; cursor: pointer;
}
.detail-title { font-size: 22px; margin: 10px 0; }
.detail-object { white-space: pre-wrap; color: #c3d4dc; overflow-wrap: anywhere; }
.detail-links { display: flex; gap: 18px; flex-wrap: wrap; margin: 16px 0; }
.detail-extra h3 { font-size: 14px; margin: 18px 0 8px; color: #a9f4df; }
.muted { color: var(--muted); }
.files { padding-left: 18px; margin: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #0b1925; }
td.num { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .filter-grid { grid-template-columns: repeat(3, 1fr); }
  .results { grid-template-columns: 1fr; }
  .meta-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .app { padding: 14px; }
  .top { margin-bottom: 22px; }
  .brand small { display: none; }
  .live { flex-shrink: 0; }
  .hero { display: block; }
  .source-pill { display: inline-block; margin-top: 14px; }
  .stats dl { grid-template-columns: repeat(2, 1fr); }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .search-field, .primary { grid-column: 1 / -1; }
  .results-head { align-items: flex-start; flex-direction: column; }
  .card-foot { align-items: flex-start; }
  footer { align-items: flex-start; flex-direction: column; }
  .dialog-inner { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
