:root {
  --bg: #0f1420;
  --bg-soft: #161d2e;
  --bg-card: #1a2338;
  --border: #2a3550;
  --text: #e6ecf7;
  --text-dim: #93a0b8;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.15);
  --green: #35c47c;
  --amber: #f5b942;
  --red: #f06a6a;
  --radius: 10px;
  font-size: 15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  min-height: 100vh;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 1.8rem; }
.brand h1 { font-size: 1.1rem; font-weight: 700; }
.subtitle { font-size: 0.75rem; color: var(--text-dim); }

.stats { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.stat-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.stat-chip b { color: var(--text); font-variant-numeric: tabular-nums; }

.topbar-actions { display: flex; gap: 8px; }

/* ---------- buttons / inputs ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  transition: 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

input, select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
small { color: var(--text-dim); font-size: 0.72rem; display: block; margin-top: 4px; }

/* ---------- layout ---------- */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  width: 290px;
  flex-shrink: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--border);
  min-height: calc(100vh - 65px);
  position: sticky;
  top: 65px;
  max-height: calc(100vh - 65px);
  overflow-y: auto;
}
.filter-group > label, .filter-group legend {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 600;
}
.filter-group.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline-checks { display: flex; gap: 14px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 0.83rem; cursor: pointer; }
.check input { width: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  user-select: none;
  transition: 0.12s;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

.check-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow-y: auto; }
.check-list.two { display: grid; grid-template-columns: 1fr 1fr; max-height: none; }
.check-list label { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; cursor: pointer; color: var(--text); }
.check-list input { width: auto; }

.mini-link {
  background: none; border: none; color: var(--accent);
  font-size: 0.7rem; cursor: pointer; text-transform: none; letter-spacing: 0;
}

/* ---------- results ---------- */
.content { flex: 1; padding: 18px 22px; min-width: 0; }

.results-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; color: var(--text-dim); font-size: 0.85rem;
}
.page-size { display: flex; align-items: center; gap: 8px; }
.page-size select { width: auto; }

.results { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.card-orgao { font-weight: 600; font-size: 0.92rem; }
.card-local { color: var(--text-dim); font-size: 0.8rem; }
.card-objeto { font-size: 0.85rem; color: var(--text); line-height: 1.45; margin-bottom: 10px; }
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.badge {
  font-size: 0.7rem; padding: 2px 9px; border-radius: 12px;
  border: 1px solid var(--border); color: var(--text-dim);
}
.badge.ti { background: rgba(53, 196, 124, 0.12); border-color: var(--green); color: var(--green); font-weight: 700; }
.badge.valor { color: var(--amber); border-color: rgba(245, 185, 66, 0.4); }
.badge.prazo-ok { color: var(--green); border-color: rgba(53, 196, 124, 0.4); }
.badge.prazo-perto { color: var(--amber); border-color: rgba(245, 185, 66, 0.4); }
.badge.prazo-fim { color: var(--red); border-color: rgba(240, 106, 106, 0.4); }

.empty {
  text-align: center; padding: 60px 20px; color: var(--text-dim);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty .big { font-size: 2.5rem; margin-bottom: 10px; }

/* ---------- pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.page-btn {
  min-width: 34px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); cursor: pointer; font-size: 0.8rem;
}
.page-btn.current { background: var(--accent); border-color: var(--accent); font-weight: 700; }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- drawer ---------- */
.drawer-overlay, .modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 8, 15, 0.65); z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 95vw);
  background: var(--bg-soft); border-left: 1px solid var(--border);
  z-index: 50; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(0,0,0,0.5);
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.drawer-head h2 { font-size: 1rem; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.detail-section { margin-bottom: 20px; }
.detail-section h3 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin-bottom: 8px;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.detail-item .k { font-size: 0.7rem; color: var(--text-dim); }
.detail-item .v { font-size: 0.85rem; }
.objeto-full { font-size: 0.88rem; line-height: 1.5; background: var(--bg); padding: 12px; border-radius: 8px; border: 1px solid var(--border); }
.drawer-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.drawer-links a { text-decoration: none; }

.itens-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.itens-table th, .itens-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.itens-table th { color: var(--text-dim); font-weight: 600; }
.itens-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
.modal-overlay { display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal {
  width: min(560px, 94vw); max-height: 90vh; overflow-y: auto;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 14px; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 1rem; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); }

.sync-progress { margin-top: 4px; }
.progress-track { height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.4s; }
.progress-text { font-size: 0.78rem; color: var(--text-dim); margin-top: 8px; line-height: 1.5; }

/* ---------- rodapé ---------- */
.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 20px 30px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  text-align: center;
}
.footer-logo { height: 44px; max-width: 220px; object-fit: contain; }
.footer p { font-size: 0.8rem; color: var(--text-dim); line-height: 1.5; }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-login { border-top: 1px solid var(--border); background: transparent; padding: 16px 0 0; margin-top: 4px; }
.footer-login .footer-logo { height: 34px; }

.hidden { display: none !important; }

.loading { text-align: center; padding: 40px; color: var(--text-dim); }

/* ---------- responsivo ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; min-height: 0; border-right: none; border-bottom: 1px solid var(--border); }
  .detail-grid { grid-template-columns: 1fr; }
}
