:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --accent: #1f6feb;
  --accent-soft: #e6effd;
  --ok: #1a7f37;
  --ok-soft: #dcf5e3;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --danger: #cf222e;
  --danger-soft: #ffe5e7;
  --mark: #fff0a8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --border: #2b323c;
    --text: #e6e9ee;
    --muted: #97a3b3;
    --accent: #5b9dff;
    --accent-soft: #1b2a42;
    --ok: #4ac26b;
    --ok-soft: #15301f;
    --warn: #d4a72c;
    --warn-soft: #2e2610;
    --danger: #ff6b6b;
    --danger-soft: #3a1a1d;
    --mark: #5c4d0e;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1e232b;
  --border: #2b323c;
  --text: #e6e9ee;
  --muted: #97a3b3;
  --accent: #5b9dff;
  --accent-soft: #1b2a42;
  --ok: #4ac26b;
  --ok-soft: #15301f;
  --warn: #d4a72c;
  --warn-soft: #2e2610;
  --danger: #ff6b6b;
  --danger-soft: #3a1a1d;
  --mark: #5c4d0e;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 0.6rem; }
h3 { font-size: 1rem; margin: 0 0 0.3rem; }
p { margin: 0.3rem 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
mark, b.hl { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); min-height: 1.2em; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.2rem;
  padding: 0.6rem max(16px, calc((100vw - 1100px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand.big { font-size: 1.4rem; margin-bottom: 0.3rem; }
#nav { display: flex; gap: 0.2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
#nav a { color: var(--muted); padding: 0.35rem 0.7rem; border-radius: 8px; white-space: nowrap; font-weight: 500; }
#nav a:hover { background: var(--surface-2); text-decoration: none; }
#nav a.active { color: var(--accent); background: var(--accent-soft); }
main { max-width: 1100px; margin: 0 auto; padding: 1.4rem 16px 4rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 0.8rem; }
.grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .num { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .lbl { color: var(--muted); font-size: 0.85rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.btn {
  font: inherit; font-weight: 500; font-size: 0.9rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 0.45rem 0.9rem; border-radius: 8px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.55; cursor: progress; }

label { display: block; font-weight: 500; font-size: 0.88rem; }
label.inline { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 400; }
input[type='text'], input[type='password'], input[type='number'], input[type='url'], input[type='search'], select, textarea {
  display: block; width: 100%; margin-top: 0.3rem;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.65rem;
}
textarea { min-height: 7rem; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88rem; }
textarea.prose { font-family: inherit; font-size: 0.95rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.filters { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1rem; }
.form-grid { display: grid; gap: 0.8rem; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 0.3rem; }
.seg button { font: inherit; font-size: 0.88rem; border: 0; background: var(--surface); color: var(--muted); padding: 0.45rem 0.9rem; cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.hit .meta { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; align-items: center; font-size: 0.85rem; color: var(--muted); }
.hit .title { font-weight: 600; }
.context { margin: 0.6rem 0; padding: 0.6rem 0.8rem; border-radius: 8px; background: var(--accent-soft); }
.context.irrelevant { background: var(--surface-2); color: var(--muted); }
.snippet {
  white-space: pre-wrap; margin: 0.5rem 0 0; padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--border); background: var(--surface-2); border-radius: 0 8px 8px 0;
  font-size: 0.9rem; max-height: 22rem; overflow: auto;
}
.snippet b { background: var(--mark); padding: 0 2px; border-radius: 3px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.table-wrap { overflow-x: auto; }

.help { font-size: 0.85rem; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 0.7rem 0.9rem; }
.help code { background: var(--surface); }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.8rem; margin: 0.4rem 0 0; }
.help dd { margin: 0; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(400px, 100%); display: grid; gap: 0.9rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(860px, calc(100vw - 32px)); max-height: 88vh; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
#modal-body { padding: 1.2rem; overflow: auto; max-height: 88vh; }
.page-text { white-space: pre-wrap; font-size: 0.9rem; background: var(--surface-2); padding: 0.8rem; border-radius: 8px; }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 0.6rem 1rem; border-radius: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width 0.3s; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 0.4rem; }
  #nav { order: 3; flex-basis: 100%; }
  h1 { font-size: 1.25rem; }
}

/* hits agrupados */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font: inherit; font-size: 0.88rem; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 0.3rem 0.75rem; border-radius: 999px;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.small { font-size: 0.78rem; padding: 0.12rem 0.6rem; background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.meeting-head {
  position: sticky; top: 52px; z-index: 5;
  margin-top: 1.4rem; padding: 0.45rem 0.2rem; font-weight: 600; font-size: 0.92rem;
  background: var(--bg); color: var(--muted); border-bottom: 1px solid var(--border);
}
.stack > .meeting-head:first-child { margin-top: 0; }
.group-title { font-size: 1rem; line-height: 1.4; margin: 0.55rem 0 0; }
.group .context { margin: 0.55rem 0; }
.sources { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; font-size: 0.86rem; }
.source { display: inline-flex; align-items: center; gap: 0.1rem; }
.excerpt { margin-top: 0.5rem; }
.excerpt summary { cursor: pointer; color: var(--muted); font-size: 0.86rem; }
.group-actions { margin-top: 0.4rem; }
@media (max-width: 640px) { .meeting-head { top: 96px; } }
