@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@600;700;800&family=Rajdhani:wght@500;600;700&family=Exo+2:wght@400;500;600;700&display=swap");

:root {
  --background: 218 60% 5%;
  --foreground: 200 30% 92%;
  --card: 217 50% 8%;
  --primary: 190 95% 55%;
  --primary-foreground: 218 60% 5%;
  --muted: 216 40% 12%;
  --muted-foreground: 205 20% 62%;
  --accent: 205 90% 60%;
  --border: 205 60% 22%;
  --input: 205 50% 18%;
  --scba: #0bb8da;
  --radius: 0.4rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  font-family: "Exo 2", system-ui, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
}
a { color: hsl(var(--primary)); }
.font-display { font-family: Orbitron, sans-serif; }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: .75rem 1.25rem; background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-family: Rajdhani, sans-serif; text-transform: uppercase; letter-spacing: .08em;
}
.skip-link:focus { left: 1rem; }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0 1.4rem;
  height: 3.5rem;
  background: #fff;
  border-bottom: 1px solid rgb(226 232 240 / 0.8);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.06);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: #244161; }
.brand img { width: 36px; height: 36px; object-fit: contain; }
.brand-name {
  font-family: Orbitron, sans-serif; letter-spacing: 0.12em; font-size: 0.9rem;
  color: #244161;
}
.brand-sub {
  display: block; font-family: Rajdhani, sans-serif; font-size: 0.7rem;
  letter-spacing: 0.18em; text-transform: uppercase; color: #64748b;
}
nav { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; }
.nav-btn, header button, form button, .tiny-btn {
  font-family: Rajdhani, sans-serif; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; border: 1px solid hsla(190, 95%, 60%, 0.5);
  background: transparent; color: hsl(var(--primary)); padding: 0.4rem 0.75rem; cursor: pointer;
}
header .nav-btn {
  border: none;
  color: #475569;
  background: transparent;
}
header .nav-btn.active {
  color: #244161;
  background: rgb(241 245 249);
  font-weight: 700;
}
header #btn-logout {
  color: #64748b;
  border: none;
}
header #who { color: #334155; font-size: 0.8rem; }
form button[type="submit"] {
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
}
.tiny-btn { padding: 0.2rem 0.5rem; font-size: 0.7rem; }

main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.85rem 1.25rem 2.5rem;
}
#view-search { width: 100%; }
.login-panel { max-width: 480px; margin: 2rem auto; }
.glass {
  background: linear-gradient(150deg, hsla(216, 50%, 12%, 0.72), hsla(217, 55%, 7%, 0.6));
  backdrop-filter: blur(10px);
  border: 1px solid hsla(190, 90%, 60%, 0.22);
  padding: 1.15rem; margin-bottom: 1rem; border-radius: var(--radius);
}
h1 {
  font-family: Orbitron, sans-serif; font-size: 1.05rem; letter-spacing: 0.08em;
  margin: 0 0 0.75rem; color: hsl(var(--primary));
}
h2 {
  font-family: Rajdhani, sans-serif; text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 0.9rem; margin: 0;
}
label { display: block; margin: 0.55rem 0; font-size: 0.82rem; font-weight: 600; color: hsl(var(--muted-foreground)); }
input, select {
  width: 100%; margin-top: 0.28rem; padding: 0.5rem 0.6rem;
  border: 1px solid hsl(var(--border)); background: hsl(var(--input));
  color: hsl(var(--foreground)); border-radius: calc(var(--radius) - 2px);
}
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; align-items: end; }
.actions { margin-top: 0.5rem; }
.switch-row {
  display: flex; align-items: center; gap: 0.55rem;
  margin: 0.75rem 0 0.25rem; font-size: 0.85rem; color: hsl(var(--foreground)); cursor: pointer;
}
.search-box {
  padding: 0.45rem 0.65rem 0.4rem;
  margin-bottom: 0.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.search-box h1 {
  font-size: 0.7rem;
  margin: 0 0 0.3rem;
}
.search-box #form-search { display: grid; gap: 0.3rem; width: 100%; min-width: 0; }
.search-box label { margin: 0; font-size: 0.65rem; min-width: 0; }
.search-box input,
.search-box select {
  margin-top: 0.12rem;
  padding: 0.28rem 0.45rem;
  font-size: 0.82rem;
  min-width: 0;
  max-width: 100%;
}
.search-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: end;
  width: 100%;
  min-width: 0;
}
.query-field { min-width: 0; }
.date-row {
  display: grid;
  grid-template-columns: 8.6rem 8.6rem;
  gap: 0.4rem;
  min-width: 0;
}
.search-line.tools {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}
.search-box .switch-row {
  margin: 0;
  font-size: 0.75rem;
  gap: 0.45rem;
}
.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.switch-ui {
  width: 2.15rem;
  height: 1.2rem;
  border-radius: 999px;
  background: hsl(var(--input));
  border: 1px solid hsl(var(--border));
  position: relative;
  flex-shrink: 0;
  display: inline-block;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.88rem;
  height: 0.88rem;
  border-radius: 50%;
  background: #8aa0b5;
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch-input:checked + .switch-ui {
  background: hsla(190, 95%, 55%, 0.28);
  border-color: hsl(var(--primary));
}
.switch-input:checked + .switch-ui::after {
  transform: translateX(0.92rem);
  background: hsl(var(--primary));
}
.switch-input:focus-visible + .switch-ui {
  outline: 2px solid hsl(var(--primary));
  outline-offset: 2px;
}
.search-box .row.actions {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}
.search-box .row.actions button {
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
}
.search-box .row.actions button:disabled { opacity: 0.45; cursor: not-allowed; }
.search-box .row.actions button[hidden] { display: none !important; }
.search-box .icon-btn {
  width: 2.05rem;
  height: 2.05rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.search-box .icon-btn svg { width: 1.15rem; height: 1.15rem; display: block; }
.logout-icon { display: none; width: 1.25rem; height: 1.25rem; }
.adv-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  min-width: 0;
}
.adv-panel {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.35);
  min-width: 0;
}
.adv-panel > summary {
  list-style: none;
  cursor: pointer;
  font-family: Rajdhani, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--primary));
  padding: 0.28rem 0.5rem;
}
.adv-panel > summary::-webkit-details-marker { display: none; }
.adv-body { padding: 0.35rem 0.5rem 0.5rem; display: grid; gap: 0.35rem; }
.near-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}
.adv-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.adv-row select, .adv-body select, .adv-row input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}
.adv-row button {
  padding: 0.28rem 0.5rem;
  font-size: 0.7rem;
  flex: 0 0 auto;
}
.search-box .stats { margin-top: 0.25rem; }
.search-box #search-status { margin: 0.15rem 0 0; font-size: 0.75rem; }
.search-box #search-status:empty,
.search-box .stats:empty { display: none; }
@media (min-width: 1400px) {
  .search-layout { grid-template-columns: 360px minmax(0, 1fr); }
}
.hint { color: hsl(var(--muted-foreground)); font-size: 0.9rem; line-height: 1.5; }
.hint.tiny { font-size: 0.75rem; }
.error { color: hsl(0 72% 65%); }
.hidden { display: none !important; }
.site-link { font-family: Rajdhani, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; }

.search-layout {
  display: grid;
  grid-template-columns: minmax(280px, 22vw) minmax(0, 1fr);
  grid-template-areas:
    "filters search"
    "filters results";
  gap: 1rem;
  align-items: start;
  width: 100%;
}
.search-box { grid-area: search; min-width: 0; }
.filters-pane { grid-area: filters; min-width: 0; }
.results-pane { grid-area: results; min-width: 0; }
.pane-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; gap: 0.5rem; }
.pane-head h2 { pointer-events: none; }
.drawer-hint { display: none; font-size: 0.65rem; color: hsl(var(--muted-foreground)); font-family: Rajdhani, sans-serif; text-transform: uppercase; letter-spacing: 0.06em; }
.filters-drawer { border: none; }
.filters-drawer > summary { list-style: none; cursor: default; }
.filters-drawer > summary::-webkit-details-marker { display: none; }
.pane-tools { display: flex; justify-content: flex-end; margin-bottom: 0.35rem; }
.filters-pane {
  min-width: 0;
}
.registro-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 0.75rem; font-size: 0.75rem; }
.radio { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; color: hsl(var(--foreground)); }
.radio input { width: auto; margin: 0; }

.filtros-tree details { border-bottom: 1px solid hsl(var(--border) / 0.5); padding-bottom: 0.25rem; margin-bottom: 0.25rem; }
.filtros-tree summary {
  list-style: none; cursor: pointer; font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0;
}
.filtros-tree summary::-webkit-details-marker { display: none; }
.filtros-tree label.org-row {
  display: flex; align-items: flex-start; gap: 0.4rem; font-size: 0.7rem; font-weight: 500;
  color: hsl(var(--muted-foreground)); padding: 0.2rem 0.15rem; margin: 0; cursor: pointer;
}
.filtros-tree label.org-row:hover { background: hsl(var(--muted) / 0.5); color: hsl(var(--foreground)); }
.filtros-tree input[type="checkbox"] { width: auto; margin: 0.15rem 0 0; accent-color: var(--scba); }
.filtros-tree .nest { padding-left: 0.55rem; }

.stats { margin-top: 0.75rem; font-size: 0.8rem; font-family: Rajdhani, sans-serif; }
.stats .warn {
  display: inline-block; margin-left: 0.4rem; padding: 0.15rem 0.45rem;
  border: 1px solid #eab30880; color: #eab308; font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.results-pane { min-height: 200px; }
.hit {
  background: #0c1724 !important;
  border: 1px solid #1f4a66;
  padding: 0.85rem; margin-bottom: 0.5rem; cursor: pointer;
  color: #d7e6f0 !important;
}
.hit:hover { border-color: hsl(var(--primary) / 0.55); }
.hit h3 { margin: 0 0 0.3rem; font-size: 0.92rem; color: #d7e6f0 !important; }
.meta { font-size: 0.72rem; color: #8aa0b5 !important; font-family: Rajdhani, sans-serif; }
.snippet {
  margin-top: 0.4rem; font-size: 0.82rem; line-height: 1.45;
  color: #d7e6f0 !important;
  background: transparent !important;
}
.snippet, .snippet * {
  color: #d7e6f0 !important;
  background: transparent !important;
  background-color: transparent !important;
}
.snippet b,
.snippet strong,
.snippet mark,
.snippet .text-indigo-600 {
  color: hsl(var(--primary)) !important;
  background: hsla(190, 95%, 55%, 0.16) !important;
  background-color: hsla(190, 95%, 55%, 0.16) !important;
  font-weight: 700;
}
.empty {
  text-align: center; color: hsl(var(--muted-foreground)); padding: 2.5rem 1rem; font-style: italic;
}
.empty strong { display: block; font-style: normal; margin-bottom: 0.35rem; color: hsl(var(--foreground)); }

ul { padding-left: 1.1rem; }
#dlg-doc {
  width: min(96vw, 1680px);
  max-width: 96vw;
  height: 92vh;
  max-height: 92vh;
  overflow: auto;
  padding: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsla(190, 95%, 60%, 0.4);
  border-radius: var(--radius);
}
#dlg-doc::backdrop { background: rgba(8, 16, 28, 0.78); }
.dlg-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.7rem 1.1rem;
  background: #fff;
  border-bottom: 1px solid rgb(226 232 240 / 0.8);
  color: #244161;
}
.dlg-bar strong {
  font-family: Rajdhani, sans-serif; font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.02em; color: #244161;
}
.dlg-bar .tiny-btn {
  color: #244161;
  border-color: rgb(203 213 225);
}
#dlg-body {
  padding: 1.35rem 1.75rem 2.2rem;
  font-size: 1.02rem;
  line-height: 1.7;
  color: hsl(var(--foreground)) !important;
  background: transparent !important;
}
#dlg-body html,
#dlg-body body,
#dlg-body .siaj-doc-html,
#dlg-body .prose,
#dlg-body .text-slate-800,
#dlg-body .text-slate-700,
#dlg-body .text-gray-800,
#dlg-body .bg-white,
#dlg-body [bgcolor],
#dlg-body [style*="background"] {
  background: transparent !important;
  background-color: transparent !important;
  max-width: none !important;
}
#dlg-body,
#dlg-body * {
  color: hsl(var(--foreground)) !important;
}
#dlg-body a { color: hsl(var(--primary)) !important; }
#dlg-body b,
#dlg-body strong,
#dlg-body mark,
#dlg-body .text-indigo-600,
#dlg-body .bg-indigo-50 {
  color: hsl(var(--primary)) !important;
  background: hsla(190, 95%, 55%, 0.16) !important;
  background-color: hsla(190, 95%, 55%, 0.16) !important;
}
#dlg-body h1, #dlg-body h2, #dlg-body h3 {
  color: hsl(var(--primary));
  font-family: Rajdhani, sans-serif;
  letter-spacing: 0.04em;
}
#dlg-body table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
#dlg-body td, #dlg-body th {
  border: 1px solid hsl(var(--border));
  padding: 0.3rem 0.5rem;
  color: hsl(var(--foreground));
}

@media (min-width: 961px) {
  .filters-pane {
    max-height: calc(100vh - 5.5rem);
    overflow: auto;
    position: sticky;
    top: 4.25rem;
  }
  .filters-drawer > summary { pointer-events: none; }
}

@media (max-width: 960px) {
  .top {
    height: 3rem;
    min-height: 3rem;
    flex-wrap: nowrap;
    align-items: center;
    padding: 0 0.65rem 0 0.5rem;
    gap: 0.35rem;
  }
  .brand { flex-shrink: 0; }
  .brand-text, .brand-name, .brand-sub { display: none; }
  .brand img { width: 28px; height: 28px; }
  nav {
    flex: 1;
    width: auto;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.15rem;
  }
  .nav-search { display: none !important; }
  header #who { display: none; }
  header #btn-install { font-size: 0.65rem; padding: 0.28rem 0.35rem; }
  header .nav-btn {
    padding: 0.28rem 0.4rem;
    font-size: 0.68rem;
  }
  header #btn-logout {
    margin-left: auto;
    padding: 0.3rem;
    color: #334155;
    flex-shrink: 0;
  }
  .logout-label { display: none; }
  .logout-icon { display: block; }
  main { padding: 0.55rem 0.7rem 1.5rem; }
  .search-layout {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }
  .search-box {
    order: 1;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0;
    width: 100%;
    max-width: 100%;
  }
  .search-line,
  .search-line.tools {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }
  .date-row {
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .date-row input[type="date"] {
    min-width: 0;
    width: 100%;
  }
  .search-box .row.actions {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }
  .search-box .row.actions button:not(.icon-btn) {
    width: auto;
    flex: 1 1 auto;
  }
  .search-box .icon-btn { width: 2.15rem; height: 2.15rem; }
  .adv-tools { grid-template-columns: 1fr; }
  .filters-pane {
    order: 2;
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0;
  }
  .results-pane { order: 3; }
  .filters-drawer > summary { cursor: pointer; margin: 0; }
  .drawer-hint { display: inline; }
  .filters-help { display: none; }
  .filters-body { padding-top: 0.35rem; }
  .filtros-tree {
    max-height: 40vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .search-box input { font-size: 16px; padding: 0.45rem 0.5rem; }
  .hit { padding: 0.7rem; }
  .hit h3 { font-size: 0.86rem; }
  #dlg-doc {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }
  .dlg-bar { padding: 0.55rem 0.75rem; }
  .dlg-bar strong { font-size: 0.82rem; }
  #dlg-body { padding: 0.9rem 0.85rem 1.5rem; font-size: 0.95rem; }
}

.pwa-sheet {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(6, 12, 22, 0.72);
  padding: 1rem;
}
.pwa-sheet.hidden { display: none !important; }
.pwa-card {
  width: min(100%, 28rem);
  background: #0c1724;
  color: #d7e6f0;
  border: 1px solid #1f4a66;
  border-radius: 0.7rem;
  padding: 1.1rem 1.15rem 1.2rem;
}
.pwa-card h2 {
  font-family: Orbitron, sans-serif;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  color: #2ad4f0;
  margin: 0.5rem 0 0.4rem;
  text-transform: none;
}
.pwa-steps {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.15rem;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #d7e6f0;
}
.pwa-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.pwa-primary {
  flex: 1;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  padding: 0.55rem 0.8rem;
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}
#pwa-dismiss-btn {
  flex: 1;
  background: transparent;
  color: #8aa0b5;
  border: 1px solid #1f4a66;
  padding: 0.55rem 0.8rem;
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}
@media (display-mode: standalone) {
  #pwa-sheet, #btn-install { display: none !important; }
}
