/* Report Builder - list, viewer, editor and keys. Uses the site's tokens (styles.css). */
.rb { --rb-soft: rgba(143, 163, 107, .16); --rb-soft-line: rgba(143, 163, 107, .5); --rb-fill: rgba(42, 53, 20, .04); --rb-danger: var(--danger); --rb-ok: var(--live); --rb-chip: rgba(42, 53, 20, .08); }
.rb { font-size: 14px; line-height: 1.4; }
.rb h1 { font-size: 1.6rem; margin: 0; }
.rb h2 { font-size: 1.05rem; margin: 22px 0 6px; }
.rb code { background: var(--rb-chip); padding: 1px 5px; border-radius: 4px; font-size: .85em; }
.rb .rb-grow { flex: 1 1 auto; }
.rb .rb-muted { color: var(--muted); }
.rb .rb-small { font-size: .85em; }
.rb .rb-nowrap { white-space: nowrap; }
.rb .rb-link { white-space: nowrap; }
.rb .rb-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--rb-chip); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.rb .rb-null { color: var(--muted); font-style: italic; }

/* buttons */
.rb .rb-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.rb .rb-btn:hover { filter: brightness(1.1); text-decoration: none; }
.rb .rb-btn[disabled] { opacity: .5; cursor: not-allowed; }
.rb .rb-btn.rb-quiet { background: transparent; color: var(--accent); }
.rb .rb-btn.rb-quiet:hover { background: var(--rb-soft); filter: none; }
.rb .rb-btn.rb-quiet[aria-pressed="true"] { background: var(--rb-soft); }
.rb .rb-btn.rb-danger { color: var(--rb-danger); border-color: var(--rb-danger); }
.rb .rb-btn.rb-small { height: 26px; padding: 0 9px; font-size: 12px; font-weight: 500; }
.rb .rb-btn .rb-spinner { margin: 0; }

/* fields */
.rb input[type=text], .rb input[type=search], .rb input[type=number], .rb input[type=date], .rb input[type=datetime-local], .rb select, .rb textarea {
  font: inherit; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); height: 32px; box-sizing: border-box;
}
.rb textarea { height: auto; }
.rb select { padding-right: 24px; }
.rb input:focus-visible, .rb select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rb label { font-weight: 600; font-size: 12px; color: var(--muted); display: block; }
.rb .rb-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; background: var(--panel); }
.rb .rb-card.rb-warn { border-left: 4px solid var(--accent); }
.rb .rb-card.rb-err { border-left: 4px solid var(--rb-danger); }
.rb .rb-err-text { color: var(--rb-danger); }
@keyframes rb-spin { to { transform: rotate(360deg); } }
.rb .rb-spinner { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rb-spin .8s linear infinite; box-sizing: border-box; }
.rb .rb-toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 10000; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 80vw; }
.rb .rb-toast[hidden] { display: none; }

/* ---------------- list ---------------- */
.rb-list .rb-listbar { display: flex; align-items: center; gap: 12px; margin: 16px 0 4px; flex-wrap: wrap; }
.rb-list #rbFilter { width: 280px; }
.rb-list .rb-rows td { padding: 5px 8px; }
.rb-list .rb-rows td:nth-child(2) { width: 100%; }
.rb-list .rb-star-cell { width: 1px; padding-right: 2px !important; }
.rb-list .rb-star { font-size: 1.1em; color: var(--muted); }
.rb-list .rb-star.on { color: var(--accent); }
.rb-list .rb-about { margin-top: 30px; }
.rb-list .rb-about summary { cursor: pointer; font-weight: 600; }

/* ---------------- viewer ---------------- */
.rb-report .rb-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.rb-report .rb-back { white-space: nowrap; }
.rb-report .rb-pick { max-width: 560px; min-width: 260px; font-weight: 600; }
.rb-report .rb-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rb-report .rb-id { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--rb-chip); color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; white-space: nowrap; }
.rb-report .rb-id:hover { background: var(--rb-soft); color: var(--accent); }
.rb-report .rb-notes { padding: 8px 12px; margin: 0 0 10px; border-radius: 8px; background: var(--rb-soft); border: 1px solid var(--rb-soft-line); white-space: pre-wrap; }
.rb-report .rb-questions { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.rb-report .rb-q { display: flex; flex-direction: column; gap: 3px; }
.rb-report .rb-q label .req { color: var(--rb-danger); margin-left: 2px; }
.rb-report .rb-q input, .rb-report .rb-q select { min-width: 150px; }
.rb-report .rb-q input[type=text] { width: 240px; }
.rb-report .rb-q.rb-q-missing input, .rb-report .rb-q.rb-q-missing select { border-color: var(--rb-danger); }
.rb-report .rb-q .rb-q-err { color: var(--rb-danger); font-size: 11px; max-width: 320px; }
.rb-report .rb-run { align-self: flex-end; }
.rb-report .rb-message { margin: 0 0 10px; }
.rb-report .rb-message .rb-card { margin: 0; }

/* tabs */
.rb-report .rb-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0; border-bottom: 1px solid var(--line); }
.rb-report .rb-tab { padding: 6px 12px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.rb-report .rb-tab[aria-selected="true"] { color: var(--accent); background: var(--panel); border-color: var(--line); margin-bottom: -1px; }
.rb-report .rb-tab .n { font-weight: 400; font-size: 11px; margin-left: 4px; }
.rb-report .rb-panel[hidden] { display: none; }

/* grid */
.rb-report .rb-gridbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; }
.rb-report .rb-gridbar .rb-title { font-weight: 600; font-size: 15px; }
.rb-report .rb-gridbar input[type=search] { width: 220px; }
.rb-report .rb-gridwrap { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.rb-report table.rb-grid { border-collapse: separate; border-spacing: 0; font-size: 13px; width: max-content; min-width: 100%; }
.rb-report table.rb-grid th { position: sticky; top: 0; z-index: 2; background: var(--bg); border-bottom: 2px solid var(--line); padding: 7px 10px; text-align: left; font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; }
.rb-report table.rb-grid th:hover { color: var(--accent); }
.rb-report table.rb-grid th .dir { color: var(--muted); font-size: 10px; margin-left: 4px; }
.rb-report table.rb-grid td { padding: 4px 10px; border-bottom: 1px solid var(--line); vertical-align: top; max-width: 480px; overflow-wrap: anywhere; }
.rb-report table.rb-grid tbody tr:nth-child(even) td { background: var(--rb-fill); }
.rb-report table.rb-grid tbody tr:hover td { background: var(--rb-soft); }
.rb-report table.rb-grid td.r, .rb-report table.rb-grid th.r { text-align: right; font-variant-numeric: tabular-nums; }
.rb-report table.rb-grid td.c, .rb-report table.rb-grid th.c { text-align: center; }
.rb-report table.rb-grid td.nowrap { white-space: nowrap; }
.rb-report table.rb-grid tr.rb-subtotal td { background: var(--rb-soft) !important; font-weight: 600; border-top: 1px solid var(--rb-soft-line); }
.rb-report table.rb-grid tr.rb-total td { background: var(--rb-soft) !important; font-weight: 700; border-top: 2px solid var(--accent); }
.rb-report table.rb-grid tr.rb-nomatch { display: none; }
.rb-report table.rb-grid tr.rb-more td { text-align: center; padding: 10px; }
.rb-report .rb-empty { padding: 14px; color: var(--muted); }

/* editor */
.rb-report .rb-editor { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 12px 14px; }
.rb-report .rb-editor .rb-edrow { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 0 0 10px; }
.rb-report .rb-editor .rb-f { display: flex; flex-direction: column; gap: 3px; }
.rb-report .rb-editor .rb-f.grow { flex: 1 1 260px; }
.rb-report .rb-editor .rb-f input[type=text] { width: 100%; }
.rb-report .rb-editor .rb-check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; height: 32px; font-weight: 500; font-size: 13px; color: var(--text); }
.rb-report .rb-editor .rb-sqlbox { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.rb-report .rb-editor .rb-sqlbox textarea { width: 100%; height: 360px; border: 0; border-radius: 0; font: 13px/1.45 ui-monospace, Consolas, "Cascadia Code", monospace; resize: vertical; padding: 8px; }
.rb-report .rb-editor .CodeMirror { height: auto; min-height: 240px; max-height: 60vh; font: 13px/1.5 ui-monospace, Consolas, "Cascadia Code", monospace; background: var(--bg); color: var(--text); }
.rb-report .rb-editor .CodeMirror-scroll { max-height: 60vh; }
.rb-report .CodeMirror-gutters { background: var(--panel); border-right: 1px solid var(--line); }
.rb-report .CodeMirror-linenumber { color: var(--muted); }
.rb-report .CodeMirror-cursor { border-left-color: var(--text); }
.rb-report .CodeMirror-selected, .rb-report .CodeMirror-focused .CodeMirror-selected { background: rgba(227, 180, 138, .45); }
.rb-report .cm-s-default .cm-keyword { color: var(--accent); font-weight: 600; }
.rb-report .cm-s-default .cm-builtin { color: #4D6B2C; }
.rb-report .cm-s-default .cm-string { color: #A44C26; }
.rb-report .cm-s-default .cm-number { color: #2F5F8A; }
.rb-report .cm-s-default .cm-comment { color: var(--muted); font-style: italic; }
.rb-report .cm-s-default .cm-variable-2, .rb-report .cm-s-default .cm-atom { color: var(--text); }
.rb-report .cm-error-mark { background: rgba(158, 59, 43, .22); border-bottom: 2px solid var(--danger); }
.rb-report .rb-editor .rb-edfoot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.rb-report .rb-editor .rb-help { font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.rb-report .rb-editor .rb-help summary { cursor: pointer; font-weight: 600; color: var(--text); }
.rb-report .rb-editor .rb-help table { border-collapse: collapse; margin: 6px 0; }
.rb-report .rb-editor .rb-help td { padding: 3px 10px 3px 0; vertical-align: top; }
.rb-report .rb-editor .rb-qpreview { font-size: 12px; margin: 8px 0 0; }
.rb-report .rb-editor .rb-qpreview .rb-chip { margin: 2px 4px 2px 0; }
.rb-report .rb-editor .rb-sqlerr { margin: 8px 0 0; }
.rb-report .rb-history table { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-top: 8px; }
.rb-report .rb-history th, .rb-report .rb-history td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.rb-report .rb-history th { color: var(--muted); }
.rb-report .rb-history tr.current td { background: var(--rb-soft); }
.rb-report .rb-diff { font: 12px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 320px; overflow: auto; margin-top: 8px; background: var(--bg); }
.rb-report .rb-diff .add { background: rgba(143, 163, 107, .3); }
.rb-report .rb-diff .del { background: rgba(181, 85, 43, .22); text-decoration: line-through; }

/* type-ahead list questions */
.rb-report .rb-lookup { position: relative; display: inline-block; min-width: 260px; }
.rb-report .rb-q .rb-lookup input[type=text].rb-lookup-text { width: 100%; padding-right: 28px; }
.rb-report .rb-lookup.picked .rb-lookup-text { border-color: var(--live); }
.rb-report .rb-lookup-clear { position: absolute; right: 2px; top: 2px; width: 26px; height: 28px; border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; border-radius: 6px; padding: 0; }
.rb-report .rb-lookup-clear:hover { background: var(--rb-fill); color: var(--text); filter: none; }
.rb-report .rb-lookup-list { position: absolute; left: 0; top: 100%; z-index: 50; min-width: 100%; max-width: 720px; max-height: 320px; overflow: auto; margin-top: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.35); }
.rb-report .rb-lookup-list[hidden] { display: none; }
.rb-report .rb-lookup-item { padding: 6px 10px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.rb-report .rb-lookup-item.on, .rb-report .rb-lookup-item:hover { background: var(--rb-soft); color: var(--accent); }
.rb-report .rb-lookup-hint { padding: 6px 10px; font-size: 12px; color: var(--muted); }

/* key row in the editor */
.rb-report .rb-keyrow { padding: 8px 10px; border: 1px dashed var(--rb-soft-line); border-radius: 8px; background: var(--rb-soft); }
.rb-report .rb-keyrow[hidden] { display: none; }
.rb-report .rb-keybox { display: flex; gap: 8px; align-items: center; }
.rb-report .rb-keybox input.rb-keyvalue { flex: 1 1 auto; font: 13px/1.4 ui-monospace, Consolas, "Cascadia Code", monospace; letter-spacing: .02em; }
.rb-report .rb-urls { font: 12px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; }

@media (max-width: 720px) {
  .rb-report .rb-pick { min-width: 0; width: 100%; }
  .rb-report .rb-q input[type=text] { width: 100%; }
  .rb-report .rb-lookup { min-width: 0; width: 100%; }
}
