:root {
    --bg: #f3f5f9;
    --panel: #ffffff;
    --line: #dfe4ec;
    --line-strong: #c8d0dc;
    --text: #1d2633;
    --muted: #6a7686;
    --primary: #f05424;          /* laranja-avermelhado da chama Prizzu */
    --primary-dark: #d33f14;
    --primary-soft: #fde4da;
    --brand-amber: #f09018;      /* laranja médio da chama */
    --brand-yellow: #f6c900;     /* amarelo do detalhe da chama */
    --green: #198754;
    --green-soft: #e3f4ea;
    --orange: #c46a00;
    --orange-soft: #fdf0dd;
    --purple: #6b46c1;
    --purple-soft: #efe9fb;
    --red: #c62828;
    --red-soft: #fdeaea;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
    --topbar: 52px;
    --sidebar: 190px;
    font-size: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 4px; }
h3 { font-size: 13px; margin: 0; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- layout ---------- */
.topbar {
    position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; background: linear-gradient(90deg, #f05424 0%, #f0701f 100%); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; }
.brand-mark {
    border-radius: 8px; background: #fff; font-weight: 800; padding: 4px 9px;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.brand-mark img { height: 26px; width: auto; display: block; }
.sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar);
    background: var(--panel); border-right: 1px solid var(--line); padding: 12px 8px;
    display: flex; flex-direction: column; overflow-y: auto;
}
.nav-credit {
    margin: auto 4px 0; padding: 12px 8px 4px; border-top: 1px solid var(--line);
    font-size: 11px; color: var(--muted); line-height: 1.5;
}
.nav-credit-line { display: block; }
.nav-credit-copy { display: block; margin-top: 2px; opacity: .85; }
.nav-credit-ver { display: block; margin-top: 4px; font-size: 10px; opacity: .7; }
.login-ver { display: inline-block; margin-top: 4px; opacity: .75; }
.sidebar a {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px;
    color: var(--text); margin-bottom: 2px;
}
.sidebar a svg { width: 18px; height: 18px; fill: var(--muted); }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar a.active svg { fill: var(--primary); }
.sidebar .nav-credit a {
    display: inline; padding: 0; margin: 0; border-radius: 0; background: none;
    color: var(--primary-dark); font-weight: 600;
}
.sidebar .nav-credit a:hover { background: none; text-decoration: underline; }
main { margin: var(--topbar) 0 0 var(--sidebar); min-height: calc(100vh - var(--topbar)); }

.page { padding: 24px 28px; max-width: none; } /* todas as telas usam a largura toda */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }

/* ---------- controles ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
    border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--text);
    font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }

input, select, textarea {
    font: inherit; color: var(--text); border: 1px solid var(--line-strong); border-radius: 6px;
    padding: 6px 9px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #f3b872; border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; }
.check input { width: auto; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 0 14px; height: 32px; font: inherit; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--primary); color: #fff; }
.limit-ctl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.limit-ctl input { width: 74px; height: 32px; padding: 0 8px; }

.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; background: rgba(255,255,255,.15); color: #fff;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #aaa; }
.badge.ok::before { background: #4ade80; }
.badge.err::before { background: #f87171; }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.tag.analitico { background: var(--primary-soft); color: var(--primary); }
.tag.sintetico { background: var(--purple-soft); color: var(--purple); }

/* ---------- lista de relatórios ---------- */
.search { max-width: 360px; margin-bottom: 16px; }
.folder-title { margin: 18px 0 8px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.report-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
    box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
}
.report-card h4 { margin: 0; font-size: 15px; }
.report-card p { margin: 0; color: var(--muted); font-size: 13px; }
.report-card .actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.empty.error { color: var(--red); }

/* ---------- construtor ---------- */
.builder {
    display: grid; grid-template-columns: 290px minmax(0, 1fr) 300px;
    height: calc(100vh - var(--topbar));
}
.explorer, .props { background: var(--panel); overflow: hidden; display: flex; flex-direction: column; }
.explorer { border-right: 1px solid var(--line); }
.props { border-left: 1px solid var(--line); }
.panel-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin-bottom: 8px; }
.panel-body { flex: 1; overflow: auto; padding: 10px 14px; }
.panel-foot { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.special-item {
    display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; padding: 7px 10px; border-radius: 6px;
    border: 1px dashed var(--purple); color: var(--purple); background: var(--purple-soft); cursor: grab; font-weight: 600;
}
/* "Função do banco...": abre a escolha da função (clique, não arrasta) */
.special-item.func-item { cursor: pointer; margin-top: 4px; border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.fn-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 4px;
    background: #fff; font-weight: 700; font-style: italic; font-size: 13px; }
.group-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin: 12px 0 4px; }
.tbl { border-radius: 6px; margin-bottom: 2px; }
.tbl-head {
    display: flex; align-items: center; gap: 6px; padding: 6px 6px; border-radius: 6px; cursor: pointer; user-select: none;
}
.tbl-head:hover { background: var(--bg); }
.tbl-head .caret { width: 14px; color: var(--muted); transition: transform .15s; }
.tbl.open .caret { transform: rotate(90deg); }
.tbl-head .t-label { flex: 1; min-width: 0; }
.tbl-head .t-label b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl-head .t-label small { color: var(--muted); font-size: 11px; font-family: Consolas, monospace; }
.tbl.in-report > .tbl-head b { color: var(--primary); }
.tbl.in-report > .tbl-head::after { content: "no relatório"; font-size: 10px; color: var(--primary); background: var(--primary-soft); padding: 1px 6px; border-radius: 99px; }
.cols { list-style: none; margin: 0 0 6px 14px; padding: 0 0 0 8px; border-left: 2px solid var(--line); }
.col {
    display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 5px; cursor: grab; font-size: 13px;
}
.col:hover { background: var(--primary-soft); }
.col .c-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col .c-name { color: var(--muted); font-size: 10px; font-family: Consolas, monospace; }
.col .c-add { display: none; border: 0; background: none; cursor: pointer; color: var(--primary); padding: 0 2px; font-size: 15px; }
.col:hover .c-add { display: inline; }
.ticon {
    flex: none; width: 22px; height: 18px; border-radius: 4px; font-size: 10px; font-weight: 700;
    display: grid; place-items: center; font-family: Consolas, monospace;
}
.ticon.number { background: var(--green-soft); color: var(--green); }
.ticon.text { background: var(--primary-soft); color: var(--primary); }
.ticon.date { background: var(--orange-soft); color: var(--orange); }
.ticon.lob { background: #eee; color: #888; }
.ticon.special { background: var(--purple-soft); color: var(--purple); }

.canvas { overflow: auto; padding: 14px 18px 30px; display: flex; flex-direction: column; gap: 12px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.title-input { flex: 1; min-width: 220px; font-size: 18px; font-weight: 600; border-color: transparent; background: transparent; padding: 4px 8px; }
.title-input:hover { border-color: var(--line-strong); background: #fff; }

.zone {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow);
}
.zone-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.zone-head .hint { font-size: 12px; color: var(--muted); }
.drop {
    min-height: 44px; border: 2px dashed var(--line-strong); border-radius: 7px; padding: 6px;
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center; transition: background .1s, border-color .1s;
}
.drop:empty::before { content: attr(data-placeholder); color: var(--muted); font-size: 13px; padding: 4px 6px; }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.zones-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }

.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 8px; border-radius: 6px;
    background: #fff; border: 1px solid var(--line-strong); cursor: grab; max-width: 100%; user-select: none;
}
.chip:hover { border-color: var(--primary); }
.chip.selected { border-color: var(--primary); box-shadow: 0 0 0 2px #f6c38a; }
.chip .ch-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.chip .ch-label { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.chip .ch-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chip .ch-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; }
.chip .ch-x:hover { color: var(--red); }
.chip.ask { border-style: dashed; border-color: var(--orange); }
.chip.drop-before { box-shadow: -3px 0 0 var(--primary); }
.chip.table-chip { cursor: pointer; background: var(--bg); }
/* tabela selecionada em "Tabelas e ligações": destaca os campos dela nas outras seções */
.chip.from-table { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px #f6c38a; }
.chip.dim { opacity: .45; }
.chip.dim:hover { opacity: 1; }
.join-arrow { color: var(--muted); font-size: 12px; }

.preview { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 160px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }

/* ---------- propriedades ---------- */
.props .panel-body h4 { margin: 0 0 12px; font-size: 15px; }
.prop-sub { font-size: 12px; color: var(--muted); margin: -8px 0 14px; font-family: Consolas, monospace; }
.help { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; line-height: 1.45; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 4px; align-items: center; margin-bottom: 6px; }
.pair select { padding: 4px; font-size: 12px; }

/* ---------- resultado ---------- */
.result-info { display: flex; gap: 14px; align-items: center; padding: 8px 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.result-info .warn { color: var(--orange); font-weight: 600; }
.table-wrap { overflow: auto; max-height: 70vh; }
table.result { border-collapse: collapse; width: 100%; font-size: 13px; }
table.result th {
    position: sticky; top: 0; background: #fdeedd; text-align: left; font-weight: 600; padding: 7px 10px;
    border-bottom: 1px solid var(--line-strong); white-space: nowrap; z-index: 1;
}
table.result td { padding: 5px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.result tr:hover td { background: #fdf8f2; }
table.result .num { text-align: right; font-variant-numeric: tabular-nums; }
table.result tr.grp td { background: var(--primary-soft); font-weight: 700; color: var(--primary-dark); }
table.result tr.grp.l1 td { background: #fdf0e0; padding-left: 24px; }
table.result tr.grp.l2 td { background: #fef7f0; padding-left: 38px; }
table.result tr.sub td { background: #fdfbf8; font-weight: 600; border-bottom: 2px solid var(--line-strong); }
table.result tr.grand td { background: #f7e2cd; font-weight: 700; border-top: 2px solid var(--line-strong); }
.result-msg { padding: 30px; text-align: center; color: var(--muted); }
.result-msg.error { color: var(--red); white-space: pre-wrap; }

/* ---------- executar ---------- */
.viewer-params {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 16px;
    margin-bottom: 14px; box-shadow: var(--shadow);
}
.params-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.params-head h3 { margin: 0; }
.params-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
/* cada parâmetro num cartão: nome + condição em cima, valor embaixo */
.param-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; background: #fcfcfd; min-width: 0; }
.param-card.param-date { grid-column: span 2; }
.param-empresa { margin-bottom: 12px; }
.param-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px;
    font-size: 13px; font-weight: 700; color: var(--text); }
.param-hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.op-pill { width: auto; max-width: 150px; flex: none; border: 1px solid transparent; background: var(--primary-soft); color: var(--primary-dark);
    border-radius: 99px; padding: 2px 8px; font-size: 12px; font-weight: 600; cursor: pointer; }
.op-pill:hover { border-color: var(--primary); }
.period { display: flex; flex-direction: column; gap: 8px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-period, .pill { border: 1px solid var(--line-strong); background: #fff; color: var(--text); border-radius: 99px;
    padding: 4px 11px; font: inherit; font-size: 12.5px; cursor: pointer; transition: background .12s, border-color .12s; }
.chip-period:hover, .pill:hover { border-color: var(--primary); }
.chip-period.on, .pill.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.range-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range-row input { width: auto; flex: 1 1 120px; min-width: 0; }
.param-card:not(.param-date) .range-row { flex-wrap: nowrap; }
.range-label { font-size: 13px; color: var(--muted); }
.linklike { border: 0; background: none; color: var(--primary-dark); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.params-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.btn-run { flex: none; padding-left: 22px; padding-right: 22px; height: 38px; font-size: 14px; }
/* depois de executar: só o resumo, para sobrar espaço para o resultado */
.params-summary { display: none; align-items: center; justify-content: space-between; gap: 12px; }
.params-summary-text { font-size: 13px; color: var(--text); }
.viewer-params.collapsed .params-body, .viewer-params.collapsed .params-head { display: none; }
.viewer-params.collapsed .params-summary { display: flex; }
.viewer-params.collapsed { padding: 10px 16px; }
@media (max-width: 760px) { .param-card.param-date { grid-column: auto; } .params-grid { grid-template-columns: 1fr; } }
.viewer-result { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.print-head { display: none; }

/* ---------- menu (exportar) ---------- */
.menu-wrap { position: relative; display: inline-block; }
.menu {
    display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 250px;
    background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 8px 24px rgba(20,30,50,.15); padding: 4px;
}
.menu.open { display: block; }
.menu-item {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; border: 0; background: none;
    padding: 7px 10px; border-radius: 6px; cursor: pointer; font: inherit; text-align: left;
}
.menu-item:hover { background: var(--primary-soft); }
.menu-item span { font-size: 11px; color: var(--muted); }
.conn-select { margin-bottom: 8px; font-weight: 600; }
.mono { font-family: Consolas, "Courier New", monospace; }
.txt-fields td { padding: 3px 6px; }
.txt-fields select, .txt-fields input { padding: 3px 5px; font-size: 12px; }
.empresas { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.empresas .check { margin: 0; font-size: 13px; }

/* ---------- modal e avisos ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: grid; place-items: center; z-index: 50; }
.modal { background: #fff; border-radius: 10px; width: min(560px, 92vw); max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { width: min(900px, 94vw); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 16px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
pre.sql { background: #0f1b2d; color: #d6e4ff; padding: 14px; border-radius: 6px; overflow: auto; font-size: 12.5px; margin: 0; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1d2633; color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: var(--shadow); max-width: 380px; animation: tin .15s ease-out; }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

.spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Botão em andamento (modal salvando): não encolhe e o spinner fica visível no botão */
.btn.loading { opacity: .85; cursor: progress; }
.btn.loading .spinner { width: 14px; height: 14px; border-width: 2px; }
.btn.primary.loading .spinner { border-color: rgba(255,255,255,.55); border-top-color: #fff; }

@media (max-width: 1100px) {
    .builder { grid-template-columns: 250px minmax(0, 1fr) 260px; }
}

/* ---------- impressão ---------- */
@media print {
    .topbar, .sidebar, .no-print, .viewer-params, #toasts { display: none !important; }
    main { margin: 0; }
    .page { padding: 0; max-width: none; }
    .print-head { display: block; margin-bottom: 10px; }
    .viewer-result { border: 0; box-shadow: none; }
    .table-wrap { max-height: none; overflow: visible; }
    table.result { font-size: 10px; }
    table.result th { position: static; }
    table.result td { white-space: normal; }
    body.print-blocked main { display: none !important; }
    body.print-blocked::before { content: 'Seu perfil não tem permissão para imprimir relatórios.'; display: block; padding: 20px; font-size: 14px; }
}

/* ================= login, sessão e administração ================= */
body.booting main, body.booting .sidebar, body.booting .topbar-right { visibility: hidden; }
body.logged-out .sidebar, body.logged-out .topbar-right { display: none; }
body.logged-out main { margin-left: 0; }

.login-page { min-height: calc(100vh - var(--topbar)); display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #fde6cc 0%, var(--bg) 60%); }
.login-card { width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 26px 28px; box-shadow: 0 8px 30px rgba(130, 70, 10, .14); }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; color: #8a4300; margin-bottom: 6px; }
.login-brand .brand-mark { background: transparent; box-shadow: none; padding: 0; }
.login-brand .brand-mark img { height: 30px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.login-credit { text-align: center; margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.login-credit a { color: var(--primary-dark); font-weight: 600; }
.login-privacy { max-width: 360px; margin: 0 auto 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 11.5px; line-height: 1.5; }
.login-credit a:hover { text-decoration: underline; }

.nav-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 16px 12px 6px; }
.user-btn { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); border: 0; color: #fff; padding: 4px 10px 4px 4px; border-radius: 999px; cursor: pointer; font: inherit; }
.user-btn:hover { background: rgba(255,255,255,.2); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: #f28c00; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
/* Modo central: cliente em que o super administrador está trabalhando */
.tenant-select {
    width: auto; max-width: 240px; height: 28px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
    background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.45); cursor: pointer;
}
.tenant-select option { color: var(--text); background: #fff; }
#tenant-chip.badge::before { display: none; }
@media (max-width: 700px) { .tenant-select { max-width: 130px; } }
.user-dropdown { color: var(--text); }
.menu-info { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; gap: 2px; }
.menu-info span { font-size: 12px; color: var(--muted); }

/* relatórios em pastas */
.reports-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 18px; align-items: start; }
.folder-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); position: sticky; top: calc(var(--topbar) + 12px); max-height: calc(100vh - var(--topbar) - 40px); overflow: auto; }
.tree-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin: 12px 8px 4px; }
.tree-node { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; cursor: pointer; user-select: none; }
.tree-node:hover { background: var(--bg); }
.tree-node.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.tree-node.locked { color: var(--muted); }
.tree-toggle { width: 14px; flex: none; color: var(--muted); font-size: 11px; text-align: center; }
.tree-icon { flex: none; width: 18px; text-align: center; }
.tree-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { font-size: 11px; background: var(--bg); color: var(--muted); border-radius: 999px; padding: 0 7px; }
.folder-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.folder-head h3 { text-transform: none; font-size: 17px; color: var(--text); letter-spacing: 0; }
.subfolders { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.subfolder { border: 1px solid var(--line-strong); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; font: inherit; }
.subfolder:hover { border-color: var(--primary); background: var(--primary-soft); }

/* tabelas e formulários de administração */
.card-table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th { text-align: left; background: #fdeedd; padding: 8px 12px; font-weight: 600; border-bottom: 1px solid var(--line-strong); }
table.grid td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr.inactive td { color: var(--muted); }
table.grid tr.warn-row td { background: var(--orange-soft); }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.off { background: #eef0f3; color: var(--muted); }
.tag.warn { background: var(--orange-soft); color: var(--orange); }
.tag.danger { background: var(--red-soft, #fde8e8); color: var(--red, #dc2626); }
.settings-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.settings-card-head h3 { text-transform: none; font-size: 15px; color: var(--text); margin: 0; letter-spacing: 0; }
.badge-secure { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; flex: none; padding: 3px 10px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 12px; }
.check-grid .check { margin-bottom: 4px; }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sub-title { font-size: 13px; margin: 16px 0 8px; color: var(--primary-dark); }
.emp-conn { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.error-text { color: var(--red); }
.perm-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.perm-group { margin-bottom: 4px; }
.folder-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(200px, 1.4fr) auto; gap: 12px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.folder-row:last-child { border-bottom: 0; }
.folder-access { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.folder-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.chip-access { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); }
.chip-access.edit { background: var(--green-soft); color: var(--green); }
.alert { background: var(--orange-soft); border: 1px solid #f3cf9a; color: #7a4300; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.settings-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.conn-msg { margin-top: 10px; font-size: 13px; min-height: 18px; white-space: pre-wrap; }
.conn-msg.ok { color: var(--green); }
.conn-msg.err { color: var(--red); }
.audit-details { font-size: 11px; background: var(--bg); padding: 6px 8px; border-radius: 6px; max-width: 520px; overflow: auto; margin: 4px 0 0; }

@media (max-width: 900px) {
    .reports-layout, .form-cols { grid-template-columns: 1fr; }
    .folder-panel { position: static; max-height: none; }
    .folder-row { grid-template-columns: 1fr; }
}
.settings-card .row > .btn { flex: none; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; font-size: 13px; padding: 10px 0 0; display: block; margin: 0 auto; }
.link-btn:hover { text-decoration: underline; }
.login-ok { color: var(--green); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.dict-info { padding: 6px 14px 10px; font-size: 11px; color: var(--muted); }
.seg-full { display: flex; width: 100%; margin-bottom: 8px; }
.seg-full button { flex: 1; height: 28px; font-size: 13px; }
.field-results { margin-left: 0; padding-left: 0; border-left: 0; }
.field-hit { align-items: flex-start; padding: 5px 6px; }
.field-hit .c-label { display: flex; flex-direction: column; white-space: normal; }
.field-hit .hit-table { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-hit.in-report .hit-table { color: var(--primary); }
.chip .ch-eye { border: 0; background: none; cursor: pointer; font-size: 13px; padding: 0 2px; opacity: .55; }
.chip .ch-eye:hover { opacity: 1; }
.chip.hidden-col { opacity: .6; border-style: dashed; }
.chip.hidden-col .ch-label { text-decoration: line-through; }
/* ajuda */
.help-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.help-toc .tree-node { width: 100%; border: 0; background: none; font: inherit; text-align: left; }
.help-content { max-width: 920px; }
.help-section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; margin-bottom: 16px; line-height: 1.6; scroll-margin-top: calc(var(--topbar) + 12px); }
.help-section h2 { margin: 0 0 8px; font-size: 19px; color: var(--primary-dark); }
.help-h3 { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 15px; margin: 18px 0 6px; }
.help-section ol, .help-section ul { padding-left: 22px; margin: 6px 0 10px; }
.help-section li { margin-bottom: 5px; }
.help-section p { margin: 6px 0; }
.ui-ref { display: inline-block; background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #f3c79a; border-radius: 4px; padding: 0 6px; font-size: 12.5px; font-weight: 600; line-height: 1.5; }
.help-section code { background: #f0f3f8; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12.5px; }
.help-tip, .help-warn { border-radius: 6px; padding: 8px 12px; margin: 10px 0; font-size: 13.5px; }
.help-tip { background: var(--green-soft); border-left: 3px solid var(--green); }
.help-warn { background: var(--orange-soft); border-left: 3px solid var(--orange); }
@media (max-width: 900px) { .help-layout { grid-template-columns: 1fr; } }
/* busca dentro da tabela aberta */
.col-filter-row { list-style: none; padding: 2px 0 4px; }
.col-filter { padding: 4px 8px; font-size: 12px; }

/* editor de SQL */
.sql-editor { display: grid; grid-template-columns: auto 1fr; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; height: 46vh; background: #0f1b2d; }
.sql-gutter { padding: 10px 8px; color: #6b7c96; font: 12.5px/1.55 Consolas, "Courier New", monospace; text-align: right; white-space: pre; overflow: hidden; user-select: none; background: #0b1524; }
.sql-input { border: 0; border-radius: 0; resize: none; height: 100%; padding: 10px 12px; background: #0f1b2d; color: #d6e4ff; font: 12.5px/1.55 Consolas, "Courier New", monospace; white-space: pre; overflow: auto; tab-size: 4; }
.sql-input:focus { outline: none; }
.sql-input::placeholder { color: #50607a; }
.sql-result { margin-top: 10px; }
.sql-summary { margin: 6px 0; padding-left: 20px; font-size: 13px; }
.sql-summary li { margin-bottom: 3px; }
.modal .row > .btn { flex: none; }
/* relatório combinado */
.tag.uniao { background: var(--orange-soft); color: var(--orange); }
.combine-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.card-title { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 15px; margin-bottom: 10px; }
.part-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 220px auto; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.part-row.bad { border-color: var(--red); background: var(--red-soft); }
.part-num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); display: grid; place-items: center; font-weight: 700; }
.part-label { display: flex; flex-direction: column; gap: 2px; }
.part-actions { display: flex; gap: 2px; }
@media (max-width: 900px) { .part-row { grid-template-columns: 32px 1fr; } }
.pair-box { background: #f6f7f9; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 8px 0 14px; }
.pair-value { font-family: ui-monospace, Consolas, monospace; font-size: 14px; word-break: break-all; }
.pair-code { font-size: 22px; letter-spacing: 2px; font-weight: 700; color: var(--primary-dark); }
.pair-steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.7; }
