/* =====================================================================
   TSTT Consulta SQL RM — tema visual
   Paleta do site tstt.net.br + logo TROI (azul marinho, azul claro, vermelho)
   ===================================================================== */
:root {
  --tstt-navy: #0b4a8b;
  --tstt-navy-dark: #083766;
  --tstt-blue: #2563eb;
  --tstt-sky: #27a9e1;
  --tstt-indigo: #2b2f6b;
  --tstt-red: #e30613;
  --tstt-text: #1f2937;
  --tstt-muted: #6b7280;
  --tstt-bg: #f9fafb;
  --tstt-surface: #ffffff;
  --tstt-border: #e5e7eb;
  --tstt-soft: #eff6ff;
  --tstt-grid-alt: #f8fafc;
  --tstt-grid-sel: #dbeafe;
  --tstt-editor-bg: #ffffff;
  --tstt-editor-gutter: #f3f4f6;
  --tstt-gradient: linear-gradient(135deg, #27a9e1 0%, #0b4a8b 55%, #2b2f6b 100%);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bs-primary: var(--tstt-navy);
  --bs-primary-rgb: 11, 74, 139;
  --bs-link-color: var(--tstt-blue);
  --bs-link-color-rgb: 37, 99, 235;
  --bs-body-font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--tstt-text);
  --bs-body-bg: var(--tstt-bg);
  --bs-border-color: var(--tstt-border);
  --bs-danger: var(--tstt-red);
  --bs-danger-rgb: 227, 6, 19;
}
[data-bs-theme="dark"] {
  --tstt-text: #e5e7eb;
  --tstt-muted: #9ca3af;
  --tstt-bg: #0f172a;
  --tstt-surface: #111827;
  --tstt-border: #263244;
  --tstt-soft: #13233f;
  --tstt-grid-alt: #0f1a2c;
  --tstt-grid-sel: #1e3a8a;
  --tstt-editor-bg: #0b1220;
  --tstt-editor-gutter: #0f172a;
  --bs-body-color: var(--tstt-text);
  --bs-body-bg: var(--tstt-bg);
  --bs-border-color: var(--tstt-border);
  --bs-primary: #3b82f6;
  --bs-primary-rgb: 59, 130, 246;
}

html, body { height: 100%; }
body { font-family: var(--bs-body-font-family); background: var(--tstt-bg); color: var(--tstt-text); font-size: 14px; }
.font-mono, code, kbd, pre { font-family: var(--font-mono); }
kbd { font-size: .75em; padding: .1rem .35rem; }

.btn-primary { --bs-btn-bg: var(--tstt-navy); --bs-btn-border-color: var(--tstt-navy); --bs-btn-hover-bg: var(--tstt-navy-dark); --bs-btn-hover-border-color: var(--tstt-navy-dark); --bs-btn-active-bg: var(--tstt-navy-dark); --bs-btn-disabled-bg: var(--tstt-navy); --bs-btn-disabled-border-color: var(--tstt-navy); }
.btn-outline-primary { --bs-btn-color: var(--tstt-navy); --bs-btn-border-color: var(--tstt-navy); --bs-btn-hover-bg: var(--tstt-navy); --bs-btn-hover-border-color: var(--tstt-navy); --bs-btn-active-bg: var(--tstt-navy); }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: #93c5fd; --bs-btn-border-color: #3b82f6; }
.btn-dark { --bs-btn-bg: #0a0a0a; --bs-btn-border-color: #0a0a0a; }
[data-bs-theme="dark"] .btn-dark { --bs-btn-bg: #2563eb; --bs-btn-border-color: #2563eb; --bs-btn-hover-bg: #1d4ed8; }
.btn-danger { --bs-btn-bg: var(--tstt-red); --bs-btn-border-color: var(--tstt-red); --bs-btn-hover-bg: #b80510; --bs-btn-hover-border-color: #b80510; --bs-btn-disabled-bg: var(--tstt-red); --bs-btn-disabled-border-color: var(--tstt-red); }
.btn-icon { border: 0; background: transparent; color: var(--tstt-muted); padding: .35rem .5rem; border-radius: .5rem; }
.btn-icon:hover { background: var(--tstt-soft); color: var(--tstt-navy); }
.form-control:focus, .form-select:focus { border-color: var(--tstt-blue); box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15); }
.card { border-color: var(--tstt-border); background: var(--tstt-surface); border-radius: .75rem; }
.card-header { background: transparent; border-color: var(--tstt-border); }
.modal-content { border-radius: .85rem; background: var(--tstt-surface); }
.dropdown-menu { border-color: var(--tstt-border); border-radius: .6rem; }
.dropdown-item.active, .dropdown-item:active { background: var(--tstt-navy); }
.badge-perfil { background: var(--tstt-soft); color: var(--tstt-navy); border: 1px solid #bfdbfe; }
[data-bs-theme="dark"] .badge-perfil { color: #93c5fd; border-color: #1e3a8a; }

/* ---------------------------------------------------------- topbar */
.topbar { height: 56px; display: flex; align-items: center; gap: 1.25rem; padding: 0 1rem; background: var(--tstt-surface); border-bottom: 1px solid var(--tstt-border); position: sticky; top: 0; z-index: 1030; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--tstt-gradient); opacity: .9; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--tstt-text); white-space: nowrap; }
.brand-text { font-size: 1rem; }
.brand-text strong { color: var(--tstt-navy); font-weight: 800; letter-spacing: .02em; }
[data-bs-theme="dark"] .brand-text strong { color: #60a5fa; }
.brand-rm { background: var(--tstt-red); color: #fff; font-size: .7rem; padding: .1rem .35rem; border-radius: .3rem; font-weight: 700; vertical-align: middle; }
.topnav { display: flex; align-items: center; gap: .25rem; }
.topnav > a, .topnav .dropdown > a { color: var(--tstt-muted); text-decoration: none; padding: .4rem .7rem; border-radius: .5rem; font-weight: 500; }
.topnav > a:hover, .topnav .dropdown > a:hover, .topnav a.active { color: var(--tstt-navy); background: var(--tstt-soft); }
[data-bs-theme="dark"] .topnav a.active, [data-bs-theme="dark"] .topnav > a:hover { color: #93c5fd; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.avatar-btn { border: 0; background: transparent; padding: 0; border-radius: 50%; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; }
.avatar-initials { background: var(--tstt-blue); color: #fff; font-weight: 700; font-size: .85rem; }
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }

/* ---------------------------------------------------------- login */
.page-login { background: var(--tstt-bg); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-brand { background: var(--tstt-gradient); color: #fff; padding: 4rem; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-brand::before { content: ""; position: absolute; right: -120px; top: -120px; width: 360px; height: 360px; border-radius: 50%; border: 40px solid rgba(255,255,255,.07); }
.login-logo { width: 150px; background: #fff; padding: 1rem; border-radius: 1rem; margin-bottom: 2rem; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.login-brand h1 { font-weight: 700; font-size: 2.1rem; line-height: 1.25; margin-bottom: 1.5rem; }
.login-points { list-style: none; padding: 0; margin: 0; font-size: 1.05rem; }
.login-points li { margin: .55rem 0; opacity: .95; }
.login-points i { margin-right: .5rem; color: #fff; background: rgba(255,255,255,.15); padding: .25rem .4rem; border-radius: .4rem; }
.login-foot { margin-top: 3rem; opacity: .7; font-size: .85rem; }
.login-card { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-card form { width: 100%; max-width: 440px; }
@media (max-width: 900px) { .login-wrap { grid-template-columns: 1fr; } .login-brand { display: none; } }

/* ---------------------------------------------------------- editor workspace */
.page-app { overflow: hidden; }
.workspace { display: flex; height: calc(100vh - 56px); }
.sidebar { width: 300px; flex: 0 0 300px; background: var(--tstt-surface); border-right: 1px solid var(--tstt-border); display: flex; flex-direction: column; padding: .9rem; gap: .6rem; overflow: hidden; transition: margin .2s; }
.workspace.sidebar-hidden .sidebar { margin-left: -300px; }
.btn-nova-conexao { padding: .6rem; font-weight: 600; border-radius: .5rem; }
.conn-list { max-height: 34vh; overflow: auto; display: flex; flex-direction: column; gap: .35rem; flex: 0 0 auto; }
.conn-item { display: flex; align-items: center; gap: .5rem; padding: .55rem .6rem; border-radius: .5rem; background: var(--tstt-bg); border: 1px solid transparent; cursor: pointer; border-left: 4px solid var(--conn-color, var(--tstt-navy)); }
.conn-item:hover { border-color: var(--tstt-border); }
.conn-item.active { background: var(--tstt-soft); border-color: #bfdbfe; }
[data-bs-theme="dark"] .conn-item.active { border-color: #1e3a8a; }
.conn-item .conn-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-item .conn-sub { font-size: .72rem; color: var(--tstt-muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-item .conn-actions { display: flex; gap: .15rem; font-size: .8rem; }
.conn-item .conn-actions a { color: var(--tstt-muted); text-decoration: none; padding: 0 .2rem; }
.conn-item .conn-actions a:hover { color: var(--tstt-navy); }
.conn-item .conn-actions a.danger:hover { color: var(--tstt-red); }
.conn-status { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex: 0 0 8px; }
.conn-status.ok { background: #22c55e; }
.conn-status.fail { background: var(--tstt-red); }
.empty-hint { color: var(--tstt-muted); font-size: .85rem; padding: .5rem; text-align: center; }

.side-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .15rem; border-bottom: 1px solid var(--tstt-border); margin-top: .3rem; }
.side-tabs button { width: 100%; border: 0; background: transparent; padding: .45rem .1rem; font-size: .72rem; color: var(--tstt-muted); display: flex; flex-direction: column; align-items: center; gap: .1rem; border-bottom: 2px solid transparent; }
.side-tabs button i { font-size: 1.05rem; }
.side-tabs button.active { color: var(--tstt-navy); border-bottom-color: var(--tstt-navy); font-weight: 600; }
[data-bs-theme="dark"] .side-tabs button.active { color: #93c5fd; border-bottom-color: #3b82f6; }
.side-panel { display: none; flex: 1; min-height: 0; flex-direction: column; gap: .5rem; }
.side-panel.active { display: flex; }
.side-list { flex: 1; overflow: auto; min-height: 0; }
.side-item { padding: .45rem .5rem; border-radius: .45rem; cursor: pointer; border: 1px solid transparent; }
.side-item:hover { background: var(--tstt-bg); border-color: var(--tstt-border); }
.side-item .t { font-weight: 500; font-size: .85rem; display: flex; align-items: center; gap: .35rem; }
.side-item .t span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .s { font-size: .72rem; color: var(--tstt-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); }
.side-item .acts { display: none; gap: .2rem; }
.side-item:hover .acts { display: flex; }
.side-item .acts a { color: var(--tstt-muted); font-size: .8rem; }
.side-item .acts a:hover { color: var(--tstt-red); }
.side-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--tstt-muted); margin: .6rem .4rem .2rem; font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: 0 0 7px; }
.status-dot.sucesso { background: #22c55e; } .status-dot.erro { background: var(--tstt-red); } .status-dot.bloqueado { background: #f59e0b; }
.dict-detail { border-top: 1px solid var(--tstt-border); padding-top: .5rem; max-height: 50%; overflow: auto; }
.dict-col { display: flex; gap: .4rem; font-size: .78rem; padding: .2rem .3rem; border-radius: .3rem; cursor: pointer; }
.dict-col:hover { background: var(--tstt-soft); }
.dict-col b { font-family: var(--font-mono); font-weight: 500; }
.dict-col small { color: var(--tstt-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: .9rem 1.2rem .6rem; gap: .55rem; }
.main-head { display: flex; align-items: center; gap: .6rem; }
.main-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.badge-db { border: 1px solid var(--tstt-border); border-radius: .4rem; padding: .15rem .5rem; font-size: .8rem; color: var(--tstt-muted); background: var(--tstt-surface); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.badge-db.active { color: var(--tstt-text); border-color: var(--conn-color, var(--tstt-navy)); box-shadow: inset 3px 0 0 var(--conn-color, var(--tstt-navy)); }
.autosave-status { font-size: .78rem; color: var(--tstt-muted); white-space: nowrap; }
.autosave-status.saving { color: var(--tstt-blue); }
.autosave-status.error { color: var(--tstt-red); }

.tabs-bar { display: flex; align-items: flex-end; border-bottom: 1px solid var(--tstt-text); gap: .2rem; }
[data-bs-theme="dark"] .tabs-bar { border-bottom-color: var(--tstt-border); }
.tabs-scroll { display: flex; gap: .2rem; overflow-x: auto; scrollbar-width: thin; }
.tab { display: flex; align-items: center; gap: .4rem; padding: .45rem .8rem; border: 1px solid var(--tstt-border); border-bottom: 0; border-radius: .45rem .45rem 0 0; background: var(--tstt-bg); color: var(--tstt-muted); cursor: pointer; white-space: nowrap; max-width: 240px; user-select: none; }
.tab .tab-title { overflow: hidden; text-overflow: ellipsis; }
.tab.active { background: var(--tstt-surface); color: var(--tstt-text); border-color: var(--tstt-text); position: relative; top: 1px; font-weight: 500; }
[data-bs-theme="dark"] .tab.active { border-color: var(--tstt-border); }
.tab .tab-close { border: 0; background: transparent; color: inherit; opacity: .5; padding: 0 .1rem; line-height: 1; }
.tab .tab-close:hover { opacity: 1; color: var(--tstt-red); }
.tab .tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--conn-color, transparent); }
.tab-add { border: 0; background: transparent; color: var(--tstt-muted); padding: .35rem .6rem; }
.tab-add:hover { color: var(--tstt-navy); }

.editor-wrap { height: 300px; min-height: 90px; border: 1px solid var(--tstt-border); border-top: 0; background: var(--tstt-editor-bg); }
.editor-wrap .CodeMirror { height: 100%; font-family: var(--font-mono); font-size: 13.5px; background: var(--tstt-editor-bg); color: var(--tstt-text); }
.CodeMirror-gutters { background: var(--tstt-editor-gutter); border-right: 1px solid var(--tstt-border); }
.CodeMirror-linenumber { color: #9ca3af; }
.CodeMirror-activeline-background { background: rgba(37, 99, 235, .06); }
.CodeMirror-cursor { border-left-color: var(--tstt-text); }
.CodeMirror-selected { background: rgba(37, 99, 235, .18) !important; }
.cm-s-default .cm-keyword { color: #7c3aed; font-weight: 500; }
.cm-s-default .cm-string { color: #047857; }
.cm-s-default .cm-number { color: #b45309; }
.cm-s-default .cm-comment { color: #9ca3af; font-style: italic; }
.cm-s-default .cm-builtin, .cm-s-default .cm-type { color: #0369a1; }
.cm-s-default .cm-operator { color: #475569; }
.cm-s-default .cm-variable-2 { color: #be185d; }
[data-bs-theme="dark"] .cm-s-default .cm-keyword { color: #c4b5fd; }
[data-bs-theme="dark"] .cm-s-default .cm-string { color: #6ee7b7; }
[data-bs-theme="dark"] .cm-s-default .cm-number { color: #fbbf24; }
[data-bs-theme="dark"] .cm-s-default .cm-builtin, [data-bs-theme="dark"] .cm-s-default .cm-type { color: #7dd3fc; }
[data-bs-theme="dark"] .CodeMirror-matchingbracket { color: #fff !important; }
.CodeMirror-hints { font-family: var(--font-mono); font-size: 12.5px; border-radius: .4rem; max-height: 22em; z-index: 2000; background: var(--tstt-surface); border-color: var(--tstt-border); }
.CodeMirror-hint { color: var(--tstt-text); padding: 2px 8px; max-width: 560px; overflow: hidden; text-overflow: ellipsis; }
li.CodeMirror-hint-active { background: var(--tstt-navy); color: #fff; }
.hint-kind { display: inline-block; min-width: 1.4em; font-size: .7em; padding: 0 .25em; margin-right: .4em; border-radius: .25em; text-align: center; background: #e0e7ff; color: #3730a3; }
.hint-kind.t { background: #dbeafe; color: #1e40af; } .hint-kind.c { background: #dcfce7; color: #166534; } .hint-kind.s { background: #fee2e2; color: #991b1b; } .hint-kind.k { background: #f3f4f6; color: #374151; }
.hint-desc { color: #9ca3af; margin-left: .6em; font-family: var(--bs-body-font-family); font-size: .92em; }
li.CodeMirror-hint-active .hint-desc { color: #dbeafe; }
.resizer { height: 7px; cursor: row-resize; margin-top: -4px; position: relative; }
.resizer::after { content: ""; position: absolute; left: 50%; top: 2px; width: 40px; height: 3px; margin-left: -20px; border-radius: 2px; background: var(--tstt-border); }
.resizer:hover::after { background: var(--tstt-blue); }

.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.toolbar .btn { border-radius: .45rem; }
.btn-exec { padding: .5rem 1.1rem; font-weight: 600; }
.btn-exec small { opacity: .7; font-weight: 400; }
.btn-exec.running { background: #6b7280; border-color: #6b7280; }
.sql-tipo .badge { font-weight: 600; }

.results { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.results-empty { margin: auto; text-align: center; color: var(--tstt-muted); max-width: 440px; }
.results-empty i { font-size: 2.2rem; display: block; margin-bottom: .4rem; opacity: .5; }
.results-box { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 2px solid var(--tstt-text); border-radius: .45rem; background: var(--tstt-surface); overflow: hidden; }
[data-bs-theme="dark"] .results-box { border-color: var(--tstt-border); }
.results-head { display: flex; align-items: center; gap: .6rem; padding: .45rem .8rem; background: var(--tstt-bg); border-bottom: 1px solid var(--tstt-border); }
.results-meta { font-size: .8rem; color: var(--tstt-muted); }
.results-filter { margin: .5rem .7rem; width: auto; }
.results-alert { margin: 0 .7rem .5rem; font-size: .85rem; }
.results-foot { padding: .4rem .8rem; border-top: 1px solid var(--tstt-border); font-size: .8rem; color: var(--tstt-muted); display: flex; gap: 1rem; background: var(--tstt-bg); }
.results-error { border: 1px solid #fecaca; background: #fef2f2; color: #991b1b; border-radius: .5rem; padding: .9rem 1rem; white-space: pre-wrap; font-family: var(--font-mono); font-size: .85rem; overflow: auto; }
[data-bs-theme="dark"] .results-error { background: #2a0e12; border-color: #7f1d1d; color: #fecaca; }
.dml-result { margin: auto; text-align: center; padding: 2rem; }
.dml-result .big { font-size: 2.4rem; font-weight: 700; color: var(--tstt-navy); }

/* ---------------------------------------------------------- grid virtual */
.vgrid { flex: 1; min-height: 0; overflow: auto; position: relative; outline: none; font-size: 13px; }
.vg-inner { position: relative; }
.vg-head { position: sticky; top: 0; z-index: 3; display: flex; background: var(--tstt-bg); border-bottom: 2px solid var(--tstt-border); }
.vg-row { position: absolute; left: 0; display: flex; height: 30px; border-bottom: 1px solid var(--tstt-border); }
.vg-row { background: var(--tstt-surface); }
.vg-row.odd { background: var(--tstt-grid-alt); }
.vg-row.odd .vg-num, .vg-row .vg-num { background: var(--tstt-bg); }
.vg-cell, .vg-hcell { flex: 0 0 auto; padding: 0 .6rem; border-right: 1px solid var(--tstt-border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 30px; }
.vg-hcell { font-weight: 700; line-height: 34px; height: 34px; cursor: pointer; position: relative; user-select: none; background: var(--tstt-bg); }
.vg-hcell:hover { background: var(--tstt-soft); }
.vg-hcell .sort { color: var(--tstt-blue); margin-left: .25rem; font-size: .8em; }
.vg-hcell .rz { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; }
.vg-hcell .rz:hover { background: var(--tstt-blue); }
.vg-num { position: sticky; left: 0; z-index: 2; background: var(--tstt-bg); color: var(--tstt-muted); text-align: left; cursor: pointer; }
.vg-head .vg-num { z-index: 4; }
.vg-cell.sel { background: var(--tstt-grid-sel) !important; }
.vg-cell.cur { outline: 2px solid var(--tstt-blue); outline-offset: -2px; }
.vg-cell.null { color: #9ca3af; font-style: italic; }
.vg-cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.vg-empty { padding: 2rem; text-align: center; color: var(--tstt-muted); }

/* ---------------------------------------------------------- modais específicos */
.sql-preview { max-height: 220px; overflow: auto; background: var(--tstt-bg); border: 1px solid var(--tstt-border); border-radius: .4rem; padding: .7rem; font-size: .8rem; white-space: pre-wrap; }
.admin-box { border: 1px dashed #fca5a5; background: #fff7f7; border-radius: .5rem; padding: .75rem 1rem; }
[data-bs-theme="dark"] .admin-box { background: #1f1215; border-color: #7f1d1d; }
details.advanced summary { cursor: pointer; color: var(--tstt-muted); font-size: .9rem; }
.test-result { border-radius: .5rem; border: 1px solid var(--tstt-border); padding: .6rem .8rem; font-size: .88rem; }
.test-result .step { display: flex; gap: .5rem; padding: .15rem 0; }
.test-result .step i.ok { color: #16a34a; } .test-result .step i.fail { color: var(--tstt-red); }
.shortcuts td:first-child { white-space: nowrap; }

/* ---------------------------------------------------------- admin */
.page-admin { background: var(--tstt-bg); }
.admin-main { padding-top: 1.5rem; padding-bottom: 3rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-head h1 i { color: var(--tstt-navy); }
[data-bs-theme="dark"] .page-head h1 i { color: #60a5fa; }
.kpi { background: var(--tstt-surface); border: 1px solid var(--tstt-border); border-radius: .75rem; padding: 1rem 1.1rem; height: 100%; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--kpi-color, var(--tstt-navy)); }
.kpi .v { font-size: 1.7rem; font-weight: 700; }
.kpi .l { color: var(--tstt-muted); font-size: .82rem; }
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: .5rem; }
.chart-bars .bar { flex: 1; display: flex; flex-direction: column-reverse; gap: 1px; position: relative; }
.chart-bars .bar span { display: block; border-radius: 2px 2px 0 0; }
.chart-bars .bar .ok { background: var(--tstt-sky); } .chart-bars .bar .er { background: var(--tstt-red); } .chart-bars .bar .bl { background: #f59e0b; }
.chart-bars .bar em { position: absolute; bottom: -1.3rem; left: 0; right: 0; text-align: center; font-size: .65rem; color: var(--tstt-muted); font-style: normal; }
.legend span { display: inline-flex; align-items: center; gap: .3rem; margin-right: .8rem; font-size: .8rem; color: var(--tstt-muted); }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.filters { background: var(--tstt-surface); border: 1px solid var(--tstt-border); border-radius: .75rem; padding: .85rem; margin-bottom: 1rem; }
.table-admin { background: var(--tstt-surface); }
.table-admin td, .table-admin th { vertical-align: middle; }
.table-admin .sqlprev { font-family: var(--font-mono); font-size: .78rem; max-width: 520px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-admin tr.clickable { cursor: pointer; }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: .75rem; font-size: .85rem; color: var(--tstt-muted); }
.profile-photo { width: 132px; height: 132px; border-radius: 50%; overflow: hidden; background: var(--tstt-gradient); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 2.6rem; font-weight: 700; border: 4px solid var(--tstt-surface); box-shadow: 0 0 0 2px var(--tstt-border); }
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.stat-mini { background: var(--tstt-bg); border-radius: .5rem; padding: .5rem; }
.stat-mini b { display: block; font-size: 1.15rem; }
.stat-mini span { color: var(--tstt-muted); }
.tipo-badge { font-size: .7rem; font-weight: 700; padding: .15rem .4rem; border-radius: .3rem; }
.tipo-SELECT { background: #dbeafe; color: #1e40af; } .tipo-DML { background: #fee2e2; color: #991b1b; } .tipo-DDL { background: #1f2937; color: #fff; } .tipo-EXEC { background: #fef3c7; color: #92400e; } .tipo-OUTRO { background: #f3f4f6; color: #374151; }
.st-sucesso { color: #16a34a; } .st-erro { color: var(--tstt-red); } .st-bloqueado { color: #d97706; }
pre.detail { background: var(--tstt-bg); border: 1px solid var(--tstt-border); border-radius: .5rem; padding: .8rem; white-space: pre-wrap; font-size: .8rem; max-height: 50vh; overflow: auto; }
.toast { border-radius: .6rem; }

@media (max-width: 992px) {
  .sidebar { position: absolute; z-index: 1020; height: calc(100vh - 56px); box-shadow: 0 10px 30px rgba(0,0,0,.15); }
  .workspace:not(.sidebar-open) .sidebar { margin-left: -300px; }
  .brand-text { display: none; }
  .main { padding: .6rem; }
}

/* ---------------------------------------------------------- ajustes finos */
.side-item .t .status-dot { flex: 0 0 7px; }
.side-item .t small { flex: 0 0 auto; }
[data-bs-theme="dark"] .cm-s-default .cm-operator { color: #94a3b8; }
[data-bs-theme="dark"] .cm-s-default .cm-comment { color: #64748b; }
@media (max-width: 576px) {
  .main-title { font-size: 1rem; white-space: nowrap; }
  .main-head .badge-db:not(#connBadge) { display: none; }
  #connBadge { max-width: 150px; }
  .autosave-status span { display: none; }
  .topnav { gap: 0; }
  .toolbar .btn-exec small { display: none; }
  .editor-wrap { height: 220px; }
}

/* =====================================================================
   v1.1 — layout do editor: resultado sempre visível, divisória arrastável
   ===================================================================== */
.main { overflow-y: auto; overflow-x: hidden; padding: .75rem 1rem .75rem; gap: .5rem; }
.main-head { flex: 0 0 auto; }
.main-title { font-size: 1.15rem; }
.badge-db-muted { color: var(--tstt-muted); }
.tabs-bar { flex: 0 0 auto; border-bottom: 1px solid var(--tstt-border); }
.tab { padding: .38rem .75rem; font-size: .88rem; }
.tab.active { border-color: var(--tstt-border); border-top: 2px solid var(--tstt-navy); box-shadow: 0 1px 0 var(--tstt-surface); }
[data-bs-theme="dark"] .tab.active { border-top-color: #3b82f6; }

.toolbar { flex: 0 0 auto; gap: .35rem; padding: .35rem .4rem; background: var(--tstt-surface); border: 1px solid var(--tstt-border); border-radius: .55rem; }
.btn-exec { background: var(--tstt-navy); color: #fff; border: 0; padding: .42rem .95rem; font-weight: 600; border-radius: .45rem; display: inline-flex; align-items: center; gap: .35rem; }
.btn-exec:hover, .btn-exec:focus { background: var(--tstt-navy-dark); color: #fff; }
.btn-exec small { opacity: .7; font-weight: 400; font-size: .72rem; border: 1px solid rgba(255,255,255,.35); border-radius: .25rem; padding: 0 .3rem; }
.btn-exec.running { background: #64748b; }
.btn-exec:disabled { color: #fff; opacity: .85; }
[data-bs-theme="dark"] .btn-exec { background: #2563eb; }
.btn-tool { border: 1px solid transparent; background: transparent; color: var(--tstt-text); padding: .38rem .6rem; border-radius: .45rem; display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; }
.btn-tool:hover, .btn-tool.show { background: var(--tstt-soft); border-color: #bfdbfe; color: var(--tstt-navy); }
[data-bs-theme="dark"] .btn-tool:hover { border-color: #1e3a8a; color: #93c5fd; }
.btn-tool:disabled { opacity: .4; }
.btn-group > .btn-tool.dropdown-toggle-split { padding: .38rem .35rem; }
.tb-sep { width: 1px; align-self: stretch; background: var(--tstt-border); margin: 0 .2rem; }

.editor-wrap { flex: 0 0 auto; height: clamp(120px, 34vh, 420px); border: 1px solid var(--tstt-border); border-radius: .55rem; overflow: hidden; }
.resizer { flex: 0 0 10px; margin: -2px 0; }
.resizer::after { top: 3px; width: 56px; margin-left: -28px; }

.results { flex: 1 0 280px; min-height: 280px; border: 1px solid var(--tstt-border); border-radius: .55rem; background: var(--tstt-surface); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.results-head { flex: 0 0 auto; display: flex; align-items: center; gap: .6rem; padding: .35rem .6rem; background: var(--tstt-bg); border-bottom: 1px solid var(--tstt-border); flex-wrap: wrap; }
.res-tabs { list-style: none; margin: 0; padding: 0; display: flex; gap: .15rem; }
.res-tabs button { border: 0; background: transparent; padding: .35rem .65rem; border-radius: .4rem; color: var(--tstt-muted); font-weight: 500; font-size: .88rem; display: inline-flex; align-items: center; gap: .35rem; }
.res-tabs button:hover { background: var(--tstt-soft); }
.res-tabs button.active { background: var(--tstt-surface); color: var(--tstt-navy); box-shadow: 0 0 0 1px var(--tstt-border); }
[data-bs-theme="dark"] .res-tabs button.active { color: #93c5fd; }
.res-count { font-size: .72rem; background: var(--tstt-soft); color: var(--tstt-navy); border-radius: 1rem; padding: 0 .45rem; font-weight: 600; }
.res-count:empty { display: none; }
.res-count.err { background: #fee2e2; color: #991b1b; }
.results-filter { margin: 0; width: 220px; }
.results-alert { flex: 0 0 auto; margin: .5rem .6rem 0; }
.res-pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; position: relative; }
.res-pane[hidden] { display: none; }
.vgrid { flex: 1 1 auto; min-height: 160px; }
.vgrid[hidden] { display: none; }
.results-empty { margin: auto; padding: 1.5rem; }
.results-empty i { color: var(--tstt-sky); opacity: .9; }
.results-loading { margin: auto; color: var(--tstt-muted); display: flex; gap: .5rem; align-items: center; }
.results-error { margin: .75rem; flex: 0 0 auto; }
.results-foot { flex: 0 0 auto; }

.log-list { flex: 1 1 auto; overflow: auto; padding: .5rem .75rem; font-size: .85rem; }
.log-empty { color: var(--tstt-muted); padding: 1rem 0; }
.log-item { border-left: 3px solid var(--tstt-border); padding: .35rem .65rem; margin-bottom: .45rem; background: var(--tstt-bg); border-radius: 0 .4rem .4rem 0; }
.log-item.ok { border-left-color: #22c55e; } .log-item.erro { border-left-color: var(--tstt-red); } .log-item.alerta { border-left-color: #f59e0b; } .log-item.info { border-left-color: var(--tstt-sky); }
.log-item .lh { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.log-item .lt { font-family: var(--font-mono); font-size: .75rem; color: var(--tstt-muted); }
.log-item .lm { font-weight: 500; }
.log-item ul { margin: .25rem 0 0; padding-left: 1.1rem; color: var(--tstt-muted); font-size: .8rem; }
.log-item pre { margin: .35rem 0 0; background: var(--tstt-surface); border: 1px solid var(--tstt-border); border-radius: .35rem; padding: .5rem; font-size: .75rem; white-space: pre-wrap; max-height: 220px; overflow: auto; }
.log-item details summary { cursor: pointer; font-size: .78rem; color: var(--tstt-blue); margin-top: .2rem; }

.sidebar { width: 280px; flex-basis: 280px; }
.workspace.sidebar-hidden .sidebar { margin-left: -280px; }

@media (max-width: 992px) {
  .workspace:not(.sidebar-open) .sidebar { margin-left: -280px; }
  .tb-label { display: none; }
}
@media (max-width: 576px) {
  .results-filter { width: 100%; order: 10; }
  .res-actions { width: 100%; }
  .btn-exec small { display: none; }
}
.editor-wrap { height: clamp(110px, 28vh, 420px); }
.results { flex: 1 0 240px; min-height: 240px; }
.conn-item .conn-actions a { font-size: .95rem; padding: .1rem .25rem; border-radius: .3rem; }
.conn-item .conn-actions a:hover { background: var(--tstt-surface); }
@media (max-width: 768px) { .topnav .nav-label { display: none; } }
.sec-box { background: var(--tstt-bg); border: 1px dashed var(--tstt-border); border-radius: .5rem; padding: .75rem; font-family: var(--font-mono); font-size: .85rem; white-space: pre-wrap; }
.drop-zone { border: 2px dashed var(--tstt-border); border-radius: .75rem; padding: 1.5rem; text-align: center; color: var(--tstt-muted); cursor: pointer; transition: .15s; }
.drop-zone.over, .drop-zone:hover { border-color: var(--tstt-blue); background: var(--tstt-soft); color: var(--tstt-navy); }
.drop-zone i { font-size: 2rem; display: block; margin-bottom: .3rem; }
.diff-list { max-height: 220px; overflow: auto; font-family: var(--font-mono); font-size: .78rem; background: var(--tstt-bg); border-radius: .4rem; padding: .5rem .75rem; margin: 0; list-style: none; }
.diff-list li.n::before { content: "+ "; color: #16a34a; } .diff-list li.a::before { content: "~ "; color: #d97706; }
.env-ok { color: #16a34a; } .env-bad { color: var(--tstt-red); }
.main-title { white-space: nowrap; }
@media (max-width: 1100px) { .main-title, .badge-db-muted { display: none; } }

.travas { list-style: none; padding: 0; margin: 0; font-family: var(--bs-body-font-family); }
.travas li { display: flex; gap: .6rem; align-items: center; padding: .45rem .6rem; border-radius: .4rem; background: rgba(255,255,255,.6); margin-bottom: .35rem; color: var(--tstt-text); }
[data-bs-theme="dark"] .travas li { background: rgba(0,0,0,.2); }
.travas li.ok i { color: #16a34a; } .travas li.nok i { color: var(--tstt-red); }
.travas li .small { color: var(--tstt-muted); }
.results-error:has(.travas) { white-space: normal; }
